fix block initialization
This commit is contained in:
parent
e7b8f2fcc8
commit
f91c9fabe8
@ -12,6 +12,7 @@ module Virtual
|
|||||||
def initialize(name , method )
|
def initialize(name , method )
|
||||||
super()
|
super()
|
||||||
@method = method
|
@method = method
|
||||||
|
raise "Method is not Method, but #{method.class}" unless method == :dummy or method.is_a?(Parfait::Method)
|
||||||
@name = name.to_sym
|
@name = name.to_sym
|
||||||
@branch = nil
|
@branch = nil
|
||||||
@codes = []
|
@codes = []
|
||||||
|
@ -123,7 +123,7 @@ module Virtual
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
boot_parfait!
|
boot_parfait!
|
||||||
@init = Block.new("init",nil)
|
@init = Block.new("init", :dummy )
|
||||||
@init.add_code Virtual::VirtualMain.new( self.space.get_init )
|
@init.add_code Virtual::VirtualMain.new( self.space.get_init )
|
||||||
@booted = true
|
@booted = true
|
||||||
self
|
self
|
||||||
|
@ -46,7 +46,7 @@ module Virtual
|
|||||||
# just passing the method object in for Instructions to make decisions (later)
|
# just passing the method object in for Instructions to make decisions (later)
|
||||||
def initialize method , return_type = Virtual::Unknown
|
def initialize method , return_type = Virtual::Unknown
|
||||||
# first block we have to create with .new , as new_block assumes a current
|
# 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
|
@return_type = return_type
|
||||||
@blocks = [enter]
|
@blocks = [enter]
|
||||||
@current = enter
|
@current = enter
|
||||||
@ -110,7 +110,7 @@ module Virtual
|
|||||||
# In code generation , the new_block is written after this one, ie zero runtime cost
|
# 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)
|
# This does _not_ change the insertion point, that has do be done with insert_at(block)
|
||||||
def new_block new_name
|
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 )
|
index = @blocks.index( @current )
|
||||||
@blocks.insert( index + 1 , new_b ) # + one because we want the ne after the insert_at
|
@blocks.insert( index + 1 , new_b ) # + one because we want the ne after the insert_at
|
||||||
return new_b
|
return new_b
|
||||||
|
Loading…
Reference in New Issue
Block a user