mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
WASM: fix name section
This commit is contained in:
parent
3d7224d47a
commit
b8b3aa7a53
|
@ -242,7 +242,7 @@ public class TCharacter extends TObject implements TComparable<TCharacter> {
|
|||
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<TCharacter> {
|
|||
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) {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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<WasmSignature> signatures = new ArrayList<>();
|
||||
private Map<WasmSignature, Integer> signatureIndexes = new HashMap<>();
|
||||
private Map<String, Integer> importIndexes = new HashMap<>();
|
||||
private Map<String, Integer> 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<WasmFunction> 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<WasmFunction> functions = module.getFunctions().values().stream()
|
||||
.filter(function -> function.getImportName() == null)
|
||||
.collect(Collectors.toList());
|
||||
WasmBinaryWriter functionsSubsection = new WasmBinaryWriter();
|
||||
Collection<WasmFunction> 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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user