use of com.oracle.truffle.api.interop.UnsupportedTypeException in project graal by oracle.
the class ContextAPITest method testExecute.
private static void testExecute(Context context) {
ContextAPITestLanguage.runinside = (env) -> new ProxyInteropObject() {
@Override
public boolean isExecutable() {
return true;
}
@Override
public Object execute(Object[] args) throws UnsupportedTypeException, ArityException, UnsupportedMessageException {
return 42;
}
};
Value executable = context.eval(ContextAPITestLanguage.ID, "");
assertEquals(42, executable.execute().asInt());
assertEquals(42, executable.execute(42).asInt());
executable.executeVoid();
executable.executeVoid(42);
}
use of com.oracle.truffle.api.interop.UnsupportedTypeException in project sulong by graalvm.
the class LLVMTruffleInvoke method doInvoke.
@ExplodeLoop
private Object doInvoke(VirtualFrame frame, TruffleObject value, String id, ContextReference<LLVMContext> contextReference, LLVMGetStackNode getStack) {
Object[] evaluatedArgs = new Object[args.length];
for (int i = 0; i < args.length; i++) {
evaluatedArgs[i] = prepareValuesForEscape[i].executeWithTarget(args[i].executeGeneric(frame));
}
try {
LLVMContext context = contextReference.get();
LLVMStack stack = getStack.executeWithTarget(getThreadingStack(context), Thread.currentThread());
Object rawValue;
try (StackPointer save = stack.newFrame()) {
rawValue = ForeignAccess.sendInvoke(foreignInvoke, value, id, evaluatedArgs);
}
return toLLVM.executeWithTarget(rawValue);
} catch (UnknownIdentifierException | UnsupportedMessageException | UnsupportedTypeException | ArityException e) {
CompilerDirectives.transferToInterpreter();
throw new IllegalStateException(e);
}
}
Aggregations