Пример #1
0
 /*
  * (non-Javadoc)
  *
  * @see jaskell.compiler.JaskellVisitor#visit(jaskell.compiler.core.Application)
  */
 public Object visit(Application a) {
   /* visit function */
   a.setFunction((Expression) a.getFunction().visit(this));
   /* visit all bodies of alternative */
   List it = a.getArgs();
   for (int i = 0; i < it.size(); i++) {
     Expression e = (Expression) it.get(i);
     it.set(i, e.visit(this));
   }
   return a;
 }
Пример #2
0
 /**
  * This method produces an Expression from an arbitrary Abstraction object which is applied to a
  * list of Variables referencing captured bindings.
  *
  * @param a an Abstraction object to partially apply
  * @param captured
  * @return
  */
 private Expression applyLifted(String s, Set captured) {
   if (captured.isEmpty()) return new Variable(s);
   Application app = new Application();
   app.setFunction(new Variable(s));
   /* bind captured variables */
   Iterator it = captured.iterator();
   while (it.hasNext()) {
     LocalBinding lb = (LocalBinding) it.next();
     app.addArgument(new Variable(lb.getName()));
   }
   return app;
 }