Search in sources :

Example 1 with BigIntegerConstant

use of com.oracle.truffle.llvm.parser.model.symbols.constants.integer.BigIntegerConstant in project sulong by graalvm.

the class ParseUtil method asLong.

public static long asLong(long[] args, int index, Metadata md) {
    final int typeIndex = index << 1;
    if (typeIndex >= args.length) {
        return DEFAULT_NUMBER;
    }
    final Type type = md.getTypeById(args[typeIndex]);
    if (type == MetaType.METADATA || VoidType.INSTANCE.equals(type)) {
        return DEFAULT_NUMBER;
    }
    final int valueIndex = typeIndex + 1;
    final SymbolImpl value = md.getScope().getSymbols().getOrNull((int) args[valueIndex]);
    if (value instanceof IntegerConstant) {
        return ((IntegerConstant) value).getValue();
    } else if (value instanceof BigIntegerConstant) {
        return ((BigIntegerConstant) value).getValue().longValue();
    } else if (value instanceof NullConstant || value instanceof UndefinedConstant) {
        return 0L;
    } else {
        return DEFAULT_NUMBER;
    }
}
Also used : SymbolImpl(com.oracle.truffle.llvm.parser.model.SymbolImpl) Type(com.oracle.truffle.llvm.runtime.types.Type) VoidType(com.oracle.truffle.llvm.runtime.types.VoidType) MetaType(com.oracle.truffle.llvm.runtime.types.MetaType) UndefinedConstant(com.oracle.truffle.llvm.parser.model.symbols.constants.UndefinedConstant) BigIntegerConstant(com.oracle.truffle.llvm.parser.model.symbols.constants.integer.BigIntegerConstant) NullConstant(com.oracle.truffle.llvm.parser.model.symbols.constants.NullConstant) IntegerConstant(com.oracle.truffle.llvm.parser.model.symbols.constants.integer.IntegerConstant) BigIntegerConstant(com.oracle.truffle.llvm.parser.model.symbols.constants.integer.BigIntegerConstant)

Example 2 with BigIntegerConstant

use of com.oracle.truffle.llvm.parser.model.symbols.constants.integer.BigIntegerConstant in project sulong by graalvm.

the class ParseUtil method isInteger.

public static boolean isInteger(long[] args, int index, Metadata md) {
    final int typeIndex = index << 1;
    final Type type = md.getTypeById(args[typeIndex]);
    if (type == MetaType.METADATA || VoidType.INSTANCE.equals(type)) {
        return false;
    }
    final int valueIndex = typeIndex + 1;
    final SymbolImpl value = md.getScope().getSymbols().getOrNull((int) args[valueIndex]);
    return value instanceof IntegerConstant || value instanceof BigIntegerConstant || value instanceof NullConstant || value instanceof UndefinedConstant;
}
Also used : SymbolImpl(com.oracle.truffle.llvm.parser.model.SymbolImpl) Type(com.oracle.truffle.llvm.runtime.types.Type) VoidType(com.oracle.truffle.llvm.runtime.types.VoidType) MetaType(com.oracle.truffle.llvm.runtime.types.MetaType) UndefinedConstant(com.oracle.truffle.llvm.parser.model.symbols.constants.UndefinedConstant) BigIntegerConstant(com.oracle.truffle.llvm.parser.model.symbols.constants.integer.BigIntegerConstant) NullConstant(com.oracle.truffle.llvm.parser.model.symbols.constants.NullConstant) IntegerConstant(com.oracle.truffle.llvm.parser.model.symbols.constants.integer.IntegerConstant) BigIntegerConstant(com.oracle.truffle.llvm.parser.model.symbols.constants.integer.BigIntegerConstant)

Aggregations

SymbolImpl (com.oracle.truffle.llvm.parser.model.SymbolImpl)2 NullConstant (com.oracle.truffle.llvm.parser.model.symbols.constants.NullConstant)2 UndefinedConstant (com.oracle.truffle.llvm.parser.model.symbols.constants.UndefinedConstant)2 BigIntegerConstant (com.oracle.truffle.llvm.parser.model.symbols.constants.integer.BigIntegerConstant)2 IntegerConstant (com.oracle.truffle.llvm.parser.model.symbols.constants.integer.IntegerConstant)2 MetaType (com.oracle.truffle.llvm.runtime.types.MetaType)2 Type (com.oracle.truffle.llvm.runtime.types.Type)2 VoidType (com.oracle.truffle.llvm.runtime.types.VoidType)2