2015-10-22 17:16:29 +02:00
|
|
|
module Register
|
2014-07-24 20:56:31 +02:00
|
|
|
# So when an object calls a method, or sends a message, this is what it sends: a Message
|
2014-07-16 23:53:19 +02:00
|
|
|
|
2015-05-30 11:20:39 +02:00
|
|
|
# A message contains the sender, return and exceptional return addresses,the arguments,
|
|
|
|
# and a slot for the frame.
|
2014-07-16 23:53:19 +02:00
|
|
|
|
2015-05-30 11:20:39 +02:00
|
|
|
# As such it is a very run-time object, deep in the machinery as it were, and does not have
|
|
|
|
# meaningful methods you could call at compile time.
|
2014-07-16 23:53:19 +02:00
|
|
|
|
2015-05-30 11:20:39 +02:00
|
|
|
# The methods that are there, are nevertheless meant to be called at compile time and generate
|
|
|
|
# code, rather than executing it.
|
2015-05-05 14:11:09 +02:00
|
|
|
|
2014-07-16 23:53:19 +02:00
|
|
|
# The caller creates the Message and passes control to the receiver's method
|
|
|
|
|
2015-05-30 11:20:39 +02:00
|
|
|
# The receiver create a new Frame to hold local and temporary variables and (later) creates
|
|
|
|
# default values for arguments that were not passed
|
2014-07-16 23:53:19 +02:00
|
|
|
|
2015-05-30 11:20:39 +02:00
|
|
|
# How the actual finding of the method takes place (acording to the ruby rules) is not simple,
|
|
|
|
# but as there is a guaranteed result (be it method_missing) it does not matter to the passing
|
|
|
|
# mechanism described
|
2014-07-16 23:53:19 +02:00
|
|
|
|
|
|
|
# During compilation Message and frame objects are created to do type analysis
|
|
|
|
|
|
|
|
class Message
|
2014-09-11 18:00:14 +02:00
|
|
|
|
2014-07-16 23:53:19 +02:00
|
|
|
def initialize me , normal , exceptional
|
|
|
|
@me = me
|
|
|
|
@next_normal = normal
|
|
|
|
@next_exception = exceptional
|
2014-07-24 20:56:31 +02:00
|
|
|
@arguments = arguments
|
2014-07-16 23:53:19 +02:00
|
|
|
# a frame represents the local and temporary variables at a point in the program.
|
2014-07-24 20:56:31 +02:00
|
|
|
@frame = nil
|
2014-07-16 23:53:19 +02:00
|
|
|
end
|
2014-07-24 20:56:31 +02:00
|
|
|
attr_reader :me, :next_normal, :next_exception, :arguments , :frame
|
2014-07-16 23:53:19 +02:00
|
|
|
|
2015-05-05 14:11:09 +02:00
|
|
|
#
|
2014-07-16 23:53:19 +02:00
|
|
|
end
|
|
|
|
end
|