better names for index constants

This commit is contained in:
Torsten Ruger 2015-06-21 21:09:15 +03:00
parent 836089a249
commit 9c21f4274d
5 changed files with 28 additions and 24 deletions

View File

@ -16,7 +16,7 @@ module Register
# move the current new_message to message
new_codes << RegisterTransfer.new( slot::NEW_MESSAGE_REGISTER , slot::MESSAGE_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
new_codes << FunctionCall.new( code.method )
block.replace(code , new_codes )

View File

@ -8,12 +8,12 @@ module Register
# move the current message to new_message
new_codes << RegisterTransfer.new( slot::MESSAGE_REGISTER , slot::NEW_MESSAGE_REGISTER )
# 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
new_codes << GetSlot.new( slot::MESSAGE_REGISTER , Virtual::MESSAGE_SELF , slot::SELF_REGISTER )
new_codes << GetSlot.new( slot::MESSAGE_REGISTER , Virtual::MESSAGE_FRAME , slot::FRAME_REGISTER )
new_codes << GetSlot.new( slot::MESSAGE_REGISTER , Virtual::SELF_INDEX , slot::SELF_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)
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 )
end
end

View File

@ -7,7 +7,7 @@ module Virtual
new_codes = []
# save return register and create a new frame
# 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
block.replace(code , new_codes )
end

View File

@ -1,13 +1,17 @@
module Virtual
MESSAGE_CALLER = 0
MESSAGE_RETURN_ADDRESS = 1
MESSAGE_EXCEPTION_ADDRESS = 2
MESSAGE_SELF = 3
MESSAGE_NAME = 4
MESSAGE_RETURN_VALUE = 5
MESSAGE_FRAME = 6
MESSAGE_PAYLOAD = 7
#TODO : this constant approach is a bit old, from before PArfait adapter
# nowadays these are unneccessary as we can resolve the names by using the
# layout of the class. (get Class from space)
TYPE_INDEX = 0
LAYOUT_INDEX = 1
CALLER_INDEX = 2
RETURN_INDEX = 3
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
#
@ -23,24 +27,24 @@ module Virtual
# named classes exist for slots that often accessed
# Return is the MessageSlot(MESSAGE_RETURN_VALUE)
# Return is the MessageSlot(RETURN_INDEX)
class Return < MessageSlot
def initialize type = Unknown, value = nil
super( MESSAGE_RETURN_VALUE , type , value )
super( RETURN_INDEX , type , value )
end
end
# Self is the MessageSlot(MESSAGE_SELF)
# Self is the MessageSlot(SELF_INDEX)
class Self < MessageSlot
def initialize type = Unknown, value = nil
super( MESSAGE_SELF , type , value )
super( SELF_INDEX , type , value )
end
end
# MessageName of the current message
class MessageName < MessageSlot
def initialize type = Unknown, value = nil
super( MESSAGE_NAME , type , value )
super( NAME_INDEX , type , value )
end
end
end

View File

@ -14,24 +14,24 @@ module Virtual
# named classes exist for slots that often accessed
# NextReturn is the NextMessageSlot(MESSAGE_RETURN_VALUE)
# NextReturn is the NextMessageSlot(RETURN_INDEX)
class NextReturn < NextMessageSlot
def initialize type = Unknown, value = nil
super( MESSAGE_RETURN_VALUE, type , value )
super( RETURN_INDEX, type , value )
end
end
# NextSelf is the NextMessageSlot(MESSAGE_SELF)
# NextSelf is the NextMessageSlot(SELF_INDEX)
class NextSelf < NextMessageSlot
def initialize type = Unknown, value = nil
super( MESSAGE_SELF , type , value )
super( SELF_INDEX , type , value )
end
end
# NextMessageName of the next message
class NextMessageName < NextMessageSlot
def initialize type = Unknown, value = nil
super( MESSAGE_NAME, type , value )
super( NAME_INDEX, type , value )
end
end
end