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

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


        node, 1, eclipseVariableQuery);
    ResultfulInstruction<?> binop = new EclipseBinaryDesugaredOperation(
        node,
        node.getOperand(), operator, one.getResultVariable(),
        true, eclipseVariableQuery);
    TACInstruction store = createStore(
        node, node.getOperand(),
        binop.getResultVariable(),
        eclipseVariableQuery);
    return new EclipseInstructionSequence(node, new TACInstruction[] { copy, one, binop, store }, 0, eclipseVariableQuery);
  }
View Full Code Here


          node, 1, eclipseVariableQuery);
      ResultfulInstruction<?> binop = new EclipseBinaryDesugaredOperation(
          node,
          node.getOperand(), BinaryOperator.ARIT_SUBTRACT, one.getResultVariable(),
          false, eclipseVariableQuery);
      TACInstruction store = createStore(node, node.getOperand(), binop.getResultVariable(), eclipseVariableQuery);
      return new EclipseInstructionSequence(node, new TACInstruction[] { one, binop, store }, 1, eclipseVariableQuery);
    }
    if(PrefixExpression.Operator.INCREMENT.equals(node.getOperator())) {
      ResultfulInstruction<?> one = new EclipseLoadDesugaredLiteralInstruction(
          node, 1, eclipseVariableQuery);
      ResultfulInstruction<?> binop = new EclipseBinaryDesugaredOperation(
          node, node.getOperand(),
          BinaryOperator.ARIT_ADD, one.getResultVariable(),
          false, eclipseVariableQuery);
      TACInstruction store = createStore(node, node.getOperand(), binop.getResultVariable(), eclipseVariableQuery);
      return new EclipseInstructionSequence(node, new TACInstruction[] { one, binop, store }, 1, eclipseVariableQuery);
    }
    if(PrefixExpression.Operator.MINUS.equals(node.getOperator())) {
      return new UnaryOperationImpl(node, UnaryOperator.ARIT_MINUS, eclipseVariableQuery);
    }
View Full Code Here

  public void testReadField() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("FieldRead", FIELD_READ);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    Expression read = (Expression) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(read);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof LoadFieldInstruction);
    LoadFieldInstruction load = (LoadFieldInstruction) instr;
    Assert.assertTrue(load.getSourceObject() instanceof ThisVariable);
    Assert.assertTrue(load.getSourceObject().isUnqualifiedThis());
View Full Code Here

  public void testReadThis() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("ThisRead", THIS_READ);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    FieldAccess read = (FieldAccess) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(read);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof LoadFieldInstruction);
    LoadFieldInstruction load = (LoadFieldInstruction) instr;
    Assert.assertTrue(load.getSourceObject() instanceof ThisVariable);
    Assert.assertTrue(load.getSourceObject().isUnqualifiedThis());
View Full Code Here

  public void testObjectRead() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("ObjectRead", OBJECT_READ);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    Expression read = (Expression) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(read);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof LoadFieldInstruction);
    LoadFieldInstruction load = (LoadFieldInstruction) instr;
    Assert.assertEquals(
        tac.sourceVariable(((SingleVariableDeclaration) m.parameters().get(0)).resolveBinding()),
View Full Code Here

  public void testFieldWrite() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("FieldWrite", FIELD_WRITE);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    Assignment write = (Assignment) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(write);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof StoreFieldInstruction);
   
    StoreFieldInstruction store = (StoreFieldInstruction) instr;
    Assert.assertTrue(store.getDestinationObject() instanceof ThisVariable);
View Full Code Here

  public void testFieldInc() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("FieldInc", FIELD_INC);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    PostfixExpression inc = (PostfixExpression) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(inc);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof EclipseInstructionSequence);
    LoadFieldInstruction load = (LoadFieldInstruction) tac.instruction(inc.getOperand());
   
    EclipseInstructionSequence seq = (EclipseInstructionSequence) instr;
View Full Code Here

  public void testNestedFieldWrite() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("NestedFieldWrite", NESTED_FIELD_WRITE);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    MethodInvocation inv = (MethodInvocation) ((ExpressionStatement) EclipseTACSimpleTestDriver.getLastStatement(m)).getExpression();
    TACInstruction instr = tac.instruction(inv);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof MethodCallInstruction);
    MethodCallInstruction call = (MethodCallInstruction) instr;
   
    List<Variable> args = call.getArgOperands();
View Full Code Here

  public void testPrivateOuterField() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("PrivateOuterField", PRIVATE_OUTER_FIELD);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(cu); // method in inner class
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    Expression read = (Expression) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(read);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof LoadFieldInstruction);
    LoadFieldInstruction load = (LoadFieldInstruction) instr;
    Assert.assertTrue(load.getSourceObject() instanceof ThisVariable);
    Assert.assertFalse(load.getSourceObject().isUnqualifiedThis());
View Full Code Here

  public void testVisibleOuterField() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("VisibleOuterField", VISIBLE_OUTER_FIELD);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(cu); // method in inner class
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    Expression read = (Expression) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(read);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof LoadFieldInstruction);
    LoadFieldInstruction load = (LoadFieldInstruction) instr;
    Assert.assertTrue(load.getSourceObject() instanceof ThisVariable);
    Assert.assertTrue(load.getSourceObject().isUnqualifiedThis());
View Full Code Here

TOP

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

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.