The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Macros | Functions
lvm.cpp File Reference
#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   100
 
#define luai_runtimecheck(L, c)   /* void */
 
#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 KBx(i)   (k + (GETARG_Bx(i) != 0 ? GETARG_Bx(i) - 1 : GETARG_Ax(*ci->u.l.savedpc++)))
 
#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 arith_op(op, tm)
 
#define vmdispatch(o)   switch(o)
 
#define vmcase(l, b)   case l: {b} break;
 
#define vmcasenb(l, b)   case l: {b} /* nb = no break */
 

Functions

const TValueluaV_tonumber (const TValue *obj, TValue *n)
 
int luaV_tostring (lua_State *L, StkId obj)
 
static void traceexec (lua_State *L)
 
static void callTM (lua_State *L, const TValue *f, const TValue *p1, const TValue *p2, TValue *p3, int hasres)
 
void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val)
 
void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val)
 
static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2, StkId res, TMS event)
 
static const TValueget_equalTM (lua_State *L, Table *mt1, Table *mt2, TMS event)
 
static int call_orderTM (lua_State *L, const TValue *p1, const TValue *p2, TMS event)
 
static int l_strcmp (const TString *ls, const TString *rs)
 
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)
 
void luaV_concat (lua_State *L, int total)
 
void luaV_objlen (lua_State *L, StkId ra, const TValue *rb)
 
void luaV_arith (lua_State *L, StkId ra, const TValue *rb, const TValue *rc, TMS op)
 
static Closuregetcached (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

#define arith_op (   op,
  tm 
)
Value:
{ \
TValue *rb = RKB(i); \
TValue *rc = RKC(i); \
if (ttisnumber(rb) && ttisnumber(rc)) { \
lua_Number nb = nvalue(rb), nc = nvalue(rc); \
setnvalue(ra, op(L, nb, nc)); \
} \
else { Protect(luaV_arith(L, ra, rb, rc, tm)); } }
#define nvalue(o)
Definition: lobject.h:152
#define setnvalue(obj, x)
Definition: lobject.h:186
void luaV_arith(lua_State *L, StkId ra, const TValue *rb, const TValue *rc, TMS op)
Definition: lvm.cpp:360
size_t i
Definition: function.cpp:1057
struct lua_TValue TValue
Definition: lobject.h:105
#define RKC(i)
Definition: lvm.cpp:495
#define ttisnumber(o)
Definition: lobject.h:132
CALLABLE_WRAPPER_INPUT_END if(key=="terrain")
#define Protect(x)
Definition: lvm.cpp:511
#define RKB(i)
Definition: lvm.cpp:493
LUA_NUMBER lua_Number
Definition: lua.h:102

Definition at line 520 of file lvm.cpp.

Referenced by luaV_execute().

#define checkGC (   L,
  c 
)
Value:
Protect( luaC_condGC(L,{L->top = (c); /* limit of live values */ \
L->top = ci->top;}) /* restore top */ \
#define luaC_condGC(L, c)
Definition: lgc.h:121
void luaC_step(lua_State *L)
Definition: lgc.cpp:1176
#define luai_threadyield(L)
Definition: llimits.h:159
#define c
Definition: glew.h:12743
#define Protect(x)
Definition: lvm.cpp:511

Definition at line 513 of file lvm.cpp.

Referenced by luaV_execute().

#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:88
#define GETARG_sBx(i)
Definition: lopcodes.h:111
GLdouble l
Definition: glew.h:6966
#define GETARG_A(i)
Definition: lopcodes.h:96
GLboolean GLboolean GLboolean GLboolean a
Definition: glew.h:7319
size_t i
Definition: function.cpp:1057
CALLABLE_WRAPPER_INPUT_END if(key=="terrain")
#define e

Definition at line 502 of file lvm.cpp.

Referenced by luaV_execute().

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

Definition at line 508 of file lvm.cpp.

Referenced by luaV_execute().

#define KBx (   i)    (k + (GETARG_Bx(i) != 0 ? GETARG_Bx(i) - 1 : GETARG_Ax(*ci->u.l.savedpc++)))

Definition at line 497 of file lvm.cpp.

#define LUA_CORE

Definition at line 12 of file lvm.cpp.

#define luai_runtimecheck (   L,
  c 
)    /* void */

