Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
lcode.h File Reference
#include "llex.h"
#include "lobject.h"
#include "lopcodes.h"
#include "lparser.h"

Go to the source code of this file.

Macros

#define NO_JUMP   (-1)
 
#define getcode(fs, e)   ((fs)->f->code[(e)->u.info])
 
#define luaK_codeAsBx(fs, o, A, sBx)   luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx)
 
#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_DIV ,
  OPR_MOD , OPR_POW , 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_NOT , OPR_LEN , OPR_NOUNOPR }
 

Functions

LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx)
 
LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C)
 
LUAI_FUNC int luaK_codek (FuncState *fs, int reg, int k)
 
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 int luaK_stringK (FuncState *fs, TString *s)
 
LUAI_FUNC int luaK_numberK (FuncState *fs, lua_Number r)
 
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_patchclose (FuncState *fs, int list, int level)
 
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_setlist (FuncState *fs, int base, int nelems, int tostore)
 

Macro Definition Documentation

◆ getcode

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

Definition at line 39 of file lua-5.2.4/src/lcode.h.

◆ luaK_codeAsBx

#define luaK_codeAsBx ( fs,
o,
A,
sBx )   luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx)

Definition at line 41 of file lua-5.2.4/src/lcode.h.

◆ luaK_jumpto

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

Definition at line 45 of file lua-5.2.4/src/lcode.h.

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

◆ luaK_setmultret

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

Definition at line 43 of file lua-5.2.4/src/lcode.h.

◆ NO_JUMP

#define NO_JUMP   (-1)

Definition at line 20 of file lua-5.2.4/src/lcode.h.

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_DIV 
OPR_MOD 
OPR_POW 
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 lua-5.2.4/src/lcode.h.

◆ UnOpr

enum UnOpr
Enumerator
OPR_MINUS 
OPR_NOT 
OPR_LEN 
OPR_NOUNOPR 

Definition at line 36 of file lua-5.2.4/src/lcode.h.

Function Documentation

◆ luaK_checkstack()

LUAI_FUNC void luaK_checkstack ( FuncState * fs,
int n )

Definition at line 199 of file lua-5.1.5/src/lcode.c.

199 {
200 int newstack = fs->freereg + n;
201 if (newstack > fs->f->maxstacksize) {
202 if (newstack >= MAXSTACK)
203 luaX_syntaxerror(fs->ls, "function or expression too complex");
204 fs->f->maxstacksize = cast_byte(newstack);
205 }
206}
void luaX_syntaxerror(LexState *ls, const char *msg)
#define cast_byte(i)
#define MAXSTACK
struct LexState * ls
lu_byte maxstacksize

◆ luaK_codeABC()

LUAI_FUNC int luaK_codeABC ( FuncState * fs,
OpCode o,
int A,
int B,
int C )

Definition at line 804 of file lua-5.1.5/src/lcode.c.

804 {
806 lua_assert(getBMode(o) != OpArgN || b == 0);
807 lua_assert(getCMode(o) != OpArgN || c == 0);
808 return luaK_code(fs, CREATE_ABC(o, a, b, c), fs->ls->lastline);
809}
static int luaK_code(FuncState *fs, Instruction i, int line)
#define lua_assert(c)
#define CREATE_ABC(o, a, b, c)
#define getCMode(m)
#define getBMode(m)
#define getOpMode(m)

◆ luaK_codeABx()

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

Definition at line 812 of file lua-5.1.5/src/lcode.c.

812 {
813 lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx);
815 return luaK_code(fs, CREATE_ABx(o, a, bc), fs->ls->lastline);
816}
#define CREATE_ABx(o, a, bc)

◆ luaK_codek()

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

Definition at line 250 of file lua-5.2.4/src/lcode.c.

250 {
251 if (k <= MAXARG_Bx)
252 return luaK_codeABx(fs, OP_LOADK, reg, k);
253 else {
254 int p = luaK_codeABx(fs, OP_LOADKX, reg, 0);
255 codeextraarg(fs, k);
256 return p;
257 }
258}
#define MAXARG_Bx
int luaK_codeABx(FuncState *fs, OpCode o, int a, unsigned int bc)
static int codeextraarg(FuncState *fs, int a)

◆ luaK_concat()

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

