Examples of typeCheck()


Examples of org.pdf4j.saxon.expr.ExpressionVisitor.typeCheck()

    private XPathExpressionImpl createExpressionInternal(String expression) throws org.pdf4j.saxon.trans.XPathException {
        Expression exp = ExpressionTool.make(expression, staticContext, 0, -1, 1, false);
        ExpressionVisitor visitor = ExpressionVisitor.make(staticContext);
        visitor.setExecutable(getExecutable());
        exp = visitor.typeCheck(exp, Type.ITEM_TYPE);
        SlotManager map = staticContext.getConfiguration().makeSlotManager();
        ExpressionTool.allocateSlots(exp, 0, map);
        exp.setContainer(staticContext);
        XPathExpressionImpl xpe = new XPathExpressionImpl(exp, getExecutable());
        xpe.setStackFrameMap(map);
View Full Code Here

Examples of org.pdf4j.saxon.expr.ExpressionVisitor.typeCheck()

    public List evaluate(String expression) throws org.pdf4j.saxon.trans.XPathException {
        Expression exp = ExpressionTool.make(expression, staticContext,0,-1,1, false);
        ExpressionVisitor visitor = ExpressionVisitor.make(staticContext);
        visitor.setExecutable(getExecutable());
        exp = visitor.typeCheck(exp, Type.ITEM_TYPE);
        SlotManager map = staticContext.getConfiguration().makeSlotManager();
        ExpressionTool.allocateSlots(exp, 0, map);
        XPathContextMajor context = new XPathContextMajor(contextNode, staticContext.getExecutable());
        context.openStackFrame(map);
        SequenceIterator iterator = exp.iterate(context);
View Full Code Here

Examples of org.pdf4j.saxon.expr.ExpressionVisitor.typeCheck()

    public Object evaluateSingle(String expression) throws org.pdf4j.saxon.trans.XPathException {
        Expression exp = ExpressionTool.make(expression, staticContext,0,-1,1, false);
        ExpressionVisitor visitor = ExpressionVisitor.make(staticContext);
        visitor.setExecutable(getExecutable());
        exp = visitor.typeCheck(exp, Type.ITEM_TYPE);
        SlotManager map = staticContext.getConfiguration().makeSlotManager();
        ExpressionTool.allocateSlots(exp, 0, map);
        XPathContextMajor context = new XPathContextMajor(contextNode, staticContext.getExecutable());
        context.openStackFrame(map);
        SequenceIterator iterator = exp.iterate(context);
View Full Code Here

Examples of org.pdf4j.saxon.expr.ExpressionVisitor.typeCheck()

    public XPathExpression createExpression(String expression) throws XPathException {
        Expression exp = ExpressionTool.make(expression, staticContext, 0, -1, 1, false);
        exp.setContainer(staticContext);
        ExpressionVisitor visitor = ExpressionVisitor.make(staticContext);
        visitor.setExecutable(getExecutable());
        exp = visitor.typeCheck(exp, Type.ITEM_TYPE);
        exp = visitor.optimize(exp, Type.ITEM_TYPE);
        SlotManager map = staticContext.getStackFrameMap();
        int numberOfExternalVariables = map.getNumberOfVariables();
        ExpressionTool.allocateSlots(exp, numberOfExternalVariables, map);
        XPathExpression xpe = new XPathExpression(this, exp);
View Full Code Here

Examples of org.yinwang.yin.ast.Node.typecheck()

        } catch (ParserException e) {
            Util.abort("parsing error: " + e);
            return null;
        }
        Scope s = Scope.buildInitTypeScope();
        Value ret = program.typecheck(s);

        while (!uncalled.isEmpty()) {
            List<FunType> toRemove = new ArrayList<>(uncalled);
            for (FunType ft : toRemove) {
                invokeUncalled(ft, s);
View Full Code Here

Examples of wyvern.tools.typedAST.core.Sequence.typecheck()

  public void testSplice1() throws IOException, CopperParserException {
    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

Examples of wyvern.tools.typedAST.core.declarations.ValDeclaration.typecheck()

  }

  private Environment getGenericDecls(Environment env, Environment mockEnv, LinkedList<Declaration> decls) {
    for (Entry<String, TypedAST> elem : args.entrySet()) {
      ValDeclaration e = new ValDeclaration(elem.getKey(), elem.getValue(), elem.getValue().getLocation());
      e.typecheck(env, Optional.empty());
      mockEnv = e.extend(mockEnv, mockEnv);
      decls.add(e);
    }
    return mockEnv;
  }
View Full Code Here

Examples of wyvern.tools.typedAST.interfaces.TypedAST.typecheck()

    }
   
    try {
      Reader reader = new FileReader(file);
      TypedAST res = (TypedAST) new Wyvern().parse(reader, filename);
      res.typecheck(Globals.getStandardEnv(), Optional.empty());
      res = new DSLTransformer().transform(res);
      Value finalV = res.evaluate(Globals.getStandardEnv());
      TreeWriter t = new TreeWriter();
      finalV.writeArgsToTree(t);
      System.out.println(t.getResult());
View Full Code Here

Examples of wyvern.tools.typedAST.interfaces.TypedAST.typecheck()

public class Compiler {
  public static TypedAST compileSources(String filename, List<String> sources) {
    try {
      TypedAST ast = (TypedAST) new Wyvern().parse(new StringReader(sources.get(0)), "test input");
      ast.typecheck(Globals.getStandardEnv(), Optional.<Type>empty());
      return ast;
    } catch (IOException | CopperParserException e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

Examples of wyvern.tools.typedAST.interfaces.TypedAST.typecheck()

    //Path path = Paths.get(args[0]);
    //Files.lines(path).forEach(s -> System.out.println(s));
   
    try (FileInputStream fis = new FileInputStream(file)) {
      TypedAST res = (TypedAST)new Wyvern().parse(new InputStreamReader(fis), "test input");
      Type checkedType = res.typecheck(Globals.getStandardEnv(), Optional.empty());
      System.out.println("Result type: "+checkedType);
      res = new DSLTransformer().transform(res);
      Value finalV = res.evaluate(Globals.getStandardEnv());
      System.out.println("Result: "+finalV);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.