From e7bb774da06adade67225103f3b6d05b10879a85 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sun, 8 Jun 2014 00:56:15 +0300 Subject: [PATCH] fix block insert ordering with depth > 1 --- lib/vm/block.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/vm/block.rb b/lib/vm/block.rb index 8473940d..2865bcfd 100644 --- a/lib/vm/block.rb +++ b/lib/vm/block.rb @@ -38,17 +38,19 @@ module Vm self end alias :<< :add_code - alias :a :add_code # create a new linear block after this block. Linear means there is no brach needed from this one # to the new one. Usually the new one just serves as jump address for a control statement # In code generation (assembly) , new new_block is written after this one, ie zero runtime cost - def new_block name - new_b = Block.new( name , @function , @next ) - @next = new_b + def new_block new_name + new_b = Block.new( new_name , @function , @insert_at.next ) + @insert_at.set_next new_b return new_b end + def set_next next_b + @next = next_b + end # when control structures create new blocks (with new_block) control continues at some new block the # the control structure creates. # Example: while, needs 2 extra blocks