本文整理汇总了Java中jdk.nashorn.internal.ir.Expression.getToken方法的典型用法代码示例。如果您正苦于以下问题:Java Expression.getToken方法的具体用法?Java Expression.getToken怎么用?Java Expression.getToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jdk.nashorn.internal.ir.Expression
的用法示例。
在下文中一共展示了Expression.getToken方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newExpression
import jdk.nashorn.internal.ir.Expression; //导入方法依赖的package包/类
/**
* NewExpression :
* MemberExpression
* new NewExpression
*
* See 11.2
*
* Parse new expression.
* @return Expression node.
*/
private Expression newExpression() {
final long newToken = token;
// NEW is tested in caller.
next();
// Get function base.
final int callLine = line;
final Expression constructor = memberExpression();
if (constructor == null) {
return null;
}
// Get arguments.
ArrayList<Expression> arguments;
// Allow for missing arguments.
if (type == LPAREN) {
arguments = argumentList();
} else {
arguments = new ArrayList<>();
}
// Nashorn extension: This is to support the following interface implementation
// syntax:
//
// var r = new java.lang.Runnable() {
// run: function() { println("run"); }
// };
//
// The object literal following the "new Constructor()" expresssion
// is passed as an additional (last) argument to the constructor.
if (!env._no_syntax_extensions && type == LBRACE) {
arguments.add(objectLiteral());
}
final CallNode callNode = new CallNode(callLine, constructor.getToken(), finish, constructor, optimizeList(arguments), true);
return new UnaryNode(newToken, callNode);
}
示例2: referenceError
import jdk.nashorn.internal.ir.Expression; //导入方法依赖的package包/类
private RuntimeNode referenceError(final Expression lhs, final Expression rhs, final boolean earlyError) {
if (earlyError) {
throw error(JSErrorType.REFERENCE_ERROR, AbstractParser.message("invalid.lvalue"), lhs.getToken());
}
final ArrayList<Expression> args = new ArrayList<>();
args.add(lhs);
if (rhs == null) {
args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish()));
} else {
args.add(rhs);
}
args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish(), lhs.toString()));
return new RuntimeNode(lhs.getToken(), lhs.getFinish(), RuntimeNode.Request.REFERENCE_ERROR, args);
}
示例3: referenceError
import jdk.nashorn.internal.ir.Expression; //导入方法依赖的package包/类
private RuntimeNode referenceError(final Expression lhs, final Expression rhs, final boolean earlyError) {
if (env._parse_only || earlyError) {
throw error(JSErrorType.REFERENCE_ERROR, AbstractParser.message("invalid.lvalue"), lhs.getToken());
}
final ArrayList<Expression> args = new ArrayList<>();
args.add(lhs);
if (rhs == null) {
args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish()));
} else {
args.add(rhs);
}
args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish(), lhs.toString()));
return new RuntimeNode(lhs.getToken(), lhs.getFinish(), RuntimeNode.Request.REFERENCE_ERROR, args);
}
示例4: newExpression
import jdk.nashorn.internal.ir.Expression; //导入方法依赖的package包/类
/**
* NewExpression :
* MemberExpression
* new NewExpression
*
* See 11.2
*
* Parse new expression.
* @return Expression node.
*/
private Expression newExpression() {
final long newToken = token;
// NEW is tested in caller.
next();
if (type == PERIOD && isES6()) {
next();
if (type == IDENT && "target".equals(getValue())) {
if (lc.getCurrentFunction().isProgram()) {
throw error(AbstractParser.message("new.target.in.function"), token);
}
next();
markNewTarget(lc);
return new IdentNode(newToken, finish, "new.target");
} else {
throw error(AbstractParser.message("expected.target"), token);
}
}
// Get function base.
final int callLine = line;
final Expression constructor = memberExpression();
if (constructor == null) {
return null;
}
// Get arguments.
ArrayList<Expression> arguments;
// Allow for missing arguments.
if (type == LPAREN) {
arguments = argumentList();
} else {
arguments = new ArrayList<>();
}
// Nashorn extension: This is to support the following interface implementation
// syntax:
//
// var r = new java.lang.Runnable() {
// run: function() { println("run"); }
// };
//
// The object literal following the "new Constructor()" expression
// is passed as an additional (last) argument to the constructor.
if (!env._no_syntax_extensions && type == LBRACE) {
arguments.add(objectLiteral());
}
final CallNode callNode = new CallNode(callLine, constructor.getToken(), finish, constructor, optimizeList(arguments), true);
return new UnaryNode(newToken, callNode);
}