Steamline objectPosition init
check for resetting on the same position with different class, which should not happen Ie it’s ok for an object to push another object up, but not for an instruction to land on code
This commit is contained in:
@ -16,7 +16,7 @@ module Risc
|
||||
|
||||
module Position
|
||||
include Util::Logging
|
||||
log_level :info
|
||||
log_level :debug
|
||||
|
||||
@positions = {}
|
||||
|
||||
@ -57,17 +57,21 @@ module Risc
|
||||
|
||||
def self.set( object , pos , extra = nil)
|
||||
# resetting of position used to be error, but since relink and dynamic instruction size it is ok.
|
||||
# in measures (of 32)
|
||||
log.debug "Setting #{pos} for #{object.class}-#{object}" if pos < 3000
|
||||
# in measures
|
||||
log.debug "Setting #{pos.to_s(16)} for #{object.class}-#{object}"
|
||||
old = Position.positions[object]
|
||||
testing = self.at( pos )
|
||||
if old != nil
|
||||
raise "Mismatch was:#{old}#{old.class} , should #{testing}#{testing.class}" if testing and testing.class != old.class
|
||||
old.reset_to(pos)
|
||||
log.debug "Reset #{pos.to_s(16)} for #{old.class}"
|
||||
return old
|
||||
end
|
||||
position = for_at( object , pos , extra)
|
||||
raise "Mismatch was:#{position}#{position.class} , should #{testing}#{testing.class}" if testing and testing.class != old.class
|
||||
self.positions[object] = position
|
||||
position.init(pos)
|
||||
log.debug "Set #{pos} for #{position.class}" if pos < 3000
|
||||
log.debug "Set #{pos.to_s(16)} for #{position.class}"
|
||||
position
|
||||
end
|
||||
|
||||
@ -78,7 +82,7 @@ module Risc
|
||||
when Arm::Instruction , Risc::Instruction
|
||||
InstructionPosition.new(object,at , extra)
|
||||
else
|
||||
ObjectPosition.new(at,object)
|
||||
ObjectPosition.new(object,at)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -13,7 +13,7 @@ module Risc
|
||||
attr_reader :code , :method
|
||||
|
||||
def initialize(code, pos , method)
|
||||
super(pos,code)
|
||||
super(code,pos)
|
||||
@code = code
|
||||
@method = method
|
||||
raise "Method nil" unless method
|
||||
@ -26,21 +26,22 @@ module Risc
|
||||
next_meth = next_method
|
||||
return unless next_meth
|
||||
Position.set( next_meth.binary , next_pos , next_meth)
|
||||
Position.set( next_meth.cpu_instructions, next_pos + 12 , next_meth.binary)
|
||||
next_cpu_pos = next_pos + Parfait::BinaryCode.offset
|
||||
Position.set( next_meth.cpu_instructions, next_cpu_pos , next_meth.binary)
|
||||
end
|
||||
end
|
||||
def reset_to(pos)
|
||||
super(pos)
|
||||
#puts "Reset (#{changed}) #{instruction}"
|
||||
Position.log.debug "Reset (#{pos.to_s(16)}) #{code}"
|
||||
init(pos)
|
||||
end
|
||||
def next_method
|
||||
next_m = @method.next_method
|
||||
return next_m if next_m
|
||||
#puts "Type now #{@method.for_type.name}"
|
||||
Position.log.debug "Type now #{@method.for_type.name}"
|
||||
type = next_type(@method.for_type)
|
||||
if type
|
||||
#puts "Position for #{type.name}"
|
||||
Position.log.debug "Position for #{type.name}"
|
||||
return type.methods
|
||||
else
|
||||
return nil
|
||||
|
@ -18,26 +18,26 @@ module Risc
|
||||
attr_reader :instruction , :binary
|
||||
def initialize(instruction, pos , binary)
|
||||
raise "not set " unless binary
|
||||
super(pos, instruction)
|
||||
super(instruction,pos)
|
||||
@instruction = instruction
|
||||
@binary = binary
|
||||
end
|
||||
def init(at)
|
||||
diff = at - Position.get(@binary).at
|
||||
if( diff % 60 == 12*4)
|
||||
if( diff % 60 == 13*4)
|
||||
@binary.extend_one unless @binary.next
|
||||
@binary = @binary.next
|
||||
raise "end of line " unless @binary
|
||||
at = Position.get(@binary).at + 3*4
|
||||
at = Position.get(@binary).at + Parfait::BinaryCode.offset
|
||||
end
|
||||
return unless instruction.next
|
||||
at += instruction.byte_length
|
||||
Position.set(instruction.next, at , binary)
|
||||
return unless @instruction.next
|
||||
at += @instruction.byte_length
|
||||
Position.set(@instruction.next, at , @binary)
|
||||
end
|
||||
|
||||
def reset_to(pos)
|
||||
super(pos)
|
||||
#puts "Reset (#{changed}) #{instruction}"
|
||||
Position.log.debug "Reset (#{pos}) #{instruction}"
|
||||
init(pos)
|
||||
end
|
||||
end
|
||||
|
@ -3,7 +3,7 @@ module Risc
|
||||
class ObjectPosition
|
||||
attr_reader :at , :object
|
||||
|
||||
def initialize( at , object)
|
||||
def initialize( object, at)
|
||||
@at = at
|
||||
@object = object
|
||||
raise "not int #{self}-#{at}" unless @at.is_a?(Integer)
|
||||
|
Reference in New Issue
Block a user