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

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


      else
        init = tac.instruction(d.getInitializer());
      Assert.assertNotNull("Statement: " + s, init);
     
      Assert.assertTrue("Statement: " + s, init instanceof AssignmentInstruction);
      Variable t = ((AssignmentInstruction) init).getTarget();
     
      Variable declared = null;
//      if(decl instanceof SourceVariableDeclaration) {
//        declared = ((SourceVariableDeclaration) decl).getDeclaredVariable();
//        Assert.assertEquals("Statement: " + s, declared, t);
//      }
//      else
View Full Code Here


   * (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

  }
 
  public TupleLatticeElement<Variable, AliasLE> createEntryValue(MethodDeclaration m) {
   
    TupleLatticeElement<Variable, AliasLE> entry = ops.getDefault();
    Variable thisVar = this.getAnalysisContext().getThisVariable();
   
    if (thisVar != null)
      entry.put(thisVar, AliasLE.create(new DefaultObjectLabel(thisVar.resolveType(), false)));
   
    return entry;
  }
View Full Code Here

  public TupleLatticeElement<Variable, LiveVariableLE> transfer(NewObjectInstruction instr,
      TupleLatticeElement<Variable, LiveVariableLE> value)
  {
    log(instr, value);
    value.put(instr.getTarget(), LiveVariableLE.DEAD);
    Variable operand = instr.getOuterObjectSpecifierOperand();
    if (operand != null)
      value.put(operand, LiveVariableLE.LIVE);
   
    for (Variable var : (List<Variable>) instr.getArgOperands())
      value.put(var, LiveVariableLE.LIVE);
View Full Code Here

   
    AC aliases = aliasTF.createEntryValue(method);
    RelationshipContext startingContext = retriever.getStartContext()
   
    if (method.getBody() != null) {
      Variable thisVar = this.getAnalysisContext().getThisVariable();
      List<Variable> params = new ArrayList<Variable>();
      Iterator<SingleVariableDeclaration> itr = method.parameters().iterator();
      while (itr.hasNext()) {
        params.add(getAnalysisContext().getSourceVariable(itr.next().resolveBinding()));
      }   
View Full Code Here

      return new FusionLattice<AC>(startingContext, aliases, aliases);
    }
  }
 
  private Method createTACMethod(MethodDeclaration decl) {
    Variable thisVar = getAnalysisContext().getThisVariable();
    Variable[] params = new Variable[decl.parameters().size()];
    Iterator<SingleVariableDeclaration> itr = decl.parameters().iterator();
    int ndx = 0;
    while (itr.hasNext()) {
      params[ndx] = getAnalysisContext().getSourceVariable(itr.next().resolveBinding());
View Full Code Here

    knownLiterals.put(null, new LiteralLabel(null, "java.lang.Object"));
  }
 
  public PointsToAliasContext createEntryValue(MethodDeclaration method) {
    PointsToAliasContext entry = ops.bottom();
    Variable thisVar = this.getAnalysisContext().getThisVariable();
   
    if (thisVar != null) {
      Set<ObjectLabel> thisAliases = retriever.getStartingAliases(thisVar);
     
      if (thisAliases.isEmpty()) {
        ObjectLabel fresh = new DefaultObjectLabel(thisVar.resolveType(), false);
        entry.addPointsTo(getAnalysisContext().getSuperVariable(), fresh);
        entry.addPointsTo(thisVar, fresh);
        entry.addLabel(fresh);
      }
      else {     
        entry.addPointsTo(thisVar, thisAliases);
        entry.addPointsTo(getAnalysisContext().getSuperVariable(), thisAliases);
      }
    }
   
    entry.addLabel(voidLabel);
    entry.addLabels(retriever.getAllLabels());
   
    //first, create fresh variables for all the parameters
    Iterator itr = method.parameters().iterator();
    while (itr.hasNext()) {
      SingleVariableDeclaration param = (SingleVariableDeclaration) itr.next();
      Variable paramVar = getAnalysisContext().getSourceVariable(param.resolveBinding());
     
      ObjectLabel fresh = new DefaultObjectLabel(param.getType().resolveBinding(), false);
      entry.addPointsTo(paramVar, fresh);
      entry.addLabel(fresh);
    }

    //once we have all starting variables, figure out who might point to who
    itr = method.parameters().iterator();
    while (itr.hasNext()) {
      SingleVariableDeclaration param = (SingleVariableDeclaration) itr.next();
      Variable paramVar = getAnalysisContext().getSourceVariable(param.resolveBinding());
      entry.addPointsToAnySubtype(paramVar, param.getType().resolveBinding());
    }
   
    return entry;
  }
View Full Code Here

    knownLiterals.put(null, new LiteralLabel(null, "java.lang.Object"));
  }
 
  public PointsToAliasContext createEntryValue(MethodDeclaration method) {
    PointsToAliasContext entry = ops.bottom();
    Variable thisVar = this.getAnalysisContext().getThisVariable();
   
    if (thisVar != null) {
      Set<ObjectLabel> thisAliases = retriever.getStartingAliases(thisVar);
     
      if (thisAliases.isEmpty()) {
        ObjectLabel fresh = new DefaultObjectLabel(thisVar.resolveType(), false);
        entry.addPointsTo(getAnalysisContext().getSuperVariable(), fresh);
        entry.addPointsTo(thisVar, fresh);
        entry.addLabel(fresh);
      }
      else {
        entry.addPointsTo(thisVar, thisAliases);
        entry.addPointsTo(getAnalysisContext().getSuperVariable(), thisAliases);
      }
    }
   
    entry.addLabel(voidLabel);
    entry.addLabels(retriever.getAllLabels());
   
    //create fresh variables for all the parameters
    Iterator itr = method.parameters().iterator();
    while (itr.hasNext()) {
      SingleVariableDeclaration param = (SingleVariableDeclaration) itr.next();
      Variable paramVar = getAnalysisContext().getSourceVariable(param.resolveBinding());
     
      ObjectLabel fresh = new DefaultObjectLabel(param.getType().resolveBinding(), false);
      entry.addPointsTo(paramVar, fresh);
      entry.addLabel(fresh);
    }   
View Full Code Here

    if (instr.getTarget().resolveType().isPrimitive())
      return LabeledSingleResult.createResult(putFresh(instr.getNode(), instr.getTarget(), value), labels);
   
    PointsToAliasContext newValue = value.clone();
    IVariableBinding binding = instr.resolveFieldBinding();
    Variable var = receiverFields.get(binding);
    if (var == null) {
      var = new FieldVariable(binding);
      receiverFields.put(binding, var);
    }
View Full Code Here

  @Override
  public IResult<PointsToAliasContext> transfer(StoreFieldInstruction instr,
      List<ILabel> labels, PointsToAliasContext value) {
    IVariableBinding binding = instr.resolveFieldBinding();
    Variable fieldVar = receiverFields.get(binding);
    if (fieldVar == null) {
      fieldVar = new FieldVariable(binding);
      receiverFields.put(binding, fieldVar);   
    }
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.