本文整理汇总了Java中jdk.nashorn.internal.codegen.types.Type.isBoolean方法的典型用法代码示例。如果您正苦于以下问题:Java Type.isBoolean方法的具体用法?Java Type.isBoolean怎么用?Java Type.isBoolean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jdk.nashorn.internal.codegen.types.Type
的用法示例。
在下文中一共展示了Type.isBoolean方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeElementType
import jdk.nashorn.internal.codegen.types.Type; //导入方法依赖的package包/类
private static Type computeElementType(final Expression[] value) {
Type widestElementType = Type.INT;
for (final Expression elem : value) {
if (elem == null) {
widestElementType = widestElementType.widest(Type.OBJECT); //no way to represent undefined as number
break;
}
final Type type = elem.getType().isUnknown() ? Type.OBJECT : elem.getType();
if (type.isBoolean()) {
//TODO fix this with explicit boolean types
widestElementType = widestElementType.widest(Type.OBJECT);
break;
}
widestElementType = widestElementType.widest(type);
if (widestElementType.isObject()) {
break;
}
}
return widestElementType;
}
示例2: dynamicGet
import jdk.nashorn.internal.codegen.types.Type; //导入方法依赖的package包/类
/**
* Generate dynamic getter. Pop scope from stack. Push result
*
* @param valueType type of the value to set
* @param name name of property
* @param flags call site flags
* @param isMethod should it prefer retrieving methods
* @param isIndex is this an index operation?
* @return the method emitter
*/
MethodEmitter dynamicGet(final Type valueType, final String name, final int flags, final boolean isMethod, final boolean isIndex) {
debug("dynamic_get", name, valueType, getProgramPoint(flags));
Type type = valueType;
if (type.isObject() || type.isBoolean()) {
type = Type.OBJECT; //promote e.g strings to object generic setter
}
popType(Type.SCOPE);
method.visitInvokeDynamicInsn(dynGetOperation(isMethod, isIndex) + ':' + NameCodec.encode(name),
Type.getMethodDescriptor(type, Type.OBJECT), LINKERBOOTSTRAP, flags);
pushType(type);
convert(valueType); //most probably a nop
return this;
}
示例3: dynamicGet
import jdk.nashorn.internal.codegen.types.Type; //导入方法依赖的package包/类
/**
* Generate dynamic getter. Pop scope from stack. Push result
*
* @param valueType type of the value to set
* @param name name of property
* @param flags call site flags
* @param isMethod should it prefer retrieving methods
* @param isIndex is this an index operation?
* @return the method emitter
*/
MethodEmitter dynamicGet(final Type valueType, final String name, final int flags, final boolean isMethod, final boolean isIndex) {
if (name.length() > LARGE_STRING_THRESHOLD) { // use getIndex for extremely long names
return load(name).dynamicGetIndex(valueType, flags, isMethod);
}
debug("dynamic_get", name, valueType, getProgramPoint(flags));
Type type = valueType;
if (type.isObject() || type.isBoolean()) {
type = Type.OBJECT; //promote e.g strings to object generic setter
}
popType(Type.SCOPE);
method.visitInvokeDynamicInsn(NameCodec.encode(name),
Type.getMethodDescriptor(type, Type.OBJECT), LINKERBOOTSTRAP, flags | dynGetOperation(isMethod, isIndex));
pushType(type);
convert(valueType); //most probably a nop
return this;
}
示例4: 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;
}
示例5: noToPrimitiveConversion
import jdk.nashorn.internal.codegen.types.Type; //导入方法依赖的package包/类
private static boolean noToPrimitiveConversion(final Type source, final Type target) {
// Object to boolean conversion does not cause ToPrimitive call
return source.isJSPrimitive() || !target.isJSPrimitive() || target.isBoolean();
}
示例6: comparisonOperandsArePrimitive
import jdk.nashorn.internal.codegen.types.Type; //导入方法依赖的package包/类
private static boolean comparisonOperandsArePrimitive(final BinaryNode binaryNode) {
final Type widest = Type.widest(binaryNode.lhs().getType(), binaryNode.rhs().getType());
return widest.isNumeric() || widest.isBoolean();
}
示例7: 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;
}