Search in sources :

Example 1 with Instruction

use of org.freud.analysed.classbytecode.method.instruction.Instruction 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);
}
Also used : ReferenceOperandInstruction(org.freud.analysed.classbytecode.method.instruction.ReferenceOperandInstruction) Opcode(org.freud.analysed.classbytecode.method.instruction.Opcode) Instruction(org.freud.analysed.classbytecode.method.instruction.Instruction) ReferenceOperandInstruction(org.freud.analysed.classbytecode.method.instruction.ReferenceOperandInstruction) VarInstruction(org.freud.analysed.classbytecode.method.instruction.VarInstruction) JumpInstruction(org.freud.analysed.classbytecode.method.instruction.JumpInstruction) ConstInstruction(org.freud.analysed.classbytecode.method.instruction.ConstInstruction) FieldInstruction(org.freud.analysed.classbytecode.method.instruction.FieldInstruction) IntOperandInstruction(org.freud.analysed.classbytecode.method.instruction.IntOperandInstruction) MethodInvocationInstruction(org.freud.analysed.classbytecode.method.instruction.MethodInvocationInstruction)

Example 2 with Instruction

use of org.freud.analysed.classbytecode.method.instruction.Instruction in project freud by LMAX-Exchange.

the class AsmMethod method visitJumpInsn.

public void visitJumpInsn(final int opcode, final org.objectweb.asm.Label asmLabel) {
    Label label = declareLabel(asmLabel);
    //        System.out.println(name + " " + OPCODES_ARRAY[opcode] + " " + asmLabel + " " + label);
    final Instruction instruction = new JumpInstruction(instructionList.size(), OPCODES_ARRAY[opcode], currentLineNumber, label);
    updateCurrentState(instruction);
}
Also used : Label(org.freud.analysed.classbytecode.method.instruction.Label) Instruction(org.freud.analysed.classbytecode.method.instruction.Instruction) ReferenceOperandInstruction(org.freud.analysed.classbytecode.method.instruction.ReferenceOperandInstruction) VarInstruction(org.freud.analysed.classbytecode.method.instruction.VarInstruction) JumpInstruction(org.freud.analysed.classbytecode.method.instruction.JumpInstruction) ConstInstruction(org.freud.analysed.classbytecode.method.instruction.ConstInstruction) FieldInstruction(org.freud.analysed.classbytecode.method.instruction.FieldInstruction) IntOperandInstruction(org.freud.analysed.classbytecode.method.instruction.IntOperandInstruction) MethodInvocationInstruction(org.freud.analysed.classbytecode.method.instruction.MethodInvocationInstruction) JumpInstruction(org.freud.analysed.classbytecode.method.instruction.JumpInstruction)

Example 3 with Instruction

use of org.freud.analysed.classbytecode.method.instruction.Instruction in project freud by LMAX-Exchange.

the class AsmMethod method visitFieldInsn.

public void visitFieldInsn(final int opcode, final String owner, final String name, final String desc) {
    final Instruction instruction = new FieldInstruction(instructionList.size(), OPCODES_ARRAY[opcode], currentLineNumber, owner, name, desc);
    updateCurrentState(instruction);
}
Also used : FieldInstruction(org.freud.analysed.classbytecode.method.instruction.FieldInstruction) Instruction(org.freud.analysed.classbytecode.method.instruction.Instruction) ReferenceOperandInstruction(org.freud.analysed.classbytecode.method.instruction.ReferenceOperandInstruction) VarInstruction(org.freud.analysed.classbytecode.method.instruction.VarInstruction) JumpInstruction(org.freud.analysed.classbytecode.method.instruction.JumpInstruction) ConstInstruction(org.freud.analysed.classbytecode.method.instruction.ConstInstruction) FieldInstruction(org.freud.analysed.classbytecode.method.instruction.FieldInstruction) IntOperandInstruction(org.freud.analysed.classbytecode.method.instruction.IntOperandInstruction) MethodInvocationInstruction(org.freud.analysed.classbytecode.method.instruction.MethodInvocationInstruction)

Example 4 with Instruction

use of org.freud.analysed.classbytecode.method.instruction.Instruction in project freud by LMAX-Exchange.

the class ClassByteCodeDsl method hasMethodInvocation.

