Search in sources :

Example 1 with Properties

use of org.evosuite.Properties in project evosuite by EvoSuite.

the class ArrayAllocationLimitMethodAdapter method visitMultiANewArrayInsn.

/* (non-Javadoc)
	 * @see org.objectweb.asm.MethodVisitor#visitMultiANewArrayInsn(java.lang.String, int)
	 */
/**
 * {@inheritDoc}
 */
@Override
public void visitMultiANewArrayInsn(String desc, int dims) {
    Label origTarget = new Label();
    Label errorTarget = new Label();
    // Multidimensional arrays can only have max 256 dimensions
    if (Properties.ARRAY_LIMIT < 256) {
        push(dims);
        visitFieldInsn(Opcodes.GETSTATIC, PackageInfo.getNameWithSlash(org.evosuite.Properties.class), "ARRAY_LIMIT", "I");
        super.visitJumpInsn(Opcodes.IF_ICMPGE, errorTarget);
    }
    // Check each of the dimensions
    Map<Integer, Integer> to = new HashMap<Integer, Integer>();
    for (int i = dims - 1; i >= 0; i--) {
        int loc = newLocal(Type.INT_TYPE);
        storeLocal(loc);
        to.put(i, loc);
    }
    for (int i = 0; i < dims; i++) {
        loadLocal(to.get(i));
        visitFieldInsn(Opcodes.GETSTATIC, "org/evosuite/Properties", "ARRAY_LIMIT", "I");
        super.visitJumpInsn(Opcodes.IF_ICMPGE, errorTarget);
    }
    goTo(origTarget);
    super.visitLabel(errorTarget);
    super.visitTypeInsn(Opcodes.NEW, PackageInfo.getNameWithSlash(TestCaseExecutor.TimeoutExceeded.class));
    super.visitInsn(Opcodes.DUP);
    super.visitMethodInsn(Opcodes.INVOKESPECIAL, PackageInfo.getNameWithSlash(TestCaseExecutor.TimeoutExceeded.class), "<init>", "()V", false);
    super.visitInsn(Opcodes.ATHROW);
    super.visitLabel(origTarget);
    // Restore original dimensions
    for (int i = 0; i < dims; i++) {
        loadLocal(to.get(i));
    }
    super.visitMultiANewArrayInsn(desc, dims);
}
Also used : HashMap(java.util.HashMap) Label(org.objectweb.asm.Label) Properties(org.evosuite.Properties)

Aggregations

HashMap (java.util.HashMap)1 Properties (org.evosuite.Properties)1 Label (org.objectweb.asm.Label)1