-
Notifications
You must be signed in to change notification settings - Fork 609
/
arguments.hpp
142 lines (112 loc) · 2.66 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#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 {
Symbol* name_;
Object* recv_;
Object* block_;
uint32_t total_;
Object** arguments_;
Tuple* argument_container_;
public:
Arguments(Symbol* name, Object* recv, Object* block, uint32_t total, Object** buffer)
: name_(name)
, recv_(recv)
, block_(block)
, total_(total)
, arguments_(buffer)
, argument_container_(0)
{}
Arguments(Symbol* name, Object* recv, uint32_t total, Object** buffer)
: name_(name)
, recv_(recv)
, block_(cNil)
, total_(total)
, arguments_(buffer)
, argument_container_(0)
{}
Arguments(Symbol* name, uint32_t total, Object** buffer)
: name_(name)
, recv_(cNil)
, block_(cNil)
, total_(total)
, arguments_(buffer)
, argument_container_(0)
{}
Arguments(Symbol* name)
: name_(name)
, recv_(cNil)
, block_(cNil)
, total_(0)
, arguments_(0)
, argument_container_(0)
{}
Arguments(Symbol* name, Array* ary)
: name_(name)
, recv_(cNil)
, block_(cNil)
{
use_array(ary);
}
Symbol* name() {
return name_;
}
void set_name(Symbol* n) {
name_ = n;
}
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_argument(Object* obj) {
arguments_[0] = obj;
}
void use_array(Array* ary) {
use_tuple(ary->tuple(), ary->size(), ary->offset());
}
void use_tuple(Tuple* tup, uint32_t size, uint32_t offset) {
total_ = size;
arguments_ = tup->field + offset;
argument_container_ = tup;
}
void use_tuple(Tuple* tup, uint32_t size) {
use_tuple(tup, size, 0);
}
Tuple*& argument_container_location() {
return argument_container_;
}
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