diff options
Diffstat (limited to 'src/lj_lib.h')
-rw-r--r-- | src/lj_lib.h | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/src/lj_lib.h b/src/lj_lib.h index 55529ad8..a18f52bf 100644 --- a/src/lj_lib.h +++ b/src/lj_lib.h | |||
@@ -41,15 +41,28 @@ 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 | ||
49 | #if LJ_HASBUFFER | ||
50 | LJ_FUNC GCstr *lj_lib_checkstrx(lua_State *L, int narg); | ||
51 | LJ_FUNC int32_t lj_lib_checkintrange(lua_State *L, int narg, | ||
52 | int32_t a, int32_t b); | ||
53 | #endif | ||
54 | |||
50 | /* Avoid including lj_frame.h. */ | 55 | /* Avoid including lj_frame.h. */ |
56 | #if LJ_GC64 | ||
57 | #define lj_lib_upvalue(L, n) \ | ||
58 | (&gcval(L->base-2)->fn.c.upvalue[(n)-1]) | ||
59 | #elif LJ_FR2 | ||
60 | #define lj_lib_upvalue(L, n) \ | ||
61 | (&gcref((L->base-2)->gcr)->fn.c.upvalue[(n)-1]) | ||
62 | #else | ||
51 | #define lj_lib_upvalue(L, n) \ | 63 | #define lj_lib_upvalue(L, n) \ |
52 | (&gcref((L->base-1)->fr.func)->fn.c.upvalue[(n)-1]) | 64 | (&gcref((L->base-1)->fr.func)->fn.c.upvalue[(n)-1]) |
65 | #endif | ||
53 | 66 | ||
54 | #if LJ_TARGET_WINDOWS | 67 | #if LJ_TARGET_WINDOWS |
55 | #define lj_lib_checkfpu(L) \ | 68 | #define lj_lib_checkfpu(L) \ |
@@ -60,23 +73,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) | 73 | #define lj_lib_checkfpu(L) UNUSED(L) |
61 | #endif | 74 | #endif |
62 | 75 | ||
63 | /* Push internal function on the stack. */ | 76 | 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)) | 77 | #define lj_lib_pushcf(L, fn, id) (lj_lib_pushcc(L, (fn), (id), 0)) |
75 | 78 | ||
76 | /* Library function declarations. Scanned by buildvm. */ | 79 | /* Library function declarations. Scanned by buildvm. */ |
77 | #define LJLIB_CF(name) static int lj_cf_##name(lua_State *L) | 80 | #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) | 81 | #define LJLIB_ASM(name) static int lj_ffh_##name(lua_State *L) |
79 | #define LJLIB_ASM_(name) | 82 | #define LJLIB_ASM_(name) |
83 | #define LJLIB_LUA(name) | ||
80 | #define LJLIB_SET(name) | 84 | #define LJLIB_SET(name) |
81 | #define LJLIB_PUSH(arg) | 85 | #define LJLIB_PUSH(arg) |
82 | #define LJLIB_REC(handler) | 86 | #define LJLIB_REC(handler) |
@@ -88,6 +92,10 @@ static LJ_AINLINE void lj_lib_pushcc(lua_State *L, lua_CFunction f, | |||
88 | 92 | ||
89 | LJ_FUNC void lj_lib_register(lua_State *L, const char *libname, | 93 | LJ_FUNC void lj_lib_register(lua_State *L, const char *libname, |
90 | const uint8_t *init, const lua_CFunction *cf); | 94 | const uint8_t *init, const lua_CFunction *cf); |
95 | LJ_FUNC void lj_lib_prereg(lua_State *L, const char *name, lua_CFunction f, | ||
96 | GCtab *env); | ||
97 | LJ_FUNC int lj_lib_postreg(lua_State *L, lua_CFunction cf, int id, | ||
98 | const char *name); | ||
91 | 99 | ||
92 | /* Library init data tags. */ | 100 | /* Library init data tags. */ |
93 | #define LIBINIT_LENMASK 0x3f | 101 | #define LIBINIT_LENMASK 0x3f |
@@ -96,7 +104,8 @@ LJ_FUNC void lj_lib_register(lua_State *L, const char *libname, | |||
96 | #define LIBINIT_ASM 0x40 | 104 | #define LIBINIT_ASM 0x40 |
97 | #define LIBINIT_ASM_ 0x80 | 105 | #define LIBINIT_ASM_ 0x80 |
98 | #define LIBINIT_STRING 0xc0 | 106 | #define LIBINIT_STRING 0xc0 |
99 | #define LIBINIT_MAXSTR 0x39 | 107 | #define LIBINIT_MAXSTR 0x38 |
108 | #define LIBINIT_LUA 0xf9 | ||
100 | #define LIBINIT_SET 0xfa | 109 | #define LIBINIT_SET 0xfa |
101 | #define LIBINIT_NUMBER 0xfb | 110 | #define LIBINIT_NUMBER 0xfb |
102 | #define LIBINIT_COPY 0xfc | 111 | #define LIBINIT_COPY 0xfc |
@@ -104,9 +113,4 @@ LJ_FUNC void lj_lib_register(lua_State *L, const char *libname, | |||
104 | #define LIBINIT_FFID 0xfe | 113 | #define LIBINIT_FFID 0xfe |
105 | #define LIBINIT_END 0xff | 114 | #define LIBINIT_END 0xff |
106 | 115 | ||
107 | /* Exported library functions. */ | ||
108 | |||
109 | typedef struct RandomState RandomState; | ||
110 | LJ_FUNC uint64_t LJ_FASTCALL lj_math_random_step(RandomState *rs); | ||
111 | |||
112 | #endif | 116 | #endif |