diff options
Diffstat (limited to 'src/main/java/cuchaz')
| -rw-r--r-- | src/main/java/cuchaz/enigma/analysis/IndexReferenceVisitor.java | 26 | ||||
| -rw-r--r-- | src/main/java/cuchaz/enigma/analysis/SourceIndexMethodVisitor.java | 23 |
2 files changed, 49 insertions, 0 deletions
diff --git a/src/main/java/cuchaz/enigma/analysis/IndexReferenceVisitor.java b/src/main/java/cuchaz/enigma/analysis/IndexReferenceVisitor.java index c05281bd..f37f1e90 100644 --- a/src/main/java/cuchaz/enigma/analysis/IndexReferenceVisitor.java +++ b/src/main/java/cuchaz/enigma/analysis/IndexReferenceVisitor.java | |||
| @@ -6,7 +6,9 @@ import cuchaz.enigma.mapping.Signature; | |||
| 6 | import cuchaz.enigma.mapping.entry.ClassEntry; | 6 | import cuchaz.enigma.mapping.entry.ClassEntry; |
| 7 | import cuchaz.enigma.mapping.entry.MethodDefEntry; | 7 | import cuchaz.enigma.mapping.entry.MethodDefEntry; |
| 8 | import org.objectweb.asm.ClassVisitor; | 8 | import org.objectweb.asm.ClassVisitor; |
| 9 | import org.objectweb.asm.Handle; | ||
| 9 | import org.objectweb.asm.MethodVisitor; | 10 | import org.objectweb.asm.MethodVisitor; |
| 11 | import org.objectweb.asm.Opcodes; | ||
| 10 | 12 | ||
| 11 | public class IndexReferenceVisitor extends ClassVisitor { | 13 | public class IndexReferenceVisitor extends ClassVisitor { |
| 12 | private final JarIndex index; | 14 | private final JarIndex index; |
| @@ -47,5 +49,29 @@ public class IndexReferenceVisitor extends ClassVisitor { | |||
| 47 | public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { | 49 | public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { |
| 48 | this.index.indexMethodCall(callerEntry, owner, name, desc); | 50 | this.index.indexMethodCall(callerEntry, owner, name, desc); |
| 49 | } | 51 | } |
| 52 | |||
| 53 | @Override | ||
| 54 | public void visitInvokeDynamicInsn(String name, String desc, Handle bsm, Object... bsmArgs) { | ||
| 55 | for (Object bsmArg : bsmArgs){ | ||
| 56 | if (bsmArg instanceof Handle){ | ||
| 57 | Handle handle = (Handle)bsmArg; | ||
| 58 | switch (handle.getTag()){ | ||
| 59 | case Opcodes.H_GETFIELD: | ||
| 60 | case Opcodes.H_GETSTATIC: | ||
| 61 | case Opcodes.H_PUTFIELD: | ||
| 62 | case Opcodes.H_PUTSTATIC: | ||
| 63 | this.index.indexFieldAccess(callerEntry, handle.getOwner(), handle.getName(), handle.getDesc()); | ||
| 64 | break; | ||
| 65 | case Opcodes.H_INVOKEINTERFACE: | ||
| 66 | case Opcodes.H_INVOKESPECIAL: | ||
| 67 | case Opcodes.H_INVOKESTATIC: | ||
| 68 | case Opcodes.H_INVOKEVIRTUAL: | ||
| 69 | case Opcodes.H_NEWINVOKESPECIAL: | ||
| 70 | this.index.indexMethodCall(callerEntry, handle.getOwner(), handle.getName(), handle.getDesc()); | ||
| 71 | break; | ||
| 72 | } | ||
| 73 | } | ||
| 74 | } | ||
| 75 | } | ||
| 50 | } | 76 | } |
| 51 | } | 77 | } |
diff --git a/src/main/java/cuchaz/enigma/analysis/SourceIndexMethodVisitor.java b/src/main/java/cuchaz/enigma/analysis/SourceIndexMethodVisitor.java index cc2c331f..83fe296c 100644 --- a/src/main/java/cuchaz/enigma/analysis/SourceIndexMethodVisitor.java +++ b/src/main/java/cuchaz/enigma/analysis/SourceIndexMethodVisitor.java | |||
| @@ -198,4 +198,27 @@ public class SourceIndexMethodVisitor extends SourceIndexVisitor { | |||
| 198 | } | 198 | } |
| 199 | return recurse(node, index); | 199 | return recurse(node, index); |
| 200 | } | 200 | } |
| 201 | |||
| 202 | @Override | ||
| 203 | public Void visitMethodGroupExpression(MethodGroupExpression node, SourceIndex index) { | ||
| 204 | MemberReference ref = node.getUserData(Keys.MEMBER_REFERENCE); | ||
| 205 | |||
| 206 | if (ref instanceof MethodReference) { | ||
| 207 | // get the behavior entry | ||
| 208 | ClassEntry classEntry = entryPool.getClass(ref.getDeclaringType().getInternalName()); | ||
| 209 | MethodEntry methodEntry = null; | ||
| 210 | |||
| 211 | methodEntry = entryPool.getMethod(classEntry, ref.getName(), ref.getErasedSignature()); | ||
| 212 | // get the node for the token | ||
| 213 | AstNode tokenNode = node.getMethodNameToken(); | ||
| 214 | if (tokenNode == null || (tokenNode.getRegion().getBeginLine() == 0 || tokenNode.getRegion().getEndLine() == 0)){ | ||
| 215 | tokenNode = node.getTarget(); | ||
| 216 | } | ||
| 217 | if (tokenNode != null) { | ||
| 218 | index.addReference(tokenNode, methodEntry, this.methodEntry); | ||
| 219 | } | ||
| 220 | } | ||
| 221 | |||
| 222 | return recurse(node, index); | ||
| 223 | } | ||
| 201 | } | 224 | } |