Definition at line 185 of file lua-5.1.5/src/lcode.c.

185 {
186 if (l2 == NO_JUMP) return;
187 else if (*l1 == NO_JUMP)
188 *l1 = l2;
189 else {
190 int list = *l1;
191 int next;
192 while ((next = getjump(fs, list)) != NO_JUMP) /* find last element */
193 list = next;
194 fixjump(fs, list, l2);
195 }
196}
static void fixjump(FuncState *fs, int pc, int dest)
static int getjump(FuncState *fs, int pc)
#define NO_JUMP
#define next(ls)

◆ luaK_dischargevars()

LUAI_FUNC void luaK_dischargevars ( FuncState * fs,
expdesc * e )

Definition at line 304 of file lua-5.1.5/src/lcode.c.

304 {
305 switch (e->k) {
306 case VLOCAL: {
307 e->k = VNONRELOC;
308 break;
309 }
310 case VUPVAL: {
311 e->u.s.info = luaK_codeABC(fs, OP_GETUPVAL, 0, e->u.s.info, 0);
312 e->k = VRELOCABLE;
313 break;
314 }
315 case VGLOBAL: {
316 e->u.s.info = luaK_codeABx(fs, OP_GETGLOBAL, 0, e->u.s.info);
317 e->k = VRELOCABLE;
318 break;
319 }
320 case VINDEXED: {
321 freereg(fs, e->u.s.aux);
322 freereg(fs, e->u.s.info);
323 e->u.s.info = luaK_codeABC(fs, OP_GETTABLE, 0, e->u.s.info, e->u.s.aux);
324 e->k = VRELOCABLE;
325 break;
326 }
327 case VVARARG:
328 case VCALL: {
329 luaK_setoneret(fs, e);
330 break;
331 }
332 default: break; /* there is one value available (somewhere) */
333 }
334}
static void freereg(FuncState *fs, int reg)
int luaK_codeABx(FuncState *fs, OpCode o, int a, unsigned int bc)
void luaK_setoneret(FuncState *fs, expdesc *e)
#define luaK_codeABC(fs, o, a, b, c)
struct expdesc::@52::@53 s
union expdesc::@52 u

◆ luaK_exp2anyreg()

LUAI_FUNC int luaK_exp2anyreg ( FuncState * fs,
expdesc * e )

Definition at line 422 of file lua-5.1.5/src/lcode.c.

422 {
423 luaK_dischargevars(fs, e);
424 if (e->k == VNONRELOC) {
425 if (!hasjumps(e)) return e->u.s.info; /* exp is already in a register */
426 if (e->u.s.info >= fs->nactvar) { /* reg. is not a local? */
427 exp2reg(fs, e, e->u.s.info); /* put value on it */
428 return e->u.s.info;
429 }
430 }
431 luaK_exp2nextreg(fs, e); /* default */
432 return e->u.s.info;
433}
void luaK_exp2nextreg(FuncState *fs, expdesc *e)
#define hasjumps(e)
void luaK_dischargevars(FuncState *fs, expdesc *e)
static void exp2reg(FuncState *fs, expdesc *e, int reg)

◆ luaK_exp2anyregup()

LUAI_FUNC void luaK_exp2anyregup ( FuncState * fs,
expdesc * e )

Definition at line 514 of file lua-5.2.4/src/lcode.c.

514 {
515 if (e->k != VUPVAL || hasjumps(e))
516 luaK_exp2anyreg(fs, e);
517}
#define hasjumps(e)
int luaK_exp2anyreg(FuncState *fs, expdesc *e)

◆ luaK_exp2nextreg()

LUAI_FUNC void luaK_exp2nextreg ( FuncState * fs,
expdesc * e )

Definition at line 414 of file lua-5.1.5/src/lcode.c.

414 {
415 luaK_dischargevars(fs, e);
416 freeexp(fs, e);
417 luaK_reserveregs(fs, 1);
418 exp2reg(fs, e, fs->freereg - 1);
419}
static void freeexp(FuncState *fs, expdesc *e)
void luaK_reserveregs(FuncState *fs, int n)

◆ luaK_exp2RK()

LUAI_FUNC int luaK_exp2RK ( FuncState * fs,
expdesc * e )

Definition at line 444 of file lua-5.1.5/src/lcode.c.

