private PolyglotException handleInvalidArity(ArityException e) { int actual = e.getActualArity(); int expected = e.getExpectedArity(); return error(String.format("Expected %s number of arguments but got %s when creating a new instance of %s.", expected, actual, toString())); }
protected final Object executeShared(Object receiver, Object[] args) { Object[] guestArguments = toGuestValues.apply(polyglot.languageContext, args); try { return ForeignAccess.sendExecute(executeNode, (TruffleObject) receiver, guestArguments); } catch (UnsupportedTypeException e) { CompilerDirectives.transferToInterpreter(); throw invalidExecuteArgumentType(polyglot.languageContext, receiver, e); } catch (ArityException e) { CompilerDirectives.transferToInterpreter(); throw invalidExecuteArity(polyglot.languageContext, receiver, guestArguments, e.getExpectedArity(), e.getActualArity()); } catch (UnsupportedMessageException e) { CompilerDirectives.transferToInterpreter(); return polyglot.executeUnsupported(receiver); } }
protected final Object executeShared(PolyglotLanguageContext context, Object receiver, Object[] args) { Object[] guestArguments = toGuestValues.apply(context, args); try { return ForeignAccess.sendExecute(executeNode, (TruffleObject) receiver, guestArguments); } catch (UnsupportedTypeException e) { CompilerDirectives.transferToInterpreter(); throw invalidExecuteArgumentType(context, receiver, e); } catch (ArityException e) { CompilerDirectives.transferToInterpreter(); throw invalidExecuteArity(context, receiver, guestArguments, e.getExpectedArity(), e.getActualArity()); } catch (UnsupportedMessageException e) { CompilerDirectives.transferToInterpreter(); return executeUnsupported(context, receiver); } }
@Override protected Object executeImpl(PolyglotLanguageContext context, Object receiver, Object[] args) { Object[] instantiateArguments = toGuestValues.apply(context, (Object[]) args[ARGUMENT_OFFSET]); try { return toHostValue.execute(context, ForeignAccess.sendNew(newInstanceNode, (TruffleObject) receiver, instantiateArguments)); } catch (UnsupportedTypeException e) { CompilerDirectives.transferToInterpreter(); throw invalidInstantiateArgumentType(context, receiver, args); } catch (ArityException e) { CompilerDirectives.transferToInterpreter(); throw invalidInstantiateArity(context, receiver, args, e.getExpectedArity(), e.getActualArity()); } catch (UnsupportedMessageException e) { CompilerDirectives.transferToInterpreter(); return newInstanceUnsupported(context, receiver); } }
protected final Object executeShared(PolyglotLanguageContext context, Object receiver, String key, Object[] guestArguments) { TruffleObject truffleReceiver = (TruffleObject) receiver; try { return ForeignAccess.sendInvoke(invokeNode, truffleReceiver, key, guestArguments); } catch (UnsupportedMessageException e) { CompilerDirectives.transferToInterpreter(); invokeUnsupported(context, receiver, key); return null; } catch (UnknownIdentifierException e) { CompilerDirectives.transferToInterpreter(); throw invalidMemberKey(context, receiver, key); } catch (UnsupportedTypeException e) { CompilerDirectives.transferToInterpreter(); throw invalidExecuteArgumentType(context, receiver, e); } catch (ArityException e) { CompilerDirectives.transferToInterpreter(); throw invalidExecuteArity(context, receiver, guestArguments, e.getExpectedArity(), e.getActualArity()); } }
CompilerDirectives.transferToInterpreter(); if (executable) { throw JavaInteropErrors.invalidExecuteArity(languageContext, function, functionArgs, e.getExpectedArity(), e.getActualArity()); } else { throw JavaInteropErrors.invalidInstantiateArity(languageContext, function, functionArgs, e.getExpectedArity(), e.getActualArity());
CompilerDirectives.transferToInterpreter(); if (executable) { throw HostInteropErrors.invalidExecuteArity(languageContext, function, functionArgs, e.getExpectedArity(), e.getActualArity()); } else { throw HostInteropErrors.invalidInstantiateArity(languageContext, function, functionArgs, e.getExpectedArity(), e.getActualArity());
} catch (ArityException e) { CompilerDirectives.transferToInterpreter(); throw JavaInteropErrors.invalidExecuteArity(polyglotContext, receiver, arguments, e.getExpectedArity(), e.getActualArity()); } catch (UnsupportedMessageException e) { CompilerDirectives.transferToInterpreter();
} catch (ArityException e) { CompilerDirectives.transferToInterpreter(); throw HostInteropErrors.invalidExecuteArity(polyglotContext, receiver, arguments, e.getExpectedArity(), e.getActualArity()); } catch (UnsupportedMessageException e) { CompilerDirectives.transferToInterpreter();