Simplify Parfait booting

Since some weeks, Parfait uses instance variables instead of generated attribute getters (that needed type)
This makes it possible to simplify the boot process, getting rid of separate boot Space and class versions.
It is still quite order dependent, but all "normal" ruby code, (less magic) so easier to understand.

Also moved all code that can never run at runtime into the adapter. This included Space and Object new, space as the space will only ever be created at compile time and object, since that is quite different at run-time (which is where i am working towards)
This commit is contained in:
2019-09-22 19:10:47 +03:00
parent a496ea7e4b
commit e61c5d4a55
11 changed files with 105 additions and 174 deletions

View File

@ -22,32 +22,3 @@ require_relative "parfait/type"
require_relative "parfait/cache_entry"
require_relative "parfait/message"
require_relative "parfait/space"
module Parfait
# temporary shorthand getter for the space
# See implementation, space is now moved to inside the Object class
# (not module anymore), but there is a lot of code (about 100, 50/50 li/test)
# still calling this old version and since it is shorter . . .
def self.object_space
Object.object_space
end
class Object
# redefine the runtime version
def self.new( *args )
object = self.allocate
# have to grab the class, because we are in the ruby class not the parfait one
cl = Parfait.object_space.get_class_by_name( self.name.split("::").last.to_sym)
# and have to set the type before we let the object do anything. otherwise boom
object.set_type cl.instance_type
object.send :initialize , *args
object
end
# Setter fo the boot process, only at runtime.
# only one space exists and it is generated at compile time, not runtime
def self.set_object_space( space )
@object_space = space
end
end
end