The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Macros | Functions
lcode.cpp File Reference
#include <stdlib.h>
#include "lua.h"
#include "lcode.h"
#include "ldebug.h"
#include "ldo.h"
#include "lgc.h"
#include "llex.h"
#include "lmem.h"
#include "lobject.h"
#include "lopcodes.h"
#include "lparser.h"
#include "lstring.h"
#include "ltable.h"
#include "lvm.h"
Include dependency graph for lcode.cpp:

Go to the source code of this file.

Macros

#define lcode_c
 
#define LUA_CORE
 
#define hasjumps(e)   ((e)->t != (e)->f)
 

Functions

static int isnumeral (expdesc *e)
 
void luaK_nil (FuncState *fs, int from, int n)
 
int luaK_jump (FuncState *fs)
 
void luaK_ret (FuncState *fs, int first, int nret)
 
static int condjump (FuncState *fs, OpCode op, int A, int B, int C)
 
static void fixjump (FuncState *fs, int pc, int dest)
 
int luaK_getlabel (FuncState *fs)
 
static int getjump (FuncState *fs, int pc)
 
static Instructiongetjumpcontrol (FuncState *fs, int pc)
 
static int need_value (FuncState *fs, int list)
 
static int patchtestreg (FuncState *fs, int node, int reg)
 
static void removevalues (FuncState *fs, int list)
 
static void patchlistaux (FuncState *fs, int list, int vtarget, int reg, int dtarget)
 
static void dischargejpc (FuncState *fs)
 
void luaK_patchlist (FuncState *fs, int list, int target)
 
LUAI_FUNC void luaK_patchclose (FuncState *fs, int list, int level)
 
void luaK_patchtohere (FuncState *fs, int list)
 
void luaK_concat (FuncState *fs, int *l1, int l2)
 
static int luaK_code (FuncState *fs, Instruction i)
 
int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c)
 
int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc)
 
static int codeextraarg (FuncState *fs, int a)
 
int luaK_codek (FuncState *fs, int reg, int k)
 
void luaK_checkstack (FuncState *fs, int n)
 
void luaK_reserveregs (FuncState *fs, int n)
 
static void freereg (FuncState *fs, int reg)
 
static void freeexp (FuncState *fs, expdesc *e)
 
static int addk (FuncState *fs, TValue *key, TValue *v)
 
int luaK_stringK (FuncState *fs, TString *s)
 
int luaK_numberK (FuncState *fs, lua_Number r)
 
static int boolK (FuncState *fs, int b)
 
static int nilK (FuncState *fs)
 
void luaK_setreturns (FuncState *fs, expdesc *e, int nresults)
 
void luaK_setoneret (FuncState *fs, expdesc *e)
 
void luaK_dischargevars (FuncState *fs, expdesc *e)
 
static int code_label (FuncState *fs, int A, int b, int jump)
 
static void discharge2reg (FuncState *fs, expdesc *e, int reg)
 
static void discharge2anyreg (FuncState *fs, expdesc *e)
 
static void exp2reg (FuncState *fs, expdesc *e, int reg)
 
void luaK_exp2nextreg (FuncState *fs, expdesc *e)
 
int luaK_exp2anyreg (FuncState *fs, expdesc *e)
 
void luaK_exp2anyregup (FuncState *fs, expdesc *e)
 
void luaK_exp2val (FuncState *fs, expdesc *e)
 
int luaK_exp2RK (FuncState *fs, expdesc *e)
 
void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex)
 
void luaK_self (FuncState *fs, expdesc *e, expdesc *key)
 
static void invertjump (FuncState *fs, expdesc *e)
 
static int jumponcond (FuncState *fs, expdesc *e, int cond)
 
void luaK_goiftrue (FuncState *fs, expdesc *e)
 
void luaK_goiffalse (FuncState *fs, expdesc *e)
 
static void codenot (FuncState *fs, expdesc *e)
 
void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k)
 
static int constfolding (OpCode op, expdesc *e1, expdesc *e2)
 
static void codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2, int line)
 
static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1, expdesc *e2)
 
void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e, int line)
 
void luaK_infix (FuncState *fs, BinOpr op, expdesc *v)
 
void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2, int line)
 
void luaK_fixline (FuncState *fs, int line)
 
void luaK_setlist (FuncState *fs, int base, int nelems, int tostore)
 

Macro Definition Documentation

#define hasjumps (   e)    ((e)->t != (e)->f)

Definition at line 28 of file lcode.cpp.

Referenced by exp2reg(), luaK_exp2anyreg(), luaK_exp2anyregup(), luaK_exp2val(), and luaK_indexed().

#define lcode_c

Definition at line 9 of file lcode.cpp.

#define LUA_CORE

Definition at line 10 of file lcode.cpp.

Function Documentation

static int addk ( FuncState fs,
TValue key,
TValue v 
)
static
static int boolK ( FuncState fs,
int  b 
)
static

Definition at line 342 of file lcode.cpp.

References addk(), and setbvalue.

Referenced by luaK_exp2RK().

static int code_label ( FuncState fs,
int  A,
int  b,
int  jump 
)
static

