4 ivar_as_index :method_table => 1, :name => 3, :constants => 4, :encloser => 5, :superclass => 6
6 def method_table ; @method_table ; end
7 def constant_table ; @constants ; end
8 def encloser ; @encloser ; end
9 def name ; @name.to_s ; end
12 Ruby.primitive :allocate_module
13 raise PrimitiveFailure, "Module.allocate primitive failed"
16 # Ultra simple private
18 if cm = @method_table[name]
25 @method_table[name] = tup
30 # Ultra simple protected
32 if cm = @method_table[name]
39 @method_table[name] = tup
44 # Ultra simple module_function
45 def module_function(name)
46 if cm = @method_table[name]
50 meta = class << self; self; end
51 meta.method_table[name] = cm
56 def __find_method(namesym)
57 Ruby.primitive :find_method
58 raise PrimitiveFailure, "primitive failed"
61 def alias_method(new_name, current_name)
62 unless meth = @method_table[current_name]
63 mod = direct_superclass()
65 meth = mod.method_table[current_name]
66 mod = mod.direct_superclass
71 raise NoMethodError, "Unable to find method '#{current_name}' to alias to '#{new_name}'"
73 @method_table[new_name] = meth
74 Rubinius::VM.reset_method_cache(new_name)
77 # 'superclass' method defined in class.rb,
78 # because it is more complex than a mere accessor
79 def superclass=(other)
83 # This may be either an included Module or then
89 def append_features(mod)
90 im = IncludedModule.new(self)
94 def included(mod); end
97 mod.append_features(self)
102 def attr_reader(name)
103 sym = "@#{name}".to_sym
104 meth = AccessVarMethod.get_ivar(sym, name)
105 @method_table[name] = meth
109 def attr_writer(name)
110 sym = "@#{name}".to_sym
111 meth = AccessVarMethod.set_ivar(sym, "#{name}=")
112 @method_table["#{name}=".to_sym] = meth
116 def attr_accessor(name)