more on set

This commit is contained in:
Torsten Ruger 2014-09-11 21:26:22 +03:00
parent 1d33c03537
commit b7e0d3fba4
3 changed files with 14 additions and 3 deletions

View File

@ -15,7 +15,7 @@ module Builtin
clazz = Virtual::BootSpace.space.get_or_create_class :Kernel clazz = Virtual::BootSpace.space.get_or_create_class :Kernel
method = clazz.resolve_method :main method = clazz.resolve_method :main
me = Virtual::Self.new(Virtual::Reference) 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(code)
function.add_code Virtual::FunctionCall.new(method) function.add_code Virtual::FunctionCall.new(method)
return function return function

View File

@ -6,9 +6,13 @@ module Register
def run block def run block
block.codes.dup.each do |code| block.codes.dup.each do |code|
next unless code.is_a? Virtual::Set next unless code.is_a? Virtual::Set
tmp = RegisterReference.new(Virtual::Message::TMP_REG)
if( code.to.is_a? Virtual::NewMessageSlot) if( code.to.is_a? Virtual::NewMessageSlot)
to = RegisterReference.new(:r0) to = Virtual::Message::NEW_MESSAGE_REG
tmp = RegisterReference.new(:r5) 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 ) move = RegisterMachine.instance.ldr( to , tmp , code.to.index )
block.replace(code , move ) block.replace(code , move )
else else

View File

@ -24,6 +24,13 @@ module Virtual
EXCEPTION = 3 EXCEPTION = 3
SELF = 4 SELF = 4
SELF_REG = :r0
MESSAGE_REG = :r1
FRAME_REG = :r2
NEW_MESSAGE_REG = :r3
TMP_REG = :r4
def initialize me , normal , exceptional def initialize me , normal , exceptional
@me = me @me = me
@next_normal = normal @next_normal = normal