diff --git a/lib/parfait/type.rb b/lib/parfait/type.rb index 61bda058..fa158455 100644 --- a/lib/parfait/type.rb +++ b/lib/parfait/type.rb @@ -106,7 +106,6 @@ module Parfait end def remove_method( method_name ) - raise "May not remove method_missing" if method_name == :method_missing raise "No such method #{method_name} in #{self.name}" unless @methods if( @methods.name == method_name) @methods = @methods.next_method @@ -126,7 +125,6 @@ module Parfait def get_method( fname ) raise "get_method #{fname}.#{fname.class}" unless fname.is_a?(Symbol) - #if we had a hash this would be easier. Detect or find would help too return nil unless @methods @methods.each_method do |m| return m if(m.name == fname ) diff --git a/lib/risc/boot.rb b/lib/risc/boot.rb index ab7ac9cd..3af37483 100644 --- a/lib/risc/boot.rb +++ b/lib/risc/boot.rb @@ -170,7 +170,7 @@ module Risc space_class.instance_type.add_method Builtin::Space.send(:main, nil) obj = space.get_class_by_name(:Object) - [ :get_internal_word , :set_internal_word ].each do |f| + [ :get_internal_word , :set_internal_word , :_method_missing].each do |f| obj.instance_type.add_method Builtin::Object.send(f , nil) end obj = space.get_class_by_name(:Kernel) diff --git a/lib/risc/builtin/kernel.rb b/lib/risc/builtin/kernel.rb index 84c71850..841aee25 100644 --- a/lib/risc/builtin/kernel.rb +++ b/lib/risc/builtin/kernel.rb @@ -31,13 +31,13 @@ module Risc return compiler.method end - def exit context + def exit( context ) compiler = compiler_for(:Kernel,:exit ,{}) emit_syscall( compiler , :exit ) return compiler.method end - def emit_syscall compiler , name + def emit_syscall( compiler , name ) save_message( compiler ) compiler.add_code Syscall.new("emit_syscall(#{name})", name ) restore_message(compiler) diff --git a/lib/risc/builtin/object.rb b/lib/risc/builtin/object.rb index f0f4045a..cda5cd1f 100644 --- a/lib/risc/builtin/object.rb +++ b/lib/risc/builtin/object.rb @@ -33,6 +33,13 @@ module Risc return compiler.method end + # every object needs a method missing. + # Even if it's just this one, sys_exit (later raise) + def _method_missing( context ) + compiler = compiler_for(:Object,:method_missing ,{}) + Risc::Builtin::Kernel.emit_syscall( compiler , :exit ) + return compiler.method + end end extend ClassMethods end diff --git a/test/parfait/type/test_method_api.rb b/test/parfait/type/test_method_api.rb index 123ecb0b..8ab08345 100644 --- a/test/parfait/type/test_method_api.rb +++ b/test/parfait/type/test_method_api.rb @@ -43,12 +43,6 @@ class TestMethodApi < MiniTest::Test @try_type.remove_method(:foo) end end - def test_remove_method_missing -# assert @try_type.get_method( :method_missing) - assert_raises RuntimeError do - @try_type.remove_method(:method_missing) - end - end def test_create_method args = Parfait::Type.for_hash( @try_class , { bar: :Integer}) @try_type.create_method :bar, args , empty_frame