Class: Flor::Pro::Match

Inherits:
Case show all
Defined in:
lib/flor/pcore/match.rb

Constant Summary

Constants inherited from Flor::Procedure

Flor::Procedure::RVARS, Flor::Procedure::TRUE_ATTS

Instance Attribute Summary

Attributes inherited from Node

#message

Instance Method Summary collapse

Methods inherited from Case

#receive

Methods inherited from Flor::Procedure

[], core?, #debug_msg, #debug_tree, #end, #flank, #heap, inherited, make, names, #prepare_on_receive_last, #trigger_on_error

Methods inherited from Node

#child_id, #cnodes, #cnodes_any?, #cnodes_empty?, #deref, #descendant_of?, #domain, #exid, #fei, #from, #h, #initialize, #lookup_tree, #lookup_value, #message_or_node_payload, #nid, #node_closed?, #node_ended?, #node_open?, #node_payload, #node_payload_ret, #node_status, #node_status_flavour, #on_error_parent, #parent, #payload, #payload_ret, #point, #reheap, #to_procedure_node, #tree

Constructor Details

This class inherits a constructor from Flor::Node

Instance Method Details

#execute_child(index = 0, sub = nil, h = nil) ⇒ Object



219
220
221
222
223
224
225
226
227
# File 'lib/flor/pcore/match.rb', line 219

def execute_child(index=0, sub=nil, h=nil)

  t = tree[1][index]

  payload['_pat_val'] = @node['val'] \
    if t && t[0].match(/\A_pat_(arr|obj|or|guard|regex)\z/)

  super
end

#pre_executeObject



195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/flor/pcore/match.rb', line 195

def pre_execute

  unatt_unkeyed_children

  conditional = true
  @node['val'] = payload['ret'] if non_att_count.even?
  found_val = @node.has_key?('val')
  t = tree
  changed = false

  t[1].each_with_index do |ct, i|

    next if ct[0] == '_att'
    next(found_val = true) unless found_val
    next(conditional = true) unless conditional

    conditional = false
    t[1][i] = patternize(ct)
    changed = changed || t[1][i] != ct
  end

  @node['tree'] = t if changed
end