gisele-vm 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. data/CHANGELOG.md +5 -0
  2. data/Gemfile +18 -0
  3. data/Gemfile.lock +46 -0
  4. data/LICENCE.md +22 -0
  5. data/Manifest.txt +15 -0
  6. data/README.md +10 -0
  7. data/Rakefile +11 -0
  8. data/bin/gvm +9 -0
  9. data/gisele-vm.gemspec +191 -0
  10. data/gisele-vm.noespec +31 -0
  11. data/lib/gisele-vm.rb +4 -0
  12. data/lib/gisele-vm/loader.rb +5 -0
  13. data/lib/gisele-vm/version.rb +16 -0
  14. data/lib/gisele/compiling.rb +3 -0
  15. data/lib/gisele/compiling/gisele2gts.rb +143 -0
  16. data/lib/gisele/compiling/gts.rb +74 -0
  17. data/lib/gisele/compiling/gts2bytecode.rb +127 -0
  18. data/lib/gisele/vm.rb +87 -0
  19. data/lib/gisele/vm/bytecode.rb +84 -0
  20. data/lib/gisele/vm/bytecode/builder.rb +77 -0
  21. data/lib/gisele/vm/bytecode/grammar.citrus +116 -0
  22. data/lib/gisele/vm/bytecode/grammar.rb +19 -0
  23. data/lib/gisele/vm/bytecode/grammar.sexp.yml +113 -0
  24. data/lib/gisele/vm/bytecode/printer.rb +35 -0
  25. data/lib/gisele/vm/command.rb +140 -0
  26. data/lib/gisele/vm/component.rb +91 -0
  27. data/lib/gisele/vm/console.rb +58 -0
  28. data/lib/gisele/vm/enacter.rb +29 -0
  29. data/lib/gisele/vm/errors.rb +26 -0
  30. data/lib/gisele/vm/event.rb +11 -0
  31. data/lib/gisele/vm/event_manager.rb +65 -0
  32. data/lib/gisele/vm/kernel.rb +58 -0
  33. data/lib/gisele/vm/kernel/macros.gvm +214 -0
  34. data/lib/gisele/vm/kernel/opcodes.rb +212 -0
  35. data/lib/gisele/vm/kernel/runner.rb +63 -0
  36. data/lib/gisele/vm/lifecycle.rb +72 -0
  37. data/lib/gisele/vm/logging.rb +18 -0
  38. data/lib/gisele/vm/null_object.rb +19 -0
  39. data/lib/gisele/vm/prog.rb +63 -0
  40. data/lib/gisele/vm/prog_list.rb +55 -0
  41. data/lib/gisele/vm/prog_list/memory.rb +74 -0
  42. data/lib/gisele/vm/prog_list/sqldb.rb +123 -0
  43. data/lib/gisele/vm/prog_list/storage.rb +31 -0
  44. data/lib/gisele/vm/proxy.rb +14 -0
  45. data/lib/gisele/vm/proxy/client.rb +64 -0
  46. data/lib/gisele/vm/proxy/server.rb +29 -0
  47. data/lib/gisele/vm/registry.rb +57 -0
  48. data/lib/gisele/vm/robustness.rb +31 -0
  49. data/lib/gisele/vm/simulator/resumer.rb +32 -0
  50. data/spec/command/gvm_compile.cmd +1 -0
  51. data/spec/command/gvm_compile.stdout +111 -0
  52. data/spec/command/gvm_gts.cmd +1 -0
  53. data/spec/command/gvm_gts.stdout +101 -0
  54. data/spec/command/gvm_help.cmd +1 -0
  55. data/spec/command/gvm_help.stdout +30 -0
  56. data/spec/command/gvm_version.cmd +1 -0
  57. data/spec/command/gvm_version.stdout +2 -0
  58. data/spec/command/test_command.rb +29 -0
  59. data/spec/fixtures/complete.gis +13 -0
  60. data/spec/fixtures/fake_component.rb +24 -0
  61. data/spec/fixtures/kernel.rb +39 -0
  62. data/spec/fixtures/ts.adl +11 -0
  63. data/spec/fixtures/ts.gts +20 -0
  64. data/spec/fixtures/ts.gvm +19 -0
  65. data/spec/spec_helper.rb +86 -0
  66. data/spec/test_examples.rb +29 -0
  67. data/spec/test_gisele-vm.rb +8 -0
  68. data/spec/unit/bytecode/builder/test_at.rb +56 -0
  69. data/spec/unit/bytecode/builder/test_helpers.rb +36 -0
  70. data/spec/unit/bytecode/builder/test_instruction.rb +35 -0
  71. data/spec/unit/bytecode/builder/test_to_a.rb +53 -0
  72. data/spec/unit/bytecode/bytecode.gvm +1 -0
  73. data/spec/unit/bytecode/grammar/fixtures/comments.gvm +16 -0
  74. data/spec/unit/bytecode/grammar/fixtures/every.gvm +46 -0
  75. data/spec/unit/bytecode/grammar/fixtures/singleblock.gvm +2 -0
  76. data/spec/unit/bytecode/grammar/fixtures/twoblocks.gvm +4 -0
  77. data/spec/unit/bytecode/grammar/fixtures/with_end.gvm +5 -0
  78. data/spec/unit/bytecode/grammar/test_array.rb +24 -0
  79. data/spec/unit/bytecode/grammar/test_block.rb +35 -0
  80. data/spec/unit/bytecode/grammar/test_boolean.rb +20 -0
  81. data/spec/unit/bytecode/grammar/test_constant.rb +20 -0
  82. data/spec/unit/bytecode/grammar/test_eol.rb +20 -0
  83. data/spec/unit/bytecode/grammar/test_eol_comment.rb +36 -0
  84. data/spec/unit/bytecode/grammar/test_file.rb +38 -0
  85. data/spec/unit/bytecode/grammar/test_hash.rb +33 -0
  86. data/spec/unit/bytecode/grammar/test_instruction.rb +32 -0
  87. data/spec/unit/bytecode/grammar/test_int.rb +24 -0
  88. data/spec/unit/bytecode/grammar/test_label.rb +24 -0
  89. data/spec/unit/bytecode/grammar/test_opcode.rb +23 -0
  90. data/spec/unit/bytecode/grammar/test_string.rb +25 -0
  91. data/spec/unit/bytecode/grammar/test_symbol.rb +30 -0
  92. data/spec/unit/bytecode/test_build.rb +36 -0
  93. data/spec/unit/bytecode/test_coerce.rb +41 -0
  94. data/spec/unit/bytecode/test_fetch.rb +20 -0
  95. data/spec/unit/bytecode/test_grammar.rb +30 -0
  96. data/spec/unit/bytecode/test_parse.rb +22 -0
  97. data/spec/unit/bytecode/test_plus.rb +27 -0
  98. data/spec/unit/bytecode/test_to_a.rb +19 -0
  99. data/spec/unit/bytecode/test_to_s.rb +32 -0
  100. data/spec/unit/command/code.gis +3 -0
  101. data/spec/unit/command/test_vm.rb +51 -0
  102. data/spec/unit/compiling/gisele2gts/test_on_par_st.rb +51 -0
  103. data/spec/unit/compiling/gisele2gts/test_on_seq_st.rb +46 -0
  104. data/spec/unit/compiling/gisele2gts/test_on_task_call_st.rb +37 -0
  105. data/spec/unit/compiling/gisele2gts/test_on_task_def.rb +49 -0
  106. data/spec/unit/compiling/gisele2gts/test_on_unit_def.rb +35 -0
  107. data/spec/unit/compiling/gts2bytecode/test_on_end.rb +31 -0
  108. data/spec/unit/compiling/gts2bytecode/test_on_event.rb +37 -0
  109. data/spec/unit/compiling/gts2bytecode/test_on_fork.rb +41 -0
  110. data/spec/unit/compiling/gts2bytecode/test_on_join.rb +42 -0
  111. data/spec/unit/compiling/gts2bytecode/test_on_listen.rb +36 -0
  112. data/spec/unit/compiling/gts2bytecode/test_on_nop.rb +30 -0
  113. data/spec/unit/component/test_component_name.rb +16 -0
  114. data/spec/unit/component/test_logging.rb +36 -0
  115. data/spec/unit/enacter/test_component.rb +11 -0
  116. data/spec/unit/event/test_to_s.rb +12 -0
  117. data/spec/unit/event_manager/test_component.rb +9 -0
  118. data/spec/unit/event_manager/test_subscribe.rb +40 -0
  119. data/spec/unit/event_manager/test_unsubscribe.rb +39 -0
  120. data/spec/unit/kernel/macros/test_fork.rb +37 -0
  121. data/spec/unit/kernel/macros/test_join.rb +43 -0
  122. data/spec/unit/kernel/macros/test_listen.rb +37 -0
  123. data/spec/unit/kernel/macros/test_notify.rb +57 -0
  124. data/spec/unit/kernel/macros/test_react.rb +47 -0
  125. data/spec/unit/kernel/macros/test_schedule_at.rb +30 -0
  126. data/spec/unit/kernel/opcodes/test_op_del.rb +42 -0
  127. data/spec/unit/kernel/opcodes/test_op_event.rb +25 -0
  128. data/spec/unit/kernel/opcodes/test_op_fetch.rb +27 -0
  129. data/spec/unit/kernel/opcodes/test_op_flip.rb +17 -0
  130. data/spec/unit/kernel/opcodes/test_op_fold.rb +29 -0
  131. data/spec/unit/kernel/opcodes/test_op_fork.rb +63 -0
  132. data/spec/unit/kernel/opcodes/test_op_forka.rb +51 -0
  133. data/spec/unit/kernel/opcodes/test_op_get.rb +62 -0
  134. data/spec/unit/kernel/opcodes/test_op_getr.rb +48 -0
  135. data/spec/unit/kernel/opcodes/test_op_ifenil.rb +41 -0
  136. data/spec/unit/kernel/opcodes/test_op_ifezero.rb +32 -0
  137. data/spec/unit/kernel/opcodes/test_op_invoke.rb +34 -0
  138. data/spec/unit/kernel/opcodes/test_op_nop.rb +18 -0
  139. data/spec/unit/kernel/opcodes/test_op_parent.rb +39 -0
  140. data/spec/unit/kernel/opcodes/test_op_pop.rb +22 -0
  141. data/spec/unit/kernel/opcodes/test_op_push.rb +17 -0
  142. data/spec/unit/kernel/opcodes/test_op_save.rb +32 -0
  143. data/spec/unit/kernel/opcodes/test_op_savea.rb +34 -0
  144. data/spec/unit/kernel/opcodes/test_op_self.rb +20 -0
  145. data/spec/unit/kernel/opcodes/test_op_send.rb +20 -0
  146. data/spec/unit/kernel/opcodes/test_op_set.rb +61 -0
  147. data/spec/unit/kernel/opcodes/test_op_then.rb +50 -0
  148. data/spec/unit/kernel/opcodes/test_op_unfold.rb +22 -0
  149. data/spec/unit/kernel/opcodes/test_op_uuid.rb +16 -0
  150. data/spec/unit/kernel/runner/test_pop.rb +26 -0
  151. data/spec/unit/kernel/runner/test_stack.rb +28 -0
  152. data/spec/unit/kernel/test_progress.rb +47 -0
  153. data/spec/unit/kernel/test_resume.rb +53 -0
  154. data/spec/unit/kernel/test_start.rb +36 -0
  155. data/spec/unit/prog/test_to_hash.rb +29 -0
  156. data/spec/unit/prog/test_waitlist_eq.rb +20 -0
  157. data/spec/unit/prog_list/memory/test_component.rb +9 -0
  158. data/spec/unit/prog_list/memory/test_fetch.rb +40 -0
  159. data/spec/unit/prog_list/memory/test_pick.rb +39 -0
  160. data/spec/unit/prog_list/memory/test_save.rb +91 -0
  161. data/spec/unit/prog_list/memory/test_to_relation.rb +17 -0
  162. data/spec/unit/prog_list/sqldb/test_component.rb +11 -0
  163. data/spec/unit/prog_list/sqldb/test_connect.rb +46 -0
  164. data/spec/unit/prog_list/test_memory.rb +9 -0
  165. data/spec/unit/prog_list/test_sqldb.rb +13 -0
  166. data/spec/unit/prog_list/test_storage.rb +51 -0
  167. data/spec/unit/registry/test_component.rb +9 -0
  168. data/spec/unit/registry/test_connect.rb +53 -0
  169. data/spec/unit/registry/test_disconnect.rb +51 -0
  170. data/spec/unit/registry/test_registration.rb +44 -0
  171. data/spec/unit/shared/a_component.rb +49 -0
  172. data/spec/unit/shared/a_storage.rb +114 -0
  173. data/spec/unit/test_logging.rb +46 -0
  174. data/spec/unit/test_prog.rb +57 -0
  175. data/spec/unit/test_prog_list.rb +22 -0
  176. data/spec/unit/vm/test_event_facace.rb +11 -0
  177. data/spec/unit/vm/test_initialize.rb +59 -0
  178. data/spec/unit/vm/test_proglist_facade.rb +21 -0
  179. data/tasks/debug_mail.rake +75 -0
  180. data/tasks/debug_mail.txt +13 -0
  181. data/tasks/gem.rake +73 -0
  182. data/tasks/spec_test.rake +71 -0
  183. data/tasks/unit_test.rake +76 -0
  184. data/tasks/yard.rake +51 -0
  185. metadata +493 -0
