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
|
end
|
||||||
|
|
||||||
def remove_method( method_name )
|
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
|
raise "No such method #{method_name} in #{self.name}" unless @methods
|
||||||
if( @methods.name == method_name)
|
if( @methods.name == method_name)
|
||||||
@methods = @methods.next_method
|
@methods = @methods.next_method
|
||||||
@ -126,7 +125,6 @@ module Parfait
|
|||||||
|
|
||||||
def get_method( fname )
|
def get_method( fname )
|
||||||
raise "get_method #{fname}.#{fname.class}" unless fname.is_a?(Symbol)
|
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
|
return nil unless @methods
|
||||||
@methods.each_method do |m|
|
@methods.each_method do |m|
|
||||||
return m if(m.name == fname )
|
return m if(m.name == fname )
|
||||||
|
@ -170,7 +170,7 @@ module Risc
|
|||||||
space_class.instance_type.add_method Builtin::Space.send(:main, nil)
|
space_class.instance_type.add_method Builtin::Space.send(:main, nil)
|
||||||
|
|
||||||
obj = space.get_class_by_name(:Object)
|
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)
|
obj.instance_type.add_method Builtin::Object.send(f , nil)
|
||||||
end
|
end
|
||||||
obj = space.get_class_by_name(:Kernel)
|
obj = space.get_class_by_name(:Kernel)
|
||||||
|
@ -31,13 +31,13 @@ module Risc
|
|||||||
return compiler.method
|
return compiler.method
|
||||||
end
|
end
|
||||||
|
|
||||||
def exit context
|
def exit( context )
|
||||||
compiler = compiler_for(:Kernel,:exit ,{})
|
compiler = compiler_for(:Kernel,:exit ,{})
|
||||||
emit_syscall( compiler , :exit )
|
emit_syscall( compiler , :exit )
|
||||||
return compiler.method
|
return compiler.method
|
||||||
end
|
end
|
||||||
|
|
||||||
def emit_syscall compiler , name
|
def emit_syscall( compiler , name )
|
||||||
save_message( compiler )
|
save_message( compiler )
|
||||||
compiler.add_code Syscall.new("emit_syscall(#{name})", name )
|
compiler.add_code Syscall.new("emit_syscall(#{name})", name )
|
||||||
restore_message(compiler)
|
restore_message(compiler)
|
||||||
|
@ -33,6 +33,13 @@ module Risc
|
|||||||
return compiler.method
|
return compiler.method
|
||||||
end
|
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
|
end
|
||||||
extend ClassMethods
|
extend ClassMethods
|
||||||
end
|
end
|
||||||
|
@ -43,12 +43,6 @@ class TestMethodApi < MiniTest::Test
|
|||||||
@try_type.remove_method(:foo)
|
@try_type.remove_method(:foo)
|
||||||
end
|
end
|
||||||
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
|
def test_create_method
|
||||||
args = Parfait::Type.for_hash( @try_class , { bar: :Integer})
|
args = Parfait::Type.for_hash( @try_class , { bar: :Integer})
|
||||||
@try_type.create_method :bar, args , empty_frame
|
@try_type.create_method :bar, args , empty_frame
|
||||||
|
Loading…
x
Reference in New Issue
Block a user