mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-23 23:04:50 -08:00
WASM: fix remaining errors in WebAssembly 0xC
This commit is contained in:
parent
56b1f54dda
commit
d6cc340676
|
@ -353,13 +353,12 @@ public class WasmTarget implements TeaVMTarget {
|
||||||
initFunction.getBody().add(new WasmCall(WasmMangling.mangleInitializer(className)));
|
initFunction.getBody().add(new WasmCall(WasmMangling.mangleInitializer(className)));
|
||||||
}
|
}
|
||||||
module.add(initFunction);
|
module.add(initFunction);
|
||||||
//module.setStartFunction(initFunction);
|
module.setStartFunction(initFunction);
|
||||||
|
|
||||||
for (TeaVMEntryPoint entryPoint : controller.getEntryPoints().values()) {
|
for (TeaVMEntryPoint entryPoint : controller.getEntryPoints().values()) {
|
||||||
String mangledName = WasmMangling.mangleMethod(entryPoint.getReference());
|
String mangledName = WasmMangling.mangleMethod(entryPoint.getReference());
|
||||||
WasmFunction function = module.getFunctions().get(mangledName);
|
WasmFunction function = module.getFunctions().get(mangledName);
|
||||||
if (function != null) {
|
if (function != null) {
|
||||||
function.getBody().add(0, new WasmCall(initFunction.getName()));
|
|
||||||
function.setExportName(entryPoint.getPublicName());
|
function.setExportName(entryPoint.getPublicName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1226,7 +1226,6 @@ class WasmGenerationVisitor implements StatementVisitor, ExprVisitor {
|
||||||
WasmIntBinaryOperation.GT_SIGNED, new WasmGetLocal(tagVar),
|
WasmIntBinaryOperation.GT_SIGNED, new WasmGetLocal(tagVar),
|
||||||
new WasmInt32Constant(ranges.get(i - 1).upper));
|
new WasmInt32Constant(ranges.get(i - 1).upper));
|
||||||
WasmConditional conditional = new WasmConditional(upperThanExcluded);
|
WasmConditional conditional = new WasmConditional(upperThanExcluded);
|
||||||
conditional.setType(WasmType.INT32);
|
|
||||||
WasmExpression lowerThanExcluded = new WasmIntBinary(WasmIntType.INT32,
|
WasmExpression lowerThanExcluded = new WasmIntBinary(WasmIntType.INT32,
|
||||||
WasmIntBinaryOperation.LT_SIGNED, new WasmGetLocal(tagVar),
|
WasmIntBinaryOperation.LT_SIGNED, new WasmGetLocal(tagVar),
|
||||||
new WasmInt32Constant(ranges.get(i).lower));
|
new WasmInt32Constant(ranges.get(i).lower));
|
||||||
|
|
|
@ -70,16 +70,17 @@ class WasmBinaryRenderingVisitor implements WasmExpressionVisitor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(WasmBlock expression) {
|
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);
|
blockDepths.put(expression, depth);
|
||||||
writer.writeByte(expression.isLoop() ? 0x02 : 0x01);
|
writer.writeByte(expression.isLoop() ? 0x02 : 0x01);
|
||||||
writeBlockType(expression.getType());
|
writeBlockType(expression.getType());
|
||||||
for (WasmExpression part : expression.getBody()) {
|
for (WasmExpression part : expression.getBody()) {
|
||||||
part.acceptVisitor(this);
|
part.acceptVisitor(this);
|
||||||
}
|
}
|
||||||
writer.writeByte(0x0F);
|
writer.writeByte(0x0F);
|
||||||
blockDepths.remove(expression);
|
blockDepths.remove(expression);
|
||||||
depth -= expression.isLoop() ? 2 : 1;
|
depth -= blockDepth;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeBlockType(WasmType type) {
|
private void writeBlockType(WasmType type) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user