forked from rubinius/rubinius
/
stack_variables.hpp
74 lines (57 loc) · 1.31 KB
/
stack_variables.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
#ifndef RBX_SCOPE_VARIABLES_HPP
#define RBX_SCOPE_VARIABLES_HPP
#include "builtin/object.hpp"
namespace rubinius {
class VariableScope;
class StackVariables {
public: // Treat these like private!
VariableScope* on_heap_;
VariableScope* parent_;
Object* self_;
Object* block_;
Module* module_;
Object* locals_[];
public:
void initialize(Object* self, Object* block, Module* module, int locals) {
on_heap_ = 0;
parent_ = 0;
self_ = self;
block_ = block;
module_ = module;
for(int i = 0; i < locals; i++) {
locals_[i] = Qnil;
}
}
VariableScope* on_heap() {
return on_heap_;
}
VariableScope* parent() {
return parent_;
}
void set_parent(VariableScope* scope) {
parent_ = scope;
}
Object* self() {
return self_;
}
Object* block() {
return block_;
}
Module* module() {
return module_;
}
bool made_alias_p() {
return on_heap_ != 0;
}
Object* get_local(int which) {
return locals_[which];
}
void set_local(int which, Object* val) {
locals_[which] = val;
}
VariableScope* create_heap_alias(STATE, CallFrame* call_frame, bool full=true);
void flush_to_heap(STATE);
friend class GarbageCollector;
};
}
#endif