Move the space instance to the parfait module

A better fit, maybe even a pattern for singletons
This commit is contained in:
Torsten Ruger
2016-12-30 14:10:49 +02:00
parent a00f6be3ba
commit f0350601a7
43 changed files with 85 additions and 85 deletions

View File

@ -45,7 +45,7 @@ module Parfait
def super_class
raise "No super_class for class #{@name}" unless @super_class_name
s = Parfait::Space.object_space.get_class_by_name(@super_class_name)
s = Parfait.object_space.get_class_by_name(@super_class_name)
raise "superclass not found for class #{@name} (#{@super_class_name})" unless s
s
end

View File

@ -23,7 +23,7 @@ module Parfait
object = self.allocate
# have to grab the class, because we are in the ruby class not the parfait one
cl = Space.object_space.get_class_by_name( self.name.split("::").last.to_sym)
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

View File

@ -9,6 +9,16 @@
# recycles objects.
module Parfait
# Make the object space globally available
def self.object_space
@@object_space
end
# TODO Must get rid of the setter (move the boot process ?)
def self.set_object_space space
@@object_space = space
end
# The Space contains all objects for a program. In functional terms it is a program, but in oo
# it is a collection of objects, some of which are data, some classes, some functions
@ -42,16 +52,6 @@ module Parfait
attr_reader :types , :classes , :first_message
# Make the object space globally available
def self.object_space
@@object_space
end
# TODO Must get rid of the setter
def self.set_object_space space
@@object_space = space
end
def each_type
@types.values.each do |type|
yield(type)

View File

@ -7,7 +7,7 @@ class Symbol
true
end
def get_type
l = Parfait::Space.object_space.classes[:Word].instance_type
l = Parfait.object_space.classes[:Word].instance_type
#puts "LL #{l.class}"
l
end

View File

@ -42,7 +42,7 @@ module Parfait
def self.for_hash( object_class , hash)
new_type = Type.new( object_class , hash)
code = hash_code_for_hash( hash )
Space.object_space.types[code] = new_type
Parfait.object_space.types[code] = new_type
new_type
end
@ -154,7 +154,7 @@ module Parfait
hash = to_hash
hash[name] = type
code = Type.hash_code_for_hash( hash )
existing = Space.object_space.types[code]
existing = Parfait.object_space.types[code]
if existing
return existing
else

View File

@ -40,7 +40,7 @@ module Parfait
@name = name
@binary = BinaryCode.new 0
@arguments = arguments
@locals = Type.new Space.object_space.get_class_by_name( :Object )
@locals = Type.new Parfait.object_space.get_class_by_name( :Object )
end
def set_instructions(inst)