lua/lcode.c File Reference

#include <stdlib.h>
#include "lua.h"
#include "lcode.h"
#include "ldebug.h"
#include "ldo.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 hasjumps(e)   ((e)->t != (e)->f)

Functions

void luaK_nil (FuncState *fs, int from, int n)
int luaK_jump (FuncState *fs)
static int luaK_condjump (FuncState *fs, OpCode op, int A, int B, int C)
static void luaK_fixjump (FuncState *fs, int pc, int dest)
int luaK_getlabel (FuncState *fs)
static int luaK_getjump (FuncState *fs, int pc)
static Instructiongetjumpcontrol (FuncState *fs, int pc)
static int need_value (FuncState *fs, int list, int cond)
static void patchtestreg (Instruction *i, int reg)
static void luaK_patchlistaux (FuncState *fs, int list, int ttarget, int treg, int ftarget, int freg, int dtarget)
static void luaK_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, TObject *k, TObject *v)
int luaK_stringK (FuncState *fs, TString *s)
int luaK_numberK (FuncState *fs, lua_Number r)
static int nil_constant (FuncState *fs)
void luaK_setcallreturns (FuncState *fs, expdesc *e, int nresults)
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 luaK_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 *exp)
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)
void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e)
void luaK_infix (FuncState *fs, BinOpr op, expdesc *v)
static void codebinop (FuncState *fs, expdesc *res, BinOpr op, int o1, int o2)
void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2)
void luaK_fixline (FuncState *fs, int line)
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)


Define Documentation

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

Definition at line 25 of file lcode.c.

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

#define lcode_c

Definition at line 10 of file lcode.c.


Function Documentation

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

Definition at line 229 of file lcode.c.

References cast, FuncState::f, FuncState::h, Proto::k, FuncState::L, lua_assert, luaH_get(), luaH_set(), luaM_growvector, luaO_rawequalObj(), MAXARG_Bx, FuncState::nk, nvalue, setnvalue, setobj2n, Proto::sizek, and ttisnumber.

Referenced by luaK_numberK(), luaK_stringK(), and nil_constant().

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

Definition at line 315 of file lcode.c.

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

Referenced by luaK_exp2reg().

static void codebinop ( FuncState fs,
expdesc res,
BinOpr  op,
int  o1,
int  o2 
) [static]

Definition at line 657 of file lcode.c.

References cast, cond(), expdesc::info, expdesc::k, luaK_codeABC(), luaK_condjump(), OP_ADD, OP_EQ, OP_LE, OP_LT, OPR_ADD, OPR_GT, OPR_NE, OPR_POW, ops, VJMP, and VRELOCABLE.

Referenced by luaK_posfix().

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

Definition at line 573 of file lcode.c.

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

Referenced by luaK_prefix().

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

Definition at line 360 of file lcode.c.

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

Referenced by codenot(), and jumponcond().

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

Definition at line 323 of file lcode.c.

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

Referenced by discharge2anyreg(), and luaK_exp2reg().

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

Definition at line 221 of file lcode.c.

References freereg(), expdesc::info, expdesc::k, and VNONRELOC.

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

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

Definition at line 211 of file lcode.c.

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

Referenced by freeexp(), and luaK_dischargevars().

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

Definition at line 95 of file lcode.c.

References Proto::code, FuncState::f, GET_OPCODE, OpModeT, and testOpMode.

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

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

Definition at line 495 of file lcode.c.

References GET_OPCODE, GETARG_A, getjumpcontrol(), expdesc::info, lua_assert, OP_TEST, OpModeT, SETARG_A, and testOpMode.

Referenced by codenot(), and luaK_goiftrue().

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

Definition at line 505 of file lcode.c.

References discharge2anyreg(), freeexp(), GET_OPCODE, GETARG_B, getcode, expdesc::info, expdesc::k, luaK_condjump(), NO_REG, OP_NOT, OP_TEST, FuncState::pc, and VRELOCABLE.

Referenced by luaK_goiffalse(), and luaK_goiftrue().

void luaK_checkstack ( FuncState fs,
int  n 
)

Definition at line 195 of file lcode.c.

References cast, FuncState::f, FuncState::freereg, FuncState::ls, luaX_syntaxerror(), MAXSTACK, and Proto::maxstacksize.

Referenced by forlist(), and luaK_reserveregs().

int luaK_code ( FuncState fs,
Instruction  i,
int  line 
)

Definition at line 729 of file lcode.c.

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

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

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

Definition at line 744 of file lcode.c.

References CREATE_ABC, getOpMode, iABC, LexState::lastline, FuncState::ls, lua_assert, and luaK_code().

Referenced by breakstat(), close_func(), code_label(), codebinop(), codenot(), constructor(), discharge2reg(), forbody(), fornum(), funcargs(), leaveblock(), luaK_condjump(), luaK_dischargevars(), luaK_nil(), luaK_posfix(), luaK_prefix(), luaK_self(), luaK_storevar(), pushclosure(), recfield(), and retstat().

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

