lib/flok/user_compiler.rb in flok-0.0.62 vs lib/flok/user_compiler.rb in flok-0.0.63

- old
+ new

@@ -206,9 +206,53 @@ from: old_action, to: "#{action_name}" }]); } out.puts res + elsif l =~ /Push/ + l.strip! + l.gsub!(/Push\(/, "") + l.gsub! /\)$/, "" + l.gsub! /\);$/, "" + o = l.split(",").map{|e| e.strip} + + action_name = o.shift.gsub(/"/, "") + + #Switch the actions, reset embeds, and call on_entry + res = %{ + var old_action = __info__.action; + __info__.action = "#{action_name}"; + + //Prep embeds array, embeds[0] refers to the spot bp+2 (bp is vc, bp+1 is main) + __info__.embeds = []; + for (var i = 1; i < #{@controller.spots.count}; ++i) { + __info__.embeds.push([]); + } + + //Call on_entry for the new action via the singleton on_entry + //located in ctable + __info__.cte.actions[__info__.action].on_entry(__base__) + + //'choose_action' pseudo-action will be sent as 'null' as it's the initial state + if (old_action === "choose_action") { + old_action = null; + } + + //Send off event for action change + main_q.push([3, "if_event", __base__, "action", { + from: old_action, + to: "#{action_name}" + }]); + } + out.puts res + elsif l =~ /Pop/ + l.strip! + l.gsub!(/Pop\(/, "") + l.gsub! /\)$/, "" + l.gsub! /\);$/, "" + o = l.split(",").map{|e| e.strip} + + #out.puts res #Request(service_instance_name, ename, info) elsif l =~ /Request/ l.strip! l.gsub!(/Request\(/, "") l.gsub! /\)$/, ""