return the linker from mom_compiler
linker holds assemblers assemblers come from method compilation and so the layers come into focus
This commit is contained in:
@ -3,7 +3,7 @@ module Mom
|
||||
attr_reader :clazz , :method_compilers
|
||||
|
||||
def initialize(compilers = [])
|
||||
@method_compilers = Builtin.boot_functions + compilers
|
||||
@method_compilers = Risc::Builtin.boot_functions + compilers
|
||||
end
|
||||
|
||||
# Translate code to whatever cpu is specified.
|
||||
@ -14,7 +14,8 @@ module Mom
|
||||
def translate( platform_sym )
|
||||
platform_sym = platform_sym.to_s.capitalize
|
||||
platform = Risc::Platform.for(platform_sym)
|
||||
translate_methods( platform.translator )
|
||||
assemblers = translate_methods( platform.translator )
|
||||
Risc::Linker.new(platform , assemblers)
|
||||
#@cpu_init = risc_init.to_cpu(@platform.translator)
|
||||
end
|
||||
|
||||
|
@ -13,19 +13,20 @@ module Risc
|
||||
include Util::Logging
|
||||
log_level :info
|
||||
|
||||
def initialize(platform)
|
||||
def initialize(platform , assemblers)
|
||||
if(platform.is_a?(Symbol))
|
||||
platform = platform.to_s.capitalize
|
||||
platform = Risc::Platform.for(platform)
|
||||
end
|
||||
raise "Platform must be platform, not #{platform.class}" unless platform.is_a?(Platform)
|
||||
@platform = platform
|
||||
@assemblers = assemblers
|
||||
@risc_init = nil
|
||||
@constants = []
|
||||
end
|
||||
|
||||
attr_reader :constants , :cpu_init
|
||||
attr_reader :platform
|
||||
attr_reader :platform , :assemblers
|
||||
|
||||
# machine keeps a list of all objects and their positions.
|
||||
# this is lazily created with a collector
|
||||
@ -38,12 +39,6 @@ module Risc
|
||||
def risc_init
|
||||
@risc_init ||= Branch.new( "__initial_branch__" , Parfait.object_space.get_init.risc_instructions )
|
||||
end
|
||||
# add a constant (which get created during compilation and need to be linked)
|
||||
def add_constant(const)
|
||||
raise "Must be Parfait #{const}" unless const.is_a?(Parfait::Object)
|
||||
@constants << const
|
||||
end
|
||||
|
||||
|
||||
# To create binaries, objects (and labels) need to have a position
|
||||
# (so objects can be loaded and branches know where to jump)
|
||||
|
@ -61,7 +61,9 @@ module Risc
|
||||
end
|
||||
end
|
||||
|
||||
# add a constant (which get created during compilation and need to be linked)
|
||||
def add_constant(const)
|
||||
raise "Must be Parfait #{const}" unless const.is_a?(Parfait::Object)
|
||||
@constants << const
|
||||
end
|
||||
|
||||
|
@ -27,9 +27,7 @@ module RubyX
|
||||
def ruby_to_binary(platform = :arm)
|
||||
Parfait.boot!
|
||||
Risc.boot!
|
||||
assemblers = ruby_to_mom
|
||||
puts "Assemblers #{assemblers}"
|
||||
linker = Risc::Linker.new(platform)
|
||||
linker = ruby_to_risc(platform)
|
||||
linker.position_all
|
||||
linker.create_binary
|
||||
end
|
||||
|
Reference in New Issue
Block a user