use of org.objectweb.asm.tree.MultiANewArrayInsnNode in project openj9 by eclipse.
the class ClassFileCompare method compareInstructions.
private void compareInstructions(ClassNode clazz1, MethodNode method1, ClassNode clazz2, MethodNode method2) {
if (nullCheck(method1.instructions, method2.instructions, "Instructions (" + method1.name + ")")) {
return;
}
if (method1.instructions.size() != method2.instructions.size()) {
reportDifference("Method " + method1.name + ": instructions differ: " + method1.instructions.size() + ", " + method2.instructions.size());
} else {
@SuppressWarnings("unchecked") Iterator<AbstractInsnNode> iter1 = method1.instructions.iterator();
@SuppressWarnings("unchecked") Iterator<AbstractInsnNode> iter2 = method2.instructions.iterator();
int index = 0;
while (iter1.hasNext()) {
AbstractInsnNode instruction1 = iter1.next();
AbstractInsnNode instruction2 = iter2.next();
if (instruction1.getOpcode() != instruction2.getOpcode()) {
/* Check for J9 opcode mapping */
compareJ9OpcodeMapping(clazz2, method2, instruction1, instruction2, index);
} else {
switch(instruction1.getType()) {
case INSN:
/* Do nothing */
break;
case INT_INSN:
compare(((IntInsnNode) instruction1).operand, ((IntInsnNode) instruction2).operand, "Operands of " + Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ")", false);
break;
case VAR_INSN:
compare(((VarInsnNode) instruction1).var, ((VarInsnNode) instruction2).var, "Operands of " + Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ")", false);
break;
case TYPE_INSN:
compare(((TypeInsnNode) instruction1).desc, ((TypeInsnNode) instruction2).desc, "Operands of " + Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ")");
break;
case FIELD_INSN:
{
FieldInsnNode fieldInsn1 = (FieldInsnNode) instruction1;
FieldInsnNode fieldInsn2 = (FieldInsnNode) instruction2;
compare(fieldInsn1.owner, fieldInsn2.owner, "Owning class name of " + Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ")");
compare(fieldInsn1.name, fieldInsn2.name, "Field name of " + Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ")");
compare(fieldInsn1.desc, fieldInsn2.desc, "Descriptor of " + Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ")");
break;
}
case METHOD_INSN:
{
MethodInsnNode methodInsn1 = (MethodInsnNode) instruction1;
MethodInsnNode methodInsn2 = (MethodInsnNode) instruction2;
compare(methodInsn1.owner, methodInsn2.owner, "Owning class name of " + Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ")");
compare(methodInsn1.name, methodInsn2.name, "Method name of " + Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ")");
compare(methodInsn1.desc, methodInsn2.desc, "Descriptor of " + Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ")");
break;
}
case INVOKE_DYNAMIC_INSN:
compareInvokeDynamic((InvokeDynamicInsnNode) instruction1, (InvokeDynamicInsnNode) instruction2, method1, index);
break;
case JUMP_INSN:
compare(method1, ((JumpInsnNode) instruction1).label, method2, ((JumpInsnNode) instruction2).label, "Operands of " + Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ")");
break;
case LABEL:
/* Do nothing */
break;
case LDC_INSN:
if (!((LdcInsnNode) instruction1).cst.equals(((LdcInsnNode) instruction2).cst)) {
reportDifference("Operands of " + Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ") differ: " + ((LdcInsnNode) instruction1).cst + ", " + ((LdcInsnNode) instruction2).cst);
}
break;
case IINC_INSN:
{
IincInsnNode iincInsn1 = (IincInsnNode) instruction1;
IincInsnNode iincInsn2 = (IincInsnNode) instruction2;
compare(iincInsn1.var, iincInsn2.var, "Variable operands of " + Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ")", false);
compare(iincInsn1.incr, iincInsn2.incr, "Increment operands of " + Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ")", false);
break;
}
case TABLESWITCH_INSN:
{
TableSwitchInsnNode tableSwitchInsn1 = (TableSwitchInsnNode) instruction1;
TableSwitchInsnNode tableSwitchInsn2 = (TableSwitchInsnNode) instruction2;
compare(tableSwitchInsn1.min, tableSwitchInsn2.min, Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ") minimum key value", false);
compare(tableSwitchInsn1.max, tableSwitchInsn2.max, Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ") maximum key value", false);
compare(method1, tableSwitchInsn1.dflt, method2, tableSwitchInsn2.dflt, Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ") default_handler_block");
compareLabels(method1, tableSwitchInsn1.labels, method2, tableSwitchInsn2.labels, Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ") handler_blocks");
break;
}
case LOOKUPSWITCH_INSN:
{
LookupSwitchInsnNode lookupSwitchInsn1 = (LookupSwitchInsnNode) instruction1;
LookupSwitchInsnNode lookupSwitchInsn2 = (LookupSwitchInsnNode) instruction2;
compare(method1, lookupSwitchInsn1.dflt, method2, lookupSwitchInsn2.dflt, Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ") default_handler_block");
compare(lookupSwitchInsn1.keys, lookupSwitchInsn2.keys, Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ") key values");
compareLabels(method1, lookupSwitchInsn1.labels, method2, lookupSwitchInsn2.labels, Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ") handler_blocks");
break;
}
case MULTIANEWARRAY_INSN:
{
MultiANewArrayInsnNode arrayInsn1 = (MultiANewArrayInsnNode) instruction1;
MultiANewArrayInsnNode arrayInsn2 = (MultiANewArrayInsnNode) instruction2;
compare(arrayInsn1.desc, arrayInsn2.desc, "Desc operand of " + Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ")");
compare(arrayInsn1.dims, arrayInsn2.dims, "Dimension operand of " + Printer.OPCODES[instruction1.getOpcode()] + " (" + method1.name + ":" + index + ")", false);
break;
}
case FRAME:
{
FrameNode frameInsn1 = (FrameNode) instruction1;
FrameNode frameInsn2 = (FrameNode) instruction2;
compare(frameInsn1.type, frameInsn2.type, "Stack map frame (" + method1.name + ":" + index + ") frame type", false);
compareFrames(frameInsn1.local, frameInsn2.local, "Stack map frame (" + method1.name + ":" + index + ") types of the local variables");
compareFrames(frameInsn1.stack, frameInsn2.stack, "Stack map frame (" + method1.name + ":" + index + ") types of the operand stack elements");
}
break;
case LINE:
{
assert shouldCompareDebugInfo;
LineNumberNode lineInsn1 = (LineNumberNode) instruction1;
LineNumberNode lineInsn2 = (LineNumberNode) instruction2;
compare(lineInsn1.line, lineInsn2.line, "Line number (" + method1.name + ":" + index + ") line No.", false);
compare(method1, lineInsn1.start, method2, lineInsn2.start, "Line number (" + method1.name + ":" + index + ") offset of the 1st instruction");
break;
}
default:
assert false;
}
}
index++;
}
}
}
use of org.objectweb.asm.tree.MultiANewArrayInsnNode in project phosphor by gmu-swe.
the class Frame method execute.
public void execute(final AbstractInsnNode insn, final Interpreter interpreter) throws AnalyzerException {
V value1, value2, value3, value4;
List<V> values;
int var;
switch(insn.getOpcode()) {
case Opcodes.NOP:
break;
case Opcodes.ACONST_NULL:
case Opcodes.ICONST_M1:
case Opcodes.ICONST_0:
case Opcodes.ICONST_1:
case Opcodes.ICONST_2:
case Opcodes.ICONST_3:
case Opcodes.ICONST_4:
case Opcodes.ICONST_5:
case Opcodes.LCONST_0:
case Opcodes.LCONST_1:
case Opcodes.FCONST_0:
case Opcodes.FCONST_1:
case Opcodes.FCONST_2:
case Opcodes.DCONST_0:
case Opcodes.DCONST_1:
case Opcodes.BIPUSH:
case Opcodes.SIPUSH:
case Opcodes.LDC:
push((V) interpreter.newOperation(insn));
break;
case Opcodes.ILOAD:
case Opcodes.LLOAD:
case Opcodes.FLOAD:
case Opcodes.DLOAD:
case Opcodes.ALOAD:
push((V) interpreter.copyOperation(insn, getLocal(((VarInsnNode) insn).var)));
break;
case Opcodes.IALOAD:
case Opcodes.LALOAD:
case Opcodes.FALOAD:
case Opcodes.DALOAD:
case Opcodes.AALOAD:
case Opcodes.BALOAD:
case Opcodes.CALOAD:
case Opcodes.SALOAD:
value2 = pop();
value1 = pop();
push((V) interpreter.binaryOperation(insn, value1, value2));
break;
case Opcodes.ISTORE:
case Opcodes.LSTORE:
case Opcodes.FSTORE:
case Opcodes.DSTORE:
case Opcodes.ASTORE:
value1 = (V) interpreter.copyOperation(insn, pop());
var = ((VarInsnNode) insn).var;
setLocal(var, value1);
if (value1.getSize() == 2) {
setLocal(var + 1, (V) interpreter.newValue(null));
}
if (var > 0) {
Value local = getLocal(var - 1);
if (local != null && local.getSize() == 2) {
setLocal(var - 1, (V) interpreter.newValue(null));
}
}
break;
case Opcodes.IASTORE:
case Opcodes.LASTORE:
case Opcodes.FASTORE:
case Opcodes.DASTORE:
case Opcodes.AASTORE:
case Opcodes.BASTORE:
case Opcodes.CASTORE:
case Opcodes.SASTORE:
value3 = pop();
value2 = pop();
value1 = pop();
interpreter.ternaryOperation(insn, value1, value2, value3);
break;
case Opcodes.POP:
if (pop().getSize() == 2) {
throw new AnalyzerException(insn, "Illegal use of POP");
}
break;
case Opcodes.POP2:
if (pop().getSize() == 1 && pop().getSize() != 1) {
throw new AnalyzerException(insn, "Illegal use of POP2");
}
break;
case Opcodes.DUP:
value1 = pop();
if (value1.getSize() != 1) {
throw new AnalyzerException(insn, "Illegal use of DUP");
}
push(value1);
push((V) interpreter.copyOperation(insn, value1));
break;
case Opcodes.DUP_X1:
value1 = pop();
value2 = pop();
if (value1.getSize() != 1 || value2.getSize() != 1) {
throw new AnalyzerException(insn, "Illegal use of DUP_X1");
}
push((V) interpreter.copyOperation(insn, value1));
push(value2);
push(value1);
break;
case Opcodes.DUP_X2:
value1 = pop();
if (value1.getSize() == 1) {
value2 = pop();
if (value2.getSize() == 1) {
value3 = pop();
if (value3.getSize() == 1) {
push((V) interpreter.copyOperation(insn, value1));
push(value3);
push(value2);
push(value1);
break;
}
} else {
push((V) interpreter.copyOperation(insn, value1));
push(value2);
push(value1);
break;
}
}
throw new AnalyzerException(insn, "Illegal use of DUP_X2");
case Opcodes.DUP2:
value1 = pop();
if (value1.getSize() == 1) {
value2 = pop();
if (value2.getSize() == 1) {
push(value2);
push(value1);
push((V) interpreter.copyOperation(insn, value2));
push((V) interpreter.copyOperation(insn, value1));
break;
}
} else {
push(value1);
push((V) interpreter.copyOperation(insn, value1));
break;
}
throw new AnalyzerException(insn, "Illegal use of DUP2");
case Opcodes.DUP2_X1:
value1 = pop();
if (value1.getSize() == 1) {
value2 = pop();
if (value2.getSize() == 1) {
value3 = pop();
if (value3.getSize() == 1) {
push((V) interpreter.copyOperation(insn, value2));
push((V) interpreter.copyOperation(insn, value1));
push(value3);
push(value2);
push(value1);
break;
}
}
} else {
value2 = pop();
if (value2.getSize() == 1) {
push((V) interpreter.copyOperation(insn, value1));
push(value2);
push(value1);
break;
}
}
throw new AnalyzerException(insn, "Illegal use of DUP2_X1");
case Opcodes.DUP2_X2:
value1 = pop();
if (value1.getSize() == 1) {
value2 = pop();
if (value2.getSize() == 1) {
value3 = pop();
if (value3.getSize() == 1) {
value4 = pop();
if (value4.getSize() == 1) {
push((V) interpreter.copyOperation(insn, value2));
push((V) interpreter.copyOperation(insn, value1));
push(value4);
push(value3);
push(value2);
push(value1);
break;
}
} else {
push((V) interpreter.copyOperation(insn, value2));
push((V) interpreter.copyOperation(insn, value1));
push(value3);
push(value2);
push(value1);
break;
}
}
} else {
value2 = pop();
if (value2.getSize() == 1) {
value3 = pop();
if (value3.getSize() == 1) {
push((V) interpreter.copyOperation(insn, value1));
push(value3);
push(value2);
push(value1);
break;
}
} else {
push((V) interpreter.copyOperation(insn, value1));
push(value2);
push(value1);
break;
}
}
throw new AnalyzerException(insn, "Illegal use of DUP2_X2");
case Opcodes.SWAP:
value2 = pop();
value1 = pop();
if (value1.getSize() != 1 || value2.getSize() != 1) {
throw new AnalyzerException(insn, "Illegal use of SWAP");
}
push((V) interpreter.copyOperation(insn, value2));
push((V) interpreter.copyOperation(insn, value1));
break;
case Opcodes.IADD:
case Opcodes.LADD:
case Opcodes.FADD:
case Opcodes.DADD:
case Opcodes.ISUB:
case Opcodes.LSUB:
case Opcodes.FSUB:
case Opcodes.DSUB:
case Opcodes.IMUL:
case Opcodes.LMUL:
case Opcodes.FMUL:
case Opcodes.DMUL:
case Opcodes.IDIV:
case Opcodes.LDIV:
case Opcodes.FDIV:
case Opcodes.DDIV:
case Opcodes.IREM:
case Opcodes.LREM:
case Opcodes.FREM:
case Opcodes.DREM:
value2 = pop();
value1 = pop();
push((V) interpreter.binaryOperation(insn, value1, value2));
break;
case Opcodes.INEG:
case Opcodes.LNEG:
case Opcodes.FNEG:
case Opcodes.DNEG:
push((V) interpreter.unaryOperation(insn, pop()));
break;
case Opcodes.ISHL:
case Opcodes.LSHL:
case Opcodes.ISHR:
case Opcodes.LSHR:
case Opcodes.IUSHR:
case Opcodes.LUSHR:
case Opcodes.IAND:
case Opcodes.LAND:
case Opcodes.IOR:
case Opcodes.LOR:
case Opcodes.IXOR:
case Opcodes.LXOR:
value2 = pop();
value1 = pop();
push((V) interpreter.binaryOperation(insn, value1, value2));
break;
case Opcodes.IINC:
var = ((IincInsnNode) insn).var;
setLocal(var, (V) interpreter.unaryOperation(insn, getLocal(var)));
break;
case Opcodes.I2L:
case Opcodes.I2F:
case Opcodes.I2D:
case Opcodes.L2I:
case Opcodes.L2F:
case Opcodes.L2D:
case Opcodes.F2I:
case Opcodes.F2L:
case Opcodes.F2D:
case Opcodes.D2I:
case Opcodes.D2L:
case Opcodes.D2F:
case Opcodes.I2B:
case Opcodes.I2C:
case Opcodes.I2S:
push((V) interpreter.unaryOperation(insn, pop()));
break;
case Opcodes.LCMP:
case Opcodes.FCMPL:
case Opcodes.FCMPG:
case Opcodes.DCMPL:
case Opcodes.DCMPG:
value2 = pop();
value1 = pop();
push((V) interpreter.binaryOperation(insn, value1, value2));
break;
case Opcodes.IFEQ:
case Opcodes.IFNE:
case Opcodes.IFLT:
case Opcodes.IFGE:
case Opcodes.IFGT:
case Opcodes.IFLE:
interpreter.unaryOperation(insn, pop());
break;
case Opcodes.IF_ICMPEQ:
case Opcodes.IF_ICMPNE:
case Opcodes.IF_ICMPLT:
case Opcodes.IF_ICMPGE:
case Opcodes.IF_ICMPGT:
case Opcodes.IF_ICMPLE:
case Opcodes.IF_ACMPEQ:
case Opcodes.IF_ACMPNE:
value2 = pop();
value1 = pop();
interpreter.binaryOperation(insn, value1, value2);
break;
case Opcodes.GOTO:
break;
case Opcodes.JSR:
push((V) interpreter.newOperation(insn));
break;
case Opcodes.RET:
break;
case Opcodes.TABLESWITCH:
case Opcodes.LOOKUPSWITCH:
interpreter.unaryOperation(insn, pop());
break;
case Opcodes.IRETURN:
case Opcodes.LRETURN:
case Opcodes.FRETURN:
case Opcodes.DRETURN:
case Opcodes.ARETURN:
value1 = pop();
interpreter.unaryOperation(insn, value1);
interpreter.returnOperation(insn, value1, returnValue);
break;
case Opcodes.RETURN:
if (returnValue != null) {
throw new AnalyzerException(insn, "Incompatible return type");
}
break;
case Opcodes.GETSTATIC:
push((V) interpreter.newOperation(insn));
break;
case Opcodes.PUTSTATIC:
interpreter.unaryOperation(insn, pop());
break;
case Opcodes.GETFIELD:
push((V) interpreter.unaryOperation(insn, pop()));
break;
case Opcodes.PUTFIELD:
value2 = pop();
value1 = pop();
interpreter.binaryOperation(insn, value1, value2);
break;
case Opcodes.INVOKEVIRTUAL:
case Opcodes.INVOKESPECIAL:
case Opcodes.INVOKESTATIC:
case Opcodes.INVOKEINTERFACE:
{
values = new ArrayList<V>();
String desc = ((MethodInsnNode) insn).desc;
for (int i = Type.getArgumentTypes(desc).length; i > 0; --i) {
values.add(0, pop());
}
if (insn.getOpcode() != Opcodes.INVOKESTATIC) {
values.add(0, pop());
}
if (Type.getReturnType(desc) == Type.VOID_TYPE) {
interpreter.naryOperation(insn, values);
} else {
push((V) interpreter.naryOperation(insn, values));
}
break;
}
case Opcodes.INVOKEDYNAMIC:
{
values = new ArrayList<V>();
String desc = ((InvokeDynamicInsnNode) insn).desc;
for (int i = Type.getArgumentTypes(desc).length; i > 0; --i) {
values.add(0, pop());
}
if (Type.getReturnType(desc) == Type.VOID_TYPE) {
interpreter.naryOperation(insn, values);
} else {
push((V) interpreter.naryOperation(insn, values));
}
break;
}
case Opcodes.NEW:
push((V) interpreter.newOperation(insn));
break;
case Opcodes.NEWARRAY:
case Opcodes.ANEWARRAY:
case Opcodes.ARRAYLENGTH:
push((V) interpreter.unaryOperation(insn, pop()));
break;
case Opcodes.ATHROW:
interpreter.unaryOperation(insn, pop());
break;
case Opcodes.CHECKCAST:
case Opcodes.INSTANCEOF:
push((V) interpreter.unaryOperation(insn, pop()));
break;
case Opcodes.MONITORENTER:
case Opcodes.MONITOREXIT:
interpreter.unaryOperation(insn, pop());
break;
case Opcodes.MULTIANEWARRAY:
values = new ArrayList<V>();
for (int i = ((MultiANewArrayInsnNode) insn).dims; i > 0; --i) {
values.add(0, pop());
}
push((V) interpreter.naryOperation(insn, values));
break;
case Opcodes.IFNULL:
case Opcodes.IFNONNULL:
interpreter.unaryOperation(insn, pop());
break;
}
}
use of org.objectweb.asm.tree.MultiANewArrayInsnNode in project soot by Sable.
the class AsmMethodSource method convert.
private void convert() {
ArrayDeque<Edge> worklist = new ArrayDeque<Edge>();
for (LabelNode ln : trapHandlers.keySet()) {
if (checkInlineExceptionHandler(ln))
handleInlineExceptionHandler(ln, worklist);
else
worklist.add(new Edge(ln, new ArrayList<Operand>()));
}
worklist.add(new Edge(instructions.getFirst(), new ArrayList<Operand>()));
conversionWorklist = worklist;
edges = HashBasedTable.create(1, 1);
do {
Edge edge = worklist.pollLast();
AbstractInsnNode insn = edge.insn;
stack = edge.stack;
edge.stack = null;
do {
int type = insn.getType();
if (type == FIELD_INSN) {
convertFieldInsn((FieldInsnNode) insn);
} else if (type == IINC_INSN) {
convertIincInsn((IincInsnNode) insn);
} else if (type == INSN) {
convertInsn((InsnNode) insn);
int op = insn.getOpcode();
if ((op >= IRETURN && op <= RETURN) || op == ATHROW) {
break;
}
} else if (type == INT_INSN) {
convertIntInsn((IntInsnNode) insn);
} else if (type == LDC_INSN) {
convertLdcInsn((LdcInsnNode) insn);
} else if (type == JUMP_INSN) {
JumpInsnNode jmp = (JumpInsnNode) insn;
convertJumpInsn(jmp);
int op = jmp.getOpcode();
if (op == JSR)
throw new UnsupportedOperationException("JSR!");
if (op != GOTO) {
/* ifX opcode, i.e. two successors */
AbstractInsnNode next = insn.getNext();
addEdges(insn, next, Collections.singletonList(jmp.label));
} else {
addEdges(insn, jmp.label, null);
}
break;
} else if (type == LOOKUPSWITCH_INSN) {
LookupSwitchInsnNode swtch = (LookupSwitchInsnNode) insn;
convertLookupSwitchInsn(swtch);
LabelNode dflt = swtch.dflt;
addEdges(insn, dflt, swtch.labels);
break;
} else if (type == METHOD_INSN) {
convertMethodInsn((MethodInsnNode) insn);
} else if (type == INVOKE_DYNAMIC_INSN) {
convertInvokeDynamicInsn((InvokeDynamicInsnNode) insn);
} else if (type == MULTIANEWARRAY_INSN) {
convertMultiANewArrayInsn((MultiANewArrayInsnNode) insn);
} else if (type == TABLESWITCH_INSN) {
TableSwitchInsnNode swtch = (TableSwitchInsnNode) insn;
convertTableSwitchInsn(swtch);
LabelNode dflt = swtch.dflt;
addEdges(insn, dflt, swtch.labels);
} else if (type == TYPE_INSN) {
convertTypeInsn((TypeInsnNode) insn);
} else if (type == VAR_INSN) {
if (insn.getOpcode() == RET)
throw new UnsupportedOperationException("RET!");
convertVarInsn((VarInsnNode) insn);
} else if (type == LABEL) {
convertLabel((LabelNode) insn);
} else if (type == LINE) {
convertLine((LineNumberNode) insn);
} else if (type == FRAME) {
// we can ignore it
} else
throw new RuntimeException("Unknown instruction type: " + type);
} while ((insn = insn.getNext()) != null);
} while (!worklist.isEmpty());
conversionWorklist = null;
edges = null;
}
use of org.objectweb.asm.tree.MultiANewArrayInsnNode in project bytecode-viewer by Konloch.
the class RegexInsnFinder method getInsString.
private static String getInsString(AbstractInsnNode ain) {
String insnString = "";
switch(ain.getType()) {
case AbstractInsnNode.INT_INSN:
final IntInsnNode iin = (IntInsnNode) ain;
insnString += "{" + iin.operand + "}";
break;
case AbstractInsnNode.LDC_INSN:
final LdcInsnNode lin = (LdcInsnNode) ain;
insnString += "{" + lin.cst.toString().replace("}", "\\}") + "}";
break;
case AbstractInsnNode.VAR_INSN:
final VarInsnNode vin = (VarInsnNode) ain;
insnString += "_" + vin.var;
break;
case AbstractInsnNode.IINC_INSN:
final IincInsnNode iiin = (IincInsnNode) ain;
insnString += "{" + iiin.var + "," + iiin.incr + "}";
break;
case AbstractInsnNode.FIELD_INSN:
final FieldInsnNode fin = (FieldInsnNode) ain;
insnString += "{" + fin.desc + "," + fin.owner + "," + fin.name + "}";
break;
case AbstractInsnNode.METHOD_INSN:
final MethodInsnNode min = (MethodInsnNode) ain;
insnString += "{" + min.desc + "," + min.owner + "," + min.name + "}";
break;
case AbstractInsnNode.TYPE_INSN:
final TypeInsnNode tin = (TypeInsnNode) ain;
insnString += "{" + tin.desc + "}";
break;
case AbstractInsnNode.MULTIANEWARRAY_INSN:
final MultiANewArrayInsnNode manain = (MultiANewArrayInsnNode) ain;
insnString += "{" + manain.dims + "," + manain.desc + "}";
break;
}
return insnString;
}
use of org.objectweb.asm.tree.MultiANewArrayInsnNode in project evosuite by EvoSuite.
the class MethodNodeTransformer method transform.
/**
* <p>transform</p>
*
* @param mn a {@link org.objectweb.asm.tree.MethodNode} object.
*/
public void transform(MethodNode mn) {
setupLocals(mn);
Set<AbstractInsnNode> originalNodes = new HashSet<AbstractInsnNode>();
AbstractInsnNode node = mn.instructions.getFirst();
while (node != mn.instructions.getLast()) {
originalNodes.add(node);
node = node.getNext();
}
// int currentIndex = 0;
node = mn.instructions.getFirst();
// while (currentIndex < mn.instructions.size()) {
boolean finished = false;
while (!finished) {
// } else
if (node instanceof MethodInsnNode) {
node = transformMethodInsnNode(mn, (MethodInsnNode) node);
} else if (node instanceof VarInsnNode) {
node = transformVarInsnNode(mn, (VarInsnNode) node);
} else if (node instanceof FieldInsnNode) {
node = transformFieldInsnNode(mn, (FieldInsnNode) node);
} else if (node instanceof InsnNode) {
node = transformInsnNode(mn, (InsnNode) node);
} else if (node instanceof TypeInsnNode) {
node = transformTypeInsnNode(mn, (TypeInsnNode) node);
} else if (node instanceof JumpInsnNode) {
node = transformJumpInsnNode(mn, (JumpInsnNode) node);
} else if (node instanceof LabelNode) {
node = transformLabelNode(mn, (LabelNode) node);
} else if (node instanceof IntInsnNode) {
node = transformIntInsnNode(mn, (IntInsnNode) node);
} else if (node instanceof MultiANewArrayInsnNode) {
node = transformMultiANewArrayInsnNode(mn, (MultiANewArrayInsnNode) node);
}
if (node == mn.instructions.getLast()) {
finished = true;
} else {
node = node.getNext();
}
}
}
Aggregations