rename (corrected) method def to instance methods in class
This commit is contained in:
@ -7,22 +7,21 @@ module Boot
|
||||
def initialize name , super_class_name = :Object
|
||||
super()
|
||||
# class methods
|
||||
@method_definitions = []
|
||||
@instance_methods = []
|
||||
@name = name.to_sym
|
||||
@super_class_name = super_class_name.to_sym
|
||||
@meta_class = MetaClass.new(self)
|
||||
end
|
||||
attr_reader :name , :method_definitions , :meta_class , :context , :super_class_name
|
||||
def add_method_definition method
|
||||
attr_reader :name , :instance_methods , :meta_class , :context , :super_class_name
|
||||
def add_instance_method method
|
||||
raise "not a method #{method.class} #{method.inspect}" unless method.is_a? Virtual::MethodDefinition
|
||||
raise "syserr " unless method.name.is_a? Symbol
|
||||
@method_definitions << method
|
||||
@instance_methods << method
|
||||
end
|
||||
|
||||
def get_method_definition fname
|
||||
def get_instance_method fname
|
||||
fname = fname.to_sym
|
||||
f = @method_definitions.detect{ |f| f.name == fname }
|
||||
names = @method_definitions.collect{|f| f.name }
|
||||
f = @instance_methods.detect{ |f| f.name == fname }
|
||||
f
|
||||
end
|
||||
|
||||
|
@ -34,7 +34,7 @@ module Boot
|
||||
puts "Runnning pass #{pass}"
|
||||
all = main.blocks
|
||||
@classes.each_value do |c|
|
||||
c.method_definitions.each {|f| all += f.blocks }
|
||||
c.instance_methods.each {|f| all += f.blocks }
|
||||
end
|
||||
all.each do |block|
|
||||
pass.new.run(block)
|
||||
@ -66,16 +66,16 @@ module Boot
|
||||
obj = get_or_create_class :Object
|
||||
[:index_of , :_get_instance_variable , :_set_instance_variable].each do |f|
|
||||
#puts "Boot Object::#{f}"
|
||||
obj.add_method_definition Boot::Object.send(f , @context)
|
||||
obj.add_instance_method Boot::Object.send(f , @context)
|
||||
end
|
||||
[:putstring,:putint,:fibo,:exit].each do |f|
|
||||
#puts "Boot Kernel::#{f}"
|
||||
obj.add_method_definition Salama::Kernel.send(f , @context)
|
||||
obj.add_instance_method Salama::Kernel.send(f , @context)
|
||||
end
|
||||
obj = get_or_create_class :String
|
||||
[:get , :set , :puts].each do |f|
|
||||
#puts "Boot String::#{f}"
|
||||
obj.add_method_definition Boot::String.send(f , @context)
|
||||
obj.add_instance_method Boot::String.send(f , @context)
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user