From 98db88ac2fb699f08d44aa287a14e5a364601314 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Fri, 18 Jul 2014 00:29:45 +0300 Subject: [PATCH] not recursing into labels to avoid infinite loops --- lib/virtual/instruction.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/virtual/instruction.rb b/lib/virtual/instruction.rb index 8edce522..20593b34 100644 --- a/lib/virtual/instruction.rb +++ b/lib/virtual/instruction.rb @@ -18,6 +18,22 @@ module Virtual def initialize nex = nil @next = nex end + # simple thought: don't recurse for labels, just check their names + def == other + return false unless other.class == self.class + attributes.each do |a| + left = send(a) + right = other.send(a) + return false unless left.class == right.class + if( left.is_a? Label) + return false unless left.name == right.name + else + return false unless left == right + end + end + return true + end + end module Named