protected IRubyObject[] assignArrayToBlockArgs(Ruby ruby, IRubyObject value) {
   switch (argumentType) {
     case ZERO_ARGS:
       return new IRubyObject[] {};
     case MULTIPLE_ASSIGNMENT:
     case SINGLE_RESTARG:
       return ArgsUtil.convertToJavaArray(value);
     default:
       {
         return new IRubyObject[] {prepareArrayArgsForCall(ruby, value)};
       }
   }
 }
示例#2
0
  public static IRubyObject[] setupArgs(
      Ruby runtime, ThreadContext context, Node node, IRubyObject self, Block aBlock) {
    if (node == null) return IRubyObject.NULL_ARRAY;

    if (node instanceof ArrayNode) {
      ArrayNode argsArrayNode = (ArrayNode) node;
      String savedFile = context.getFile();
      int savedLine = context.getLine();
      int size = argsArrayNode.size();
      IRubyObject[] argsArray = new IRubyObject[size];

      for (int i = 0; i < size; i++) {
        argsArray[i] = argsArrayNode.get(i).interpret(runtime, context, self, aBlock);
      }

      context.setFileAndLine(savedFile, savedLine);

      return argsArray;
    }

    return ArgsUtil.convertToJavaArray(node.interpret(runtime, context, self, aBlock));
  }