fix inital main (again)
stop even compiling a fake main if a real exists (in builtin) previous version was still buggy: using builting methods types (especially locals) even comiled version had different
This commit is contained in:
parent
6f936f190d
commit
d8b58d8da6
@ -3,12 +3,7 @@ module Mom
|
||||
attr_reader :method_compilers
|
||||
|
||||
def initialize(compilers = [])
|
||||
@method_compilers = compilers
|
||||
Risc::Builtin.boot_functions.each do |boot_comp|
|
||||
next if @method_compilers.find{|comp| comp.method == boot_comp.method }
|
||||
@method_compilers << boot_comp
|
||||
end
|
||||
|
||||
@method_compilers = compilers + Risc::Builtin.boot_functions
|
||||
end
|
||||
|
||||
# collects constants from all compilers into one array
|
||||
|
@ -12,15 +12,17 @@ module Risc
|
||||
# This should return the implementation of the method (ie a method object),
|
||||
# not actually try to implement it(as that's impossible in ruby)
|
||||
#
|
||||
def self.boot_functions
|
||||
compilers = []
|
||||
space = Parfait.object_space
|
||||
# very fiddly chicken 'n egg problem. Functions need to be in the right order,
|
||||
# and in fact we have to define some dummies, just for the others to compile
|
||||
# When no main has been compiled, we will add an empty main (for testing)
|
||||
#
|
||||
def self.boot_functions(add_main = false)
|
||||
# TODO go through the virtual parfait layer and adjust function names
|
||||
# to what they really are
|
||||
compilers = []
|
||||
space = Parfait.object_space
|
||||
space_type = space.get_class.instance_type
|
||||
compilers << compiler_for( space_type , Space , :main)
|
||||
if(space_type.methods.nil?)
|
||||
compilers << compiler_for( space_type , Space , :main)
|
||||
end
|
||||
|
||||
obj_type = space.get_class_by_name(:Object).instance_type
|
||||
[ :get_internal_word , :set_internal_word , :_method_missing,
|
||||
|
@ -13,10 +13,10 @@ module Mom
|
||||
assert_equal MomCompiler , @comp.class
|
||||
end
|
||||
def test_compilers
|
||||
assert_equal 24 , @comp.method_compilers.length
|
||||
assert_equal 23 , @comp.method_compilers.length
|
||||
end
|
||||
def test_compilers_bare
|
||||
assert_equal 23 , MomCompiler.new.method_compilers.length
|
||||
assert_equal 22 , MomCompiler.new.method_compilers.length
|
||||
end
|
||||
def test_returns_constants
|
||||
assert_equal Array , @comp.constants.class
|
||||
|
Loading…
Reference in New Issue
Block a user