Class: Flor::Pro::PatObj
Constant Summary
Flor::Procedure::RVARS, Flor::Procedure::TRUE_ATTS
Instance Attribute Summary
Attributes inherited from Node
#message
Instance Method Summary
collapse
#execute, #execute_child
[], 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
#pre_execute ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/flor/pcore/_pat_obj.rb', line 10
def pre_execute
@node['atts'] = []
t = tree
if (
i = t[1].index { |ct|
ct[0] == '_att' &&
ct[1].size == 1 &&
ct[1][0][0, 2] == [ 'only', [] ] }
) then
t[1][i] =
[ '_att', [
[ '_sqs', 'only', -1 ],
[ '_boo', true, -1 ],
], *t[1][i][2..-1] ]
@node['tree'] = [ t[0], t[1], *t[1][2..-1] ]
end
t = tree
changed = false
t[1].each_with_index do |ct, j|
next if j.odd? || ct[0] != '_ref'
ct[0] = '_rep'
changed = true
end
@node['tree'] = t if changed
super
end
|
#receive_first ⇒ Object
42
43
44
45
46
47
|
# File 'lib/flor/pcore/_pat_obj.rb', line 42
def receive_first
return wrap_no_match_reply unless val.is_a?(Hash)
super
end
|
#receive_last ⇒ Object
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/flor/pcore/_pat_obj.rb', line 99
def receive_last
ks = @node['keys']
return wrap_no_match_reply if ks && val.keys.sort != ks.sort
payload['_pat_binding'] = @node['binding']
payload.delete('_pat_val')
super
end
|
#receive_last_att ⇒ Object
49
50
51
52
53
54
55
56
57
|
# File 'lib/flor/pcore/_pat_obj.rb', line 49
def receive_last_att
rewrite_keys
@node['key'] = nil
@node['keys'] = [] if att('only')
super
end
|
#receive_non_att ⇒ Object
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
|
# File 'lib/flor/pcore/_pat_obj.rb', line 59
def receive_non_att
key = @node['key']
ret = payload['ret']
unless key
return wrap_no_match_reply unless Dense.has_key?(val, Array(ret))
@node['key'] = ret
@node['keys'] << ret if @node['keys']
return super
end
ct = child_type(@fcid)
if ct == :pattern
if b = payload.delete('_pat_binding')
@node['binding'].merge!(b)
else
return wrap_no_match_reply
end
elsif ct.is_a?(String)
@node['binding'][ct] = val[@node['key']] if ct != '_'
elsif ct.is_a?(Array)
@node['binding'][ct[0]] = val[@node['key']] if ct[0].length > 0
elsif Dense.get(val, key) != ret
return wrap_no_match_reply
end
@node['key'] = nil
super
end
|