The Battle for Wesnoth  1.17.0-dev
Macros | Typedefs | Enumerations | Functions
lcode.h File Reference
#include "llex.h"
#include "lobject.h"
#include "lopcodes.h"
#include "lparser.h"
Include dependency graph for lcode.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define NO_JUMP   (-1)
 
#define foldbinop(op)   ((op) <= OPR_SHR)
 
#define luaK_codeABC(fs, o, a, b, c)   luaK_codeABCk(fs,o,a,b,c,0)
 
#define getinstruction(fs, e)   ((fs)->f->code[(e)->u.info])
 
#define luaK_setmultret(fs, e)   luaK_setreturns(fs, e, LUA_MULTRET)
 
#define luaK_jumpto(fs, t)   luaK_patchlist(fs, luaK_jump(fs), t)
 

Typedefs

typedef enum BinOpr BinOpr
 
typedef enum UnOpr UnOpr
 

Enumerations

enum  BinOpr {
  OPR_ADD, OPR_SUB, OPR_MUL, OPR_MOD,
  OPR_POW, OPR_DIV, OPR_IDIV, OPR_BAND,
  OPR_BOR, OPR_BXOR, OPR_SHL, OPR_SHR,
  OPR_CONCAT, OPR_EQ, OPR_LT, OPR_LE,
  OPR_NE, OPR_GT, OPR_GE, OPR_AND,
  OPR_OR, OPR_NOBINOPR
}
 
enum  UnOpr {
  OPR_MINUS, OPR_BNOT, OPR_NOT, OPR_LEN,
  OPR_NOUNOPR
}
 

Functions

LUAI_FUNC int luaK_code (FuncState *fs, Instruction i)
 
LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx)
 
LUAI_FUNC int luaK_codeAsBx (FuncState *fs, OpCode o, int A, int Bx)
 
LUAI_FUNC int luaK_codeABCk (FuncState *fs, OpCode o, int A, int B, int C, int k)
 
LUAI_FUNC int luaK_isKint (expdesc *e)
 
LUAI_FUNC int luaK_exp2const (FuncState *fs, const expdesc *e, TValue *v)
 
LUAI_FUNC void luaK_fixline (FuncState *fs, int line)
 
LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n)
 
LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n)
 
LUAI_FUNC void luaK_checkstack (FuncState *fs, int n)
 
LUAI_FUNC void luaK_int (FuncState *fs, int reg, lua_Integer n)
 
LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e)
 
LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e)
 
LUAI_FUNC void luaK_exp2anyregup (FuncState *fs, expdesc *e)
 
LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e)
 
LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e)
 
LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e)
 
LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key)
 
LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k)
 
LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e)
 
LUAI_FUNC void luaK_goiffalse (FuncState *fs, expdesc *e)
 
LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e)
 
LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults)
 
LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e)
 
LUAI_FUNC int luaK_jump (FuncState *fs)
 
LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret)
 
LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target)
 
LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list)
 
LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2)
 
LUAI_FUNC int luaK_getlabel (FuncState *fs)
 
LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v, int line)
 
LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v)
 
LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, expdesc *v2, int line)
 
LUAI_FUNC void luaK_settablesize (FuncState *fs, int pc, int ra, int asize, int hsize)
 
LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore)
 
LUAI_FUNC void luaK_finish (FuncState *fs)
 
LUAI_FUNC l_noret luaK_semerror (LexState *ls, const char *msg)
 

Macro Definition Documentation

◆ foldbinop

#define foldbinop (   op)    ((op) <= OPR_SHR)

Definition at line 45 of file lcode.h.

Referenced by luaK_posfix().

◆ getinstruction

#define getinstruction (   fs,
  e 
)    ((fs)->f->code[(e)->u.info])

Definition at line 55 of file lcode.h.

Referenced by discharge2reg(), exprstat(), jumponcond(), luaK_setoneret(), luaK_setreturns(), and retstat().

◆ luaK_codeABC

#define luaK_codeABC (   fs,
  o,
  a,
  b,
  c 
)    luaK_codeABCk(fs,o,a,b,c,0)

◆ luaK_jumpto

#define luaK_jumpto (   fs,
  t 
)    luaK_patchlist(fs, luaK_jump(fs), t)

Definition at line 60 of file lcode.h.

Referenced by whilestat().

