本文整理汇总了Java中jdk.nashorn.internal.ir.visitor.NodeVisitor类的典型用法代码示例。如果您正苦于以下问题:Java NodeVisitor类的具体用法?Java NodeVisitor怎么用?Java NodeVisitor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NodeVisitor类属于jdk.nashorn.internal.ir.visitor包,在下文中一共展示了NodeVisitor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: accept
import jdk.nashorn.internal.ir.visitor.NodeVisitor; //导入依赖的package包/类
/**
* Assist in IR navigation.
*
* @param visitor IR navigating visitor.
*
* @return node or replacement
*/
@Override
public Node accept(final LexicalContext lc, final NodeVisitor<? extends LexicalContext> visitor) {
if (visitor.enterCallNode(this)) {
final CallNode newCallNode = (CallNode)visitor.leaveCallNode(
setFunction((Expression)function.accept(visitor)).
setArgs(Node.accept(visitor, args)).
setEvalArgs(evalArgs == null ?
null :
evalArgs.setArgs(Node.accept(visitor, evalArgs.getArgs()))));
// Theoretically, we'd need to instead pass lc to every setter and do a replacement on each. In practice,
// setType from TypeOverride can't accept a lc, and we don't necessarily want to go there now.
if (this != newCallNode) {
return Node.replaceInLexicalContext(lc, this, newCallNode);
}
}
return this;
}
示例2: accept
import jdk.nashorn.internal.ir.visitor.NodeVisitor; //导入依赖的package包/类
/**
* Assist in IR navigation.
* @param visitor IR navigating visitor.
*/
@Override
public Node accept(final NodeVisitor<? extends LexicalContext> visitor) {
if (visitor.enterTryNode(this)) {
// Need to do finallybody first for termination analysis. TODO still necessary?
final Block newFinallyBody = finallyBody == null ? null : (Block)finallyBody.accept(visitor);
final Block newBody = (Block)body.accept(visitor);
return visitor.leaveTryNode(
setBody(newBody).
setFinallyBody(newFinallyBody).
setCatchBlocks(Node.accept(visitor, catchBlocks)).
setFinallyCatchAll(finallyCatchAll));
}
return this;
}
示例3: directChildren
import jdk.nashorn.internal.ir.visitor.NodeVisitor; //导入依赖的package包/类
private static List<FunctionNode> directChildren(final FunctionNode functionNode) {
final List<FunctionNode> dc = new ArrayList<>();
functionNode.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) {
@Override
public boolean enterFunctionNode(final FunctionNode child) {
if (child == functionNode) {
return true;
}
if (lc.getParentFunction(child) == functionNode) {
dc.add(child);
}
return false;
}
});
return dc;
}
示例4: hasApplies
import jdk.nashorn.internal.ir.visitor.NodeVisitor; //导入依赖的package包/类
private boolean hasApplies(final FunctionNode functionNode) {
try {
functionNode.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) {
@Override
public boolean enterFunctionNode(final FunctionNode fn) {
return fn == functionNode;
}
@Override
public boolean enterCallNode(final CallNode callNode) {
if (isApply(callNode)) {
throw HAS_APPLIES;
}
return true;
}
});
} catch (final AppliesFoundException e) {
return true;
}
log.fine("There are no applies in ", DebugLogger.quote(functionNode.getName()), " - nothing to do.");
return false; // no applies
}
示例5: markEvalInArrowParameterList
import jdk.nashorn.internal.ir.visitor.NodeVisitor; //导入依赖的package包/类
private void markEvalInArrowParameterList(final ParserContextBlockNode parameterBlock) {
final Iterator<ParserContextFunctionNode> iter = lc.getFunctions();
final ParserContextFunctionNode current = iter.next();
final ParserContextFunctionNode parent = iter.next();
if (parent.getFlag(FunctionNode.HAS_EVAL) != 0) {
// we might have flagged has-eval in the parent function during parsing the parameter list,
// if the parameter list contains eval; must tag arrow function as has-eval.
for (final Statement st : parameterBlock.getStatements()) {
st.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) {
@Override
public boolean enterCallNode(final CallNode callNode) {
if (callNode.getFunction() instanceof IdentNode && ((IdentNode) callNode.getFunction()).getName().equals("eval")) {
current.setFlag(FunctionNode.HAS_EVAL);
}
return true;
}
});
}
// TODO: function containing the arrow function should not be flagged has-eval
}
}
示例6: accept
import jdk.nashorn.internal.ir.visitor.NodeVisitor; //导入依赖的package包/类
/**
* Assist in IR navigation.
* @param visitor IR navigating visitor.
*/
@Override
public Node accept(final LexicalContext lc, final NodeVisitor<? extends LexicalContext> visitor) {
if (visitor.enterTryNode(this)) {
// Need to do finallybody first for termination analysis. TODO still necessary?
final Block newFinallyBody = finallyBody == null ? null : (Block)finallyBody.accept(visitor);
final Block newBody = (Block)body.accept(visitor);
return visitor.leaveTryNode(
setBody(lc, newBody).
setFinallyBody(lc, newFinallyBody).
setCatchBlocks(lc, Node.accept(visitor, catchBlocks)).
setInlinedFinallies(lc, Node.accept(visitor, inlinedFinallies)));
}
return this;
}
示例7: accept
import jdk.nashorn.internal.ir.visitor.NodeVisitor; //导入依赖的package包/类
/**
* Assist in IR navigation.
* @param visitor IR navigating visitor.
*/
@Override
public Node accept(final NodeVisitor<? extends LexicalContext> visitor) {
if (visitor.enterVarNode(this)) {
// var is right associative, so visit init before name
final Expression newInit = init == null ? null : (Expression)init.accept(visitor);
final IdentNode newName = (IdentNode)name.accept(visitor);
final VarNode newThis;
if (name != newName || init != newInit) {
newThis = new VarNode(this, newName, newInit, flags);
} else {
newThis = this;
}
return visitor.leaveVarNode(newThis);
}
return this;
}
示例8: accept
import jdk.nashorn.internal.ir.visitor.NodeVisitor; //导入依赖的package包/类
@Override
public Node accept(final NodeVisitor<? extends LexicalContext> visitor) {
if (visitor.enterReturnNode(this)) {
if (expression != null) {
return visitor.leaveReturnNode(setExpression((Expression)expression.accept(visitor)));
}
return visitor.leaveReturnNode(this);
}
return this;
}
示例9: accept
import jdk.nashorn.internal.ir.visitor.NodeVisitor; //导入依赖的package包/类
@Override
public Node accept(final LexicalContext lc, final NodeVisitor<? extends LexicalContext> visitor) {
if (visitor.enterFunctionNode(this)) {
return visitor.leaveFunctionNode(setBody(lc, (Block)body.accept(visitor)));
}
return this;
}
示例10: accept
import jdk.nashorn.internal.ir.visitor.NodeVisitor; //导入依赖的package包/类
@Override
public Node accept(final LexicalContext lc, final NodeVisitor<? extends LexicalContext> visitor) {
if (visitor.enterSwitchNode(this)) {
return visitor.leaveSwitchNode(
setExpression(lc, (Expression)expression.accept(visitor)).
setCases(lc, Node.accept(visitor, cases), defaultCaseIndex));
}
return this;
}
示例11: accept
import jdk.nashorn.internal.ir.visitor.NodeVisitor; //导入依赖的package包/类
@Override
public Node accept(final NodeVisitor<? extends LexicalContext> visitor) {
if (visitor.enterIndexNode(this)) {
return visitor.leaveIndexNode(
setBase((Expression)base.accept(visitor)).
setIndex((Expression)index.accept(visitor)));
}
return this;
}
示例12: accept
import jdk.nashorn.internal.ir.visitor.NodeVisitor; //导入依赖的package包/类
/**
* Assist in IR navigation.
*
* @param visitor IR navigating visitor.
* @return new or same node
*/
@Override
public Node accept(final LexicalContext lc, final NodeVisitor<? extends LexicalContext> visitor) {
if (visitor.enterBlock(this)) {
return visitor.leaveBlock(setStatements(lc, Node.accept(visitor, statements)));
}
return this;
}
示例13: accept
import jdk.nashorn.internal.ir.visitor.NodeVisitor; //导入依赖的package包/类
@Override
public Node accept(final NodeVisitor<? extends LexicalContext> visitor) {
if(visitor.enterJoinPredecessorExpression(this)) {
final Expression expr = getExpression();
return visitor.leaveJoinPredecessorExpression(expr == null ? this : setExpression((Expression)expr.accept(visitor)));
}
return this;
}
示例14: accept
import jdk.nashorn.internal.ir.visitor.NodeVisitor; //导入依赖的package包/类
/**
* Assist in IR navigation.
* @param visitor IR navigating visitor.
*/
@Override
public Node accept(final NodeVisitor<? extends LexicalContext> visitor) {
if (visitor.enterBinaryNode(this)) {
return visitor.leaveBinaryNode(setLHS((Expression)lhs.accept(visitor)).setRHS((Expression)rhs.accept(visitor)));
}
return this;
}
示例15: accept
import jdk.nashorn.internal.ir.visitor.NodeVisitor; //导入依赖的package包/类
@Override
public Node accept(final NodeVisitor<? extends LexicalContext> visitor) {
if (visitor.enterRuntimeNode(this)) {
return visitor.leaveRuntimeNode(setArgs(Node.accept(visitor, args)));
}
return this;
}