@@ -0,0 +1,31 @@
1
+ module Gisele
2
+ class VM
3
+ module Robustness
4
+
5
+ private
6
+
7
+ def valid_label!(at)
8
+ unless vm.bytecode[at]
9
+ raise InvalidLabelError, "Unknown label: `#{at.inspect}`"
10
+ end
11
+ at
12
+ end
13
+
14
+ def valid_input!(input)
15
+ unless Array===input
16
+ raise InvalidInputError, "Invalid VM input: `#{input.inspect}`"
17
+ end
18
+ input
19
+ end
20
+
21
+ def valid_prog!(p, waitfor)
22
+ prog = Prog===p ? p : vm.fetch(p)
23
+ unless prog.waitfor == waitfor
24
+ raise InvalidStateError, "Prog `#{p}` does not wait for the #{waitfor}"
25
+ end
26
+ prog
27
+ end
28
+
29
+ end # module Robustness
30
+ end # class VM
31
+ end # module Gisele
@@ -0,0 +1,32 @@
1
+ module Gisele
2
+ class VM
3
+ module Simulator
4
+ class Resumer < Component
5
+
6
+ def enter_heartbeat
7
+ @timer = EM.add_periodic_timer(0.01, &method(:resume))
8
+ end
9
+
10
+ def leave_heartbeat
11
+ @timer.cancel
12
+ end
13
+
14
+ private
15
+
16
+ def resume
17
+ prog = vm.pick(:waitfor => :world)
18
+ resume_one(prog) if prog
19
+ end
20
+
21
+ def resume_one(prog)
22
+ event = prog.waitlist.keys.sample
23
+ debug("Resuming Prog #{prog.puid}@#{prog.pc} -> #{event}")
24
+ vm.resume(prog, [ event ])
25
+ rescue Exception => ex
26
+ error error_message(ex, "Resume error (#{prog.puid}):")
27
+ end
28
+
29
+ end # class Resumer
30
+ end # class Simulator
31
+ end # class VM
32
+ end # module Gisele
@@ -0,0 +1 @@
1
+ gts --compile complete.gis
@@ -0,0 +1,111 @@
1
+ main: then :s0
2
+ s0: push {:Main=>:s2}
3
+ flip
4
+ get
5
+ then
6
+ s1: then :notify
7
+ s2: then :s5
8
+ then :e48
9
+ e48: push ["Main"]
10
+ event :start
11
+ s3: then :notify
12
+ s4: then :s3
13
+ then :e50
14
+ e50: push ["Main"]
15
+ event :end
16
+ s5: push :s6
17
+ push [:s7, :s14]
18
+ then :fork
19
+ s6: push {:wake=>:s4}
20
+ then :join
21
+ s7: push :s8
22
+ push [:s9]
23
+ then :fork
24
+ s8: push {:wake=>:s13}
25
+ then :join
26
+ s9: then :s10
27
+ then :e2
28
+ e2: push ["Sort"]
29
+ event :start
30
+ s10: push {:ended=>:s11}
31
+ then :listen
32
+ s11: then :s12
33
+ then :e4
34
+ e4: push ["Sort"]
35
+ event :end
36
+ s12: then :notify
37
+ s13: then :notify
38
+ s14: then :s16
39
+ s15: then :s44
40
+ s16: push :s17
41
+ push [:s18]
42
+ then :fork
43
+ s17: push {:wake=>:s22}
44
+ then :join
45
+ s18: then :s19
46
+ then :e11
47
+ e11: push ["Hello"]
48
+ event :start
49
+ s19: push {:ended=>:s20}
50
+ then :listen
51
+ s20: then :s21
52
+ then :e13
53
+ e13: push ["Hello"]
54
+ event :end
55
+ s21: then :notify
56
+ s22: push :s23
57
+ push [:s24, :s31]
58
+ then :fork
59
+ s23: push {:wake=>:s38}
60
+ then :join
61
+ s24: push :s25
62
+ push [:s26]
63
+ then :fork
64
+ s25: push {:wake=>:s30}
65
+ then :join
66
+ s26: then :s27
67
+ then :e19
68
+ e19: push ["Ping"]
69
+ event :start
70
+ s27: push {:ended=>:s28}
71
+ then :listen
72
+ s28: then :s29
73
+ then :e21
74
+ e21: push ["Ping"]
75
+ event :end
76
+ s29: then :notify
77
+ s30: then :notify
78
+ s31: push :s32
79
+ push [:s33]
80
+ then :fork
81
+ s32: push {:wake=>:s37}
82
+ then :join
83
+ s33: then :s34
84
+ then :e28
85
+ e28: push ["Pong"]
86
+ event :start
87
+ s34: push {:ended=>:s35}
88
+ then :listen
89
+ s35: then :s36
90
+ then :e30
91
+ e30: push ["Pong"]
92
+ event :end
93
+ s36: then :notify
94
+ s37: then :notify
95
+ s38: push :s39
96
+ push [:s40]
97
+ then :fork
98
+ s39: push {:wake=>:s15}
99
+ then :join
100
+ s40: then :s41
101
+ then :e38
102
+ e38: push ["Goodbye"]
103
+ event :start
104
+ s41: push {:ended=>:s42}
105
+ then :listen
106
+ s42: then :s43
107
+ then :e40
108
+ e40: push ["Goodbye"]
109
+ event :end
110
+ s43: then :notify
111
+ s44: then :notify
@@ -0,0 +1 @@
1
+ gvm --gts complete.gis
@@ -0,0 +1,101 @@
1
+ digraph G {
2
+ graph [rankdir="LR"];
3
+ 0 [fillcolor="green" fixedsize="true" label="LA" shape="circle" style="filled" width="0.6"];
4
+ 1 [fillcolor="grey" fixedsize="true" label="E" shape="doublecircle" style="filled" width="0.6"];
5
+ 2 [fillcolor="white" fixedsize="true" label="EVT" shape="circle" style="filled" width="0.6"];
6
+ 3 [fillcolor="grey" fixedsize="true" label="E" shape="doublecircle" style="filled" width="0.6"];
7
+ 4 [fillcolor="white" fixedsize="true" label="EVT" shape="circle" style="filled" width="0.6"];
8
+ 5 [fillcolor="white" fixedsize="true" label="F" shape="octagon" style="filled" width="0.6"];
9
+ 6 [fillcolor="white" fixedsize="true" label="J" shape="doubleoctagon" style="filled" width="0.6"];
10
+ 7 [fillcolor="white" fixedsize="true" label="F" shape="octagon" style="filled" width="0.6"];
11
+ 8 [fillcolor="white" fixedsize="true" label="J" shape="doubleoctagon" style="filled" width="0.6"];
12
+ 9 [fillcolor="white" fixedsize="true" label="EVT" shape="circle" style="filled" width="0.6"];
13
+ 10 [fillcolor="white" fixedsize="true" label="L" shape="doublecircle" style="filled" width="0.6"];
14
+ 11 [fillcolor="white" fixedsize="true" label="EVT" shape="circle" style="filled" width="0.6"];
15
+ 12 [fillcolor="grey" fixedsize="true" label="E" shape="doublecircle" style="filled" width="0.6"];
16
+ 13 [fillcolor="grey" fixedsize="true" label="E" shape="doublecircle" style="filled" width="0.6"];
17
+ 14 [fillcolor="white" fixedsize="true" label="N" shape="circle" style="filled" width="0.6"];
18
+ 15 [fillcolor="white" fixedsize="true" label="N" shape="circle" style="filled" width="0.6"];
19
+ 16 [fillcolor="white" fixedsize="true" label="F" shape="octagon" style="filled" width="0.6"];
20
+ 17 [fillcolor="white" fixedsize="true" label="J" shape="doubleoctagon" style="filled" width="0.6"];
21
+ 18 [fillcolor="white" fixedsize="true" label="EVT" shape="circle" style="filled" width="0.6"];
22
+ 19 [fillcolor="white" fixedsize="true" label="L" shape="doublecircle" style="filled" width="0.6"];
23
+ 20 [fillcolor="white" fixedsize="true" label="EVT" shape="circle" style="filled" width="0.6"];
24
+ 21 [fillcolor="grey" fixedsize="true" label="E" shape="doublecircle" style="filled" width="0.6"];
25
+ 22 [fillcolor="white" fixedsize="true" label="F" shape="octagon" style="filled" width="0.6"];
26
+ 23 [fillcolor="white" fixedsize="true" label="J" shape="doubleoctagon" style="filled" width="0.6"];
27
+ 24 [fillcolor="white" fixedsize="true" label="F" shape="octagon" style="filled" width="0.6"];
28
+ 25 [fillcolor="white" fixedsize="true" label="J" shape="doubleoctagon" style="filled" width="0.6"];
29
+ 26 [fillcolor="white" fixedsize="true" label="EVT" shape="circle" style="filled" width="0.6"];
30
+ 27 [fillcolor="white" fixedsize="true" label="L" shape="doublecircle" style="filled" width="0.6"];
31
+ 28 [fillcolor="white" fixedsize="true" label="EVT" shape="circle" style="filled" width="0.6"];
32
+ 29 [fillcolor="grey" fixedsize="true" label="E" shape="doublecircle" style="filled" width="0.6"];
33
+ 30 [fillcolor="grey" fixedsize="true" label="E" shape="doublecircle" style="filled" width="0.6"];
34
+ 31 [fillcolor="white" fixedsize="true" label="F" shape="octagon" style="filled" width="0.6"];
35
+ 32 [fillcolor="white" fixedsize="true" label="J" shape="doubleoctagon" style="filled" width="0.6"];
36
+ 33 [fillcolor="white" fixedsize="true" label="EVT" shape="circle" style="filled" width="0.6"];
37
+ 34 [fillcolor="white" fixedsize="true" label="L" shape="doublecircle" style="filled" width="0.6"];
38
+ 35 [fillcolor="white" fixedsize="true" label="EVT" shape="circle" style="filled" width="0.6"];
39
+ 36 [fillcolor="grey" fixedsize="true" label="E" shape="doublecircle" style="filled" width="0.6"];
40
+ 37 [fillcolor="grey" fixedsize="true" label="E" shape="doublecircle" style="filled" width="0.6"];
41
+ 38 [fillcolor="white" fixedsize="true" label="F" shape="octagon" style="filled" width="0.6"];
42
+ 39 [fillcolor="white" fixedsize="true" label="J" shape="doubleoctagon" style="filled" width="0.6"];
43
+ 40 [fillcolor="white" fixedsize="true" label="EVT" shape="circle" style="filled" width="0.6"];
44
+ 41 [fillcolor="white" fixedsize="true" label="L" shape="doublecircle" style="filled" width="0.6"];
45
+ 42 [fillcolor="white" fixedsize="true" label="EVT" shape="circle" style="filled" width="0.6"];
46
+ 43 [fillcolor="grey" fixedsize="true" label="E" shape="doublecircle" style="filled" width="0.6"];
47
+ 44 [fillcolor="grey" fixedsize="true" label="E" shape="doublecircle" style="filled" width="0.6"];
48
+ 5 -> 6 [label="(wait)"];
49
+ 7 -> 8 [label="(wait)"];
50
+ 9 -> 10 [label="start(Sort)"];
51
+ 10 -> 11 [label="ended"];
52
+ 11 -> 12 [label="end(Sort)"];
53
+ 7 -> 9 [label="(forked)"];
54
+ 12 -> 8 [label="(notify)"];
55
+ 5 -> 7 [label="(forked#0)"];
56
+ 8 -> 13 [label="(joined)"];
57
+ 13 -> 6 [label="(notify)"];
58
+ 16 -> 17 [label="(wait)"];
59
+ 18 -> 19 [label="start(Hello)"];
60
+ 19 -> 20 [label="ended"];
61
+ 20 -> 21 [label="end(Hello)"];
62
+ 16 -> 18 [label="(forked)"];
63
+ 21 -> 17 [label="(notify)"];
64
+ 14 -> 16 [label=""];
65
+ 22 -> 23 [label="(wait)"];
66
+ 24 -> 25 [label="(wait)"];
67
+ 26 -> 27 [label="start(Ping)"];
68
+ 27 -> 28 [label="ended"];
69
+ 28 -> 29 [label="end(Ping)"];
70
+ 24 -> 26 [label="(forked)"];
71
+ 29 -> 25 [label="(notify)"];
72
+ 22 -> 24 [label="(forked#0)"];
73
+ 25 -> 30 [label="(joined)"];
74
+ 30 -> 23 [label="(notify)"];
75
+ 31 -> 32 [label="(wait)"];
76
+ 33 -> 34 [label="start(Pong)"];
77
+ 34 -> 35 [label="ended"];
78
+ 35 -> 36 [label="end(Pong)"];
79
+ 31 -> 33 [label="(forked)"];
80
+ 36 -> 32 [label="(notify)"];
81
+ 22 -> 31 [label="(forked#1)"];
82
+ 32 -> 37 [label="(joined)"];
83
+ 37 -> 23 [label="(notify)"];
84
+ 17 -> 22 [label=""];
85
+ 38 -> 39 [label="(wait)"];
86
+ 40 -> 41 [label="start(Goodbye)"];
87
+ 41 -> 42 [label="ended"];
88
+ 42 -> 43 [label="end(Goodbye)"];
89
+ 38 -> 40 [label="(forked)"];
90
+ 43 -> 39 [label="(notify)"];
91
+ 23 -> 38 [label=""];
92
+ 39 -> 15 [label=""];
93
+ 5 -> 14 [label="(forked#1)"];
94
+ 15 -> 44 [label="(joined)"];
95
+ 44 -> 6 [label="(notify)"];
96
+ 2 -> 5 [label="start(Main)"];
97
+ 6 -> 4 [label=""];
98
+ 4 -> 3 [label="end(Main)"];
99
+ 0 -> 2 [label="Main"];
100
+ 3 -> 1 [label=""];
101
+ }
@@ -0,0 +1 @@
1
+ gvm --help
@@ -0,0 +1,30 @@
1
+
2
+ The Gisele Virtual Machine
3
+
4
+ SYNOPSIS
5
+ gvm [--version] [--help]
6
+ gvm [--drb-server] [options] GIS_FILE
7
+ gvm --drb-client [options]
8
+
9
+ OPTIONS
10
+ --help Show this help message
11
+ --version Show version and exit
12
+ -c, --compile Compile the input file and output the VM bytecode
13
+ -g, --gts Outputs a gisele transition system
14
+
15
+ Storage
16
+ --storage=URI Use the specified storage (defaults to 'memory')
17
+ -t, --truncate Truncate process instances first
18
+
19
+ VM & Agents
20
+ -i, --interactive Start a console in interactive VM mode
21
+ -s, --simulate Use an agent simulating the environment
22
+ --drb-server Register the VM as a DRb server
23
+ --drb-client Look for the virtual machine on DRb
24
+
25
+ Logging
26
+ -v, --verbose Log in verbose mode
27
+ --silent Only show warnings and errors
28
+ --log=FILE Use a specific log file
29
+
30
+ SystemExit
@@ -0,0 +1 @@
1
+ gvm --version
@@ -0,0 +1,2 @@
1
+ gvm 0.6.0 (c) The University of Louvain
2
+ SystemExit
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+ require 'gisele/vm/command'
3
+ module Gisele
4
+ describe 'the `gvm` commandline tool' do
5
+
6
+ Path.dir.glob("**/*.cmd").each do |cmdfile|
7
+
8
+ it "executes `#{cmdfile}` as expected" do
9
+ command = cmdfile.read.strip
10
+ argv = Quickl.parse_commandline_args(command)[1..-1]
11
+ stdout = cmdfile.sub_ext('.stdout').read
12
+
13
+ out, err = capture_io do
14
+ begin
15
+ Dir.chdir Path.dir/'../fixtures' do
16
+ VM::Command.run(argv)
17
+ end
18
+ rescue SystemExit
19
+ puts "SystemExit"
20
+ end
21
+ end
22
+
23
+ out.should eq stdout
24
+ end
25
+
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,13 @@
1
+ task Main
2
+ par
3
+ Sort
4
+ seq
5
+ Hello
6
+ par
7
+ Ping
8
+ Pong
9
+ end
10
+ Goodbye
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,24 @@
1
+ module Gisele
2
+ class VM
3
+ module FakeComponent
4
+ def registered(vm)
5
+ @vm = vm
6
+ end
7
+ def unregistered
8
+ @vm = nil
9
+ end
10
+ def registered?
11
+ !@vm.nil?
12
+ end
13
+ def connect
14
+ @connected = true
15
+ end
16
+ def disconnect
17
+ @connected = false
18
+ end
19
+ def connected?
20
+ @connected
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,39 @@
1
+ module Gisele
2
+ class VM
3
+ class Kernel
4
+ public :runner
5
+ class Runner
6
+ attr_accessor :bytecode
7
+ attr_accessor :opcodes
8
+ attr_accessor :stack
9
+
10
+ public :push, :peek, :pop
11
+
12
+ public :op_then,
13
+ :op_puid,
14
+ :op_parent,
15
+ :op_fetch,
16
+ :op_save,
17
+ :op_savea,
18
+ :op_pop,
19
+ :op_push,
20
+ :op_send,
21
+ :op_invoke,
22
+ :op_fold,
23
+ :op_unfold,
24
+ :op_event,
25
+ :op_fork,
26
+ :op_forka,
27
+ :op_get,
28
+ :op_getr,
29
+ :op_set,
30
+ :op_del,
31
+ :op_self,
32
+ :op_flip,
33
+ :op_nop,
34
+ :op_ifenil,
35
+ :op_ifezero
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,11 @@
1
+ 5 5
2
+ 0 true false
3
+ 1 false true
4
+ 2 false false
5
+ 3 false false
6
+ 4 false false
7
+ 0 1 hello
8
+ 1 2 ping
9
+ 2 1 pong
10
+ 1 3 goodbye
11
+ 3 4 ciao