Package com.google.test.metric.method.op.stack

Examples of com.google.test.metric.method.op.stack.Load


     * } catch {    | label:lHandle
     *   return 2;
     * }
     */
    Label lTry = new Label();
    Load l1 = load(1);
    Load l2 = load(2);
    Return ret = new Return(1, Type.INT);
    Label lTryEnd = new Label();
    Label lHandle = new Label();

    BlockDecomposer decomposer = new BlockDecomposer();
View Full Code Here


    Variable e = new LocalVariableInfo("e", Type.OBJECT);
    Variable any = new LocalVariableInfo("any", Type.OBJECT);
    decomposer.tryCatchBlock(tryStart, tryEnd, runtimeHandler, "java/lang/RuntimeException");
    decomposer.tryCatchBlock(tryStart, catchEnd, finallyHandler, null);

    /* 0*/ decomposer.addOp(new Load(0, new Constant(1, Type.INT)));
    /* 1*/ decomposer.addOp(new Store(1, b));
    decomposer.label(tryStart);
    /* 2*/ decomposer.addOp(new Load(2, new Constant(2, Type.INT)));
    decomposer.label(tryEnd);
    /* 3*/ decomposer.addOp(new Store(3, b));
    /* 4*/ decomposer.unconditionalGoto(l20);
    decomposer.label(runtimeHandler);
    /* 7*/ decomposer.addOp(new Store(7, e));
    /* 8*/ decomposer.addOp(new Load(8, new Constant(3, Type.INT)));
    /* 9*/ decomposer.addOp(new Store(9, b));
    decomposer.label(catchEnd);
    /*10*/ decomposer.addOp(new Load(10, new Constant(4, Type.INT)));
    /*11*/ decomposer.addOp(new Store(11, b));
    /*12*/ decomposer.unconditionalGoto(l22);
    decomposer.label(finallyHandler);
    /*15*/ decomposer.addOp(new Store(15, any));
    /*16*/ decomposer.addOp(new Load(16, new Constant(4, Type.INT)));
    /*17*/ decomposer.addOp(new Store(17, b));
    /*18*/ decomposer.addOp(new Load(18, any));
    /*19*/ decomposer.addOp(new Throw(19));
    decomposer.label(l20);
    /*20*/ decomposer.addOp(new Load(20, new Constant(4, Type.INT)));
    /*21*/ decomposer.addOp(new Store(21, b));
    decomposer.label(l22);
    /*22*/ decomposer.addOp(new Load(22, new Constant(4, Type.INT)));
    /*23*/ decomposer.addOp(new Store(23, b));
    /*24*/ decomposer.addOp(new Return(24, Type.VOID));

    decomposer.done();

View Full Code Here

  public void testBlockToString() throws Exception {
    Block block = new Block("1");
    assertEquals("Block[1]{\n}", block.toString());

    block.addOp(new Load(-1, var(1)));
    assertEquals("Block[1]{\n  load 1{java.lang.Object}\n}", block.toString());
  }
View Full Code Here

    assertEquals("Block[1]{\n  load 1{java.lang.Object}\n}", block.toString());
  }

  public void testVariableStaticAssignment() throws Exception {
    Block block = new Block("1");
    block.addOp(new Load(-1, var(1)));
    block.addOp(new PutField(-1, new FieldInfo(null, "abc", OBJECT,
        false, true, false)));

    List<Operation> operations = new Stack2Turing(block).translate();
    assertEquals("[null.abc{java.lang.Object} <- 1{java.lang.Object}]", operations.toString());
View Full Code Here

    assertEquals("[null.abc{java.lang.Object} <- 1{java.lang.Object}]", operations.toString());
  }

  public void testVariableAssignment() throws Exception {
    Block block = new Block("1");
    block.addOp(new Load(-1, var("this"))); // this
    block.addOp(new Load(-1, var(1)));
    block.addOp(new PutField(-1, new FieldInfo(null, "abc", OBJECT,
        false, false, false)));

    List<Operation> operations = new Stack2Turing(block).translate();
    assertEquals("[null.abc{java.lang.Object} <- 1{java.lang.Object}]", operations.toString());
View Full Code Here

        .toString());
  }

  public void testMethodInvocation() throws Exception {
    Block block = new Block("1");
    block.addOp(new Load(-1, var("methodThis"))); // this
    block.addOp(new GetField(-1, new FieldInfo(null, "p1", OBJECT,
        false, true, false)));
    block.addOp(new GetField(-1, new FieldInfo(null, "p2", OBJECT,
        false, true, false)));
    block.addOp(new Invoke(-1, null, "methodA", "(II)A", asList(Type.INT,
View Full Code Here

    root.addNextBlock(branchA);
    root.addNextBlock(branchB);
    branchA.addNextBlock(joined);
    branchB.addNextBlock(joined);

    root.addOp(new Load(-1, var("this")));
    root.addOp(new Load(-1, var("root")));
    branchA.addOp(new Load(-1, var("A")));
    branchB.addOp(new Load(-1, var("B")));
    joined.addOp(new Load(-1, var("joined")));
    joined.addOp(new Invoke(-1, null, "m", "(III)V", asList(Type.INT,
        Type.INT, Type.INT), false, Type.VOID));

    List<Operation> operations = new Stack2Turing(root).translate();
    assertEquals(2, operations.size());
View Full Code Here

  public void testJSRSingleBlock() throws Exception {
    Block main = new Block("main");
    Block sub = new Block("sub");

    main.addOp(new Load(0, new Variable("this", Type.OBJECT, false, false)));
    main.addOp(new JSR(0, sub));
    main.addOp(new PutField(0, new FieldInfo(null, "a", Type.INT, false, false,
        false)));

    sub.addOp(new Load(0, new Constant(1, Type.INT)));
    sub.addOp(new Return(0, Type.VOID));

    Stack2Turing converter = new Stack2Turing(main);
    List<Operation> operations = converter.translate();
    assertEquals(1, operations.size());
View Full Code Here

    recorder.add(new Runnable() {
      public void run() {
        switch (opcode) {
          case Opcodes.NEW :
            Constant constant = new Constant("new", type);
            block.addOp(new Load(lineNumber, constant));
            break;
          case Opcodes.NEWARRAY :
          case Opcodes.ANEWARRAY :
            block.addOp(new Transform(lineNumber, "newarray", Type.INT, null,
                type.toArray()));
View Full Code Here

  }

  private void load(final int var, final Type type) {
    recorder.add(new Runnable() {
      public void run() {
        block.addOp(new Load(lineNumber, variable(var, type)));
      }
    });
  }
View Full Code Here

TOP

Related Classes of com.google.test.metric.method.op.stack.Load

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.