本文整理汇总了Java中jdk.nashorn.internal.parser.TokenType类的典型用法代码示例。如果您正苦于以下问题:Java TokenType类的具体用法?Java TokenType怎么用?Java TokenType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TokenType类属于jdk.nashorn.internal.parser包,在下文中一共展示了TokenType类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: dumpTokens
import jdk.nashorn.internal.parser.TokenType; //导入依赖的package包/类
/**
* Dump a token stream to stdout
*
* TODO: most other bugging goes to stderr, change?
*
* @param source the source
* @param lexer the lexer
* @param stream the stream to dump
*/
public static void dumpTokens(final Source source, final Lexer lexer, final TokenStream stream) {
TokenType type;
int k = 0;
do {
while (k > stream.last()) {
// Get more tokens.
lexer.lexify();
}
final long token = stream.get(k);
type = Token.descType(token);
System.out.println("" + k + ": " + Token.toString(source, token, true));
k++;
} while(type != EOF);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:Debug.java
示例2: leaveExpressionStatement
import jdk.nashorn.internal.parser.TokenType; //导入依赖的package包/类
@Override
public Node leaveExpressionStatement(final ExpressionStatement expressionStatement) {
final Expression expr = expressionStatement.getExpression();
ExpressionStatement node = expressionStatement;
final FunctionNode currentFunction = lc.getCurrentFunction();
if (currentFunction.isProgram()) {
if (!isInternalExpression(expr) && !isEvalResultAssignment(expr)) {
node = expressionStatement.setExpression(
new BinaryNode(
Token.recast(
expressionStatement.getToken(),
TokenType.ASSIGN),
compilerConstant(RETURN),
expr));
}
}
return addStatement(node);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:Lower.java
示例3: leaveBlock
import jdk.nashorn.internal.parser.TokenType; //导入依赖的package包/类
@Override
public Node leaveBlock(final Block block) {
if (!artificialBlock) {
if (lc.isFunctionBody()) {
// Prepend declaration-only var statements to the top of the statement list.
lc.prependStatements(getCurrentFunctionState().varStatements);
} else if (lc.isSplitBody()) {
appendSplitReturn(FALLTHROUGH_STATE, NO_LINE_NUMBER);
if (getCurrentFunctionState().fn.isProgram()) {
// If we're splitting the program, make sure every shard ends with "return :return" and
// begins with ":return = :return-in;".
lc.prependStatement(new ExpressionStatement(NO_LINE_NUMBER, NO_TOKEN, NO_FINISH,
new BinaryNode(Token.toDesc(TokenType.ASSIGN, 0, 0), createReturnIdent(), createReturnParamIdent())));
}
}
}
return block;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:SplitIntoFunctions.java
示例4: enterBinaryNode
import jdk.nashorn.internal.parser.TokenType; //导入依赖的package包/类
@Override
public boolean enterBinaryNode(final BinaryNode binaryNode) {
if(binaryNode.isAssignment()) {
final Expression lhs = binaryNode.lhs();
if(!binaryNode.isSelfModifying()) {
tagNeverOptimistic(lhs);
}
if(lhs instanceof IdentNode) {
final Symbol symbol = ((IdentNode)lhs).getSymbol();
// Assignment to internal symbols is never optimistic, except for self-assignment expressions
if(symbol.isInternal() && !binaryNode.rhs().isSelfModifying()) {
tagNeverOptimistic(binaryNode.rhs());
}
}
} else if(binaryNode.isTokenType(TokenType.INSTANCEOF)) {
tagNeverOptimistic(binaryNode.lhs());
tagNeverOptimistic(binaryNode.rhs());
}
return true;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:OptimisticTypesCalculator.java
示例5: loadNOT
import jdk.nashorn.internal.parser.TokenType; //导入依赖的package包/类
private void loadNOT(final UnaryNode unaryNode) {
final Expression expr = unaryNode.getExpression();
if(expr instanceof UnaryNode && expr.isTokenType(TokenType.NOT)) {
// !!x is idiomatic boolean cast in JavaScript
loadExpressionAsBoolean(((UnaryNode)expr).getExpression());
} else {
final Label trueLabel = new Label("true");
final Label afterLabel = new Label("after");
emitBranch(expr, trueLabel, true);
method.load(true);
method._goto(afterLabel);
method.label(trueLabel);
method.load(false);
method.label(afterLabel);
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:CodeGenerator.java
示例6: enterBinaryNode
import jdk.nashorn.internal.parser.TokenType; //导入依赖的package包/类
@Override
public boolean enterBinaryNode(final BinaryNode binaryNode) {
if (binaryNode.isAssignment()) {
final ExpressionTree srcTree = translateExpr(binaryNode.getAssignmentSource());
final ExpressionTree destTree = translateExpr(binaryNode.getAssignmentDest());
if (binaryNode.isTokenType(TokenType.ASSIGN)) {
curExpr = new AssignmentTreeImpl(binaryNode, destTree, srcTree);
} else {
curExpr = new CompoundAssignmentTreeImpl(binaryNode, destTree, srcTree);
}
} else {
final ExpressionTree leftTree = translateExpr(binaryNode.lhs());
final ExpressionTree rightTree = translateExpr(binaryNode.rhs());
if (binaryNode.isTokenType(TokenType.INSTANCEOF)) {
curExpr = new InstanceOfTreeImpl(binaryNode, leftTree, rightTree);
} else {
curExpr = new BinaryTreeImpl(binaryNode, leftTree, rightTree);
}
}
return false;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:IRTranslator.java
示例7: enterUnaryNode
import jdk.nashorn.internal.parser.TokenType; //导入依赖的package包/类
@Override
public boolean enterUnaryNode(final UnaryNode unaryNode) {
if (unaryNode.isTokenType(TokenType.NEW)) {
curExpr = new NewTreeImpl(unaryNode,
translateExpr(unaryNode.getExpression()));
} else if (unaryNode.isTokenType(TokenType.YIELD) ||
unaryNode.isTokenType(TokenType.YIELD_STAR)) {
curExpr = new YieldTreeImpl(unaryNode,
translateExpr(unaryNode.getExpression()));
} else if (unaryNode.isTokenType(TokenType.SPREAD_ARGUMENT) ||
unaryNode.isTokenType(TokenType.SPREAD_ARRAY)) {
curExpr = new SpreadTreeImpl(unaryNode,
translateExpr(unaryNode.getExpression()));
} else {
curExpr = new UnaryTreeImpl(unaryNode,
translateExpr(unaryNode.getExpression()));
}
return false;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:IRTranslator.java
示例8: leaveExpressionStatement
import jdk.nashorn.internal.parser.TokenType; //导入依赖的package包/类
@Override
public Node leaveExpressionStatement(final ExpressionStatement expressionStatement) {
final Expression expr = expressionStatement.getExpression();
ExpressionStatement node = expressionStatement;
final FunctionNode currentFunction = lc.getCurrentFunction();
if (currentFunction.isProgram()) {
if (!isInternalExpression(expr) && !isEvalResultAssignment(expr)) {
node = expressionStatement.setExpression(
new BinaryNode(
Token.recast(
expressionStatement.getToken(),
TokenType.ASSIGN),
compilerConstant(RETURN),
expr));
}
}
if (es6 && expressionStatement.destructuringDeclarationType() != null) {
throwNotImplementedYet("es6.destructuring", expressionStatement);
}
return addStatement(node);
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:Lower.java
示例9: enterBinaryNode
import jdk.nashorn.internal.parser.TokenType; //导入依赖的package包/类
@Override
public boolean enterBinaryNode(final BinaryNode binaryNode) {
if(binaryNode.isAssignment()) {
final Expression lhs = binaryNode.lhs();
if(!binaryNode.isSelfModifying()) {
tagNeverOptimistic(lhs);
}
if(lhs instanceof IdentNode) {
final Symbol symbol = ((IdentNode)lhs).getSymbol();
// Assignment to internal symbols is never optimistic, except for self-assignment expressions
if(symbol.isInternal() && !binaryNode.rhs().isSelfModifying()) {
tagNeverOptimistic(binaryNode.rhs());
}
}
} else if(binaryNode.isTokenType(TokenType.INSTANCEOF)
|| binaryNode.isTokenType(TokenType.EQ_STRICT)
|| binaryNode.isTokenType(TokenType.NE_STRICT)) {
tagNeverOptimistic(binaryNode.lhs());
tagNeverOptimistic(binaryNode.rhs());
}
return true;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:OptimisticTypesCalculator.java
示例10: emitObjectToNumberComparisonConversion
import jdk.nashorn.internal.parser.TokenType; //导入依赖的package包/类
private static void emitObjectToNumberComparisonConversion(final MethodEmitter method, final TokenType tt) {
switch(tt) {
case EQ:
case NE:
if (method.peekType().isObject()) {
TO_NUMBER_FOR_EQ.invoke(method);
return;
}
break;
case EQ_STRICT:
case NE_STRICT:
if (method.peekType().isObject()) {
TO_NUMBER_FOR_STRICT_EQ.invoke(method);
return;
}
break;
default:
break;
}
method.convert(Type.NUMBER);
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:CodeGenerator.java
示例11: tokenFor
import jdk.nashorn.internal.parser.TokenType; //导入依赖的package包/类
private static long tokenFor(final FunctionNode fn) {
final int position = Token.descPosition(fn.getFirstToken());
final long lastToken = Token.withDelimiter(fn.getLastToken());
// EOL uses length field to store the line number
final int length = Token.descPosition(lastToken) - position + (Token.descType(lastToken) == TokenType.EOL ? 0 : Token.descLength(lastToken));
return Token.toDesc(TokenType.FUNCTION, position, length);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:RecompilableScriptFunctionData.java
示例12: isLogical
import jdk.nashorn.internal.parser.TokenType; //导入依赖的package包/类
/**
* Returns true if the token type represents a logical operation.
* @param tokenType the token type
* @return true if the token type represents a logical operation.
*/
public static boolean isLogical(final TokenType tokenType) {
switch (tokenType) {
case AND:
case OR:
return true;
default:
return false;
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:BinaryNode.java
示例13: getMostOptimisticType
import jdk.nashorn.internal.parser.TokenType; //导入依赖的package包/类
@Override
public Type getMostOptimisticType() {
final TokenType tokenType = tokenType();
if(tokenType == TokenType.ADD || tokenType == TokenType.ASSIGN_ADD) {
return OPTIMISTIC_UNDECIDED_TYPE;
} else if (CAN_OVERFLOW.contains(tokenType())) {
return Type.INT;
}
return getMostPessimisticType();
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:BinaryNode.java
示例14: toString
import jdk.nashorn.internal.parser.TokenType; //导入依赖的package包/类
/**
* Creates the string representation of this unary node, delegating the creation of the string representation of its
* operand to a specified runnable.
* @param sb the string builder to use
* @param rhsStringBuilder the runnable that appends the string representation of the operand to the string builder
* @param printType should we print type
* when invoked.
*/
public void toString(final StringBuilder sb, final Runnable rhsStringBuilder, final boolean printType) {
final TokenType tokenType = tokenType();
final String name = tokenType.getName();
final boolean isPostfix = tokenType == DECPOSTFIX || tokenType == INCPOSTFIX;
if (isOptimistic()) {
sb.append(Expression.OPT_IDENTIFIER);
}
boolean rhsParen = tokenType.needsParens(getExpression().tokenType(), false);
if (!isPostfix) {
if (name == null) {
sb.append(tokenType.name());
rhsParen = true;
} else {
sb.append(name);
if (tokenType.ordinal() > BIT_NOT.ordinal()) {
sb.append(' ');
}
}
}
if (rhsParen) {
sb.append('(');
}
rhsStringBuilder.run();
if (rhsParen) {
sb.append(')');
}
if (isPostfix) {
sb.append(tokenType == DECPOSTFIX ? "--" : "++");
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:44,代码来源:UnaryNode.java
示例15: ArrayLiteralNode
import jdk.nashorn.internal.parser.TokenType; //导入依赖的package包/类
/**
* Constructor
*
* @param token token
* @param finish finish
* @param value array literal value, a Node array
*/
protected ArrayLiteralNode(final long token, final int finish, final Expression[] value) {
super(Token.recast(token, TokenType.ARRAY), finish, value);
this.elementType = Type.UNKNOWN;
this.presets = null;
this.postsets = null;
this.units = null;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:LiteralNode.java
示例16: toString
import jdk.nashorn.internal.parser.TokenType; //导入依赖的package包/类
@Override
public void toString(final StringBuilder sb, final boolean printType) {
final TokenType tokenType = tokenType();
final boolean testParen = tokenType.needsParens(getTest().tokenType(), true);
final boolean trueParen = tokenType.needsParens(getTrueExpression().tokenType(), false);
final boolean falseParen = tokenType.needsParens(getFalseExpression().tokenType(), false);
if (testParen) {
sb.append('(');
}
getTest().toString(sb, printType);
if (testParen) {
sb.append(')');
}
sb.append(" ? ");
if (trueParen) {
sb.append('(');
}
getTrueExpression().toString(sb, printType);
if (trueParen) {
sb.append(')');
}
sb.append(" : ");
if (falseParen) {
sb.append('(');
}
getFalseExpression().toString(sb, printType);
if (falseParen) {
sb.append(')');
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:36,代码来源:TernaryNode.java
示例17: makeIfStateEquals
import jdk.nashorn.internal.parser.TokenType; //导入依赖的package包/类
private static IfNode makeIfStateEquals(final int lineNumber, final long token, final int finish,
final int value, final Block pass, final Statement fail) {
return new IfNode(lineNumber, token, finish,
new BinaryNode(Token.recast(token, TokenType.EQ_STRICT),
GetSplitState.INSTANCE, intLiteral(value)),
pass,
fail == null ? null : new Block(NO_TOKEN, NO_FINISH, fail));
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:SplitIntoFunctions.java
注:本文中的jdk.nashorn.internal.parser.TokenType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论