Class: Flor::Pro::Define

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

#executeObject



43
44
45
46
47
48
49
50
# File 'lib/flor/pcore/define.rb', line 43

def execute

  if i = att_children.index { |c| %w[ _dqs _sqs ].include?(c[1].first.first) }
    execute_child(i)
  else
    receive_att
  end
end

#receive_attObject



52
53
54
55
56
57
58
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
# File 'lib/flor/pcore/define.rb', line 52

def receive_att

  t, sig = flatten_tree

  bad_param =
    sig.inject(nil) { |r, a|
      a10 = a[1][0]
      pa = a10[0] == '_ref' && a10[1].size > 1 && a10[1].collect { |e| e[1] }
      break pa.join('.') if pa && ! pa[0].match(/\A(f|fld|field)\z/)
      nil }

  fail Flor::FlorError.new(
    "cannot accept #{bad_param.inspect} as parameter", self
  ) if bad_param

  cnode = lookup_var_node(@node, 'l')
  cnid = cnode['nid']
  fun = counter_next('funs') - 1

  (cnode['closures'] ||= []) << fun

  val = [
    '_func',
    { 'nid' => nid, 'tree' => t, 'cnid' => cnid, 'fun' => fun },
    t[2] ]

  if heap == 'define'
    name =
      if @message['point'] == 'execute'
        t[1].first[1].first[0]
      else
        payload['ret']
      end
    set_var('', name, val)
  end

  wrap('ret' => val)
end