add object method missing as sys exit
functions get added twice and thus removed once remove restriction for now
This commit is contained in:
parent
fb29fb6431
commit
87eee0b66e
@ -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 )
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user