Package org.mozilla.javascript

Examples of org.mozilla.javascript.ScriptOrFnNode


    if (node.getLineno() > lineStart) {
      lineStart = node.getLineno();
    }

    if (node instanceof ScriptOrFnNode) {
      final ScriptOrFnNode sfn = (ScriptOrFnNode) node;
      isScriptOrFn = true;
      scope = this;
      if (!isRoot) {
        parentScope = parent.getScope();
      }
      parameters = getParams(sfn);
      localVars = getLocalVars(sfn);
      lineStart = sfn.getBaseLineno();
      lineEnd = sfn.getEndLineno();
    } else {
      scope = parent.getScope();
      parentScope = scope.getScope();
    }
    if (type == Token.SCRIPT) {
View Full Code Here


      }
      sb.append("]");
    }

    if (isScript) {
      final ScriptOrFnNode sfn = (ScriptOrFnNode) node;
      final String sourceName = sfn.getSourceName();
      if (sourceName != null) {
        final String[] sp = sourceName.split("/");
        sb.append(" |").append(sp[sp.length - 1]).append("| ");
      }
    }
View Full Code Here

   * @param fileName
   * @throws WinkAstException
   * @throws WinkParseException
   */
  private void parse(final String fileName) throws WinkAstException, WinkParseException {
    ScriptOrFnNode tree;
    Ast ast;
    final AstBuilder astBuilder = new AstBuilder();
    try {
      tree = getParsedAst(fileName);
      ast = astBuilder.build(tree);
View Full Code Here

   */
  private ScriptOrFnNode getParsedAst(final String fileName) throws IOException {
    final File f = new File(fileName);
    final Reader reader = new FileReader(f);
    String sourceURI;
    ScriptOrFnNode tree = null;

    sourceURI = f.getCanonicalPath();
    tree = parser.parse(reader, sourceURI, 1);

    reader.close();
View Full Code Here

   *           压缩过程中的错误
   */
  public void compress(Reader reader, Writer writer, boolean keepLineno,
      int mode) throws Exception {
    Parser parser = new Parser(new CompilerEnvirons(), reporter);
    ScriptOrFnNode root = parser.parse(reader, null, 1);

    Environment env = new Environment(keepLineno, mode);
    GlobalScope globalScope = new GlobalScope();
    StatementList statements = new StatementList();
    Node node = root.getFirstChild();
    while (node != null) {
      IStatement statement = Utils.createStatement(node, root, globalScope);
      statements.add(statement);
      node = statement.getNext();
    }
View Full Code Here

    if(condition)
      newQuery.conditionFunction = queryFunction;
    newQuery.source = oldQuery.source;
    newQuery.subObjectId = oldQuery.subObjectId;
    Parser p = new Parser(compilerEnvirons, compilerEnvirons.getErrorReporter());
        ScriptOrFnNode tree;
        tree = p.parse("(" + queryStr + ")", "jsonpath-sub-expression", 0);
        Node functionBody = tree.getFunctionNode(0).getFirstChild();
        Node returnNode = functionBody.getFirstChild();
        if(returnNode.getType() != Token.RETURN){
          returnNode = returnNode.getFirstChild().getFirstChild().getFirstChild();
        }
        Node queryNode = returnNode.getFirstChild();
View Full Code Here

    ce.setGenerateDebugInfo(true);   
    ce.initFromContext(ContextFactory.getGlobal().enterContext());
    ce.setErrorReporter(errorReporter);
   
    Parser p = new Parser(ce, errorReporter);
    ScriptOrFnNode ast = p.parse(this.scriptSource, "script", 0);
   
    searchAstForNodes(ast);
  }
View Full Code Here

    ce.setGenerateDebugInfo(true);   
    ce.initFromContext(ContextFactory.getGlobal().enterContext());
    ce.setErrorReporter(errorReporter);
   
    Parser p = new Parser(ce, errorReporter);
    ScriptOrFnNode ast = p.parse(scriptSource, "script", 0);
   
    return new ArrayLiteral(ast.getFirstChild().getFirstChild().getFirstChild());
  }
View Full Code Here

    ce.setGenerateDebugInfo(true);   
    ce.initFromContext(ContextFactory.getGlobal().enterContext());
    ce.setErrorReporter(errorReporter);
   
    Parser p = new Parser(ce, errorReporter);
    ScriptOrFnNode ast = p.parse(scriptSource, "script", 0);
   
    return new ObjectLiteral(ast.getFirstChild().getFirstChild().getFirstChild());
  }
View Full Code Here

    ce.setGenerateDebugInfo(true);   
    ce.initFromContext(ContextFactory.getGlobal().enterContext());
    ce.setErrorReporter(errorReporter);
   
    Parser p = new Parser(ce, errorReporter);
    ScriptOrFnNode ast = p.parse(this.scriptSource, "script", 0);
   
    recursiveParse(ast);
   
    this.scriptParsed = true;
  }
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.ScriptOrFnNode

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.