The Battle for Wesnoth  1.15.1+dev
Macros | Functions
lvm.cpp File Reference
#include "lprefix.h"
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "lua.h"
#include "ldebug.h"
#include "ldo.h"
#include "lfunc.h"
#include "lgc.h"
#include "lobject.h"
#include "lopcodes.h"
#include "lstate.h"
#include "lstring.h"
#include "ltable.h"
#include "ltm.h"
#include "lvm.h"
Include dependency graph for lvm.cpp:

Go to the source code of this file.

Macros

#define lvm_c
 
#define LUA_CORE
 
#define MAXTAGLOOP   2000
 
#define NBM   (l_mathlim(MANT_DIG))
 
#define tostring(L, o)   (ttisstring(o) || (cvt2str(o) && (luaO_tostring(L, o), 1)))
 
#define isemptystr(o)   (ttisshrstring(o) && tsvalue(o)->shrlen == 0)
 
#define NBITS   cast_int(sizeof(lua_Integer) * CHAR_BIT)
 
#define RA(i)   (base+GETARG_A(i))
 
#define RB(i)   check_exp(getBMode(GET_OPCODE(i)) == OpArgR, base+GETARG_B(i))
 
#define RC(i)   check_exp(getCMode(GET_OPCODE(i)) == OpArgR, base+GETARG_C(i))
 
#define RKB(i)
 
#define RKC(i)
 
#define dojump(ci, i, e)
 
#define donextjump(ci)   { i = *ci->u.l.savedpc; dojump(ci, i, 1); }
 
#define Protect(x)   { {x;}; base = ci->u.l.base; }
 
#define checkGC(L, c)
 
#define vmfetch()
 
#define vmdispatch(o)   switch(o)
 
#define vmcase(l)   case l:
 
#define vmbreak   break
 
#define gettableProtected(L, t, k, v)
 
#define settableProtected(L, t, k, v)
 

Functions

int luaV_tonumber_ (const TValue *obj, lua_Number *n)
 
int luaV_tointeger (const TValue *obj, lua_Integer *p, int mode)
 
static int forlimit (const TValue *obj, lua_Integer *p, lua_Integer step, int *stopnow)
 
void luaV_finishget (lua_State *L, const TValue *t, TValue *key, StkId val, const TValue *slot)
 
void luaV_finishset (lua_State *L, const TValue *t, TValue *key, StkId val, const TValue *slot)
 
static int l_strcmp (const TString *ls, const TString *rs)
 
static int LTintfloat (lua_Integer i, lua_Number f)
 
static int LEintfloat (lua_Integer i, lua_Number f)
 
static int LTnum (const TValue *l, const TValue *r)
 
static int LEnum (const TValue *l, const TValue *r)
 
int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r)
 
int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r)
 
int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2)
 
static void copy2buff (StkId top, int n, char *buff)
 
void luaV_concat (lua_State *L, int total)
 
void luaV_objlen (lua_State *L, StkId ra, const TValue *rb)
 
lua_Integer luaV_div (lua_State *L, lua_Integer m, lua_Integer n)
 
lua_Integer luaV_mod (lua_State *L, lua_Integer m, lua_Integer n)
 
lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y)
 
static LClosuregetcached (Proto *p, UpVal **encup, StkId base)
 
static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base, StkId ra)
 
void luaV_finishOp (lua_State *L)
 
void luaV_execute (lua_State *L)
 

Macro Definition Documentation

◆ checkGC

#define checkGC (   L,
  c 
)
Value:
{ luaC_condGC(L, L->top = (c), /* limit of live values */ \
Protect(L->top = ci->top)); /* restore top */ \
luai_threadyield(L); }
#define luaC_condGC(L, pre, pos)
Definition: lgc.h:110
#define Protect(x)
Definition: lvm.cpp:747
mock_char c

Definition at line 749 of file lvm.cpp.

Referenced by luaV_execute().

◆ dojump

#define dojump (   ci,
  i,
  e 
)
Value:
{ int a = GETARG_A(i); \
if (a != 0) luaF_close(L, ci->u.l.base + a - 1); \
ci->u.l.savedpc += GETARG_sBx(i) + e; }
void luaF_close(lua_State *L, StkId level)
Definition: lfunc.cpp:83
#define GETARG_sBx(i)
Definition: lopcodes.h:112
#define a
#define GETARG_A(i)
Definition: lopcodes.h:97
std::size_t i
Definition: function.cpp:933
#define e

Definition at line 738 of file lvm.cpp.

Referenced by luaV_execute().

◆ donextjump

#define donextjump (   ci)    { i = *ci->u.l.savedpc; dojump(ci, i, 1); }

Definition at line 744 of file lvm.cpp.

Referenced by luaV_execute().

◆ gettableProtected

