sdk-world
v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Toggle main menu visibility
Loading...
Searching...
No Matches
lvm.h
Go to the documentation of this file.
1
/*
2
** $Id: lvm.h $
3
** Lua virtual machine
4
** See Copyright Notice in lua.h
5
*/
6
11
#ifndef lvm_h
12
#define lvm_h
13
14
15
#include "
ldo.h
"
16
#include "
lobject.h
"
17
#include "
ltm.h
"
18
19
20
#if !defined(LUA_NOCVTN2S)
21
#define cvt2str(o) ttisnumber(o)
22
#else
23
#define cvt2str(o) 0
/* no conversion from numbers to strings */
24
#endif
25
26
27
#if !defined(LUA_NOCVTS2N)
28
#define cvt2num(o) ttisstring(o)
29
#else
30
#define cvt2num(o) 0
/* no conversion from strings to numbers */
31
#endif
32
33
34
/*
35
** You can define LUA_FLOORN2I if you want to convert floats to integers
36
** by flooring them (instead of raising an error if they are not
37
** integral values)
38
*/
39
#if !defined(LUA_FLOORN2I)
40
#define LUA_FLOORN2I F2Ieq
41
#endif
42
43
44
/*
45
** Rounding modes for float->integer coercion
46
*/
47
typedef
enum
{
48
F2Ieq,
/* no rounding; accepts only integral values */
49
F2Ifloor,
/* takes the floor of the number */
50
F2Iceil
/* takes the ceil of the number */
51
} F2Imod;
52
53
54
/* convert an object to a float (including string coercion) */
55
#define tonumber(o,n) \
56
(ttisfloat(o) ? (*(n) = fltvalue(o), 1) : luaV_tonumber_(o,n))
57
58
59
/* convert an object to a float (without string coercion) */
60
#define tonumberns(o,n) \
61
(ttisfloat(o) ? ((n) = fltvalue(o), 1) : \
62
(ttisinteger(o) ? ((n) = cast_num(ivalue(o)), 1) : 0))
63
64
65
/* convert an object to an integer (including string coercion) */
66
#define tointeger(o,i) \
67
(l_likely(ttisinteger(o)) ? (*(i) = ivalue(o), 1) \
68
: luaV_tointeger(o,i,LUA_FLOORN2I))
69
70
71
/* convert an object to an integer (without string coercion) */
72
#define tointegerns(o,i) \
73
(l_likely(ttisinteger(o)) ? (*(i) = ivalue(o), 1) \
74
: luaV_tointegerns(o,i,LUA_FLOORN2I))
75
76
77
#define intop(op,v1,v2) l_castU2S(l_castS2U(v1) op l_castS2U(v2))
78
79
#define luaV_rawequalobj(t1,t2) luaV_equalobj(NULL,t1,t2)
80
81
82
/*
83
** fast track for 'gettable': if 't' is a table and 't[k]' is present,
84
** return 1 with 'slot' pointing to 't[k]' (position of final result).
85
** Otherwise, return 0 (meaning it will have to check metamethod)
86
** with 'slot' pointing to an empty 't[k]' (if 't' is a table) or NULL
87
** (otherwise). 'f' is the raw get function to use.
88
*/
89
#define luaV_fastget(L,t,k,slot,f) \
90
(!ttistable(t) \
91
? (slot = NULL, 0)
/* not a table; 'slot' is NULL and result is 0 */
\
92
: (slot = f(hvalue(t), k),
/* else, do raw access */
\
93
!isempty(slot)))
/* result not empty? */
94
95
96
/*
97
** Special case of 'luaV_fastget' for integers, inlining the fast case
98
** of 'luaH_getint'.
99
*/
100
#define luaV_fastgeti(L,t,k,slot) \
101
(!ttistable(t) \
102
? (slot = NULL, 0)
/* not a table; 'slot' is NULL and result is 0 */
\
103
: (slot = (l_castS2U(k) - 1u < hvalue(t)->alimit) \
104
? &hvalue(t)->array[k - 1] : luaH_getint(hvalue(t), k), \
105
!isempty(slot)))
/* result not empty? */
106
107
108
/*
109
** Finish a fast set operation (when fast get succeeds). In that case,
110
** 'slot' points to the place to put the value.
111
*/
112
#define luaV_finishfastset(L,t,slot,v) \
113
{ setobj2t(L, cast(TValue *,slot), v); \
114
luaC_barrierback(L, gcvalue(t), v); }
115
116
117
/*
118
** Shift right is the same as shift left with a negative 'y'
119
*/
120
#define luaV_shiftr(x,y) luaV_shiftl(x,intop(-, 0, y))
121
122
123
124
LUAI_FUNC
int
luaV_equalobj (
lua_State
*L,
const
TValue
*t1,
const
TValue
*t2);
125
LUAI_FUNC
int
luaV_lessthan (
lua_State
*L,
const
TValue
*l,
const
TValue
*r);
126
LUAI_FUNC
int
luaV_lessequal (
lua_State
*L,
const
TValue
*l,
const
TValue
*r);
127
LUAI_FUNC
int
luaV_tonumber_ (
const
TValue
*obj, lua_Number *n);
128
LUAI_FUNC
int
luaV_tointeger (
const
TValue
*obj, lua_Integer *p, F2Imod mode);
129
LUAI_FUNC
int
luaV_tointegerns (
const
TValue
*obj, lua_Integer *p,
130
F2Imod mode);
131
LUAI_FUNC
int
luaV_flttointeger (lua_Number n, lua_Integer *p, F2Imod mode);
132
LUAI_FUNC
void
luaV_finishget (
lua_State
*L,
const
TValue
*t,
TValue
*key,
133
StkId val,
const
TValue
*slot);
134
LUAI_FUNC
void
luaV_finishset (
lua_State
*L,
const
TValue
*t,
TValue
*key,
135
TValue
*val,
const
TValue
*slot);
136
LUAI_FUNC
void
luaV_finishOp (
lua_State
*L);
137
LUAI_FUNC
void
luaV_execute (
lua_State
*L,
CallInfo
*ci);
138
LUAI_FUNC
void
luaV_concat (
lua_State
*L,
int
total);
139
LUAI_FUNC lua_Integer luaV_idiv (
lua_State
*L, lua_Integer x, lua_Integer y);
140
LUAI_FUNC lua_Integer luaV_mod (
lua_State
*L, lua_Integer x, lua_Integer y);
141
LUAI_FUNC lua_Number luaV_modf (
lua_State
*L, lua_Number x, lua_Number y);
142
LUAI_FUNC lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y);
143
LUAI_FUNC
void
luaV_objlen (
lua_State
*L, StkId ra,
const
TValue
*rb);
144
145
#endif
ldo.h
lobject.h
ltm.h
CallInfo
Definition
lstate.h:181
TValue
Definition
lobject.h:71
lua_State
Definition
lstate.h:313
lua
src
lvm.h
Generated by
1.18.0