start to move translate code

This commit is contained in:
Torsten Ruger
2018-06-30 22:53:32 +03:00
parent daf1b56062
commit 208b98d709
7 changed files with 45 additions and 5 deletions

View File

@ -6,5 +6,25 @@ module Mom
@clazz = clazz
@methods = methods
end
# Translate code to whatever cpu is specified.
# Currently only :arm and :interpret
#
# Translating means translating the initial jump
# and then translating all methods
def translate( platform )
platform = platform.to_s.capitalize
@platform = Risc::Platform.for(platform)
translate_methods( @platform.translator )
#@cpu_init = risc_init.to_cpu(@platform.translator)
end
# go through all methods and translate them to cpu, given the translator
def translate_methods(translator)
Parfait.object_space.get_all_methods.each do |method|
#log.debug "Translate method #{method.name}"
method.translate_cpu(translator)
end
end
end
end

View File

@ -6,7 +6,7 @@ module Risc
def compiler_for( clazz_name , method_name , arguments , locals = {})
frame = Parfait::NamedList.type_for( locals )
args = Parfait::NamedList.type_for( arguments )
Risc::RiscCompiler.compiler_for_class(clazz_name , method_name , args, frame )
RiscCompiler.compiler_for_class(clazz_name , method_name , args, frame )
end
end

View File

@ -17,7 +17,8 @@ module RubyX
def self.ruby_to_binary(source , platform = :arm)
Parfait.boot!
machine = Risc.machine.boot
ruby_to_mom(source)
mom = ruby_to_mom(source)
#mom.translate(platform)
machine.translate(platform)
machine.position_all
machine.create_binary