fix code init bug
where initial pos wasnt propagated
This commit is contained in:
parent
e4b4551acf
commit
cf94227b2c
@ -18,6 +18,13 @@ module Risc
|
||||
end
|
||||
|
||||
def position_changed(position)
|
||||
nekst = position.object.next
|
||||
if( nekst )
|
||||
nekst_pos = Position.get(nekst)
|
||||
unless(nekst_pos.valid?)
|
||||
nekst_pos.set(position + position.object.padded_length)
|
||||
end
|
||||
end
|
||||
set_jump_for(position)
|
||||
end
|
||||
|
||||
|
@ -178,7 +178,11 @@ module Risc
|
||||
end
|
||||
self.positions[position.object] = position
|
||||
@reverse_cache[to] = position unless position.object.is_a?(Label)
|
||||
log.debug "Set #{position} to 0x#{to.to_s(16)} for #{position.object.class} #{position.object.object_id.to_s(16)}"
|
||||
if to == -1
|
||||
log.debug "Initialize for #{position.object.class} #{position.object.object_id.to_s(16)}"
|
||||
else
|
||||
log.debug "Set #{position} to 0x#{to.to_s(16)} for #{position.object.class} #{position.object.object_id.to_s(16)}"
|
||||
end
|
||||
position
|
||||
end
|
||||
end
|
||||
|
@ -17,10 +17,15 @@ module Risc
|
||||
pos = Position.get(@binary.next)
|
||||
assert_equal CodeListener , pos.event_table[:position_changed].first.class
|
||||
end
|
||||
def test_valid_pos_for_extended
|
||||
@binary.extend_one
|
||||
CodeListener.init(@binary).set(10)
|
||||
assert Position.get(@binary.next).valid?
|
||||
end
|
||||
def test_extend_sets_next_pos
|
||||
CodeListener.init(@binary).set(10)
|
||||
@binary.extend_one
|
||||
assert Position.get(@binary.next)
|
||||
assert Position.get(@binary.next).valid?
|
||||
end
|
||||
def test_extends_creates_jump
|
||||
CodeListener.init(@binary).set(10)
|
||||
|
Loading…
Reference in New Issue
Block a user