◆ luaK_setmultret

#define luaK_setmultret (   fs,
  e 
)    luaK_setreturns(fs, e, LUA_MULTRET)

Definition at line 58 of file lcode.h.

Referenced by funcargs(), lastlistfield(), and retstat().

◆ NO_JUMP

#define NO_JUMP   (-1)

Typedef Documentation

◆ BinOpr

typedef enum BinOpr BinOpr

◆ UnOpr

typedef enum UnOpr UnOpr

Enumeration Type Documentation

◆ BinOpr

enum BinOpr
Enumerator
OPR_ADD 
OPR_SUB 
OPR_MUL 
OPR_MOD 
OPR_POW 
OPR_DIV 
OPR_IDIV 
OPR_BAND 
OPR_BOR 
OPR_BXOR 
OPR_SHL 
OPR_SHR 
OPR_CONCAT 
OPR_EQ 
OPR_LT 
OPR_LE 
OPR_NE 
OPR_GT 
OPR_GE 
OPR_AND 
OPR_OR 
OPR_NOBINOPR 

Definition at line 26 of file lcode.h.

◆ UnOpr

enum UnOpr
Enumerator
OPR_MINUS 
OPR_BNOT 
OPR_NOT 
OPR_LEN 
OPR_NOUNOPR 

Definition at line 51 of file lcode.h.

Function Documentation

◆ luaK_checkstack()

LUAI_FUNC void luaK_checkstack ( FuncState fs,
int  n 
)

◆ luaK_code()

LUAI_FUNC int luaK_code ( FuncState fs,
Instruction  i 
)

◆ luaK_codeABCk()

LUAI_FUNC int luaK_codeABCk ( FuncState fs,
OpCode  o,
int  A,
int  B,
int  C,
int  k 
)

Definition at line 405 of file lcode.cpp.

References CREATE_ABCk, getOpMode, iABC, lua_assert, luaK_code(), MAXARG_A, MAXARG_B, and MAXARG_C.

Referenced by codeABRK(), condjump(), finishbinexpval(), and luaK_setlist().

◆ luaK_codeABx()

LUAI_FUNC int luaK_codeABx ( FuncState fs,
OpCode  o,
int  A,
unsigned int  Bx 
)

Definition at line 416 of file lcode.cpp.

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

Referenced by codeclosure(), forbody(), and luaK_codek().

◆ luaK_codeAsBx()

LUAI_FUNC int luaK_codeAsBx ( FuncState fs,
OpCode  o,
int  A,
int  Bx 
)

Definition at line 426 of file lcode.cpp.

References b, CREATE_ABx, getOpMode, iAsBx, lua_assert, luaK_code(), MAXARG_A, MAXARG_Bx, and OFFSET_sBx.

Referenced by luaK_float(), and luaK_int().

◆ luaK_concat()

LUAI_FUNC void luaK_concat ( FuncState fs,
int *  l1,
int  l2 
)

Definition at line 180 of file lcode.cpp.

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

Referenced by exp2reg(), luaK_goiffalse(), luaK_goiftrue(), luaK_posfix(), and test_then_block().

◆ luaK_dischargevars()

LUAI_FUNC void luaK_dischargevars ( FuncState fs,
expdesc e 
)

◆ luaK_exp2anyreg()

LUAI_FUNC int luaK_exp2anyreg ( FuncState fs,
expdesc e 
)

◆ luaK_exp2anyregup()

LUAI_FUNC void luaK_exp2anyregup ( FuncState fs,
expdesc e 
)

Definition at line 963 of file lcode.cpp.

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

Referenced by fieldsel(), and suffixedexp().

◆ luaK_exp2const()

LUAI_FUNC int luaK_exp2const ( FuncState fs,
const expdesc e,
TValue v 
)

◆ luaK_exp2nextreg()

LUAI_FUNC void luaK_exp2nextreg ( FuncState fs,
expdesc e 
)

◆ luaK_exp2RK()

LUAI_FUNC int luaK_exp2RK ( FuncState fs,
expdesc e 
)

Definition at line 1015 of file lcode.cpp.

References luaK_exp2anyreg(), and luaK_exp2K().

Referenced by codeABRK(), codebitwise(), codeeq(), and luaK_infix().

◆ luaK_exp2val()

LUAI_FUNC void luaK_exp2val ( FuncState fs,
expdesc e 
)

