rubyx/test/risc/position/helper.rb
Torsten Ruger 56f2742e89 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
2018-07-02 23:03:00 +03:00

65 lines
1.1 KiB
Ruby

require_relative "../helper"
module Risc
class Dummy
def padded_length
4
end
def byte_length
4
end
end
class Machine
def set_platform(plat)
@platform = plat
end
def set_translated
@translated = true
translate_methods( @platform.translator )
@cpu_init = risc_init.to_cpu(@platform.translator)
end
end
class DummyPlatform
def self.boot
Parfait.boot!
Risc.boot!
end
def translator
DummyTranslator.new
end
def padding
0
end
end
class DummyTranslator
def translate(arg)
DummyInstruction.new
end
end
class DummyBranch < Branch
attr_reader :precheck_called
def precheck
@precheck_called = true
end
end
class DummyInstruction < Dummy
include Util::List
def initialize(nekst = nil)
@next = nekst
end
def insert(instruction)
ret = super
Position.get(self).trigger_inserted if Position.set?(self)
ret
end
def assemble(io)
io.write_unsigned_int_32(0)
end
def total_byte_length
4
end
end
end