diff --git a/lib/mom/mom_compiler.rb b/lib/mom/mom_compiler.rb index 3ac3b552..17160ad7 100644 --- a/lib/mom/mom_compiler.rb +++ b/lib/mom/mom_compiler.rb @@ -3,7 +3,12 @@ module Mom attr_reader :method_compilers def initialize(compilers = []) - @method_compilers = Risc::Builtin.boot_functions + 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 + end # collects constants from all compilers into one array diff --git a/lib/parfait/typed_method.rb b/lib/parfait/typed_method.rb index 2512ba10..964527fa 100644 --- a/lib/parfait/typed_method.rb +++ b/lib/parfait/typed_method.rb @@ -32,6 +32,12 @@ module Parfait init(arguments_type, frame_type) end + def ==(other) + return false unless other.is_a?(TypedMethod) + return false if @name != other.name + @for_type == other.for_type + end + # (re) init with given args and frame types def init(arguments_type, frame_type) raise "Wrong argument type, expect Type not #{arguments_type.class}" unless arguments_type.is_a? Type diff --git a/test/mom/test_mom_compiler.rb b/test/mom/test_mom_compiler.rb index 3c58504a..c1285312 100644 --- a/test/mom/test_mom_compiler.rb +++ b/test/mom/test_mom_compiler.rb @@ -15,6 +15,9 @@ module Mom def test_compilers assert_equal 24 , @comp.method_compilers.length end + def test_compilers_bare + assert_equal 23 , MomCompiler.new.method_compilers.length + end def test_returns_constants assert_equal Array , @comp.constants.class end diff --git a/test/mom/test_mom_compiler1.rb b/test/mom/test_mom_compiler1.rb index 917d8add..5618960d 100644 --- a/test/mom/test_mom_compiler1.rb +++ b/test/mom/test_mom_compiler1.rb @@ -32,7 +32,7 @@ module Mom assert_equal Risc::Label , @linker.assemblers.first.instructions.class end def test_assembler_assembled - assert_equal Risc::SlotToReg , @linker.assemblers.first.instructions.next.class + assert_equal Risc::LoadConstant , @linker.assemblers.first.instructions.next.class end def test_no_loops_in_chain @linker.assemblers.each do |asm| diff --git a/test/parfait/test_typed_method.rb b/test/parfait/test_typed_method.rb index ac5fa672..2e0638e0 100644 --- a/test/parfait/test_typed_method.rb +++ b/test/parfait/test_typed_method.rb @@ -5,10 +5,10 @@ module Parfait def setup super - obj = Parfait.object_space.get_class_by_name(:Object).instance_type - args = Parfait::Type.for_hash( obj.object_class , { bar: :Integer , foo: :Type}) - frame = Parfait::Type.for_hash( obj.object_class , { local_bar: :Integer , local_foo: :Type}) - @method = Parfait::TypedMethod.new( obj , :meth , args , frame) + @obj = Parfait.object_space.get_class_by_name(:Object).instance_type + @args = Parfait::Type.for_hash( @obj.object_class , { bar: :Integer , foo: :Type}) + @frame = Parfait::Type.for_hash( @obj.object_class , { local_bar: :Integer , local_foo: :Type}) + @method = Parfait::TypedMethod.new( @obj , :meth , @args , @frame) end def test_method_name @@ -95,5 +95,12 @@ module Parfait def test_created_with_binary assert @method.binary end + def test_equal + assert_equal @method , @method + end + def test_not_equal + method = Parfait::TypedMethod.new( @obj , :other , @args , @frame) + assert @method != method + end end end