Ejemplo n.º 1
0
  // returns a list consisting of two-element-lists consisting of
  // (actual cbr-param, formal cbr-param) (Variable objects)
  public List<List<Variable>> getCbrParams() {
    if (this.cbrParamList != null) {
      return this.cbrParamList;
    }

    List<TacActualParameter> actualParams = this.paramList;
    List<TacFormalParameter> formalParams = this.getCallee().getParams();

    this.cbrParamList = new LinkedList<>();

    Iterator<TacActualParameter> actualIter = actualParams.iterator();
    Iterator<TacFormalParameter> formalIter = formalParams.iterator();

    while (actualIter.hasNext()) {
      TacActualParameter actualParam = actualIter.next();
      TacFormalParameter formalParam = formalIter.next();

      // if this is a cbr-param...
      if (actualParam.isReference() || formalParam.isReference()) {
        // the actual part of a cbr-param must always be a variable
        if (!(actualParam.getPlace() instanceof Variable)) {
          throw new RuntimeException("Error in the PHP file!");
        }

        Variable actualVar = (Variable) actualParam.getPlace();
        Variable formalVar = formalParam.getVariable();

        // check for unsupported features;
        // none of the variables must be an array or etc.;
        // in such a case, ignore it and continue with the next cbr-param
        boolean supported =
            AliasAnalysis.isSupported(formalVar, actualVar, true, this.getOriginalLineNumber());

        if (!supported) {
          continue;
        }

        List<Variable> pairList = new LinkedList<>();
        pairList.add(actualVar);
        pairList.add(formalVar);
        cbrParamList.add(pairList);
      }
    }

    return cbrParamList;
  }
Ejemplo n.º 2
0
 public List<Variable> getVariables() {
   // only the params are relevant for globals replacement
   List<Variable> retMe = new LinkedList<>();
   for (TacActualParameter param : this.paramList) {
     AbstractTacPlace paramPlace = param.getPlace();
     if (paramPlace instanceof Variable) {
       retMe.add((Variable) paramPlace);
     } else {
       retMe.add(null);
     }
   }
   return retMe;
 }