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

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


   * (parameter, local, or type variable).
   * @param binding Parameter, local, or type variable.
   * @return the variable representing the given binding.
   */
  private Variable getVariable(IBinding binding) {
    Variable result = variables.get(binding);
    if(result == null) {
      if(binding instanceof IVariableBinding) {
        IVariableBinding vb = (IVariableBinding) binding;
        if(vb.isEnumConstant() || vb.isField())
          throw new IllegalArgumentException("Not a local: " + binding);
View Full Code Here


   * @author ciera
   */
  public class NPEFlowVisitor extends ASTVisitor {

    private void checkVariable(TupleLatticeElement<Variable, NullLatticeElement> tuple, Expression nodeToCheck) {
      Variable varToCheck = flowAnalysis.getVariable(nodeToCheck);
      NullLatticeElement element = tuple.get(varToCheck);
     
      if (element == NullLatticeElement.MAYBE_NULL)
        getReporter().reportUserProblem("The expression " + nodeToCheck + " may be null.", nodeToCheck, getName(), SEVERITY.WARNING);   
      else if (element == NullLatticeElement.NULL)
View Full Code Here

   * @author ciera
   */
  public class NPEFlowVisitor extends ASTVisitor {

    private void checkVariable(TupleLatticeElement<Variable, NullLatticeElement> tuple, Expression nodeToCheck) {
      Variable varToCheck = flowAnalysis.getVariable(nodeToCheck);
      NullLatticeElement element = tuple.get(varToCheck);
     
      if (element == NullLatticeElement.MAYBE_NULL)
        getReporter().reportUserProblem("The expression " + nodeToCheck + " may be null.", nodeToCheck, getName(), SEVERITY.WARNING);   
      else if (element == NullLatticeElement.NULL)
View Full Code Here

   
    AnnotationSummary summary = annoDB.getSummaryForMethod(method.resolveBinding());
   
    for (int ndx = 0; ndx < method.parameters().size(); ndx++) {
      SingleVariableDeclaration decl = (SingleVariableDeclaration) method.parameters().get(ndx);
      Variable paramVar = getAnalysisContext().getSourceVariable(decl.resolveBinding());
     
      if (summary.getParameter(ndx, AnnotatedNPEAnalysis.NON_NULL_ANNO) != null) //is this parameter annotated with @Nonnull?
        def.put(paramVar, NullLatticeElement.NOT_NULL);
    }
   
View Full Code Here

      MethodCallInstruction instr,
      TupleLatticeElement<Variable, NullLatticeElement> value) {
    AnnotationSummary summary = annoDB.getSummaryForMethod(instr.resolveBinding());
   
    for (int ndx = 0; ndx < instr.getArgOperands().size(); ndx++) {
      Variable paramVar = instr.getArgOperands().get(ndx);
     
      if (summary.getParameter(ndx, AnnotatedNPEAnalysis.NON_NULL_ANNO) != null) //is this parameter annotated with @Nonnull?
        value.put(paramVar, NullLatticeElement.NOT_NULL);
    }
   
View Full Code Here

   
    AnnotationSummary summary = annoDB.getSummaryForMethod(method.resolveBinding());
   
    for (int ndx = 0; ndx < method.parameters().size(); ndx++) {
      SingleVariableDeclaration decl = (SingleVariableDeclaration) method.parameters().get(ndx);
      Variable paramVar = getAnalysisContext().getSourceVariable(decl.resolveBinding());
     
      if (summary.getParameter(ndx, BranchingNPEAnalysis.NON_NULL_ANNO) != null) //is this parameter annotated with @Nonnull?
        def.put(paramVar, NullLatticeElement.NOT_NULL);
    }
   
View Full Code Here

     
      TupleLatticeElement<Variable, NullLatticeElement> tVal = ops.copy(value);
      TupleLatticeElement<Variable, NullLatticeElement> fVal = ops.copy(value);
     
      if (rightValue == NullLatticeElement.NULL || leftValue == NullLatticeElement.NULL) {
        Variable opToChange = leftValue == NullLatticeElement.NULL ? binop.getOperand2() : binop.getOperand1();
        if (binop.getOperator() == BinaryOperator.REL_EQ) {
          tVal.put(opToChange, NullLatticeElement.NULL);
          fVal.put(opToChange, NullLatticeElement.NOT_NULL);
        }
        else {
          fVal.put(opToChange, NullLatticeElement.NULL);
          tVal.put(opToChange, NullLatticeElement.NOT_NULL);
        }
      }
      else if (rightValue == NullLatticeElement.NOT_NULL || leftValue == NullLatticeElement.NOT_NULL) {
        Variable opToChange = leftValue == NullLatticeElement.NOT_NULL ? binop.getOperand2() : binop.getOperand1();
        if (binop.getOperator() == BinaryOperator.REL_EQ) {
          tVal.put(opToChange, NullLatticeElement.NOT_NULL);
        }
        else {
          fVal.put(opToChange, NullLatticeElement.NOT_NULL);
View Full Code Here

      MethodCallInstruction instr, List<ILabel> labels,
      TupleLatticeElement<Variable, NullLatticeElement> value) {
    AnnotationSummary summary = annoDB.getSummaryForMethod(instr.resolveBinding());
   
    for (int ndx = 0; ndx < instr.getArgOperands().size(); ndx++) {
      Variable paramVar = instr.getArgOperands().get(ndx);
     
      if (summary.getParameter(ndx, BranchingNPEAnalysis.NON_NULL_ANNO) != null) //is this parameter annotated with @Nonnull?
        value.put(paramVar, NullLatticeElement.NOT_NULL);
    }
   
View Full Code Here

   * @author ciera
   */
  public class NPEFlowVisitor extends ASTVisitor {

    private void checkVariable(TupleLatticeElement<Variable, NullLatticeElement> tuple, Expression nodeToCheck) {
      Variable varToCheck = flowAnalysis.getVariable(nodeToCheck);
      NullLatticeElement element = tuple.get(varToCheck);
     
      if (element == NullLatticeElement.MAYBE_NULL)
        getReporter().reportUserProblem("The expression " + nodeToCheck + " may be null.", nodeToCheck, getName(), SEVERITY.WARNING);   
      else if (element == NullLatticeElement.NULL)
View Full Code Here

    CompilationUnit simple = EclipseTACSimpleTestDriver.parseCode("Factorial", FACTORIAL);
    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

TOP

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

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.