mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Switch to asm4
This commit is contained in:
parent
b144d474f2
commit
45fe202740
|
@ -24,7 +24,7 @@ import org.teavm.model.ClassReader;
|
||||||
*
|
*
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
class JCLComparisonVisitor implements ClassVisitor {
|
class JCLComparisonVisitor extends ClassVisitor {
|
||||||
private Map<String, JCLPackage> packageMap;
|
private Map<String, JCLPackage> packageMap;
|
||||||
private ClassReaderSource classSource;
|
private ClassReaderSource classSource;
|
||||||
private ClassReader classReader;
|
private ClassReader classReader;
|
||||||
|
@ -32,6 +32,7 @@ class JCLComparisonVisitor implements ClassVisitor {
|
||||||
private JCLClass jclClass;
|
private JCLClass jclClass;
|
||||||
|
|
||||||
public JCLComparisonVisitor(ClassReaderSource classSource, Map<String, JCLPackage> packageMap) {
|
public JCLComparisonVisitor(ClassReaderSource classSource, Map<String, JCLPackage> packageMap) {
|
||||||
|
super(Opcodes.ASM4);
|
||||||
this.classSource = classSource;
|
this.classSource = classSource;
|
||||||
this.packageMap = packageMap;
|
this.packageMap = packageMap;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,9 +37,9 @@
|
||||||
<version>2.4</version>
|
<version>2.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>asm</groupId>
|
<groupId>org.ow2.asm</groupId>
|
||||||
<artifactId>asm-debug-all</artifactId>
|
<artifactId>asm-debug-all</artifactId>
|
||||||
<version>3.3.1</version>
|
<version>4.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ public final class Parser {
|
||||||
SSATransformer ssaProducer = new SSATransformer();
|
SSATransformer ssaProducer = new SSATransformer();
|
||||||
ssaProducer.transformToSSA(program, method.getParameterTypes());
|
ssaProducer.transformToSSA(program, method.getParameterTypes());
|
||||||
method.setProgram(program);
|
method.setProgram(program);
|
||||||
parseAnnotations(method.getAnnotations(), node);
|
parseAnnotations(method.getAnnotations(), node.visibleAnnotations, node.invisibleAnnotations);
|
||||||
while (program.variableCount() <= method.parameterCount()) {
|
while (program.variableCount() <= method.parameterCount()) {
|
||||||
program.createVariable();
|
program.createVariable();
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ public final class Parser {
|
||||||
cls.setOwnerName(node.name.substring(0, lastIndex).replace('/', '.'));
|
cls.setOwnerName(node.name.substring(0, lastIndex).replace('/', '.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parseAnnotations(cls.getAnnotations(), node);
|
parseAnnotations(cls.getAnnotations(), node.visibleAnnotations, node.invisibleAnnotations);
|
||||||
return cls;
|
return cls;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ public final class Parser {
|
||||||
field.setType(ValueType.parse(node.desc));
|
field.setType(ValueType.parse(node.desc));
|
||||||
field.setInitialValue(node.value);
|
field.setInitialValue(node.value);
|
||||||
parseModifiers(node.access, field);
|
parseModifiers(node.access, field);
|
||||||
parseAnnotations(field.getAnnotations(), node);
|
parseAnnotations(field.getAnnotations(), node.visibleAnnotations, node.invisibleAnnotations);
|
||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,14 +147,14 @@ public final class Parser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
private static void parseAnnotations(AnnotationContainer annotations, List<AnnotationNode> visibleAnnotations,
|
||||||
private static void parseAnnotations(AnnotationContainer annotations, MemberNode node) {
|
List<AnnotationNode> invisibleAnnotations) {
|
||||||
List<Object> annotNodes = new ArrayList<>();
|
List<Object> annotNodes = new ArrayList<>();
|
||||||
if (node.visibleAnnotations != null) {
|
if (visibleAnnotations != null) {
|
||||||
annotNodes.addAll(node.visibleAnnotations);
|
annotNodes.addAll(visibleAnnotations);
|
||||||
}
|
}
|
||||||
if (node.invisibleAnnotations != null) {
|
if (invisibleAnnotations != null) {
|
||||||
annotNodes.addAll(node.invisibleAnnotations);
|
annotNodes.addAll(invisibleAnnotations);
|
||||||
}
|
}
|
||||||
for (Object obj : annotNodes) {
|
for (Object obj : annotNodes) {
|
||||||
AnnotationNode annotNode = (AnnotationNode)obj;
|
AnnotationNode annotNode = (AnnotationNode)obj;
|
||||||
|
@ -180,7 +180,6 @@ public final class Parser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private static AnnotationValue parseAnnotationValue(Object value) {
|
private static AnnotationValue parseAnnotationValue(Object value) {
|
||||||
if (value instanceof String[]) {
|
if (value instanceof String[]) {
|
||||||
String[] enumInfo = (String[])value;
|
String[] enumInfo = (String[])value;
|
||||||
|
|
|
@ -296,7 +296,8 @@ public class ProgramParser {
|
||||||
return local;
|
return local;
|
||||||
}
|
}
|
||||||
|
|
||||||
private MethodVisitor methodVisitor = new MethodVisitor() {
|
// TODO: invokedynamic support (a great task, involving not only parser, but every layer of TeaVM)
|
||||||
|
private MethodVisitor methodVisitor = new MethodVisitor(Opcodes.ASM4) {
|
||||||
@Override
|
@Override
|
||||||
public void visitVarInsn(int opcode, int local) {
|
public void visitVarInsn(int opcode, int local) {
|
||||||
switch (opcode) {
|
switch (opcode) {
|
||||||
|
@ -373,7 +374,7 @@ public class ProgramParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitTableSwitchInsn(int min, int max, Label dflt, Label[] labels) {
|
public void visitTableSwitchInsn(int min, int max, Label dflt, Label... labels) {
|
||||||
SwitchTableEntry[] table = new SwitchTableEntry[labels.length];
|
SwitchTableEntry[] table = new SwitchTableEntry[labels.length];
|
||||||
nextIndexes = new int[labels.length + 1];
|
nextIndexes = new int[labels.length + 1];
|
||||||
for (int i = 0; i < labels.length; ++i) {
|
for (int i = 0; i < labels.length; ++i) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user