crete positions while collecting objects

clear two phase lifecycle for positions
always created invalid and set later
new does not auto add to cache
but create and get_or_create do
This commit is contained in:
Torsten Ruger
2018-06-15 21:54:21 +03:00
parent 2c765c8f14
commit 9c93b38b8f
5 changed files with 43 additions and 24 deletions

View File

@ -1,12 +1,13 @@
module Risc
# collect anything that is in the space but and reachable from init
#
# The place we collect in is the position map in Position class
module Collector
def self.collect_space
@objects = {}
keep Parfait.object_space , 0
Risc.machine.constants.each {|obj| keep(obj,0)}
@objects
Position.positions
end
def self.keep( object , depth )
@ -30,7 +31,7 @@ module Risc
# Objects are data and get assembled after functions
def self.add_object( objekt , depth)
return false if @objects[objekt]
return false if Position.set?(objekt)
return true if objekt.is_a? Fixnum
return true if objekt.is_a?( Risc::Label)
#puts message(objekt , depth)
@ -39,7 +40,7 @@ module Risc
raise "adding non parfait #{objekt.class}:#{objekt}"
end
#raise "Method #{objekt.name}" if objekt.is_a? Parfait::TypedMethod
@objects[objekt] = objekt
Position.get_or_create(objekt)
true
end