Definition at line 973 of file lcode.cpp.

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

Referenced by yindex().

◆ luaK_finish()

LUAI_FUNC void luaK_finish ( FuncState fs)

◆ luaK_fixline()

LUAI_FUNC void luaK_fixline ( FuncState fs,
int  line 
)

◆ luaK_getlabel()

LUAI_FUNC int luaK_getlabel ( FuncState fs)

◆ luaK_goiffalse()

LUAI_FUNC void luaK_goiffalse ( FuncState fs,
expdesc e 
)

◆ luaK_goiftrue()

LUAI_FUNC void luaK_goiftrue ( FuncState fs,
expdesc e 
)

◆ luaK_indexed()

LUAI_FUNC void luaK_indexed ( FuncState fs,
expdesc t,
expdesc k 
)

◆ luaK_infix()

LUAI_FUNC void luaK_infix ( FuncState fs,
BinOpr  op,
expdesc v 
)

◆ luaK_int()

LUAI_FUNC void luaK_int ( FuncState fs,
int  reg,
lua_Integer  n 
)

Definition at line 659 of file lcode.cpp.

References cast_int, fitsBx(), luaK_codeAsBx(), luaK_codek(), luaK_intK(), and OP_LOADI.

Referenced by discharge2reg(), and fornum().

◆ luaK_isKint()

LUAI_FUNC int luaK_isKint ( expdesc e)

Definition at line 1215 of file lcode.cpp.

References hasjumps, expdesc::k, and VKINT.

Referenced by finishbinexpneg(), isCint(), and isSCint().

◆ luaK_jump()

LUAI_FUNC int luaK_jump ( FuncState fs)

Definition at line 198 of file lcode.cpp.

References codesJ(), NO_JUMP, and OP_JMP.

Referenced by breakstat(), condjump(), exp2reg(), gotostat(), repeatstat(), and test_then_block().

◆ luaK_nil()

LUAI_FUNC void luaK_nil ( FuncState fs,
int  from,
int  n 
)

◆ luaK_patchlist()

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

Definition at line 305 of file lcode.cpp.

References lua_assert, NO_REG, and patchlistaux().

Referenced by gotostat(), luaK_patchtohere(), repeatstat(), and solvegoto().

◆ luaK_patchtohere()

LUAI_FUNC void luaK_patchtohere ( FuncState fs,
int  list 
)

◆ luaK_posfix()

LUAI_FUNC void luaK_posfix ( FuncState fs,
BinOpr  op,
expdesc v1,
expdesc v2,
int  line 
)

◆ luaK_prefix()

LUAI_FUNC void luaK_prefix ( FuncState fs,
UnOpr  op,
expdesc v,
int  line 
)

◆ luaK_reserveregs()

LUAI_FUNC void luaK_reserveregs ( FuncState fs,
int  n 
)

◆ luaK_ret()

LUAI_FUNC void luaK_ret ( FuncState fs,
int  first,
int  nret 
)

Definition at line 206 of file lcode.cpp.

References luaK_codeABC, OP_RETURN, OP_RETURN0, and OP_RETURN1.

Referenced by close_func(), and retstat().

◆ luaK_self()

LUAI_FUNC void luaK_self ( FuncState fs,
expdesc e,
expdesc key 
)

◆ luaK_semerror()

LUAI_FUNC l_noret luaK_semerror ( LexState ls,
const char *  msg 
)

◆ luaK_setlist()

LUAI_FUNC void luaK_setlist ( FuncState fs,
int  base,
int  nelems,
int  tostore 
)

◆ luaK_setoneret()

LUAI_FUNC void luaK_setoneret ( FuncState fs,
expdesc e 
)

◆ luaK_setreturns()

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

◆ luaK_settablesize()

LUAI_FUNC void luaK_settablesize ( FuncState fs,
int  pc,
int  ra,
int  asize,
int  hsize 
)

Definition at line 1736 of file lcode.cpp.

References Proto::code, CREATE_ABCk, CREATE_Ax, FuncState::f, luaO_ceillog2(), MAXARG_C, OP_EXTRAARG, and OP_NEWTABLE.

Referenced by constructor().

◆ luaK_storevar()

LUAI_FUNC void luaK_storevar ( FuncState fs,
expdesc var,
expdesc e 
)