lib/ruote/dboard/mutation.rb
# Look for mutation points in a concurrent expression (concurrence or
# concurrent-iterator).
#
Look for mutation points in a concurrent expression (concurrence or
concurrent-iterator).
Look for mutation points in a concurrent expression ( concurrence or concurrent - iterator ) .
def walk_concurrence(fexp, ftree, tree)
      if ftree[2].size != tree[2].size
         that's lazy, but why not?
         we could add/apply a new child...
        register(MutationPoint.new(fexp.fei, tree, :re_apply))
      else
         if there is a least one child that replied and whose
         tree must be changes, then re-apply the whole concurrence
         else try to re-apply only the necessary branch (walk them)
        branches = ftree[2].zip(tree[2]).each_with_object([]) { |(ft, t), a|
           match child expressions (if not yet replied) with current tree (ft)
           and desired tree (t)
          cfei = fexp.children[a.size]
          cexp = cfei ? @ps.fexp(cfei) : nil
          a << [ cexp, ft, t ]
        }.select { |cexp, ft, t|
           only keep diverging branches
          ft != t
        }
        branches.each do |cexp, ft, t|
          next if cexp
           there is at least one branch that replied,
           this forces re-apply for the whole concurrence
          register(MutationPoint.new(fexp.fei, tree, :re_apply))
          return
        end
        branches.each do |cexp, ft, t|
           we're left with divering branches that haven't yet replied,
           let's walk to register the mutation point deep into it
          walk(cexp, t)
        end
      end
    end
def walk_concurrence ( fexp , ftree , tree ) if ftree [ 2 ] . size != tree [ 2 ] . size register ( MutationPoint . new ( fexp . fei , tree , :re_apply ) ) else branches = ftree [ 2 ] . zip ( tree [ 2 ] ) . each_with_object ( [ ] ) { | ( ft , t ) , a | cfei = fexp . children [ a . size ] cexp = cfei ? @ps . fexp ( cfei ) : nil a << [ cexp , ft , t ] } . select { | cexp , ft , t | ft != t } branches . each do | cexp , ft , t | next if cexp register ( MutationPoint . new ( fexp . fei , tree , :re_apply ) ) return end branches . each do | cexp , ft , t | walk ( cexp , t ) end end end
Look for mutation points in a concurrent expression (concurrence or
concurrent-iterator).
Look for mutation points in a concurrent expression ( concurrence or concurrent - iterator ) .
# # that's lazy, but why not? # # we could add/apply a new child... # # if there is a least one child that replied and whose # tree must be changes, then re-apply the whole concurrence # # else try to re-apply only the necessary branch (walk them) # # match child expressions (if not yet replied) with current tree (ft) # and desired tree (t) # # # # only keep diverging branches # # there is at least one branch that replied, # this forces re-apply for the whole concurrence # # we're left with divering branches that haven't yet replied, # let's walk to register the mutation point deep into it
fexp
ftree
tree