method marking for labels
This commit is contained in:
parent
6882f39645
commit
ca1dc36e3d
@ -18,6 +18,11 @@ module Register
|
|||||||
"Label: #{@name} (#{self.next.class})"
|
"Label: #{@name} (#{self.next.class})"
|
||||||
end
|
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 = []
|
def to_ac labels = []
|
||||||
return [] if labels.include?(self)
|
return [] if labels.include?(self)
|
||||||
labels << self
|
labels << self
|
||||||
@ -57,6 +62,11 @@ module Register
|
|||||||
self.next.set_position(position,labels)
|
self.next.set_position(position,labels)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# shame we need this, just for logging
|
||||||
|
def byte_length
|
||||||
|
0
|
||||||
|
end
|
||||||
|
|
||||||
def each_label labels =[] , &block
|
def each_label labels =[] , &block
|
||||||
return if labels.include?(self)
|
return if labels.include?(self)
|
||||||
labels << self
|
labels << self
|
||||||
|
@ -70,5 +70,12 @@ module Register
|
|||||||
start.each_label { |l| count += 1 }
|
start.each_label { |l| count += 1 }
|
||||||
assert_equal 2 , count
|
assert_equal 2 , count
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user