Package wyvern.tools.typedAST.extensions

Examples of wyvern.tools.typedAST.extensions.ExternalFunction


   
    env = env.extend(new ValueBinding("null", UnitVal.getInstance(FileLocation.UNKNOWN))); // How to represent  shock/horror  null!?
    env = env.extend(new ValueBinding("true", new BooleanConstant(true)));
    env = env.extend(new ValueBinding("false", new BooleanConstant(false)));
   
    env = env.extend(new ValueBinding("print", new ExternalFunction(arrow(str, unit), (env1, argument) -> {
      System.out.println(((StringConstant)argument).getValue());
      return UnitVal.getInstance(FileLocation.UNKNOWN); // Fake line number! FIXME:
    })));
    env = env.extend(new ValueBinding("printInteger", new ExternalFunction(arrow(integer, unit), (env1, argument) -> {
      System.out.println(((IntegerConstant)argument).getValue());
      return UnitVal.getInstance(FileLocation.UNKNOWN); // Fake line number! FIXME:
    })));
    return env;
  }
View Full Code Here


  }

  @Override
  public TypedAST parse(ParseBuffer input) throws IOException, CopperParserException {
    TypedAST quoted = (TypedAST) new WyvernQuote().parse(input.getSrcString()+"\n");
    return new Application(new ExternalFunction(arrow(unit, Util.javaToWyvType(TypedAST.class)), (env, arg) -> {
      TypedAST adapted = new ToastExecutor(env).transform(quoted);
      return Util.toWyvObj(adapted);
    }), UnitVal.getInstance(FileLocation.UNKNOWN), FileLocation.UNKNOWN);
  }
View Full Code Here

        new Invocation(new Variable(new NameBindingImpl("buf", null), unkLoc), "getSrcString", null, unkLoc),
        UnitVal.getInstance(unkLoc),
        unkLoc);
    ClassType emptyType =
        new ClassType(new Reference<>(Environment.getEmptyEnvironment()), new Reference<>(Environment.getEmptyEnvironment()), new LinkedList<>(), "empty");
    TypedAST javaObjInit = new Application(new ExternalFunction(new Arrow(emptyType, Util.javaToWyvType(Value.class)), (env,arg)->{
      return Util.toWyvObj(arg);
    }),
        new Application(
            new Invocation(new Variable(new NameBindingImpl(wyvClassName, null), unkLoc), "create", null, unkLoc),
            UnitVal.getInstance(unkLoc), unkLoc), unkLoc);
    TypedAST body = new Application(new ExternalFunction(new Arrow(Util.javaToWyvType(Object.class), Util.javaToWyvType(TypedAST.class)),
          (env,arg)-> (Value)Util.toJavaObject(arg,Value.class)),
        new Application(new Invocation(new Application(
          new Invocation(new Variable(new NameBindingImpl(javaClassName, null), unkLoc), "create", null, unkLoc),
          javaObjInit, unkLoc), "parse", null, unkLoc),
          new TupleObject(new TypedAST[] {bufGet, new StringConstant("TSL code")}), unkLoc), unkLoc);
View Full Code Here

TOP

Related Classes of wyvern.tools.typedAST.extensions.ExternalFunction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.