Package wyvern.tools.typedAST.interfaces

Examples of wyvern.tools.typedAST.interfaces.TypedAST


  public void tVin() {
    ArrayList<String> strs = new ArrayList<>();
    strs.add("val x = 2\n" +
        "val y = x\n" +
        "y");
    TypedAST pair = wyvern.stdlib.Compiler.compileSources("in1", strs);
    List<Statement> result = getResult(pair);
    Assert.assertEquals("val x = 2,val y = x,y", join(result));
  }
View Full Code Here


        +"    this.t                    \n"
        +"val c:X = X.create(1)    \n"
        +"val a:Unit->Int = c.get             \n"
        +"val b:Unit->Int = X.create(2).get           \n"
        +"b() + a()                         \n");
    TypedAST pair = wyvern.stdlib.Compiler.compileSources("in1", strs);
    List<Statement> result = getResult(pair);
    Assert.assertEquals("class X { static {def create(i : Int) {new }; def $init() {val t = null}}; val t = null; def get() {val temp$0 = this,temp$0.t}},val temp$3 = X,val temp$2 = temp$3.create,val temp$5 = 1,val c = temp$2(temp$5),val temp$6 = c,val a = temp$6.get,val temp$9 = X,val temp$8 = temp$9.create,val temp$11 = 2,val temp$12 = temp$8(temp$11),val b = temp$12.get,val temp$16 = b,val temp$17 = (),val temp$18 = temp$16(temp$17),val temp$14 = a,val temp$15 = (),val temp$19 = temp$14(temp$15),val temp$20 = temp$18 + temp$19,temp$20", join(result));
  }
View Full Code Here

    this.expr = new Immediate(new TupleValue(ops));
  }

  @Override
  public void visit(Assignment assignment) {
    TypedAST dst = assignment.getTarget();
    TypedAST src = assignment.getValue();
   
    if(!(dst instanceof CoreAST) || !(src instanceof CoreAST))
      throw new RuntimeException();
   
    CoreAST cDst = (CoreAST) dst;
View Full Code Here

        "if a == 4    \n"
        " then    \n"
        + "  a = 2   \n"
        + " else    \n"
        + "  a = 3   \n");
    TypedAST pair = wyvern.stdlib.Compiler.compileSources("in1", strs);
    List<Statement> result = getResult(pair);
    Assert.assertEquals("var a = 4,label 1,val temp$0 = a,val temp$1 = 4,val temp$2 = temp$0 == temp$1,if (temp$2) goto label 2,goto label 3,label 2,a = 2,val ifRet$0 = (),goto label 0,label 3,if (true) goto label 4,goto label 5,label 4,a = 3,val ifRet$0 = (),goto label 0,label 5,goto label 0,label 0,ifRet$0", join(result));
  }
View Full Code Here

  }
  @Test
  public void tP() {
    ArrayList<String> strs = new ArrayList<>();
    strs.add("val x = (1,2,3)\nx");
    TypedAST pair = wyvern.stdlib.Compiler.compileSources("in1", strs);
    List<Statement> result = getResult(pair);
    Assert.assertEquals("val temp$0 = 1,val temp$1 = 2,val temp$2 = 3,val x = (temp$0,temp$1,temp$2),x", join(result));
  }
View Full Code Here

    this.expectedType = expectedType;
  }

  @Override
  public void execute() throws IOException, CopperParserException {
    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(code+"\n"), "test input");
    Assert.assertEquals(expectedType, res.typecheck(Globals.getStandardEnv(), Optional.<Type>empty()).toString());
    res = new DSLTransformer().transform(res);
    Value finalV = res.evaluate(Globals.getStandardEnv());
    Assert.assertEquals(expectedValue, finalV.toString());
  }
View Full Code Here

        "val x = X.create()             \n" +
        "                               \n" +
        "match(x):                      \n" +
        "  default => 15               \n";
       
    TypedAST ast = getAST(input);
    evaluateExpecting(ast, 15);
  }
View Full Code Here

        "                               \n" +
        "match(x):                      \n" +
        "  default => 15               \n";
       
   
    TypedAST ast = getAST(input);
    evaluateExpecting(ast, 15);
  }
View Full Code Here

    WyvernResolver.clearFiles();
    for (Pair<String,String> pair : modules) {
      WyvernResolver.addFile(pair.first, pair.second+"\n");
    }

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

        "  W => 4                     \n" +
        "  U => 5                     \n" +
        "  V => 6                     \n" +
        "  default => 15               \n";
   
    TypedAST ast = getAST(input);
    evaluateExpecting(ast, 1);
  }
View Full Code Here

TOP

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

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.