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 "ltable.h"

Go to the source code of this file.

Defines

#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)
void luaK_patchtohere (FuncState *fs, int list)
void luaK_concat (FuncState *fs, int *l1, int l2)
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 *k, 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_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)
static 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)
static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1, expdesc *e2)
void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e)
void luaK_infix (FuncState *fs, BinOpr op, expdesc *v)
void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2)
void luaK_fixline (FuncState *fs, int line)
static int luaK_code (FuncState *fs, Instruction i, int line)
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)
void luaK_setlist (FuncState *fs, int base, int nelems, int tostore)


Define Documentation

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

Definition at line 27 of file lcode.cpp.

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

#define lcode_c

Definition at line 10 of file lcode.cpp.

#define LUA_CORE

Definition at line 11 of file lcode.cpp.


Function Documentation

static int addk ( FuncState fs,
TValue k,
TValue v 
) [static]

Definition at line 229 of file lcode.cpp.

References cast_int, cast_num, FuncState::f, FuncState::h, Proto::k, FuncState::L, lua_assert, luaC_barrier, luaH_set(), luaM_growvector, luaO_rawequalObj(), MAXARG_Bx, FuncState::nk, nvalue, setnilvalue, setnvalue, setobj, Proto::sizek, and ttisnumber.

Referenced by boolK(), luaK_numberK(), luaK_stringK(), and nilK().

static int boolK ( FuncState fs,
int  b 
) [static]

Definition at line 264 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 337 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 
) [static]

Definition at line 661 of file lcode.cpp.

References constfolding(), freeexp(), expdesc::k, luaK_codeABC(), luaK_exp2RK(), OP_LEN, OP_UNM, expdesc::s, expdesc::u, and VRELOCABLE.

Referenced by luaK_posfix(), and luaK_prefix().

static void codecomp ( FuncState fs,
OpCode  op,
int  cond,
expdesc e1,
expdesc e2 
) [static]

Definition at line 681 of file lcode.cpp.

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

Referenced by luaK_posfix().

static void codenot ( FuncState fs,
expdesc e 
) [static]

Definition at line 594 of file lcode.cpp.

References discharge2anyreg(), expdesc::f, freeexp(), invertjump(), expdesc::k, lua_assert, luaK_codeABC(), luaK_dischargevars(), OP_NOT, removevalues(), expdesc::s, expdesc::t, expdesc::u, VFALSE, VJMP, VK, VKNUM, VNIL, VNONRELOC, VRELOCABLE, and VTRUE.

Referenced by luaK_prefix().

static int condjump ( FuncState fs,
OpCode  op,
int  A,
int  B,
int  C 
) [static]

Definition at line 74 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 635 of file lcode.cpp.

References isnumeral(), lua_assert, expdesc::nval, OP_ADD, OP_DIV, OP_LEN, OP_MOD, OP_MUL, OP_POW, OP_SUB, OP_UNM, and expdesc::u.

Referenced by codearith().

static void discharge2anyreg ( FuncState fs,
expdesc e 
) [static]

Definition at line 382 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]

Definition at line 343 of file lcode.cpp.

References getcode, expdesc::k, lua_assert, luaK_codeABC(), luaK_codeABx(), luaK_dischargevars(), luaK_nil(), luaK_numberK(), expdesc::nval, OP_LOADBOOL, OP_LOADK, OP_MOVE, expdesc::s, SETARG_A, expdesc::u, VFALSE, VJMP, VK, VKNUM, VNIL, VNONRELOC, VRELOCABLE, VTRUE, and VVOID.

Referenced by discharge2anyreg(), and exp2reg().

static void dischargejpc ( FuncState fs  )  [static]

Definition at line 163 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]

Definition at line 390 of file lcode.cpp.

References code_label(), discharge2reg(), expdesc::f, hasjumps, expdesc::k, luaK_concat(), luaK_getlabel(), luaK_jump(), luaK_patchtohere(), need_value(), NO_JUMP, patchlistaux(), expdesc::s, expdesc::t, expdesc::u, VJMP, and VNONRELOC.

Referenced by luaK_exp2anyreg(), luaK_exp2nextreg(), and luaK_storevar().

static void fixjump ( FuncState fs,
int  pc,
int  dest 
) [static]

Definition at line 80 of file lcode.cpp.

