flor 0.0.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. data/CHANGELOG.md +13 -0
  2. data/LICENSE.txt +1 -1
  3. data/Makefile +66 -0
  4. data/README.md +57 -0
  5. data/fail.txt +7 -0
  6. data/flor.gemspec +12 -9
  7. data/intercepted.txt +123 -0
  8. data/lib/flor/colours.rb +140 -0
  9. data/lib/flor/conf.rb +88 -0
  10. data/lib/flor/core/executor.rb +473 -0
  11. data/lib/flor/core/node.rb +397 -0
  12. data/lib/flor/core/procedure.rb +600 -0
  13. data/lib/flor/core/texecutor.rb +209 -0
  14. data/lib/flor/core.rb +93 -0
  15. data/lib/flor/dollar.rb +248 -0
  16. data/lib/flor/errors.rb +36 -0
  17. data/lib/flor/flor.rb +556 -0
  18. data/lib/flor/log.rb +336 -0
  19. data/lib/flor/migrations/0001_tables.rb +122 -0
  20. data/lib/flor/parser.rb +414 -0
  21. data/lib/flor/pcore/_arr.rb +49 -0
  22. data/lib/flor/pcore/_atom.rb +43 -0
  23. data/lib/flor/pcore/_att.rb +160 -0
  24. data/lib/flor/pcore/_dump.rb +60 -0
  25. data/lib/flor/pcore/_err.rb +30 -0
  26. data/lib/flor/pcore/_happly.rb +73 -0
  27. data/lib/flor/pcore/_obj.rb +65 -0
  28. data/lib/flor/pcore/_skip.rb +63 -0
  29. data/lib/flor/pcore/apply.rb +60 -0
  30. data/lib/flor/pcore/arith.rb +46 -0
  31. data/lib/flor/pcore/break.rb +71 -0
  32. data/lib/flor/pcore/cmp.rb +72 -0
  33. data/lib/flor/pcore/cond.rb +57 -0
  34. data/lib/flor/pcore/cursor.rb +223 -0
  35. data/lib/flor/pcore/define.rb +96 -0
  36. data/lib/flor/pcore/fail.rb +45 -0
  37. data/lib/flor/pcore/ife.rb +56 -0
  38. data/lib/flor/pcore/loop.rb +53 -0
  39. data/lib/flor/pcore/map.rb +75 -0
  40. data/lib/flor/pcore/match.rb +70 -0
  41. data/lib/flor/pcore/move.rb +65 -0
  42. data/lib/flor/pcore/noeval.rb +46 -0
  43. data/lib/flor/pcore/noret.rb +47 -0
  44. data/lib/flor/pcore/push.rb +69 -0
  45. data/lib/flor/pcore/sequence.rb +39 -0
  46. data/lib/flor/pcore/set.rb +76 -0
  47. data/lib/flor/pcore/stall.rb +35 -0
  48. data/lib/flor/pcore/until.rb +122 -0
  49. data/lib/flor/pcore/val.rb +40 -0
  50. data/lib/flor/punit/cancel.rb +69 -0
  51. data/lib/flor/punit/cmap.rb +76 -0
  52. data/lib/flor/punit/concurrence.rb +149 -0
  53. data/lib/flor/punit/every.rb +46 -0
  54. data/lib/flor/punit/on.rb +81 -0
  55. data/lib/flor/punit/schedule.rb +68 -0
  56. data/lib/flor/punit/signal.rb +47 -0
  57. data/lib/flor/punit/sleep.rb +53 -0
  58. data/lib/flor/punit/task.rb +109 -0
  59. data/lib/flor/punit/trace.rb +51 -0
  60. data/lib/flor/punit/trap.rb +100 -0
  61. data/lib/flor/to_string.rb +81 -0
  62. data/lib/flor/tools/env.rb +103 -0
  63. data/lib/flor/tools/repl.rb +231 -0
  64. data/lib/flor/unit/executor.rb +260 -0
  65. data/lib/flor/unit/hooker.rb +186 -0
  66. data/lib/flor/unit/journal.rb +52 -0
  67. data/lib/flor/unit/loader.rb +181 -0
  68. data/lib/flor/unit/logger.rb +181 -0
  69. data/lib/flor/unit/models/execution.rb +105 -0
  70. data/lib/flor/unit/models/pointer.rb +31 -0
  71. data/lib/flor/unit/models/timer.rb +52 -0
  72. data/lib/flor/unit/models/trace.rb +31 -0
  73. data/lib/flor/unit/models/trap.rb +130 -0
  74. data/lib/flor/unit/models.rb +106 -0
  75. data/lib/flor/unit/scheduler.rb +419 -0
  76. data/lib/flor/unit/storage.rb +633 -0
  77. data/lib/flor/unit/tasker.rb +191 -0
  78. data/lib/flor/unit/waiter.rb +146 -0
  79. data/lib/flor/unit/wlist.rb +77 -0
  80. data/lib/flor/unit.rb +50 -0
  81. data/lib/flor.rb +40 -3
  82. metadata +152 -22
  83. checksums.yaml +0 -7
  84. data/Rakefile +0 -52
