Class: Flor::Pro::Set

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

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



90
91
92
93
94
95
96
# File 'lib/flor/pcore/set.rb', line 90

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

  payload['ret'] = node_payload_ret \
    if children[index]

  super(index, sub, h)
end

#pre_executeObject



78
79
80
81
82
83
84
85
86
87
88
# File 'lib/flor/pcore/set.rb', line 78

def pre_execute

  unatt_unkeyed_children
  reref_children

  @node['single_child'] = (non_att_children.count == 1)

  rep_children

  @node['refs'] = []
end

#receive_lastObject



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/flor/pcore/set.rb', line 114

def receive_last

  ret =
    if @node['single_child']
      node_payload_ret
    else
      payload['ret']
    end

  refs = @node['refs']

  case refs.size
  when 0 then 0
  when 1 then set_value(refs.first, ret)
  else splat_value(refs, ret)
  end

  payload['ret'] =
    if tree[0] == 'setr' || refs_include_f_ret?
      ret
    else
      node_payload_ret
    end

  wrap
end

#receive_non_attObject



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/flor/pcore/set.rb', line 98

def receive_non_att

  ft = tree[1][@fcid] || []

  if ft[0] == '_rep' || (Flor.is_string_tree?(ft) && ! last_receive?)
    @node['refs'] << payload['ret']
  elsif ft[0] == '_ref' &&
    ft[1].size == 2 &&
    ft[1][0][0, 2] == [ '_sqs', 'f' ] && ft[1][1][0, 2] == [ '_sqs', 'ret' ]
  then
    payload['ret'] = node_payload_ret
  end

  super
end