Definition at line 750 of file lcode.c.

References CREATE_ABx, getOpMode, iABx, iAsBx, LexState::lastline, FuncState::ls, lua_assert, and luaK_code().

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

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

Definition at line 181 of file lcode.c.

References luaK_fixjump(), luaK_getjump(), next, and NO_JUMP.

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

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

Definition at line 54 of file lcode.c.

References luaK_codeABC(), and luaK_jump().

Referenced by codebinop(), and jumponcond().

static void luaK_dischargejpc ( FuncState fs  )  [static]

Definition at line 157 of file lcode.c.

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

Referenced by luaK_code().

void luaK_dischargevars ( FuncState fs,
expdesc e 
)

Definition at line 283 of file lcode.c.

References expdesc::aux, freereg(), expdesc::info, expdesc::k, luaK_codeABC(), luaK_codeABx(), luaK_setcallreturns(), OP_GETGLOBAL, OP_GETTABLE, OP_GETUPVAL, VCALL, VGLOBAL, VINDEXED, VLOCAL, VNONRELOC, VRELOCABLE, and VUPVAL.

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 406 of file lcode.c.

References hasjumps, expdesc::info, expdesc::k, luaK_dischargevars(), luaK_exp2nextreg(), luaK_exp2reg(), FuncState::nactvar, and VNONRELOC.

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

void luaK_exp2nextreg ( FuncState fs,
expdesc e 
)

Definition at line 398 of file lcode.c.

References freeexp(), FuncState::freereg, luaK_dischargevars(), luaK_exp2reg(), and luaK_reserveregs().

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

static void luaK_exp2reg ( FuncState fs,
expdesc e,
int  reg 
) [static]

Definition at line 370 of file lcode.c.

References code_label(), discharge2reg(), expdesc::f, hasjumps, expdesc::info, expdesc::k, luaK_concat(), luaK_getlabel(), luaK_jump(), luaK_patchlistaux(), luaK_patchtohere(), need_value(), NO_JUMP, NO_REG, expdesc::t, VJMP, and VNONRELOC.

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

int luaK_exp2RK ( FuncState fs,
expdesc e 
)

Definition at line 428 of file lcode.c.

References expdesc::info, expdesc::k, luaK_exp2anyreg(), luaK_exp2val(), MAXARG_C, MAXSTACK, nil_constant(), FuncState::nk, VK, and VNIL.

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

void luaK_exp2val ( FuncState fs,
expdesc e 
)

Definition at line 420 of file lcode.c.

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

Referenced by luaK_exp2RK(), luaK_posfix(), luaK_prefix(), and luaY_index().

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

Definition at line 62 of file lcode.c.

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

Referenced by luaK_concat(), and luaK_patchlistaux().

void luaK_fixline ( FuncState fs,
int  line 
)

Definition at line 724 of file lcode.c.

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

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

static int luaK_getjump ( FuncState fs,
int  pc 
) [static]

Definition at line 84 of file lcode.c.

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

Referenced by luaK_concat(), luaK_patchlistaux(), and need_value().

int luaK_getlabel ( FuncState fs  ) 

Definition at line 78 of file lcode.c.

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

Referenced by code_label(), forbody(), luaK_exp2reg(), luaK_patchtohere(), repeatstat(), and whilestat().

void luaK_goiffalse ( FuncState fs,
expdesc e 
)

Definition at line 548 of file lcode.c.

References expdesc::info, jumponcond(), expdesc::k, luaK_concat(), luaK_dischargevars(), luaK_jump(), NO_JUMP, expdesc::t, VFALSE, VJMP, VNIL, and VTRUE.

Referenced by luaK_infix(), and whilestat().

void luaK_goiftrue ( FuncState fs,
expdesc e 
)

Definition at line 522 of file lcode.c.

References expdesc::f, expdesc::info, invertjump(), jumponcond(), expdesc::k, luaK_concat(), luaK_dischargevars(), luaK_jump(), NO_JUMP, VFALSE, VJMP, VK, and VTRUE.

Referenced by cond(), and luaK_infix().

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

Definition at line 608 of file lcode.c.

References expdesc::aux, expdesc::k, luaK_exp2RK(), and VINDEXED.

Referenced by luaY_field(), and primaryexp().

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

Definition at line 631 of file lcode.c.

References expdesc::f, luaK_exp2nextreg(), luaK_exp2RK(), luaK_goiffalse(), luaK_goiftrue(), luaK_patchtohere(), NO_JUMP, OPR_AND, OPR_CONCAT, OPR_OR, and expdesc::t.

Referenced by subexpr().

int luaK_jump ( FuncState fs  ) 

Definition at line 44 of file lcode.c.

References FuncState::jpc, luaK_codeAsBx, luaK_concat(), NO_JUMP, and OP_JMP.

