use of org.freud.analysed.classbytecode.method.instruction.Opcode in project freud by LMAX-Exchange.
the class AsmMethod method visitTypeInsn.
public void visitTypeInsn(final int opcodeUsed, final String type) {
final Opcode opcode = OPCODES_ARRAY[opcodeUsed];
final String operandType = "L" + type + ";";
final Instruction instruction = new ReferenceOperandInstruction(instructionList.size(), opcode, currentLineNumber, operandType);
updateCurrentState(instruction);
}
use of org.freud.analysed.classbytecode.method.instruction.Opcode in project freud by LMAX-Exchange.
the class AsmMethod method updateCurrentState.
private void updateCurrentState(final Instruction instruction) {
instructionList.add(instruction);
// System.out.println(name + " " + instruction + " " + labelByAsmLabelMap);
final Opcode opcode = instruction.getOpcode();
ensureCurrentLocalsSize(instruction.getVarIndex());
currentLocals = opcode.updateLocals(currentLocals, instruction);
currentOperandStack = opcode.updateOperandStack(this, instruction, currentOperandStack);
instruction.setOperandStack(currentOperandStack);
}
use of org.freud.analysed.classbytecode.method.instruction.Opcode in project freud by LMAX-Exchange.
the class ClassByteCodeMethodMatchers method containsInstructions.
public static FreudExtendedMatcher<ClassByteCodeMethod> containsInstructions(final Opcode... opcodes) {
return new FreudExtendedMatcher<ClassByteCodeMethod>() {
private Instruction found = null;
@Override
protected boolean matchesSafely(final ClassByteCodeMethod item) {
item.findInstruction(new AbstractInstructionVisitor() {
@Override
public void noArgInstruction(final Instruction instruction) {
for (int i = 0; i < opcodes.length; i++) {
Opcode opcode = opcodes[i];
if (instruction.getOpcode() == opcode) {
found = instruction;
break;
}
}
}
});
return found != null;
}
@Override
public void describeTo(final Description description) {
description.appendText("containsInstructions(");
for (int i = 0; i < opcodes.length; i++) {
Opcode opcode = opcodes[i];
description.appendText(opcode.name());
description.appendText(", ");
}
description.appendText(") found");
}
};
}
use of org.freud.analysed.classbytecode.method.instruction.Opcode in project freud by LMAX-Exchange.
the class AsmMethod method visitIntInsn.
public void visitIntInsn(final int opcodeUsed, final int operand) {
final Opcode opcode = OPCODES_ARRAY[opcodeUsed];
final Instruction instruction;
if (opcode == Opcode.NEWARRAY) {
instruction = new ReferenceOperandInstruction(instructionList.size(), opcode, currentLineNumber, NEWARRAY_TYPES[operand]);
} else {
instruction = new IntOperandInstruction(instructionList.size(), opcode, currentLineNumber, operand);
}
updateCurrentState(instruction);
}
use of org.freud.analysed.classbytecode.method.instruction.Opcode in project freud by LMAX-Exchange.
the class ClassByteCodeDsl method containsInstructions.
public static boolean containsInstructions(final ClassByteCodeMethod analysed, final Opcode... opcodes) {
final Instruction[] found = new Instruction[1];
analysed.findInstruction(new AbstractInstructionVisitor() {
@Override
public void noArgInstruction(final Instruction instruction) {
for (int i = 0; i < opcodes.length; i++) {
Opcode opcode = opcodes[i];
if (instruction.getOpcode() == opcode) {
found[0] = instruction;
break;
}
}
}
});
return found[0] != null;
}
Aggregations