Package wyvern.tools.typedAST.interfaces

Examples of wyvern.tools.typedAST.interfaces.Value


    TypedAST testAST = new Sequence(
        new ValDeclaration("x", new IntegerConstant(4), null),
        new Application(new TSLBlock(new Fn(Arrays.asList(new NameBindingImpl("x", Int.getInstance())),
            new SpliceExn(new Variable(new NameBindingImpl("x", Int.getInstance()), null)))), new IntegerConstant(9), null) );
    Type result = testAST.typecheck(Globals.getStandardEnv(), Optional.<Type>empty());
    Value out = testAST.evaluate(Globals.getStandardEnv());
    int finalRes = ((IntegerConstant)out).getValue();
    Assert.assertEquals(4, finalRes);
  }
View Full Code Here


    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(user), "test input");
    Type result = res.typecheck(Globals.getStandardEnv(), Optional.<Type>empty());
    res = new DSLTransformer().transform(res);
    Assert.assertEquals("Int", result.toString());

    Value out = res.evaluate(Globals.getStandardEnv());
    Assert.assertEquals("IntegerConstant(13)", out.toString());
  }
View Full Code Here

    WyvernResolver.addFile("supplier", supplier);

    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(client), "test input");
    Type result = res.typecheck(Globals.getStandardEnv(), Optional.<Type>empty());
    res = new DSLTransformer().transform(res);
    Value finalV = res.evaluate(Globals.getStandardEnv());
  }
View Full Code Here

        }
      }
      if (!suitable)
        continue;
      //This is the first method => most specific
      Value evaluate = app.getArgument().evaluate(iEnv);
      Value[] args = values;
      Type[] sig = fromValue(evaluate);
      if (sig.length == 1 && sig[0] instanceof Unit) {
        sig = new Type[] {};
      }
View Full Code Here

  public Value evaluateAssignment(Assignment ass, Environment env) {
    if (!(ass.getTarget() instanceof Invocation))
      throw new RuntimeException("Something really, really weird happened.");
    String operation = ((Invocation) ass.getTarget()).getOperationName();

    Value newValue = ass.getValue().evaluate(env);

    intEnv.get().lookupBinding(operation, AssignableValueBinding.class)
        .orElseThrow(() -> new RuntimeException("Trying to assign a non-var"))
        .assign(newValue);
View Full Code Here

  private static HashSet<Binding> bindings = new HashSet<>();
  public static void setValueBinding(Object arg, ValueBinding b) {
    if (bindings.contains(b))
      return;
    bindings.add(b);
    Value toSet = toWyvObj(arg);
    b.setValue(toSet);
    bindings.remove(b);
  }
View Full Code Here

      throw new RuntimeException("Something awful happened!");
    }
  }

  public static Object doInvoke(Obj receiver, String target, Object[] args) {
    Value arguments = toWyvObjs(args);
    return toJavaObject((
        new Application(
            new Invocation(receiver, target, null, FileLocation.UNKNOWN),
            arguments, FileLocation.UNKNOWN)
            .evaluate(Environment.getEmptyEnvironment())), null);//Therefore, can only handle strings and ints
View Full Code Here

            .evaluate(Environment.getEmptyEnvironment());//Therefore, can only handle strings and ints
  }
 

  public static Object doInvokeVarargs(Obj receiver, String target, Object... args) {
    Value arguments = toWyvObjs(args);
    return toJavaObject((
        new Application(
            new Invocation(receiver, target, null, FileLocation.UNKNOWN),
            arguments, FileLocation.UNKNOWN)
            .evaluate(Environment.getEmptyEnvironment())), null);//Therefore, can only handle strings and ints
View Full Code Here

    return new Application(
        new Invocation(reciever,target, null, FileLocation.UNKNOWN),
        args, FileLocation.UNKNOWN).evaluate(Environment.getEmptyEnvironment());
  }
  public static Value invokeValueVarargs(Value reciever, String target, Value... args) {
    Value iargs;
    if (args.length == 0)
      iargs = UnitVal.getInstance(FileLocation.UNKNOWN);
    else if (args.length == 1)
      iargs = args[0];
    else
View Full Code Here

    return type;
  }

  @Override
  public Value evaluate(Environment env) {
    Value value = env.getValue(binding.getName());
    assert value != null;
    return value;
  }
View Full Code Here

TOP

Related Classes of wyvern.tools.typedAST.interfaces.Value

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.