2 function _return_value(x) {
6 function co_return(x) {
7 return new _return_value(x);
10 const CONTINUATION = { toString: function () "[object CONTINUATION]" };
11 const SUSPEND = { toString: function () "[object SUSPEND]" };
13 function is_coroutine(obj) {
15 typeof(obj) == "object" &&
16 typeof(obj.next) == "function" &&
17 typeof(obj.send) == "function";
20 function _do_call(f) {
25 var throw_value = false;
36 if (x == CONTINUATION) {
54 stack[stack.length] = f;
60 if (x instanceof _return_value) {
61 if (stack.length == 0)
64 f = stack[stack.length - 1];
70 // Just return the value back to the function
73 if (stack.length == 0)
75 f = stack[stack.length - 1];
77 if (e instanceof StopIteration)
92 var cc = function (x) {
95 } catch (e if e instanceof StopIteration) {}
97 cc.throw = function (x) {
100 } catch (e if e instanceof StopIteration) {}
104 } catch (e if e instanceof StopIteration) {}