Class: FastRuby::Reductor
- Defined in:
- lib/fastruby/builder/reductor.rb,
lib/fastruby/modules/reductor/for.rb,
lib/fastruby/modules/reductor/case.rb,
lib/fastruby/modules/reductor/nontree.rb,
lib/fastruby/modules/reductor/recursive.rb,
lib/fastruby/modules/reductor/fastruby_flag.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.reduce_for(ntype, options = {}, &blk) ⇒ Object
28 29 30 |
# File 'lib/fastruby/builder/reductor.rb', line 28 def self.reduce_for(ntype, = {}, &blk) define_method_handler(:reduce, , &blk).condition{|tree| tree.respond_to?(:node_type) && tree.node_type == ntype} end |
Instance Method Details
#call(*args) ⇒ Object
32 33 34 |
# File 'lib/fastruby/builder/reductor.rb', line 32 def call(*args) reduce *args end |
#when_array_to_if(array, temporal_var_name) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/fastruby/modules/reductor/case.rb', line 27 def when_array_to_if(array, temporal_var_name) if array.size == 1 array[0] || fs(:nil) else first_when_tree = array[0] comparers = first_when_tree[1][1..-1] condition_tree = fs(:or) comparers.each do |st| condition_tree << fs(:call, st, :===, fs(:arglist, fs(:lvar, temporal_var_name))) end fs(:if, condition_tree, first_when_tree[2], when_array_to_if(array[1..-1], temporal_var_name) ) end end |