diff --git a/lib/register/instructions/label.rb b/lib/register/instructions/label.rb index 3b4dca84..926b3fd7 100644 --- a/lib/register/instructions/label.rb +++ b/lib/register/instructions/label.rb @@ -18,6 +18,11 @@ module Register "Label: #{@name} (#{self.next.class})" end + # a method start has a label of the form Class.method , test for that + def is_method + @name.split(".").length == 2 + end + def to_ac labels = [] return [] if labels.include?(self) labels << self @@ -57,6 +62,11 @@ module Register self.next.set_position(position,labels) end + # shame we need this, just for logging + def byte_length + 0 + end + def each_label labels =[] , &block return if labels.include?(self) labels << self diff --git a/test/register/test_instructions.rb b/test/register/test_instructions.rb index 38d744aa..34715a06 100644 --- a/test/register/test_instructions.rb +++ b/test/register/test_instructions.rb @@ -70,5 +70,12 @@ module Register start.each_label { |l| count += 1 } assert_equal 2 , count end + def test_label_is_method + label = Label.new("test" , "Object.test") + assert label.is_method + end + def test_label_is_not_method + assert ! @label.is_method + end end end