Example #1
0
  @Override
  public Value evaluateApplication(Application app, Environment argEnv) {
    Value argValue = app.getArgument().evaluate(argEnv);
    Environment bodyEnv = env;
    List<NameBinding> bindings = function.getArgBindings();
    if (bindings.size() == 1)
      bodyEnv = bodyEnv.extend(new ValueBinding(bindings.get(0).getName(), argValue));
    else if (bindings.size() > 1 && argValue instanceof TupleValue)
      for (int i = 0; i < bindings.size(); i++)
        bodyEnv =
            bodyEnv.extend(
                new ValueBinding(bindings.get(i).getName(), ((TupleValue) argValue).getValue(i)));
    else if (bindings.size() != 0) throw new RuntimeException("Something bad happened!");

    return function.getBody().evaluate(bodyEnv);
  }
Example #2
0
 public TypedAST getInner() {
   return function.getBody();
 }
Example #3
0
 @Override
 public Type getType() {
   return function.getType();
 }