本文整理汇总了Java中jdk.nashorn.internal.ir.IdentNode.setIsDeclaredHere方法的典型用法代码示例。如果您正苦于以下问题:Java IdentNode.setIsDeclaredHere方法的具体用法?Java IdentNode.setIsDeclaredHere怎么用?Java IdentNode.setIsDeclaredHere使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jdk.nashorn.internal.ir.IdentNode
的用法示例。
在下文中一共展示了IdentNode.setIsDeclaredHere方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: variableStatement
import jdk.nashorn.internal.ir.IdentNode; //导入方法依赖的package包/类
/**
* VariableStatement :
* var VariableDeclarationList ;
*
* VariableDeclarationList :
* VariableDeclaration
* VariableDeclarationList , VariableDeclaration
*
* VariableDeclaration :
* Identifier Initializer?
*
* Initializer :
* = AssignmentExpression
*
* See 12.2
*
* Parse a VAR statement.
* @param isStatement True if a statement (not used in a FOR.)
*/
private List<VarNode> variableStatement(final TokenType varType, final boolean isStatement) {
// VAR tested in caller.
next();
final List<VarNode> vars = new ArrayList<>();
int varFlags = 0;
if (varType == LET) {
varFlags |= VarNode.IS_LET;
} else if (varType == CONST) {
varFlags |= VarNode.IS_CONST;
}
while (true) {
// Get starting token.
final int varLine = line;
final long varToken = token;
// Get name of var.
final IdentNode name = getIdent();
verifyStrictIdent(name, "variable name");
// Assume no init.
Expression init = null;
// Look for initializer assignment.
if (type == ASSIGN) {
next();
// Get initializer expression. Suppress IN if not statement.
defaultNames.push(name);
try {
init = assignmentExpression(!isStatement);
} finally {
defaultNames.pop();
}
} else if (varType == CONST) {
throw error(AbstractParser.message("missing.const.assignment", name.getName()));
}
// Allocate var node.
final VarNode var = new VarNode(varLine, varToken, finish, name.setIsDeclaredHere(), init, varFlags);
vars.add(var);
appendStatement(var);
if (type != COMMARIGHT) {
break;
}
next();
}
// If is a statement then handle end of line.
if (isStatement) {
final boolean semicolon = type == SEMICOLON;
endOfLine();
if (semicolon) {
lc.getCurrentBlock().setFinish(finish);
}
}
return vars;
}