@@ -0,0 +1,46 @@
1
+ #--
2
+ # Copyright (c) 2015-2017, John Mettraux, jmettraux+flor@gmail.com
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to deal
6
+ # in the Software without restriction, including without limitation the rights
7
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in
12
+ # all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ # THE SOFTWARE.
21
+ #
22
+ # Made in Japan.
23
+ #++
24
+
25
+
26
+ class Flor::Pro::NoEval < Flor::Procedure
27
+ #
28
+ # Immediately replies, children are not evaluated
29
+ #
30
+ # ```
31
+ # sequence
32
+ # 1
33
+ # noeval
34
+ # true
35
+ # [ 1, 2, 3 ]
36
+ # # f.ret is still 1 here, not [ 1, 2, 3 ]
37
+ # ```
38
+
39
+ name 'noeval'
40
+
41
+ def execute
42
+
43
+ reply
44
+ end
45
+ end
46
+
@@ -0,0 +1,47 @@
1
+ #--
2
+ # Copyright (c) 2015-2017, John Mettraux, jmettraux+flor@gmail.com
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to deal
6
+ # in the Software without restriction, including without limitation the rights
7
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in
12
+ # all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ # THE SOFTWARE.
21
+ #
22
+ # Made in Japan.
23
+ #++
24
+
25
+
26
+ class Flor::Pro::NoRet < Flor::Procedure
27
+ #
28
+ # executes its children, but doesn't alter the received f.ret
29
+ #
30
+ # ```
31
+ # sequence
32
+ # 123
33
+ # noret
34
+ # 456
35
+ # # f.ret is "back" to 123 at this point
36
+ # ```
37
+
38
+ name 'noret'
39
+
40
+ def receive_last
41
+
42
+ payload['ret'] = node_payload_ret
43
+
44
+ reply
45
+ end
46
+ end
47
+
@@ -0,0 +1,69 @@
1
+ #--
2
+ # Copyright (c) 2015-2017, John Mettraux, jmettraux+flor@gmail.com
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to deal
6
+ # in the Software without restriction, including without limitation the rights
7
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in
12
+ # all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ # THE SOFTWARE.
21
+ #
22
+ # Made in Japan.
23
+ #++
24
+
25
+
26
+ class Flor::Pro::Push < Flor::Procedure
27
+
28
+ name 'push', 'pushr'
29
+
30
+ def pre_execute
31
+
32
+ unatt_unkeyed_children
33
+ stringify_first_child
34
+ end
35
+
36
+ def receive_non_att
37
+
38
+ @node['arr'] ||= payload['ret']
39
+
40
+ super
41
+ end
42
+
43
+ def receive_last
44
+
45
+ arr = @node['arr']
46
+
47
+ if arr.is_a?(String)
48
+ payload.copy if arr[0, 1] == 'f'
49
+ arr = lookup(arr)
50
+ end
51
+
52
+ fail Flor::FlorError.new(
53
+ "cannot push to given target (#{arr.class})", self
54
+ ) unless arr.respond_to?(:push)
55
+
56
+ val =
57
+ unkeyed_children.size > 1 ?
58
+ payload['ret'] :
59
+ node_payload_ret
60
+
61
+ arr.push(val)
62
+
63
+ payload['ret'] = node_payload_ret \
64
+ unless tree[0] == 'pushr'
65
+
66
+ reply
67
+ end
68
+ end
69
+
@@ -0,0 +1,39 @@
1
+ #--
2
+ # Copyright (c) 2015-2017, John Mettraux, jmettraux+flor@gmail.com
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to deal
6
+ # in the Software without restriction, including without limitation the rights
7
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in
12
+ # all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ # THE SOFTWARE.
21
+ #
22
+ # Made in Japan.
23
+ #++
24
+
25
+
26
+ class Flor::Pro::Sequence < Flor::Procedure
27
+ #
28
+ # Executes child expressions in sequence.
29
+ #
30
+ # ```
31
+ # sequence
32
+ # task 'alpha'
33
+ # task 'bravo' if f.amount > 2000
34
+ # task 'charly'
35
+ # ```
36
+
37
+ names %w[ sequence _apply begin ]
38
+ end
39
+
@@ -0,0 +1,76 @@
1
+ #--
2
+ # Copyright (c) 2015-2017, John Mettraux, jmettraux+flor@gmail.com
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to deal
6
+ # in the Software without restriction, including without limitation the rights
7
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in
12
+ # all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ # THE SOFTWARE.
21
+ #
22
+ # Made in Japan.
23
+ #++
24
+
25
+
26
+ class Flor::Pro::Set < Flor::Procedure
27
+
28
+ names %w[ set setr ]
29
+
30
+ def pre_execute
31
+
32
+ unatt_unkeyed_children
33
+ stringify_first_child
34
+ end
35
+
36
+ def receive_non_att
37
+
38
+ @node['ref'] ||= payload['ret']
39
+
40
+ super
41
+ end
42
+
43
+ def receive_last
44
+
45
+ set_value(@node['ref'], payload['ret'])
46
+
47
+ payload['ret'] =
48
+ if tree[0] == 'setr' || @node['ref'] == 'f.ret'
49
+ payload['ret']
50
+ else
51
+ node_payload_ret
52
+ end
53
+
54
+ reply
55
+ end
56
+ end
57
+
58
+ # protected
59
+ #
60
+ # def splat(ks, vs)
61
+ #
62
+ # ks.inject(0) { |off, k|
63
+ # if k[0, 1] == '*'
64
+ # #p({ off: off, k: k, ks: ks[off + 1..-1], vs: vs[off..-1] })
65
+ # l = vs.length - ks.length + 1
66
+ # set_value(k[1..-1], vs[off, l])
67
+ # off + l
68
+ # else
69
+ # set_value(k, vs[off])
70
+ # off + 1
71
+ # end
72
+ # }
73
+ # end
74
+ #
75
+ # TODO need a splat a some point
76
+
@@ -0,0 +1,35 @@
1
+ #--
2
+ # Copyright (c) 2015-2017, John Mettraux, jmettraux+flor@gmail.com
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to deal
6
+ # in the Software without restriction, including without limitation the rights
7
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in
12
+ # all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ # THE SOFTWARE.
21
+ #
22
+ # Made in Japan.
23
+ #++
24
+
25
+
26
+ class Flor::Pro::Stall < Flor::Procedure
27
+
28
+ name 'stall'
29
+
30
+ def receive_last_att
31
+
32
+ [] # give back no messages, just stall...
33
+ end
34
+ end
35
+
@@ -0,0 +1,122 @@
1
+ #--
2
+ # Copyright (c) 2015-2017, John Mettraux, jmettraux+flor@gmail.com
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to deal
6
+ # in the Software without restriction, including without limitation the rights
7
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in
12
+ # all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ # THE SOFTWARE.
21
+ #
22
+ # Made in Japan.
23
+ #++
24
+
25
+
26
+ class Flor::Pro::Until < Flor::Procedure
27
+
28
+ names 'until', 'while'
29
+
30
+ def pre_execute
31
+
32
+ @node['subs'] = []
33
+
34
+ unatt_first_unkeyed_child
35
+ end
36
+
37
+ def receive_first
38
+
39
+ @node['vars'] =
40
+ {}
41
+ @node['vars']['break'] =
42
+ [ '_proc', { 'proc' => 'break', 'nid' => nid }, tree[-1] ]
43
+ @node['vars']['continue'] =
44
+ [ '_proc', { 'proc' => 'continue', 'nid' => nid }, tree[-1] ]
45
+
46
+ super
47
+ end
48
+
49
+ def receive_non_att
50
+ #
51
+ # receiving from a non_att child (condition or block)
52
+
53
+ if @fcid == first_unkeyed_child_id
54
+
55
+ t0 = tree[0]
56
+ tru = Flor.true?(payload['ret'])
57
+
58
+ if (tru && t0 == 'until') || ( ! tru && t0 == 'while')
59
+ #
60
+ # over
61
+
62
+ ret = @node.has_key?('cret') ? @node['cret'] : node_payload_ret
63
+ reply('ret' => ret)
64
+
65
+ else
66
+ #
67
+ # condition yield false, enter "block"
68
+
69
+ payload['ret'] = node_payload_ret
70
+ execute_child(@ncid, @node['subs'].last)
71
+ end
72
+
73
+ elsif @ncid >= children.size
74
+ #
75
+ # block over, increment counter and head back to condition
76
+
77
+ @node['subs'] << counter_next('subs')
78
+
79
+ @node['cret'] = payload['ret']
80
+ payload['ret'] = node_payload_ret
81
+ execute_child(first_unkeyed_child_id, @node['subs'].last)
82
+
83
+ else
84
+ #
85
+ # we're in the middle of the "block", let's carry on
86
+
87
+ # no need to set 'ret', we're in some kind of sequence
88
+ execute_child(@ncid, @node['subs'].last)
89
+ end
90
+ end
91
+
92
+ def cancel_when_closed
93
+
94
+ return [] unless @message['flavour'] == 'break'
95
+
96
+ cancel
97
+ end
98
+
99
+ def cancel
100
+
101
+ fla = @message['flavour']
102
+
103
+ if fla == 'continue'
104
+
105
+ pl = node_payload.copy_current
106
+ pl = pl.merge!(payload.copy_current)
107
+
108
+ @node['subs'] << counter_next('subs')
109
+
110
+ @node['on_receive_last'] =
111
+ execute_child(
112
+ first_unkeyed_child_id, @node['subs'].last, 'payload' => pl)
113
+
114
+ else
115
+
116
+ @node['on_receive_last'] = nil
117
+ end
118
+
119
+ super
120
+ end
121
+ end
122
+
@@ -0,0 +1,40 @@
1
+ #--
2
+ # Copyright (c) 2015-2017, John Mettraux, jmettraux+flor@gmail.com
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to deal
6
+ # in the Software without restriction, including without limitation the rights
7
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in
12
+ # all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ # THE SOFTWARE.
21
+ #
22
+ # Made in Japan.
23
+ #++
24
+
25
+
26
+ class Flor::Pro::Val < Flor::Procedure
27
+
28
+ name '_val'
29
+
30
+ def execute
31
+
32
+ heat = @node['heat']
33
+ heat = nil if heat == [ '_proc', 'val', -1 ]
34
+
35
+ payload['ret'] = heat
36
+
37
+ reply
38
+ end
39
+ end
40
+
@@ -0,0 +1,69 @@
1
+ #--
2
+ # Copyright (c) 2015-2017, John Mettraux, jmettraux+flor@gmail.com
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to deal
6
+ # in the Software without restriction, including without limitation the rights
7
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in
12
+ # all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ # THE SOFTWARE.
21
+ #
22
+ # Made in Japan.
23
+ #++
24
+
25
+
26
+ class Flor::Pro::Cancel < Flor::Procedure
27
+ #
28
+ # Cancels an execution branch
29
+ #
30
+ # ```
31
+ # concurrence
32
+ # sequence tag: 'blue'
33
+ # sequence
34
+ # cancel ref: 'blue'
35
+ # ```
36
+
37
+ name 'cancel', 'kill'
38
+ # ruote had "undo" as well...
39
+
40
+ def pre_execute
41
+
42
+ @node['atts'] = []
43
+ end
44
+
45
+ def receive_last
46
+
47
+ targets =
48
+ @node['atts']
49
+ .select { |k, v| k == nil }
50
+ .inject([]) { |a, (k, v)|
51
+ v = Array(v)
52
+ a.concat(v) if v.all? { |e| e.is_a?(String) }
53
+ a
54
+ } +
55
+ att_a('nid') +
56
+ att_a('ref')
57
+
58
+ nids, tags = targets.partition { |t| Flor.is_nid?(t) }
59
+
60
+ nids += tags_to_nids(tags)
61
+
62
+ fla = @node['heap']
63
+
64
+ nids.uniq.collect { |nid|
65
+ reply('point' => 'cancel', 'nid' => nid, 'flavour' => fla).first
66
+ } + reply
67
+ end
68
+ end
69
+
@@ -0,0 +1,76 @@
1
+ #--
2
+ # Copyright (c) 2015-2017, John Mettraux, jmettraux+flor@gmail.com
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to deal
6
+ # in the Software without restriction, including without limitation the rights
7
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in
12
+ # all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ # THE SOFTWARE.
21
+ #
22
+ # Made in Japan.
23
+ #++
24
+
25
+
26
+ class Flor::Pro::Cmap < Flor::Procedure
27
+
28
+ name 'cmap'
29
+
30
+ def pre_execute
31
+
32
+ @node['atts'] = []
33
+
34
+ @node['fun'] = nil
35
+ @node['col'] = []
36
+ end
37
+
38
+ def receive_non_att
39
+
40
+ if @node['fun']
41
+ receive_elt
42
+ else
43
+ receive_fun
44
+ end
45
+ end
46
+
47
+ protected
48
+
49
+ def receive_fun
50
+
51
+ fun = payload['ret']
52
+
53
+ fail ArgumentError.new(
54
+ "cmap expects a function"
55
+ ) unless Flor.is_func_tree?(fun)
56
+
57
+ col = att(nil)
58
+ @node['fun'] = fun
59
+
60
+ col.collect.with_index do |e, i|
61
+ apply(@node['fun'], [ e, i ], tree[2])
62
+ end.flatten(1)
63
+ end
64
+
65
+ def receive_elt
66
+
67
+ @node['col'] << payload['ret']
68
+
69
+ return [] if @node['cnodes'].any?
70
+
71
+ payload['ret'] = @node['col']
72
+
73
+ reply
74
+ end
75
+ end
76
+