Class: Flor::Pro::Cursor

Inherits:
Flor::Procedure show all
Defined in:
lib/flor/pcore/cursor.rb

Direct Known Subclasses

Loop

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



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/flor/pcore/cursor.rb', line 138

def cancel

  if %w[ continue move ].include?(fla = @message['flavour'])

    cid =
      fla == 'move' ?
      move_target_child_id :
      first_non_att_child_id

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

    @node['on_receive_last'] =
      execute_child(cid, @node['subs'].last, 'orl' => fla)

  else

    @node['on_receive_last'] = nil
  end

  super
end

#cancel_when_closedObject



130
131
132
133
134
135
136
# File 'lib/flor/pcore/cursor.rb', line 130

def cancel_when_closed

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

  cancel
end

#pre_executeObject



80
81
82
83
84
# File 'lib/flor/pcore/cursor.rb', line 80

def pre_execute

  @node['atts'] = []
  @node['subs'] = []
end

#receive_attObject



102
103
104
105
# File 'lib/flor/pcore/cursor.rb', line 102

def receive_att

  receive_unkeyed_tag_att + super
end

#receive_firstObject



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/flor/pcore/cursor.rb', line 86

def receive_first

  # break/continue/move are set as variables so that they can
  # be aliases, it's useful in nested loops

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

  super
end

#receive_last_attObject



121
122
123
124
125
126
127
128
# File 'lib/flor/pcore/cursor.rb', line 121

def receive_last_att

  start = att('start', 'initial')
  cid = start && find_child_id(start)
  @ncid = cid if cid

  super
end

#receive_non_attObject



107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/flor/pcore/cursor.rb', line 107

def receive_non_att

  if @ncid >= children.size
    if @message['orl'] == 'continue'
      @node['subs'] << counter_next('subs')
      execute_child(first_non_att_child_id, @node['subs'].last)
    else
      wrap_reply
    end
  else
    execute_child(@ncid, @node['subs'].last)
  end
end