We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C source:
// fwd.c #include "umka_api.h" void umproc(UmkaStackSlot *param, UmkaStackSlot *result) { int n = param[0].intVal; void *umka = result->ptrVal; const int callback = umkaGetFunc(umka, NULL, "callback"); int sum = 0; for (int i = 0; i < n; i++) { UmkaStackSlot callbackParam[] = {{.intVal = i}}; UmkaStackSlot callbackResult; umkaCall(umka, callback, 1, callbackParam, &callbackResult); sum += callbackResult.intVal; } result->intVal = sum; }
Umka source:
// fwd.um fn umproc*(n: int): int // implemented in C fn callback(x: int): int { printf("x = %d\n", x) return 2 * x } fn main() { printf("main\n") sum := umproc(3) printf("sum = %d\n", sum) }
Build command (MinGW):
gcc fwd.c -o fwd.umi -shared -static -Wl,--dll -lumka -L%CD%
Run command:
umka fwd.um
Output:
main x = 0 x = 1 x = 2 main x = 0 x = 1 x = 2 main x = 0 x = 1 x = 2 ...
The text was updated successfully, but these errors were encountered:
In contrast, a Lua->C->Lua call chain is quite possible:
int l_loop (lua_State *L) { for (;;) { lua_pushvalue(L, 1); lua_call(L, 0, 1); if (lua_isnil(L, -1)) break; printf("%s\n", lua_tostring(L, -1)); lua_pop(L, 1); } return 0; }
(Example is taken from https://www.lua.org/doc/hopl.pdf)
Sorry, something went wrong.
The problem is not that trivial, as such call chains imply recursive calls to vmLoop in the current Umka implementation.
vmLoop
No branches or pull requests
C source:
Umka source:
Build command (MinGW):
Run command:
Output:
The text was updated successfully, but these errors were encountered: