public
Description: Rubinius, the Ruby VM
Homepage: http://rubini.us
Clone URL: git://github.com/evanphx/rubinius.git
rubinius / vm / builtin_class.hpp
d769c944 » evanphx 2008-03-25 Initial work on new C++ VM 1 #ifndef RBX_BUILTIN_CLASS_HPP
2 #define RBX_BUILTIN_CLASS_HPP
3
9eb47483 » evanphx 2008-04-20 Flesh out Task considerable... 4 #include "objects.hpp"
d769c944 » evanphx 2008-03-25 Initial work on new C++ VM 5
6 namespace rubinius {
7 class Module : public BuiltinType {
8 public:
feb91b43 » evanphx 2008-05-07 Tons of stuff (too much pro... 9 const static size_t fields = 5;
22ef7b8b » evanphx 2008-04-16 Pass 1 through adding Task ... 10 const static object_type type = ModuleType;
4c08cc4b » evanphx 2008-04-10 Add object cleanup post col... 11
feb91b43 » evanphx 2008-05-07 Tons of stuff (too much pro... 12 OBJECT __ivars__; // slot
13 LookupTable* method_table; // slot
14 SYMBOL name; // slot
15 LookupTable* constants; // slot
16 Module* superclass; // slot
d769c944 » evanphx 2008-03-25 Initial work on new C++ VM 17
9eb47483 » evanphx 2008-04-20 Flesh out Task considerable... 18 static Module* create(STATE);
d769c944 » evanphx 2008-03-25 Initial work on new C++ VM 19 void setup(STATE);
304caf31 » evanphx 2008-04-04 Bunch more work. 20 void setup(STATE, char* name, Module* under = NULL);
9eb47483 » evanphx 2008-04-20 Flesh out Task considerable... 21 void setup(STATE, SYMBOL name, Module* under = NULL);
304caf31 » evanphx 2008-04-04 Bunch more work. 22 void set_const(STATE, OBJECT sym, OBJECT val);
fceff3d8 » evanphx 2008-04-09 NativeFunction, Selector, S... 23 void set_const(STATE, char* name, OBJECT val);
9eb47483 » evanphx 2008-04-20 Flesh out Task considerable... 24 OBJECT get_const(STATE, SYMBOL sym);
25 OBJECT get_const(STATE, SYMBOL sym, bool* found);
304caf31 » evanphx 2008-04-04 Bunch more work. 26 OBJECT get_const(STATE, char* sym);
9eb47483 » evanphx 2008-04-20 Flesh out Task considerable... 27
28 void set_name(STATE, Module* under, SYMBOL name);
feb91b43 » evanphx 2008-05-07 Tons of stuff (too much pro... 29
30 class Info : public TypeInfo {
31 public:
32 Info(object_type type) : TypeInfo(type) { }
33 virtual void set_field(STATE, OBJECT target, size_t index, OBJECT val);
34 virtual OBJECT get_field(STATE, OBJECT target, size_t index);
35 };
d769c944 » evanphx 2008-03-25 Initial work on new C++ VM 36 };
37
38 class Class : public Module {
39 public:
feb91b43 » evanphx 2008-05-07 Tons of stuff (too much pro... 40 const static size_t fields = 9;
22ef7b8b » evanphx 2008-04-16 Pass 1 through adding Task ... 41 const static object_type type = ClassType;
42
feb91b43 » evanphx 2008-05-07 Tons of stuff (too much pro... 43 FIXNUM instance_fields; // slot
44 OBJECT has_ivars; // slot
45 OBJECT needs_cleanup; // slot
46 FIXNUM instance_type; // slot
d769c944 » evanphx 2008-03-25 Initial work on new C++ VM 47
fceff3d8 » evanphx 2008-04-09 NativeFunction, Selector, S... 48 void set_object_type(size_t type) {
22ef7b8b » evanphx 2008-04-16 Pass 1 through adding Task ... 49 instance_type = Object::i2n(type);
fceff3d8 » evanphx 2008-04-09 NativeFunction, Selector, S... 50 }
9eb47483 » evanphx 2008-04-20 Flesh out Task considerable... 51
52 static Class* create(STATE, Class* super);
feb91b43 » evanphx 2008-05-07 Tons of stuff (too much pro... 53
54 class Info : public TypeInfo {
55 public:
56 Info(object_type type) : TypeInfo(type) { }
57 virtual void set_field(STATE, OBJECT target, size_t index, OBJECT val);
58 virtual OBJECT get_field(STATE, OBJECT target, size_t index);
59 };
d769c944 » evanphx 2008-03-25 Initial work on new C++ VM 60 };
61
22ef7b8b » evanphx 2008-04-16 Pass 1 through adding Task ... 62 /* See t1 */
63 template <>
64 static bool kind_of<Module>(OBJECT obj) {
65 return obj->reference_p() &&
66 (obj->obj_type == Module::type ||
67 kind_of<Class>(obj));
68 }
69
d769c944 » evanphx 2008-03-25 Initial work on new C++ VM 70 class MetaClass : public Class {
71 public:
feb91b43 » evanphx 2008-05-07 Tons of stuff (too much pro... 72 const static size_t fields = 10;
22ef7b8b » evanphx 2008-04-16 Pass 1 through adding Task ... 73 const static object_type type = MetaclassType;
74
feb91b43 » evanphx 2008-05-07 Tons of stuff (too much pro... 75 OBJECT attached_instance; // slot
d769c944 » evanphx 2008-03-25 Initial work on new C++ VM 76
9eb47483 » evanphx 2008-04-20 Flesh out Task considerable... 77 static MetaClass* attach(STATE, OBJECT obj, OBJECT sup = NULL);
feb91b43 » evanphx 2008-05-07 Tons of stuff (too much pro... 78
79 class Info : public TypeInfo {
80 public:
81 Info(object_type type) : TypeInfo(type) { }
82 virtual void set_field(STATE, OBJECT target, size_t index, OBJECT val);
83 virtual OBJECT get_field(STATE, OBJECT target, size_t index);
84 };
d769c944 » evanphx 2008-03-25 Initial work on new C++ VM 85 };
86
87 class IncludedModule : public Module {
88 public:
feb91b43 » evanphx 2008-05-07 Tons of stuff (too much pro... 89 const static size_t field = 6;
90 const static object_type type = IncModType;
d769c944 » evanphx 2008-03-25 Initial work on new C++ VM 91
feb91b43 » evanphx 2008-05-07 Tons of stuff (too much pro... 92 OBJECT module; // slot
93
94 class Info : public TypeInfo {
95 public:
96 Info(object_type type) : TypeInfo(type) { }
97 virtual void set_field(STATE, OBJECT target, size_t index, OBJECT val);
98 virtual OBJECT get_field(STATE, OBJECT target, size_t index);
99 };
d769c944 » evanphx 2008-03-25 Initial work on new C++ VM 100 };
101
102 };
103
104 #endif