Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mr_call(L) = R :-
- semipure Func:lua_func = get_func_upvalue(L),
- (try [Func]
- impure R0 = (Func(L))
- then R = R0
- else
- impure lua_pushboolean(L, no),
- R = 1
- catch_any E ->
- impure lua_pushnil(L),
- impure lua_pushuserdata(L, univ(E)),
- R = 2
- ).
- :- semipure func get_func_upvalue(lua) = lua_func.
- :- pragma foreign_proc("C", get_func_upvalue(L::in) = (F::out),
- [promise_semipure, will_not_call_mercury], "
- luaMR_getupvalue(L, 1);
- MR_Word ** ptr = lua_touserdata(L, -1);
- F = **ptr;
- lua_pop(L, 1);
- ").
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement