当前位置: 首页>>代码示例>>Java>>正文


Java Type.isBoolean方法代码示例

本文整理汇总了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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:LiteralNode.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:MethodEmitter.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:MethodEmitter.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:46,代码来源:FoldConstants.java

示例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();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:CodeGenerator.java

示例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();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:CodeGenerator.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:50,代码来源:FoldConstants.java


注:本文中的jdk.nashorn.internal.codegen.types.Type.isBoolean方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。