Definition at line 414 of file lcode.cpp.

References luaK_codeABC(), luaK_getlabel(), and OP_LOADBOOL.

Referenced by exp2reg().

static void codearith ( FuncState fs,
OpCode  op,
expdesc e1,
expdesc e2,
int  line 
)
static
static void codecomp ( FuncState fs,
OpCode  op,
int  cond,
expdesc e1,
expdesc e2 
)
static

Definition at line 745 of file lcode.cpp.

References condjump(), freeexp(), expdesc::info, expdesc::k, luaK_exp2RK(), OP_EQ, expdesc::u, and VJMP.

Referenced by luaK_posfix().

static int codeextraarg ( FuncState fs,
int  a 
)
static

Definition at line 243 of file lcode.cpp.

References CREATE_Ax, lua_assert, luaK_code(), MAXARG_Ax, and OP_EXTRAARG.

Referenced by luaK_codek(), and luaK_setlist().

static void codenot ( FuncState fs,
expdesc e 
)
static
static int condjump ( FuncState fs,
OpCode  op,
int  A,
int  B,
int  C 
)
static

Definition at line 73 of file lcode.cpp.

References luaK_codeABC(), and luaK_jump().

Referenced by codecomp(), and jumponcond().

static int constfolding ( OpCode  op,
expdesc e1,
expdesc e2 
)
static

Definition at line 712 of file lcode.cpp.

References isnumeral(), LUA_OPADD, luaO_arith(), expdesc::nval, OP_ADD, OP_DIV, OP_MOD, and expdesc::u.

Referenced by codearith().

static void discharge2anyreg ( FuncState fs,
expdesc e 
)
static

Definition at line 459 of file lcode.cpp.

References discharge2reg(), FuncState::freereg, expdesc::k, luaK_reserveregs(), and VNONRELOC.

Referenced by codenot(), and jumponcond().

static void discharge2reg ( FuncState fs,
expdesc e,
int  reg 
)
static
static void dischargejpc ( FuncState fs)
static

Definition at line 162 of file lcode.cpp.

References FuncState::jpc, NO_JUMP, NO_REG, patchlistaux(), and FuncState::pc.

Referenced by luaK_code().

static void exp2reg ( FuncState fs,
expdesc e,
int  reg 
)
static
static void fixjump ( FuncState fs,
int  pc,
int  dest 
)
static
static void freeexp ( FuncState fs,
expdesc e 
)
static
static void freereg ( FuncState fs,
int  reg 
)
static

Definition at line 276 of file lcode.cpp.

References FuncState::freereg, ISK, lua_assert, and FuncState::nactvar.

Referenced by freeexp(), and luaK_dischargevars().

static int getjump ( FuncState fs,
int  pc 
)
static

Definition at line 99 of file lcode.cpp.

References Proto::code, FuncState::f, GETARG_sBx, and NO_JUMP.

Referenced by luaK_concat(), luaK_patchclose(), need_value(), patchlistaux(), and removevalues().

static Instruction* getjumpcontrol ( FuncState fs,
int  pc 
)
static

Definition at line 108 of file lcode.cpp.

References Proto::code, FuncState::f, GET_OPCODE, and testTMode.

Referenced by invertjump(), need_value(), and patchtestreg().

static void invertjump ( FuncState fs,
expdesc e 
)
static
static int isnumeral ( expdesc e)
static

Definition at line 31 of file lcode.cpp.

References expdesc::f, expdesc::k, NO_JUMP, expdesc::t, and VKNUM.

Referenced by constfolding(), luaK_infix(), and luaK_prefix().

static int jumponcond ( FuncState fs,
expdesc e,
int  cond 
)
static
void luaK_checkstack ( FuncState fs,
int  n 
)
static int luaK_code ( FuncState fs,
Instruction  i 
)
static
int luaK_codeABC ( FuncState fs,
OpCode  o,
int  a,
int  b,
int  c 
)
int luaK_codeABx ( FuncState fs,
OpCode  o,
int  a,
unsigned int  bc 
)

Definition at line 235 of file lcode.cpp.

References CREATE_ABx, getCMode, getOpMode, iABx, iAsBx, lua_assert, luaK_code(), MAXARG_A, MAXARG_Bx, and OpArgN.

Referenced by codeclosure(), and luaK_codek().

int luaK_codek ( FuncState fs,
int  reg,
int  k 
)

Definition at line 249 of file lcode.cpp.

References codeextraarg(), luaK_codeABx(), MAXARG_Bx, OP_LOADK, and OP_LOADKX.

Referenced by discharge2reg(), and fornum().

void luaK_concat ( FuncState fs,
int l1,
int  l2 
)
void luaK_dischargevars ( FuncState fs,
expdesc e 
)
int luaK_exp2anyreg ( FuncState fs,
expdesc e 
)
void luaK_exp2anyregup ( FuncState fs,
expdesc e 
)

Definition at line 513 of file lcode.cpp.

References hasjumps, expdesc::k, luaK_exp2anyreg(), and VUPVAL.

Referenced by fieldsel(), and suffixedexp().

