refactor risc_collection

move code that operates on compiler to the compiler class
this leaves the collection thin, very thin indeed
This commit is contained in:
2019-09-28 15:34:09 +03:00
parent 9f81d78767
commit dcbc3e17be
6 changed files with 106 additions and 117 deletions

View File

@ -123,5 +123,20 @@ module Risc
def builder( source)
Builder.new(self , source)
end
# compile the callable (method or block) to cpu
# return an Assembler that will then translate to binary
def translate_cpu(translator)
risc = @risc_instructions
cpu_instructions = risc.to_cpu(translator)
nekst = risc.next
while(nekst)
cpu = nekst.to_cpu(translator) # returning nil means no replace
cpu_instructions << cpu if cpu
nekst = nekst.next
end
Risc::Assembler.new(@callable , cpu_instructions )
end
end
end