mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-23 00:24:11 -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);
|
return toLowerCaseSystem(codePoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Import(module = "runtime", name = "towlower")
|
@Import(module = "runtime", name = "tolower")
|
||||||
private static native int toLowerCaseSystem(int codePoint);
|
private static native int toLowerCaseSystem(int codePoint);
|
||||||
|
|
||||||
public static char toUpperCase(char ch) {
|
public static char toUpperCase(char ch) {
|
||||||
|
@ -258,7 +258,7 @@ public class TCharacter extends TObject implements TComparable<TCharacter> {
|
||||||
return toUpperCaseSystem(codePoint);
|
return toUpperCaseSystem(codePoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Import(module = "runtime", name = "towupper")
|
@Import(module = "runtime", name = "toupper")
|
||||||
private static native int toUpperCaseSystem(int codePoint);
|
private static native int toUpperCaseSystem(int codePoint);
|
||||||
|
|
||||||
public static int digit(char ch, int radix) {
|
public static int digit(char ch, int radix) {
|
||||||
|
|
|
@ -398,7 +398,7 @@ public class WasmTarget implements TeaVMTarget, TeaVMWasmHost {
|
||||||
private class IntrinsicFactoryContext implements WasmIntrinsicFactoryContext {
|
private class IntrinsicFactoryContext implements WasmIntrinsicFactoryContext {
|
||||||
private ListableClassReaderSource classSource;
|
private ListableClassReaderSource classSource;
|
||||||
|
|
||||||
public IntrinsicFactoryContext(ListableClassReaderSource classSource) {
|
IntrinsicFactoryContext(ListableClassReaderSource classSource) {
|
||||||
this.classSource = classSource;
|
this.classSource = classSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -610,7 +610,7 @@ public class WasmTarget implements TeaVMTarget, TeaVMWasmHost {
|
||||||
body.add(new WasmReturn(itemTest));
|
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()));
|
WasmFunction function = module.getFunctions().get(WasmMangling.mangleMethod(method.getReference()));
|
||||||
|
|
||||||
WasmCall call = new WasmCall(WasmMangling.mangleMethod(implementor.getReference()));
|
WasmCall call = new WasmCall(WasmMangling.mangleMethod(implementor.getReference()));
|
||||||
|
@ -625,7 +625,6 @@ public class WasmTarget implements TeaVMTarget, TeaVMWasmHost {
|
||||||
} else {
|
} else {
|
||||||
function.getBody().add(new WasmReturn(call));
|
function.getBody().add(new WasmReturn(call));
|
||||||
}
|
}
|
||||||
return function;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderClinit(ListableClassReaderSource classes, WasmClassGenerator classGenerator,
|
private void renderClinit(ListableClassReaderSource classes, WasmClassGenerator classGenerator,
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
package org.teavm.backend.wasm.render;
|
package org.teavm.backend.wasm.render;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -47,7 +48,6 @@ public class WasmBinaryRenderer {
|
||||||
private WasmBinaryVersion version;
|
private WasmBinaryVersion version;
|
||||||
private List<WasmSignature> signatures = new ArrayList<>();
|
private List<WasmSignature> signatures = new ArrayList<>();
|
||||||
private Map<WasmSignature, Integer> signatureIndexes = new HashMap<>();
|
private Map<WasmSignature, Integer> signatureIndexes = new HashMap<>();
|
||||||
private Map<String, Integer> importIndexes = new HashMap<>();
|
|
||||||
private Map<String, Integer> functionIndexes = new HashMap<>();
|
private Map<String, Integer> functionIndexes = new HashMap<>();
|
||||||
|
|
||||||
public WasmBinaryRenderer(WasmBinaryWriter output, WasmBinaryVersion version) {
|
public WasmBinaryRenderer(WasmBinaryWriter output, WasmBinaryVersion version) {
|
||||||
|
@ -106,7 +106,6 @@ public class WasmBinaryRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderImports(WasmModule module) {
|
private void renderImports(WasmModule module) {
|
||||||
int index = 0;
|
|
||||||
List<WasmFunction> functions = new ArrayList<>();
|
List<WasmFunction> functions = new ArrayList<>();
|
||||||
for (WasmFunction function : module.getFunctions().values()) {
|
for (WasmFunction function : module.getFunctions().values()) {
|
||||||
if (function.getImportName() == null) {
|
if (function.getImportName() == null) {
|
||||||
|
@ -332,17 +331,21 @@ public class WasmBinaryRenderer {
|
||||||
private void renderNames(WasmModule module) {
|
private void renderNames(WasmModule module) {
|
||||||
WasmBinaryWriter section = new WasmBinaryWriter();
|
WasmBinaryWriter section = new WasmBinaryWriter();
|
||||||
|
|
||||||
List<WasmFunction> functions = module.getFunctions().values().stream()
|
WasmBinaryWriter functionsSubsection = new WasmBinaryWriter();
|
||||||
.filter(function -> function.getImportName() == null)
|
Collection<WasmFunction> functions = module.getFunctions().values();
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
section.writeLEB(functions.size());
|
functionsSubsection.writeLEB(functions.size());
|
||||||
|
|
||||||
for (WasmFunction function : functions) {
|
for (WasmFunction function : functions) {
|
||||||
section.writeAsciiString(function.getName());
|
functionsSubsection.writeLEB(functionIndexes.get(function.getName()));
|
||||||
section.writeLEB(0);
|
functionsSubsection.writeAsciiString(function.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
byte[] payload = functionsSubsection.getData();
|
||||||
|
section.writeLEB(1);
|
||||||
|
section.writeLEB(payload.length);
|
||||||
|
section.writeBytes(payload);
|
||||||
|
|
||||||
writeSection(SECTION_UNKNOWN, "name", section.getData());
|
writeSection(SECTION_UNKNOWN, "name", section.getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,7 +353,7 @@ public class WasmBinaryRenderer {
|
||||||
WasmType type;
|
WasmType type;
|
||||||
int count = 1;
|
int count = 1;
|
||||||
|
|
||||||
public LocalEntry(WasmType type) {
|
LocalEntry(WasmType type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user