WASM: fix remaining errors in WebAssembly 0xC

This commit is contained in:
Alexey Andreev 2016-10-14 22:32:12 +03:00
parent 56b1f54dda
commit d6cc340676
3 changed files with 5 additions and 6 deletions

View File

@ -353,13 +353,12 @@ public class WasmTarget implements TeaVMTarget {
initFunction.getBody().add(new WasmCall(WasmMangling.mangleInitializer(className)));
}
module.add(initFunction);
//module.setStartFunction(initFunction);
module.setStartFunction(initFunction);
for (TeaVMEntryPoint entryPoint : controller.getEntryPoints().values()) {
String mangledName = WasmMangling.mangleMethod(entryPoint.getReference());
WasmFunction function = module.getFunctions().get(mangledName);
if (function != null) {
function.getBody().add(0, new WasmCall(initFunction.getName()));
function.setExportName(entryPoint.getPublicName());
}
}

View File

@ -1226,7 +1226,6 @@ class WasmGenerationVisitor implements StatementVisitor, ExprVisitor {
WasmIntBinaryOperation.GT_SIGNED, new WasmGetLocal(tagVar),
new WasmInt32Constant(ranges.get(i - 1).upper));
WasmConditional conditional = new WasmConditional(upperThanExcluded);
conditional.setType(WasmType.INT32);
WasmExpression lowerThanExcluded = new WasmIntBinary(WasmIntType.INT32,
WasmIntBinaryOperation.LT_SIGNED, new WasmGetLocal(tagVar),
new WasmInt32Constant(ranges.get(i).lower));

View File

@ -70,16 +70,17 @@ class WasmBinaryRenderingVisitor implements WasmExpressionVisitor {
@Override
public void visit(WasmBlock expression) {
depth += expression.isLoop() ? 2 : 1;
int blockDepth = expression.isLoop() & version == WasmBinaryVersion.V_0xB ? 2 : 1;
depth += blockDepth;
blockDepths.put(expression, depth);
writer.writeByte(expression.isLoop() ? 0x02 : 0x01);
writer.writeByte(expression.isLoop() ? 0x02 : 0x01);
writeBlockType(expression.getType());
for (WasmExpression part : expression.getBody()) {
part.acceptVisitor(this);
}
writer.writeByte(0x0F);
blockDepths.remove(expression);
depth -= expression.isLoop() ? 2 : 1;
depth -= blockDepth;
}
private void writeBlockType(WasmType type) {