Skip to content

Instantly share code, notes, and snippets.

@YellowAfterlife
Created September 1, 2018 10:10
Show Gist options
  • Save YellowAfterlife/52759fc0071360de803e0e9169e8a0ee to your computer and use it in GitHub Desktop.
Save YellowAfterlife/52759fc0071360de803e0e9169e8a0ee to your computer and use it in GitHub Desktop.
Coroutine output from GMEdit
var l_ctx = argument[0];
if (!is_array(l_ctx)) {
l_ctx = array_create(6);
var l_argc = argument_count - 1;
var l_args = array_create(l_argc);
while (--l_argc >= 0) l_args[@l_argc] = argument[l_argc + 1];
l_ctx[2/* args */] = l_args;
return l_ctx;
}
var l_args = l_ctx[2/* args */];
while (true) switch (l_ctx[1/* label */]) {
case 0/* [L2,c5] begin */:
/// @param ctx
l_ctx[@3/* arr */] = l_args[0];
l_ctx[@4/* len */] = array_length_1d(l_ctx[3/* arr */]);
l_ctx[@5/* i */] = 0;
case 1/* [L4,c1] check for */:
if (l_ctx[5/* i */] >= l_ctx[4/* len */]) { l_ctx[@1/* label */] = 4; continue; }
l_ctx[@0/* yield */] = array_wget(l_ctx[3/* arr */], l_ctx[5/* i */]); l_ctx[@1/* label */] = 2; return true;
case 2/* [L5,c5] post yield, [L4,c1] post for */:
l_ctx[@5/* i */]++;
l_ctx[@1/* label */] = 1; continue;
default/* [L4,c1] end for, [L6,c2] end */: l_ctx[@0/* yield */] = 0; return false;
}
/*//!#gmcr
#gmcr
var arr = argument0;
var len = array_length_1d(arr);
for (var i = 0; i < len; i++) {
yield arr[i];
}
//!#gmcr*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment