fix code listener logic bug
next's position was only updated initially previous logic relied on pushing everything long rightly but it wasn't right, and no harm in setting position twice, as events only fire if there is real change
This commit is contained in:
@ -17,21 +17,22 @@ module Risc
|
||||
def position_inserted(position)
|
||||
Position.log.debug "extending one at #{position}"
|
||||
pos = CodeListener.init( position.object.next , @platform)
|
||||
raise "HI #{position}" unless position.valid?
|
||||
return unless position.valid?
|
||||
puts "insert #{position.object.next.object_id.to_s(16)}" unless position.valid?
|
||||
Position.log.debug "insert #{position.object.next.object_id.to_s(16)}"
|
||||
pos.set( position + position.object.padded_length)
|
||||
set_jump_for(position)
|
||||
end
|
||||
|
||||
def position_changed(position)
|
||||
Position.log.debug "Code 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
|
||||
Position.log.debug "Code changed, setting next #{position}"
|
||||
nekst_pos.set(position + position.object.padded_length)
|
||||
set_jump_for(position)
|
||||
end
|
||||
set_jump_for(position)
|
||||
end
|
||||
|
||||
def position_changing(position , to)
|
||||
|
@ -25,7 +25,7 @@ module Risc
|
||||
# Taking into account that BinaryCodes only take 13 instructions,
|
||||
# meaning that chain may have to be extended
|
||||
def position_changing(position , to)
|
||||
Position.log.debug "Changing #{position} to 0x#{to.to_s(16)}, bin #{Position.get(@binary)}"
|
||||
Position.log.debug "Instruction from #{position} to 0x#{to.to_s(16)}, bin #{Position.get(@binary)}"
|
||||
update_index(to)
|
||||
instruction = position.object
|
||||
return unless instruction.next
|
||||
@ -43,8 +43,11 @@ module Risc
|
||||
index = (to - Position.get(@binary).at) / 4
|
||||
raise "Invalid negative index #{index} , #{Position.get(@binary)}" if index < Parfait::BinaryCode.type_length
|
||||
while(index >= (Parfait::BinaryCode.memory_size - 1) )
|
||||
Position.log.debug "Binary Extend (#{index}) #{Position.get(@binary)}, 0x#{@binary.object_id.to_s(16)}"
|
||||
@binary = @binary.ensure_next
|
||||
Position.log.debug "Binary Extended (#{index}) #{Position.get(@binary)}"
|
||||
index = (to - Position.get(@binary).at) / 4
|
||||
Position.log.debug "Binary Extended new index (#{index}) #{Position.get(@binary)}"
|
||||
end
|
||||
@index = index - 2
|
||||
raise "Invalid negative index #{@index} , #{Position.get(@binary)}" if index < 0
|
||||
|
Reference in New Issue
Block a user