/
methodtable.hpp
98 lines (73 loc) · 2.5 KB
/
methodtable.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
#ifndef RBX_BUILTIN_METHODTABLE_HPP
#define RBX_BUILTIN_METHODTABLE_HPP
namespace rubinius {
class Tuple;
class Array;
class Executable;
class Symbol;
class MethodTableBucket : public Object {
public:
const static object_type type = MethodTableBucketType;
private:
Symbol* name_; // slot
Symbol* visibility_; // slot
Executable* method_; // slot
MethodTableBucket* next_; // slot
public:
attr_accessor(name, Symbol);
attr_accessor(visibility, Symbol);
attr_accessor(method, Executable);
attr_accessor(next, MethodTableBucket);
static MethodTableBucket* create(STATE, Symbol* name,
Executable* method, Symbol* visibility);
Object* append(STATE, MethodTableBucket *nxt);
bool private_p(STATE);
bool public_p(STATE);
bool protected_p(STATE);
bool undef_p(STATE);
class Info : public TypeInfo {
public:
BASIC_TYPEINFO(TypeInfo)
};
};
#define METHODTABLE_MIN_SIZE 16
class MethodTable : public Object {
public:
const static object_type type = MethodTableType;
private:
Tuple* values_; // slot
Integer* bins_; // slot
Integer* entries_; // slot
void redistribute(STATE, size_t size);
public:
/* accessors */
attr_accessor(values, Tuple);
attr_accessor(bins, Integer);
attr_accessor(entries, Integer);
/* interface */
static MethodTable* create(STATE, size_t sz = METHODTABLE_MIN_SIZE);
void setup(STATE, size_t sz);
// Rubinius.primitive :methodtable_allocate
static MethodTable* allocate(STATE, Object* self);
// Rubinius.primitive :methodtable_store
Object* store(STATE, GCToken gct, Symbol* name, Object* meth, Symbol* vis);
// Rubinius.primitive :methodtable_alias
Object* alias(STATE, GCToken gct, Symbol* name, Symbol* vis, Symbol* orig_name, Object* orig_method, Module* orig_mod);
// Rubinius.primitive :methodtable_duplicate
MethodTable* duplicate(STATE, GCToken gct);
MethodTableBucket* find_entry(STATE, Symbol* name);
MethodTableBucket* find_entry(Symbol* name);
// Rubinius.primitive :methodtable_lookup
MethodTableBucket* lookup(STATE, Symbol* name);
// Rubinius.primitive :methodtable_delete
Executable* remove(STATE, GCToken gct, Symbol* name);
// Rubinius.primitive :methodtable_has_name
Object* has_name(STATE, Symbol* name);
class Info : public TypeInfo {
public:
BASIC_TYPEINFO(TypeInfo)
virtual void show(STATE, Object* self, int level);
};
};
}
#endif