save and restore the right registers

This commit is contained in:
Torsten Ruger
2014-05-22 21:55:17 +03:00
parent 4f0b769e82
commit 86e73bf1ba
5 changed files with 22 additions and 17 deletions

View File

@ -67,6 +67,16 @@ module Vm
l
end
def save_locals context , into
save = args.collect{|a| a.register } + @locals.collect{|l| l.register}
into.push save
end
def restore_locals context , into
restore = args.collect{|a| a.register } + @locals.collect{|l| l.register}
into.pop restore
end
def new_block name
block = Block.new(name , self)
@blocks << block

View File

@ -59,6 +59,7 @@ module Vm
end
def initialize reg
@register = reg
raise inspect if reg == nil
end
def length
4