#define gettableProtected (   L,
  t,
  k,
 
)
Value:
{ const TValue *slot; \
if (luaV_fastget(L,t,k,slot,luaH_get)) { setobj2s(L, v, slot); } \
else Protect(luaV_finishget(L,t,k,v,slot)); }
#define luaV_fastget(L, t, k, slot, f)
Definition: lvm.h:58
void luaV_finishget(lua_State *L, const TValue *t, TValue *key, StkId val, const TValue *slot)
Definition: lvm.cpp:160
const TValue * luaH_get(Table *t, const TValue *key)
Definition: ltable.cpp:589
#define setobj2s
Definition: lobject.h:271
double t
Definition: astarsearch.cpp:64
#define Protect(x)
Definition: lvm.cpp:747

Definition at line 774 of file lvm.cpp.

Referenced by luaV_execute().

◆ isemptystr

#define isemptystr (   o)    (ttisshrstring(o) && tsvalue(o)->shrlen == 0)

Definition at line 457 of file lvm.cpp.

Referenced by luaV_concat().

◆ LUA_CORE

#define LUA_CORE

Definition at line 8 of file lvm.cpp.

◆ lvm_c

#define lvm_c

Definition at line 7 of file lvm.cpp.

◆ MAXTAGLOOP

#define MAXTAGLOOP   2000

Definition at line 35 of file lvm.cpp.

Referenced by luaV_finishget(), and luaV_finishset().

◆ NBITS

#define NBITS   cast_int(sizeof(lua_Integer) * CHAR_BIT)

Definition at line 588 of file lvm.cpp.

Referenced by luaV_shiftl().

◆ NBM

#define NBM   (l_mathlim(MANT_DIG))

Definition at line 47 of file lvm.cpp.

◆ Protect

#define Protect (   x)    { {x;}; base = ci->u.l.base; }

Definition at line 747 of file lvm.cpp.

Referenced by luaV_execute().

◆ RA

#define RA (   i)    (base+GETARG_A(i))

Definition at line 728 of file lvm.cpp.

Referenced by luaV_execute().

◆ RB

#define RB (   i)    check_exp(getBMode(GET_OPCODE(i)) == OpArgR, base+GETARG_B(i))

Definition at line 729 of file lvm.cpp.

Referenced by luaV_execute().

◆ RC

#define RC (   i)    check_exp(getCMode(GET_OPCODE(i)) == OpArgR, base+GETARG_C(i))

Definition at line 730 of file lvm.cpp.

◆ RKB

#define RKB (   i)
Value:
ISK(GETARG_B(i)) ? k+INDEXK(GETARG_B(i)) : base+GETARG_B(i))
#define check_exp(c, e)
Definition: llimits.h:90
#define INDEXK(r)
Definition: lopcodes.h:140
#define GET_OPCODE(i)
Definition: lopcodes.h:89
#define getBMode(m)
Definition: lopcodes.h:284
std::size_t i
Definition: function.cpp:933
#define GETARG_B(i)
Definition: lopcodes.h:100
#define ISK(x)
Definition: lopcodes.h:137

Definition at line 731 of file lvm.cpp.

Referenced by luaV_execute().

◆ RKC

#define RKC (   i)
Value:
ISK(GETARG_C(i)) ? k+INDEXK(GETARG_C(i)) : base+GETARG_C(i))
#define check_exp(c, e)
Definition: llimits.h:90
#define INDEXK(r)
Definition: lopcodes.h:140
#define GET_OPCODE(i)
Definition: lopcodes.h:89
#define GETARG_C(i)
Definition: lopcodes.h:103
std::size_t i
Definition: function.cpp:933
#define getCMode(m)
Definition: lopcodes.h:285
#define ISK(x)
Definition: lopcodes.h:137

Definition at line 733 of file lvm.cpp.

Referenced by luaV_execute().

◆ settableProtected

#define settableProtected (   L,
  t,
  k,
 
)
Value:
{ const TValue *slot; \
if (!luaV_fastset(L,t,k,slot,luaH_get,v)) \
Protect(luaV_finishset(L,t,k,v,slot)); }
const TValue * luaH_get(Table *t, const TValue *key)
Definition: ltable.cpp:589
double t
Definition: astarsearch.cpp:64
#define luaV_fastset(L, t, k, slot, f, v)
Definition: lvm.h:80
void luaV_finishset(lua_State *L, const TValue *t, TValue *key, StkId val, const TValue *slot)
Definition: lvm.cpp:203

Definition at line 780 of file lvm.cpp.

Referenced by luaV_execute().

◆ tostring

#define tostring (   L,
 
)    (ttisstring(o) || (cvt2str(o) && (luaO_tostring(L, o), 1)))

Definition at line 454 of file lvm.cpp.

Referenced by luaV_concat().

