register and boot consequences of typed method

This commit is contained in:
Torsten Ruger 2016-12-14 13:23:46 +02:00
parent 021fab31db
commit b3a9d8b1bc
3 changed files with 10 additions and 9 deletions

View File

@ -129,7 +129,7 @@ module Register
:super_class_name => :Word}, :super_class_name => :Word},
:Dictionary => {:keys => :List , :values => :List } , :Dictionary => {:keys => :List , :values => :List } ,
:TypedMethod => {:name => :Word, :source => :Object, :instructions => :Object, :binary => :Object, :TypedMethod => {:name => :Word, :source => :Object, :instructions => :Object, :binary => :Object,
:arguments => :List , :for_class => :Class, :locals => :List } , :arguments => :Type , :for_type => :Type, :locals => :Type } ,
:Value => {}, :Value => {},
:Variable => {:value_type => :Class, :name => :Word , :value => :Object} :Variable => {:value_type => :Class, :name => :Word , :value => :Object}
} }
@ -144,26 +144,27 @@ module Register
# very fiddly chicken 'n egg problem. Functions need to be in the right order, and in fact we # very fiddly chicken 'n egg problem. Functions need to be in the right order, and in fact we
# have to define some dummies, just for the others to compile # have to define some dummies, just for the others to compile
# TODO go through the virtual parfait layer and adjust function names to what they really are # TODO go through the virtual parfait layer and adjust function names to what they really are
@space.get_class_by_name(:Space).add_instance_method Builtin::Space.send(:main, nil) space = @space.get_class_by_name(:Space)
space.instance_type.add_instance_method Builtin::Space.send(:main, nil)
obj = @space.get_class_by_name(:Object) obj = @space.get_class_by_name(:Object)
[ :get_internal_word , :set_internal_word ].each do |f| [ :get_internal_word , :set_internal_word ].each do |f|
obj.add_instance_method Builtin::Object.send(f , nil) obj.instance_type.add_instance_method Builtin::Object.send(f , nil)
end end
obj = @space.get_class_by_name(:Kernel) obj = @space.get_class_by_name(:Kernel)
# create __init__ main first, __init__ calls it # create __init__ main first, __init__ calls it
[:exit , :__init__ ].each do |f| [:exit , :__init__ ].each do |f|
obj.add_instance_method Builtin::Kernel.send(f , nil) obj.instance_type.add_instance_method Builtin::Kernel.send(f , nil)
end end
obj = @space.get_class_by_name(:Word) obj = @space.get_class_by_name(:Word)
[:putstring , :get_internal_byte , :set_internal_byte ].each do |f| [:putstring , :get_internal_byte , :set_internal_byte ].each do |f|
obj.add_instance_method Builtin::Word.send(f , nil) obj.instance_type.add_instance_method Builtin::Word.send(f , nil)
end end
obj = @space.get_class_by_name(:Integer) obj = @space.get_class_by_name(:Integer)
[ :putint, :mod4, :div10].each do |f| #mod4 is just a forward declaration [ :putint, :mod4, :div10].each do |f| #mod4 is just a forward declaration
obj.add_instance_method Builtin::Integer.send(f , nil) obj.instance_type.add_instance_method Builtin::Integer.send(f , nil)
end end
end end
end end

View File

@ -22,7 +22,7 @@ module Register
compiler.add_code Register.get_slot( source , space_reg , message_ind , :message) compiler.add_code Register.get_slot( source , space_reg , message_ind , :message)
# And store the space as the new self (so the call can move it back as self) # And store the space as the new self (so the call can move it back as self)
compiler.add_code Register.set_slot( source, space_reg , :message , :receiver) compiler.add_code Register.set_slot( source, space_reg , :message , :receiver)
exit_label = Label.new("_exit_label" , "#{compiler.clazz.name}.#{compiler.method.name}" ) exit_label = Label.new("_exit_label" , "#{compiler.type.object_class.name}.#{compiler.method.name}" )
ret_tmp = compiler.use_reg(:Label) ret_tmp = compiler.use_reg(:Label)
compiler.add_code Register::LoadConstant.new(source, exit_label , ret_tmp) compiler.add_code Register::LoadConstant.new(source, exit_label , ret_tmp)
compiler.add_code Register.set_slot(source, ret_tmp , :message , :return_address) compiler.add_code Register.set_slot(source, ret_tmp , :message , :return_address)

View File

@ -15,9 +15,9 @@ module Register
end end
end end
def self.issue_call compiler , callee def self.issue_call( compiler , callee )
source = "_issue_call(#{callee.name})" source = "_issue_call(#{callee.name})"
return_label = Label.new("_return_label" , "#{compiler.clazz.name}.#{compiler.method.name}" ) return_label = Label.new("_return_label" , "#{compiler.type.object_class.name}.#{compiler.method.name}" )
ret_tmp = compiler.use_reg(:Label) ret_tmp = compiler.use_reg(:Label)
compiler.add_code Register::LoadConstant.new(source, return_label , ret_tmp) compiler.add_code Register::LoadConstant.new(source, return_label , ret_tmp)
compiler.add_code Register.set_slot(source, ret_tmp , :new_message , :return_address) compiler.add_code Register.set_slot(source, ret_tmp , :new_message , :return_address)