Definition at line 485 of file lvm.cpp.

Referenced by luaV_execute().

#define lvm_c

Definition at line 11 of file lvm.cpp.

#define MAXTAGLOOP   100

Definition at line 31 of file lvm.cpp.

Referenced by luaV_gettable(), and luaV_settable().

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

Definition at line 511 of file lvm.cpp.

Referenced by luaV_execute().

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

Definition at line 489 of file lvm.cpp.

Referenced by luaV_execute().

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

Definition at line 491 of file lvm.cpp.

Referenced by luaV_execute().

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

Definition at line 492 of file lvm.cpp.

#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:66
#define INDEXK(r)
Definition: lopcodes.h:139
#define GET_OPCODE(i)
Definition: lopcodes.h:88
#define getBMode(m)
Definition: lopcodes.h:274
#define GETARG_B(i)
Definition: lopcodes.h:99
size_t i
Definition: function.cpp:1057
#define ISK(x)
Definition: lopcodes.h:136

Definition at line 493 of file lvm.cpp.

Referenced by luaV_execute().

#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:66
#define INDEXK(r)
Definition: lopcodes.h:139
#define GET_OPCODE(i)
Definition: lopcodes.h:88
#define GETARG_C(i)
Definition: lopcodes.h:102
size_t i
Definition: function.cpp:1057
#define getCMode(m)
Definition: lopcodes.h:275
#define ISK(x)
Definition: lopcodes.h:136

Definition at line 495 of file lvm.cpp.

Referenced by luaV_execute().

#define vmcase (   l,
  b 
)    case l: {b} break;

Definition at line 531 of file lvm.cpp.

Referenced by luaV_execute().

#define vmcasenb (   l,
  b 
)    case l: {b} /* nb = no break */

Definition at line 532 of file lvm.cpp.

Referenced by luaV_execute().

#define vmdispatch (   o)    switch(o)

Definition at line 530 of file lvm.cpp.

Referenced by luaV_execute().

Function Documentation

static int call_binTM ( lua_State L,
const TValue p1,
const TValue p2,
StkId  res,
TMS  event 
)
static

Definition at line 174 of file lvm.cpp.

References callTM(), luaT_gettmbyobj(), and ttisnil.

Referenced by call_orderTM(), luaV_arith(), and luaV_concat().

static int call_orderTM ( lua_State L,
const TValue p1,
const TValue p2,
TMS  event 
)
static

Definition at line 199 of file lvm.cpp.

References call_binTM(), l_isfalse, and lua_State::top.

Referenced by luaV_lessequal(), and luaV_lessthan().

static void callTM ( lua_State L,
const TValue f,
const TValue p1,
const TValue p2,
TValue p3,
int  hasres 
)
static
static const TValue* get_equalTM ( lua_State L,
Table mt1,
Table mt2,
TMS  event 
)
static

Definition at line 185 of file lvm.cpp.

References fasttm, and luaV_rawequalobj.

Referenced by luaV_equalobj_().

static Closure* getcached ( Proto p,
UpVal **  encup,
StkId  base 
)
static
static int l_strcmp ( const TString ls,
const TString rs 
)
static

Definition at line 208 of file lvm.cpp.

References getstr, TString::len, and TString::tsv.

Referenced by luaV_lessequal(), and luaV_lessthan().

void luaV_arith ( lua_State L,
StkId  ra,
const TValue rb,
const TValue rc,
TMS  op 
)

Definition at line 360 of file lvm.cpp.

References c, call_binTM(), LUA_OPADD, luaG_aritherror(), luaO_arith(), luaV_tonumber(), nvalue, setnvalue, and TM_ADD.

Referenced by lua_arith(), and luaV_execute().

