mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Add resolving of JSR opcode
This commit is contained in:
parent
c546af553b
commit
cff91e03ff
|
@ -19,6 +19,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
import org.objectweb.asm.Type;
|
import org.objectweb.asm.Type;
|
||||||
|
import org.objectweb.asm.commons.JSRInlinerAdapter;
|
||||||
import org.objectweb.asm.tree.*;
|
import org.objectweb.asm.tree.*;
|
||||||
import org.teavm.model.*;
|
import org.teavm.model.*;
|
||||||
import org.teavm.optimization.UnreachableBasicBlockEliminator;
|
import org.teavm.optimization.UnreachableBasicBlockEliminator;
|
||||||
|
@ -32,6 +33,12 @@ public final class Parser {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MethodHolder parseMethod(MethodNode node, String className, String fileName) {
|
public static MethodHolder parseMethod(MethodNode node, String className, String fileName) {
|
||||||
|
MethodNode nodeWithoutJsr = new MethodNode(Opcodes.ASM5, node.access, node.name, node.desc, node.signature,
|
||||||
|
node.exceptions.toArray(new String[0]));
|
||||||
|
JSRInlinerAdapter adapter = new JSRInlinerAdapter(nodeWithoutJsr, node.access, node.name, node.desc,
|
||||||
|
node.signature, node.exceptions.toArray(new String[0]));
|
||||||
|
node.accept(adapter);
|
||||||
|
node = nodeWithoutJsr;
|
||||||
ValueType[] signature = MethodDescriptor.parseSignature(node.desc);
|
ValueType[] signature = MethodDescriptor.parseSignature(node.desc);
|
||||||
MethodHolder method = new MethodHolder(node.name, signature);
|
MethodHolder method = new MethodHolder(node.name, signature);
|
||||||
parseModifiers(node.access, method);
|
parseModifiers(node.access, method);
|
||||||
|
@ -59,8 +66,8 @@ public final class Parser {
|
||||||
cls.setParent(null);
|
cls.setParent(null);
|
||||||
}
|
}
|
||||||
if (node.interfaces != null) {
|
if (node.interfaces != null) {
|
||||||
for (Object obj : node.interfaces) {
|
for (String iface : node.interfaces) {
|
||||||
cls.getInterfaces().add(((String)obj).replace('/', '.'));
|
cls.getInterfaces().add(iface.replace('/', '.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Object obj : node.fields) {
|
for (Object obj : node.fields) {
|
||||||
|
@ -68,8 +75,7 @@ public final class Parser {
|
||||||
cls.addField(parseField(fieldNode));
|
cls.addField(parseField(fieldNode));
|
||||||
}
|
}
|
||||||
String fullFileName = node.name.substring(0, node.name.lastIndexOf('/') + 1) + node.sourceFile;
|
String fullFileName = node.name.substring(0, node.name.lastIndexOf('/') + 1) + node.sourceFile;
|
||||||
for (Object obj : node.methods) {
|
for (MethodNode methodNode : node.methods) {
|
||||||
MethodNode methodNode = (MethodNode)obj;
|
|
||||||
cls.addMethod(parseMethod(methodNode, node.name, fullFileName));
|
cls.addMethod(parseMethod(methodNode, node.name, fullFileName));
|
||||||
}
|
}
|
||||||
if (node.outerClass != null) {
|
if (node.outerClass != null) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user