Java Code Examples for jdk.nashorn.internal.codegen.types.Type#INT

The following examples show how to use jdk.nashorn.internal.codegen.types.Type#INT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CodeGeneratorLexicalContext.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
static Type getTypeForSlotDescriptor(final char typeDesc) {
    // Recognizing both lowercase and uppercase as we're using both to signify symbol boundaries; see
    // MethodEmitter.markSymbolBoundariesInLvarTypesDescriptor().
    switch (typeDesc) {
        case 'I':
        case 'i':
            return Type.INT;
        case 'J':
        case 'j':
            return Type.LONG;
        case 'D':
        case 'd':
            return Type.NUMBER;
        case 'A':
        case 'a':
            return Type.OBJECT;
        case 'U':
        case 'u':
            return Type.UNKNOWN;
        default:
            throw new AssertionError();
    }
}
 
Example 2
Source File: LiteralNode.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 3
Source File: UnaryNode.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Type getMostOptimisticType() {
    if (CAN_OVERFLOW.contains(tokenType())) {
        return Type.INT;
    }
    return getMostPessimisticType();
}
 
Example 4
Source File: MethodEmitter.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Pop a type from the existing stack, ensuring that it is an integer type
 * (integer or long). Boolean type is popped as int type.
 *
 * @return the type
 */
private BitwiseType popBitwise() {
    final Type type = popType();
    if(type == Type.BOOLEAN) {
        return Type.INT;
    }
    return (BitwiseType)type;
}
 
Example 5
Source File: MethodEmitter.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Pop a type from the existing stack, ensuring that it is an integer type
 * (integer or long). Boolean type is popped as int type.
 *
 * @return the type
 */
private BitwiseType popBitwise() {
    final Type type = popType();
    if(type == Type.BOOLEAN) {
        return Type.INT;
    }
    return (BitwiseType)type;
}
 
Example 6
Source File: BinaryNode.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the widest possible operand type for this operation.
 *
 * @return Type
 */
public Type getWidestOperandType() {
    switch (tokenType()) {
    case SHR:
    case ASSIGN_SHR:
        return Type.INT;
    case INSTANCEOF:
        return Type.OBJECT;
    default:
        if (isComparison()) {
            return Type.OBJECT;
        }
        return getWidestOperationType();
    }
}
 
Example 7
Source File: MethodEmitter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Pop a type from the existing stack, ensuring that it is an integer type
 * (integer or long). Boolean type is popped as int type.
 *
 * @return the type
 */
private BitwiseType popBitwise() {
    final Type type = popType();
    if(type == Type.BOOLEAN) {
        return Type.INT;
    }
    return (BitwiseType)type;
}
 
Example 8
Source File: LiteralNode.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private boolean presetsMatchElementType() {
    if (elementType == Type.INT) {
        return presets instanceof int[];
    } else if (elementType == Type.NUMBER) {
        return presets instanceof double[];
    } else {
        return presets instanceof Object[];
    }
}
 
Example 9
Source File: LiteralNode.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private boolean presetsMatchElementType() {
    if (elementType == Type.INT) {
        return presets instanceof int[];
    } else if (elementType == Type.NUMBER) {
        return presets instanceof double[];
    } else {
        return presets instanceof Object[];
    }
}
 
Example 10
Source File: BinaryNode.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Type getMostOptimisticType() {
    final TokenType tokenType = tokenType();
    if(tokenType == TokenType.ADD || tokenType == TokenType.ASSIGN_ADD) {
        return OPTIMISTIC_UNDECIDED_TYPE;
    } else if (CAN_OVERFLOW.contains(tokenType)) {
        return Type.INT;
    }
    return getMostPessimisticType();
}
 
Example 11
Source File: BinaryNode.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private static Type booleanToInt(final Type type) {
    return type == Type.BOOLEAN ? Type.INT : type;
}
 
Example 12
Source File: GetSplitState.java    From jdk8u_nashorn with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Type getType() {
    return Type.INT;
}
 
Example 13
Source File: BaseNode.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Type getMostOptimisticType() {
    return Type.INT;
}
 
Example 14
Source File: BaseNode.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Type getMostOptimisticType() {
    return Type.INT;
}
 
Example 15
Source File: IdentNode.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Type getMostOptimisticType() {
    return Type.INT;
}
 
Example 16
Source File: BinaryNode.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private static Type booleanToInt(final Type type) {
    return type == Type.BOOLEAN ? Type.INT : type;
}
 
Example 17
Source File: BaseNode.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Type getMostOptimisticType() {
    return Type.INT;
}
 
Example 18
Source File: IdentNode.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Type getMostOptimisticType() {
    return Type.INT;
}
 
Example 19
Source File: Attr.java    From openjdk-8-source with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Return the type that arithmetic ops should use. Until we have implemented better type
 * analysis (range based) or overflow checks that are fast enough for int arithmetic,
 * this is the number type
 * @return the arithetic type
 */
private static Type arithType() {
    return Compiler.shouldUseIntegerArithmetic() ? Type.INT : Type.NUMBER;
}
 
Example 20
Source File: Attr.java    From openjdk-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Return the type that arithmetic ops should use. Until we have implemented better type
 * analysis (range based) or overflow checks that are fast enough for int arithmetic,
 * this is the number type
 * @return the arithetic type
 */
private static Type arithType() {
    return Compiler.shouldUseIntegerArithmetic() ? Type.INT : Type.NUMBER;
}