本文整理汇总了Java中jdk.nashorn.internal.ir.TernaryNode.getTest方法的典型用法代码示例。如果您正苦于以下问题:Java TernaryNode.getTest方法的具体用法?Java TernaryNode.getTest怎么用?Java TernaryNode.getTest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jdk.nashorn.internal.ir.TernaryNode
的用法示例。
在下文中一共展示了TernaryNode.getTest方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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();
final Symbol symbol = ternaryNode.getSymbol();
final Label falseLabel = new Label("ternary_false");
final Label exitLabel = new Label("ternary_exit");
Type widest = Type.widest(ternaryNode.getType(), Type.widest(trueExpr.getType(), falseExpr.getType()));
if (trueExpr.getType().isArray() || falseExpr.getType().isArray()) { //loadArray creates a Java array type on the stack, calls global allocate, which creates a native array type
widest = Type.OBJECT;
}
load(test, Type.BOOLEAN);
// we still keep the conversion here as the AccessSpecializer can have separated the types, e.g. var y = x ? x=55 : 17
// will left as (Object)x=55 : (Object)17 by Lower. Then the first term can be {I}x=55 of type int, which breaks the
// symmetry for the temporary slot for this TernaryNode. This is evidence that we assign types and explicit conversions
// too early, or Apply the AccessSpecializer too late. We are mostly probably looking for a separate type pass to
// do this property. Then we never need any conversions in CodeGenerator
method.ifeq(falseLabel);
load(trueExpr, widest);
method._goto(exitLabel);
method.label(falseLabel);
load(falseExpr, widest);
method.label(exitLabel);
method.store(symbol);
return false;
}
示例6: leaveTernaryNode
import jdk.nashorn.internal.ir.TernaryNode; //导入方法依赖的package包/类
@Override
public Node leaveTernaryNode(final TernaryNode ternaryNode) {
final Node test = ternaryNode.getTest();
if (test instanceof LiteralNode) {
return ((LiteralNode<?>)test).isTrue() ? ternaryNode.getTrueExpression() : ternaryNode.getFalseExpression();
}
return ternaryNode;
}