more constants for slots

This commit is contained in:
Torsten Ruger 2014-09-20 17:06:11 +03:00
parent 4ad10d3678
commit 3d5eb685a1
3 changed files with 23 additions and 15 deletions

View File

@ -7,7 +7,7 @@ module Register
# save return register and create a new frame # save return register and create a new frame
to = RegisterReference.new(:r0) # message base to = RegisterReference.new(:r0) # message base
pc = RegisterReference.new(:pc) pc = RegisterReference.new(:pc)
move1 = RegisterMachine.instance.str( pc , to , Virtual::Slot::RETURN ) move1 = RegisterMachine.instance.str( pc , to , Virtual::Slot::MESSAGE_RETURN_VALUE )
block.replace(code , [move1] ) block.replace(code , [move1] )
end end
end end

View File

@ -6,7 +6,7 @@ module 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)
message = RegisterReference.new(:r0) message = RegisterReference.new(:r0)
pc = RegisterReference.new(:pc) pc = RegisterReference.new(:pc)
move1 = RegisterMachine.instance.ldr( pc ,message , Virtual::Slot::RETURN ) move1 = RegisterMachine.instance.ldr( pc ,message , Virtual::Slot::MESSAGE_RETURN_VALUE )
block.replace(code , [move1] ) block.replace(code , [move1] )
end end
end end

View File

@ -9,11 +9,19 @@ module Virtual
# additionally frame, self and return are slots in Message and NewMessage # additionally frame, self and return are slots in Message and NewMessage
class Slot class Slot
RETURN = 0 MESSAGE_REGISTER = :r0
SELF = 1 SELF_REGISTER = :r1
FRAME = 2 FRAME_REGISTER = :r2
NAME = 3 NEW_MESSAGE_REGISTER = :r3
MESSAGE_PAYLOAD = 4
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
attr_accessor :index , :type , :value attr_accessor :index , :type , :value
private #abstract base class private #abstract base class
@ -26,7 +34,7 @@ module Virtual
class MessageSlot < Slot class MessageSlot < Slot
def initialize index , type = Mystery , value = nil def initialize index , type = Mystery , value = nil
super(index + MESSAGE_PAYLOAD ,type , value ) super(index ,type , value )
end end
end end
class FrameSlot < Slot class FrameSlot < Slot
@ -41,39 +49,39 @@ module Virtual
end end
class NewMessageSlot < Slot class NewMessageSlot < Slot
def initialize index , type = Mystery, value = nil def initialize index , type = Mystery, value = nil
super(index + MESSAGE_PAYLOAD , type , value ) super(index , type , value )
end end
end end
class Return < MessageSlot class Return < MessageSlot
def initialize type = Mystery, value = nil def initialize type = Mystery, value = nil
super( RETURN - MESSAGE_PAYLOAD, type , value ) super( MESSAGE_RETURN_VALUE , type , value )
end end
end end
class Self < MessageSlot class Self < MessageSlot
def initialize type = Mystery, value = nil def initialize type = Mystery, value = nil
super( SELF - MESSAGE_PAYLOAD , type , value ) super( MESSAGE_SELF , type , value )
end end
end end
class Name < MessageSlot class Name < MessageSlot
def initialize type = Mystery, value = nil def initialize type = Mystery, value = nil
super( NAME - MESSAGE_PAYLOAD , type , value ) super( MESSAGE_NAME , type , value )
end end
end end
class NewReturn < NewMessageSlot class NewReturn < NewMessageSlot
def initialize type = Mystery, value = nil def initialize type = Mystery, value = nil
super( RETURN - MESSAGE_PAYLOAD, type , value ) super( MESSAGE_RETURN_VALUE, type , value )
end end
end end
class NewSelf < NewMessageSlot class NewSelf < NewMessageSlot
def initialize type = Mystery, value = nil def initialize type = Mystery, value = nil
super( SELF - MESSAGE_PAYLOAD , type , value ) super( MESSAGE_SELF , type , value )
end end
end end
class NewName < NewMessageSlot class NewName < NewMessageSlot
def initialize type = Mystery, value = nil def initialize type = Mystery, value = nil
super( NAME - MESSAGE_PAYLOAD , type , value ) super( MESSAGE_NAME, type , value )
end end
end end