2014-08-20 16:14:52 +02:00
|
|
|
module Virtual
|
|
|
|
# Slots are named, or rather indexed, storage locations that are typed.
|
|
|
|
# Four of those locations exist and those correspond to subclasses:
|
|
|
|
# - the message that has been received: MessageSlot
|
|
|
|
# - the frame of the method that is executing (local variables): FrameSlot
|
|
|
|
# - self as an object: SelfSlot
|
|
|
|
# - a message that will be sent, NewMessageSlot
|
|
|
|
|
|
|
|
# additionally frame, self and return are slots in Message and NewMessage
|
|
|
|
|
|
|
|
class Slot < Value
|
|
|
|
RETURN = 0
|
|
|
|
SELF = 1
|
2014-08-21 16:46:12 +02:00
|
|
|
FRAME = 2
|
|
|
|
NAME = 3
|
|
|
|
MESSAGE_PAYLOAD = 4
|
2014-08-20 16:14:52 +02:00
|
|
|
|
2014-09-15 11:08:37 +02:00
|
|
|
attr_accessor :index , :type , :value
|
2014-08-20 16:14:52 +02:00
|
|
|
private #abstract base class
|
2014-09-15 11:08:37 +02:00
|
|
|
def initialize index , type , value
|
2014-08-20 16:14:52 +02:00
|
|
|
@index = index
|
|
|
|
@type = type
|
2014-09-15 11:08:37 +02:00
|
|
|
@value = value
|
2014-08-20 16:14:52 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class MessageSlot < Slot
|
2014-09-15 11:08:37 +02:00
|
|
|
def initialize index , type = Mystery , value = nil
|
|
|
|
super(index + MESSAGE_PAYLOAD ,type , value )
|
2014-08-20 16:14:52 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
class FrameSlot < Slot
|
2014-09-15 11:08:37 +02:00
|
|
|
def initialize index , type = Mystery, value = nil
|
2014-08-20 16:14:52 +02:00
|
|
|
super
|
|
|
|
end
|
|
|
|
end
|
|
|
|
class SelfSlot < Slot
|
2014-09-15 11:08:37 +02:00
|
|
|
def initialize index , type = Mystery, value = nil
|
2014-08-20 16:14:52 +02:00
|
|
|
super
|
|
|
|
end
|
|
|
|
end
|
|
|
|
class NewMessageSlot < Slot
|
2014-09-15 11:08:37 +02:00
|
|
|
def initialize index , type = Mystery, value = nil
|
|
|
|
super(index + MESSAGE_PAYLOAD , type , value )
|
2014-08-20 16:14:52 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Return < MessageSlot
|
2014-09-15 11:08:37 +02:00
|
|
|
def initialize type = Mystery, value = nil
|
|
|
|
super( RETURN - MESSAGE_PAYLOAD, type , value )
|
2014-08-20 16:14:52 +02:00
|
|
|
end
|
|
|
|
end
|
2014-08-21 16:46:12 +02:00
|
|
|
class Self < MessageSlot
|
2014-09-15 11:08:37 +02:00
|
|
|
def initialize type = Mystery, value = nil
|
|
|
|
super( SELF - MESSAGE_PAYLOAD , type , value )
|
2014-08-20 16:14:52 +02:00
|
|
|
end
|
|
|
|
end
|
2014-08-21 16:46:12 +02:00
|
|
|
class Name < MessageSlot
|
2014-09-15 11:08:37 +02:00
|
|
|
def initialize type = Mystery, value = nil
|
|
|
|
super( NAME - MESSAGE_PAYLOAD , type , value )
|
2014-08-21 16:46:12 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class NewReturn < NewMessageSlot
|
2014-09-15 11:08:37 +02:00
|
|
|
def initialize type = Mystery, value = nil
|
|
|
|
super( RETURN - MESSAGE_PAYLOAD, type , value )
|
2014-08-20 16:14:52 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
class NewSelf < NewMessageSlot
|
2014-09-15 11:08:37 +02:00
|
|
|
def initialize type = Mystery, value = nil
|
|
|
|
super( SELF - MESSAGE_PAYLOAD , type , value )
|
2014-08-21 16:46:12 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
class NewName < NewMessageSlot
|
2014-09-15 11:08:37 +02:00
|
|
|
def initialize type = Mystery, value = nil
|
|
|
|
super( NAME - MESSAGE_PAYLOAD , type , value )
|
2014-08-20 16:14:52 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|