References Proto::code, FuncState::f, FuncState::ls, lua_assert, luaX_syntaxerror(), MAXARG_sBx, NO_JUMP, and SETARG_sBx.

Referenced by luaK_concat(), and patchlistaux().

static void freeexp ( FuncState fs,
expdesc e 
) [static]

Definition at line 223 of file lcode.cpp.

References freereg(), expdesc::k, expdesc::s, expdesc::u, and VNONRELOC.

Referenced by codearith(), codecomp(), codenot(), jumponcond(), luaK_exp2nextreg(), luaK_posfix(), luaK_self(), and luaK_storevar().

static void freereg ( FuncState fs,
int  reg 
) [static]

Definition at line 215 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 100 of file lcode.cpp.

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

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

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

Definition at line 109 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]

Definition at line 516 of file lcode.cpp.

References GET_OPCODE, GETARG_A, getjumpcontrol(), lua_assert, OP_TEST, OP_TESTSET, expdesc::s, SETARG_A, testTMode, and expdesc::u.

Referenced by codenot(), and luaK_goiftrue().

static int isnumeral ( expdesc e  )  [static]

Definition at line 30 of file lcode.cpp.

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

Referenced by constfolding(), and luaK_infix().

static int jumponcond ( FuncState fs,
expdesc e,
int  cond 
) [static]

Definition at line 524 of file lcode.cpp.

References condjump(), discharge2anyreg(), freeexp(), GET_OPCODE, GETARG_B, getcode, expdesc::k, NO_REG, OP_NOT, OP_TEST, OP_TESTSET, FuncState::pc, expdesc::s, expdesc::u, and VRELOCABLE.

Referenced by luaK_goiffalse(), and luaK_goiftrue().

void luaK_checkstack ( FuncState fs,
int  n 
)

Definition at line 199 of file lcode.cpp.

Referenced by forlist(), and luaK_reserveregs().

static int luaK_code ( FuncState fs,
Instruction  i,
int  line 
) [static]

Definition at line 797 of file lcode.cpp.

References Proto::code, dischargejpc(), FuncState::f, FuncState::L, Proto::lineinfo, luaM_growvector, MAX_INT, FuncState::pc, Proto::sizecode, and Proto::sizelineinfo.

Referenced by luaK_codeABC(), luaK_codeABx(), and luaK_setlist().

int luaK_codeABC ( FuncState fs,
OpCode  o,
int  a,
int  b,
int  c 
)

Definition at line 812 of file lcode.cpp.

Referenced by breakstat(), check_conflict(), code_label(), codearith(), codenot(), condjump(), constructor(), discharge2reg(), forbody(), funcargs(), leaveblock(), luaK_dischargevars(), luaK_nil(), luaK_ret(), luaK_self(), luaK_setlist(), luaK_storevar(), pushclosure(), recfield(), and simpleexp().

int luaK_codeABx ( FuncState fs,
OpCode  o,
int  a,
unsigned int  bc 
)

Definition at line 820 of file lcode.cpp.

Referenced by discharge2reg(), fornum(), luaK_dischargevars(), luaK_storevar(), and pushclosure().

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

Definition at line 185 of file lcode.cpp.

Referenced by breakstat(), exp2reg(), ifstat(), luaK_goiffalse(), luaK_goiftrue(), luaK_jump(), luaK_patchtohere(), and luaK_posfix().

void luaK_dischargevars ( FuncState fs,
expdesc e 
)

Definition at line 304 of file lcode.cpp.

Referenced by codenot(), discharge2reg(), luaK_exp2anyreg(), luaK_exp2nextreg(), luaK_exp2val(), luaK_goiffalse(), luaK_goiftrue(), luaK_posfix(), and prefixexp().

int luaK_exp2anyreg ( FuncState fs,
expdesc e 
)

Definition at line 422 of file lcode.cpp.

Referenced by field(), luaK_exp2RK(), luaK_exp2val(), luaK_prefix(), luaK_self(), luaK_storevar(), primaryexp(), and retstat().

void luaK_exp2nextreg ( FuncState fs,
expdesc e 
)

Definition at line 414 of file lcode.cpp.

Referenced by adjust_assign(), closelistfield(), constructor(), exp1(), explist1(), funcargs(), lastlistfield(), luaK_exp2anyreg(), luaK_infix(), luaK_posfix(), primaryexp(), and retstat().

int luaK_exp2RK ( FuncState fs,
expdesc e 
)

Definition at line 444 of file lcode.cpp.

