use of com.oracle.truffle.api.library.ExportMessage in project graal by oracle.
the class EspressoInterop method fitsInByte.
@ExportMessage
static boolean fitsInByte(StaticObject receiver) {
receiver.checkNotForeign();
if (isNull(receiver)) {
return false;
}
Klass klass = receiver.getKlass();
if (isAtMostByte(klass)) {
return true;
}
Meta meta = klass.getMeta();
if (klass == meta.java_lang_Short) {
short content = meta.java_lang_Short_value.getShort(receiver);
return (byte) content == content;
}
if (klass == meta.java_lang_Integer) {
int content = meta.java_lang_Integer_value.getInt(receiver);
return (byte) content == content;
}
if (klass == meta.java_lang_Long) {
long content = meta.java_lang_Long_value.getLong(receiver);
return (byte) content == content;
}
if (klass == meta.java_lang_Float) {
float content = meta.java_lang_Float_value.getFloat(receiver);
return (byte) content == content && !isNegativeZero(content);
}
if (klass == meta.java_lang_Double) {
double content = meta.java_lang_Double_value.getDouble(receiver);
return (byte) content == content && !isNegativeZero(content);
}
return false;
}
use of com.oracle.truffle.api.library.ExportMessage in project graal by oracle.
the class EspressoInterop method isMemberInvocable.
@ExportMessage
static boolean isMemberInvocable(StaticObject receiver, String member, @Exclusive @Cached LookupVirtualMethodNode lookupMethod) {
receiver.checkNotForeign();
if (isNull(receiver)) {
return false;
}
ObjectKlass k = getInteropKlass(receiver);
return lookupMethod.isInvocable(k, member);
}
use of com.oracle.truffle.api.library.ExportMessage in project graal by oracle.
the class EspressoInterop method fitsInLong.
@ExportMessage
static boolean fitsInLong(StaticObject receiver) {
receiver.checkNotForeign();
if (isNull(receiver)) {
return false;
}
Klass klass = receiver.getKlass();
if (isAtMostLong(klass)) {
return true;
}
Meta meta = klass.getMeta();
if (klass == meta.java_lang_Float) {
float content = meta.java_lang_Float_value.getFloat(receiver);
return inSafeIntegerRange(content) && !isNegativeZero(content) && (long) content == content;
}
if (klass == meta.java_lang_Double) {
double content = meta.java_lang_Double_value.getDouble(receiver);
return inSafeIntegerRange(content) && !isNegativeZero(content) && (long) content == content;
}
return false;
}
use of com.oracle.truffle.api.library.ExportMessage in project graal by oracle.
the class EspressoInterop method writeMember.
@ExportMessage
static void writeMember(StaticObject receiver, String member, Object value, @Cached @Exclusive LookupInstanceFieldNode lookup, @Cached ToEspressoNode toEspresso, @Shared("error") @Cached BranchProfile error) throws UnsupportedTypeException, UnknownIdentifierException, UnsupportedMessageException {
receiver.checkNotForeign();
Field f = lookup.execute(getInteropKlass(receiver), member);
if (f != null) {
if (f.isFinalFlagSet()) {
error.enter();
throw UnsupportedMessageException.create();
}
f.set(receiver, toEspresso.execute(value, f.resolveTypeKlass()));
return;
}
error.enter();
throw UnknownIdentifierException.create(member);
}
use of com.oracle.truffle.api.library.ExportMessage in project graal by oracle.
the class EspressoInterop method fitsInInt.
@ExportMessage
static boolean fitsInInt(StaticObject receiver) {
receiver.checkNotForeign();
if (isNull(receiver)) {
return false;
}
Klass klass = receiver.getKlass();
if (isAtMostInt(klass)) {
return true;
}
Meta meta = klass.getMeta();
if (klass == meta.java_lang_Long) {
long content = meta.java_lang_Long_value.getLong(receiver);
return (int) content == content;
}
if (klass == meta.java_lang_Float) {
float content = meta.java_lang_Float_value.getFloat(receiver);
return inSafeIntegerRange(content) && !isNegativeZero(content) && (int) content == content;
}
if (klass == meta.java_lang_Double) {
double content = meta.java_lang_Double_value.getDouble(receiver);
return (int) content == content && !isNegativeZero(content);
}
return false;
}
Aggregations