need to collect labels for return

so the interpreter can find the object
This commit is contained in:
Torsten Ruger 2015-11-03 11:22:26 +02:00
parent bc414fd3e8
commit 1be5d1862f
2 changed files with 7 additions and 2 deletions

View File

@ -13,6 +13,10 @@ module Register
#puts "adding #{' ' * depth}:#{object.class}"
#puts "ADD #{object.first.class}, #{object.last.class}" if object.is_a? Array
return unless self.add_object object
# probably should make labels or even instructions derive from Parfait::Object, but . .
if object.is_a? Register::Label
object.each_label { |l| self.add_object(l)}
end
return unless object.respond_to? :has_layout?
layout = object.get_layout
keep(layout , depth + 1)

View File

@ -55,8 +55,9 @@ module Register
def add_object o
return false if @objects[o.object_id]
return true if o.is_a? Fixnum
return true if o.is_a? Register::Label
raise "adding non parfait #{o.class}" unless o.is_a? Parfait::Object or o.is_a? Symbol
unless o.is_a? Parfait::Object or o.is_a? Symbol or o.is_a? Register::Label
raise "adding non parfait #{o.class}"
end
@objects[o.object_id] = o
true
end