本文整理汇总了Java中jdk.nashorn.internal.ir.Node类的典型用法代码示例。如果您正苦于以下问题:Java Node类的具体用法?Java Node怎么用?Java Node使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Node类属于jdk.nashorn.internal.ir包,在下文中一共展示了Node类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: enterCatchNode
import jdk.nashorn.internal.ir.Node; //导入依赖的package包/类
@Override
public boolean enterCatchNode(final CatchNode catchNode) {
enterDefault(catchNode);
type("CatchClause");
comma();
property("param");
catchNode.getException().accept(this);
comma();
final Node guard = catchNode.getExceptionCondition();
if (guard != null) {
property("guard");
guard.accept(this);
comma();
}
property("body");
catchNode.getBody().accept(this);
return leave();
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:JSONWriter.java
示例2: leaveForNode
import jdk.nashorn.internal.ir.Node; //导入依赖的package包/类
@Override
public Node leaveForNode(final ForNode forNode) {
ForNode newForNode = forNode;
final Expression test = forNode.getTest();
if (!forNode.isForIn() && isAlwaysTrue(test)) {
newForNode = forNode.setTest(lc, null);
}
newForNode = checkEscape(newForNode);
if(newForNode.isForIn()) {
// Wrap it in a block so its internally created iterator is restricted in scope
addStatementEnclosedInBlock(newForNode);
} else {
addStatement(newForNode);
}
return newForNode;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:Lower.java
示例3: pop
import jdk.nashorn.internal.ir.Node; //导入依赖的package包/类
@Override
public <T extends Node> T pop(final T node) {
final T popped = super.pop(node);
if (isWithBoundary(node)) {
dynamicScopeCount--;
assert dynamicScopeCount >= 0;
} else if (node instanceof FunctionNode) {
if (((FunctionNode)node).inDynamicContext()) {
dynamicScopeCount--;
assert dynamicScopeCount >= 0;
}
assert splitNodes.peek() == 0;
splitNodes.pop();
}
return popped;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:CodeGeneratorLexicalContext.java
示例4: leaveExpressionStatement
import jdk.nashorn.internal.ir.Node; //导入依赖的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
示例5: leaveIdentNode
import jdk.nashorn.internal.ir.Node; //导入依赖的package包/类
@Override
public Node leaveIdentNode(final IdentNode identNode) {
if (identNode.isPropertyName()) {
return identNode;
}
final Symbol symbol = nameIsUsed(identNode.getName(), identNode);
if (!identNode.isInitializedHere()) {
symbol.increaseUseCount();
}
IdentNode newIdentNode = identNode.setSymbol(symbol);
// If a block-scoped var is used before its declaration mark it as dead.
// We can only statically detect this for local vars, cross-function symbols require runtime checks.
if (symbol.isBlockScoped() && !symbol.hasBeenDeclared() && !identNode.isDeclaredHere() && isLocal(lc.getCurrentFunction(), symbol)) {
newIdentNode = newIdentNode.markDead();
}
return end(newIdentNode);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:AssignSymbols.java
示例6: start
import jdk.nashorn.internal.ir.Node; //导入依赖的package包/类
private boolean start(final Node node, final boolean printNode) {
if (debug) {
final StringBuilder sb = new StringBuilder();
sb.append("[ENTER ").
append(name(node)).
append("] ").
append(printNode ? node.toString() : "").
append(" in '").
append(lc.getCurrentFunction().getName()).
append("'");
log.info(sb);
log.indent();
}
return true;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:AssignSymbols.java
示例7: leaveTYPEOF
import jdk.nashorn.internal.ir.Node; //导入依赖的package包/类
private Node leaveTYPEOF(final UnaryNode unaryNode) {
final Expression rhs = unaryNode.getExpression();
final List<Expression> args = new ArrayList<>();
if (rhs instanceof IdentNode && !isParamOrVar((IdentNode)rhs)) {
args.add(compilerConstantIdentifier(SCOPE));
args.add(LiteralNode.newInstance(rhs, ((IdentNode)rhs).getName())); //null
} else {
args.add(rhs);
args.add(LiteralNode.newInstance(unaryNode)); //null, do not reuse token of identifier rhs, it can be e.g. 'this'
}
final Node runtimeNode = new RuntimeNode(unaryNode, Request.TYPEOF, args);
end(unaryNode);
return runtimeNode;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:AssignSymbols.java
示例8: leaveForNode
import jdk.nashorn.internal.ir.Node; //导入依赖的package包/类
@Override
public Node leaveForNode(final ForNode forNode) {
ForNode newForNode = forNode;
final Expression test = forNode.getTest();
if (!forNode.isForInOrOf() && isAlwaysTrue(test)) {
newForNode = forNode.setTest(lc, null);
}
newForNode = checkEscape(newForNode);
if(!es6 && newForNode.isForInOrOf()) {
// Wrap it in a block so its internally created iterator is restricted in scope, unless we are running
// in ES6 mode, in which case the parser already created a block to capture let/const declarations.
addStatementEnclosedInBlock(newForNode);
} else {
addStatement(newForNode);
}
return newForNode;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:Lower.java
示例9: leaveIdentNode
import jdk.nashorn.internal.ir.Node; //导入依赖的package包/类
@Override
public Node leaveIdentNode(final IdentNode identNode) {
if(identNode.isPropertyName()) {
return identNode;
}
return setProgramPoint(identNode);
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:ProgramPoints.java
示例10: isNumericArray
import jdk.nashorn.internal.ir.Node; //导入依赖的package包/类
private static boolean isNumericArray(final Node[] values) {
for (final Node node : values) {
if (node instanceof LiteralNode && ((LiteralNode<?>)node).getValue() instanceof Number) {
continue;
}
return false;
}
return true;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:JSONFunctions.java
示例11: end
import jdk.nashorn.internal.ir.Node; //导入依赖的package包/类
private <T extends Node> T end(final T node, final boolean printNode) {
if (debug) {
final StringBuilder sb = new StringBuilder();
sb.append("[LEAVE ").
append(name(node)).
append("] ").
append(printNode ? node.toString() : "").
append(" in '").
append(lc.getCurrentFunction().getName()).
append('\'');
if (node instanceof IdentNode) {
final Symbol symbol = ((IdentNode)node).getSymbol();
if (symbol == null) {
sb.append(" <NO SYMBOL>");
} else {
sb.append(" <symbol=").append(symbol).append('>');
}
}
log.unindent();
log.info(sb);
}
return node;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:AssignSymbols.java
示例12: leaveLiteralNode
import jdk.nashorn.internal.ir.Node; //导入依赖的package包/类
@Override
public Node leaveLiteralNode(final LiteralNode<?> literalNode) {
//for e.g. ArrayLiteralNodes the initial types may have been narrowed due to the
//introduction of optimistic behavior - hence ensure that all literal nodes are
//reinitialized
return literalNode.initialize(lc);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:LocalVariableTypesCalculator.java
示例13: leaveCaseNode
import jdk.nashorn.internal.ir.Node; //导入依赖的package包/类
@Override
public Node leaveCaseNode(final CaseNode caseNode) {
// Try to represent the case test as an integer
final Node test = caseNode.getTest();
if (test instanceof LiteralNode) {
final LiteralNode<?> lit = (LiteralNode<?>)test;
if (lit.isNumeric() && !(lit.getValue() instanceof Integer)) {
if (JSType.isRepresentableAsInt(lit.getNumber())) {
return caseNode.setTest((Expression)LiteralNode.newInstance(lit, lit.getInt32()).accept(this));
}
}
}
return caseNode;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:Lower.java
示例14: leaveTernaryNode
import jdk.nashorn.internal.ir.Node; //导入依赖的package包/类
@Override
public Node leaveTernaryNode(final TernaryNode ternaryNode) {
final Node test = ternaryNode.getTest();
if (test instanceof LiteralNode.PrimitiveLiteralNode) {
return (((LiteralNode.PrimitiveLiteralNode<?>)test).isTrue() ? ternaryNode.getTrueExpression() : ternaryNode.getFalseExpression()).getExpression();
}
return ternaryNode;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:FoldConstants.java
示例15: enterDefault
import jdk.nashorn.internal.ir.Node; //导入依赖的package包/类
@Override
protected boolean enterDefault(final Node node) {
objectStart();
location(node);
return true;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:JSONWriter.java
示例16: leaveIndexNode
import jdk.nashorn.internal.ir.Node; //导入依赖的package包/类
@Override
public Node leaveIndexNode(final IndexNode indexNode) {
final String name = getConstantPropertyName(indexNode.getIndex());
if (name != null) {
// If index node is a constant property name convert index node to access node.
assert indexNode.isIndex();
return new AccessNode(indexNode.getToken(), indexNode.getFinish(), indexNode.getBase(), name);
}
return super.leaveIndexNode(indexNode);
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:Lower.java
示例17: enterLiteralNode
import jdk.nashorn.internal.ir.Node; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public boolean enterLiteralNode(final LiteralNode literalNode) {
weight += LITERAL_WEIGHT;
if (literalNode instanceof ArrayLiteralNode) {
final ArrayLiteralNode arrayLiteralNode = (ArrayLiteralNode)literalNode;
final Node[] value = arrayLiteralNode.getValue();
final int[] postsets = arrayLiteralNode.getPostsets();
final List<Splittable.SplitRange> units = arrayLiteralNode.getSplitRanges();
if (units == null) {
for (final int postset : postsets) {
weight += AASTORE_WEIGHT;
final Node element = value[postset];
if (element != null) {
element.accept(this);
}
}
}
return false;
}
return true;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:WeighNodes.java
示例18: isEvalResultAssignment
import jdk.nashorn.internal.ir.Node; //导入依赖的package包/类
/**
* Is this an assignment to the special variable that hosts scripting eval
* results, i.e. __return__?
*
* @param expression expression to check whether it is $evalresult = X
* @return true if an assignment to eval result, false otherwise
*/
private static boolean isEvalResultAssignment(final Node expression) {
final Node e = expression;
if (e instanceof BinaryNode) {
final Node lhs = ((BinaryNode)e).lhs();
if (lhs instanceof IdentNode) {
return ((IdentNode)lhs).getName().equals(RETURN.symbolName());
}
}
return false;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:Lower.java
示例19: leaveFunctionNode
import jdk.nashorn.internal.ir.Node; //导入依赖的package包/类
/**
* Try to do the apply to call transformation
* @return true if successful, false otherwise
*/
@Override
public Node leaveFunctionNode(final FunctionNode functionNode) {
FunctionNode newFunctionNode = functionNode;
final String functionName = newFunctionNode.getName();
if (changed.contains(newFunctionNode.getId())) {
newFunctionNode = newFunctionNode.clearFlag(lc, FunctionNode.USES_ARGUMENTS).
setFlag(lc, FunctionNode.HAS_APPLY_TO_CALL_SPECIALIZATION).
setParameters(lc, explodedArguments.peek());
if (log.isEnabled()) {
log.info("Success: ",
massageURL(newFunctionNode.getSource().getURL()),
'.',
functionName,
"' id=",
newFunctionNode.getId(),
" params=",
callSiteTypes.peek());
}
}
callSiteTypes.pop();
explodedArguments.pop();
return newFunctionNode.setState(lc, CompilationState.BUILTINS_TRANSFORMED);
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:32,代码来源:ApplySpecialization.java
示例20: leaveASSIGN
import jdk.nashorn.internal.ir.Node; //导入依赖的package包/类
private Node leaveASSIGN(final BinaryNode binaryNode) {
// If we're assigning a property of the this object ("this.foo = ..."), record it.
final Expression lhs = binaryNode.lhs();
if (lhs instanceof AccessNode) {
final AccessNode accessNode = (AccessNode) lhs;
final Expression base = accessNode.getBase();
if (base instanceof IdentNode) {
final Symbol symbol = ((IdentNode)base).getSymbol();
if(symbol.isThis()) {
thisProperties.peek().add(accessNode.getProperty());
}
}
}
return binaryNode;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:AssignSymbols.java
注:本文中的jdk.nashorn.internal.ir.Node类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论