public static IRubyObject methodArgs(IRubyObject recv) {
Ruby runtime = recv.getRuntime();
RubyMethod rubyMethod = (RubyMethod)recv;
RubyArray argsArray = RubyArray.newArray(runtime);
DynamicMethod method = rubyMethod.getMethod().getRealMethod();
RubySymbol req = runtime.newSymbol("req");
RubySymbol opt = runtime.newSymbol("opt");
RubySymbol rest = runtime.newSymbol("rest");
RubySymbol block = runtime.newSymbol("block");
if (method instanceof MethodArgs2) {
return Helpers.parameterListToParameters(runtime, ((MethodArgs2) method).getParameterList(), true);
} else if (method instanceof MethodArgs) {
MethodArgs interpMethod = (MethodArgs)method;
ArgsNode args = interpMethod.getArgsNode();
ListNode requiredArgs = args.getPre();
for (int i = 0; requiredArgs != null && i < requiredArgs.size(); i++) {
Node argNode = requiredArgs.get(i);
if (argNode instanceof MultipleAsgn19Node) {
argsArray.append(RubyArray.newArray(runtime, req));
} else {
argsArray.append(RubyArray.newArray(runtime, req, getNameFrom(runtime, (INameNode)argNode)));
}
}
ListNode optArgs = args.getOptArgs();
for (int i = 0; optArgs != null && i < optArgs.size(); i++) {
argsArray.append(RubyArray.newArray(runtime, opt, getNameFrom(runtime, (INameNode) optArgs.get(i))));
}
if (args.getRestArg() >= 0) {
RestArgNode restArg = (RestArgNode) args.getRestArgNode();
if (restArg instanceof UnnamedRestArgNode) {
if (((UnnamedRestArgNode) restArg).isStar()) {
argsArray.append(RubyArray.newArray(runtime, rest));
}
} else {
argsArray.append(RubyArray.newArray(runtime, rest, getNameFrom(runtime, args.getRestArgNode())));
}
}
ListNode requiredArgsPost = args.getPost();
for (int i = 0; requiredArgsPost != null && i < requiredArgsPost.size(); i++) {
Node argNode = requiredArgsPost.get(i);
if (argNode instanceof MultipleAsgn19Node) {
argsArray.append(RubyArray.newArray(runtime, req));
} else {
argsArray.append(RubyArray.newArray(runtime, req, getNameFrom(runtime, (INameNode) requiredArgsPost.get(i))));
}
}
if (args.getBlock() != null) {
argsArray.append(RubyArray.newArray(runtime, block, getNameFrom(runtime, args.getBlock())));
}
} else if (method instanceof IRMethodArgs) {
for (String[] argParam: ((IRMethodArgs)method).getParameterList()) {
RubySymbol argType = runtime.newSymbol(argParam[0]);
if (argParam[1] == "") argsArray.append(RubyArray.newArray(runtime, argType));
else argsArray.append(RubyArray.newArray(runtime, argType, runtime.newSymbol(argParam[1])));
}
} else {
if (method.getArity() == Arity.OPTIONAL) {