|
|
@ -48,40 +48,65 @@ public abstract class Opcodes implements RuntimeConstants { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static FlowBlock createNormal(int addr, int length, |
|
|
|
public static FlowBlock createNormal(CodeAnalyzer ca, |
|
|
|
|
|
|
|
int addr, int length, |
|
|
|
Instruction instr) |
|
|
|
Instruction instr) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return new FlowBlock(addr, length, |
|
|
|
return new FlowBlock(ca, addr, length, |
|
|
|
new InstructionBlock(instr, |
|
|
|
new InstructionBlock(instr, |
|
|
|
new Jump(addr+length))); |
|
|
|
new Jump(addr+length))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static FlowBlock createGoto(int addr, int length, |
|
|
|
public static FlowBlock createGoto(CodeAnalyzer ca, |
|
|
|
|
|
|
|
int addr, int length, |
|
|
|
int destAddr) |
|
|
|
int destAddr) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return new FlowBlock(addr, length, new EmptyBlock(new Jump(destAddr))); |
|
|
|
return new FlowBlock(ca, addr, length, |
|
|
|
|
|
|
|
new EmptyBlock(new Jump(destAddr))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static FlowBlock createIfGoto(int addr, int length, |
|
|
|
public static FlowBlock createJsr(CodeAnalyzer ca, |
|
|
|
|
|
|
|
int addr, int length, |
|
|
|
|
|
|
|
int destAddr) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return new FlowBlock(ca, addr, length, |
|
|
|
|
|
|
|
new JsrBlock(new Jump(addr+length), |
|
|
|
|
|
|
|
new Jump(destAddr))); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static FlowBlock createIfGoto(CodeAnalyzer ca, |
|
|
|
|
|
|
|
int addr, int length, |
|
|
|
int destAddr, Instruction instr) |
|
|
|
int destAddr, Instruction instr) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ConditionalBlock ifBlock = |
|
|
|
ConditionalBlock ifBlock = |
|
|
|
new ConditionalBlock(instr, |
|
|
|
new ConditionalBlock(instr, |
|
|
|
new Jump(destAddr), |
|
|
|
new Jump(destAddr), |
|
|
|
new Jump(addr+length)); |
|
|
|
new Jump(addr+length)); |
|
|
|
return new FlowBlock(addr, length, ifBlock); |
|
|
|
return new FlowBlock(ca, addr, length, ifBlock); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static FlowBlock createSwitch(int addr, int length, |
|
|
|
public static FlowBlock createSwitch(CodeAnalyzer ca, |
|
|
|
|
|
|
|
int addr, int length, |
|
|
|
int[] cases, int[] dests) |
|
|
|
int[] cases, int[] dests) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return new FlowBlock(addr, length, new SwitchBlock(cases, dests)); |
|
|
|
return new FlowBlock(ca, addr, length, |
|
|
|
|
|
|
|
new SwitchBlock(new NopOperator(MyType.tInt), |
|
|
|
|
|
|
|
cases, dests)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static FlowBlock createBlock(int addr, int length, |
|
|
|
public static FlowBlock createBlock(CodeAnalyzer ca, |
|
|
|
|
|
|
|
int addr, int length, |
|
|
|
StructuredBlock block) |
|
|
|
StructuredBlock block) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return new FlowBlock(addr, length, block); |
|
|
|
return new FlowBlock(ca, addr, length, block); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static FlowBlock createRet(CodeAnalyzer ca, |
|
|
|
|
|
|
|
int addr, int length, |
|
|
|
|
|
|
|
LocalInfo local) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return new FlowBlock(ca, addr, length, |
|
|
|
|
|
|
|
new RetBlock(local)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -103,43 +128,43 @@ public abstract class Opcodes implements RuntimeConstants { |
|
|
|
int opcode = stream.readUnsignedByte(); |
|
|
|
int opcode = stream.readUnsignedByte(); |
|
|
|
switch (opcode) { |
|
|
|
switch (opcode) { |
|
|
|
case opc_nop: |
|
|
|
case opc_nop: |
|
|
|
return createNormal(addr, 1, new NopOperator()); |
|
|
|
return createNormal(ca, addr, 1, new NopOperator()); |
|
|
|
case opc_aconst_null: |
|
|
|
case opc_aconst_null: |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 1, new ConstOperator(OBJECT_TYPE, "null")); |
|
|
|
(ca, addr, 1, new ConstOperator(OBJECT_TYPE, "null")); |
|
|
|
case opc_iconst_m1: |
|
|
|
case opc_iconst_m1: |
|
|
|
case opc_iconst_0: case opc_iconst_1: case opc_iconst_2: |
|
|
|
case opc_iconst_0: case opc_iconst_1: case opc_iconst_2: |
|
|
|
case opc_iconst_3: case opc_iconst_4: case opc_iconst_5: |
|
|
|
case opc_iconst_3: case opc_iconst_4: case opc_iconst_5: |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 1, new ConstOperator |
|
|
|
(ca, addr, 1, new ConstOperator |
|
|
|
(ALL_INT_TYPE, Integer.toString(opcode - opc_iconst_0))); |
|
|
|
(ALL_INT_TYPE, Integer.toString(opcode - opc_iconst_0))); |
|
|
|
case opc_lconst_0: case opc_lconst_1: |
|
|
|
case opc_lconst_0: case opc_lconst_1: |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 1, new ConstOperator |
|
|
|
(ca, addr, 1, new ConstOperator |
|
|
|
(LONG_TYPE, |
|
|
|
(LONG_TYPE, |
|
|
|
Integer.toString(opcode - opc_lconst_0) + "L")); |
|
|
|
Integer.toString(opcode - opc_lconst_0) + "L")); |
|
|
|
case opc_fconst_0: case opc_fconst_1: case opc_fconst_2: |
|
|
|
case opc_fconst_0: case opc_fconst_1: case opc_fconst_2: |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 1, new ConstOperator |
|
|
|
(ca, addr, 1, new ConstOperator |
|
|
|
(FLOAT_TYPE, |
|
|
|
(FLOAT_TYPE, |
|
|
|
Integer.toString(opcode - opc_fconst_0) + ".0F")); |
|
|
|
Integer.toString(opcode - opc_fconst_0) + ".0F")); |
|
|
|
case opc_dconst_0: case opc_dconst_1: |
|
|
|
case opc_dconst_0: case opc_dconst_1: |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 1, new ConstOperator |
|
|
|
(ca, addr, 1, new ConstOperator |
|
|
|
(DOUBLE_TYPE, |
|
|
|
(DOUBLE_TYPE, |
|
|
|
Integer.toString(opcode - opc_dconst_0) + ".0")); |
|
|
|
Integer.toString(opcode - opc_dconst_0) + ".0")); |
|
|
|
case opc_bipush: |
|
|
|
case opc_bipush: |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 2, new ConstOperator |
|
|
|
(ca, addr, 2, new ConstOperator |
|
|
|
(ALL_INT_TYPE, Integer.toString(stream.readByte()))); |
|
|
|
(ALL_INT_TYPE, Integer.toString(stream.readByte()))); |
|
|
|
case opc_sipush: |
|
|
|
case opc_sipush: |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 3, new ConstOperator |
|
|
|
(ca, addr, 3, new ConstOperator |
|
|
|
(ALL_INT_TYPE, Integer.toString(stream.readShort()))); |
|
|
|
(ALL_INT_TYPE, Integer.toString(stream.readShort()))); |
|
|
|
case opc_ldc: { |
|
|
|
case opc_ldc: { |
|
|
|
int index = stream.readUnsignedByte(); |
|
|
|
int index = stream.readUnsignedByte(); |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 2, new ConstOperator |
|
|
|
(ca, addr, 2, new ConstOperator |
|
|
|
(ca.env.getConstantType(index), |
|
|
|
(ca.env.getConstantType(index), |
|
|
|
ca.env.getConstant(index).toString())); |
|
|
|
ca.env.getConstant(index).toString())); |
|
|
|
} |
|
|
|
} |
|
|
@ -147,14 +172,14 @@ public abstract class Opcodes implements RuntimeConstants { |
|
|
|
case opc_ldc2_w: { |
|
|
|
case opc_ldc2_w: { |
|
|
|
int index = stream.readUnsignedShort(); |
|
|
|
int index = stream.readUnsignedShort(); |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 3, new ConstOperator |
|
|
|
(ca, addr, 3, new ConstOperator |
|
|
|
(ca.env.getConstantType(index), |
|
|
|
(ca.env.getConstantType(index), |
|
|
|
ca.env.getConstant(index).toString())); |
|
|
|
ca.env.getConstant(index).toString())); |
|
|
|
} |
|
|
|
} |
|
|
|
case opc_iload: case opc_lload: |
|
|
|
case opc_iload: case opc_lload: |
|
|
|
case opc_fload: case opc_dload: case opc_aload: |
|
|
|
case opc_fload: case opc_dload: case opc_aload: |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 2, new LocalLoadOperator |
|
|
|
(ca, addr, 2, new LocalLoadOperator |
|
|
|
(types[0][opcode-opc_iload], |
|
|
|
(types[0][opcode-opc_iload], |
|
|
|
ca.getLocalInfo(addr, stream.readUnsignedByte()))); |
|
|
|
ca.getLocalInfo(addr, stream.readUnsignedByte()))); |
|
|
|
case opc_iload_0: case opc_iload_1: case opc_iload_2: case opc_iload_3: |
|
|
|
case opc_iload_0: case opc_iload_1: case opc_iload_2: case opc_iload_3: |
|
|
@ -163,19 +188,19 @@ public abstract class Opcodes implements RuntimeConstants { |
|
|
|
case opc_dload_0: case opc_dload_1: case opc_dload_2: case opc_dload_3: |
|
|
|
case opc_dload_0: case opc_dload_1: case opc_dload_2: case opc_dload_3: |
|
|
|
case opc_aload_0: case opc_aload_1: case opc_aload_2: case opc_aload_3: |
|
|
|
case opc_aload_0: case opc_aload_1: case opc_aload_2: case opc_aload_3: |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 1, new LocalLoadOperator |
|
|
|
(ca, addr, 1, new LocalLoadOperator |
|
|
|
(types[0][(opcode-opc_iload_0)/4], |
|
|
|
(types[0][(opcode-opc_iload_0)/4], |
|
|
|
ca.getLocalInfo(addr, (opcode-opc_iload_0) & 3))); |
|
|
|
ca.getLocalInfo(addr, (opcode-opc_iload_0) & 3))); |
|
|
|
case opc_iaload: case opc_laload: |
|
|
|
case opc_iaload: case opc_laload: |
|
|
|
case opc_faload: case opc_daload: case opc_aaload: |
|
|
|
case opc_faload: case opc_daload: case opc_aaload: |
|
|
|
case opc_baload: case opc_caload: case opc_saload: |
|
|
|
case opc_baload: case opc_caload: case opc_saload: |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 1, new ArrayLoadOperator |
|
|
|
(ca, addr, 1, new ArrayLoadOperator |
|
|
|
(types[1][opcode - opc_iaload])); |
|
|
|
(types[1][opcode - opc_iaload])); |
|
|
|
case opc_istore: case opc_lstore: |
|
|
|
case opc_istore: case opc_lstore: |
|
|
|
case opc_fstore: case opc_dstore: case opc_astore: |
|
|
|
case opc_fstore: case opc_dstore: case opc_astore: |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 2, new LocalStoreOperator |
|
|
|
(ca, addr, 2, new LocalStoreOperator |
|
|
|
(types[0][opcode-opc_istore], |
|
|
|
(types[0][opcode-opc_istore], |
|
|
|
ca.getLocalInfo(addr, stream.readUnsignedByte()), |
|
|
|
ca.getLocalInfo(addr, stream.readUnsignedByte()), |
|
|
|
Operator.ASSIGN_OP)); |
|
|
|
Operator.ASSIGN_OP)); |
|
|
@ -190,7 +215,7 @@ public abstract class Opcodes implements RuntimeConstants { |
|
|
|
case opc_astore_0: case opc_astore_1: |
|
|
|
case opc_astore_0: case opc_astore_1: |
|
|
|
case opc_astore_2: case opc_astore_3: |
|
|
|
case opc_astore_2: case opc_astore_3: |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 1, new LocalStoreOperator |
|
|
|
(ca, addr, 1, new LocalStoreOperator |
|
|
|
(types[0][(opcode-opc_istore_0)/4], |
|
|
|
(types[0][(opcode-opc_istore_0)/4], |
|
|
|
ca.getLocalInfo(addr, (opcode-opc_istore_0) & 3), |
|
|
|
ca.getLocalInfo(addr, (opcode-opc_istore_0) & 3), |
|
|
|
Operator.ASSIGN_OP)); |
|
|
|
Operator.ASSIGN_OP)); |
|
|
@ -198,43 +223,43 @@ public abstract class Opcodes implements RuntimeConstants { |
|
|
|
case opc_fastore: case opc_dastore: case opc_aastore: |
|
|
|
case opc_fastore: case opc_dastore: case opc_aastore: |
|
|
|
case opc_bastore: case opc_castore: case opc_sastore: |
|
|
|
case opc_bastore: case opc_castore: case opc_sastore: |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 1, new ArrayStoreOperator |
|
|
|
(ca, addr, 1, new ArrayStoreOperator |
|
|
|
(types[1][opcode - opc_iastore])); |
|
|
|
(types[1][opcode - opc_iastore])); |
|
|
|
case opc_pop: case opc_pop2: |
|
|
|
case opc_pop: case opc_pop2: |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 1, new PopOperator(opcode - opc_pop + 1)); |
|
|
|
(ca, addr, 1, new PopOperator(opcode - opc_pop + 1)); |
|
|
|
case opc_dup: case opc_dup_x1: case opc_dup_x2: |
|
|
|
case opc_dup: case opc_dup_x1: case opc_dup_x2: |
|
|
|
case opc_dup2: case opc_dup2_x1: case opc_dup2_x2: |
|
|
|
case opc_dup2: case opc_dup2_x1: case opc_dup2_x2: |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 1, new DupOperator |
|
|
|
(ca, addr, 1, new DupOperator |
|
|
|
((opcode - opc_dup)%3, (opcode - opc_dup)/3+1)); |
|
|
|
((opcode - opc_dup)%3, (opcode - opc_dup)/3+1)); |
|
|
|
case opc_swap: |
|
|
|
case opc_swap: |
|
|
|
return createNormal(addr, 1, new SwapOperator()); |
|
|
|
return createNormal(ca, addr, 1, new SwapOperator()); |
|
|
|
case opc_iadd: case opc_ladd: case opc_fadd: case opc_dadd: |
|
|
|
case opc_iadd: case opc_ladd: case opc_fadd: case opc_dadd: |
|
|
|
case opc_isub: case opc_lsub: case opc_fsub: case opc_dsub: |
|
|
|
case opc_isub: case opc_lsub: case opc_fsub: case opc_dsub: |
|
|
|
case opc_imul: case opc_lmul: case opc_fmul: case opc_dmul: |
|
|
|
case opc_imul: case opc_lmul: case opc_fmul: case opc_dmul: |
|
|
|
case opc_idiv: case opc_ldiv: case opc_fdiv: case opc_ddiv: |
|
|
|
case opc_idiv: case opc_ldiv: case opc_fdiv: case opc_ddiv: |
|
|
|
case opc_irem: case opc_lrem: case opc_frem: case opc_drem: |
|
|
|
case opc_irem: case opc_lrem: case opc_frem: case opc_drem: |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 1, new BinaryOperator |
|
|
|
(ca, addr, 1, new BinaryOperator |
|
|
|
(types[0][(opcode - opc_iadd)%4], |
|
|
|
(types[0][(opcode - opc_iadd)%4], |
|
|
|
(opcode - opc_iadd)/4+Operator.ADD_OP)); |
|
|
|
(opcode - opc_iadd)/4+Operator.ADD_OP)); |
|
|
|
case opc_ineg: case opc_lneg: case opc_fneg: case opc_dneg: |
|
|
|
case opc_ineg: case opc_lneg: case opc_fneg: case opc_dneg: |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 1, new UnaryOperator |
|
|
|
(ca, addr, 1, new UnaryOperator |
|
|
|
(types[0][opcode - opc_ineg], Operator.NEG_OP)); |
|
|
|
(types[0][opcode - opc_ineg], Operator.NEG_OP)); |
|
|
|
case opc_ishl: case opc_lshl: |
|
|
|
case opc_ishl: case opc_lshl: |
|
|
|
case opc_ishr: case opc_lshr: |
|
|
|
case opc_ishr: case opc_lshr: |
|
|
|
case opc_iushr: case opc_lushr: |
|
|
|
case opc_iushr: case opc_lushr: |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 1, new ShiftOperator |
|
|
|
(ca, addr, 1, new ShiftOperator |
|
|
|
(types[0][(opcode - opc_ishl)%2], |
|
|
|
(types[0][(opcode - opc_ishl)%2], |
|
|
|
(opcode - opc_ishl)/2 + Operator.SHIFT_OP)); |
|
|
|
(opcode - opc_ishl)/2 + Operator.SHIFT_OP)); |
|
|
|
case opc_iand: case opc_land: |
|
|
|
case opc_iand: case opc_land: |
|
|
|
case opc_ior : case opc_lor : |
|
|
|
case opc_ior : case opc_lor : |
|
|
|
case opc_ixor: case opc_lxor: |
|
|
|
case opc_ixor: case opc_lxor: |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 1, new BinaryOperator |
|
|
|
(ca, addr, 1, new BinaryOperator |
|
|
|
(types[0][(opcode - opc_iand)%2], |
|
|
|
(types[0][(opcode - opc_iand)%2], |
|
|
|
(opcode - opc_iand)/2 + Operator.AND_OP)); |
|
|
|
(opcode - opc_iand)/2 + Operator.AND_OP)); |
|
|
|
case opc_iinc: { |
|
|
|
case opc_iinc: { |
|
|
@ -247,7 +272,7 @@ public abstract class Opcodes implements RuntimeConstants { |
|
|
|
} |
|
|
|
} |
|
|
|
LocalInfo li = ca.getLocalInfo(addr, local); |
|
|
|
LocalInfo li = ca.getLocalInfo(addr, local); |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 3, new IIncOperator |
|
|
|
(ca, addr, 3, new IIncOperator |
|
|
|
(li, Integer.toString(value), |
|
|
|
(li, Integer.toString(value), |
|
|
|
operation + Operator.OPASSIGN_OP)); |
|
|
|
operation + Operator.OPASSIGN_OP)); |
|
|
|
} |
|
|
|
} |
|
|
@ -260,48 +285,46 @@ public abstract class Opcodes implements RuntimeConstants { |
|
|
|
if (to >= from) |
|
|
|
if (to >= from) |
|
|
|
to++; |
|
|
|
to++; |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 1, new ConvertOperator(types[0][from], |
|
|
|
(ca, addr, 1, new ConvertOperator(types[0][from], |
|
|
|
types[0][to])); |
|
|
|
types[0][to])); |
|
|
|
} |
|
|
|
} |
|
|
|
case opc_i2b: case opc_i2c: case opc_i2s: |
|
|
|
case opc_i2b: case opc_i2c: case opc_i2s: |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 1, new ConvertOperator |
|
|
|
(ca, addr, 1, new ConvertOperator |
|
|
|
(ALL_INT_TYPE, types[1][(opcode-opc_i2b)+5])); |
|
|
|
(ALL_INT_TYPE, types[1][(opcode-opc_i2b)+5])); |
|
|
|
case opc_lcmp: |
|
|
|
case opc_lcmp: |
|
|
|
case opc_fcmpl: case opc_fcmpg: |
|
|
|
case opc_fcmpl: case opc_fcmpg: |
|
|
|
case opc_dcmpl: case opc_dcmpg: |
|
|
|
case opc_dcmpl: case opc_dcmpg: |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 1, new CompareToIntOperator |
|
|
|
(ca, addr, 1, new CompareToIntOperator |
|
|
|
(types[0][(opcode-opc_lcmp+3)/2], (opcode-opc_lcmp+3)%2)); |
|
|
|
(types[0][(opcode-opc_lcmp+3)/2], (opcode-opc_lcmp+3)%2)); |
|
|
|
case opc_ifeq: case opc_ifne: |
|
|
|
case opc_ifeq: case opc_ifne: |
|
|
|
case opc_iflt: case opc_ifge: case opc_ifgt: case opc_ifle: |
|
|
|
case opc_iflt: case opc_ifge: case opc_ifgt: case opc_ifle: |
|
|
|
return createIfGoto |
|
|
|
return createIfGoto |
|
|
|
(addr, 3, addr+stream.readShort(), |
|
|
|
(ca, addr, 3, addr+stream.readShort(), |
|
|
|
new CompareUnaryOperator |
|
|
|
new CompareUnaryOperator |
|
|
|
(ALL_INT_TYPE, opcode - opc_ifeq+Operator.COMPARE_OP)); |
|
|
|
(ALL_INT_TYPE, opcode - opc_ifeq+Operator.COMPARE_OP)); |
|
|
|
case opc_if_icmpeq: case opc_if_icmpne: case opc_if_icmplt: |
|
|
|
case opc_if_icmpeq: case opc_if_icmpne: case opc_if_icmplt: |
|
|
|
case opc_if_icmpge: case opc_if_icmpgt: case opc_if_icmple: |
|
|
|
case opc_if_icmpge: case opc_if_icmpgt: case opc_if_icmple: |
|
|
|
return createIfGoto |
|
|
|
return createIfGoto |
|
|
|
(addr, 3, addr+stream.readShort(), |
|
|
|
(ca, addr, 3, addr+stream.readShort(), |
|
|
|
new CompareBinaryOperator |
|
|
|
new CompareBinaryOperator |
|
|
|
(ALL_INT_TYPE, opcode - opc_if_icmpeq+Operator.COMPARE_OP)); |
|
|
|
(ALL_INT_TYPE, opcode - opc_if_icmpeq+Operator.COMPARE_OP)); |
|
|
|
case opc_if_acmpeq: case opc_if_acmpne: |
|
|
|
case opc_if_acmpeq: case opc_if_acmpne: |
|
|
|
return createIfGoto |
|
|
|
return createIfGoto |
|
|
|
(addr, 3, addr+stream.readShort(), |
|
|
|
(ca, addr, 3, addr+stream.readShort(), |
|
|
|
new CompareBinaryOperator |
|
|
|
new CompareBinaryOperator |
|
|
|
(OBJECT_TYPE, opcode - opc_if_acmpeq+Operator.COMPARE_OP)); |
|
|
|
(OBJECT_TYPE, opcode - opc_if_acmpeq+Operator.COMPARE_OP)); |
|
|
|
case opc_goto: |
|
|
|
case opc_goto: |
|
|
|
return createGoto |
|
|
|
return createGoto |
|
|
|
(addr, 3, addr+stream.readShort()); |
|
|
|
(ca, addr, 3, addr+stream.readShort()); |
|
|
|
// case opc_jsr:
|
|
|
|
case opc_jsr: |
|
|
|
// return createGoto //XXX
|
|
|
|
return createJsr |
|
|
|
// (addr, 3, addr+stream.readShort());
|
|
|
|
(ca, addr, 3, addr+stream.readShort()); |
|
|
|
// case opc_ret:
|
|
|
|
case opc_ret: |
|
|
|
// return createReturn //XXX
|
|
|
|
return createRet |
|
|
|
// (addr, 2,
|
|
|
|
(ca, addr, 2, |
|
|
|
// new LocalLoadOperator
|
|
|
|
ca.getLocalInfo(addr, stream.readUnsignedByte())); |
|
|
|
// (OBJECT_TYPE,
|
|
|
|
|
|
|
|
// ca.getLocalInfo(addr, stream.readUnsignedByte())));
|
|
|
|
|
|
|
|
case opc_tableswitch: { |
|
|
|
case opc_tableswitch: { |
|
|
|
int length = 3-(addr % 4); |
|
|
|
int length = 3-(addr % 4); |
|
|
|
stream.skip(length); |
|
|
|
stream.skip(length); |
|
|
@ -317,7 +340,7 @@ public abstract class Opcodes implements RuntimeConstants { |
|
|
|
dests[cases.length] = def; |
|
|
|
dests[cases.length] = def; |
|
|
|
length += 13 + 4 * cases.length; |
|
|
|
length += 13 + 4 * cases.length; |
|
|
|
return createSwitch |
|
|
|
return createSwitch |
|
|
|
(addr, length, cases, dests); |
|
|
|
(ca, addr, length, cases, dests); |
|
|
|
} |
|
|
|
} |
|
|
|
case opc_lookupswitch: { |
|
|
|
case opc_lookupswitch: { |
|
|
|
int length = 3-(addr % 4); |
|
|
|
int length = 3-(addr % 4); |
|
|
@ -333,7 +356,7 @@ public abstract class Opcodes implements RuntimeConstants { |
|
|
|
dests[npairs] = def; |
|
|
|
dests[npairs] = def; |
|
|
|
length += 9 + 8 * npairs; |
|
|
|
length += 9 + 8 * npairs; |
|
|
|
return createSwitch |
|
|
|
return createSwitch |
|
|
|
(addr, length, cases, dests); |
|
|
|
(ca, addr, length, cases, dests); |
|
|
|
} |
|
|
|
} |
|
|
|
case opc_ireturn: case opc_lreturn: |
|
|
|
case opc_ireturn: case opc_lreturn: |
|
|
|
case opc_freturn: case opc_dreturn: case opc_areturn: { |
|
|
|
case opc_freturn: case opc_dreturn: case opc_areturn: { |
|
|
@ -341,23 +364,23 @@ public abstract class Opcodes implements RuntimeConstants { |
|
|
|
(ca.getMethod().mdef.getType().getReturnType(), |
|
|
|
(ca.getMethod().mdef.getType().getReturnType(), |
|
|
|
types[0][opcode-opc_ireturn]); |
|
|
|
types[0][opcode-opc_ireturn]); |
|
|
|
return createBlock |
|
|
|
return createBlock |
|
|
|
(addr, 1, new ReturnBlock(new NopOperator(retType))); |
|
|
|
(ca, addr, 1, new ReturnBlock(new NopOperator(retType))); |
|
|
|
} |
|
|
|
} |
|
|
|
case opc_return: |
|
|
|
case opc_return: |
|
|
|
/* Address -1 is interpreted as end of method */ |
|
|
|
/* Address -1 is interpreted as end of method */ |
|
|
|
return createBlock |
|
|
|
return createBlock |
|
|
|
(addr, 1, new EmptyBlock(new Jump(-1))); |
|
|
|
(ca, addr, 1, new EmptyBlock(new Jump(-1))); |
|
|
|
case opc_getstatic: |
|
|
|
case opc_getstatic: |
|
|
|
case opc_getfield: |
|
|
|
case opc_getfield: |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 3, new GetFieldOperator |
|
|
|
(ca, addr, 3, new GetFieldOperator |
|
|
|
(ca, opcode == opc_getstatic, |
|
|
|
(ca, opcode == opc_getstatic, |
|
|
|
(FieldDefinition)ca.env.getConstant |
|
|
|
(FieldDefinition)ca.env.getConstant |
|
|
|
(stream.readUnsignedShort()))); |
|
|
|
(stream.readUnsignedShort()))); |
|
|
|
case opc_putstatic: |
|
|
|
case opc_putstatic: |
|
|
|
case opc_putfield: |
|
|
|
case opc_putfield: |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 3, new PutFieldOperator |
|
|
|
(ca, addr, 3, new PutFieldOperator |
|
|
|
(ca, opcode == opc_putstatic, |
|
|
|
(ca, opcode == opc_putstatic, |
|
|
|
(FieldDefinition)ca.env.getConstant |
|
|
|
(FieldDefinition)ca.env.getConstant |
|
|
|
(stream.readUnsignedShort()))); |
|
|
|
(stream.readUnsignedShort()))); |
|
|
@ -365,14 +388,14 @@ public abstract class Opcodes implements RuntimeConstants { |
|
|
|
case opc_invokespecial: |
|
|
|
case opc_invokespecial: |
|
|
|
case opc_invokestatic : |
|
|
|
case opc_invokestatic : |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 3, new InvokeOperator |
|
|
|
(ca, addr, 3, new InvokeOperator |
|
|
|
(ca, |
|
|
|
(ca, |
|
|
|
opcode == opc_invokestatic, opcode == opc_invokespecial, |
|
|
|
opcode == opc_invokestatic, opcode == opc_invokespecial, |
|
|
|
(FieldDefinition)ca.env.getConstant |
|
|
|
(FieldDefinition)ca.env.getConstant |
|
|
|
(stream.readUnsignedShort()))); |
|
|
|
(stream.readUnsignedShort()))); |
|
|
|
case opc_invokeinterface: { |
|
|
|
case opc_invokeinterface: { |
|
|
|
FlowBlock fb = createNormal |
|
|
|
FlowBlock fb = createNormal |
|
|
|
(addr, 5, new InvokeOperator |
|
|
|
(ca, addr, 5, new InvokeOperator |
|
|
|
(ca, false, false, |
|
|
|
(ca, false, false, |
|
|
|
(FieldDefinition)ca.env.getConstant |
|
|
|
(FieldDefinition)ca.env.getConstant |
|
|
|
(stream.readUnsignedShort()))); |
|
|
|
(stream.readUnsignedShort()))); |
|
|
@ -384,7 +407,7 @@ public abstract class Opcodes implements RuntimeConstants { |
|
|
|
ca.env.getConstant(stream.readUnsignedShort()); |
|
|
|
ca.env.getConstant(stream.readUnsignedShort()); |
|
|
|
Type type = MyType.tClassOrArray(cldec.getName()); |
|
|
|
Type type = MyType.tClassOrArray(cldec.getName()); |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 3, new NewOperator(type, ca.env.getTypeString(type))); |
|
|
|
(ca, addr, 3, new NewOperator(type, ca.env.getTypeString(type))); |
|
|
|
} |
|
|
|
} |
|
|
|
case opc_newarray: { |
|
|
|
case opc_newarray: { |
|
|
|
Type type; |
|
|
|
Type type; |
|
|
@ -401,7 +424,7 @@ public abstract class Opcodes implements RuntimeConstants { |
|
|
|
throw new ClassFormatError("Invalid newarray operand"); |
|
|
|
throw new ClassFormatError("Invalid newarray operand"); |
|
|
|
} |
|
|
|
} |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 2, |
|
|
|
(ca, addr, 2, |
|
|
|
new NewArrayOperator(MyType.tArray(type), |
|
|
|
new NewArrayOperator(MyType.tArray(type), |
|
|
|
type.toString(), 1)); |
|
|
|
type.toString(), 1)); |
|
|
|
} |
|
|
|
} |
|
|
@ -411,22 +434,22 @@ public abstract class Opcodes implements RuntimeConstants { |
|
|
|
Identifier ident = cldec.getName(); |
|
|
|
Identifier ident = cldec.getName(); |
|
|
|
Type type = MyType.tClassOrArray(cldec.getName()); |
|
|
|
Type type = MyType.tClassOrArray(cldec.getName()); |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 3, new NewArrayOperator |
|
|
|
(ca, addr, 3, new NewArrayOperator |
|
|
|
(MyType.tArray(type), ca.env.getTypeString(type),1)); |
|
|
|
(MyType.tArray(type), ca.env.getTypeString(type),1)); |
|
|
|
} |
|
|
|
} |
|
|
|
case opc_arraylength: |
|
|
|
case opc_arraylength: |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 1, new ArrayLengthOperator()); |
|
|
|
(ca, addr, 1, new ArrayLengthOperator()); |
|
|
|
case opc_athrow: |
|
|
|
case opc_athrow: |
|
|
|
return createBlock |
|
|
|
return createBlock |
|
|
|
(addr, 1, |
|
|
|
(ca, addr, 1, |
|
|
|
new ThrowBlock(new NopOperator(MyType.tUObject))); |
|
|
|
new ThrowBlock(new NopOperator(MyType.tUObject))); |
|
|
|
case opc_checkcast: { |
|
|
|
case opc_checkcast: { |
|
|
|
ClassDeclaration cldec = (ClassDeclaration) ca.env.getConstant |
|
|
|
ClassDeclaration cldec = (ClassDeclaration) ca.env.getConstant |
|
|
|
(stream.readUnsignedShort()); |
|
|
|
(stream.readUnsignedShort()); |
|
|
|
Type type = MyType.tClassOrArray(cldec.getName()); |
|
|
|
Type type = MyType.tClassOrArray(cldec.getName()); |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 3, new CheckCastOperator |
|
|
|
(ca, addr, 3, new CheckCastOperator |
|
|
|
(type, ca.env.getTypeString(type))); |
|
|
|
(type, ca.env.getTypeString(type))); |
|
|
|
} |
|
|
|
} |
|
|
|
case opc_instanceof: { |
|
|
|
case opc_instanceof: { |
|
|
@ -434,28 +457,28 @@ public abstract class Opcodes implements RuntimeConstants { |
|
|
|
(stream.readUnsignedShort()); |
|
|
|
(stream.readUnsignedShort()); |
|
|
|
Type type = MyType.tClassOrArray(cldec.getName()); |
|
|
|
Type type = MyType.tClassOrArray(cldec.getName()); |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 3, |
|
|
|
(ca, addr, 3, |
|
|
|
new InstanceOfOperator(type, ca.env.getTypeString(type))); |
|
|
|
new InstanceOfOperator(type, ca.env.getTypeString(type))); |
|
|
|
} |
|
|
|
} |
|
|
|
case opc_monitorenter: |
|
|
|
case opc_monitorenter: |
|
|
|
return createNormal(addr, 1, |
|
|
|
return createNormal(ca, addr, 1, |
|
|
|
new MonitorEnterOperator()); |
|
|
|
new MonitorEnterOperator()); |
|
|
|
case opc_monitorexit: |
|
|
|
case opc_monitorexit: |
|
|
|
return createNormal(addr, 1, |
|
|
|
return createNormal(ca, addr, 1, |
|
|
|
new MonitorExitOperator()); |
|
|
|
new MonitorExitOperator()); |
|
|
|
case opc_wide: { |
|
|
|
case opc_wide: { |
|
|
|
switch (opcode=stream.readUnsignedByte()) { |
|
|
|
switch (opcode=stream.readUnsignedByte()) { |
|
|
|
case opc_iload: case opc_lload: |
|
|
|
case opc_iload: case opc_lload: |
|
|
|
case opc_fload: case opc_dload: case opc_aload: |
|
|
|
case opc_fload: case opc_dload: case opc_aload: |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 4, |
|
|
|
(ca, addr, 4, |
|
|
|
new LocalLoadOperator(types[0][opcode-opc_iload], |
|
|
|
new LocalLoadOperator |
|
|
|
new LocalInfo |
|
|
|
(types[0][opcode-opc_iload], |
|
|
|
(stream.readUnsignedShort()))); |
|
|
|
ca.getLocalInfo(addr, stream.readUnsignedShort()))); |
|
|
|
case opc_istore: case opc_lstore: |
|
|
|
case opc_istore: case opc_lstore: |
|
|
|
case opc_fstore: case opc_dstore: case opc_astore: |
|
|
|
case opc_fstore: case opc_dstore: case opc_astore: |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 4, |
|
|
|
(ca, addr, 4, |
|
|
|
new LocalStoreOperator |
|
|
|
new LocalStoreOperator |
|
|
|
(types[0][opcode-opc_istore], |
|
|
|
(types[0][opcode-opc_istore], |
|
|
|
ca.getLocalInfo(addr, stream.readUnsignedShort()), |
|
|
|
ca.getLocalInfo(addr, stream.readUnsignedShort()), |
|
|
@ -470,16 +493,14 @@ public abstract class Opcodes implements RuntimeConstants { |
|
|
|
} |
|
|
|
} |
|
|
|
LocalInfo li = ca.getLocalInfo(addr, local); |
|
|
|
LocalInfo li = ca.getLocalInfo(addr, local); |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 6, new IIncOperator |
|
|
|
(ca, addr, 6, new IIncOperator |
|
|
|
(li, Integer.toString(value), |
|
|
|
(li, Integer.toString(value), |
|
|
|
operation + Operator.OPASSIGN_OP)); |
|
|
|
operation + Operator.OPASSIGN_OP)); |
|
|
|
} |
|
|
|
} |
|
|
|
// case opc_ret:
|
|
|
|
case opc_ret: |
|
|
|
// return new RetInstructionHeader
|
|
|
|
return createRet |
|
|
|
// (addr, 4,
|
|
|
|
(ca, addr, 4, |
|
|
|
// new LocalLoadOperator
|
|
|
|
ca.getLocalInfo(addr, stream.readUnsignedShort())); |
|
|
|
// (INT_TYPE,
|
|
|
|
|
|
|
|
// ca.getLocalInfo(addr, stream.readUnsignedShort())));
|
|
|
|
|
|
|
|
default: |
|
|
|
default: |
|
|
|
throw new ClassFormatError("Invalid wide opcode "+opcode); |
|
|
|
throw new ClassFormatError("Invalid wide opcode "+opcode); |
|
|
|
} |
|
|
|
} |
|
|
@ -493,23 +514,23 @@ public abstract class Opcodes implements RuntimeConstants { |
|
|
|
for (int i=0; i<dimension; i++) |
|
|
|
for (int i=0; i<dimension; i++) |
|
|
|
baseType = baseType.getElementType(); |
|
|
|
baseType = baseType.getElementType(); |
|
|
|
return createNormal |
|
|
|
return createNormal |
|
|
|
(addr, 4, |
|
|
|
(ca, addr, 4, |
|
|
|
new NewArrayOperator |
|
|
|
new NewArrayOperator |
|
|
|
(type, ca.env.getTypeString(baseType), dimension)); |
|
|
|
(type, ca.env.getTypeString(baseType), dimension)); |
|
|
|
} |
|
|
|
} |
|
|
|
case opc_ifnull: case opc_ifnonnull: |
|
|
|
case opc_ifnull: case opc_ifnonnull: |
|
|
|
return createIfGoto |
|
|
|
return createIfGoto |
|
|
|
(addr, 3, addr+stream.readShort(), |
|
|
|
(ca, addr, 3, addr+stream.readShort(), |
|
|
|
new CompareUnaryOperator |
|
|
|
new CompareUnaryOperator |
|
|
|
(OBJECT_TYPE, opcode - opc_ifnull+Operator.COMPARE_OP)); |
|
|
|
(OBJECT_TYPE, opcode - opc_ifnull+Operator.COMPARE_OP)); |
|
|
|
case opc_goto_w: |
|
|
|
case opc_goto_w: |
|
|
|
return createGoto |
|
|
|
return createGoto |
|
|
|
(addr, 5, addr + stream.readInt()); |
|
|
|
(ca, addr, 5, addr + stream.readInt()); |
|
|
|
// case opc_jsr_w:
|
|
|
|
case opc_jsr_w: |
|
|
|
// return createGoto
|
|
|
|
return createJsr |
|
|
|
// (addr, 5, addr+stream.readInt()); // XXX
|
|
|
|
(ca, addr, 5, addr+stream.readInt()); |
|
|
|
default: |
|
|
|
default: |
|
|
|
throw new ClassFormatError("Invalid opcode "+opcode); |
|
|
|
throw new ClassFormatError("Invalid opcode "+opcode); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (ClassCastException ex) { |
|
|
|
} catch (ClassCastException ex) { |
|
|
|
ex.printStackTrace(); |
|
|
|
ex.printStackTrace(); |
|
|
|