void luaV_concat ( lua_State L,
int  total 
)
int luaV_equalobj_ ( lua_State L,
const TValue t1,
const TValue t2 
)
void luaV_execute ( lua_State L)

Definition at line 534 of file lvm.cpp.

References arith_op, CallInfo::callstatus, cast_int, checkGC, lua_State::ci, CIST_REENTRY, CIST_TAIL, clLvalue, dojump, donextjump, equalobj, CallInfo::func, GET_OPCODE, GETARG_A, GETARG_Ax, GETARG_B, GETARG_Bx, GETARG_C, GETARG_sBx, getcached(), getproto, h, lua_State::hookcount, lua_State::hookmask, hvalue, i, ai::registry::init(), isLua, Proto::k, CallInfo::l, l_isfalse, LFIELDS_PER_FLUSH, lua_assert, LUA_MASKCOUNT, LUA_MASKLINE, LUA_MULTRET, LUA_QL, luaC_barrier, luaC_barrierback, luaD_call(), luaD_checkstack, luaD_poscall(), luaD_precall(), luaF_close(), luaG_runerror(), luaH_new(), luaH_resize(), luaH_resizearray(), luaH_setint(), luai_runtimecheck, luaO_fb2int(), luaV_arith(), luaV_concat(), luaV_gettable(), luaV_lessequal(), luaV_lessthan(), luaV_objlen(), luaV_settable(), Proto::numparams, nvalue, obj2gco, OP_ADD, OP_CALL, OP_CLOSURE, OP_CONCAT, OP_DIV, OP_EQ, OP_EXTRAARG, OP_FORLOOP, OP_FORPREP, OP_GETTABLE, OP_GETTABUP, OP_GETUPVAL, 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_SUB, OP_TAILCALL, OP_TEST, OP_TESTSET, OP_TFORCALL, OP_TFORLOOP, OP_UNM, OP_VARARG, Proto::p, LClosure::p, CallInfo::previous, Protect, pushclosure(), RA, RB, RKB, RKC, setbvalue, setclLvalue, sethvalue, setnilvalue, setnvalue, setobj, setobj2s, setobjs2s, Table::sizearray, Proto::sizep, lua_State::stack, lua_State::stacksize, TM_ADD, TM_DIV, TM_MOD, TM_MUL, TM_POW, TM_SUB, TM_UNM, tonumber, CallInfo::top, lua_State::top, traceexec(), ttisnil, ttisnumber, ttistable, CallInfo::u, LClosure::upvals, UpVal::v, vmcase, vmcasenb, and vmdispatch.

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

void luaV_finishOp ( lua_State L)
void luaV_gettable ( lua_State L,
const TValue t,
TValue key,
StkId  val 
)
int luaV_lessequal ( lua_State L,
const TValue l,
const TValue r 
)

Definition at line 243 of file lvm.cpp.

References call_orderTM(), l_strcmp(), luaG_ordererror(), nvalue, rawtsvalue, TM_LE, TM_LT, ttisnumber, and ttisstring.

Referenced by lua_compare(), and luaV_execute().

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

Definition at line 231 of file lvm.cpp.

References call_orderTM(), l_strcmp(), luaG_ordererror(), nvalue, rawtsvalue, TM_LT, ttisnumber, and ttisstring.

Referenced by lua_compare(), and luaV_execute().

void luaV_objlen ( lua_State L,
StkId  ra,
const TValue rb 
)
void luaV_settable ( lua_State L,
const TValue t,
TValue key,
StkId  val 
)
const TValue* luaV_tonumber ( const TValue obj,
TValue n 
)

Definition at line 34 of file lvm.cpp.

References luaO_str2d(), setnvalue, svalue, tsvalue, ttisnumber, and ttisstring.

Referenced by luaG_aritherror(), and luaV_arith().

int luaV_tostring ( lua_State L,
StkId  obj 
)

Definition at line 46 of file lvm.cpp.

References lua_number2str, LUAI_MAXNUMBER2STR, luaS_newlstr(), nvalue, setsvalue2s, and ttisnumber.

Referenced by lua_tolstring().

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