remove new_message instruction

This commit is contained in:
Torsten Ruger 2015-10-10 12:04:34 +03:00
parent c3eb295f4e
commit 3d342f7d88
13 changed files with 11 additions and 48 deletions

View File

@ -16,7 +16,9 @@ module Phisol
end
## need two step process, compile and save to frame
# then move from frame to new message
@method.source.add_code Virtual::NewMessage.new
# load the new_message from message by index, simple get_slot
new_message = Register.get_slot(@method, :message , :next_message , Register.resolve_to_register(:new_message))
@method.source.add_code new_message
@method.source.add_code Virtual::Set.new( me , Virtual::NewSelf.new(me.type))
@method.source.add_code Virtual::Set.new( name.to_sym , Virtual::NewMessageName.new(:int))
compiled_args = []

View File

@ -1,32 +0,0 @@
module Register
# This implements the creation of a new message object
#
# It does so by loading the next message into the new_message register.
#
# Messages are created at compile time and form a linked list which actually never changes.
# We just grab the next item of the list.
# Just as a reminder: a message object is used for a send and holds return address/message
# and arguments + self
# while frames are used by a method and hold local and temporary variables
# This was at first a little surprising, but it actually similar in c. When a c function pops to
# stack, it doesn't create a new stack. Just increments some index. The storage/stack is reused,
# stays constant. (until such time it runs out, which we haven't covered yet)
#
# Even stranger at first was the notion that the caller does not have to be set either.
# That is contstant (a compile time property) too. It's a bit like when calling someone,
#
class MessageImplementation
def run block
block.codes.dup.each do |code|
next unless code.is_a?(Virtual::NewMessage)
# load the new_message from message by index, simple get_slot
new_codes = [ Register.get_slot(code, :message , :next_message , Register.resolve_to_register(:new_message))]
block.replace(code , new_codes )
end
end
end
Virtual.machine.add_pass "Register::MessageImplementation"
end

View File

@ -2,7 +2,6 @@ require_relative "instruction"
require_relative "register_reference"
require_relative "assembler"
require_relative "passes/frame_implementation"
require_relative "passes/message_implementation"
require_relative "passes/set_implementation"
require_relative "passes/return_implementation"
require_relative "passes/call_implementation"

View File

@ -18,5 +18,4 @@ require_relative "instructions/method_call"
require_relative "instructions/method_enter"
require_relative "instructions/method_return"
require_relative "instructions/new_frame"
require_relative "instructions/new_message"
require_relative "instructions/set"

View File

@ -1,5 +0,0 @@
module Virtual
class NewMessage < Instruction
end
end

View File

@ -16,7 +16,7 @@ class Object
end
end
HERE
@expect = [ [Virtual::MethodEnter,Virtual::NewMessage,Virtual::Set,Virtual::Set,
@expect = [ [Virtual::MethodEnter,Register::GetSlot,Virtual::Set,Virtual::Set,
Virtual::Set,Virtual::Set,Virtual::MethodCall] ,[Virtual::MethodReturn] ]
check
end

View File

@ -35,7 +35,7 @@ class Object
end
end
HERE
@expect = [[Virtual::MethodEnter,Virtual::NewMessage,Virtual::Set,Virtual::Set,Virtual::MethodCall] ,
@expect = [[Virtual::MethodEnter,Register::GetSlot,Virtual::Set,Virtual::Set,Virtual::MethodCall] ,
[Virtual::MethodReturn]]
check

View File

@ -11,7 +11,7 @@ class Object
end
end
HERE
@expect = [[Virtual::MethodEnter,Virtual::Set,Virtual::NewMessage,Virtual::Set,
@expect = [[Virtual::MethodEnter,Virtual::Set,Register::GetSlot,Virtual::Set,
Virtual::Set,Virtual::MethodCall] ,[Virtual::MethodReturn]]
check
end

View File

@ -51,7 +51,7 @@ class Object
end
end
HERE
@expect = [ [Virtual::MethodEnter,Virtual::NewMessage,Virtual::Set,Virtual::Set,
@expect = [ [Virtual::MethodEnter,Register::GetSlot,Virtual::Set,Virtual::Set,
Virtual::Set,Virtual::Set,Virtual::MethodCall] ,[Virtual::MethodReturn] ]
check
end

View File

@ -41,7 +41,7 @@ class Object
end
end
HERE
@expect = [[MethodEnter , NewMessage, Set, Set , Set, Set, MethodCall],[MethodReturn]]
@expect = [[MethodEnter , Register::GetSlot, Set, Set , Set, Set, MethodCall],[MethodReturn]]
check
end

View File

@ -11,7 +11,7 @@ class Object
end
end
HERE
@expect = [ [Virtual::MethodEnter,Virtual::Set,Virtual::NewMessage,Virtual::Set,
@expect = [ [Virtual::MethodEnter,Virtual::Set,Register::GetSlot,Virtual::Set,
Virtual::Set,Virtual::MethodCall] ,[Virtual::MethodReturn] ]
check
end

View File

@ -27,7 +27,7 @@ class Object
end
end
HERE
@expect = [[Virtual::MethodEnter,Virtual::NewMessage,Virtual::Set,Virtual::Set,
@expect = [[Virtual::MethodEnter,Register::GetSlot,Virtual::Set,Virtual::Set,
Virtual::Set,Virtual::Set,Virtual::MethodCall] , [Virtual::MethodReturn]]
check
end

View File

@ -24,7 +24,7 @@ class Object
end
end
HERE
@expect = [ [Virtual::MethodEnter,Virtual::NewMessage,Virtual::Set,Virtual::Set,
@expect = [ [Virtual::MethodEnter,Register::GetSlot,Virtual::Set,Virtual::Set,
Virtual::Set,Virtual::Set,Virtual::MethodCall] ,[Virtual::MethodReturn] ]
check
end