evanphx / rubinius

Rubinius, the Ruby VM

This URL has Read+Write access

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
4 #include "prelude.hpp"
5 #include "object.hpp"
6
7 namespace rubinius {
8 class Module : public BuiltinType {
9 public:
10 const static size_t fields = 7;
22ef7b8b » evanphx 2008-04-16 Pass 1 through adding Task ... 11 const static object_type type = ModuleType;
4c08cc4b » evanphx 2008-04-10 Add object cleanup post col... 12
d769c944 » evanphx 2008-03-25 Initial work on new C++ VM 13 OBJECT instance_variables;
304caf31 » evanphx 2008-04-04 Bunch more work. 14 LookupTable* method_table;
d769c944 » evanphx 2008-03-25 Initial work on new C++ VM 15 OBJECT method_cache;
4c08cc4b » evanphx 2008-04-10 Add object cleanup post col... 16 SYMBOL name;
304caf31 » evanphx 2008-04-04 Bunch more work. 17 LookupTable* constants;
d769c944 » evanphx 2008-03-25 Initial work on new C++ VM 18 OBJECT encloser;
22ef7b8b » evanphx 2008-04-16 Pass 1 through adding Task ... 19 Class* superclass;
d769c944 » evanphx 2008-03-25 Initial work on new C++ VM 20
21 void setup(STATE);
304caf31 » evanphx 2008-04-04 Bunch more work. 22 void setup(STATE, char* name, Module* under = NULL);
23 void set_const(STATE, OBJECT sym, OBJECT val);
fceff3d8 » evanphx 2008-04-09 NativeFunction, Selector, S... 24 void set_const(STATE, char* name, OBJECT val);
304caf31 » evanphx 2008-04-04 Bunch more work. 25 OBJECT get_const(STATE, OBJECT sym);
26 OBJECT get_const(STATE, char* sym);
d769c944 » evanphx 2008-03-25 Initial work on new C++ VM 27 };
28
29 class Class : public Module {
30 public:
31 const static size_t fields = 11;
22ef7b8b » evanphx 2008-04-16 Pass 1 through adding Task ... 32 const static object_type type = ClassType;
33
d769c944 » evanphx 2008-03-25 Initial work on new C++ VM 34 OBJECT instance_fields;
35 OBJECT has_ivars;
36 OBJECT needs_cleanup;
22ef7b8b » evanphx 2008-04-16 Pass 1 through adding Task ... 37 OBJECT instance_type;
d769c944 » evanphx 2008-03-25 Initial work on new C++ VM 38
39 static bool is_a(OBJECT obj) {
40 return obj->obj_type == ClassType;
41 }
fceff3d8 » evanphx 2008-04-09 NativeFunction, Selector, S... 42
43 void set_object_type(size_t type) {
22ef7b8b » evanphx 2008-04-16 Pass 1 through adding Task ... 44 instance_type = Object::i2n(type);
fceff3d8 » evanphx 2008-04-09 NativeFunction, Selector, S... 45 }
d769c944 » evanphx 2008-03-25 Initial work on new C++ VM 46 };
47
22ef7b8b » evanphx 2008-04-16 Pass 1 through adding Task ... 48 /* See t1 */
49 template <>
50 static bool kind_of<Module>(OBJECT obj) {
51 return obj->reference_p() &&
52 (obj->obj_type == Module::type ||
53 kind_of<Class>(obj));
54 }
55
d769c944 » evanphx 2008-03-25 Initial work on new C++ VM 56 class MetaClass : public Class {
57 public:
58 const static size_t fields = 12;
22ef7b8b » evanphx 2008-04-16 Pass 1 through adding Task ... 59 const static object_type type = MetaclassType;
60
d769c944 » evanphx 2008-03-25 Initial work on new C++ VM 61 OBJECT attached_instance;
62
63 static bool is_a(OBJECT obj) {
64 return obj->obj_type == MetaclassType;
65 }
66
67 static OBJECT attach(STATE, OBJECT obj, OBJECT sup = NULL);
68 };
69
70 class IncludedModule : public Module {
71 public:
72
73 OBJECT module;
74 };
75
76 };
77
78 #endif