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

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


    ASTNode node = instr.getNode();
    // get regular results before looking up root instruction
    // to switch to surrounding method, if necessary
    // (driver.tac could be null or outdated otherwise)
    final IResult<LE> nodeResults = getLabeledResultsAfter(node);
    final TACInstruction rootInstr = this.driver.tac.instruction(node);
    if(rootInstr == instr) {
      // usual case: only one instruction for this node
      // return regular results
      return nodeResults;
    }
View Full Code Here


    ASTNode node = instr.getNode();
    // get regular results before looking up root instruction
    // to switch to surrounding method, if necessary
    // (driver.tac could be null or outdated otherwise)
    final IResult<LE> nodeResults = getLabeledResultsBefore(node);
    final TACInstruction rootInstr = this.driver.tac.instruction(node);
    if(rootInstr == instr) {
      // usual case: only one instruction for this node
      // return regular results
      return nodeResults;
    }
View Full Code Here

      super(tf, compUnitTacs);
    }
   
    public LE transfer(ASTNode astNode, LE incoming) {
      LE result;
      TACInstruction instr = tac.instruction(astNode);
      if(instr == null)
        result = incoming;
      else
        result = instr.transfer(tf, incoming);
      return result;
    }
View Full Code Here

        CompilationUnitTACs compUnitTacs) {
      super(tf, compUnitTacs);
    }

    public IResult<LE> transfer(ASTNode astNode, List<ILabel> labels, LE value) {
      TACInstruction instr = tac.instruction(astNode);
      if(instr == null)
        return new LabeledSingleResult<LE>(value, labels);
      else
        return instr.transfer(tf, labels, value);
    }
View Full Code Here

    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(simple);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
   
    ConditionalExpression cond = (ConditionalExpression) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    Variable r = tac.variable(cond);
    TACInstruction instr;

    instr = tac.instruction(cond.getExpression());
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof BinaryOperation);
   
View Full Code Here

    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
   
    List<Statement> stmts = m.getBody().statements();
    Assert.assertTrue(stmts.size() == 5);
   
    TACInstruction decl, init;
    for(int i = 0; i < 4; i++) {
      VariableDeclarationStatement s = (VariableDeclarationStatement) stmts.get(i);
      Assert.assertTrue("Statement: " + s, s.fragments().size() == 1);
      VariableDeclaration d = (VariableDeclaration) s.fragments().get(0);
      decl = tac.instruction(d);
View Full Code Here

  public void testSimpleBinop() throws Exception {
    CompilationUnit simple = EclipseTACSimpleTestDriver.parseCode("SimpleBinop", SIMPLE_BINOP);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(simple);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    InfixExpression infix = (InfixExpression) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(infix);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof BinaryOperation);
    BinaryOperation binop = (BinaryOperation) instr;
    Assert.assertEquals(tac.variable(infix.getLeftOperand()), binop.getOperand1());
    Assert.assertEquals(tac.variable(infix.getRightOperand()), binop.getOperand2());
View Full Code Here

  public void testSimpleCall() throws Exception {
    CompilationUnit simple = EclipseTACSimpleTestDriver.parseCode("SimpleCall", SIMPLE_CALL);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(simple);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    MethodInvocation invoke = (MethodInvocation) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(invoke);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof MethodCallInstruction);
    MethodCallInstruction call = (MethodCallInstruction) instr;
    Assert.assertNull(((ThisVariable) tac.implicitThisVariable(m.resolveBinding())).getQualifier());
    Assert.assertEquals(tac.implicitThisVariable(m.resolveBinding()), call.getReceiverOperand());
View Full Code Here

  public void testStaticCall() throws Exception {
    CompilationUnit simple = EclipseTACSimpleTestDriver.parseCode("StaticCall", STATIC_CALL);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(simple);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    MethodInvocation invoke = (MethodInvocation) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(invoke);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof MethodCallInstruction);
    MethodCallInstruction call = (MethodCallInstruction) instr;
    Assert.assertEquals(tac.typeVariable(m.resolveBinding().getDeclaringClass()), call.getReceiverOperand());
    EclipseTACSimpleTestDriver.assertOperands(invoke.arguments(), call.getArgOperands(), tac);
View Full Code Here

    CompilationUnit simple = EclipseTACSimpleTestDriver.parseCode("SimpleReturn", SIMPLE_RETURN);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(simple);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    ReturnStatement ret = (ReturnStatement) EclipseTACSimpleTestDriver.getLastStatementReturn(m);
    Assert.assertTrue(ret.getExpression() != null);
    TACInstruction instr = tac.instruction(ret);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof ReturnInstruction);
    ReturnInstruction binop = (ReturnInstruction) instr;
    Assert.assertEquals(tac.variable(ret.getExpression()), binop.getReturnedVariable());
  }
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.