1010import java .util .List ;
1111
1212public class Frame {
13- protected int opcode ;
13+ private static final String ILLEGAL_OPCODE = "<illegal opcode>" ;
14+
15+ private static final String [] OPCODE_NAMES = {
16+ "nop" , "aconst_null" , "iconst_m1" , "iconst_0" , "iconst_1" ,
17+ "iconst_2" , "iconst_3" , "iconst_4" , "iconst_5" , "lconst_0" ,
18+ "lconst_1" , "fconst_0" , "fconst_1" , "fconst_2" , "dconst_0" ,
19+ "dconst_1" , "bipush" , "sipush" , "ldc" , "ldc_w" , "ldc2_w" , "iload" ,
20+ "lload" , "fload" , "dload" , "aload" , "iload_0" , "iload_1" , "iload_2" ,
21+ "iload_3" , "lload_0" , "lload_1" , "lload_2" , "lload_3" , "fload_0" ,
22+ "fload_1" , "fload_2" , "fload_3" , "dload_0" , "dload_1" , "dload_2" ,
23+ "dload_3" , "aload_0" , "aload_1" , "aload_2" , "aload_3" , "iaload" ,
24+ "laload" , "faload" , "daload" , "aaload" , "baload" , "caload" , "saload" ,
25+ "istore" , "lstore" , "fstore" , "dstore" , "astore" , "istore_0" ,
26+ "istore_1" , "istore_2" , "istore_3" , "lstore_0" , "lstore_1" ,
27+ "lstore_2" , "lstore_3" , "fstore_0" , "fstore_1" , "fstore_2" ,
28+ "fstore_3" , "dstore_0" , "dstore_1" , "dstore_2" , "dstore_3" ,
29+ "astore_0" , "astore_1" , "astore_2" , "astore_3" , "iastore" , "lastore" ,
30+ "fastore" , "dastore" , "aastore" , "bastore" , "castore" , "sastore" ,
31+ "pop" , "pop2" , "dup" , "dup_x1" , "dup_x2" , "dup2" , "dup2_x1" ,
32+ "dup2_x2" , "swap" , "iadd" , "ladd" , "fadd" , "dadd" , "isub" , "lsub" ,
33+ "fsub" , "dsub" , "imul" , "lmul" , "fmul" , "dmul" , "idiv" , "ldiv" ,
34+ "fdiv" , "ddiv" , "irem" , "lrem" , "frem" , "drem" , "ineg" , "lneg" ,
35+ "fneg" , "dneg" , "ishl" , "lshl" , "ishr" , "lshr" , "iushr" , "lushr" ,
36+ "iand" , "land" , "ior" , "lor" , "ixor" , "lxor" , "iinc" , "i2l" , "i2f" ,
37+ "i2d" , "l2i" , "l2f" , "l2d" , "f2i" , "f2l" , "f2d" , "d2i" , "d2l" , "d2f" ,
38+ "i2b" , "i2c" , "i2s" , "lcmp" , "fcmpl" , "fcmpg" ,
39+ "dcmpl" , "dcmpg" , "ifeq" , "ifne" , "iflt" , "ifge" , "ifgt" , "ifle" ,
40+ "if_icmpeq" , "if_icmpne" , "if_icmplt" , "if_icmpge" , "if_icmpgt" ,
41+ "if_icmple" , "if_acmpeq" , "if_acmpne" , "goto" , "jsr" , "ret" ,
42+ "tableswitch" , "lookupswitch" , "ireturn" , "lreturn" , "freturn" ,
43+ "dreturn" , "areturn" , "return" , "getstatic" , "putstatic" , "getfield" ,
44+ "putfield" , "invokevirtual" , "invokespecial" , "invokestatic" ,
45+ "invokeinterface" , "invokedynamic" , "new" , "newarray" , "anewarray" ,
46+ "arraylength" , "athrow" , "checkcast" , "instanceof" , "monitorenter" ,
47+ "monitorexit" , "wide" , "multianewarray" , "ifnull" , "ifnonnull" ,
48+ "goto_w" , "jsr_w" , "breakpoint" , ILLEGAL_OPCODE , ILLEGAL_OPCODE ,
49+ ILLEGAL_OPCODE , ILLEGAL_OPCODE , ILLEGAL_OPCODE , ILLEGAL_OPCODE ,
50+ ILLEGAL_OPCODE , ILLEGAL_OPCODE , ILLEGAL_OPCODE , ILLEGAL_OPCODE ,
51+ ILLEGAL_OPCODE , ILLEGAL_OPCODE , ILLEGAL_OPCODE , ILLEGAL_OPCODE ,
52+ ILLEGAL_OPCODE , ILLEGAL_OPCODE , ILLEGAL_OPCODE , ILLEGAL_OPCODE ,
53+ ILLEGAL_OPCODE , ILLEGAL_OPCODE , ILLEGAL_OPCODE , ILLEGAL_OPCODE ,
54+ ILLEGAL_OPCODE , ILLEGAL_OPCODE , ILLEGAL_OPCODE , ILLEGAL_OPCODE ,
55+ ILLEGAL_OPCODE , ILLEGAL_OPCODE , ILLEGAL_OPCODE , ILLEGAL_OPCODE ,
56+ ILLEGAL_OPCODE , ILLEGAL_OPCODE , ILLEGAL_OPCODE , ILLEGAL_OPCODE ,
57+ ILLEGAL_OPCODE , ILLEGAL_OPCODE , ILLEGAL_OPCODE , ILLEGAL_OPCODE ,
58+ ILLEGAL_OPCODE , ILLEGAL_OPCODE , ILLEGAL_OPCODE , ILLEGAL_OPCODE ,
59+ ILLEGAL_OPCODE , ILLEGAL_OPCODE , ILLEGAL_OPCODE , ILLEGAL_OPCODE ,
60+ ILLEGAL_OPCODE , ILLEGAL_OPCODE , ILLEGAL_OPCODE , ILLEGAL_OPCODE ,
61+ ILLEGAL_OPCODE , "impdep1" , "impdep2"
62+ };
63+
64+ protected transient int opcode ;
65+ protected String mnemonic ;
1466
1567 protected transient List <Frame > parents = new ArrayList <>(); // Represents all the frames which contributed to creating this frame
1668 protected transient List <Frame > children = new ArrayList <>(); // Represents all the frames which this frame was involved in
1769
18- private transient LinkedList <Value > locals = new LinkedList <>();
19- private transient LinkedList <Value > stack = new LinkedList <>();
70+ // private transient LinkedList<Value> locals = new LinkedList<>();
71+ // private transient LinkedList<Value> stack = new LinkedList<>();
2072 private transient Value [] localsArr ;
2173 private transient Value [] stackArr ;
2274
2375 private Boolean isConstant ;
2476
2577 public Frame (int opcode ) {
2678 this .opcode = opcode ;
79+ if (opcode == -1 ) {
80+ this .mnemonic = "-1" ;
81+ } else {
82+ this .mnemonic = OPCODE_NAMES [opcode ];
83+ }
2784 }
2885
2986 public final int getOpcode () {
@@ -34,28 +91,28 @@ public List<Frame> getChildren() {
3491 return children ;
3592 }
3693
37- public Value getLocalAt (int index ) {
38- if (localsArr == null ) {
39- localsArr = locals .toArray (new Value [locals .size ()]);
40- }
41- return localsArr [index ];
42- }
94+ // public Value getLocalAt(int index) {
95+ // if (localsArr == null) {
96+ // localsArr = locals.toArray(new Value[locals.size()]);
97+ // }
98+ // return localsArr[index];
99+ // }
43100
44- public Value getStackAt (int index ) {
45- if (stackArr == null ) {
46- stackArr = stack .toArray (new Value [stack .size ()]);
47- }
48- return stackArr [index ];
49- }
101+ // public Value getStackAt(int index) {
102+ // if (stackArr == null) {
103+ // stackArr = stack.toArray(new Value[stack.size()]);
104+ // }
105+ // return stackArr[index];
106+ // }
50107
51108 public void pushLocal (Value value ) {
52- this .locals .add (value );
53- this .localsArr = null ;
109+ // this.locals.add(value);
110+ // this.localsArr = null;
54111 }
55112
56113 public void pushStack (Value value ) {
57- this .stack .add (value );
58- this .stackArr = null ;
114+ // this.stack.add(value);
115+ // this.stackArr = null;
59116 }
60117
61118 public boolean isConstant () {
0 commit comments