@Override
 public Object visitFunction(Function fcn) {
   if (fcn.isSketchHarness()
       || fcn.getSpecification() != null
       || specFcns.contains(fcn.getName())
       || !fcn.isStatic()) {
     return fcn;
   } else {
     this.parametersToInout = new TypedHashSet<String>();
     this.inputParameters = new Vector<String>();
     for (Parameter param : fcn.getParams()) {
       if (!param.isParameterOutput()) {
         this.inputParameters.add(param.getName());
       }
     }
     super.visitFunction(fcn);
     if (parametersToInout.isEmpty()) {
       return fcn;
     } else {
       Vector<Parameter> newParams = new Vector<Parameter>();
       for (Parameter param : fcn.getParams()) {
         if (parametersToInout.contains(param.getName())) {
           newParams.add(new Parameter(param, param.getType(), param.getName(), Parameter.REF));
         } else {
           newParams.add(param);
         }
       }
       return fcn.creator().params(newParams).create();
     }
   }
 }
Ejemplo n.º 2
0
  @Override
  public Object visitPackage(Package p) {
    HashSet<String> tochange = new HashSet<String>();
    List<Function> funcs = p.getFuncs();
    for (int i = 0; i < funcs.size(); ++i) {
      Function f = funcs.get(i);
      String spec = f.getSpecification();
      if (spec != null) {
        tochange.add(spec);
      }
    }

    for (int i = 0; i < funcs.size(); ++i) {
      Function f = funcs.get(i);
      String name = f.getName();
      if (tochange.contains(name) || f.getFcnType() == Function.FcnType.Harness) {
        f = addAssumes(f);
        funcs.set(i, f);
      }
    }

    return p;
  }