diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TCharacter.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TCharacter.java index 488e1c541..122689df5 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TCharacter.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TCharacter.java @@ -242,7 +242,7 @@ public class TCharacter extends TObject implements TComparable { return toLowerCaseSystem(codePoint); } - @Import(module = "runtime", name = "towlower") + @Import(module = "runtime", name = "tolower") private static native int toLowerCaseSystem(int codePoint); public static char toUpperCase(char ch) { @@ -258,7 +258,7 @@ public class TCharacter extends TObject implements TComparable { return toUpperCaseSystem(codePoint); } - @Import(module = "runtime", name = "towupper") + @Import(module = "runtime", name = "toupper") private static native int toUpperCaseSystem(int codePoint); public static int digit(char ch, int radix) { diff --git a/core/src/main/java/org/teavm/backend/wasm/WasmTarget.java b/core/src/main/java/org/teavm/backend/wasm/WasmTarget.java index 22af8563c..83361c23c 100644 --- a/core/src/main/java/org/teavm/backend/wasm/WasmTarget.java +++ b/core/src/main/java/org/teavm/backend/wasm/WasmTarget.java @@ -398,7 +398,7 @@ public class WasmTarget implements TeaVMTarget, TeaVMWasmHost { private class IntrinsicFactoryContext implements WasmIntrinsicFactoryContext { private ListableClassReaderSource classSource; - public IntrinsicFactoryContext(ListableClassReaderSource classSource) { + IntrinsicFactoryContext(ListableClassReaderSource classSource) { this.classSource = classSource; } @@ -610,7 +610,7 @@ public class WasmTarget implements TeaVMTarget, TeaVMWasmHost { body.add(new WasmReturn(itemTest)); } - private WasmFunction generateStub(WasmModule module, MethodHolder method, MethodHolder implementor) { + private void generateStub(WasmModule module, MethodHolder method, MethodHolder implementor) { WasmFunction function = module.getFunctions().get(WasmMangling.mangleMethod(method.getReference())); WasmCall call = new WasmCall(WasmMangling.mangleMethod(implementor.getReference())); @@ -625,7 +625,6 @@ public class WasmTarget implements TeaVMTarget, TeaVMWasmHost { } else { function.getBody().add(new WasmReturn(call)); } - return function; } private void renderClinit(ListableClassReaderSource classes, WasmClassGenerator classGenerator, diff --git a/core/src/main/java/org/teavm/backend/wasm/render/WasmBinaryRenderer.java b/core/src/main/java/org/teavm/backend/wasm/render/WasmBinaryRenderer.java index 2b27f1779..0ef320d54 100644 --- a/core/src/main/java/org/teavm/backend/wasm/render/WasmBinaryRenderer.java +++ b/core/src/main/java/org/teavm/backend/wasm/render/WasmBinaryRenderer.java @@ -16,6 +16,7 @@ package org.teavm.backend.wasm.render; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -47,7 +48,6 @@ public class WasmBinaryRenderer { private WasmBinaryVersion version; private List signatures = new ArrayList<>(); private Map signatureIndexes = new HashMap<>(); - private Map importIndexes = new HashMap<>(); private Map functionIndexes = new HashMap<>(); public WasmBinaryRenderer(WasmBinaryWriter output, WasmBinaryVersion version) { @@ -106,7 +106,6 @@ public class WasmBinaryRenderer { } private void renderImports(WasmModule module) { - int index = 0; List functions = new ArrayList<>(); for (WasmFunction function : module.getFunctions().values()) { if (function.getImportName() == null) { @@ -332,17 +331,21 @@ public class WasmBinaryRenderer { private void renderNames(WasmModule module) { WasmBinaryWriter section = new WasmBinaryWriter(); - List functions = module.getFunctions().values().stream() - .filter(function -> function.getImportName() == null) - .collect(Collectors.toList()); + WasmBinaryWriter functionsSubsection = new WasmBinaryWriter(); + Collection functions = module.getFunctions().values(); - section.writeLEB(functions.size()); + functionsSubsection.writeLEB(functions.size()); for (WasmFunction function : functions) { - section.writeAsciiString(function.getName()); - section.writeLEB(0); + functionsSubsection.writeLEB(functionIndexes.get(function.getName())); + functionsSubsection.writeAsciiString(function.getName()); } + byte[] payload = functionsSubsection.getData(); + section.writeLEB(1); + section.writeLEB(payload.length); + section.writeBytes(payload); + writeSection(SECTION_UNKNOWN, "name", section.getData()); } @@ -350,7 +353,7 @@ public class WasmBinaryRenderer { WasmType type; int count = 1; - public LocalEntry(WasmType type) { + LocalEntry(WasmType type) { this.type = type; } }