diff --git a/lib/register/collector.rb b/lib/register/collector.rb index 88bfafa1..a453eb20 100644 --- a/lib/register/collector.rb +++ b/lib/register/collector.rb @@ -6,6 +6,7 @@ module Register # init= Parfait::Space.object_space.get_class_by_name("Kernel").get_instance_method "__init__" self.objects.clear keep Parfait::Space.object_space , 0 + constants.each {|o| keep(o,0)} end def keep object , depth @@ -14,12 +15,6 @@ module Register #puts "ADD #{object.first.class}, #{object.last.class}" if object.is_a? Array return unless self.add_object object return unless object.respond_to? :has_layout? - if( object.is_a? Parfait::Method) - object.source.constants.each{|c| - #puts "keeping constant #{c.class}:#{c.object_id}" - keep(c , depth + 1) - } - end layout = object.get_layout keep(layout , depth + 1) return if object.is_a? Symbol diff --git a/lib/register/machine.rb b/lib/register/machine.rb index dd761d2e..596809de 100644 --- a/lib/register/machine.rb +++ b/lib/register/machine.rb @@ -17,7 +17,9 @@ module Register @parser = Parser::Salama.new @objects = {} @booted = false + @constants = [] end + attr_reader :constants attr_reader :space , :class_mappings , :init , :objects , :booted diff --git a/lib/register/method_source.rb b/lib/register/method_source.rb index 4e7459dd..4fb68222 100644 --- a/lib/register/method_source.rb +++ b/lib/register/method_source.rb @@ -55,9 +55,7 @@ module Register #load the return address into pc, affecting return. (other cpus have commands for this, but not arm) add_code FunctionReturn.new( self , Register.new_message_reg , Register.resolve_index(:message , :return_address) ) @current = enter - @constants = [] end - attr_reader :constants attr_accessor :current , :receiver , :instructions # add an instruction after the current (insertion point) diff --git a/lib/soml/compiler/basic_values.rb b/lib/soml/compiler/basic_values.rb index a0470f77..4120ea0c 100644 --- a/lib/soml/compiler/basic_values.rb +++ b/lib/soml/compiler/basic_values.rb @@ -38,7 +38,7 @@ module Soml def on_string expression value = expression.first.to_sym reg = use_reg :Word - @method.source.constants << value + Register.machine.constants << value add_code Register::LoadConstant.new( expression, value , reg ) return reg end