extracting some of the calling into own instructions
This commit is contained in:
29
lib/mom/argument_transfer.rb
Normal file
29
lib/mom/argument_transfer.rb
Normal file
@ -0,0 +1,29 @@
|
||||
module Mom
|
||||
|
||||
# Transering the arguments from the current frame into the next frame
|
||||
#
|
||||
# This could be _done_ at this level, and in fact used to be.
|
||||
# The instructions was introduced to
|
||||
# 1. make optimisations easier
|
||||
# 2. localise the inevitable change
|
||||
#
|
||||
# 1. The optimal implementation for this loads old and new frames into registers
|
||||
# and does a whole bunch of transfers
|
||||
# But if we do individual SlotMoves here, each one has to load the frames,
|
||||
# thus making advanced analysis/optimisation neccessary to achieve the same effect.
|
||||
#
|
||||
# 2. Closures will have to have access to variables after the frame goes out of scope
|
||||
# and in fact be able to change the parents variables. This design does not allow for
|
||||
# this, and so will have to be change in the not so distant future.
|
||||
#
|
||||
class ArgumentTransfer < Instruction
|
||||
|
||||
attr_reader :receiver , :arguments
|
||||
|
||||
def initialize( receiver,arguments )
|
||||
@receiver , @arguments = receiver , arguments
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
@ -24,4 +24,6 @@ require_relative "truth_check"
|
||||
require_relative "jump"
|
||||
require_relative "slot_load"
|
||||
require_relative "return_sequence"
|
||||
require_relative "message_setup"
|
||||
require_relative "argument_transfer"
|
||||
require_relative "statement"
|
||||
|
22
lib/mom/message_setup.rb
Normal file
22
lib/mom/message_setup.rb
Normal file
@ -0,0 +1,22 @@
|
||||
module Mom
|
||||
|
||||
# Preamble when entering the method body.
|
||||
# Acquiring the message basically.
|
||||
#
|
||||
# Currently messages are hardwired as a linked list,
|
||||
# but this does not account for continuations or closures and
|
||||
# so will have to be changed.
|
||||
#
|
||||
# With the current setup this maps to a single SlotMove, ie 2 risc Instructions
|
||||
# But clearer this way.
|
||||
#
|
||||
class MessageSetup < Instruction
|
||||
attr_reader :method
|
||||
|
||||
def initialize(method)
|
||||
@method = method
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
Reference in New Issue
Block a user