public static boolean hasMethodInvocation(final ClassByteCodeMethod analysed, final Class expectedOwner, final String expectedMethodName, final Class... expectedParamsDeclared) {
    final boolean[] found = new boolean[] { false };
    final String expectedOwnerName = typeEncoding(expectedOwner);
    final String[] expectedParamNames = (expectedParamsDeclared.length == 0) ? EMPTY_ARGS : new String[expectedParamsDeclared.length];
    for (int i = 0, size = expectedParamsDeclared.length; i < size; i++) {
        expectedParamNames[i] = typeEncoding(expectedParamsDeclared[i]);
    }
    found[0] = false;
    analysed.findInstruction(new AbstractInstructionVisitor() {

        @Override
        public void methodInvocation(final Instruction instruction, final String owner, final String methodName, final String... args) {
            if (!found[0] && expectedOwnerName.equals(owner) && expectedMethodName.equals(methodName) && Arrays.equals(expectedParamNames, args)) {
                found[0] = true;
            }
        }
    });
    return found[0];
}
Also used : Instruction(org.freud.analysed.classbytecode.method.instruction.Instruction) AbstractInstructionVisitor(org.freud.analysed.classbytecode.method.instruction.AbstractInstructionVisitor)

Example 5 with Instruction

use of org.freud.analysed.classbytecode.method.instruction.Instruction in project freud by LMAX-Exchange.

the class AsmMethod method visitMultiANewArrayInsn.

public void visitMultiANewArrayInsn(final String desc, final int dims) {
    final Instruction instruction = new ReferenceOperandInstruction(instructionList.size(), Opcode.MULTIANEWARRAY, currentLineNumber, desc, dims);
    updateCurrentState(instruction);
}
Also used : ReferenceOperandInstruction(org.freud.analysed.classbytecode.method.instruction.ReferenceOperandInstruction) Instruction(org.freud.analysed.classbytecode.method.instruction.Instruction) ReferenceOperandInstruction(org.freud.analysed.classbytecode.method.instruction.ReferenceOperandInstruction) VarInstruction(org.freud.analysed.classbytecode.method.instruction.VarInstruction) JumpInstruction(org.freud.analysed.classbytecode.method.instruction.JumpInstruction) ConstInstruction(org.freud.analysed.classbytecode.method.instruction.ConstInstruction) FieldInstruction(org.freud.analysed.classbytecode.method.instruction.FieldInstruction) IntOperandInstruction(org.freud.analysed.classbytecode.method.instruction.IntOperandInstruction) MethodInvocationInstruction(org.freud.analysed.classbytecode.method.instruction.MethodInvocationInstruction)

Aggregations

Instruction (org.freud.analysed.classbytecode.method.instruction.Instruction)16 ConstInstruction (org.freud.analysed.classbytecode.method.instruction.ConstInstruction)10 FieldInstruction (org.freud.analysed.classbytecode.method.instruction.FieldInstruction)10 IntOperandInstruction (org.freud.analysed.classbytecode.method.instruction.IntOperandInstruction)10 JumpInstruction (org.freud.analysed.classbytecode.method.instruction.JumpInstruction)10 MethodInvocationInstruction (org.freud.analysed.classbytecode.method.instruction.MethodInvocationInstruction)10 ReferenceOperandInstruction (org.freud.analysed.classbytecode.method.instruction.ReferenceOperandInstruction)10 VarInstruction (org.freud.analysed.classbytecode.method.instruction.VarInstruction)10 AbstractInstructionVisitor (org.freud.analysed.classbytecode.method.instruction.AbstractInstructionVisitor)6 Opcode (org.freud.analysed.classbytecode.method.instruction.Opcode)4 ClassByteCodeMethod (org.freud.analysed.classbytecode.method.ClassByteCodeMethod)3 FreudExtendedMatcher (org.freud.java.matcher.FreudExtendedMatcher)3 Description (org.hamcrest.Description)3 OperandStack (org.freud.analysed.classbytecode.method.instruction.OperandStack)2 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1 CastOperandStack (org.freud.analysed.classbytecode.method.instruction.CastOperandStack)1 Label (org.freud.analysed.classbytecode.method.instruction.Label)1 Matcher (org.hamcrest.Matcher)1 Type (org.objectweb.asm.Type)1