本文整理匯總了Java中org.mozilla.javascript.ast.LetNode類的典型用法代碼示例。如果您正苦於以下問題:Java LetNode類的具體用法?Java LetNode怎麽用?Java LetNode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
LetNode類屬於org.mozilla.javascript.ast包,在下文中一共展示了LetNode類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: transformLetNode
import org.mozilla.javascript.ast.LetNode; //導入依賴的package包/類
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();
}
}
示例2: transformVariables
import org.mozilla.javascript.ast.LetNode; //導入依賴的package包/類
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;
}
示例3: let
import org.mozilla.javascript.ast.LetNode; //導入依賴的package包/類
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;
}
示例4: print
import org.mozilla.javascript.ast.LetNode; //導入依賴的package包/類
private void print(LetNode node) throws IOException {
writer.append("let").ws().append('(');
printList(node.getVariables().getVariables());
writer.append(')');
writer.append(node.getBody());
}