fix block initialization

This commit is contained in:
Torsten Ruger
2015-07-26 18:28:39 +03:00
parent e7b8f2fcc8
commit f91c9fabe8
3 changed files with 4 additions and 3 deletions

View File

@ -46,7 +46,7 @@ module Virtual
# just passing the method object in for Instructions to make decisions (later)
def initialize method , return_type = Virtual::Unknown
# first block we have to create with .new , as new_block assumes a current
enter = Block.new( "enter" , self ).add_code(MethodEnter.new( method ))
enter = Block.new( "enter" , method ).add_code(MethodEnter.new( method ))
@return_type = return_type
@blocks = [enter]
@current = enter
@ -110,7 +110,7 @@ module Virtual
# In code generation , the new_block is written after this one, ie zero runtime cost
# This does _not_ change the insertion point, that has do be done with insert_at(block)
def new_block new_name
new_b = Block.new( new_name , self )
new_b = Block.new( new_name , @blocks.first.method )
index = @blocks.index( @current )
@blocks.insert( index + 1 , new_b ) # + one because we want the ne after the insert_at
return new_b