From b3a9d8b1bc17849b002df61bd378632a52b318ca Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Wed, 14 Dec 2016 13:23:46 +0200 Subject: [PATCH] register and boot consequences of typed method --- lib/register/boot.rb | 13 +++++++------ lib/register/builtin/kernel.rb | 2 +- lib/register/instructions/function_call.rb | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/register/boot.rb b/lib/register/boot.rb index f5f8a9bb..bba54b77 100644 --- a/lib/register/boot.rb +++ b/lib/register/boot.rb @@ -129,7 +129,7 @@ module Register :super_class_name => :Word}, :Dictionary => {:keys => :List , :values => :List } , :TypedMethod => {:name => :Word, :source => :Object, :instructions => :Object, :binary => :Object, - :arguments => :List , :for_class => :Class, :locals => :List } , + :arguments => :Type , :for_type => :Type, :locals => :Type } , :Value => {}, :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 # 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 - @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) [ :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 obj = @space.get_class_by_name(:Kernel) # create __init__ main first, __init__ calls it [: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 obj = @space.get_class_by_name(:Word) [: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 obj = @space.get_class_by_name(:Integer) [ :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 diff --git a/lib/register/builtin/kernel.rb b/lib/register/builtin/kernel.rb index 14c412a2..cfb43505 100644 --- a/lib/register/builtin/kernel.rb +++ b/lib/register/builtin/kernel.rb @@ -22,7 +22,7 @@ module Register 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) 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) compiler.add_code Register::LoadConstant.new(source, exit_label , ret_tmp) compiler.add_code Register.set_slot(source, ret_tmp , :message , :return_address) diff --git a/lib/register/instructions/function_call.rb b/lib/register/instructions/function_call.rb index d86d6c64..663fc10e 100644 --- a/lib/register/instructions/function_call.rb +++ b/lib/register/instructions/function_call.rb @@ -15,9 +15,9 @@ module Register end end - def self.issue_call compiler , callee + def self.issue_call( compiler , callee ) 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) compiler.add_code Register::LoadConstant.new(source, return_label , ret_tmp) compiler.add_code Register.set_slot(source, ret_tmp , :new_message , :return_address)