Package org.eclipse.jdt.core.dom

Examples of org.eclipse.jdt.core.dom.Expression


  @Test
  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(
View Full Code Here


  @Test
  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);
View Full Code Here

  @Test
  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);
View Full Code Here

    }

    @Override
    public void endVisit(PrefixExpression node) {
      if (node.getOperator() == PrefixExpression.Operator.NOT) {
        Expression sub = node.getOperand();
        BooleanConstantLE val = fa.getResultsAfter(sub).get(fa.getVariable(sub));
       
        if (val == BooleanConstantLE.TRUE)
          reporter.reportUserProblem("The expression " + node + " will always be false.", node, getName());
        else if (val == BooleanConstantLE.FALSE)
View Full Code Here

      }
    }
   
    @Override
    public void endVisit(Assignment node) {
      Expression left = node.getLeftHandSide();
      Expression right = node.getRightHandSide();
     
      if (left instanceof Name && ((Name)left).resolveBinding() instanceof IVariableBinding) {
        IVariableBinding binding = (IVariableBinding) ((Name)left).resolveBinding();
     
        if (binding.isParameter()) {
View Full Code Here

      }
    }
   
    @Override
    public void endVisit(Assignment node) {
      Expression left = node.getLeftHandSide();
      Expression right = node.getRightHandSide();
     
      if (left instanceof Name && ((Name)left).resolveBinding() instanceof IVariableBinding) {
        IVariableBinding binding = (IVariableBinding) ((Name)left).resolveBinding();
     
        if (binding.isParameter()) {
View Full Code Here

  public void testFieldInitializer() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("FieldInit", FIELD_INIT);
    MethodDeclaration c = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(c.resolveBinding());
    VariableDeclarationFragment f = EclipseTACSimpleTestDriver.getFirstField(cu);
    Expression init = f.getInitializer();
    Assert.assertNotNull(init);

    TACInstruction decl = tac.instruction(f);
    Assert.assertNotNull(decl);
    Assert.assertTrue(decl instanceof StoreFieldInstruction);
View Full Code Here

  public void testFieldInitNew() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("FieldInitNew", FIELD_INIT_NEW);
    MethodDeclaration c = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(c.resolveBinding());
    VariableDeclarationFragment f = EclipseTACSimpleTestDriver.getFirstField(cu);
    Expression init = f.getInitializer();
    Assert.assertNotNull(init);

    TACInstruction decl = tac.instruction(f);
    Assert.assertNotNull(decl);
    Assert.assertTrue(decl instanceof StoreFieldInstruction);
View Full Code Here

  public void testFieldNoInitializer() throws Exception {
    CompilationUnit cu = EclipseTACSimpleTestDriver.parseCode("FieldNoInit", FIELD_NO_INIT);
    MethodDeclaration c = EclipseTACSimpleTestDriver.getFirstMethod(cu);
    EclipseTAC tac = new EclipseTAC(c.resolveBinding());
    VariableDeclarationFragment f = EclipseTACSimpleTestDriver.getFirstField(cu);
    Expression init = f.getInitializer();
    Assert.assertNull(init);

    TACInstruction decl = tac.instruction(f);
    Assert.assertNull(decl); // make sure the field declaration doesn't become a local
  }
View Full Code Here

  public class LiveVariableVisitor extends ASTVisitor {

    @Override
    public void endVisit(Assignment node) {
      IVariableBinding binding = null;
      Expression left = node.getLeftHandSide();
      TupleLatticeElement<Variable, LiveVariableLE> lattice = fa.getResultsAfter(node);
     
      if (left instanceof Name && ((Name)left).resolveBinding() instanceof IVariableBinding)
        binding = (IVariableBinding) ((Name)left).resolveBinding();
      else if (left instanceof FieldAccess)
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.dom.Expression

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.