forked from rubinius/rubinius
-
Notifications
You must be signed in to change notification settings - Fork 0
/
arguments.hpp
116 lines (91 loc) · 2.09 KB
/
arguments.hpp
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#ifndef RBX_ARGUMENTS_HPP
#define RBX_ARGUMENTS_HPP
#include <stdint.h>
#include "builtin/array.hpp"
#include "builtin/tuple.hpp"
namespace rubinius {
class Array;
class GarbageCollector;
class Arguments {
Object* recv_;
Object* block_;
uint32_t total_;
Object** arguments_;
Tuple* argument_container_;
public:
Arguments(Object* recv, Object* block, uint32_t total, Object** buffer)
: recv_(recv)
, block_(block)
, total_(total)
, arguments_(buffer)
, argument_container_(0)
{}
Arguments(Object* recv, uint32_t total, Object** buffer)
: recv_(recv)
, block_(Qnil)
, total_(total)
, arguments_(buffer)
, argument_container_(0)
{}
Arguments(uint32_t total, Object** buffer)
: recv_(Qnil)
, block_(Qnil)
, total_(total)
, arguments_(buffer)
, argument_container_(0)
{}
Arguments()
: recv_(Qnil)
, block_(Qnil)
, total_(0)
, arguments_(0)
, argument_container_(0)
{}
Arguments(Array* ary)
: recv_(Qnil)
, block_(Qnil)
{
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];
}
Object** arguments() {
return arguments_;
}
Tuple* argument_container() {
return argument_container_;
}
void update_argument_container(Tuple* obj);
uint32_t total() {
return total_;
}
void use_array(Array* ary) {
use_tuple(ary->tuple(), ary->size());
}
void use_tuple(Tuple* tup, int size) {
total_ = size;
arguments_ = tup->field;
argument_container_ = tup;
}
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