lfunc.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. ** $Id: lfunc.h,v 2.16 2017/04/11 18:41:09 roberto Exp roberto $
  3. ** Auxiliary functions to manipulate prototypes and closures
  4. ** See Copyright Notice in lua.h
  5. */
  6. #ifndef lfunc_h
  7. #define lfunc_h
  8. #include "lobject.h"
  9. #define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \
  10. cast(int, sizeof(TValue)*((n)-1)))
  11. #define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \
  12. cast(int, sizeof(TValue *)*((n)-1)))
  13. /* test whether thread is in 'twups' list */
  14. #define isintwups(L) (L->twups != L)
  15. /*
  16. ** maximum number of upvalues in a closure (both C and Lua). (Value
  17. ** must fit in a VM register.)
  18. */
  19. #define MAXUPVAL 255
  20. #define upisopen(up) ((up)->v != &(up)->u.value)
  21. /*
  22. ** maximum number of misses before giving up the cache of closures
  23. ** in prototypes
  24. */
  25. #define MAXMISS 10
  26. LUAI_FUNC Proto *luaF_newproto (lua_State *L);
  27. LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nelems);
  28. LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nelems);
  29. LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl);
  30. LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level);
  31. LUAI_FUNC void luaF_close (lua_State *L, StkId level);
  32. LUAI_FUNC void luaF_unlinkupval (UpVal *uv);
  33. LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f);
  34. LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number,
  35. int pc);
  36. #endif