void luaK_exp2nextreg ( FuncState fs,
expdesc e 
)
int luaK_exp2RK ( FuncState fs,
expdesc e 
)
void luaK_exp2val ( FuncState fs,
expdesc e 
)

Definition at line 519 of file lcode.cpp.

References hasjumps, luaK_dischargevars(), and luaK_exp2anyreg().

Referenced by luaK_exp2RK(), luaK_posfix(), and yindex().

void luaK_fixline ( FuncState fs,
int  line 
)

Definition at line 861 of file lcode.cpp.

References FuncState::f, Proto::lineinfo, and FuncState::pc.

Referenced by codearith(), forbody(), funcargs(), and funcstat().

int luaK_getlabel ( FuncState fs)

Definition at line 93 of file lcode.cpp.

References FuncState::lasttarget, and FuncState::pc.

Referenced by code_label(), exp2reg(), luaK_patchtohere(), repeatstat(), and whilestat().

void luaK_goiffalse ( FuncState fs,
expdesc e 
)
void luaK_goiftrue ( FuncState fs,
expdesc e 
)
void luaK_indexed ( FuncState fs,
expdesc t,
expdesc k 
)
void luaK_infix ( FuncState fs,
BinOpr  op,
expdesc v 
)
int luaK_jump ( FuncState fs)
void luaK_nil ( FuncState fs,
int  from,
int  n 
)
int luaK_numberK ( FuncState fs,
lua_Number  r 
)

Definition at line 325 of file lcode.cpp.

References addk(), LexState::L, FuncState::ls, luaS_newlstr(), setnvalue, setsvalue, and lua_State::top.

Referenced by discharge2reg(), fornum(), and luaK_exp2RK().

LUAI_FUNC void luaK_patchclose ( FuncState fs,
int  list,
int  level 
)
void luaK_patchlist ( FuncState fs,
int  list,
int  target 
)

Definition at line 168 of file lcode.cpp.

References lua_assert, luaK_patchtohere(), NO_REG, patchlistaux(), and FuncState::pc.

Referenced by closegoto(), forbody(), and repeatstat().

void luaK_patchtohere ( FuncState fs,
int  list 
)
void luaK_posfix ( FuncState fs,
BinOpr  op,
expdesc e1,
expdesc e2,
int  line 
)
void luaK_prefix ( FuncState fs,
UnOpr  op,
expdesc e,
int  line 
)
void luaK_reserveregs ( FuncState fs,
int  n 
)
void luaK_ret ( FuncState fs,
int  first,
int  nret 
)

Definition at line 68 of file lcode.cpp.

References luaK_codeABC(), and OP_RETURN.

Referenced by close_func(), and retstat().

void luaK_self ( FuncState fs,
expdesc e,
expdesc key 
)
void luaK_setlist ( FuncState fs,
int  base,
int  nelems,
int  tostore 
)
void luaK_setoneret ( FuncState fs,
expdesc e 
)

Definition at line 370 of file lcode.cpp.

References GETARG_A, getcode, expdesc::info, expdesc::k, SETARG_B, expdesc::u, VCALL, VNONRELOC, VRELOCABLE, and VVARARG.

Referenced by assignment(), and luaK_dischargevars().

void luaK_setreturns ( FuncState fs,
expdesc e,
int  nresults 
)

Definition at line 358 of file lcode.cpp.

References FuncState::freereg, getcode, expdesc::k, luaK_reserveregs(), SETARG_A, SETARG_B, SETARG_C, VCALL, and VVARARG.

Referenced by adjust_assign().

void luaK_storevar ( FuncState fs,
expdesc var,
expdesc ex 
)
int luaK_stringK ( FuncState fs,
TString s 
)

Definition at line 318 of file lcode.cpp.

References addk(), LexState::L, FuncState::ls, and setsvalue.

Referenced by codestring().

static int need_value ( FuncState fs,
int  list 
)
static

Definition at line 121 of file lcode.cpp.

References GET_OPCODE, getjump(), getjumpcontrol(), i, NO_JUMP, and OP_TESTSET.

Referenced by exp2reg().

static int nilK ( FuncState fs)
static

Definition at line 349 of file lcode.cpp.

References addk(), FuncState::h, LexState::L, FuncState::ls, sethvalue, and setnilvalue.

Referenced by luaK_exp2RK().

static void patchlistaux ( FuncState fs,
int  list,
int  vtarget,
int  reg,
int  dtarget 
)
static

Definition at line 149 of file lcode.cpp.

References fixjump(), getjump(), next, NO_JUMP, and patchtestreg().

Referenced by dischargejpc(), exp2reg(), and luaK_patchlist().

static int patchtestreg ( FuncState fs,
int  node,
int  reg 
)
static

Definition at line 130 of file lcode.cpp.

References CREATE_ABC, GET_OPCODE, GETARG_B, GETARG_C, getjumpcontrol(), i, NO_REG, OP_TEST, OP_TESTSET, and SETARG_A.

Referenced by patchlistaux(), and removevalues().

static void removevalues ( FuncState fs,
int  list 
)
static

Definition at line 143 of file lcode.cpp.

References getjump(), NO_JUMP, NO_REG, and patchtestreg().

Referenced by codenot().