sdk-world v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Loading...
Searching...
No Matches
lfunc.h
Go to the documentation of this file.
1/*
2** $Id: lfunc.h $
3** Auxiliary functions to manipulate prototypes and closures
4** See Copyright Notice in lua.h
5*/
6
11#ifndef lfunc_h
12#define lfunc_h
13
14
15#include "lobject.h"
16
17
18#define sizeCclosure(n) (cast_int(offsetof(CClosure, upvalue)) + \
19 cast_int(sizeof(TValue)) * (n))
20
21#define sizeLclosure(n) (cast_int(offsetof(LClosure, upvals)) + \
22 cast_int(sizeof(TValue *)) * (n))
23
24
25/* test whether thread is in 'twups' list */
26#define isintwups(L) (L->twups != L)
27
28
29/*
30** maximum number of upvalues in a closure (both C and Lua). (Value
31** must fit in a VM register.)
32*/
33#define MAXUPVAL 255
34
35
36#define upisopen(up) ((up)->v.p != &(up)->u.value)
37
38
39#define uplevel(up) check_exp(upisopen(up), cast(StkId, (up)->v.p))
40
41
42/*
43** maximum number of misses before giving up the cache of closures
44** in prototypes
45*/
46#define MAXMISS 10
47
48
49
50/* special status to close upvalues preserving the top of the stack */
51#define CLOSEKTOP (-1)
52
53
54LUAI_FUNC Proto *luaF_newproto (lua_State *L);
55LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nupvals);
56LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nupvals);
57LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl);
58LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level);
59LUAI_FUNC void luaF_newtbcupval (lua_State *L, StkId level);
60LUAI_FUNC void luaF_closeupval (lua_State *L, StkId level);
61LUAI_FUNC StkId luaF_close (lua_State *L, StkId level, int status, int yy);
62LUAI_FUNC void luaF_unlinkupval (UpVal *uv);
63LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f);
64LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number,
65 int pc);
66
67
68#endif