use of com.oracle.truffle.espresso.meta.Meta in project graal by oracle.
the class EspressoInterop method fitsInFloat.
@ExportMessage
static boolean fitsInFloat(StaticObject receiver) {
receiver.checkNotForeign();
if (isNull(receiver)) {
return false;
}
Klass klass = receiver.getKlass();
if (isAtMostFloat(klass)) {
return true;
}
Meta meta = klass.getMeta();
/*
* We might lose precision when we convert an int or a long to a float, however, we still
* perform the conversion. This is consistent with Truffle interop, see GR-22718 for more
* details.
*/
if (klass == meta.java_lang_Integer) {
int content = meta.java_lang_Integer_value.getInt(receiver);
float floatContent = content;
return (int) floatContent == content;
}
if (klass == meta.java_lang_Long) {
long content = meta.java_lang_Long_value.getLong(receiver);
float floatContent = content;
return (long) floatContent == content;
}
if (klass == meta.java_lang_Double) {
double content = meta.java_lang_Double_value.getDouble(receiver);
return !Double.isFinite(content) || (float) content == content;
}
return false;
}
use of com.oracle.truffle.espresso.meta.Meta in project graal by oracle.
the class EspressoInterop method isDate.
// endregion ### Members
// region ### Date/time conversions
@ExportMessage
static boolean isDate(StaticObject receiver) {
receiver.checkNotForeign();
if (isNull(receiver)) {
return false;
}
Meta meta = receiver.getKlass().getMeta();
return instanceOf(receiver, meta.java_time_LocalDate) || instanceOf(receiver, meta.java_time_LocalDateTime) || instanceOf(receiver, meta.java_time_Instant) || instanceOf(receiver, meta.java_time_ZonedDateTime) || instanceOf(receiver, meta.java_util_Date);
}
use of com.oracle.truffle.espresso.meta.Meta in project graal by oracle.
the class MapEntryInterop method writeArrayElement.
@ExportMessage
public static void writeArrayElement(StaticObject receiver, long index, Object value, @Cached.Exclusive @Cached InvokeEspressoNode invoke) throws InvalidArrayIndexException {
if (index != 1) {
throw InvalidArrayIndexException.create(index);
}
Meta meta = receiver.getKlass().getMeta();
Method m = doLookup(receiver, meta.java_util_Map_Entry, meta.java_util_Map_Entry_setValue);
try {
invoke.execute(m, receiver, new Object[] { value });
} catch (ArityException | UnsupportedTypeException e) {
throw EspressoError.shouldNotReachHere(e);
}
}
use of com.oracle.truffle.espresso.meta.Meta in project graal by oracle.
the class MapInterop method containsKey.
private static boolean containsKey(StaticObject receiver, Object key, InvokeEspressoNode invokeContains) {
Meta meta = receiver.getKlass().getMeta();
Method containsKey = getInteropKlass(receiver).itableLookup(meta.java_util_Map, meta.java_util_Map_containsKey.getITableIndex());
try {
return (boolean) invokeContains.execute(containsKey, receiver, new Object[] { key });
} catch (UnsupportedTypeException | ArityException e) {
throw EspressoError.shouldNotReachHere(e);
}
}
use of com.oracle.truffle.espresso.meta.Meta in project graal by oracle.
the class MapInterop method writeHashEntry.
@ExportMessage
public static void writeHashEntry(StaticObject receiver, Object key, Object value, @Cached.Exclusive @Cached InvokeEspressoNode invoke) throws UnknownKeyException {
Meta meta = receiver.getKlass().getMeta();
Method put = getInteropKlass(receiver).itableLookup(meta.java_util_Map, meta.java_util_Map_put.getITableIndex());
try {
invoke.execute(put, receiver, new Object[] { key, value });
} catch (UnsupportedTypeException e) {
throw UnknownKeyException.create(key);
} catch (ArityException e) {
throw EspressoError.shouldNotReachHere(e);
}
}
Aggregations