implement message pseudo variable (like self)

too easy
also simplified some tests
This commit is contained in:
Torsten Ruger 2015-11-08 13:55:38 +02:00
parent 69918c8e88
commit 37564d9c2e
2 changed files with 36 additions and 14 deletions

View File

@ -18,7 +18,7 @@ module Soml
add_code move
when :message
#message Slot
raise "message not yet"
value = Register.message_reg
else
if( index = @method.has_arg(receiver)) #argument
value = use_reg @method.arguments[index].type
@ -31,7 +31,7 @@ module Soml
add_code Register.get_slot(statement , :message , :frame , frame )
code = Register.get_slot(statement ,frame , Parfait::Frame.get_indexed(index) , value )
else
raise "Variable not defined #{name}"
raise "Variable not defined #{receiver}"
end
end
end

View File

@ -7,13 +7,10 @@ module Register
def test_field_frame
@string_input = <<HERE
class Fielded
field int one
end
class Object
int main()
Fielded f
return f.one
Message m
return m.name
end
end
HERE
@ -23,16 +20,13 @@ HERE
def test_field_arg
@string_input = <<HERE
class Fielded
field int one
end
class Object
int the_one(Fielded f)
return f.one
int get_name(Message main)
return main.name
end
int main()
Fielded f
return the_one(f)
Message m
return get_name(m)
end
end
HERE
@ -42,5 +36,33 @@ HERE
FunctionReturn]
check
end
def test_self_field
@string_input = <<HERE
class Object
int main()
Layout l = self.layout
return 1
end
end
HERE
@expect = [Label, GetSlot, GetSlot, GetSlot, SetSlot, LoadConstant, SetSlot ,
Label, FunctionReturn]
check
end
def test_message_field
@string_input = <<HERE
class Object
int main()
Word name = message.name
return name
end
end
HERE
@expect = [Label, GetSlot, SetSlot, GetSlot, GetSlot, SetSlot, Label ,
FunctionReturn]
check
end
end
end