From 1be5d1862ff77fddac7ceb0b68cde4ee9cb0919a Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Tue, 3 Nov 2015 11:22:26 +0200 Subject: [PATCH] need to collect labels for return so the interpreter can find the object --- lib/register/collector.rb | 4 ++++ lib/register/machine.rb | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/register/collector.rb b/lib/register/collector.rb index 08f76d05..379584b4 100644 --- a/lib/register/collector.rb +++ b/lib/register/collector.rb @@ -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) diff --git a/lib/register/machine.rb b/lib/register/machine.rb index 83c09316..836878ce 100644 --- a/lib/register/machine.rb +++ b/lib/register/machine.rb @@ -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