1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
package cuchaz.enigma.analysis;
import cuchaz.enigma.bytecode.AccessFlags;
import cuchaz.enigma.mapping.MethodDescriptor;
import cuchaz.enigma.mapping.Signature;
import cuchaz.enigma.mapping.entry.ClassEntry;
import cuchaz.enigma.mapping.entry.MethodDefEntry;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;
public class IndexReferenceVisitor extends ClassVisitor {
private final JarIndex index;
private ClassEntry classEntry;
public IndexReferenceVisitor(JarIndex index, int api) {
super(api);
this.index = index;
}
@Override
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
this.classEntry = new ClassEntry(name);
}
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
MethodDefEntry entry = new MethodDefEntry(classEntry, name, new MethodDescriptor(desc), Signature.createSignature(signature), new AccessFlags(access));
return new Method(this.index, entry, this.api);
}
private class Method extends MethodVisitor {
private final JarIndex index;
private final MethodDefEntry callerEntry;
public Method(JarIndex index, MethodDefEntry callerEntry, int api) {
super(api);
this.index = index;
this.callerEntry = callerEntry;
}
@Override
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
this.index.indexFieldAccess(callerEntry, owner, name, desc);
}
@Override
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
this.index.indexMethodCall(callerEntry, owner, name, desc);
}
}
}
|