本文整理汇总了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());
}