use common list for risc instruction

strange that that was not done before as the code was clearly copied
when extracting it

Fix bug for insertion
This commit is contained in:
Torsten Ruger
2018-03-18 10:36:01 +05:30
parent 9c052c78a7
commit c5ec532616
3 changed files with 29 additions and 60 deletions

View File

@ -11,6 +11,9 @@ module Common
end
# during translation we replace one by one
# TODO avoid this by building a new list
# Make arm instruction not derive from risc (which is weird anyway)
# and include the List into it, translate in same way we go from mom->risc
def replace_next( nekst )
old = @next
@next = nekst
@ -26,9 +29,10 @@ module Common
# set the give instruction as the next, while moving any existing
# instruction along to the given ones's next.
# ie insert into the linked list that the instructions form
# but allowing the instruction to be a list too (ie more than one)
def insert( instruction )
instruction.set_next @next
@next = instruction
instruction.last.set_next @next
@next = instruction.last
end
# return last set instruction. ie follow the linked list until it stops