444 {
445 luaK_exp2val(fs, e);
446 switch (e->k) {
447 case VKNUM:
448 case VTRUE:
449 case VFALSE:
450 case VNIL: {
451 if (fs->nk <= MAXINDEXRK) { /* constant fit in RK operand? */
452 e->u.s.info = (e->k == VNIL) ? nilK(fs) :
453 (e->k == VKNUM) ? luaK_numberK(fs, e->u.nval) :
454 boolK(fs, (e->k == VTRUE));
455 e->k = VK;
456 return RKASK(e->u.s.info);
457 }
458 else break;
459 }
460 case VK: {
461 if (e->u.s.info <= MAXINDEXRK) /* constant fit in argC? */
462 return RKASK(e->u.s.info);
463 else break;
464 }
465 default: break;
466 }
467 /* not a constant in the right range: put it in a register */
468 return luaK_exp2anyreg(fs, e);
469}
int luaK_numberK(FuncState *fs, lua_Number r)
void luaK_exp2val(FuncState *fs, expdesc *e)
static int nilK(FuncState *fs)
int luaK_exp2anyreg(FuncState *fs, expdesc *e)
static int boolK(FuncState *fs, int b)
#define RKASK(x)
#define MAXINDEXRK
lua_Number nval

◆ luaK_exp2val()

LUAI_FUNC void luaK_exp2val ( FuncState * fs,
expdesc * e )

Definition at line 436 of file lua-5.1.5/src/lcode.c.

436 {
437 if (hasjumps(e))
438 luaK_exp2anyreg(fs, e);
439 else
440 luaK_dischargevars(fs, e);
441}

◆ luaK_fixline()

LUAI_FUNC void luaK_fixline ( FuncState * fs,
int line )

Definition at line 784 of file lua-5.1.5/src/lcode.c.

784 {
785 fs->f->lineinfo[fs->pc - 1] = line;
786}

◆ luaK_getlabel()

LUAI_FUNC int luaK_getlabel ( FuncState * fs)

Definition at line 94 of file lua-5.1.5/src/lcode.c.

94 {
95 fs->lasttarget = fs->pc;
96 return fs->pc;
97}

◆ luaK_goiffalse()

LUAI_FUNC void luaK_goiffalse ( FuncState * fs,
expdesc * e )

Definition at line 645 of file lua-5.2.4/src/lcode.c.

645 {
646 int pc; /* pc of last jump */
647 luaK_dischargevars(fs, e);
648 switch (e->k) {
649 case VJMP: {
650 pc = e->u.info;
651 break;
652 }
653 case VNIL: case VFALSE: {
654 pc = NO_JUMP; /* always false; do nothing */
655 break;
656 }
657 default: {
658 pc = jumponcond(fs, e, 1);
659 break;
660 }
661 }
662 luaK_concat(fs, &e->t, pc); /* insert last jump in `t' list */
663 luaK_patchtohere(fs, e->f);
664 e->f = NO_JUMP;
665}
static int jumponcond(FuncState *fs, expdesc *e, int cond)
void luaK_patchtohere(FuncState *fs, int list)
void luaK_dischargevars(FuncState *fs, expdesc *e)
void luaK_concat(FuncState *fs, int *l1, int l2)

◆ luaK_goiftrue()

LUAI_FUNC void luaK_goiftrue ( FuncState * fs,
expdesc * e )

Definition at line 539 of file lua-5.1.5/src/lcode.c.

539 {
540 int pc; /* pc of last jump */
541 luaK_dischargevars(fs, e);
542 switch (e->k) {
543 case VK: case VKNUM: case VTRUE: {
544 pc = NO_JUMP; /* always true; do nothing */
545 break;
546 }
547 case VJMP: {
548 invertjump(fs, e);
549 pc = e->u.s.info;
550 break;
551 }
552 default: {
553 pc = jumponcond(fs, e, 0);
554 break;
555 }
556 }
557 luaK_concat(fs, &e->f, pc); /* insert last jump in `f' list */
558 luaK_patchtohere(fs, e->t);
559 e->t = NO_JUMP;
560}
static int jumponcond(FuncState *fs, expdesc *e, int cond)
void luaK_patchtohere(FuncState *fs, int list)
static void invertjump(FuncState *fs, expdesc *e)
void luaK_concat(FuncState *fs, int *l1, int l2)

