Example #1
0
  static <E extends ValueNode> E createNode(NodeFactory<E> factory, Object... constants) {
    ArgumentNode[] argumentNodes = arguments(factory.getExecutionSignature().size());

    List<Object> argumentList = new ArrayList<>();
    argumentList.addAll(Arrays.asList(constants));
    if (ChildrenNode.class.isAssignableFrom(factory.getNodeClass())
        || BuiltinNode.class.isAssignableFrom(factory.getNodeClass())) {
      argumentList.add(argumentNodes);
    } else {
      argumentList.addAll(Arrays.asList(argumentNodes));
    }
    return factory.createNode(argumentList.toArray(new Object[argumentList.size()]));
  }
    @Specialization
    public Object send(RubyBasicObject self, Object[] args, RubyProc block) {
      notDesignedForCompilation();

      final String name = args[0].toString();
      final Object[] sendArgs = Arrays.copyOfRange(args, 1, args.length);
      return self.send(name, block, sendArgs);
    }
    @Specialization
    public Object methodMissing(RubyBasicObject self, Object[] args, RubyProc block) {
      notDesignedForCompilation();

      CompilerDirectives.transferToInterpreter();

      final RubySymbol name = (RubySymbol) args[0];
      final Object[] sentArgs = Arrays.copyOfRange(args, 1, args.length);
      return methodMissing(self, name, sentArgs, block);
    }
    @Specialization
    public Object send(
        RubyBasicObject self,
        Object[] args,
        @SuppressWarnings("unused") UndefinedPlaceholder block) {
      notDesignedForCompilation();

      final String name = args[0].toString();
      final Object[] sendArgs = Arrays.copyOfRange(args, 1, args.length);
      return self.send(name, null, sendArgs);
    }
    @Specialization
    public Object methodMissing(
        RubyBasicObject self,
        Object[] args,
        @SuppressWarnings("unused") UndefinedPlaceholder block) {
      notDesignedForCompilation();

      CompilerDirectives.transferToInterpreter();

      final RubySymbol name = (RubySymbol) args[0];
      final Object[] sentArgs = Arrays.copyOfRange(args, 1, args.length);
      return methodMissing(self, name, sentArgs, null);
    }