Referenced by codearith(), codecomp(), luaK_indexed(), luaK_infix(), luaK_self(), luaK_storevar(), and recfield().

void luaK_exp2val ( FuncState fs,
expdesc e 
)

Definition at line 436 of file lcode.cpp.

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

void luaK_fixline ( FuncState fs,
int  line 
)

Definition at line 792 of file lcode.cpp.

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

int luaK_getlabel ( FuncState fs  ) 

Definition at line 94 of file lcode.cpp.

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

static void luaK_goiffalse ( FuncState fs,
expdesc e 
) [static]

Definition at line 567 of file lcode.cpp.

References expdesc::f, jumponcond(), expdesc::k, luaK_concat(), luaK_dischargevars(), luaK_jump(), luaK_patchtohere(), NO_JUMP, expdesc::s, expdesc::t, expdesc::u, VFALSE, VJMP, VNIL, and VTRUE.

Referenced by luaK_infix().

void luaK_goiftrue ( FuncState fs,
expdesc e 
)

Definition at line 539 of file lcode.cpp.

Referenced by cond(), and luaK_infix().

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

Definition at line 629 of file lcode.cpp.

Referenced by field(), and primaryexp().

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

Definition at line 718 of file lcode.cpp.

Referenced by subexpr().

int luaK_jump ( FuncState fs  ) 

Definition at line 59 of file lcode.cpp.

Referenced by breakstat(), condjump(), exp2reg(), forbody(), ifstat(), luaK_goiffalse(), luaK_goiftrue(), repeatstat(), and whilestat().

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

Definition at line 35 of file lcode.cpp.

Referenced by adjust_assign(), and discharge2reg().

int luaK_numberK ( FuncState fs,
lua_Number  r 
)

Definition at line 257 of file lcode.cpp.

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

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

Definition at line 169 of file lcode.cpp.

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

void luaK_patchtohere ( FuncState fs,
int  list 
)

Definition at line 179 of file lcode.cpp.

Referenced by exp2reg(), forbody(), ifstat(), leaveblock(), luaK_goiffalse(), luaK_goiftrue(), luaK_patchlist(), repeatstat(), and whilestat().

void luaK_posfix ( FuncState fs,
BinOpr  op,
expdesc e1,
expdesc e2 
)

Definition at line 745 of file lcode.cpp.

Referenced by subexpr().

void luaK_prefix ( FuncState fs,
UnOpr  op,
expdesc e 
)

Definition at line 697 of file lcode.cpp.

Referenced by subexpr().

void luaK_reserveregs ( FuncState fs,
int  n 
)

Definition at line 209 of file lcode.cpp.

Referenced by adjust_assign(), check_conflict(), discharge2anyreg(), forbody(), fornum(), localfunc(), luaK_exp2nextreg(), luaK_self(), luaK_setreturns(), and parlist().

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

Definition at line 69 of file lcode.cpp.

Referenced by close_func(), and retstat().

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

Definition at line 503 of file lcode.cpp.

Referenced by primaryexp().

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

Definition at line 827 of file lcode.cpp.

Referenced by closelistfield(), and lastlistfield().

void luaK_setoneret ( FuncState fs,
expdesc e 
)

Definition at line 292 of file lcode.cpp.

Referenced by assignment(), and luaK_dischargevars().

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

Definition at line 280 of file lcode.cpp.

Referenced by adjust_assign().

void luaK_storevar ( FuncState fs,
expdesc var,
expdesc ex 
)

Definition at line 472 of file lcode.cpp.

Referenced by assignment(), funcstat(), and localfunc().

int luaK_stringK ( FuncState fs,
TString s 
)

Definition at line 250 of file lcode.cpp.

Referenced by codestring(), and singlevar().

static int need_value ( FuncState fs,
int  list 
) [static]

Definition at line 122 of file lcode.cpp.

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

Referenced by exp2reg().

static int nilK ( FuncState fs  )  [static]

Definition at line 271 of file lcode.cpp.

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

Referenced by luaK_exp2RK().

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

Definition at line 150 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 131 of file lcode.cpp.

References CREATE_ABC, GET_OPCODE, GETARG_B, GETARG_C, getjumpcontrol(), 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 144 of file lcode.cpp.

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

Referenced by codenot().


Generated on Mon Feb 16 15:14:58 2009 for Scorched3D by  doxygen 1.5.3