code: public static Expression toArgumentArray(List<Expression> argList, IRewriteResources resources) {
      List<Expression> normalArgs = new ArrayList<>();
      List<Expression> spreadArgs = new ArrayList<>();
      List<Expression> spreadPositions = new ArrayList<>();
  
      for (int i = 0; i < argList.size(); i++) {
        Expression arg = argList.get(i);
        if (arg instanceof SpreadExpression) {
          spreadArgs.add(((SpreadExpression) arg).getExpression());
          spreadPositions.add(new ConstantExpression(i));
        } else {
          normalArgs.add(arg);
        }
      }
  
      if (spreadArgs.isEmpty())
        return new ArrayExpression(ClassHelper.OBJECT_TYPE, argList);
  
      return new MethodCallExpression(
          new ClassExpression(resources.getAstNodeCache().SpockRuntime),
          new ConstantExpression(SpockRuntime.DESPREAD_LIST),
          new ArgumentListExpression(
              new ArrayExpression(ClassHelper.OBJECT_TYPE, normalArgs),
              new ArrayExpression(ClassHelper.OBJECT_TYPE, spreadArgs),
              new ArrayExpression(ClassHelper.int_TYPE, spreadPositions)
          ));
    }
docs: Turns an argument list obtained from AstUtil.getArguments() into an Object[] array
  suitable to be passed to InvokerHelper or SpockRuntime. The main challenge is
  to handle SpreadExpression's correctly.