reuse translator in machine and clean up api
This commit is contained in:
parent
294f4d988f
commit
e8f449bc65
@ -22,16 +22,22 @@ module Risc
|
|||||||
end
|
end
|
||||||
attr_reader :constants , :risc_init , :cpu_init , :booted
|
attr_reader :constants , :risc_init , :cpu_init , :booted
|
||||||
|
|
||||||
# idea being that later method missing could catch translate_xxx and translate to target xxx
|
# translate to arm, ie instantiate an arm translator and pass it to translate
|
||||||
# now we just instantiate ArmTranslater and pass instructions
|
#
|
||||||
|
# currently we have no machanism to translate to other cpu's (nor such translators)
|
||||||
|
# but the mechanism is ready
|
||||||
def translate_arm
|
def translate_arm
|
||||||
methods = Parfait.object_space.collect_methods
|
translate(Arm::Translator.new)
|
||||||
translate_methods( methods )
|
|
||||||
@cpu_init = Arm::Translator.new.translate( @risc_init )
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def translate_methods(methods)
|
# translate the methods to whatever cpu the translator translates to
|
||||||
translator = Arm::Translator.new
|
def translate( translator )
|
||||||
|
methods = Parfait.object_space.collect_methods
|
||||||
|
translate_methods( methods , translator )
|
||||||
|
@cpu_init = translator.translate( @risc_init )
|
||||||
|
end
|
||||||
|
|
||||||
|
def translate_methods(methods , translator)
|
||||||
methods.each do |method|
|
methods.each do |method|
|
||||||
log.debug "Translate method #{method.name}"
|
log.debug "Translate method #{method.name}"
|
||||||
method.translate_cpu(translator)
|
method.translate_cpu(translator)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user