add NewMessage / Frame instructions (without actual implementation)

This commit is contained in:
Torsten Ruger
2014-09-23 19:06:10 +03:00
parent 3d5eb685a1
commit 4e01bc798f
4 changed files with 23 additions and 6 deletions

View File

@ -6,16 +6,18 @@ module Ast
def compile method , message
me = receiver.compile( method, message )
method.add_code Virtual::NewMessage.new
method.add_code Virtual::Set.new(Virtual::NewSelf.new(me.type), me)
method.add_code Virtual::Set.new(Virtual::NewName.new(), Virtual::StringConstant.new(name))
compiled_args = []
args.each_with_index do |arg , i|
#compile in the running method, ie before passing control
val = arg.compile( method, message)
compiled_args << val
# move the compiled value to it's slot in the new message
to = Virtual::NewMessageSlot.new(i ,val.type , val)
# (doing this immediately, not after the loop, so if it's a return it won't get overwritten)
method.add_code Virtual::Set.new(Virtual::NewMessageSlot.new(i ,val.type ) , val )
method.add_code Virtual::Set.new(to , val )
compiled_args << to
end
method.add_code Virtual::MessageSend.new(name , me , compiled_args) #and pass control
# the effect of the method is that the NewMessage Return slot will be filled, return it