Advertisement
C4Cypher

What the fuck MMC?

Aug 22nd, 2014
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.54 KB | None | 0 0
  1. mr_call(L) = R :-
  2.     semipure Func:lua_func = get_func_upvalue(L),
  3.     (try [Func]
  4.         impure R0 = (Func(L))
  5.         then R = R0
  6.         else
  7.             impure lua_pushboolean(L, no),
  8.             R = 1
  9.         catch_any E ->
  10.             impure lua_pushnil(L),
  11.             impure lua_pushuserdata(L, univ(E)),
  12.             R = 2
  13.     ).
  14.        
  15.    
  16.    
  17. :- semipure func get_func_upvalue(lua) = lua_func.
  18.  
  19. :- pragma foreign_proc("C", get_func_upvalue(L::in) = (F::out),
  20.     [promise_semipure, will_not_call_mercury], "
  21.     luaMR_getupvalue(L, 1);
  22.     MR_Word ** ptr = lua_touserdata(L, -1);
  23.     F = **ptr;
  24.     lua_pop(L, 1);
  25. ").
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement