rework binary code positioning setup
dependency chain set up explicitly. Next have to react to events correctly
This commit is contained in:
parent
91c7903848
commit
3bc35c2275
@ -117,12 +117,19 @@ module Risc
|
||||
#
|
||||
# start at code_start.
|
||||
def position_code(code_start)
|
||||
first_method = Parfait.object_space.types.values.first.methods
|
||||
before = code_start
|
||||
Position.set( first_method.binary , code_start , first_method)
|
||||
Position.set( first_method.cpu_instructions, code_start + Parfait::BinaryCode.byte_offset , first_method.binary)
|
||||
log.debug "Method #{first_method.name}:#{before.to_s(16)} len: #{(code_start - before).to_s(16)}"
|
||||
log.debug "Instructions #{first_method.cpu_instructions.object_id.to_s(16)}:#{(before+Parfait::BinaryCode.byte_offset).to_s(16)}"
|
||||
prev = nil
|
||||
Parfait.object_space.types.values.each do |type|
|
||||
next unless type.methods
|
||||
type.methods.each_method do |method|
|
||||
last = Position::CodeListener.init(method.binary , code_start)
|
||||
last.register_event(:position_changed , prev.object) if prev
|
||||
prev = last
|
||||
code_start = last.next_slot
|
||||
end
|
||||
end
|
||||
#Position.set( first_method.cpu_instructions, code_start + Parfait::BinaryCode.byte_offset , first_method.binary)
|
||||
#log.debug "Method #{first_method.name}:#{before.to_s(16)} len: #{(code_start - before).to_s(16)}"
|
||||
#log.debug "Instructions #{first_method.cpu_instructions.object_id.to_s(16)}:#{(before+Parfait::BinaryCode.byte_offset).to_s(16)}"
|
||||
end
|
||||
|
||||
# Create Binary code for all methods and the initial jump
|
||||
|
@ -72,6 +72,7 @@ module Risc
|
||||
at += code.padded_length unless at < 0
|
||||
code = code.next
|
||||
end
|
||||
position
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -40,6 +40,10 @@ module Risc
|
||||
trigger(:position_changed , self)
|
||||
true
|
||||
end
|
||||
def next_slot
|
||||
return -1 if at < 0
|
||||
at + object.byte_length
|
||||
end
|
||||
def self.init(object , at = -1)
|
||||
position = ObjectPosition.new(object , at)
|
||||
Position.set_to( position , at)
|
||||
|
@ -12,8 +12,12 @@ module Risc
|
||||
end
|
||||
|
||||
def test_has_init
|
||||
CodeListener.init(@binary)
|
||||
assert Position.get(@binary)
|
||||
pos = CodeListener.init(@binary)
|
||||
assert_equal pos, Position.get(@binary)
|
||||
end
|
||||
def test_init_returns_position
|
||||
|
||||
assert_equal Position::ObjectPosition , CodeListener.init(@binary).class
|
||||
end
|
||||
def test_init_listner
|
||||
@binary.extend_one
|
||||
|
@ -6,7 +6,12 @@ module Risc
|
||||
class TestPositionBasic < MiniTest::Test
|
||||
|
||||
def test_init
|
||||
assert_equal ObjectPosition.init(self)
|
||||
assert ObjectPosition.init(self , -1)
|
||||
end
|
||||
def test_next_slot
|
||||
mov = Arm::ArmMachine.mov(:r1 , :r1)
|
||||
position = ObjectPosition.new(mov , 0)
|
||||
assert_equal 4, position.next_slot
|
||||
end
|
||||
def pest_creation_ok
|
||||
assert ObjectPosition.new(self,0)
|
||||
|
Loading…
Reference in New Issue
Block a user