Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 151 lines (118 sloc) 2.865 kb
68a3dd0 Refactor Message, centralize arguments
Evan Phoenix authored
1 #ifndef RBX_ARGUMENTS_HPP
2 #define RBX_ARGUMENTS_HPP
3
4 #include <stdint.h>
5 #include "builtin/array.hpp"
6 #include "builtin/tuple.hpp"
7
8 namespace rubinius {
9 class Array;
10
50a4b8c Update C++ Argument objects with the GC. Fixes NASTY GC bug.
Evan Phoenix authored
11 class GarbageCollector;
12
68a3dd0 Refactor Message, centralize arguments
Evan Phoenix authored
13 class Arguments {
45a2de9 Change call protocol to remove Dispatch&. Make IC thread-safe.
Evan Phoenix authored
14 Symbol* name_;
214fe7e Refactor Message out
Evan Phoenix authored
15 Object* recv_;
16 Object* block_;
17
10c90c8 @dbussink Use uint32_t for Arguments total
dbussink authored
18 uint32_t total_;
68a3dd0 Refactor Message, centralize arguments
Evan Phoenix authored
19 Object** arguments_;
50a4b8c Update C++ Argument objects with the GC. Fixes NASTY GC bug.
Evan Phoenix authored
20 Tuple* argument_container_;
68a3dd0 Refactor Message, centralize arguments
Evan Phoenix authored
21
22 public:
45a2de9 Change call protocol to remove Dispatch&. Make IC thread-safe.
Evan Phoenix authored
23 Arguments(Symbol* name, Object* recv, Object* block, uint32_t total, Object** buffer)
24 : name_(name)
25 , recv_(recv)
214fe7e Refactor Message out
Evan Phoenix authored
26 , block_(block)
27 , total_(total)
28 , arguments_(buffer)
50a4b8c Update C++ Argument objects with the GC. Fixes NASTY GC bug.
Evan Phoenix authored
29 , argument_container_(0)
214fe7e Refactor Message out
Evan Phoenix authored
30 {}
31
45a2de9 Change call protocol to remove Dispatch&. Make IC thread-safe.
Evan Phoenix authored
32 Arguments(Symbol* name, Object* recv, uint32_t total, Object** buffer)
33 : name_(name)
34 , recv_(recv)
832cbb3 @brixen Removed use of Qtrue|false|nil|undef from native code.
brixen authored
35 , block_(cNil)
214fe7e Refactor Message out
Evan Phoenix authored
36 , total_(total)
37 , arguments_(buffer)
50a4b8c Update C++ Argument objects with the GC. Fixes NASTY GC bug.
Evan Phoenix authored
38 , argument_container_(0)
214fe7e Refactor Message out
Evan Phoenix authored
39 {}
68a3dd0 Refactor Message, centralize arguments
Evan Phoenix authored
40
45a2de9 Change call protocol to remove Dispatch&. Make IC thread-safe.
Evan Phoenix authored
41 Arguments(Symbol* name, uint32_t total, Object** buffer)
42 : name_(name)
832cbb3 @brixen Removed use of Qtrue|false|nil|undef from native code.
brixen authored
43 , recv_(cNil)
44 , block_(cNil)
214fe7e Refactor Message out
Evan Phoenix authored
45 , total_(total)
68a3dd0 Refactor Message, centralize arguments
Evan Phoenix authored
46 , arguments_(buffer)
50a4b8c Update C++ Argument objects with the GC. Fixes NASTY GC bug.
Evan Phoenix authored
47 , argument_container_(0)
68a3dd0 Refactor Message, centralize arguments
Evan Phoenix authored
48 {}
49
45a2de9 Change call protocol to remove Dispatch&. Make IC thread-safe.
Evan Phoenix authored
50 Arguments(Symbol* name)
51 : name_(name)
832cbb3 @brixen Removed use of Qtrue|false|nil|undef from native code.
brixen authored
52 , recv_(cNil)
53 , block_(cNil)
f2c4373 Fill out missing initializers in Argument constructors
Evan Phoenix authored
54 , total_(0)
68a3dd0 Refactor Message, centralize arguments
Evan Phoenix authored
55 , arguments_(0)
50a4b8c Update C++ Argument objects with the GC. Fixes NASTY GC bug.
Evan Phoenix authored
56 , argument_container_(0)
68a3dd0 Refactor Message, centralize arguments
Evan Phoenix authored
57 {}
58
45a2de9 Change call protocol to remove Dispatch&. Make IC thread-safe.
Evan Phoenix authored
59 Arguments(Symbol* name, Array* ary)
60 : name_(name)
832cbb3 @brixen Removed use of Qtrue|false|nil|undef from native code.
brixen authored
61 , recv_(cNil)
62 , block_(cNil)
f2c4373 Fill out missing initializers in Argument constructors
Evan Phoenix authored
63 {
68a3dd0 Refactor Message, centralize arguments
Evan Phoenix authored
64 use_array(ary);
65 }
66
573964b @dbussink Define methods as const where appropriate
dbussink authored
67 Symbol* name() const {
45a2de9 Change call protocol to remove Dispatch&. Make IC thread-safe.
Evan Phoenix authored
68 return name_;
69 }
70
71 void set_name(Symbol* n) {
72 name_ = n;
73 }
74
573964b @dbussink Define methods as const where appropriate
dbussink authored
75 Object* recv() const {
214fe7e Refactor Message out
Evan Phoenix authored
76 return recv_;
77 }
78
499bbe6 @dbussink Fix on stack handling for Arguments
dbussink authored
79 Object*& recv_location() {
80 return recv_;
81 }
82
214fe7e Refactor Message out
Evan Phoenix authored
83 void set_recv(Object* val) {
84 recv_ = val;
85 }
86
573964b @dbussink Define methods as const where appropriate
dbussink authored
87 Object* block() const {
214fe7e Refactor Message out
Evan Phoenix authored
88 return block_;
89 }
90
499bbe6 @dbussink Fix on stack handling for Arguments
dbussink authored
91 Object*& block_location() {
92 return block_;
93 }
94
214fe7e Refactor Message out
Evan Phoenix authored
95 void set_block(Object* val) {
96 block_ = val;
97 }
98
573964b @dbussink Define methods as const where appropriate
dbussink authored
99 Object* get_argument(uint32_t which) const {
68a3dd0 Refactor Message, centralize arguments
Evan Phoenix authored
100 return arguments_[which];
101 }
102
573964b @dbussink Define methods as const where appropriate
dbussink authored
103 Object** arguments() const {
50a4b8c Update C++ Argument objects with the GC. Fixes NASTY GC bug.
Evan Phoenix authored
104 return arguments_;
105 }
106
499bbe6 @dbussink Fix on stack handling for Arguments
dbussink authored
107 Object**& arguments_location() {
108 return arguments_;
109 }
110
573964b @dbussink Define methods as const where appropriate
dbussink authored
111 Tuple* argument_container() const {
50a4b8c Update C++ Argument objects with the GC. Fixes NASTY GC bug.
Evan Phoenix authored
112 return argument_container_;
113 }
114
115 void update_argument_container(Tuple* obj);
116
573964b @dbussink Define methods as const where appropriate
dbussink authored
117 uint32_t total() const {
68a3dd0 Refactor Message, centralize arguments
Evan Phoenix authored
118 return total_;
119 }
120
6b9d370 @brixen Fixed block arg processing for { |(a,b)| }.
brixen authored
121 void use_argument(Object* obj) {
122 arguments_[0] = obj;
123 }
124
68a3dd0 Refactor Message, centralize arguments
Evan Phoenix authored
125 void use_array(Array* ary) {
4799401 @henrikhodne Fix Arguments::use_array when the array has been shifted.
henrikhodne authored
126 use_tuple(ary->tuple(), ary->size(), ary->offset());
68a3dd0 Refactor Message, centralize arguments
Evan Phoenix authored
127 }
128
4799401 @henrikhodne Fix Arguments::use_array when the array has been shifted.
henrikhodne authored
129 void use_tuple(Tuple* tup, uint32_t size, uint32_t offset) {
ba69282 Cleanup Arguments
Evan Phoenix authored
130 total_ = size;
4799401 @henrikhodne Fix Arguments::use_array when the array has been shifted.
henrikhodne authored
131 arguments_ = tup->field + offset;
50a4b8c Update C++ Argument objects with the GC. Fixes NASTY GC bug.
Evan Phoenix authored
132 argument_container_ = tup;
ba69282 Cleanup Arguments
Evan Phoenix authored
133 }
134
4799401 @henrikhodne Fix Arguments::use_array when the array has been shifted.
henrikhodne authored
135 void use_tuple(Tuple* tup, uint32_t size) {
136 use_tuple(tup, size, 0);
137 }
138
ba69282 Cleanup Arguments
Evan Phoenix authored
139 Array* as_array(STATE);
68a3dd0 Refactor Message, centralize arguments
Evan Phoenix authored
140 void append(STATE, Array* ary);
141 void prepend(STATE, Array* ary);
ba69282 Cleanup Arguments
Evan Phoenix authored
142
68a3dd0 Refactor Message, centralize arguments
Evan Phoenix authored
143 void unshift(STATE, Object* val);
144 void unshift2(STATE, Object* val, Object* val2);
ba69282 Cleanup Arguments
Evan Phoenix authored
145
68a3dd0 Refactor Message, centralize arguments
Evan Phoenix authored
146 Object* shift(STATE);
147 };
148 }
149
150 #endif
Something went wrong with that request. Please try again.