From 8413f6b470ebc1293e8c0215eee07d873a63f35c Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Mon, 25 May 2015 18:48:35 +0300 Subject: [PATCH] smaller clean-ups --- lib/parfait/dictionary.rb | 2 +- lib/parfait/module.rb | 4 ++-- lib/parfait/object.rb | 5 +++-- lib/parfait/space.rb | 10 +++++++--- lib/virtual/block.rb | 2 +- lib/virtual/parfait_adapter.rb | 11 ++++------- 6 files changed, 18 insertions(+), 16 deletions(-) diff --git a/lib/parfait/dictionary.rb b/lib/parfait/dictionary.rb index b75278ca..cb149864 100644 --- a/lib/parfait/dictionary.rb +++ b/lib/parfait/dictionary.rb @@ -34,7 +34,7 @@ module Parfait end # get a value fot the given key - # key ientity is checked with == not === (ie equals not identity) + # key identity is checked with == not === (ie equals not identity) # return nil if no such key def get(key) index = key_index(key) diff --git a/lib/parfait/module.rb b/lib/parfait/module.rb index 7157ebcf..d0684cb6 100644 --- a/lib/parfait/module.rb +++ b/lib/parfait/module.rb @@ -40,7 +40,7 @@ module Parfait def create_instance_method name , arg_names clazz = Space.object_space.get_class_by_name(self.name) raise "??? #{self.name}" unless clazz - Method.new( clazz , name , arg_names ) + Method.new_object( clazz , name , arg_names ) end # this needs to be done during booting as we can't have all the classes and superclassses @@ -51,7 +51,7 @@ module Parfait end def get_instance_method fname - raise "uups #{fname}.#{fname.class}" unless fname.is_a? Word + raise "uups #{fname}.#{fname.class}" unless fname.is_a?(Word) or fname.is_a?(String) @instance_methods.detect{ |fun| fun.name == fname } end diff --git a/lib/parfait/object.rb b/lib/parfait/object.rb index 7dc27d47..2308eaee 100644 --- a/lib/parfait/object.rb +++ b/lib/parfait/object.rb @@ -47,8 +47,9 @@ module Parfait end def get_layout() - #puts "ME #{self.class}" - return internal_object_get(LAYOUT_INDEX) + l = internal_object_get(LAYOUT_INDEX) + raise "No layout #{self.class}" unless l + return l end def get_instance_variables diff --git a/lib/parfait/space.rb b/lib/parfait/space.rb index 7ae18f90..57a82a5c 100644 --- a/lib/parfait/space.rb +++ b/lib/parfait/space.rb @@ -40,7 +40,7 @@ module Parfait @frames = List.new_object @messages = List.new_object counter = 0 - while( counter < 100) + while( counter < 5) @frames.push Frame.new_object @messages.push Message.new_object counter = counter + 1 @@ -65,12 +65,16 @@ module Parfait @objects.push o end + def get_main + kernel = get_class_by_name "Kernel" + kernel.get_instance_method "main" + end + # this is the way to instantiate classes (not Parfait::Class.new) # so we get and keep exactly one per name def get_class_by_name name - raise "uups #{name}.#{name.class}" unless name.is_a? Word + raise "uups #{name}.#{name.class}" unless name.is_a?(Word) or name.is_a?(String) c = @classes[name] - raise "uups " if name.is_a? String puts "MISS, no class #{name} #{name.class}" unless c # " #{@classes}" c end diff --git a/lib/virtual/block.rb b/lib/virtual/block.rb index 752fcc09..8ed150f8 100644 --- a/lib/virtual/block.rb +++ b/lib/virtual/block.rb @@ -59,7 +59,7 @@ module Virtual begin code.set_position( at) rescue => e - puts "BLOCK #{self}" + puts "BLOCK #{self.to_s[0..5000]}" raise e end raise code.inspect unless code.mem_length diff --git a/lib/virtual/parfait_adapter.rb b/lib/virtual/parfait_adapter.rb index 5d48cbcd..9c561035 100644 --- a/lib/virtual/parfait_adapter.rb +++ b/lib/virtual/parfait_adapter.rb @@ -11,10 +11,7 @@ module FakeMem @length = -1 if Parfait::Space.object_space and Parfait::Space.object_space.objects Parfait::Space.object_space.add_object self - else - #TODO, must go through spce instance variables "by hand" - puts "fixme, no layout for #{self.class.name}" - end + end #Note: the else is handled in boot, by ading the space "by hand", as it slips though init_layout if Virtual::Machine.instance.class_mappings end def init_layout @@ -31,7 +28,7 @@ module FakeMem # resetting of position used to be error, but since relink and dynamic instruction size it is ok. # in measures (of 32) if @position != nil and ((@position - pos).abs > 32) - raise "position set again #{pos}!=#{@position} for #{self}" + raise "position set again #{pos}!=#{@position} for #{self.class}" end @position = pos end @@ -95,7 +92,7 @@ module Parfait end class List def mem_length - Virtual::Object.new.padded_words(length()) + padded_words(get_length()) end def to_sof_node(writer , level , ref ) Sof.array_to_sof_node(self , writer , level , ref ) @@ -122,7 +119,7 @@ module Parfait class Word def mem_length - Virtual::Object.new.padded(1 + length()) + padded(1 + length()) end def == other