Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 95 lines (73 sloc) 1.707 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
#ifndef RBX_ARGUMENTS_HPP
#define RBX_ARGUMENTS_HPP

#include <stdint.h>
#include "builtin/array.hpp"
#include "builtin/tuple.hpp"

namespace rubinius {
  class Array;

  class Arguments {
    Object* recv_;
    Object* block_;

    uint32_t total_;
    Object** arguments_;

  public:
    Arguments(Object* recv, Object* block, uint32_t total, Object** buffer)
      : recv_(recv)
      , block_(block)
      , total_(total)
      , arguments_(buffer)
    {}

    Arguments(Object* recv, uint32_t total, Object** buffer)
      : recv_(recv)
      , block_(Qnil)
      , total_(total)
      , arguments_(buffer)
    {}

    Arguments(uint32_t total, Object** buffer)
      : recv_(0)
      , block_(Qnil)
      , total_(total)
      , arguments_(buffer)
    {}

    Arguments()
      : total_(0)
      , arguments_(0)
    {}

    Arguments(Array* ary) {
      use_array(ary);
    }

    Object* recv() {
      return recv_;
    }

    void set_recv(Object* val) {
      recv_ = val;
    }

    Object* block() {
      return block_;
    }

    void set_block(Object* val) {
      block_ = val;
    }

    Object* get_argument(uint32_t which) {
      return arguments_[which];
    }

    uint32_t total() {
      return total_;
    }

    void use_array(Array* ary) {
      total_ = ary->size();
      arguments_ = ary->tuple()->field + ary->start()->to_native();
    }

    void use_tuple(Tuple* tup, int size) {
      total_ = size;
      arguments_ = tup->field;
    }

    Array* as_array(STATE);
    void append(STATE, Array* ary);
    void prepend(STATE, Array* ary);

    void unshift(STATE, Object* val);
    void unshift2(STATE, Object* val, Object* val2);

    Object* shift(STATE);
  };
}

#endif
Something went wrong with that request. Please try again.