Package edu.cmu.cs.crystal.tac.model

Examples of edu.cmu.cs.crystal.tac.model.LoadArrayInstruction


    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    ArrayAccess read = (ArrayAccess) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(read);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof LoadArrayInstruction);
    LoadArrayInstruction load = (LoadArrayInstruction) instr;
   
    Assert.assertEquals(tac.variable(read.getArray()), load.getSourceArray());
    Assert.assertTrue(load.getSourceArray() instanceof SourceVariable);
    Assert.assertEquals("a", load.getSourceArray().getSourceString());
   
    Assert.assertEquals(tac.variable(read.getIndex()), load.getArrayIndex());
    Assert.assertTrue(load.getArrayIndex() instanceof SourceVariable);
    Assert.assertEquals("index", load.getArrayIndex().getSourceString());
  }
View Full Code Here


    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    PrefixExpression inc = (PrefixExpression) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(inc);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof EclipseInstructionSequence);
    LoadArrayInstruction load = (LoadArrayInstruction) tac.instruction(inc.getOperand());
   
    EclipseInstructionSequence seq = (EclipseInstructionSequence) instr;
    Assert.assertEquals(
        "Wrong number of instructions in sequence: " + seq.getInstructions().length,
        3, seq.getInstructions().length);
    Assert.assertTrue(seq.getInstructions()[0] instanceof LoadLiteralInstruction);
    Assert.assertTrue(seq.getInstructions()[1] instanceof BinaryOperation);
    Assert.assertTrue(seq.getInstructions()[2] instanceof StoreArrayInstruction);
    LoadLiteralInstruction one = (LoadLiteralInstruction) seq.getInstructions()[0];
    BinaryOperation add = (BinaryOperation) seq.getInstructions()[1];
    StoreArrayInstruction store = (StoreArrayInstruction) seq.getInstructions()[2];
    Assert.assertEquals(load.getTarget(), add.getOperand1());
    Assert.assertEquals(one.getTarget(), add.getOperand2());
    Assert.assertEquals(add.getTarget(), store.getSourceOperand());
    Assert.assertEquals(add.getTarget(), seq.getResultVariable());
    Assert.assertFalse(add.getTarget().equals(load.getTarget()));
  }
View Full Code Here

TOP

Related Classes of edu.cmu.cs.crystal.tac.model.LoadArrayInstruction

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.