getter by position

extract and expand position testing
never return labels (that have the same position as their target)
This commit is contained in:
Torsten Ruger
2018-05-17 20:13:33 +03:00
parent 37d62d298e
commit 8966a50a8a
6 changed files with 78 additions and 15 deletions

View File

@ -21,6 +21,15 @@ module Risc
@positions
end
def self.at( int )
self.positions.each do |object , position|
next unless position.at == int
return position unless position.is_a?(InstructionPosition)
return position unless position.instruction.is_a?(Label)
end
nil
end
def self.set?(object)
self.positions.has_key?(object)
end