예제 #1
0
파일: Closure.java 프로젝트: johnmy/wyvern
  @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);
  }
예제 #2
0
파일: Closure.java 프로젝트: johnmy/wyvern
 public TypedAST getInner() {
   return function.getBody();
 }
예제 #3
0
파일: Closure.java 프로젝트: johnmy/wyvern
 @Override
 public Type getType() {
   return function.getType();
 }