◆ vmbreak

#define vmbreak   break

Definition at line 767 of file lvm.cpp.

Referenced by luaV_execute().

◆ vmcase

#define vmcase (   l)    case l:

Definition at line 766 of file lvm.cpp.

Referenced by luaV_execute().

◆ vmdispatch

#define vmdispatch (   o)    switch(o)

Definition at line 765 of file lvm.cpp.

Referenced by luaV_execute().

◆ vmfetch

#define vmfetch ( )
Value:
{ \
i = *(ci->u.l.savedpc++); \
if (L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) \
Protect(luaG_traceexec(L)); \
ra = RA(i); /* WARNING: any stack reallocation invalidates 'ra' */ \
lua_assert(base == ci->u.l.base); \
lua_assert(base <= L->top && L->top < L->stack + L->stacksize); \
}
#define LUA_MASKCOUNT
Definition: lua.h:415
std::size_t i
Definition: function.cpp:933
void luaG_traceexec(lua_State *L)
Definition: ldebug.cpp:666
#define RA(i)
Definition: lvm.cpp:728
#define LUA_MASKLINE
Definition: lua.h:414

Definition at line 756 of file lvm.cpp.

Referenced by luaV_execute().

Function Documentation

◆ copy2buff()

static void copy2buff ( StkId  top,
int  n,
char *  buff 
)
static

Definition at line 460 of file lvm.cpp.

References svalue, and vslen.

Referenced by luaV_concat().

◆ forlimit()

static int forlimit ( const TValue obj,
lua_Integer p,
lua_Integer  step,
int *  stopnow 
)
static

Definition at line 135 of file lvm.cpp.

References luai_numlt, luaV_tointeger(), n, and tonumber.

Referenced by luaV_execute().

◆ getcached()

static LClosure* getcached ( Proto p,
UpVal **  encup,
StkId  base 
)
static

◆ l_strcmp()

static int l_strcmp ( const TString ls,
const TString rs 
)
static

Definition at line 248 of file lvm.cpp.

References getstr, strcoll, and tsslen.

Referenced by luaV_lessequal(), and luaV_lessthan().

◆ LEintfloat()

static int LEintfloat ( lua_Integer  i,
lua_Number  f 
)
static

Definition at line 300 of file lvm.cpp.

References cast, cast_num, and luai_numle.

Referenced by LEnum(), and LTnum().

◆ LEnum()

static int LEnum ( const TValue l,
const TValue r 
)
static

Definition at line 341 of file lvm.cpp.

References fltvalue, ivalue, LEintfloat(), LTintfloat(), luai_numisnan, luai_numle, ttisfloat, and ttisinteger.

Referenced by luaV_lessequal().

◆ LTintfloat()

static int LTintfloat ( lua_Integer  i,
lua_Number  f 
)
static

Definition at line 281 of file lvm.cpp.

References cast, cast_num, and luai_numlt.

Referenced by LEnum(), and LTnum().

◆ LTnum()

static int LTnum ( const TValue l,
const TValue r 
)
static

Definition at line 318 of file lvm.cpp.

References fltvalue, ivalue, LEintfloat(), LTintfloat(), luai_numisnan, luai_numlt, ttisfloat, and ttisinteger.

Referenced by luaV_lessthan().

◆ luaV_concat()

void luaV_concat ( lua_State L,
int  total 
)

◆ luaV_div()

lua_Integer luaV_div ( lua_State L,
lua_Integer  m,
lua_Integer  n 
)

Definition at line 552 of file lvm.cpp.

References intop, l_castS2U, luaG_runerror(), and n.

Referenced by intarith(), and luaV_execute().

◆ luaV_equalobj()

int luaV_equalobj ( lua_State L,
const TValue t1,
const TValue t2 
)

◆ luaV_execute()

void luaV_execute ( lua_State L)

Definition at line 786 of file lvm.cpp.

