Class: Gisele::Compiling::Gisele2Gts
- Inherits:
-
Sexpr::Rewriter
- Object
- Sexpr::Rewriter
- Gisele::Compiling::Gisele2Gts
- Defined in:
- lib/gisele/compiling/gisele2gts.rb
Class Method Summary collapse
Instance Method Summary collapse
- #gts ⇒ Object
- #on_par_st(sexpr) ⇒ Object
- #on_seq_st(sexpr) ⇒ Object
- #on_task_call_st(sexpr) ⇒ Object
- #on_task_def(sexpr) ⇒ Object
- #on_unit_def(sexpr) ⇒ Object
Class Method Details
.compile(arg, parse_options = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/gisele/compiling/gisele2gts.rb', line 6 def self.compile(arg, = {}) case arg when String, Path parsed = Gisele.parse(arg, ) sexpr = Gisele.sexpr(parsed) compile(sexpr) else compiler = new compiler.call(arg) compiler.gts end end |
Instance Method Details
#gts ⇒ Object
96 97 98 |
# File 'lib/gisele/compiling/gisele2gts.rb', line 96 def gts [:gts] ||= Gts.new end |
#on_par_st(sexpr) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/gisele/compiling/gisele2gts.rb', line 68 def on_par_st(sexpr) entry = add_state(:fork) exit = add_state(:join) connect(entry, exit, :"(wait)") sexpr.sexpr_body.each_with_index do |child,idx| c_entry, c_exit = apply(child) c_end = add_state(:end) connect(entry, c_entry, :"(forked##{idx})") connect(c_exit, c_end, :"(joined)") connect(c_end, exit, :"(notify)") end [entry,exit] end |
#on_seq_st(sexpr) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/gisele/compiling/gisele2gts.rb', line 53 def on_seq_st(sexpr) entry = add_state(:nop) exit = add_state(:nop) current = entry sexpr.sexpr_body.each do |child| c_entry, c_exit = apply(child) connect(current, c_entry) current = c_exit end connect(current, exit) [entry, exit] end |
#on_task_call_st(sexpr) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/gisele/compiling/gisele2gts.rb', line 84 def on_task_call_st(sexpr) entry = add_state(:fork) exit = add_state(:join) connect(entry, exit, :"(wait)") c_entry, c_exit = task_nodes(sexpr) connect(entry, c_entry, :"(forked)") connect(c_exit, exit, :"(notify)") [entry, exit] end |
#on_task_def(sexpr) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/gisele/compiling/gisele2gts.rb', line 34 def on_task_def(sexpr) registry[sexpr[1]] ||= begin entry = add_state(:event) exit = add_state(:end) endevt = add_state(:event) sexpr[2...-1].each do |s| apply(s) if s.first == :task_def end c_entry, c_exit = apply(sexpr.last) connect(entry, c_entry, start_event(sexpr)) connect(c_exit, endevt) connect(endevt, exit, end_event(sexpr)) [entry, exit] end end |
#on_unit_def(sexpr) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/gisele/compiling/gisele2gts.rb', line 22 def on_unit_def(sexpr) entry = add_state(:launch, :initial => true) exit = add_state(:end) tasks = sexpr.sexpr_body.select{|n| n.first == :task_def} tasks.each do |task| c_entry, c_exit = apply(task) connect(entry, c_entry, task[1].to_sym) connect(c_exit, exit) end [entry, exit] end |