/** * Creates an instance. */ ExternExportsPass(AbstractCompiler compiler) { this.exports = new ArrayList<>(); this.compiler = compiler; this.definitionMap = new HashMap<>(); this.externsRoot = IR.script(); this.alreadyExportedPaths = new HashSet<>(); this.mappedPaths = new HashMap<>(); initExportMethods(); }
private Node createTemplateNode() { // The Node type choice is arbitrary. Node templateNode = IR.script(); templateNode.setStaticSourceFile( this.sourceFile); return templateNode; }
public static Node script(List<Node> stmts) { Node paramList = script(); for (Node stmt : stmts) { checkState(mayBeStatementNoReturn(stmt)); paramList.addChildToBack(stmt); } return paramList; }
public static Node script(List<Node> stmts) { Node paramList = script(); for (Node stmt : stmts) { Preconditions.checkState(mayBeStatementNoReturn(stmt)); paramList.addChildToBack(stmt); } return paramList; }
public static Node script(Node ... stmts) { Node block = script(); for (Node stmt : stmts) { checkState(mayBeStatementNoReturn(stmt)); block.addChildToBack(stmt); } return block; }
public static Node script(Node ... stmts) { Node block = script(); for (Node stmt : stmts) { Preconditions.checkState(mayBeStatementNoReturn(stmt)); block.addChildToBack(stmt); } return block; }
@Override public void clearAst() { root = IR.script(); root.setInputId(inputId); root.setStaticSourceFile(sourceFile); }
@Override public void clearAst() { root = IR.script(); root.setInputId(inputId); root.setStaticSourceFile(sourceFile); }
/** * Remove the given node from the AST, and replace it with a placeholder * SCRIPT node. * @return the new placeholder node. */ private static Node swapWithPlaceholderNode(Node n) { Preconditions.checkNotNull(n.getParent()); Node placeholder = IR.script(); n.getParent().replaceChild(n, placeholder); return placeholder; }
private static void addExternDeclaration(Node externs, Node declarationStmt) { Node script = externs.getLastChild(); if (script == null || !script.isScript()) { script = IR.script(); externs.addChildToBack(script); } script.addChildToBack(declarationStmt); }
/** * Return a MeasuredNode of the given condition node, without minimizing * the result. * <p> * Since a MinimizedCondition necessarily must contain two trees, this * method sets the negative side to a {@link Token#SCRIPT} node (never valid * inside an expression) with an unreasonably high length so that it will * never be chosen by {@link #getMinimized}. * * @param n the conditional expression tree to minimize. * This must be connected to the AST, and will be swapped * with a placeholder node during minimization. * @return a MinimizedCondition object representing that tree. */ static MinimizedCondition unoptimized(Node n) { Preconditions.checkNotNull(n.getParent()); Node placeholder = swapWithPlaceholderNode(n); MeasuredNode pos = new MeasuredNode(n, 0, false); MeasuredNode neg = new MeasuredNode(IR.script(), Integer.MAX_VALUE, true); return new MinimizedCondition(pos, neg).setPlaceholder(placeholder); }
JsDocInfoParser(JsDocTokenStream stream, String comment, int commentPosition, Node templateNode, Config config, ErrorReporter errorReporter) { this.stream = stream; boolean parseDocumentation = config.jsDocParsingMode().shouldParseDescriptions(); this.jsdocBuilder = new JSDocInfoBuilder(parseDocumentation); if (comment != null) { this.jsdocBuilder.recordOriginalCommentString(comment); this.jsdocBuilder.recordOriginalCommentPosition(commentPosition); } this.annotations = config.annotations(); this.suppressionNames = config.suppressionNames(); this.preserveWhitespace = config.jsDocParsingMode().shouldPreserveWhitespace(); this.errorReporter = errorReporter; this.templateNode = templateNode == null ? IR.script() : templateNode; }
root = IR.script(); } else { compiler.prepareAst(root);
root = IR.script(); } else { compiler.prepareAst(root);
Node newFnNode = fnNode.cloneTree(); IR.root(IR.script(newFnNode));