cache booted functions

remove more redundant parfait boots
This commit is contained in:
2019-09-07 17:56:06 +03:00
parent 2c681bf2e5
commit b13c19def3
18 changed files with 35 additions and 32 deletions

View File

@ -26,35 +26,39 @@ module Mom
#
# We create an empty main for init to jump to, if no code is compiled, that just returns
# See Builtin directory readme and module
def self.boot_functions( options = {})
# TODO go through the virtual parfait layer and adjust function names
# to what they really are
compilers = []
def self.boot_functions( options = nil)
space = Parfait.object_space
space_type = space.get_class.instance_type
if(space_type.methods.nil?)
compilers << compiler_for( space_type , Space , :main)
if @compilers and options == nil
if(space_type.methods.nil?)
@compilers << compiler_for( space_type , Space , :main)
end
return @compilers
end
# TODO go through the virtual parfait layer and adjust function names
# to what they really are
@compilers = []
obj_type = space.get_type_by_class_name(:Object)
[ :__init__ , :exit , :_method_missing, :get_internal_word ,
:set_internal_word ].each do |f|
compilers << compiler_for( obj_type , Object , f)
@compilers << compiler_for( obj_type , Object , f)
end
word_type = space.get_type_by_class_name(:Word)
[:putstring , :get_internal_byte , :set_internal_byte ].each do |f|
compilers << compiler_for( word_type , Word , f)
@compilers << compiler_for( word_type , Word , f)
end
int_type = space.get_type_by_class_name(:Integer)
Risc.operators.each do |op|
compilers << operator_compiler( int_type , op)
@compilers << operator_compiler( int_type , op)
end
[ :div4, :<,:<= , :>=, :> , :div10 ].each do |f| #div4 is just a forward declaration
compilers << compiler_for( int_type , Integer , f)
@compilers << compiler_for( int_type , Integer , f)
end
return compilers
return @compilers
end
def self.compiler_for( type , mod , name)

View File

@ -22,7 +22,7 @@ module Mom
attr_reader :method_source
def initialize(method_source)
raise "no nil" unless method_source
raise "no nil source" unless method_source
@method_source = method_source
end

View File

@ -36,7 +36,7 @@ module Risc
# go through all methods and translate them to cpu, given the translator
def translate_methods(translator)
method_compilers.collect do |compiler|
#log.debug "Translate method #{compiler.method.name}"
#puts "Translate method #{compiler.callable.name}"
translate_method(compiler , translator)
end.flatten
end