diff --git a/lib/builtin/kernel.rb b/lib/builtin/kernel.rb index 3a4ac0dd..42852268 100644 --- a/lib/builtin/kernel.rb +++ b/lib/builtin/kernel.rb @@ -15,7 +15,7 @@ module Builtin clazz = Virtual::BootSpace.space.get_or_create_class :Kernel method = clazz.resolve_method :main me = Virtual::Self.new(Virtual::Reference) - code = Virtual::Set.new(Virtual::NewSelf.new(me.type), me) + code = Virtual::Set.new(Virtual::Self.new(me.type), me) function.add_code(code) function.add_code Virtual::FunctionCall.new(method) return function diff --git a/lib/register/set_implementation.rb b/lib/register/set_implementation.rb index fa59bed2..a260bde1 100644 --- a/lib/register/set_implementation.rb +++ b/lib/register/set_implementation.rb @@ -6,9 +6,13 @@ module Register def run block block.codes.dup.each do |code| next unless code.is_a? Virtual::Set + tmp = RegisterReference.new(Virtual::Message::TMP_REG) if( code.to.is_a? Virtual::NewMessageSlot) - to = RegisterReference.new(:r0) - tmp = RegisterReference.new(:r5) + to = Virtual::Message::NEW_MESSAGE_REG + move = RegisterMachine.instance.ldr( to , tmp , code.to.index ) + block.replace(code , move ) + elsif( code.to.is_a? Virtual::Self) + to = RegisterReference.new(Virtual::Message::SELF_REG) move = RegisterMachine.instance.ldr( to , tmp , code.to.index ) block.replace(code , move ) else diff --git a/lib/virtual/message.rb b/lib/virtual/message.rb index b911e351..d17251b4 100644 --- a/lib/virtual/message.rb +++ b/lib/virtual/message.rb @@ -24,6 +24,13 @@ module Virtual EXCEPTION = 3 SELF = 4 + SELF_REG = :r0 + MESSAGE_REG = :r1 + FRAME_REG = :r2 + NEW_MESSAGE_REG = :r3 + + TMP_REG = :r4 + def initialize me , normal , exceptional @me = me @next_normal = normal