making the third arg of block init explicit (not optional)
This commit is contained in:
parent
7ca3207b3e
commit
e9fc8ac6aa
@ -20,7 +20,7 @@ module Vm
|
|||||||
|
|
||||||
class Block < Code
|
class Block < Code
|
||||||
|
|
||||||
def initialize(name , function , next_block = nil)
|
def initialize(name , function , next_block )
|
||||||
super()
|
super()
|
||||||
@function = function
|
@function = function
|
||||||
@name = name.to_sym
|
@name = name.to_sym
|
||||||
@ -138,12 +138,14 @@ module Vm
|
|||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
# helper for determining reachable blocks
|
||||||
def add_next ret
|
def add_next ret
|
||||||
return if @next.nil?
|
return if @next.nil?
|
||||||
return if ret.include? @next
|
return if ret.include? @next
|
||||||
ret << @next
|
ret << @next
|
||||||
ret + @next.reachable
|
ret + @next.reachable
|
||||||
end
|
end
|
||||||
|
# helper for determining reachable blocks
|
||||||
def add_branch ret
|
def add_branch ret
|
||||||
return if @branch.nil?
|
return if @branch.nil?
|
||||||
return if ret.include? @branch
|
return if ret.include? @branch
|
||||||
|
@ -33,10 +33,10 @@ module Vm
|
|||||||
@context.current_class = get_or_create_class :Object
|
@context.current_class = get_or_create_class :Object
|
||||||
#global objects (data)
|
#global objects (data)
|
||||||
@objects = []
|
@objects = []
|
||||||
@entry = Core::Kernel::main_start Vm::Block.new("main_entry",nil)
|
@entry = Core::Kernel::main_start Vm::Block.new("main_entry",nil,nil)
|
||||||
#main gets executed between entry and exit
|
#main gets executed between entry and exit
|
||||||
@main = Block.new("main",nil)
|
@main = Block.new("main",nil,nil)
|
||||||
@exit = Core::Kernel::main_exit Vm::Block.new("main_exit",nil)
|
@exit = Core::Kernel::main_exit Vm::Block.new("main_exit",nil,nil)
|
||||||
boot_classes
|
boot_classes
|
||||||
end
|
end
|
||||||
attr_reader :context , :main , :classes , :entry , :exit
|
attr_reader :context , :main , :classes , :entry , :exit
|
||||||
|
@ -48,7 +48,7 @@ module Vm
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
set_return return_type
|
set_return return_type
|
||||||
@exit = Core::Kernel::function_exit( Vm::Block.new("exit" , self) , name )
|
@exit = Core::Kernel::function_exit( Vm::Block.new("exit" , self , nil) , name )
|
||||||
@return = Block.new("return", self , @exit)
|
@return = Block.new("return", self , @exit)
|
||||||
@body = Block.new("body", self , @return)
|
@body = Block.new("body", self , @return)
|
||||||
@entry = Core::Kernel::function_entry( Vm::Block.new("entry" , self , @body) ,name )
|
@entry = Core::Kernel::function_entry( Vm::Block.new("entry" , self , @body) ,name )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user