fixed layouts

also moved objects to machine, from space
space has a list of objects, but implicit,
not as an explicit array
This commit is contained in:
Torsten Ruger
2015-05-31 13:02:29 +03:00
parent aaa206fbca
commit 03bdc16810
8 changed files with 69 additions and 75 deletions

View File

@ -54,9 +54,14 @@ module Parfait
internal_object_set(LAYOUT_INDEX , layout)
end
# so we can keep the raise in get_layout
def has_layout?
! internal_object_get(LAYOUT_INDEX).nil?
end
def get_layout()
l = internal_object_get(LAYOUT_INDEX)
raise "No layout #{self.class}:#{self.to_s} #{self.object_id}" unless l
raise "No layout #{self.class}:#{self.class} #{self.object_id}" unless l
return l
end

View File

@ -27,13 +27,8 @@ module Parfait
super()
Parfait::Space.set_object_space self
@classes = Parfait::Dictionary.new_object
# this is like asking for troubles, but if the space instance is not registered
# and the @classes up, one can not register classes.
# all is good after this init
#global objects (data)
@objects = Parfait::List.new_object
end
attr_reader :classes , :objects , :frames, :messages, :next_message , :next_frame
attr_reader :classes , :frames, :messages, :next_message , :next_frame
# need a two phase init for the object space (and generally parfait) because the space
# is an interconnected graph, so not everthing is ready
@ -50,25 +45,6 @@ module Parfait
@next_frame = @frames.first
end
# double check that all objects dependents are really in the space too (debugging)
def double_check
@objects.each do |o|
check o
end
end
# private
def check object , recurse = true
raise "No good #{self.class}" unless @objects.include? object
puts "#{object.class}"
puts "#{object}" if object.class == Parfait::Word
check object.get_layout
return unless recurse
object.get_layout.each do |name|
check name , false
inst = object.instance_variable_get "@#{name}".to_sym
check inst , false
end
end
@@object_space = nil
# Make the object space globally available
def self.object_space
@ -79,12 +55,6 @@ module Parfait
@@object_space = space
end
# Objects are data and get assembled after functions
def add_object o
return if @objects.include?(o)
@objects.push o
end
def get_main
kernel = get_class_by_name "Object"
kernel.get_instance_method "main"