Package org.mozilla.javascript.ast

Examples of org.mozilla.javascript.ast.AstRoot


                                        String sourceLocation,
                                        int lineno,
                                        String mainClassName)
    {
        Parser p = new Parser(compilerEnv);
        AstRoot ast = p.parse(source, sourceLocation, lineno);
        IRFactory irf = new IRFactory(compilerEnv);
        ScriptNode tree = irf.transformTree(ast);

        // release reference to original parse tree & parser
        irf = null;
View Full Code Here


        Parser p = new Parser(compilerEnv, compilationErrorReporter);
        if (returnFunction) {
            p.calledByCompileFunction = true;
        }
        AstRoot ast;
        if (sourceString != null) {
            ast = p.parse(sourceString, sourceName, lineno);
        } else {
            ast = p.parse(sourceReader, sourceName, lineno);
        }
        if (returnFunction) {
            // parser no longer adds function to script node
            if (!(ast.getFirstChild() != null
                  && ast.getFirstChild().getType() == Token.FUNCTION))
            {
                // XXX: the check just looks for the first child
                // and allows for more nodes after it for compatibility
                // with sources like function() {};;;
                throw new IllegalArgumentException(
View Full Code Here

                                        String sourceLocation,
                                        int lineno,
                                        String mainClassName)
    {
        Parser p = new Parser(compilerEnv);
        AstRoot ast = p.parse(source, sourceLocation, lineno);
        IRFactory irf = new IRFactory(compilerEnv);
        ScriptNode tree = irf.transformTree(ast);

        // release reference to original parse tree & parser
        irf = null;
View Full Code Here

    if (!shouldModify(scopename)) {
      return input;
    }
    try {
      AstRoot ast = null;

      /* initialize JavaScript context */
      Context cx = Context.enter();

      /* create a new parser */
      Parser rhinoParser = new Parser(new CompilerEnvirons(), cx.getErrorReporter());

      /* parse some script and save it in AST */
      ast = rhinoParser.parse(new String(input), scopename, 0);

      modifier.setScopeName(scopename);

      modifier.start();

      /* recurse through AST */
      ast.visit(modifier);

      modifier.finish(ast);

      /* clean up */
      Context.exit();
      return ast.toSource();
    } catch (RhinoException re) {
      System.err.println(re.getMessage()
              + "Unable to instrument. This might be a JSON response sent"
              + " with the wrong Content-Type or a syntax error.");

View Full Code Here

TOP

Related Classes of org.mozilla.javascript.ast.AstRoot

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.