renaming and test fixing

This commit is contained in:
Torsten Ruger
2018-06-02 23:48:12 +03:00
parent 1d1c7105b4
commit f35ee6425a
11 changed files with 68 additions and 54 deletions

View File

@ -42,10 +42,12 @@ module Risc
cpu_jump.assemble(JumpWriter.new(code))
end
# Create Position for the given BinaryCode object
# return the last position that was created, for chaining
def self.init( code , at = -1)
while code
raise "Not Binary Code #{code.class}" unless code.is_a?(Parfait::BinaryCode)
position = Position.new(code , at)
Position.set_to(position , at)
if code.next
listener = PositionListener.new(code.next)
position.position_listener( listener)

View File

@ -39,12 +39,6 @@ module Risc
Position.set(@instruction.next, nekst , binary)
end
def reset_to(pos , binary)
super(pos , binary)
init(pos , binary)
Position.log.debug "ResetInstruction (#{pos.to_s(16)}) #{instruction}"
end
# initialize the dependency graph for instructions
#
# starting from the given instruction, create Positions
@ -55,6 +49,7 @@ module Risc
# return the position for the first instruction which may be used to
# set all positions in the chain
def self.init( instruction , code )
raise "Not Binary Code #{code.class}" unless code.is_a?(Parfait::BinaryCode)
first = nil
while(instruction)
position = Position.new(instruction , -1)

View File

@ -48,6 +48,7 @@ module Risc
def position_listeners
event_table[:position_changed]
end
#look for InstructionListener and return its code if found
def get_code
listener = event_table.find{|one| one.class == InstructionListener}
@ -55,6 +56,14 @@ module Risc
listener.code
end
def set(int)
same = int == self.at
Position.set_to(self , int)
@at = int
trigger(:position_changed , self ) unless same
int
end
def +(offset)
offset = offset.at if offset.is_a?(Position)
@at + offset
@ -122,6 +131,6 @@ module Risc
end
end
end
require_relative "object_listener"
require_relative "position_listener"
require_relative "instruction_listener"
require_relative "code_listener"

View File

@ -20,7 +20,8 @@ module Risc
# position to reflect that change
#
def position_changed(previous)
me = previous.at + previous.object.padded_length
add = previous.object ? previous.object.padded_length : 0
me = previous.at + add
object_pos = Position.get(@object)
return if me == object_pos.at
Position.set(@object , me)