use of com.oracle.truffle.api.library.ExportMessage 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.api.library.ExportMessage 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);
}
}
use of com.oracle.truffle.api.library.ExportMessage in project graal by oracle.
the class MapInterop method readHashValue.
@ExportMessage
public static Object readHashValue(StaticObject receiver, Object key, @Cached.Exclusive @Cached InvokeEspressoNode invoke, @Cached.Shared("contains") @Cached InvokeEspressoNode contains) throws UnsupportedMessageException, UnknownKeyException {
if (!isHashEntryReadable(receiver, key, contains)) {
throw UnsupportedMessageException.create();
}
Meta meta = receiver.getKlass().getMeta();
Method get = getInteropKlass(receiver).itableLookup(meta.java_util_Map, meta.java_util_Map_get.getITableIndex());
try {
return invoke.execute(get, receiver, new Object[] { key });
} catch (UnsupportedTypeException e) {
throw UnknownKeyException.create(key);
} catch (ArityException e) {
throw EspressoError.shouldNotReachHere(e);
}
}
use of com.oracle.truffle.api.library.ExportMessage in project graal by oracle.
the class MapInterop method getHashSize.
@ExportMessage
public static long getHashSize(StaticObject receiver, @Cached.Exclusive @Cached InvokeEspressoNode invoke) throws UnsupportedMessageException {
if (!hasHashEntries(receiver)) {
throw UnsupportedMessageException.create();
}
Meta meta = receiver.getKlass().getMeta();
Method size = getInteropKlass(receiver).itableLookup(meta.java_util_Map, meta.java_util_Map_size.getITableIndex());
try {
return (int) invoke.execute(size, receiver, EMPTY_ARRAY);
} catch (UnsupportedTypeException | ArityException e) {
throw EspressoError.shouldNotReachHere(e);
}
}
use of com.oracle.truffle.api.library.ExportMessage in project graal by oracle.
the class LLVMVaListStorage method invokeMember.
@ExportMessage
public Object invokeMember(String member, Object[] arguments, @Cached.Shared("escapeNode") @Cached LLVMPointerDataEscapeNode pointerEscapeNode) throws ArityException, UnknownIdentifierException, UnsupportedTypeException {
if (GET_MEMBER.equals(member)) {
if (arguments.length == 2) {
if (!(arguments[0] instanceof Integer)) {
CompilerDirectives.transferToInterpreterAndInvalidate();
throw UnsupportedTypeException.create(new Object[] { arguments[0] }, "Index argument must be an integer");
}
int i = (Integer) arguments[0];
if (i >= realArguments.length - numberOfExplicitArguments) {
CompilerDirectives.transferToInterpreterAndInvalidate();
throw new ArrayIndexOutOfBoundsException(i);
}
Object arg = realArguments[numberOfExplicitArguments + i];
if (!(arguments[1] instanceof LLVMInteropType.Structured)) {
return arg;
}
LLVMInteropType.Structured type = (LLVMInteropType.Structured) arguments[1];
if (!LLVMPointer.isInstance(arg)) {
// arg's types
return arg;
}
LLVMPointer ptrArg = LLVMPointer.cast(arg);
return pointerEscapeNode.executeWithType(ptrArg, type);
} else {
throw ArityException.create(2, 2, arguments.length);
}
}
throw UnknownIdentifierException.create(member);
}
Aggregations