objects didn't get positions
positions.empty? was wrong check
This commit is contained in:
@ -13,6 +13,7 @@ module Risc
|
||||
Position.log.debug "extending one at #{position}"
|
||||
pos = CodeListener.init( position.object.next )
|
||||
return unless position.valid?
|
||||
puts "insert #{position.object.next.object_id.to_s(16)}" unless position.valid?
|
||||
pos.set( position + position.object.padded_length)
|
||||
set_jump_for(position)
|
||||
end
|
||||
|
@ -91,8 +91,7 @@ module Risc
|
||||
while(instruction)
|
||||
position = Position.get_or_create(instruction)
|
||||
first = position unless first
|
||||
il = InstructionListener.new( code )
|
||||
position.position_listener(il)
|
||||
position.position_listener( InstructionListener.new( code ) )
|
||||
if instruction.respond_to?(:branch)
|
||||
# label_pos = Position.get(instruction.branch)
|
||||
# label_pos.position_listener( BranchListener.new(il))
|
||||
|
@ -69,7 +69,7 @@ module Risc
|
||||
def set(int)
|
||||
return int if int == self.at
|
||||
trigger_changing( int )
|
||||
Position.set_to(self , int)
|
||||
Position.set_cache(self , int)
|
||||
@at = int
|
||||
trigger_changed
|
||||
self
|
||||
@ -157,9 +157,9 @@ module Risc
|
||||
if pos == nil
|
||||
str = "position accessed but not initialized, "
|
||||
str += "0x#{object.object_id.to_s(16)}\n"
|
||||
str += "for #{object.class} "
|
||||
str += "class: #{object.class} "
|
||||
str += "byte_length #{object.byte_length}" if object.respond_to?(:byte_length)
|
||||
str += " for #{object.to_s[0...130]}"
|
||||
str += " object: #{object.to_s[0...130]}"
|
||||
raise str
|
||||
end
|
||||
pos
|
||||
@ -186,7 +186,7 @@ module Risc
|
||||
# forward caches object -> position
|
||||
# reverse caches position.at > position
|
||||
# Labels do not participatein reverse cache
|
||||
def self.set_to( position , to)
|
||||
def self.set_cache( position , to)
|
||||
postest = Position.positions[position.object] unless to < 0
|
||||
raise "Mismatch #{position}" if postest and postest != position
|
||||
@reverse_cache.delete(position.at) unless position.object.is_a?(Label)
|
||||
|
@ -19,15 +19,14 @@ module Risc
|
||||
def position_changing(position , to)
|
||||
end
|
||||
|
||||
# when the argument changes position, we update the objects
|
||||
# when the argument changes position, we update the next objects
|
||||
# position to reflect that change
|
||||
#
|
||||
def position_changed(previous)
|
||||
add = previous.object ? previous.object.padded_length : 0
|
||||
my_pos = previous.at + add
|
||||
object_pos = Position.get(@object)
|
||||
return if my_pos == object_pos.at
|
||||
Position.set_to(object_pos , my_pos)
|
||||
next_at = previous.at + add
|
||||
next_pos = Position.get(@object)
|
||||
next_pos.set(next_at)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user