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) {
14 return typeof(obj) == "object" &&
15 typeof(obj.next) == "function" &&
16 typeof(obj.send) == "function";
19 function _do_call(f) {
24 var throw_value = false;
35 if (x == CONTINUATION) {
53 stack[stack.length] = f;
59 if (x instanceof _return_value) {
60 if (stack.length == 0)
63 f = stack[stack.length - 1];
69 // Just return the value back to the function
72 if (stack.length == 0)
74 f = stack[stack.length - 1];
76 if (e instanceof StopIteration)
91 var cc = function (x) {
94 } catch (e if e instanceof StopIteration) {}
96 cc.throw = function (x) {
99 } catch (e if e instanceof StopIteration) {}
103 } catch (e if e instanceof StopIteration) {}