better names for index constants
This commit is contained in:
parent
836089a249
commit
9c21f4274d
@ -16,7 +16,7 @@ module Register
|
|||||||
# move the current new_message to message
|
# move the current new_message to message
|
||||||
new_codes << RegisterTransfer.new( slot::NEW_MESSAGE_REGISTER , slot::MESSAGE_REGISTER )
|
new_codes << RegisterTransfer.new( slot::NEW_MESSAGE_REGISTER , slot::MESSAGE_REGISTER )
|
||||||
# "roll out" self into its register
|
# "roll out" self into its register
|
||||||
new_codes << GetSlot.new( slot::SELF_REGISTER ,slot::MESSAGE_REGISTER , Virtual::MESSAGE_SELF )
|
new_codes << GetSlot.new( slot::SELF_REGISTER ,slot::MESSAGE_REGISTER , Virtual::SELF_INDEX )
|
||||||
# do the register call
|
# do the register call
|
||||||
new_codes << FunctionCall.new( code.method )
|
new_codes << FunctionCall.new( code.method )
|
||||||
block.replace(code , new_codes )
|
block.replace(code , new_codes )
|
||||||
|
@ -8,12 +8,12 @@ module Register
|
|||||||
# move the current message to new_message
|
# move the current message to new_message
|
||||||
new_codes << RegisterTransfer.new( slot::MESSAGE_REGISTER , slot::NEW_MESSAGE_REGISTER )
|
new_codes << RegisterTransfer.new( slot::MESSAGE_REGISTER , slot::NEW_MESSAGE_REGISTER )
|
||||||
# and restore the message from saved value in new_message
|
# and restore the message from saved value in new_message
|
||||||
new_codes << GetSlot.new( slot::NEW_MESSAGE_REGISTER , Virtual::MESSAGE_CALLER , slot::MESSAGE_REGISTER)
|
new_codes << GetSlot.new( slot::NEW_MESSAGE_REGISTER , Virtual::CALLER_INDEX , slot::MESSAGE_REGISTER)
|
||||||
# "roll out" self and frame into their registers
|
# "roll out" self and frame into their registers
|
||||||
new_codes << GetSlot.new( slot::MESSAGE_REGISTER , Virtual::MESSAGE_SELF , slot::SELF_REGISTER )
|
new_codes << GetSlot.new( slot::MESSAGE_REGISTER , Virtual::SELF_INDEX , slot::SELF_REGISTER )
|
||||||
new_codes << GetSlot.new( slot::MESSAGE_REGISTER , Virtual::MESSAGE_FRAME , slot::FRAME_REGISTER )
|
new_codes << GetSlot.new( slot::MESSAGE_REGISTER , Virtual::FRAME_INDEX , slot::FRAME_REGISTER )
|
||||||
#load the return address into pc, affecting return. (other cpus have commands for this, but not arm)
|
#load the return address into pc, affecting return. (other cpus have commands for this, but not arm)
|
||||||
new_codes << FunctionReturn.new( slot::MESSAGE_REGISTER , Virtual::MESSAGE_RETURN_ADDRESS )
|
new_codes << FunctionReturn.new( slot::MESSAGE_REGISTER , Virtual::RETURN_INDEX )
|
||||||
block.replace(code , new_codes )
|
block.replace(code , new_codes )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -7,7 +7,7 @@ module Virtual
|
|||||||
new_codes = []
|
new_codes = []
|
||||||
# save return register and create a new frame
|
# save return register and create a new frame
|
||||||
# lr is link register, ie where arm stores the return address when call is issued
|
# lr is link register, ie where arm stores the return address when call is issued
|
||||||
new_codes << Register::SaveReturn.new( Virtual::Slot::MESSAGE_REGISTER , Virtual::MESSAGE_RETURN_ADDRESS )
|
new_codes << Register::SaveReturn.new( Virtual::Slot::MESSAGE_REGISTER , Virtual::RETURN_INDEX )
|
||||||
new_codes << Virtual::NewFrame.new
|
new_codes << Virtual::NewFrame.new
|
||||||
block.replace(code , new_codes )
|
block.replace(code , new_codes )
|
||||||
end
|
end
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
module Virtual
|
module Virtual
|
||||||
|
|
||||||
MESSAGE_CALLER = 0
|
#TODO : this constant approach is a bit old, from before PArfait adapter
|
||||||
MESSAGE_RETURN_ADDRESS = 1
|
# nowadays these are unneccessary as we can resolve the names by using the
|
||||||
MESSAGE_EXCEPTION_ADDRESS = 2
|
# layout of the class. (get Class from space)
|
||||||
MESSAGE_SELF = 3
|
TYPE_INDEX = 0
|
||||||
MESSAGE_NAME = 4
|
LAYOUT_INDEX = 1
|
||||||
MESSAGE_RETURN_VALUE = 5
|
CALLER_INDEX = 2
|
||||||
MESSAGE_FRAME = 6
|
RETURN_INDEX = 3
|
||||||
MESSAGE_PAYLOAD = 7
|
EXCEPTION_INDEX = 4
|
||||||
|
SELF_INDEX = 5
|
||||||
|
NAME_INDEX = 6
|
||||||
|
FRAME_INDEX = 7
|
||||||
|
ARGUMENT_START = 8
|
||||||
|
|
||||||
# The current Message is one of four objects the virtual machine knows
|
# The current Message is one of four objects the virtual machine knows
|
||||||
#
|
#
|
||||||
@ -23,24 +27,24 @@ module Virtual
|
|||||||
|
|
||||||
# named classes exist for slots that often accessed
|
# named classes exist for slots that often accessed
|
||||||
|
|
||||||
# Return is the MessageSlot(MESSAGE_RETURN_VALUE)
|
# Return is the MessageSlot(RETURN_INDEX)
|
||||||
class Return < MessageSlot
|
class Return < MessageSlot
|
||||||
def initialize type = Unknown, value = nil
|
def initialize type = Unknown, value = nil
|
||||||
super( MESSAGE_RETURN_VALUE , type , value )
|
super( RETURN_INDEX , type , value )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Self is the MessageSlot(MESSAGE_SELF)
|
# Self is the MessageSlot(SELF_INDEX)
|
||||||
class Self < MessageSlot
|
class Self < MessageSlot
|
||||||
def initialize type = Unknown, value = nil
|
def initialize type = Unknown, value = nil
|
||||||
super( MESSAGE_SELF , type , value )
|
super( SELF_INDEX , type , value )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# MessageName of the current message
|
# MessageName of the current message
|
||||||
class MessageName < MessageSlot
|
class MessageName < MessageSlot
|
||||||
def initialize type = Unknown, value = nil
|
def initialize type = Unknown, value = nil
|
||||||
super( MESSAGE_NAME , type , value )
|
super( NAME_INDEX , type , value )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -14,24 +14,24 @@ module Virtual
|
|||||||
|
|
||||||
# named classes exist for slots that often accessed
|
# named classes exist for slots that often accessed
|
||||||
|
|
||||||
# NextReturn is the NextMessageSlot(MESSAGE_RETURN_VALUE)
|
# NextReturn is the NextMessageSlot(RETURN_INDEX)
|
||||||
class NextReturn < NextMessageSlot
|
class NextReturn < NextMessageSlot
|
||||||
def initialize type = Unknown, value = nil
|
def initialize type = Unknown, value = nil
|
||||||
super( MESSAGE_RETURN_VALUE, type , value )
|
super( RETURN_INDEX, type , value )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# NextSelf is the NextMessageSlot(MESSAGE_SELF)
|
# NextSelf is the NextMessageSlot(SELF_INDEX)
|
||||||
class NextSelf < NextMessageSlot
|
class NextSelf < NextMessageSlot
|
||||||
def initialize type = Unknown, value = nil
|
def initialize type = Unknown, value = nil
|
||||||
super( MESSAGE_SELF , type , value )
|
super( SELF_INDEX , type , value )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# NextMessageName of the next message
|
# NextMessageName of the next message
|
||||||
class NextMessageName < NextMessageSlot
|
class NextMessageName < NextMessageSlot
|
||||||
def initialize type = Unknown, value = nil
|
def initialize type = Unknown, value = nil
|
||||||
super( MESSAGE_NAME, type , value )
|
super( NAME_INDEX, type , value )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user