Class: Semantic::Edges

Inherits:
Array
  • Object
show all
Defined in:
../lib/semantic_edges.rb

Overview

This class holds AttrEdge edges of the semantic graph (ie. all pending semantic functions waiting for the arguments to be computed).

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) reduce_batch(edges, attr_hash)

Compute all AttrEdge edges given that { AttrKey => value } contains attribute values. Return new { AttrKey => value } hash with computed results, remove computed edges.



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File '../lib/semantic_edges.rb', line 68

def Edges.reduce_batch( edges, attr_hash )
  
  edges.each { |e| e.substitute_deps( attr_hash ) }    

  new_hash = {}
  loop do

    removal = []
    edges.each do |e|

      e.substitute_deps( new_hash )
      next unless e.is_executable?

      new_hash[ e.result ] = e.exec_func 
      removal << e
    end
    
    break if removal.empty?
    removal.each { |e| edges.delete e }     

  end

  new_hash
end

Instance Method Details

- (Object) reduce_batch(attr_hash)

Compute all internal AttrEdge edges given that { AttrKey => value } contains attribute values. Return new { AttrKey => value } hash with computed results, remove computed internal edges.



62
63
64
# File '../lib/semantic_edges.rb', line 62

def reduce_batch( attr_hash )
  Edges.reduce_batch( self, attr_hash )
end