still working on the method dispatch
This commit is contained in:
@ -6,6 +6,27 @@ class TestClass < MiniTest::Test
|
||||
def test_class
|
||||
@string_input = <<HERE
|
||||
class Object
|
||||
def raise()
|
||||
putstring()
|
||||
exit()
|
||||
end
|
||||
def method_missing(name,args)
|
||||
name.raise()
|
||||
end
|
||||
def class()
|
||||
l = @layout
|
||||
return l.class()
|
||||
end
|
||||
def resolve_method(name)
|
||||
clazz = class()
|
||||
function = clazz._get_instance_variable(name)
|
||||
index = clazz.index_of(name)
|
||||
if( function == 0 )
|
||||
name.raise()
|
||||
else
|
||||
return function
|
||||
end
|
||||
end
|
||||
def index_of( name )
|
||||
l = @layout
|
||||
return l.index_of(name)
|
||||
@ -13,10 +34,6 @@ class Object
|
||||
def layout()
|
||||
return @layout
|
||||
end
|
||||
def class()
|
||||
l = @layout
|
||||
return l.class()
|
||||
end
|
||||
end
|
||||
class Class
|
||||
def Class.new_object( length )
|
||||
|
@ -31,12 +31,12 @@ HERE
|
||||
# not my hand off course, found in the net from a basic introduction
|
||||
def test_kernel_fibo
|
||||
int = Vm::Integer.new(Vm::RegisterMachine.instance.receiver_register)
|
||||
fibo = @object_space.get_or_create_class(:Object).get_or_create_function(:fibo)
|
||||
fibo = @object_space.get_or_create_class(:Object).resolve_function(:fibo)
|
||||
main = @object_space.main
|
||||
main.mov int , 10
|
||||
main.call( fibo )
|
||||
main.mov( Vm::RegisterMachine.instance.receiver_register , Vm::RegisterMachine.instance.return_register )
|
||||
putint = @object_space.get_or_create_class(:Object).get_or_create_function(:putint)
|
||||
putint = @object_space.get_or_create_class(:Object).resolve_function(:putint)
|
||||
main.call( putint )
|
||||
@should = [0x0,0x40,0x2d,0xe9,0x1,0x0,0x52,0xe3,0x2,0x0,0xa0,0xd1,0x7,0x0,0x0,0xda,0x1,0x30,0xa0,0xe3,0x0,0x40,0xa0,0xe3,0x4,0x30,0x83,0xe0,0x4,0x40,0x43,0xe0,0x1,0x20,0x42,0xe2,0x1,0x0,0x52,0xe3,0xfa,0xff,0xff,0x1a,0x3,0x0,0xa0,0xe1,0x0,0x80,0xbd,0xe8]
|
||||
@target = [:Object , :fibo]
|
||||
|
Reference in New Issue
Block a user