small arm fixes etc
This commit is contained in:
@ -39,9 +39,33 @@ module Risc
|
||||
end
|
||||
|
||||
def position_changed(position)
|
||||
fix_binary
|
||||
my_pos = Position.get(@instruction)
|
||||
my_pos.set(position.at + position.object.byte_length)
|
||||
end
|
||||
|
||||
# check that the binary we use is the one where the current position falls
|
||||
# if not move up and register/unregister (soon)
|
||||
def fix_binary
|
||||
return if Position.get(@instruction).at == -1
|
||||
count = 0
|
||||
org_pos = Position.get(@binary)
|
||||
return if org_pos.at == -1
|
||||
while( !pos_in_binary)
|
||||
@binary = @binary.ensure_next
|
||||
count += 1
|
||||
raise "Positions messed #{Position.get(@instruction)}:#{org_pos}"
|
||||
end
|
||||
end
|
||||
|
||||
def pos_in_binary
|
||||
me = Position.get(@instruction)
|
||||
bin = Position.get(@binary)
|
||||
return false if me < bin
|
||||
return false if me > (bin + @binary.padded_length)
|
||||
return true
|
||||
end
|
||||
|
||||
# initialize the dependency graph for instructions
|
||||
#
|
||||
# starting from the given instruction, create Positions
|
||||
|
@ -73,6 +73,17 @@ module Risc
|
||||
offset = offset.at if offset.is_a?(Position)
|
||||
@at - offset
|
||||
end
|
||||
|
||||
def <(right)
|
||||
right = right.at if right.is_a?(Position)
|
||||
@at < right
|
||||
end
|
||||
|
||||
def >(right)
|
||||
right = right.at if right.is_a?(Position)
|
||||
@at > right
|
||||
end
|
||||
|
||||
def to_s
|
||||
"0x#{@at.to_s(16)}"
|
||||
end
|
||||
@ -129,7 +140,7 @@ module Risc
|
||||
@reverse_cache.delete(position.at) unless position.object.is_a?(Label)
|
||||
testing = self.at( position.at ) unless position.at < 0
|
||||
if testing and testing.object.class != position.object.class
|
||||
raise "Mismatch (at #{pos.to_s(16)}) was:#{position} #{position.class} #{position.object} , should #{testing}#{testing.class}"
|
||||
raise "Mismatch (at #{to.to_s(16)}) was:#{position} #{position.class} #{position.object} , should #{testing}#{testing.class}"
|
||||
end
|
||||
self.positions[position.object] = position
|
||||
@reverse_cache[to] = position unless position.object.is_a?(Label)
|
||||
|
Reference in New Issue
Block a user