References b, c, CallInfo::callstatus, cast_int, checkGC, chgfltvalue, chgivalue, lua_State::ci, CIST_FRESH, CIST_TAIL, clLvalue, dojump, donextjump, fltvalue, forlimit(), CallInfo::func, GET_OPCODE, GETARG_A, GETARG_Ax, GETARG_B, GETARG_Bx, GETARG_C, GETARG_sBx, getcached(), getproto, gettableProtected, h, hvalue, i, utils::detail::init, intop, isLua, ivalue, Proto::k, CallInfo::l, l_castS2U, l_isfalse, LFIELDS_PER_FLUSH, lua_assert, LUA_MULTRET, luaC_barrierback, luaC_upvalbarrier, luaD_call(), luaD_checkstack, luaD_poscall(), luaD_precall(), luaF_close(), luaG_runerror(), luaH_getstr(), luaH_new(), luaH_resize(), luaH_resizearray(), luaH_setint(), luai_numadd, luai_numdiv, luai_numidiv, luai_numle, luai_numlt, luai_nummod, luai_nummul, luai_numpow, luai_numsub, luai_numunm, luaO_fb2int(), luaT_trybinTM(), luaV_concat(), luaV_div(), luaV_equalobj(), luaV_fastget, luaV_finishget(), luaV_lessequal(), luaV_lessthan(), luaV_mod(), luaV_objlen(), luaV_shiftl(), n, Proto::numparams, OP_ADD, OP_BAND, OP_BNOT, OP_BOR, OP_BXOR, OP_CALL, OP_CLOSURE, OP_CONCAT, OP_DIV, OP_EQ, OP_EXTRAARG, OP_FORLOOP, OP_FORPREP, OP_GETTABLE, OP_GETTABUP, OP_GETUPVAL, OP_IDIV, OP_JMP, OP_LE, OP_LEN, OP_LOADBOOL, OP_LOADK, OP_LOADKX, OP_LOADNIL, OP_LT, OP_MOD, OP_MOVE, OP_MUL, OP_NEWTABLE, OP_NOT, OP_POW, OP_RETURN, OP_SELF, OP_SETLIST, OP_SETTABLE, OP_SETTABUP, OP_SETUPVAL, OP_SHL, OP_SHR, OP_SUB, OP_TAILCALL, OP_TEST, OP_TESTSET, OP_TFORCALL, OP_TFORLOOP, OP_UNM, OP_VARARG, p, Proto::p, LClosure::p, CallInfo::previous, Protect, pushclosure(), RA, RB, RKB, RKC, setbvalue, setclLvalue, setfltvalue, sethvalue, setivalue, setnilvalue, setobj, setobj2s, setobjs2s, settableProtected, Table::sizearray, Proto::sizep, t, TM_ADD, TM_BAND, TM_BNOT, TM_BOR, TM_BXOR, TM_DIV, TM_IDIV, TM_MOD, TM_MUL, TM_POW, TM_SHL, TM_SHR, TM_SUB, TM_UNM, tointeger, tonumber, CallInfo::top, lua_State::top, tsvalue, ttisinteger, ttisnil, CallInfo::u, LClosure::upvals, UpVal::v, vmbreak, vmcase, vmdispatch, and vmfetch.

Referenced by luaD_call(), resume(), and unroll().

◆ luaV_finishget()

void luaV_finishget ( lua_State L,
const TValue t,
TValue key,
StkId  val,
const TValue slot 
)

◆ luaV_finishOp()

void luaV_finishOp ( lua_State L)

◆ luaV_finishset()

void luaV_finishset ( lua_State L,
const TValue t,
TValue key,
StkId  val,
const TValue slot 
)

◆ luaV_lessequal()

int luaV_lessequal ( lua_State L,
const TValue l,
const TValue r 
)

◆ luaV_lessthan()

int luaV_lessthan ( lua_State L,
const TValue l,
const TValue r 
)

Definition at line 364 of file lvm.cpp.

References l_strcmp(), LTnum(), luaG_ordererror(), luaT_callorderTM(), TM_LT, tsvalue, ttisnumber, and ttisstring.

Referenced by lua_compare(), and luaV_execute().

◆ luaV_mod()

lua_Integer luaV_mod ( lua_State L,
lua_Integer  m,
lua_Integer  n 
)

Definition at line 572 of file lvm.cpp.

References l_castS2U, luaG_runerror(), and n.

Referenced by intarith(), and luaV_execute().

◆ luaV_objlen()

void luaV_objlen ( lua_State L,
StkId  ra,
const TValue rb 
)

◆ luaV_shiftl()

lua_Integer luaV_shiftl ( lua_Integer  x,
lua_Integer  y 
)

Definition at line 593 of file lvm.cpp.

References intop, and NBITS.

Referenced by intarith(), and luaV_execute().

◆ luaV_tointeger()

int luaV_tointeger ( const TValue obj,
lua_Integer p,
int  mode 
)

Definition at line 94 of file lvm.cpp.

References cvt2num, f, fltvalue, ivalue, l_floor, lua_numbertointeger, luaO_str2num(), n, svalue, ttisfloat, ttisinteger, and vslen.

Referenced by forlimit(), luaH_get(), and luaH_newkey().

◆ luaV_tonumber_()

int luaV_tonumber_ ( const TValue obj,
lua_Number n 
)

Definition at line 72 of file lvm.cpp.

References cast_num, cvt2num, ivalue, luaO_str2num(), nvalue, svalue, ttisinteger, and vslen.

◆ pushclosure()

static void pushclosure ( lua_State L,
Proto p,
UpVal **  encup,
StkId  base,
StkId  ra 
)
static