本文整理汇总了Java中jdk.nashorn.internal.codegen.types.Type.isInteger方法的典型用法代码示例。如果您正苦于以下问题:Java Type.isInteger方法的具体用法?Java Type.isInteger怎么用?Java Type.isInteger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jdk.nashorn.internal.codegen.types.Type
的用法示例。
在下文中一共展示了Type.isInteger方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertOptimisticReturnValue
import jdk.nashorn.internal.codegen.types.Type; //导入方法依赖的package包/类
void convertOptimisticReturnValue() {
if (isOptimistic) {
final Type optimisticType = getOptimisticCoercedType();
if(!optimisticType.isObject()) {
method.load(optimistic.getProgramPoint());
if(optimisticType.isInteger()) {
method.invoke(ENSURE_INT);
} else if(optimisticType.isLong()) {
method.invoke(ENSURE_LONG);
} else if(optimisticType.isNumber()) {
method.invoke(ENSURE_NUMBER);
} else {
throw new AssertionError(optimisticType);
}
}
}
}
示例2: getArrayType
import jdk.nashorn.internal.codegen.types.Type; //导入方法依赖的package包/类
private static ArrayType getArrayType(final Type elementType) {
if (elementType.isInteger()) {
return Type.INT_ARRAY;
} else if (elementType.isLong()) {
return Type.LONG_ARRAY;
} else if (elementType.isNumeric()) {
return Type.NUMBER_ARRAY;
} else {
return Type.OBJECT_ARRAY;
}
}
示例3: getArrayType
import jdk.nashorn.internal.codegen.types.Type; //导入方法依赖的package包/类
private static ArrayType getArrayType(final Type elementType) {
if (elementType.isInteger()) {
return Type.INT_ARRAY;
} else if (elementType.isNumeric()) {
return Type.NUMBER_ARRAY;
} else {
return Type.OBJECT_ARRAY;
}
}
示例4: convertOptimisticReturnValue
import jdk.nashorn.internal.codegen.types.Type; //导入方法依赖的package包/类
void convertOptimisticReturnValue() {
if (isOptimistic) {
final Type optimisticType = getOptimisticCoercedType();
if(!optimisticType.isObject()) {
method.load(optimistic.getProgramPoint());
if(optimisticType.isInteger()) {
method.invoke(ENSURE_INT);
} else if(optimisticType.isNumber()) {
method.invoke(ENSURE_NUMBER);
} else {
throw new AssertionError(optimisticType);
}
}
}
}
示例5: eval
import jdk.nashorn.internal.codegen.types.Type; //导入方法依赖的package包/类
@Override
protected LiteralNode<?> eval() {
final Node rhsNode = parent.getExpression();
if (!(rhsNode instanceof LiteralNode)) {
return null;
}
if (rhsNode instanceof ArrayLiteralNode) {
return null;
}
final LiteralNode<?> rhs = (LiteralNode<?>)rhsNode;
final Type rhsType = rhs.getType();
final boolean rhsInteger = rhsType.isInteger() || rhsType.isBoolean();
LiteralNode<?> literalNode;
switch (parent.tokenType()) {
case ADD:
if (rhsInteger) {
literalNode = LiteralNode.newInstance(token, finish, rhs.getInt32());
} else {
literalNode = LiteralNode.newInstance(token, finish, rhs.getNumber());
}
break;
case SUB:
if (rhsInteger && rhs.getInt32() != 0) { // @see test/script/basic/minuszero.js
literalNode = LiteralNode.newInstance(token, finish, -rhs.getInt32());
} else {
literalNode = LiteralNode.newInstance(token, finish, -rhs.getNumber());
}
break;
case NOT:
literalNode = LiteralNode.newInstance(token, finish, !rhs.getBoolean());
break;
case BIT_NOT:
literalNode = LiteralNode.newInstance(token, finish, ~rhs.getInt32());
break;
default:
return null;
}
return literalNode;
}
示例6: eval
import jdk.nashorn.internal.codegen.types.Type; //导入方法依赖的package包/类
@Override
protected LiteralNode<?> eval() {
final Node rhsNode = parent.getExpression();
if (!(rhsNode instanceof LiteralNode)) {
return null;
}
if (rhsNode instanceof ArrayLiteralNode) {
return null;
}
final LiteralNode<?> rhs = (LiteralNode<?>)rhsNode;
final Type rhsType = rhs.getType();
final boolean rhsInteger = rhsType.isInteger() || rhsType.isBoolean();
LiteralNode<?> literalNode;
switch (parent.tokenType()) {
case POS:
if (rhsInteger) {
literalNode = LiteralNode.newInstance(token, finish, rhs.getInt32());
} else if (rhsType.isLong()) {
literalNode = LiteralNode.newInstance(token, finish, rhs.getLong());
} else {
literalNode = LiteralNode.newInstance(token, finish, rhs.getNumber());
}
break;
case NEG:
if (rhsInteger && rhs.getInt32() != 0) { // @see test/script/basic/minuszero.js
literalNode = LiteralNode.newInstance(token, finish, -rhs.getInt32());
} else if (rhsType.isLong() && rhs.getLong() != 0L) {
literalNode = LiteralNode.newInstance(token, finish, -rhs.getLong());
} else {
literalNode = LiteralNode.newInstance(token, finish, -rhs.getNumber());
}
break;
case NOT:
literalNode = LiteralNode.newInstance(token, finish, !rhs.getBoolean());
break;
case BIT_NOT:
literalNode = LiteralNode.newInstance(token, finish, ~rhs.getInt32());
break;
default:
return null;
}
return literalNode;
}