◆ luaK_indexed()

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

Definition at line 621 of file lua-5.1.5/src/lcode.c.

621 {
622 t->u.s.aux = luaK_exp2RK(fs, k);
623 t->k = VINDEXED;
624}
int luaK_exp2RK(FuncState *fs, expdesc *e)

◆ luaK_infix()

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

Definition at line 710 of file lua-5.1.5/src/lcode.c.

710 {
711 switch (op) {
712 case OPR_AND: {
713 luaK_goiftrue(fs, v);
714 break;
715 }
716 case OPR_OR: {
717 luaK_goiffalse(fs, v);
718 break;
719 }
720 case OPR_CONCAT: {
721 luaK_exp2nextreg(fs, v); /* operand must be on the `stack' */
722 break;
723 }
724 case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV:
725 case OPR_MOD: case OPR_POW: {
726 if (!isnumeral(v)) luaK_exp2RK(fs, v);
727 break;
728 }
729 default: {
730 luaK_exp2RK(fs, v);
731 break;
732 }
733 }
734}
static void luaK_goiffalse(FuncState *fs, expdesc *e)
static int isnumeral(expdesc *e)
void luaK_goiftrue(FuncState *fs, expdesc *e)
@ OPR_CONCAT

◆ luaK_jump()

LUAI_FUNC int luaK_jump ( FuncState * fs)

Definition at line 59 of file lua-5.1.5/src/lcode.c.

59 {
60 int jpc = fs->jpc; /* save list of jumps to here */
61 int j;
62 fs->jpc = NO_JUMP;
63 j = luaK_codeAsBx(fs, OP_JMP, 0, NO_JUMP);
64 luaK_concat(fs, &j, jpc); /* keep them on hold */
65 return j;
66}
#define luaK_codeAsBx(fs, o, A, sBx)

◆ luaK_nil()

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

Definition at line 35 of file lua-5.1.5/src/lcode.c.

35 {
36 Instruction *previous;
37 if (fs->pc > fs->lasttarget) { /* no jumps to current position? */
38 if (fs->pc == 0) { /* function start? */
39 if (from >= fs->nactvar)
40 return; /* positions are already clean */
41 }
42 else {
43 previous = &fs->f->code[fs->pc-1];
44 if (GET_OPCODE(*previous) == OP_LOADNIL) {
45 int pfrom = GETARG_A(*previous);
46 int pto = GETARG_B(*previous);
47 if (pfrom <= from && from <= pto+1) { /* can connect both? */
48 if (from+n-1 > pto)
49 SETARG_B(*previous, from+n-1);
50 return;
51 }
52 }
53 }
54 }
55 luaK_codeABC(fs, OP_LOADNIL, from, from+n-1, 0); /* else no optimization */
56}
lu_int32 Instruction
#define GETARG_A(i)
#define GETARG_B(i)
#define GET_OPCODE(i)
#define SETARG_B(i, b)
Instruction * code

◆ luaK_numberK()

LUAI_FUNC int luaK_numberK ( FuncState * fs,
lua_Number r )

Definition at line 257 of file lua-5.1.5/src/lcode.c.

257 {
258 TValue o;
259 setnvalue(&o, r);
260 return addk(fs, &o, &o);
261}
static int addk(FuncState *fs, TValue *k, TValue *v)
#define setnvalue(obj, x)

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

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

◆ luaK_patchclose()

LUAI_FUNC void luaK_patchclose ( FuncState * fs,
int list,
int level )

Definition at line 179 of file lua-5.2.4/src/lcode.c.

179 {
180 level++; /* argument is +1 to reserve 0 as non-op */
181 while (list != NO_JUMP) {
182 int next = getjump(fs, list);
183 lua_assert(GET_OPCODE(fs->f->code[list]) == OP_JMP &&
184 (GETARG_A(fs->f->code[list]) == 0 ||
185 GETARG_A(fs->f->code[list]) >= level));
186 SETARG_A(fs->f->code[list], level);
187 list = next;
188 }
189}
#define SETARG_A(i, u)
static int getjump(FuncState *fs, int pc)

◆ luaK_patchlist()

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

Definition at line 169 of file lua-5.1.5/src/lcode.c.

