Object blockObject,
Object argumentsObjects,
Dispatch.DispatchAction dispatchAction) {
final RubyClass callerClass = ignoreVisibility ? null : box.box(RubyArguments.getSelf(frame.getArguments())).getMetaClass();
final RubyMethod method = lookup(callerClass, receiverObject, toJavaStringNode.executeJavaString(frame, methodName),
ignoreVisibility, dispatchAction);
if (method != null) {
if (dispatchAction == Dispatch.DispatchAction.CALL_METHOD) {
return callNode.call(
frame,
method.getCallTarget(),
RubyArguments.pack(
method,
method.getDeclarationFrame(),
receiverObject,
(RubyProc) blockObject,
CompilerDirectives.unsafeCast(argumentsObjects, Object[].class, true)));
} else if (dispatchAction == Dispatch.DispatchAction.RESPOND_TO_METHOD) {
return true;
} else {
throw new UnsupportedOperationException();
}
}
methodMissingProfile.enter();
final RubyMethod missingMethod = lookup(callerClass, receiverObject, "method_missing", true,
dispatchAction);
if (missingMethod == null) {
if (dispatchAction == Dispatch.DispatchAction.RESPOND_TO_METHOD) {
return false;
} else {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().runtimeError(
receiverObject.toString() + " didn't have a #method_missing", this));
}
}
if (dispatchAction == Dispatch.DispatchAction.CALL_METHOD) {
final Object[] argumentsObjectsArray = CompilerDirectives.unsafeCast(argumentsObjects, Object[].class, true);
final Object[] modifiedArgumentsObjects = new Object[1 + argumentsObjectsArray.length];
modifiedArgumentsObjects[0] = toSymbolNode.executeRubySymbol(frame, methodName);
System.arraycopy(argumentsObjectsArray, 0, modifiedArgumentsObjects, 1, argumentsObjectsArray.length);
return callNode.call(
frame,
missingMethod.getCallTarget(),
RubyArguments.pack(
missingMethod,
missingMethod.getDeclarationFrame(),
receiverObject,
(RubyProc) blockObject,
modifiedArgumentsObjects));
} else if (dispatchAction == Dispatch.DispatchAction.RESPOND_TO_METHOD) {
return false;