vendor: 引入 Lua 5.0.3 官方源码 (lua_5.0 分支)

桥接层适配尚未完成。Lua 5.0 与 5.1+ 差异显著:
- 无 linit.c/loslib.c(luaopen_os 混于 liolib.c)
- 无 luaL_setfuncs/lua_getextraspace/lua_isinteger
- 无 LUA_REGISTRYINDEX 现代用法差异需逐一核对
后续移植需按 ADAPTATION.md 指引重写 I/O 重定向与 typed interop 层
This commit is contained in:
JianFeeeee
2026-08-25 10:14:33 +08:00
parent 80880edbce
commit 95d474ea07
65 changed files with 9165 additions and 27114 deletions

View File

@ -1,5 +1,5 @@
/*
** $Id: lfunc.h $
** $Id: lfunc.h,v 1.21a 2003/03/18 12:50:04 roberto Exp $
** Auxiliary functions to manipulate prototypes and closures
** See Copyright Notice in lua.h
*/
@ -11,55 +11,22 @@
#include "lobject.h"
#define sizeCclosure(n) \
(offsetof(CClosure, upvalue) + sizeof(TValue) * cast_uint(n))
#define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \
cast(int, sizeof(TObject)*((n)-1)))
#define sizeLclosure(n) \
(offsetof(LClosure, upvals) + sizeof(UpVal *) * cast_uint(n))
#define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \
cast(int, sizeof(TObject *)*((n)-1)))
/* test whether thread is in 'twups' list */
#define isintwups(L) (L->twups != L)
Proto *luaF_newproto (lua_State *L);
Closure *luaF_newCclosure (lua_State *L, int nelems);
Closure *luaF_newLclosure (lua_State *L, int nelems, TObject *e);
UpVal *luaF_findupval (lua_State *L, StkId level);
void luaF_close (lua_State *L, StkId level);
void luaF_freeproto (lua_State *L, Proto *f);
void luaF_freeclosure (lua_State *L, Closure *c);
/*
** maximum number of upvalues in a closure (both C and Lua). (Value
** must fit in a VM register.)
*/
#define MAXUPVAL 255
#define upisopen(up) ((up)->v.p != &(up)->u.value)
#define uplevel(up) check_exp(upisopen(up), cast(StkId, (up)->v.p))
/*
** maximum number of misses before giving up the cache of closures
** in prototypes
*/
#define MAXMISS 10
/* special status to close upvalues preserving the top of the stack */
#define CLOSEKTOP (LUA_ERRERR + 1)
LUAI_FUNC Proto *luaF_newproto (lua_State *L);
LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nupvals);
LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nupvals);
LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl);
LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level);
LUAI_FUNC void luaF_newtbcupval (lua_State *L, StkId level);
LUAI_FUNC void luaF_closeupval (lua_State *L, StkId level);
LUAI_FUNC StkId luaF_close (lua_State *L, StkId level, TStatus status, int yy);
LUAI_FUNC void luaF_unlinkupval (UpVal *uv);
LUAI_FUNC lu_mem luaF_protosize (Proto *p);
LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f);
LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number,
int pc);
const char *luaF_getlocalname (const Proto *func, int local_number, int pc);
#endif