169 {
170 if (target == fs->pc)
171 luaK_patchtohere(fs, list);
172 else {
173 lua_assert(target < fs->pc);
174 patchlistaux(fs, list, target, NO_REG, target);
175 }
176}
static void patchlistaux(FuncState *fs, int list, int vtarget, int reg, int dtarget)
#define NO_REG

◆ luaK_patchtohere()

LUAI_FUNC void luaK_patchtohere ( FuncState * fs,
int list )

Definition at line 179 of file lua-5.1.5/src/lcode.c.

179 {
180 luaK_getlabel(fs);
181 luaK_concat(fs, &fs->jpc, list);
182}
int luaK_getlabel(FuncState *fs)

◆ luaK_posfix()

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

Definition at line 813 of file lua-5.2.4/src/lcode.c.

814 {
815 switch (op) {
816 case OPR_AND: {
817 lua_assert(e1->t == NO_JUMP); /* list must be closed */
818 luaK_dischargevars(fs, e2);
819 luaK_concat(fs, &e2->f, e1->f);
820 *e1 = *e2;
821 break;
822 }
823 case OPR_OR: {
824 lua_assert(e1->f == NO_JUMP); /* list must be closed */
825 luaK_dischargevars(fs, e2);
826 luaK_concat(fs, &e2->t, e1->t);
827 *e1 = *e2;
828 break;
829 }
830 case OPR_CONCAT: {
831 luaK_exp2val(fs, e2);
832 if (e2->k == VRELOCABLE && GET_OPCODE(getcode(fs, e2)) == OP_CONCAT) {
833 lua_assert(e1->u.info == GETARG_B(getcode(fs, e2))-1);
834 freeexp(fs, e1);
835 SETARG_B(getcode(fs, e2), e1->u.info);
836 e1->k = VRELOCABLE; e1->u.info = e2->u.info;
837 }
838 else {
839 luaK_exp2nextreg(fs, e2); /* operand must be on the 'stack' */
840 codearith(fs, OP_CONCAT, e1, e2, line);
841 }
842 break;
843 }
844 case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV:
845 case OPR_MOD: case OPR_POW: {
846 codearith(fs, cast(OpCode, op - OPR_ADD + OP_ADD), e1, e2, line);
847 break;
848 }
849 case OPR_EQ: case OPR_LT: case OPR_LE: {
850 codecomp(fs, cast(OpCode, op - OPR_EQ + OP_EQ), 1, e1, e2);
851 break;
852 }
853 case OPR_NE: case OPR_GT: case OPR_GE: {
854 codecomp(fs, cast(OpCode, op - OPR_NE + OP_EQ), 0, e1, e2);
855 break;
856 }
857 default: lua_assert(0);
858 }
859}
#define getcode(fs, e)
#define cast(t, exp)
void luaK_exp2val(FuncState *fs, expdesc *e)
void luaK_exp2nextreg(FuncState *fs, expdesc *e)
static void codecomp(FuncState *fs, OpCode op, int cond, expdesc *e1, expdesc *e2)
static void codearith(FuncState *fs, OpCode op, expdesc *e1, expdesc *e2, int line)
static void freeexp(FuncState *fs, expdesc *e)

◆ luaK_prefix()

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

Definition at line 762 of file lua-5.2.4/src/lcode.c.

762 {
763 expdesc e2;
764 e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
765 switch (op) {
766 case OPR_MINUS: {
767 if (isnumeral(e)) /* minus constant? */
768 e->u.nval = luai_numunm(NULL, e->u.nval); /* fold it */
769 else {
770 luaK_exp2anyreg(fs, e);
771 codearith(fs, OP_UNM, e, &e2, line);
772 }
773 break;
774 }
775 case OPR_NOT: codenot(fs, e); break;
776 case OPR_LEN: {
777 luaK_exp2anyreg(fs, e); /* cannot operate on constants */
778 codearith(fs, OP_LEN, e, &e2, line);
779 break;
780 }
781 default: lua_assert(0);
782 }
783}
#define NULL
Definition gmacros.h:924
@ OPR_MINUS
static int isnumeral(expdesc *e)
static void codenot(FuncState *fs, expdesc *e)
#define luai_numunm(L, a)

◆ luaK_reserveregs()

LUAI_FUNC void luaK_reserveregs ( FuncState * fs,
int n )