Referenced by breakstat(), forbody(), fornum(), ifstat(), luaK_condjump(), luaK_exp2reg(), luaK_goiffalse(), luaK_goiftrue(), and whilestat().

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

Definition at line 28 of file lcode.c.

References Proto::code, FuncState::f, GET_OPCODE, GETARG_A, GETARG_B, FuncState::lasttarget, luaK_codeABC(), OP_LOADNIL, FuncState::pc, and SETARG_B.

Referenced by adjust_assign(), and discharge2reg().

int luaK_numberK ( FuncState fs,
lua_Number  r 
)

Definition at line 255 of file lcode.c.

References addk(), and setnvalue.

Referenced by fornum(), luaK_prefix(), and simpleexp().

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

Definition at line 165 of file lcode.c.

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

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

static void luaK_patchlistaux ( FuncState fs,
int  list,
int  ttarget,
int  treg,
int  ftarget,
int  freg,
int  dtarget 
) [static]

Definition at line 129 of file lcode.c.

References GET_OPCODE, GETARG_C, getjumpcontrol(), lua_assert, luaK_fixjump(), luaK_getjump(), next, NO_JUMP, OP_TEST, and patchtestreg().

Referenced by luaK_dischargejpc(), luaK_exp2reg(), and luaK_patchlist().

void luaK_patchtohere ( FuncState fs,
int  list 
)

Definition at line 175 of file lcode.c.

References FuncState::jpc, luaK_concat(), and luaK_getlabel().

Referenced by cond(), forbody(), ifstat(), leaveblock(), luaK_exp2reg(), luaK_infix(), luaK_patchlist(), and whilestat().

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

Definition at line 680 of file lcode.c.

References expdesc::aux, codebinop(), expdesc::f, freeexp(), GET_OPCODE, GETARG_B, getcode, expdesc::info, expdesc::k, lua_assert, luaK_codeABC(), luaK_concat(), luaK_dischargevars(), luaK_exp2nextreg(), luaK_exp2RK(), luaK_exp2val(), NO_JUMP, OP_CONCAT, OPR_AND, OPR_CONCAT, OPR_OR, SETARG_B, expdesc::t, and VRELOCABLE.

Referenced by subexpr().

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

Definition at line 614 of file lcode.c.

References codenot(), freeexp(), expdesc::info, expdesc::k, luaK_codeABC(), luaK_exp2anyreg(), luaK_exp2val(), luaK_numberK(), nvalue, OP_UNM, OPR_MINUS, ttisnumber, VK, and VRELOCABLE.

Referenced by subexpr().

void luaK_reserveregs ( FuncState fs,
int  n 
)

Definition at line 205 of file lcode.c.

References FuncState::freereg, and luaK_checkstack().

Referenced by adjust_assign(), code_params(), discharge2anyreg(), fornum(), localfunc(), luaK_exp2nextreg(), and luaK_self().

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

Definition at line 482 of file lcode.c.

References freeexp(), FuncState::freereg, CCallS::func, expdesc::info, expdesc::k, luaK_codeABC(), luaK_exp2anyreg(), luaK_exp2RK(), luaK_reserveregs(), OP_SELF, and VNONRELOC.

Referenced by primaryexp().

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

Definition at line 272 of file lcode.c.

References GETARG_A, getcode, expdesc::info, expdesc::k, SETARG_C, VCALL, and VNONRELOC.

Referenced by adjust_assign(), assignment(), exprstat(), funcargs(), lastlistfield(), luaK_dischargevars(), and retstat().

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

Definition at line 451 of file lcode.c.

References expdesc::aux, freeexp(), expdesc::info, expdesc::k, lua_assert, luaK_codeABC(), luaK_codeABx(), luaK_exp2anyreg(), luaK_exp2reg(), luaK_exp2RK(), OP_SETGLOBAL, OP_SETTABLE, OP_SETUPVAL, VGLOBAL, VINDEXED, VLOCAL, and VUPVAL.

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

int luaK_stringK ( FuncState fs,
TString s 
)

Definition at line 248 of file lcode.c.

References addk(), and setsvalue.

Referenced by codestring(), and singlevaraux().

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

Definition at line 110 of file lcode.c.

References GET_OPCODE, GETARG_C, getjumpcontrol(), luaK_getjump(), NO_JUMP, and OP_TEST.

Referenced by luaK_exp2reg().

static int nil_constant ( FuncState fs  )  [static]

Definition at line 262 of file lcode.c.

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

Referenced by luaK_exp2RK().

static void patchtestreg ( Instruction i,
int  reg 
) [static]

Definition at line 121 of file lcode.c.

References GETARG_B, NO_REG, and SETARG_A.

Referenced by luaK_patchlistaux().


Generated on Fri Oct 12 08:44:55 2007 for rpm by  doxygen 1.5.2