rename (corrected) method def to instance methods in class
This commit is contained in:
@ -40,7 +40,7 @@ module Ast
|
||||
if method.has_var(name)
|
||||
message.compile_get(method , name )
|
||||
else
|
||||
raise "Unimplemented"
|
||||
raise "Unimplemented #{self}"
|
||||
message.compile_send( method , name , Virtual::Self.new( Virtual::Mystery ) )
|
||||
end
|
||||
end
|
||||
|
@ -10,7 +10,7 @@ module Ast
|
||||
new_method = Virtual::MethodDefinition.new(name , args , r )
|
||||
new_method.class_name = r.is_a?(Boot::BootClass) ? r.name : method.class_name
|
||||
clazz = Virtual::Object.space.get_or_create_class(new_method.class_name)
|
||||
clazz.add_method_definition new_method
|
||||
clazz.add_instance_method new_method
|
||||
|
||||
#frame = frame.new_frame
|
||||
return_type = nil
|
||||
|
@ -29,7 +29,7 @@ module Ast
|
||||
raise "only functions for now #{expression.inspect}" unless expression.is_a? Ast::FunctionExpression
|
||||
#puts "compiling expression #{expression}"
|
||||
expression_value = expression.compile(method,message )
|
||||
clazz.add_method_definition(expression_value)
|
||||
clazz.add_instance_method(expression_value)
|
||||
#puts "compiled expression #{expression_value.inspect}"
|
||||
end
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -12,8 +12,8 @@ module Register
|
||||
next unless code.is_a? Virtual::FunctionCall
|
||||
to = RegisterReference.new(:r0)
|
||||
tmp = RegisterReference.new(:r5)
|
||||
move = RegisterMachine.instance.ldr( to , tmp , code.to.index )
|
||||
block.replace(code , [move] )
|
||||
# move = RegisterMachine.instance.ldr( to , tmp , code.to.index )
|
||||
# block.replace(code , [move] )
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -14,7 +14,7 @@ module Virtual
|
||||
raise "unimplemented"
|
||||
elsif( me.is_a? ObjectConstant )
|
||||
clazz = me.clazz
|
||||
method = clazz.get_method_definition code.name
|
||||
method = clazz.get_instance_method code.name
|
||||
raise "Method not implemented #{clazz.name}.#{code.name}" unless method
|
||||
call = FunctionCall.new( method )
|
||||
block.replace(code , [call] )
|
||||
|
Reference in New Issue
Block a user