fix code insertion in method
This commit is contained in:
parent
ed902c343c
commit
66a160d8ab
@ -32,7 +32,7 @@ module Common
|
|||||||
# but allowing the instruction to be a list too (ie more than one)
|
# but allowing the instruction to be a list too (ie more than one)
|
||||||
def insert( instruction )
|
def insert( instruction )
|
||||||
instruction.last.set_next @next
|
instruction.last.set_next @next
|
||||||
@next = instruction.last
|
@next = instruction
|
||||||
end
|
end
|
||||||
|
|
||||||
# return last set instruction. ie follow the linked list until it stops
|
# return last set instruction. ie follow the linked list until it stops
|
||||||
|
@ -107,7 +107,7 @@ module Risc
|
|||||||
raise "Not an instruction:#{instruction.to_s}" unless instruction.is_a?(Risc::Instruction)
|
raise "Not an instruction:#{instruction.to_s}" unless instruction.is_a?(Risc::Instruction)
|
||||||
raise instruction.to_s if( instruction.class.name.split("::").first == "Arm")
|
raise instruction.to_s if( instruction.class.name.split("::").first == "Arm")
|
||||||
@current.insert(instruction) #insert after current
|
@current.insert(instruction) #insert after current
|
||||||
@current = instruction
|
@current = instruction.last
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ module Risc
|
|||||||
Parfait.object_space.get_main.instructions
|
Parfait.object_space.get_main.instructions
|
||||||
end
|
end
|
||||||
def real_index(index)
|
def real_index(index)
|
||||||
index - preamble.length + 1
|
index - preamble.length
|
||||||
end
|
end
|
||||||
def compare_instructions( instruction , expect )
|
def compare_instructions( instruction , expect )
|
||||||
index = 0
|
index = 0
|
||||||
@ -50,7 +50,7 @@ module Risc
|
|||||||
#full_expect = expect
|
#full_expect = expect
|
||||||
begin
|
begin
|
||||||
should = full_expect[index]
|
should = full_expect[index]
|
||||||
return "No instruction at #{index}\n#{should(all)}" unless should
|
return "No instruction at #{real_index(index)}\n#{should(all)}" unless should
|
||||||
return "Expected at #{real_index(index)}\n#{should(all)} was #{instruction.to_s}" unless instruction.class == should
|
return "Expected at #{real_index(index)}\n#{should(all)} was #{instruction.to_s}" unless instruction.class == should
|
||||||
#puts instruction.to_s if (index > preamble.length) and (index + postamble.length <= full_expect.length)
|
#puts instruction.to_s if (index > preamble.length) and (index + postamble.length <= full_expect.length)
|
||||||
index += 1
|
index += 1
|
||||||
|
Loading…
Reference in New Issue
Block a user