Class: Flor::Pro::Until

Inherits:
Flor::Procedure show all
Defined in:
lib/flor/pcore/until.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 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

#cancelObject



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/flor/pcore/until.rb', line 113

def cancel

  if @message['flavour'] == 'continue'

    pl = node_payload.copy_current
    pl = pl.merge!(payload.copy_current)

    @node['subs'] << counter_next('subs')

    @node['on_receive_last'] =
      execute_child(
        first_unkeyed_child_id, @node['subs'].last, 'payload' => pl)

  else

    @node['on_receive_last'] = nil
  end

  super
end

#cancel_when_closedObject



105
106
107
108
109
110
111
# File 'lib/flor/pcore/until.rb', line 105

def cancel_when_closed

  return cancel if node_status_flavour == 'on-error'
  return [] if @message['flavour'] != 'break'

  cancel
end

#pre_executeObject



40
41
42
43
44
45
# File 'lib/flor/pcore/until.rb', line 40

def pre_execute

  @node['subs'] = []

  unatt_first_unkeyed_child
end

#receive_firstObject



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/flor/pcore/until.rb', line 47

def receive_first

  @node['vars'] =
    {}
  @node['vars']['break'] =
    [ '_proc', { 'proc' => 'break', 'nid' => nid }, tree[-1] ]
  @node['vars']['continue'] =
    [ '_proc', { 'proc' => 'continue', 'nid' => nid }, tree[-1] ]

  super
end

#receive_non_attObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/flor/pcore/until.rb', line 59

def receive_non_att
  #
  # receiving from a non_att child (condition or block)

  if @fcid == first_unkeyed_child_id

    t0 = tree[0]
    tru = Flor.true?(payload['ret'])

    if (tru && t0 == 'until') || ( ! tru && t0 == 'while')
      #
      # over

      ret = @node.has_key?('cret') ? @node['cret'] : node_payload_ret

      wrap_reply('ret' => ret)

    else
      #
      # condition yield false, enter "block"

      payload['ret'] = node_payload_ret

      execute_child(@ncid, @node['subs'].last)
    end

  elsif @ncid >= children.size
    #
    # block over, increment counter and head back to condition

    @node['subs'] << counter_next('subs')

    @node['cret'] = payload['ret']
    payload['ret'] = node_payload_ret

    execute_child(first_unkeyed_child_id, @node['subs'].last)

  else
    #
    # we're in the middle of the "block", let's carry on

    # no need to set 'ret', we're in some kind of sequence
    execute_child(@ncid, @node['subs'].last)
  end
end