コード例 #1
0
 @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();
     }
   }
 }
コード例 #2
0
 public Object visitStmtAssign(StmtAssign stmt) {
   if (stmt.getLHS() instanceof ExprArrayRange) {
     ExprArrayRange v = (ExprArrayRange) stmt.getLHS();
     if (v.getBase() instanceof ExprVar) {
       ExprVar v2 = (ExprVar) (v.getBase());
       if (inputParameters.contains(v2.getName())) {
         parametersToInout.add(v2.getName());
       }
     }
   }
   return stmt;
 }