本文整理汇总了Java中jdk.nashorn.internal.ir.CaseNode.getTest方法的典型用法代码示例。如果您正苦于以下问题:Java CaseNode.getTest方法的具体用法?Java CaseNode.getTest怎么用?Java CaseNode.getTest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jdk.nashorn.internal.ir.CaseNode
的用法示例。
在下文中一共展示了CaseNode.getTest方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: enterCaseNode
import jdk.nashorn.internal.ir.CaseNode; //导入方法依赖的package包/类
@Override
public boolean enterCaseNode(final CaseNode caseNode) {
enterDefault(caseNode);
type("SwitchCase");
comma();
final Node test = caseNode.getTest();
property("test");
if (test != null) {
test.accept(this);
} else {
nullValue();
}
comma();
array("consequent", caseNode.getBody().getStatements());
return leave();
}
示例2: leaveSwitchNode
import jdk.nashorn.internal.ir.CaseNode; //导入方法依赖的package包/类
@Override
public Node leaveSwitchNode(final SwitchNode switchNode) {
final boolean allInteger = switchNode.getTag().getSymbolType().isInteger();
if (allInteger) {
return switchNode;
}
final Expression expression = switchNode.getExpression();
final List<CaseNode> cases = switchNode.getCases();
final List<CaseNode> newCases = new ArrayList<>();
for (final CaseNode caseNode : cases) {
final Expression test = caseNode.getTest();
newCases.add(test != null ? caseNode.setTest(convert(test, Type.OBJECT)) : caseNode);
}
return switchNode.
setExpression(lc, convert(expression, Type.OBJECT)).
setCases(lc, newCases);
}
示例3: isUniqueIntegerSwitchNode
import jdk.nashorn.internal.ir.CaseNode; //导入方法依赖的package包/类
private static boolean isUniqueIntegerSwitchNode(final SwitchNode switchNode) {
final Set<Integer> alreadySeen = new HashSet<>();
for (final CaseNode caseNode : switchNode.getCases()) {
final Expression test = caseNode.getTest();
if (test != null && !isUniqueIntegerLiteral(test, alreadySeen)) {
return false;
}
}
return true;
}
示例4: leaveCaseNode
import jdk.nashorn.internal.ir.CaseNode; //导入方法依赖的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;
}
示例5: leaveSwitchNode
import jdk.nashorn.internal.ir.CaseNode; //导入方法依赖的package包/类
@Override
public Node leaveSwitchNode(final SwitchNode switchNode) {
Type type = Type.UNKNOWN;
final List<CaseNode> newCases = new ArrayList<>();
for (final CaseNode caseNode : switchNode.getCases()) {
final Node test = caseNode.getTest();
CaseNode newCaseNode = caseNode;
if (test != null) {
if (test instanceof LiteralNode) {
//go down to integers if we can
final LiteralNode<?> lit = (LiteralNode<?>)test;
if (lit.isNumeric() && !(lit.getValue() instanceof Integer)) {
if (JSType.isRepresentableAsInt(lit.getNumber())) {
newCaseNode = caseNode.setTest((Expression)LiteralNode.newInstance(lit, lit.getInt32()).accept(this));
}
}
} else {
// the "all integer" case that CodeGenerator optimizes for currently assumes literals only
type = Type.OBJECT;
}
final Type newCaseType = newCaseNode.getTest().getType();
if (newCaseType.isBoolean()) {
type = Type.OBJECT; //booleans and integers aren't assignment compatible
} else {
type = Type.widest(type, newCaseType);
}
}
newCases.add(newCaseNode);
}
//only optimize for all integers
if (!type.isInteger()) {
type = Type.OBJECT;
}
switchNode.setTag(newInternal(lc.getCurrentFunction().uniqueName(SWITCH_TAG_PREFIX.symbolName()), type));
end(switchNode);
return switchNode.setCases(lc, newCases);
}