split create_binary into two phases

Which gives instructions a chance to check everything
and in Arms case check the constant loads/ instruction adding
So that during assembly no more change happens (and we don't have to reassemble)
This commit is contained in:
Torsten Ruger
2018-06-17 13:53:17 +03:00
parent c94f6eaa78
commit 3298651238
7 changed files with 37 additions and 8 deletions

View File

@@ -22,6 +22,7 @@ module Risc
@constants = []
@next_address = nil
end
attr_reader :constants , :cpu_init
attr_reader :booted , :translated
attr_reader :platform
@@ -143,12 +144,23 @@ module Risc
# constant loads into one instruction.
#
def create_binary
object_positions.keys.each do |method|
next unless method.is_a? Parfait::TypedMethod
methods = object_positions.keys.find_all{|obj| obj.is_a? Parfait::TypedMethod}
prerun(methods)
assemble(methods)
log.debug "BinaryInit #{cpu_init.object_id.to_s(16)}"
end
def prerun(methods)
methods.each do |method|
method.cpu_instructions.each {|i| i.precheck }
end
end
def assemble(methods)
methods.each do |method|
writer = BinaryWriter.new(method.binary)
writer.assemble(method.cpu_instructions)
end
log.debug "BinaryInit #{cpu_init.object_id.to_s(16)}"
end
def boot