From e9fc8ac6aa13c9b832277ff80e6243a5ead9098e Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Tue, 10 Jun 2014 18:51:27 +0300 Subject: [PATCH] making the third arg of block init explicit (not optional) --- lib/vm/block.rb | 4 +++- lib/vm/boot_space.rb | 6 +++--- lib/vm/function.rb | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/vm/block.rb b/lib/vm/block.rb index 73f09b77..1946ba08 100644 --- a/lib/vm/block.rb +++ b/lib/vm/block.rb @@ -20,7 +20,7 @@ module Vm class Block < Code - def initialize(name , function , next_block = nil) + def initialize(name , function , next_block ) super() @function = function @name = name.to_sym @@ -138,12 +138,14 @@ module Vm end private + # helper for determining reachable blocks def add_next ret return if @next.nil? return if ret.include? @next ret << @next ret + @next.reachable end + # helper for determining reachable blocks def add_branch ret return if @branch.nil? return if ret.include? @branch diff --git a/lib/vm/boot_space.rb b/lib/vm/boot_space.rb index 3418ab41..7a6c1aa2 100644 --- a/lib/vm/boot_space.rb +++ b/lib/vm/boot_space.rb @@ -33,10 +33,10 @@ module Vm @context.current_class = get_or_create_class :Object #global objects (data) @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 = Block.new("main",nil) - @exit = Core::Kernel::main_exit Vm::Block.new("main_exit",nil) + @main = Block.new("main",nil,nil) + @exit = Core::Kernel::main_exit Vm::Block.new("main_exit",nil,nil) boot_classes end attr_reader :context , :main , :classes , :entry , :exit diff --git a/lib/vm/function.rb b/lib/vm/function.rb index ac90d488..5ddbf129 100644 --- a/lib/vm/function.rb +++ b/lib/vm/function.rb @@ -48,7 +48,7 @@ module Vm end end 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) @body = Block.new("body", self , @return) @entry = Core::Kernel::function_entry( Vm::Block.new("entry" , self , @body) ,name )