Move the space instance to the parfait module
A better fit, maybe even a pattern for singletons
This commit is contained in:
@ -52,7 +52,7 @@ module Register
|
||||
fix_types( types , classes )
|
||||
|
||||
space = Parfait::Space.new( classes )
|
||||
Parfait::Space.set_object_space( space )
|
||||
Parfait.set_object_space( space )
|
||||
|
||||
#puts Sof.write(@space)
|
||||
boot_functions!( space )
|
||||
@ -91,7 +91,7 @@ module Register
|
||||
clazz = BootClass.new(type)
|
||||
boot_space.classes[name] = clazz
|
||||
end
|
||||
Parfait::Space.set_object_space boot_space
|
||||
Parfait.set_object_space boot_space
|
||||
end
|
||||
|
||||
# superclasses other than default object
|
||||
|
@ -11,7 +11,7 @@ module Register
|
||||
compiler.method.set_instructions( new_start)
|
||||
compiler.set_current new_start
|
||||
|
||||
space = Parfait::Space.object_space
|
||||
space = Parfait.object_space
|
||||
space_reg = compiler.use_reg(:Space) #Set up the Space as self upon init
|
||||
compiler.add_load_constant("__init__ load Space", space , space_reg)
|
||||
message_ind = Register.resolve_to_index( :space , :first_message )
|
||||
@ -21,7 +21,7 @@ module Register
|
||||
ret_tmp = compiler.use_reg(:Label)
|
||||
compiler.add_load_constant("__init__ load return", exit_label , ret_tmp)
|
||||
compiler.add_reg_to_slot("__init__ store return", ret_tmp , :message , :return_address)
|
||||
compiler.add_code Register.function_call( "__init__ issue call" , Parfait::Space.object_space.get_main )
|
||||
compiler.add_code Register.function_call( "__init__ issue call" , Parfait.object_space.get_main )
|
||||
compiler.add_code exit_label
|
||||
emit_syscall( compiler , :exit )
|
||||
return compiler.method
|
||||
|
@ -4,7 +4,7 @@ module Register
|
||||
module Collector
|
||||
def collect
|
||||
self.objects.clear
|
||||
keep Parfait::Space.object_space , 0
|
||||
keep Parfait.object_space , 0
|
||||
constants.each {|o| keep(o,0)}
|
||||
end
|
||||
|
||||
|
@ -26,7 +26,7 @@ module Register
|
||||
# idea being that later method missing could catch translate_xxx and translate to target xxx
|
||||
# now we just instantiate ArmTranslater and pass instructions
|
||||
def translate_arm
|
||||
methods = Parfait::Space.object_space.collect_methods
|
||||
methods = Parfait.object_space.collect_methods
|
||||
translate_methods( methods )
|
||||
label = @init.next
|
||||
@init = Arm::Translator.new.translate( @init )
|
||||
@ -64,7 +64,7 @@ module Register
|
||||
def boot
|
||||
initialize
|
||||
boot_parfait!
|
||||
@init = Branch.new( "__initial_branch__" , Parfait::Space.object_space.get_init.instructions )
|
||||
@init = Branch.new( "__initial_branch__" , Parfait.object_space.get_init.instructions )
|
||||
@booted = true
|
||||
self
|
||||
end
|
||||
|
@ -85,7 +85,7 @@ module Register
|
||||
def self.resolve_to_index( clazz_name , instance_name )
|
||||
return instance_name unless instance_name.is_a? Symbol
|
||||
real_name = clazz_name.to_s.split('_').last.capitalize.to_sym
|
||||
clazz = Parfait::Space.object_space.get_class_by_name(real_name)
|
||||
clazz = Parfait.object_space.get_class_by_name(real_name)
|
||||
raise "Class name not given #{real_name}" unless clazz
|
||||
index = clazz.instance_type.variable_index( instance_name )
|
||||
raise "Instance name=#{instance_name} not found on #{real_name}:#{clazz.instance_type}" unless index.is_a?(Numeric)
|
||||
|
Reference in New Issue
Block a user