本文整理汇总了Java中jdk.nashorn.internal.ir.TernaryNode类的典型用法代码示例。如果您正苦于以下问题:Java TernaryNode类的具体用法?Java TernaryNode怎么用?Java TernaryNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TernaryNode类属于jdk.nashorn.internal.ir包,在下文中一共展示了TernaryNode类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: enterTernaryNode
import jdk.nashorn.internal.ir.TernaryNode; //导入依赖的package包/类
@Override
public boolean enterTernaryNode(final TernaryNode ternaryNode) {
enterDefault(ternaryNode);
type("ConditionalExpression");
comma();
property("test");
ternaryNode.getTest().accept(this);
comma();
property("consequent");
ternaryNode.getTrueExpression().accept(this);
comma();
property("alternate");
ternaryNode.getFalseExpression().accept(this);
return leave();
}
示例2: enterTernaryNode
import jdk.nashorn.internal.ir.TernaryNode; //导入依赖的package包/类
@Override
public boolean enterTernaryNode(final TernaryNode ternaryNode) {
final Expression test = ternaryNode.getTest();
final Expression trueExpr = ternaryNode.getTrueExpression();
final Expression falseExpr = ternaryNode.getFalseExpression();
test.accept(this);
final Map<Symbol, LvarType> testExitLvarTypes = localVariableTypes;
if(!isAlwaysFalse(test)) {
trueExpr.accept(this);
}
final Map<Symbol, LvarType> trueExitLvarTypes = localVariableTypes;
localVariableTypes = testExitLvarTypes;
if(!isAlwaysTrue(test)) {
falseExpr.accept(this);
}
final Map<Symbol, LvarType> falseExitLvarTypes = localVariableTypes;
localVariableTypes = getUnionTypes(trueExitLvarTypes, falseExitLvarTypes);
setConversion((JoinPredecessor)trueExpr, trueExitLvarTypes, localVariableTypes);
setConversion((JoinPredecessor)falseExpr, falseExitLvarTypes, localVariableTypes);
return false;
}
示例3: loadTernaryNode
import jdk.nashorn.internal.ir.TernaryNode; //导入依赖的package包/类
private void loadTernaryNode(final TernaryNode ternaryNode, final TypeBounds resultBounds) {
final Expression test = ternaryNode.getTest();
final JoinPredecessorExpression trueExpr = ternaryNode.getTrueExpression();
final JoinPredecessorExpression falseExpr = ternaryNode.getFalseExpression();
final Label falseLabel = new Label("ternary_false");
final Label exitLabel = new Label("ternary_exit");
final Type outNarrowest = Type.narrowest(resultBounds.widest, Type.generic(Type.widestReturnType(trueExpr.getType(), falseExpr.getType())));
final TypeBounds outBounds = resultBounds.notNarrowerThan(outNarrowest);
emitBranch(test, falseLabel, false);
loadExpression(trueExpr.getExpression(), outBounds);
assert Type.generic(method.peekType()) == outBounds.narrowest;
method.beforeJoinPoint(trueExpr);
method._goto(exitLabel);
method.label(falseLabel);
loadExpression(falseExpr.getExpression(), outBounds);
assert Type.generic(method.peekType()) == outBounds.narrowest;
method.beforeJoinPoint(falseExpr);
method.label(exitLabel);
}
示例4: loadTernaryNode
import jdk.nashorn.internal.ir.TernaryNode; //导入依赖的package包/类
private void loadTernaryNode(final TernaryNode ternaryNode, final TypeBounds resultBounds) {
final Expression test = ternaryNode.getTest();
final JoinPredecessorExpression trueExpr = ternaryNode.getTrueExpression();
final JoinPredecessorExpression falseExpr = ternaryNode.getFalseExpression();
final Label falseLabel = new Label("ternary_false");
final Label exitLabel = new Label("ternary_exit");
final Type outNarrowest = Type.narrowest(resultBounds.widest, Type.generic(Type.widestReturnType(trueExpr.getType(), falseExpr.getType())));
final TypeBounds outBounds = resultBounds.notNarrowerThan(outNarrowest);
emitBranch(test, falseLabel, false);
final boolean isCurrentDiscard = lc.popDiscardIfCurrent(ternaryNode);
loadMaybeDiscard(isCurrentDiscard, trueExpr.getExpression(), outBounds);
assert isCurrentDiscard || Type.generic(method.peekType()) == outBounds.narrowest;
method.beforeJoinPoint(trueExpr);
method._goto(exitLabel);
method.label(falseLabel);
loadMaybeDiscard(isCurrentDiscard, falseExpr.getExpression(), outBounds);
assert isCurrentDiscard || Type.generic(method.peekType()) == outBounds.narrowest;
method.beforeJoinPoint(falseExpr);
method.label(exitLabel);
}
示例5: branchOptimizer
import jdk.nashorn.internal.ir.TernaryNode; //导入依赖的package包/类
private void branchOptimizer(final Expression node, final Label label, final boolean state) {
if (!(node instanceof TernaryNode)) {
if (node instanceof BinaryNode) {
branchOptimizer((BinaryNode)node, label, state);
return;
}
if (node instanceof UnaryNode) {
branchOptimizer((UnaryNode)node, label, state);
return;
}
}
codegen.load(node, Type.BOOLEAN);
if (state) {
method.ifne(label);
} else {
method.ifeq(label);
}
}
示例6: branchOptimizer
import jdk.nashorn.internal.ir.TernaryNode; //导入依赖的package包/类
private void branchOptimizer(final Expression node, final Label label, final boolean state) {
if (!(node instanceof TernaryNode)) {
if (node instanceof BinaryNode) {
branchOptimizer((BinaryNode)node, label, state);
return;
}
if (node instanceof UnaryNode) {
branchOptimizer((UnaryNode)node, label, state);
return;
}
}
load(node);
method.convert(Type.BOOLEAN);
if (state) {
method.ifne(label);
} else {
method.ifeq(label);
}
}
示例7: leaveTernaryNode
import jdk.nashorn.internal.ir.TernaryNode; //导入依赖的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;
}
示例8: enterTernaryNode
import jdk.nashorn.internal.ir.TernaryNode; //导入依赖的package包/类
@Override
public boolean enterTernaryNode(final TernaryNode ternaryNode) {
curExpr = new ConditionalExpressionTreeImpl(ternaryNode,
translateExpr(ternaryNode.getTest()),
translateExpr(ternaryNode.getTrueExpression()),
translateExpr(ternaryNode.getFalseExpression()));
return false;
}
示例9: ConditionalExpressionTreeImpl
import jdk.nashorn.internal.ir.TernaryNode; //导入依赖的package包/类
ConditionalExpressionTreeImpl(final TernaryNode node,
final ExpressionTree condExpr, final ExpressionTree trueExpr,
final ExpressionTree falseExpr) {
super(node);
this.condExpr = condExpr;
this.trueExpr = trueExpr;
this.falseExpr = falseExpr;
}
示例10: enterTernaryNode
import jdk.nashorn.internal.ir.TernaryNode; //导入依赖的package包/类
@Override
public boolean enterTernaryNode(final TernaryNode ternaryNode) {
final Expression test = ternaryNode.getTest();
final Expression trueExpr = ternaryNode.getTrueExpression();
final Expression falseExpr = ternaryNode.getFalseExpression();
visitExpression(test);
final Map<Symbol, LvarType> testExitLvarTypes = localVariableTypes;
final LvarType trueType;
if(!isAlwaysFalse(test)) {
trueType = visitExpression(trueExpr);
} else {
trueType = null;
}
final Map<Symbol, LvarType> trueExitLvarTypes = localVariableTypes;
localVariableTypes = testExitLvarTypes;
final LvarType falseType;
if(!isAlwaysTrue(test)) {
falseType = visitExpression(falseExpr);
} else {
falseType = null;
}
final Map<Symbol, LvarType> falseExitLvarTypes = localVariableTypes;
localVariableTypes = getUnionTypes(trueExitLvarTypes, falseExitLvarTypes);
setConversion((JoinPredecessor)trueExpr, trueExitLvarTypes, localVariableTypes);
setConversion((JoinPredecessor)falseExpr, falseExitLvarTypes, localVariableTypes);
typeStack.push(trueType != null ? falseType != null ? widestLvarType(trueType, falseType) : trueType : assertNotNull(falseType));
return false;
}
示例11: leaveTernaryNode
import jdk.nashorn.internal.ir.TernaryNode; //导入依赖的package包/类
@Override
public Node leaveTernaryNode(final TernaryNode ternaryNode) {
final Expression trueExpr = ternaryNode.getTrueExpression();
final Expression falseExpr = ternaryNode.getFalseExpression();
ensureTypeNotUnknown(trueExpr);
ensureTypeNotUnknown(falseExpr);
final Type type = widestReturnType(trueExpr.getType(), falseExpr.getType());
return end(ensureSymbol(type, ternaryNode));
}
示例12: leaveTernaryNode
import jdk.nashorn.internal.ir.TernaryNode; //导入依赖的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();
}
return ternaryNode;
}