remove new_message instruction
This commit is contained in:
parent
c3eb295f4e
commit
3d342f7d88
@ -16,7 +16,9 @@ module Phisol
|
|||||||
end
|
end
|
||||||
## need two step process, compile and save to frame
|
## need two step process, compile and save to frame
|
||||||
# then move from frame to new message
|
# 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( me , Virtual::NewSelf.new(me.type))
|
||||||
@method.source.add_code Virtual::Set.new( name.to_sym , Virtual::NewMessageName.new(:int))
|
@method.source.add_code Virtual::Set.new( name.to_sym , Virtual::NewMessageName.new(:int))
|
||||||
compiled_args = []
|
compiled_args = []
|
||||||
|
@ -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
|
|
@ -2,7 +2,6 @@ require_relative "instruction"
|
|||||||
require_relative "register_reference"
|
require_relative "register_reference"
|
||||||
require_relative "assembler"
|
require_relative "assembler"
|
||||||
require_relative "passes/frame_implementation"
|
require_relative "passes/frame_implementation"
|
||||||
require_relative "passes/message_implementation"
|
|
||||||
require_relative "passes/set_implementation"
|
require_relative "passes/set_implementation"
|
||||||
require_relative "passes/return_implementation"
|
require_relative "passes/return_implementation"
|
||||||
require_relative "passes/call_implementation"
|
require_relative "passes/call_implementation"
|
||||||
|
@ -18,5 +18,4 @@ require_relative "instructions/method_call"
|
|||||||
require_relative "instructions/method_enter"
|
require_relative "instructions/method_enter"
|
||||||
require_relative "instructions/method_return"
|
require_relative "instructions/method_return"
|
||||||
require_relative "instructions/new_frame"
|
require_relative "instructions/new_frame"
|
||||||
require_relative "instructions/new_message"
|
|
||||||
require_relative "instructions/set"
|
require_relative "instructions/set"
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
module Virtual
|
|
||||||
|
|
||||||
class NewMessage < Instruction
|
|
||||||
end
|
|
||||||
end
|
|
@ -16,7 +16,7 @@ class Object
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
HERE
|
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] ]
|
Virtual::Set,Virtual::Set,Virtual::MethodCall] ,[Virtual::MethodReturn] ]
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
@ -35,7 +35,7 @@ class Object
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
HERE
|
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]]
|
[Virtual::MethodReturn]]
|
||||||
check
|
check
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ class Object
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
HERE
|
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]]
|
Virtual::Set,Virtual::MethodCall] ,[Virtual::MethodReturn]]
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
@ -51,7 +51,7 @@ class Object
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
HERE
|
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] ]
|
Virtual::Set,Virtual::Set,Virtual::MethodCall] ,[Virtual::MethodReturn] ]
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
@ -41,7 +41,7 @@ class Object
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
HERE
|
HERE
|
||||||
@expect = [[MethodEnter , NewMessage, Set, Set , Set, Set, MethodCall],[MethodReturn]]
|
@expect = [[MethodEnter , Register::GetSlot, Set, Set , Set, Set, MethodCall],[MethodReturn]]
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ class Object
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
HERE
|
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] ]
|
Virtual::Set,Virtual::MethodCall] ,[Virtual::MethodReturn] ]
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
@ -27,7 +27,7 @@ class Object
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
HERE
|
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]]
|
Virtual::Set,Virtual::Set,Virtual::MethodCall] , [Virtual::MethodReturn]]
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
@ -24,7 +24,7 @@ class Object
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
HERE
|
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] ]
|
Virtual::Set,Virtual::Set,Virtual::MethodCall] ,[Virtual::MethodReturn] ]
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user