-
Notifications
You must be signed in to change notification settings - Fork 0
/
HierarchyScanner.java
47 lines (41 loc) · 1.43 KB
/
HierarchyScanner.java
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
package bridge.asm;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
public class HierarchyScanner extends ClassVisitor {
protected final TypeMap types;
protected int access;
protected Type type;
private KnownType compiled;
protected String extended;
protected String[] implemented;
protected Object data;
public HierarchyScanner(TypeMap types) {
super(Opcodes.ASM9);
this.types = types;
}
@Override
public void visit(int version, int access, String name, String signature, String extended, String[] implemented) {
this.access = access;
this.type = Type.getObjectType(name);
this.extended = extended;
this.implemented = implemented;
}
@Override
public void visitEnd() {
super.visitEnd();
compile().data = data;
}
protected final KnownType compile() {
KnownType type;
if ((type = compiled) == null) {
if (this.type == null) throw new IllegalStateException("Called to compile() before visit()");
type = compiled = types.map.computeIfAbsent(this.type, KnownType::new);
type.extended = (extended == null)? types.get(Object.class) : types.loadClass(extended);
type.implemented = types.loadClass(implemented);
type.access = access;
type.data = data;
}
return type;
}
}