diff options
Diffstat (limited to 'src/lj_lib.h')
-rw-r--r-- | src/lj_lib.h | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/lj_lib.h b/src/lj_lib.h index 754e7444..83778b83 100644 --- a/src/lj_lib.h +++ b/src/lj_lib.h | |||
@@ -41,15 +41,22 @@ LJ_FUNC void lj_lib_checknumber(lua_State *L, int narg); | |||
41 | LJ_FUNC lua_Number lj_lib_checknum(lua_State *L, int narg); | 41 | LJ_FUNC lua_Number lj_lib_checknum(lua_State *L, int narg); |
42 | LJ_FUNC int32_t lj_lib_checkint(lua_State *L, int narg); | 42 | LJ_FUNC int32_t lj_lib_checkint(lua_State *L, int narg); |
43 | LJ_FUNC int32_t lj_lib_optint(lua_State *L, int narg, int32_t def); | 43 | LJ_FUNC int32_t lj_lib_optint(lua_State *L, int narg, int32_t def); |
44 | LJ_FUNC int32_t lj_lib_checkbit(lua_State *L, int narg); | ||
45 | LJ_FUNC GCfunc *lj_lib_checkfunc(lua_State *L, int narg); | 44 | LJ_FUNC GCfunc *lj_lib_checkfunc(lua_State *L, int narg); |
46 | LJ_FUNC GCtab *lj_lib_checktab(lua_State *L, int narg); | 45 | LJ_FUNC GCtab *lj_lib_checktab(lua_State *L, int narg); |
47 | LJ_FUNC GCtab *lj_lib_checktabornil(lua_State *L, int narg); | 46 | LJ_FUNC GCtab *lj_lib_checktabornil(lua_State *L, int narg); |
48 | LJ_FUNC int lj_lib_checkopt(lua_State *L, int narg, int def, const char *lst); | 47 | LJ_FUNC int lj_lib_checkopt(lua_State *L, int narg, int def, const char *lst); |
49 | 48 | ||
50 | /* Avoid including lj_frame.h. */ | 49 | /* Avoid including lj_frame.h. */ |
50 | #if LJ_GC64 | ||
51 | #define lj_lib_upvalue(L, n) \ | ||
52 | (&gcval(L->base-2)->fn.c.upvalue[(n)-1]) | ||
53 | #elif LJ_FR2 | ||
54 | #define lj_lib_upvalue(L, n) \ | ||
55 | (&gcref((L->base-2)->gcr)->fn.c.upvalue[(n)-1]) | ||
56 | #else | ||
51 | #define lj_lib_upvalue(L, n) \ | 57 | #define lj_lib_upvalue(L, n) \ |
52 | (&gcref((L->base-1)->fr.func)->fn.c.upvalue[(n)-1]) | 58 | (&gcref((L->base-1)->fr.func)->fn.c.upvalue[(n)-1]) |
59 | #endif | ||
53 | 60 | ||
54 | #if LJ_TARGET_WINDOWS | 61 | #if LJ_TARGET_WINDOWS |
55 | #define lj_lib_checkfpu(L) \ | 62 | #define lj_lib_checkfpu(L) \ |
@@ -60,23 +67,14 @@ LJ_FUNC int lj_lib_checkopt(lua_State *L, int narg, int def, const char *lst); | |||
60 | #define lj_lib_checkfpu(L) UNUSED(L) | 67 | #define lj_lib_checkfpu(L) UNUSED(L) |
61 | #endif | 68 | #endif |
62 | 69 | ||
63 | /* Push internal function on the stack. */ | 70 | LJ_FUNC GCfunc *lj_lib_pushcc(lua_State *L, lua_CFunction f, int id, int n); |
64 | static LJ_AINLINE void lj_lib_pushcc(lua_State *L, lua_CFunction f, | ||
65 | int id, int n) | ||
66 | { | ||
67 | GCfunc *fn; | ||
68 | lua_pushcclosure(L, f, n); | ||
69 | fn = funcV(L->top-1); | ||
70 | fn->c.ffid = (uint8_t)id; | ||
71 | setmref(fn->c.pc, &G(L)->bc_cfunc_int); | ||
72 | } | ||
73 | |||
74 | #define lj_lib_pushcf(L, fn, id) (lj_lib_pushcc(L, (fn), (id), 0)) | 71 | #define lj_lib_pushcf(L, fn, id) (lj_lib_pushcc(L, (fn), (id), 0)) |
75 | 72 | ||
76 | /* Library function declarations. Scanned by buildvm. */ | 73 | /* Library function declarations. Scanned by buildvm. */ |
77 | #define LJLIB_CF(name) static int lj_cf_##name(lua_State *L) | 74 | #define LJLIB_CF(name) static int lj_cf_##name(lua_State *L) |
78 | #define LJLIB_ASM(name) static int lj_ffh_##name(lua_State *L) | 75 | #define LJLIB_ASM(name) static int lj_ffh_##name(lua_State *L) |
79 | #define LJLIB_ASM_(name) | 76 | #define LJLIB_ASM_(name) |
77 | #define LJLIB_LUA(name) | ||
80 | #define LJLIB_SET(name) | 78 | #define LJLIB_SET(name) |
81 | #define LJLIB_PUSH(arg) | 79 | #define LJLIB_PUSH(arg) |
82 | #define LJLIB_REC(handler) | 80 | #define LJLIB_REC(handler) |
@@ -88,6 +86,10 @@ static LJ_AINLINE void lj_lib_pushcc(lua_State *L, lua_CFunction f, | |||
88 | 86 | ||
89 | LJ_FUNC void lj_lib_register(lua_State *L, const char *libname, | 87 | LJ_FUNC void lj_lib_register(lua_State *L, const char *libname, |
90 | const uint8_t *init, const lua_CFunction *cf); | 88 | const uint8_t *init, const lua_CFunction *cf); |
89 | LJ_FUNC void lj_lib_prereg(lua_State *L, const char *name, lua_CFunction f, | ||
90 | GCtab *env); | ||
91 | LJ_FUNC int lj_lib_postreg(lua_State *L, lua_CFunction cf, int id, | ||
92 | const char *name); | ||
91 | 93 | ||
92 | /* Library init data tags. */ | 94 | /* Library init data tags. */ |
93 | #define LIBINIT_LENMASK 0x3f | 95 | #define LIBINIT_LENMASK 0x3f |
@@ -96,7 +98,8 @@ LJ_FUNC void lj_lib_register(lua_State *L, const char *libname, | |||
96 | #define LIBINIT_ASM 0x40 | 98 | #define LIBINIT_ASM 0x40 |
97 | #define LIBINIT_ASM_ 0x80 | 99 | #define LIBINIT_ASM_ 0x80 |
98 | #define LIBINIT_STRING 0xc0 | 100 | #define LIBINIT_STRING 0xc0 |
99 | #define LIBINIT_MAXSTR 0x39 | 101 | #define LIBINIT_MAXSTR 0x38 |
102 | #define LIBINIT_LUA 0xf9 | ||
100 | #define LIBINIT_SET 0xfa | 103 | #define LIBINIT_SET 0xfa |
101 | #define LIBINIT_NUMBER 0xfb | 104 | #define LIBINIT_NUMBER 0xfb |
102 | #define LIBINIT_COPY 0xfc | 105 | #define LIBINIT_COPY 0xfc |