Definition at line 209 of file lua-5.1.5/src/lcode.c.

209 {
210 luaK_checkstack(fs, n);
211 fs->freereg += n;
212}
void luaK_checkstack(FuncState *fs, int n)

◆ luaK_ret()

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

Definition at line 69 of file lua-5.1.5/src/lcode.c.

69 {
70 luaK_codeABC(fs, OP_RETURN, first, nret+1, 0);
71}

◆ luaK_self()

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

Definition at line 503 of file lua-5.1.5/src/lcode.c.

503 {
504 int func;
505 luaK_exp2anyreg(fs, e);
506 freeexp(fs, e);
507 func = fs->freereg;
508 luaK_reserveregs(fs, 2);
509 luaK_codeABC(fs, OP_SELF, func, e->u.s.info, luaK_exp2RK(fs, key));
510 freeexp(fs, key);
511 e->u.s.info = func;
512 e->k = VNONRELOC;
513}

◆ luaK_setlist()

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

Definition at line 819 of file lua-5.1.5/src/lcode.c.

819 {
820 int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1;
821 int b = (tostore == LUA_MULTRET) ? 0 : tostore;
822 lua_assert(tostore != 0);
823 if (c <= MAXARG_C)
824 luaK_codeABC(fs, OP_SETLIST, base, b, c);
825 else {
826 luaK_codeABC(fs, OP_SETLIST, base, b, 0);
827 luaK_code(fs, cast(Instruction, c), fs->ls->lastline);
828 }
829 fs->freereg = base + 1; /* free registers with list values */
830}
#define LFIELDS_PER_FLUSH
#define MAXARG_C
#define LUA_MULTRET

◆ luaK_setoneret()

LUAI_FUNC void luaK_setoneret ( FuncState * fs,
expdesc * e )

Definition at line 292 of file lua-5.1.5/src/lcode.c.

292 {
293 if (e->k == VCALL) { /* expression is an open function call? */
294 e->k = VNONRELOC;
295 e->u.s.info = GETARG_A(getcode(fs, e));
296 }
297 else if (e->k == VVARARG) {
298 SETARG_B(getcode(fs, e), 2);
299 e->k = VRELOCABLE; /* can relocate its simple result */
300 }
301}

◆ luaK_setreturns()

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

Definition at line 280 of file lua-5.1.5/src/lcode.c.

280 {
281 if (e->k == VCALL) { /* expression is an open function call? */
282 SETARG_C(getcode(fs, e), nresults+1);
283 }
284 else if (e->k == VVARARG) {
285 SETARG_B(getcode(fs, e), nresults+1);
286 SETARG_A(getcode(fs, e), fs->freereg);
287 luaK_reserveregs(fs, 1);
288 }
289}
#define SETARG_C(i, b)

◆ luaK_storevar()

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

Definition at line 472 of file lua-5.1.5/src/lcode.c.

472 {
473 switch (var->k) {
474 case VLOCAL: {
475 freeexp(fs, ex);
476 exp2reg(fs, ex, var->u.s.info);
477 return;
478 }
479 case VUPVAL: {
480 int e = luaK_exp2anyreg(fs, ex);
481 luaK_codeABC(fs, OP_SETUPVAL, e, var->u.s.info, 0);
482 break;
483 }
484 case VGLOBAL: {
485 int e = luaK_exp2anyreg(fs, ex);
486 luaK_codeABx(fs, OP_SETGLOBAL, e, var->u.s.info);
487 break;
488 }
489 case VINDEXED: {
490 int e = luaK_exp2RK(fs, ex);
491 luaK_codeABC(fs, OP_SETTABLE, var->u.s.info, var->u.s.aux, e);
492 break;
493 }
494 default: {
495 lua_assert(0); /* invalid var kind to store */
496 break;
497 }
498 }
499 freeexp(fs, ex);
500}

◆ luaK_stringK()

LUAI_FUNC int luaK_stringK ( FuncState * fs,
TString * s )

Definition at line 250 of file lua-5.1.5/src/lcode.c.

250 {
251 TValue o;
252 setsvalue(fs->L, &o, s);
253 return addk(fs, &o, &o);
254}
#define setsvalue(L, obj, x)
CURL_EXTERN CURLMcode curl_socket_t s
Definition multi.h:318
struct lua_State * L