Java 类org.mozilla.javascript.ast.LetNode 实例源码

项目:HL4A    文件:IRFactory.java   
private Node transformLetNode(LetNode node) {
    pushScope(node);
    try {
        decompiler.addToken(Token.LET);
        decompiler.addToken(Token.LP);
        Node vars = transformVariableInitializers(node.getVariables());
        decompiler.addToken(Token.RP);
        node.addChildToBack(vars);
        boolean letExpr = node.getType() == Token.LETEXPR;
        if (node.getBody() != null) {
            if (letExpr) {
                decompiler.addName(" ");
            } else {
                decompiler.addEOL(Token.LC);
            }
            node.addChildToBack(transform(node.getBody()));
            if (!letExpr) {
                decompiler.addEOL(Token.RC);
            }
        }
        return node;
    } finally {
        popScope();
    }
}
项目:LoboEvolution    文件:IRFactory.java   
private Node transformLetNode(LetNode node) {
    pushScope(node);
    try {
        decompiler.addToken(Token.LET);
        decompiler.addToken(Token.LP);
        Node vars = transformVariableInitializers(node.getVariables());
        decompiler.addToken(Token.RP);
        node.addChildToBack(vars);
        boolean letExpr = node.getType() == Token.LETEXPR;
        if (node.getBody() != null) {
            if (letExpr) {
                decompiler.addName(" ");
            } else {
                decompiler.addEOL(Token.LC);
            }
            node.addChildToBack(transform(node.getBody()));
            if (!letExpr) {
                decompiler.addEOL(Token.RC);
            }
        }
        return node;
    } finally {
        popScope();
    }
}
项目:HL4A    文件:IRFactory.java   
private Node transformVariables(VariableDeclaration node) {
    decompiler.addToken(node.getType());
    transformVariableInitializers(node);

    // Might be most robust to have parser record whether it was
    // a variable declaration statement, possibly as a node property.
    AstNode parent = node.getParent();
    if (!(parent instanceof Loop)
        && !(parent instanceof LetNode)) {
        decompiler.addEOL(Token.SEMI);
    }
    return node;
}
项目:LoboEvolution    文件:IRFactory.java   
private Node transformVariables(VariableDeclaration node) {
    decompiler.addToken(node.getType());
    transformVariableInitializers(node);

    // Might be most robust to have parser record whether it was
    // a variable declaration statement, possibly as a node property.
    AstNode parent = node.getParent();
    if (!(parent instanceof Loop)
        && !(parent instanceof LetNode)) {
        decompiler.addEOL(Token.SEMI);
    }
    return node;
}
项目:HL4A    文件:Parser.java   
private AstNode let(boolean isStatement, int pos)
    throws IOException
{
    LetNode pn = new LetNode(pos);
    pn.setLineno(ts.lineno);
    if (mustMatchToken(Token.LP, "msg.no.paren.after.let"))
        pn.setLp(ts.tokenBeg - pos);
    pushScope(pn);
    try {
        VariableDeclaration vars = variables(Token.LET, ts.tokenBeg, isStatement);
        pn.setVariables(vars);
        if (mustMatchToken(Token.RP, "msg.no.paren.let")) {
            pn.setRp(ts.tokenBeg - pos);
        }
        if (isStatement && peekToken() == Token.LC) {
            // let statement
            consumeToken();
            int beg = ts.tokenBeg;  // position stmt at LC
            AstNode stmt = statements();
            mustMatchToken(Token.RC, "msg.no.curly.let");
            stmt.setLength(ts.tokenEnd - beg);
            pn.setLength(ts.tokenEnd - pos);
            pn.setBody(stmt);
            pn.setType(Token.LET);
        } else {
            // let expression
            AstNode expr = expr();
            pn.setLength(getNodeEnd(expr) - pos);
            pn.setBody(expr);
            if (isStatement) {
                // let expression in statement context
                ExpressionStatement es =
                        new ExpressionStatement(pn, !insideFunction());
                es.setLineno(pn.getLineno());
                return es;
            }
        }
    } finally {
        popScope();
    }
    return pn;
}
项目:LoboEvolution    文件:Parser.java   
private AstNode let(boolean isStatement, int pos)
    throws IOException
{
    LetNode pn = new LetNode(pos);
    pn.setLineno(ts.lineno);
    if (mustMatchToken(Token.LP, "msg.no.paren.after.let"))
        pn.setLp(ts.tokenBeg - pos);
    pushScope(pn);
    try {
        VariableDeclaration vars = variables(Token.LET, ts.tokenBeg, isStatement);
        pn.setVariables(vars);
        if (mustMatchToken(Token.RP, "msg.no.paren.let")) {
            pn.setRp(ts.tokenBeg - pos);
        }
        if (isStatement && peekToken() == Token.LC) {
            // let statement
            consumeToken();
            int beg = ts.tokenBeg;  // position stmt at LC
            AstNode stmt = statements();
            mustMatchToken(Token.RC, "msg.no.curly.let");
            stmt.setLength(ts.tokenEnd - beg);
            pn.setLength(ts.tokenEnd - pos);
            pn.setBody(stmt);
            pn.setType(Token.LET);
        } else {
            // let expression
            AstNode expr = expr();
            pn.setLength(getNodeEnd(expr) - pos);
            pn.setBody(expr);
            if (isStatement) {
                // let expression in statement context
                ExpressionStatement es =
                        new ExpressionStatement(pn, !insideFunction());
                es.setLineno(pn.getLineno());
                return es;
            }
        }
    } finally {
        popScope();
    }
    return pn;
}
项目:teavm    文件:AstWriter.java   
private void print(LetNode node) throws IOException {
    writer.append("let").ws().append('(');
    printList(node.getVariables().getVariables());
    writer.append(')');
    writer.append(node.getBody());
}