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


Java Type.widest方法代码示例

本文整理汇总了Java中jdk.nashorn.internal.codegen.types.Type.widest方法的典型用法代码示例。如果您正苦于以下问题:Java Type.widest方法的具体用法?Java Type.widest怎么用?Java Type.widest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jdk.nashorn.internal.codegen.types.Type的用法示例。


在下文中一共展示了Type.widest方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: decideType

import jdk.nashorn.internal.codegen.types.Type; //导入方法依赖的package包/类
private static Type decideType(final Type lhsType, final Type rhsType) {
    // Compare this to getWidestOperationType() for ADD and ASSIGN_ADD cases. There's some similar logic, but these
    // are optimistic decisions, meaning that we don't have to treat boolean addition separately (as it'll become
    // int addition in the general case anyway), and that we also don't conservatively widen sums of ints to
    // longs, or sums of longs to doubles.
    if(isString(lhsType) || isString(rhsType)) {
        return Type.CHARSEQUENCE;
    }
    // NOTE: We don't have optimistic object-to-(int, long) conversions. Therefore, if any operand is an Object, we
    // bail out of optimism here and presume a conservative Object return value, as the object's ToPrimitive() can
    // end up returning either a number or a string, and their common supertype is Object, for better or worse.
    final Type widest = Type.widest(undefinedToNumber(booleanToInt(lhsType)), undefinedToNumber(booleanToInt(rhsType)));
    return widest.isObject() ? Type.OBJECT : widest;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:BinaryNode.java

示例3: firstTypeGuess

import jdk.nashorn.internal.codegen.types.Type; //导入方法依赖的package包/类
/**
 * The first type to try to use for this generated runtime node
 *
 * @return a type
 */
public Type firstTypeGuess() {
    Type widest = Type.UNKNOWN;
    for (final Type type : parameterTypes) {
        if (type.isObject()) {
            continue;
        }
        widest = Type.widest(type, widest);
    }
    widest = Type.widest(widest, firstTypeGuessForObject(request));

    return widest;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:RuntimeCallSite.java

示例4: 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

示例5: widest

import jdk.nashorn.internal.codegen.types.Type; //导入方法依赖的package包/类
/**
 * Get the widest element type of two arrays. This can be done faster in subclasses, but
 * this works for all ContinuousArrayDatas and for where more optimal checks haven't been
 * implemented.
 *
 * @param otherData another ContinuousArrayData
 * @return the widest boxed element type
 */
public ContinuousArrayData widest(final ContinuousArrayData otherData) {
    final Class<?> elementType = getElementType();
    return Type.widest(elementType, otherData.getElementType()) == elementType ? this : otherData;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:ContinuousArrayData.java


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