Example usage for org.objectweb.asm.tree InsnList size

List of usage examples for org.objectweb.asm.tree InsnList size

Introduction

In this page you can find the example usage for org.objectweb.asm.tree InsnList size.

Prototype

int size

To view the source code for org.objectweb.asm.tree InsnList size.

Click Source Link

Document

The number of instructions in this list.

Usage

From source file:de.tuberlin.uebb.jbop.optimizer.arithmetic.ArithmeticExpressionInterpreterTest.java

License:Open Source License

/**
 * Tests that arithmeticExpressionInterpreter() of the Testobject is working correctly
 * for logical or expressions./*from   w w  w  .j av a 2  s .com*/
 */
@Test
public void testArithmeticExpressionInterpreterLogicalIntOr() {
    // INIT
    builder.addInsn(new InsnNode(Opcodes.ICONST_1)).//
            addInsn(new InsnNode(Opcodes.ICONST_2)).//
            addInsn(new InsnNode(Opcodes.IOR)).//
            addInsn(new InsnNode(Opcodes.RETURN));

    final InsnList optimized = interpreter.optimize(builder.getMethod("testMethod").instructions,
            builder.getMethod("testMethod"));

    assertEquals(2, optimized.size());
    assertEquals(3, NodeHelper.getNumberValue(optimized.get(0)));
}

From source file:de.tuberlin.uebb.jbop.optimizer.arithmetic.ArithmeticExpressionInterpreterTest.java

License:Open Source License

/**
 * Tests that arithmeticExpressionInterpreter() of the Testobject is working correctly
 * for logical xor expressions./*  w w w .  j  a v a  2 s.c o m*/
 */
@Test
public void testArithmeticExpressionInterpreterLogicalIntXOr() {
    // INIT
    builder.addInsn(new InsnNode(Opcodes.ICONST_1)).//
            addInsn(new InsnNode(Opcodes.ICONST_2)).//
            addInsn(new InsnNode(Opcodes.IXOR)).//
            addInsn(new InsnNode(Opcodes.RETURN));

    final InsnList optimized = interpreter.optimize(builder.getMethod("testMethod").instructions,
            builder.getMethod("testMethod"));

    assertEquals(2, optimized.size());
    assertEquals(3, NodeHelper.getNumberValue(optimized.get(0)));
}

From source file:de.tuberlin.uebb.jbop.optimizer.arithmetic.ArithmeticExpressionInterpreterTest.java

License:Open Source License

/**
 * Tests that arithmeticExpressionInterpreter() of the Testobject is working correctly
 * for logical and expressions.//from   ww w .  ja v  a2  s  .c o m
 */
@Test
public void testArithmeticExpressionInterpreterLogicalIntAnd() {
    // INIT
    builder.addInsn(new InsnNode(Opcodes.ICONST_1)).//
            addInsn(new InsnNode(Opcodes.ICONST_2)).//
            addInsn(new InsnNode(Opcodes.IAND)).//
            addInsn(new InsnNode(Opcodes.RETURN));

    final InsnList optimized = interpreter.optimize(builder.getMethod("testMethod").instructions,
            builder.getMethod("testMethod"));

    assertEquals(2, optimized.size());
    assertEquals(0, NodeHelper.getNumberValue(optimized.get(0)));
}

From source file:de.tuberlin.uebb.jbop.optimizer.arithmetic.ArithmeticExpressionInterpreterTest.java

License:Open Source License

/**
 * Tests that arithmeticExpressionInterpreter() of the Testobject is working correctly
 * for logical or expressions.//from  w  w w.java  2 s  . c  o m
 */
@Test
public void testArithmeticExpressionInterpreterLogicalLongOr() {
    // INIT
    builder.addInsn(new InsnNode(Opcodes.LCONST_1)).//
            addInsn(new InsnNode(Opcodes.LCONST_1)).//
            addInsn(new InsnNode(Opcodes.LOR)).//
            addInsn(new InsnNode(Opcodes.RETURN));

    final InsnList optimized = interpreter.optimize(builder.getMethod("testMethod").instructions,
            builder.getMethod("testMethod"));

    assertEquals(2, optimized.size());
    assertEquals(1l, NodeHelper.getNumberValue(optimized.get(0)));
}

From source file:de.tuberlin.uebb.jbop.optimizer.arithmetic.ArithmeticExpressionInterpreterTest.java

License:Open Source License

/**
 * Tests that arithmeticExpressionInterpreter() of the Testobject is working correctly
 * for logical xor expressions.//from  w  w w .  jav a  2  s  .  c  o  m
 */
@Test
public void testArithmeticExpressionInterpreterLogicalLongXOr() {
    // INIT
    builder.addInsn(new InsnNode(Opcodes.LCONST_1)).//
            addInsn(new InsnNode(Opcodes.LCONST_1)).//
            addInsn(new InsnNode(Opcodes.LXOR)).//
            addInsn(new InsnNode(Opcodes.RETURN));

    final InsnList optimized = interpreter.optimize(builder.getMethod("testMethod").instructions,
            builder.getMethod("testMethod"));

    assertEquals(2, optimized.size());
    assertEquals(0l, NodeHelper.getNumberValue(optimized.get(0)));
}

