fix namespacing and remove indexes

This commit is contained in:
Torsten Ruger 2015-06-29 20:58:52 +03:00
parent 553f30c874
commit a03dcecbbd

View File

@ -1,21 +1,24 @@
#TODO: get rid of this. along the Register.* functions
Virtual::MessageSlot.class_eval do
def reg
Register::RegisterReference.message_reg
Register.message_reg
end
end
Virtual::FrameSlot.class_eval do
def reg
Register::RegisterReference.frame_reg
Register.frame_reg
end
end
Virtual::SelfSlot.class_eval do
def reg
Register::RegisterReference.self_reg
Register.self_reg
end
end
Virtual::NextMessageSlot.class_eval do
Virtual::NewMessageSlot.class_eval do
def reg
Register::RegisterReference.new_message_reg
Register.new_message_reg
end
end
@ -30,17 +33,31 @@ module Register
# resolve the register and offset that we need to move to
to = code.to.reg
# need a temporay place because of indexed load/store
tmp = RegisterReference.tmp_reg
tmp = Register.tmp_reg
# for constants we have to "move" the constants value
if( code.from.is_a?(Parfait::Value) or code.from.is_a?(Symbol))
move1 = LoadConstant.new( code.from , tmp )
else # while otherwise we "load"
move1 = GetSlot.new( code.from.reg , code.from.index , tmp )
move1 = GetSlot.new( code.from.reg , get_index(code.from) , tmp )
end
move2 = SetSlot.new( tmp , to , code.to.index )
move2 = SetSlot.new( tmp , to , get_index(code.to) )
block.replace(code , [move1,move2] )
end
end
def get_index from
case from
when Virtual::Self , Virtual::NewSelf
return Register.resolve_index( :message , :receiver)
when Virtual::MessageName , Virtual::NewMessageName
return Register.resolve_index( :message , :name)
when Virtual::NewArgSlot
puts "from: #{from.index}"
return Register.resolve_index( :message , :name) + 1 + from.index
else
raise "not implemented for #{from.class}"
end
end
end
Virtual.machine.add_pass "Register::SetImplementation"
end