fix constant propagation through the layers

so they can end up in the binary
This commit is contained in:
Torsten Ruger
2018-07-03 10:12:22 +03:00
parent 63dfee0978
commit bb1d1495db
5 changed files with 29 additions and 9 deletions

View File

@ -6,6 +6,11 @@ module Mom
@method_compilers = Risc::Builtin.boot_functions + compilers
end
# collects constants from all compilers into one array
def constants
@method_compilers.inject([]){|sum ,comp| sum + comp.constants }
end
# Translate code to whatever cpu is specified.
# Currently only :arm and :interpret
#
@ -15,7 +20,7 @@ module Mom
platform_sym = platform_sym.to_s.capitalize
platform = Risc::Platform.for(platform_sym)
assemblers = translate_methods( platform.translator )
Risc::Linker.new(platform , assemblers)
Risc::Linker.new(platform , assemblers , constants)
end
# go through all methods and translate them to cpu, given the translator
@ -35,7 +40,7 @@ module Mom
cpu_instructions << cpu if cpu
nekst = nekst.next
end
Risc::Assembler.new(compiler.method , cpu_instructions , compiler.constants)
Risc::Assembler.new(compiler.method , cpu_instructions )
end
end