From source file:de.tuberlin.uebb.jbop.optimizer.arithmetic.ArithmeticExpressionInterpreterTest.java

License:Open Source License

/**
 * Tests that arithmeticExpressionInterpreter() of the Testobject is working correctly
 * for logical and expressions./*w w  w .  j  a  va2 s .com*/
 */
@Test
public void testArithmeticExpressionInterpreterLogicalLongAnd() {
    // INIT
    builder.addInsn(new InsnNode(Opcodes.LCONST_1)).//
            addInsn(new InsnNode(Opcodes.LCONST_1)).//
            addInsn(new InsnNode(Opcodes.LAND)).//
            addInsn(new InsnNode(Opcodes.RETURN));

    final InsnList optimized = interpreter.optimize(builder.getMethod("testMethod").instructions,
            builder.getMethod("testMethod"));

    assertEquals(2, optimized.size());
    assertEquals(1l, NodeHelper.getNumberValue(optimized.get(0)));
}

From source file:de.tuberlin.uebb.jbop.optimizer.arithmetic.ArithmeticExpressionInterpreterTest.java

License:Open Source License

/**
 * Tests that arithmeticExpressionInterpreter() of the Testobject is working correctly
 * for logical and expressions.// www  . j av  a2  s.  com
 */
@Test
public void testArithmeticExpressionComplexChain() {
    // INIT
    builder.getMethod("testMethod").desc = "()D";
    builder.add(DCONST_1).//
            loadConstant(2.0).//
            loadConstant(5.0).//
            add(DMUL).//
            add(DADD).//
            loadConstant(6.0).//
            add(DDIV).//
            add(ICONST_3).//
            add(ICONST_4).//
            add(IOR).//
            add(ICONST_5).//
            add(IAND).//
            add(I2D).//
            add(DMUL).//
            addReturn();
    final InsnList optimized = interpreter.optimize(builder.getMethod("testMethod").instructions,
            builder.getMethod("testMethod"));

    assertEquals(2, optimized.size());
    assertEquals(9.166666666666666, NodeHelper.getNumberValue(optimized.get(0)).doubleValue(), .0000001);
}

From source file:de.tuberlin.uebb.jbop.optimizer.arithmetic.ArithmeticExpressionInterpreterTest.java

License:Open Source License

/**
 * (1234&FF00)>>>8// w  ww .  j a va 2 s .com
 */
@Test
public void testArithmeticExpressionShiftAnd() {
    // INIT
    builder.getMethod("testMethod").desc = "()I";
    builder.add(LDC, 0x1234).//
            add(LDC, 0xff00).//
            add(IAND).//
            add(BIPUSH, 8).//
            add(IUSHR).//
            addReturn();
    final InsnList optimized = interpreter.optimize(builder.getMethod("testMethod").instructions,
            builder.getMethod("testMethod"));

    assertEquals(2, optimized.size());
    assertEquals(0x12, NodeHelper.getNumberValue(optimized.get(0)).intValue());
}

From source file:de.tuberlin.uebb.jbop.optimizer.arithmetic.ArithmeticExpressionInterpreterTest.java

License:Open Source License

/**
 * int x = (int) 1.0 * 1.0;/*from w w  w  . j  a v a 2  s  .c o  m*/
 */
@Test
public void testArithmeticExpressionNarrow() {
    // INIT
    builder.getMethod("testMethod").desc = "()I";
    builder.add(DCONST_1).//
            add(DCONST_1).//
            add(DMUL).//
            add(D2I).//
            addReturn();
    final InsnList optimized = interpreter.optimize(builder.getMethod("testMethod").instructions,
            builder.getMethod("testMethod"));

    assertEquals(3, optimized.size());
    assertEquals(1, NodeHelper.getNumberValue(optimized.get(0)).intValue());
}

From source file:de.tuberlin.uebb.jbop.optimizer.arithmetic.ArithmeticExpressionInterpreterTest.java

License:Open Source License

/**
 * int x = 0xFF << 1;//w  w  w . j  a  v a2  s.  com
 */
@Test
public void testArithmeticExpressionShiftLeft() {
    // INIT
    builder.getMethod("testMethod").desc = "()I";
    builder.//
            add(BIPUSH, 0x1).//
            add(ICONST_1).//
            add(ISHL).//
            add(BIPUSH, 0x2).//
            add(ICONST_1).//
            add(ISHL).//
            add(IOR).//
            addReturn();
    final InsnList optimized = interpreter.optimize(builder.getMethod("testMethod").instructions,
            builder.getMethod("testMethod"));

    assertEquals(2, optimized.size());
    assertEquals(6, NodeHelper.getNumberValue(optimized.get(0)).intValue());
}