/
constantscope.hpp
70 lines (48 loc) · 1.73 KB
/
constantscope.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
#ifndef RBX_BUILTIN_STATICSCOPE_HPP
#define RBX_BUILTIN_STATICSCOPE_HPP
#include "builtin/object.hpp"
namespace rubinius {
class Module;
class ConstantScope : public Object {
public:
const static object_type type = ConstantScopeType;
private:
Module* module_; // slot
// This is used like the ruby_class MRI variable. It lets
// manipulate this aspect of the class lexical enclosure
// without having to change module also.
Module* current_module_; // slot
ConstantScope* parent_; // slot
public:
/* accessors */
attr_accessor(module, Module);
attr_accessor(current_module, Module);
attr_accessor(parent, ConstantScope);
/* interface */
static void init(STATE);
static void bootstrap_methods(STATE);
static ConstantScope* create(STATE);
// Rubinius.primitive :constant_scope_of_sender
static ConstantScope* of_sender(STATE, CallFrame* calling_environment);
// Rubinius.primitive :constant_scope_const_set
Object* const_set(STATE, Symbol* name, Object* value);
// The module to use when adding and removing methods
Module* for_method_definition();
// Rubinius.primitive :constant_scope_cvar_defined
Object* cvar_defined(STATE, Symbol* name);
// Rubinius.primitive :constant_scope_cvar_get
Object* cvar_get(STATE, Symbol* name);
// Rubinius.primitive :constant_scope_cvar_set
Object* cvar_set(STATE, Symbol* name, Object* value);
// Rubinius.primitive :constant_scope_cvar_get_or_set
Object* cvar_get_or_set(STATE, Symbol* name, Object* value);
bool top_level_p(STATE) const {
return parent_->nil_p();
}
class Info : public TypeInfo {
public:
BASIC_TYPEINFO(TypeInfo)
};
};
}
#endif