File indexing completed on 2026-11-07 10:37:57
0001
0002
0003
0004
0005
0006
0007 #ifndef lvm_h
0008 #define lvm_h
0009
0010
0011 #include "ldo.h"
0012 #include "lobject.h"
0013 #include "ltm.h"
0014
0015
0016 #if !defined(LUA_NOCVTN2S)
0017 #define cvt2str(o) ttisnumber(o)
0018 #else
0019 #define cvt2str(o) 0
0020 #endif
0021
0022
0023 #if !defined(LUA_NOCVTS2N)
0024 #define cvt2num(o) ttisstring(o)
0025 #else
0026 #define cvt2num(o) 0
0027 #endif
0028
0029
0030
0031
0032
0033
0034
0035 #if !defined(LUA_FLOORN2I)
0036 #define LUA_FLOORN2I F2Ieq
0037 #endif
0038
0039
0040
0041
0042
0043 typedef enum {
0044 F2Ieq,
0045 F2Ifloor,
0046 F2Iceil
0047 } F2Imod;
0048
0049
0050
0051 #define tonumber(o,n) \
0052 (ttisfloat(o) ? (*(n) = fltvalue(o), 1) : luaV_tonumber_(o,n))
0053
0054
0055
0056 #define tonumberns(o,n) \
0057 (ttisfloat(o) ? ((n) = fltvalue(o), 1) : \
0058 (ttisinteger(o) ? ((n) = cast_num(ivalue(o)), 1) : 0))
0059
0060
0061
0062 #define tointeger(o,i) \
0063 (l_likely(ttisinteger(o)) ? (*(i) = ivalue(o), 1) \
0064 : luaV_tointeger(o,i,LUA_FLOORN2I))
0065
0066
0067
0068 #define tointegerns(o,i) \
0069 (l_likely(ttisinteger(o)) ? (*(i) = ivalue(o), 1) \
0070 : luaV_tointegerns(o,i,LUA_FLOORN2I))
0071
0072
0073 #define intop(op,v1,v2) l_castU2S(l_castS2U(v1) op l_castS2U(v2))
0074
0075 #define luaV_rawequalobj(t1,t2) luaV_equalobj(NULL,t1,t2)
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085 #define luaV_fastget(L,t,k,slot,f) \
0086 (!ttistable(t) \
0087 ? (slot = NULL, 0) \
0088 : (slot = f(hvalue(t), k), \
0089 !isempty(slot)))
0090
0091
0092
0093
0094
0095
0096 #define luaV_fastgeti(L,t,k,slot) \
0097 (!ttistable(t) \
0098 ? (slot = NULL, 0) \
0099 : (slot = (l_castS2U(k) - 1u < hvalue(t)->alimit) \
0100 ? &hvalue(t)->array[k - 1] : luaH_getint(hvalue(t), k), \
0101 !isempty(slot)))
0102
0103
0104
0105
0106
0107
0108 #define luaV_finishfastset(L,t,slot,v) \
0109 { setobj2t(L, cast(TValue *,slot), v); \
0110 luaC_barrierback(L, gcvalue(t), v); }
0111
0112
0113
0114
0115
0116 #define luaV_shiftr(x,y) luaV_shiftl(x,intop(-, 0, y))
0117
0118
0119
0120 LUAI_FUNC int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2);
0121 LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r);
0122 LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r);
0123 LUAI_FUNC int luaV_tonumber_ (const TValue *obj, lua_Number *n);
0124 LUAI_FUNC int luaV_tointeger (const TValue *obj, lua_Integer *p, F2Imod mode);
0125 LUAI_FUNC int luaV_tointegerns (const TValue *obj, lua_Integer *p,
0126 F2Imod mode);
0127 LUAI_FUNC int luaV_flttointeger (lua_Number n, lua_Integer *p, F2Imod mode);
0128 LUAI_FUNC void luaV_finishget (lua_State *L, const TValue *t, TValue *key,
0129 StkId val, const TValue *slot);
0130 LUAI_FUNC void luaV_finishset (lua_State *L, const TValue *t, TValue *key,
0131 TValue *val, const TValue *slot);
0132 LUAI_FUNC void luaV_finishOp (lua_State *L);
0133 LUAI_FUNC void luaV_execute (lua_State *L, CallInfo *ci);
0134 LUAI_FUNC void luaV_concat (lua_State *L, int total);
0135 LUAI_FUNC lua_Integer luaV_idiv (lua_State *L, lua_Integer x, lua_Integer y);
0136 LUAI_FUNC lua_Integer luaV_mod (lua_State *L, lua_Integer x, lua_Integer y);
0137 LUAI_FUNC lua_Number luaV_modf (lua_State *L, lua_Number x, lua_Number y);
0138 LUAI_FUNC lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y);
0139 LUAI_FUNC void luaV_objlen (lua_State *L, StkId ra, const TValue *rb);
0140
0141 #endif