Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
lvm.h File Reference
#include "ldo.h"
#include "lobject.h"
#include "ltm.h"

Go to the source code of this file.

Macros

#define tostring(L, o)   ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o)))
 
#define tonumber(o, n)
 
#define equalobj(L, o1, o2)    (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2))
 

Functions

LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r)
 
LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2)
 
LUAI_FUNC const TValueluaV_tonumber (const TValue *obj, TValue *n)
 
LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj)
 
LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val)
 
LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val)
 
LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls)
 
LUAI_FUNC void luaV_concat (lua_State *L, int total, int last)
 

Macro Definition Documentation

◆ equalobj

#define equalobj ( L,
o1,
o2 )    (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2))

Definition at line 21 of file lua-5.1.5/src/lvm.h.

21#define equalobj(L,o1,o2) \
22 (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2))

Referenced by lua_compare(), lua_equal(), luaV_execute(), and luaV_execute().

◆ tonumber

#define tonumber ( o,
n )
Value:
(ttype(o) == LUA_TNUMBER || \
(((o) = luaV_tonumber(o,n)) != NULL))
#define NULL
Definition gmacros.h:924
#define ttype(o)
#define LUA_TNUMBER
LUAI_FUNC const TValue * luaV_tonumber(const TValue *obj, TValue *n)

Definition at line 18 of file lua-5.1.5/src/lvm.h.

18#define tonumber(o,n) (ttype(o) == LUA_TNUMBER || \
19 (((o) = luaV_tonumber(o,n)) != NULL))

Referenced by forlimit(), forlimit(), forprep(), lua_isnumber(), lua_tointeger(), lua_tointegerx(), lua_tonumber(), lua_tonumberx(), lua_tonumberx(), lua_tounsignedx(), luaG_opinterror(), luaO_arith(), luaT_trybinTM(), luaV_execute(), and luaV_execute().

◆ tostring

#define tostring ( L,
o )   ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o)))

Definition at line 16 of file lua-5.1.5/src/lvm.h.

Referenced by luaV_concat(), and luaV_concat().

Function Documentation

◆ luaV_concat()

LUAI_FUNC void luaV_concat ( lua_State * L,
int total,
int last )

Definition at line 282 of file lua-5.1.5/src/lvm.c.

282 {
283 do {
284 StkId top = L->base + last + 1;
285 int n = 2; /* number of elements handled in this pass (at least 2) */
286 if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) {
287 if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT))
288 luaG_concaterror(L, top-2, top-1);
289 } else if (tsvalue(top-1)->len == 0) /* second op is empty? */
290 (void)tostring(L, top - 2); /* result is first op (as string) */
291 else {
292 /* at least two string values; get as many as possible */
293 size_t tl = tsvalue(top-1)->len;
294 char *buffer;
295 int i;
296 /* collect total length */
297 for (n = 1; n < total && tostring(L, top-n-1); n++) {
298 size_t l = tsvalue(top-n-1)->len;
299 if (l >= MAX_SIZET - tl) luaG_runerror(L, "string length overflow");
300 tl += l;
301 }
302 buffer = luaZ_openspace(L, &G(L)->buff, tl);
303 tl = 0;
304 for (i=n; i>0; i--) { /* concat all strings */
305 size_t l = tsvalue(top-i)->len;
306 memcpy(buffer+tl, svalue(top-i), l);
307 tl += l;
308 }
309 setsvalue2s(L, top-n, luaS_newlstr(L, buffer, tl));
310 }
311 total -= n-1; /* got `n' strings to create 1 new */
312 last -= n-1;
313 } while (total > 1); /* repeat until only 1 result left */
314}
void luaG_concaterror(lua_State *L, StkId p1, StkId p2)
void luaG_runerror(lua_State *L, const char *fmt,...)
#define MAX_SIZET
#define setsvalue2s
#define ttisnumber(o)
#define tsvalue(o)
#define ttisstring(o)
#define svalue(o)
#define G(L)
TString * luaS_newlstr(lua_State *L, const char *str, size_t l)
@ TM_CONCAT
static int call_binTM(lua_State *L, const TValue *p1, const TValue *p2, StkId res, TMS event)
#define tostring(L, o)
char * luaZ_openspace(lua_State *L, Mbuffer *buff, size_t n)

References lua_State::base, call_binTM(), G, luaG_concaterror(), luaG_runerror(), luaS_newlstr(), luaZ_openspace(), MAX_SIZET, setsvalue2s, svalue, TM_CONCAT, tostring, tsvalue, ttisnumber, and ttisstring.

Referenced by lua_concat(), luaO_pushvfstring(), luaV_execute(), and pushstr().

◆ luaV_equalval()

LUAI_FUNC int luaV_equalval ( lua_State * L,
const TValue * t1,
const TValue * t2 )

Definition at line 255 of file lua-5.1.5/src/lvm.c.

255 {
256 const TValue *tm;
257 lua_assert(ttype(t1) == ttype(t2));
258 switch (ttype(t1)) {
259 case LUA_TNIL: return 1;
260 case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2));
261 case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */
262 case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2);
263 case LUA_TUSERDATA: {
264 if (uvalue(t1) == uvalue(t2)) return 1;
265 tm = get_compTM(L, uvalue(t1)->metatable, uvalue(t2)->metatable,
266 TM_EQ);
267 break; /* will try TM */
268 }
269 case LUA_TTABLE: {
270 if (hvalue(t1) == hvalue(t2)) return 1;
271 tm = get_compTM(L, hvalue(t1)->metatable, hvalue(t2)->metatable, TM_EQ);
272 break; /* will try TM */
273 }
274 default: return gcvalue(t1) == gcvalue(t2);
275 }
276 if (tm == NULL) return 0; /* no TM? */
277 callTMres(L, L->top, tm, t1, t2); /* call TM */
278 return !l_isfalse(L->top);
279}
#define lua_assert(c)
#define gcvalue(o)
#define pvalue(o)
#define l_isfalse(o)
#define uvalue(o)
#define hvalue(o)
#define nvalue(o)
#define bvalue(o)
@ TM_EQ
#define LUA_TTABLE
#define LUA_TBOOLEAN
#define LUA_TUSERDATA
#define LUA_TLIGHTUSERDATA
#define LUA_TNIL
static void callTMres(lua_State *L, StkId res, const TValue *f, const TValue *p1, const TValue *p2)
static const TValue * get_compTM(lua_State *L, Table *mt1, Table *mt2, TMS event)
#define luai_numeq(a, b)

References bvalue, callTMres(), gcvalue, get_compTM(), hvalue, l_isfalse, lua_assert, LUA_TBOOLEAN, LUA_TLIGHTUSERDATA, LUA_TNIL, LUA_TNUMBER, LUA_TTABLE, LUA_TUSERDATA, luai_numeq, NULL, nvalue, pvalue, TM_EQ, lua_State::top, ttype, and uvalue.

◆ luaV_execute()

LUAI_FUNC void luaV_execute ( lua_State * L,
int nexeccalls )

Definition at line 377 of file lua-5.1.5/src/lvm.c.

377 {
378 LClosure *cl;
379 StkId base;
380 TValue *k;
381 const Instruction *pc;
382 reentry: /* entry point */
383 lua_assert(isLua(L->ci));
384 pc = L->savedpc;
385 cl = &clvalue(L->ci->func)->l;
386 base = L->base;
387 k = cl->p->k;
388 /* main loop of interpreter */
389 for (;;) {
390 const Instruction i = *pc++;
391 StkId ra;
392 if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) &&
393 (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) {
394 traceexec(L, pc);
395 if (L->status == LUA_YIELD) { /* did hook yield? */
396 L->savedpc = pc - 1;
397 return;
398 }
399 base = L->base;
400 }
401 /* warning!! several calls may realloc the stack and invalidate `ra' */
402 ra = RA(i);
403 lua_assert(base == L->base && L->base == L->ci->base);
404 lua_assert(base <= L->top && L->top <= L->stack + L->stacksize);
405 lua_assert(L->top == L->ci->top || luaG_checkopenop(i));
406 switch (GET_OPCODE(i)) {
407 case OP_MOVE: {
408 setobjs2s(L, ra, RB(i));
409 continue;
410 }
411 case OP_LOADK: {
412 setobj2s(L, ra, KBx(i));
413 continue;
414 }
415 case OP_LOADBOOL: {
416 setbvalue(ra, GETARG_B(i));
417 if (GETARG_C(i)) pc++; /* skip next instruction (if C) */
418 continue;
419 }
420 case OP_LOADNIL: {
421 TValue *rb = RB(i);
422 do {
423 setnilvalue(rb--);
424 } while (rb >= ra);
425 continue;
426 }
427 case OP_GETUPVAL: {
428 int b = GETARG_B(i);
429 setobj2s(L, ra, cl->upvals[b]->v);
430 continue;
431 }
432 case OP_GETGLOBAL: {
433 TValue g;
434 TValue *rb = KBx(i);
435 sethvalue(L, &g, cl->env);
437 Protect(luaV_gettable(L, &g, rb, ra));
438 continue;
439 }
440 case OP_GETTABLE: {
441 Protect(luaV_gettable(L, RB(i), RKC(i), ra));
442 continue;
443 }
444 case OP_SETGLOBAL: {
445 TValue g;
446 sethvalue(L, &g, cl->env);
448 Protect(luaV_settable(L, &g, KBx(i), ra));
449 continue;
450 }
451 case OP_SETUPVAL: {
452 UpVal *uv = cl->upvals[GETARG_B(i)];
453 setobj(L, uv->v, ra);
454 luaC_barrier(L, uv, ra);
455 continue;
456 }
457 case OP_SETTABLE: {
458 Protect(luaV_settable(L, ra, RKB(i), RKC(i)));
459 continue;
460 }
461 case OP_NEWTABLE: {
462 int b = GETARG_B(i);
463 int c = GETARG_C(i);
464 sethvalue(L, ra, luaH_new(L, luaO_fb2int(b), luaO_fb2int(c)));
466 continue;
467 }
468 case OP_SELF: {
469 StkId rb = RB(i);
470 setobjs2s(L, ra+1, rb);
471 Protect(luaV_gettable(L, rb, RKC(i), ra));
472 continue;
473 }
474 case OP_ADD: {
476 continue;
477 }
478 case OP_SUB: {
480 continue;
481 }
482 case OP_MUL: {
484 continue;
485 }
486 case OP_DIV: {
488 continue;
489 }
490 case OP_MOD: {
492 continue;
493 }
494 case OP_POW: {
496 continue;
497 }
498 case OP_UNM: {
499 TValue *rb = RB(i);
500 if (ttisnumber(rb)) {
501 lua_Number nb = nvalue(rb);
502 setnvalue(ra, luai_numunm(nb));
503 }
504 else {
505 Protect(Arith(L, ra, rb, rb, TM_UNM));
506 }
507 continue;
508 }
509 case OP_NOT: {
510 int res = l_isfalse(RB(i)); /* next assignment may change this value */
511 setbvalue(ra, res);
512 continue;
513 }
514 case OP_LEN: {
515 const TValue *rb = RB(i);
516 switch (ttype(rb)) {
517 case LUA_TTABLE: {
519 break;
520 }
521 case LUA_TSTRING: {
522 setnvalue(ra, cast_num(tsvalue(rb)->len));
523 break;
524 }
525 default: { /* try metamethod */
526 Protect(
527 if (!call_binTM(L, rb, luaO_nilobject, ra, TM_LEN))
528 luaG_typeerror(L, rb, "get length of");
529 )
530 }
531 }
532 continue;
533 }
534 case OP_CONCAT: {
535 int b = GETARG_B(i);
536 int c = GETARG_C(i);
537 Protect(luaV_concat(L, c-b+1, c); luaC_checkGC(L));
538 setobjs2s(L, RA(i), base+b);
539 continue;
540 }
541 case OP_JMP: {
542 dojump(L, pc, GETARG_sBx(i));
543 continue;
544 }
545 case OP_EQ: {
546 TValue *rb = RKB(i);
547 TValue *rc = RKC(i);
548 Protect(
549 if (equalobj(L, rb, rc) == GETARG_A(i))
550 dojump(L, pc, GETARG_sBx(*pc));
551 )
552 pc++;
553 continue;
554 }
555 case OP_LT: {
556 Protect(
557 if (luaV_lessthan(L, RKB(i), RKC(i)) == GETARG_A(i))
558 dojump(L, pc, GETARG_sBx(*pc));
559 )
560 pc++;
561 continue;
562 }
563 case OP_LE: {
564 Protect(
565 if (lessequal(L, RKB(i), RKC(i)) == GETARG_A(i))
566 dojump(L, pc, GETARG_sBx(*pc));
567 )
568 pc++;
569 continue;
570 }
571 case OP_TEST: {
572 if (l_isfalse(ra) != GETARG_C(i))
573 dojump(L, pc, GETARG_sBx(*pc));
574 pc++;
575 continue;
576 }
577 case OP_TESTSET: {
578 TValue *rb = RB(i);
579 if (l_isfalse(rb) != GETARG_C(i)) {
580 setobjs2s(L, ra, rb);
581 dojump(L, pc, GETARG_sBx(*pc));
582 }
583 pc++;
584 continue;
585 }
586 case OP_CALL: {
587 int b = GETARG_B(i);
588 int nresults = GETARG_C(i) - 1;
589 if (b != 0) L->top = ra+b; /* else previous instruction set top */
590 L->savedpc = pc;
591 switch (luaD_precall(L, ra, nresults)) {
592 case PCRLUA: {
593 nexeccalls++;
594 goto reentry; /* restart luaV_execute over new Lua function */
595 }
596 case PCRC: {
597 /* it was a C function (`precall' called it); adjust results */
598 if (nresults >= 0) L->top = L->ci->top;
599 base = L->base;
600 continue;
601 }
602 default: {
603 return; /* yield */
604 }
605 }
606 }
607 case OP_TAILCALL: {
608 int b = GETARG_B(i);
609 if (b != 0) L->top = ra+b; /* else previous instruction set top */
610 L->savedpc = pc;
612 switch (luaD_precall(L, ra, LUA_MULTRET)) {
613 case PCRLUA: {
614 /* tail call: put new frame in place of previous one */
615 CallInfo *ci = L->ci - 1; /* previous frame */
616 int aux;
617 StkId func = ci->func;
618 StkId pfunc = (ci+1)->func; /* previous function index */
619 if (L->openupval) luaF_close(L, ci->base);
620 L->base = ci->base = ci->func + ((ci+1)->base - pfunc);
621 for (aux = 0; pfunc+aux < L->top; aux++) /* move frame down */
622 setobjs2s(L, func+aux, pfunc+aux);
623 ci->top = L->top = func+aux; /* correct top */
624 lua_assert(L->top == L->base + clvalue(func)->l.p->maxstacksize);
625 ci->savedpc = L->savedpc;
626 ci->tailcalls++; /* one more call lost */
627 L->ci--; /* remove new frame */
628 goto reentry;
629 }
630 case PCRC: { /* it was a C function (`precall' called it) */
631 base = L->base;
632 continue;
633 }
634 default: {
635 return; /* yield */
636 }
637 }
638 }
639 case OP_RETURN: {
640 int b = GETARG_B(i);
641 if (b != 0) L->top = ra+b-1;
642 if (L->openupval) luaF_close(L, base);
643 L->savedpc = pc;
644 b = luaD_poscall(L, ra);
645 if (--nexeccalls == 0) /* was previous function running `here'? */
646 return; /* no: return */
647 else { /* yes: continue its execution */
648 if (b) L->top = L->ci->top;
649 lua_assert(isLua(L->ci));
650 lua_assert(GET_OPCODE(*((L->ci)->savedpc - 1)) == OP_CALL);
651 goto reentry;
652 }
653 }
654 case OP_FORLOOP: {
655 lua_Number step = nvalue(ra+2);
656 lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */
657 lua_Number limit = nvalue(ra+1);
658 if (luai_numlt(0, step) ? luai_numle(idx, limit)
659 : luai_numle(limit, idx)) {
660 dojump(L, pc, GETARG_sBx(i)); /* jump back */
661 setnvalue(ra, idx); /* update internal index... */
662 setnvalue(ra+3, idx); /* ...and external index */
663 }
664 continue;
665 }
666 case OP_FORPREP: {
667 const TValue *init = ra;
668 const TValue *plimit = ra+1;
669 const TValue *pstep = ra+2;
670 L->savedpc = pc; /* next steps may throw errors */
671 if (!tonumber(init, ra))
672 luaG_runerror(L, LUA_QL("for") " initial value must be a number");
673 else if (!tonumber(plimit, ra+1))
674 luaG_runerror(L, LUA_QL("for") " limit must be a number");
675 else if (!tonumber(pstep, ra+2))
676 luaG_runerror(L, LUA_QL("for") " step must be a number");
677 setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep)));
678 dojump(L, pc, GETARG_sBx(i));
679 continue;
680 }
681 case OP_TFORLOOP: {
682 StkId cb = ra + 3; /* call base */
683 setobjs2s(L, cb+2, ra+2);
684 setobjs2s(L, cb+1, ra+1);
685 setobjs2s(L, cb, ra);
686 L->top = cb+3; /* func. + 2 args (state and index) */
687 Protect(luaD_call(L, cb, GETARG_C(i)));
688 L->top = L->ci->top;
689 cb = RA(i) + 3; /* previous call may change the stack */
690 if (!ttisnil(cb)) { /* continue loop? */
691 setobjs2s(L, cb-1, cb); /* save control variable */
692 dojump(L, pc, GETARG_sBx(*pc)); /* jump back */
693 }
694 pc++;
695 continue;
696 }
697 case OP_SETLIST: {
698 int n = GETARG_B(i);
699 int c = GETARG_C(i);
700 int last;
701 Table *h;
702 if (n == 0) {
703 n = cast_int(L->top - ra) - 1;
704 L->top = L->ci->top;
705 }
706 if (c == 0) c = cast_int(*pc++);
707 runtime_check(L, ttistable(ra));
708 h = hvalue(ra);
709 last = ((c-1)*LFIELDS_PER_FLUSH) + n;
710 if (last > h->sizearray) /* needs more space? */
711 luaH_resizearray(L, h, last); /* pre-alloc it at once */
712 for (; n > 0; n--) {
713 TValue *val = ra+n;
714 setobj2t(L, luaH_setnum(L, h, last--), val);
715 luaC_barriert(L, h, val);
716 }
717 continue;
718 }
719 case OP_CLOSE: {
720 luaF_close(L, ra);
721 continue;
722 }
723 case OP_CLOSURE: {
724 Proto *p;
725 Closure *ncl;
726 int nup, j;
727 p = cl->p->p[GETARG_Bx(i)];
728 nup = p->nups;
729 ncl = luaF_newLclosure(L, nup, cl->env);
730 ncl->l.p = p;
731 for (j=0; j<nup; j++, pc++) {
732 if (GET_OPCODE(*pc) == OP_GETUPVAL)
733 ncl->l.upvals[j] = cl->upvals[GETARG_B(*pc)];
734 else {
736 ncl->l.upvals[j] = luaF_findupval(L, base + GETARG_B(*pc));
737 }
738 }
739 setclvalue(L, ra, ncl);
741 continue;
742 }
743 case OP_VARARG: {
744 int b = GETARG_B(i) - 1;
745 int j;
746 CallInfo *ci = L->ci;
747 int n = cast_int(ci->base - ci->func) - cl->p->numparams - 1;
748 if (b == LUA_MULTRET) {
750 ra = RA(i); /* previous call may change the stack */
751 b = n;
752 L->top = ra + n;
753 }
754 for (j = 0; j < b; j++) {
755 if (j < n) {
756 setobjs2s(L, ra + j, ci->base - n + j);
757 }
758 else {
759 setnilvalue(ra + j);
760 }
761 }
762 continue;
763 }
764 }
765 }
766}
int luaG_checkopenop(Instruction i)
void luaG_typeerror(lua_State *L, const TValue *o, const char *op)
int luaD_precall(lua_State *L, StkId func, int nresults)
void luaD_call(lua_State *L, StkId func, int nResults)
int luaD_poscall(lua_State *L, StkId firstResult)
#define PCRLUA
#define PCRC
#define luaD_checkstack(L, n)
Closure * luaF_newLclosure(lua_State *L, int nelems, Table *e)
UpVal * luaF_findupval(lua_State *L, StkId level)
void luaF_close(lua_State *L, StkId level)
#define luaC_barrier(L, p, v)
#define luaC_checkGC(L)
#define luaC_barriert(L, t, v)
lu_int32 Instruction
#define cast_int(i)
#define cast_num(i)
int luaO_fb2int(int x)
#define setobj2s
#define setbvalue(obj, x)
#define clvalue(o)
#define setobjs2s
#define setnvalue(obj, x)
#define setclvalue(L, obj, x)
#define luaO_nilobject
#define ttisnil(o)
#define sethvalue(L, obj, x)
#define ttistable(o)
#define setobj(L, obj1, obj2)
#define setnilvalue(obj)
#define setobj2t
#define LFIELDS_PER_FLUSH
#define GETARG_A(i)
#define GETARG_sBx(i)
#define GETARG_B(i)
#define GET_OPCODE(i)
#define GETARG_Bx(i)
#define GETARG_C(i)
#define isLua(ci)
TValue * luaH_setnum(lua_State *L, Table *t, int key)
Table * luaH_new(lua_State *L, int narray, int nhash)
int luaH_getn(Table *t)
void luaH_resizearray(lua_State *L, Table *t, int nasize)
@ TM_MUL
@ TM_UNM
@ TM_POW
@ TM_DIV
@ TM_LEN
@ TM_SUB
@ TM_ADD
@ TM_MOD
#define LUA_MASKCOUNT
#define LUA_TSTRING
#define LUA_MASKLINE
#define LUA_YIELD
#define LUA_MULTRET
LUA_NUMBER lua_Number
#define LUA_QL(x)
#define RB(i)
#define RKC(i)
void luaV_concat(lua_State *L, int total, int last)
#define RA(i)
int luaV_lessthan(lua_State *L, const TValue *l, const TValue *r)
#define arith_op(op, tm)
static void traceexec(lua_State *L, const Instruction *pc)
#define RKB(i)
#define runtime_check(L, c)
#define Protect(x)
#define KBx(i)
#define dojump(L, pc, i)
static int lessequal(lua_State *L, const TValue *l, const TValue *r)
static void Arith(lua_State *L, StkId ra, const TValue *rb, const TValue *rc, TMS op)
#define equalobj(L, o1, o2)
#define tonumber(o, n)
#define luai_nummul(L, a, b)
#define luai_numdiv(L, a, b)
#define luai_numpow(L, a, b)
#define luai_numunm(L, a)
#define luai_numsub(L, a, b)
#define luai_nummod(L, a, b, m)
#define luai_numlt(a, b)
#define luai_numadd(L, a, b)
#define luai_numle(a, b)
#define luaV_gettable(L, t, k, v)
#define luaV_settable(L, t, k, v)
const Instruction * savedpc
struct Proto * p
struct Proto ** p
GCObject * openupval
const Instruction * savedpc

References Arith(), arith_op, CallInfo::base, lua_State::base, call_binTM(), cast_int, cast_num, lua_State::ci, clvalue, dojump, equalobj, CallInfo::func, GET_OPCODE, GETARG_A, GETARG_B, GETARG_Bx, GETARG_C, GETARG_sBx, lua_State::hookcount, lua_State::hookmask, hvalue, isLua, Proto::k, KBx, Closure::l, l_isfalse, lessequal(), LFIELDS_PER_FLUSH, lua_assert, LUA_MASKCOUNT, LUA_MASKLINE, LUA_MULTRET, LUA_QL, LUA_TSTRING, LUA_TTABLE, LUA_YIELD, luaC_barrier, luaC_barriert, luaC_checkGC, luaD_call(), luaD_checkstack, luaD_poscall(), luaD_precall(), luaF_close(), luaF_findupval(), luaF_newLclosure(), luaG_checkopenop(), luaG_runerror(), luaG_typeerror(), luaH_getn(), luaH_new(), luaH_resizearray(), luaH_setnum(), luai_numadd, luai_numdiv, luai_numle, luai_numlt, luai_nummod, luai_nummul, luai_numpow, luai_numsub, luai_numunm, luaO_fb2int(), luaO_nilobject, luaV_concat(), luaV_gettable, luaV_lessthan(), luaV_settable, Proto::numparams, Proto::nups, nvalue, OP_ADD, OP_CALL, OP_CLOSE, OP_CLOSURE, OP_CONCAT, OP_DIV, OP_EQ, OP_FORLOOP, OP_FORPREP, OP_GETGLOBAL, OP_GETTABLE, OP_GETUPVAL, OP_JMP, OP_LE, OP_LEN, OP_LOADBOOL, OP_LOADK, OP_LOADNIL, OP_LT, OP_MOD, OP_MOVE, OP_MUL, OP_NEWTABLE, OP_NOT, OP_POW, OP_RETURN, OP_SELF, OP_SETGLOBAL, OP_SETLIST, OP_SETTABLE, OP_SETUPVAL, OP_SUB, OP_TAILCALL, OP_TEST, OP_TESTSET, OP_TFORLOOP, OP_UNM, OP_VARARG, lua_State::openupval, Proto::p, LClosure::p, PCRC, PCRLUA, Protect, RA, RB, RKB, RKC, runtime_check, CallInfo::savedpc, lua_State::savedpc, setbvalue, setclvalue, sethvalue, setnilvalue, setnvalue, setobj, setobj2s, setobj2t, setobjs2s, Table::sizearray, lua_State::stack, lua_State::stacksize, lua_State::status, CallInfo::tailcalls, TM_ADD, TM_DIV, TM_LEN, TM_MOD, TM_MUL, TM_POW, TM_SUB, TM_UNM, tonumber, CallInfo::top, lua_State::top, traceexec(), tsvalue, ttisnil, ttisnumber, ttisstring, ttistable, ttype, LClosure::upvals, and UpVal::v.

Referenced by ccall(), luaD_call(), luaD_call(), resume(), resume(), resume(), resume(), unroll(), unroll(), and unroll().

◆ luaV_gettable()

LUAI_FUNC void luaV_gettable ( lua_State * L,
const TValue * t,
TValue * key,
StkId val )

Definition at line 108 of file lua-5.1.5/src/lvm.c.

108 {
109 int loop;
110 for (loop = 0; loop < MAXTAGLOOP; loop++) {
111 const TValue *tm;
112 if (ttistable(t)) { /* `t' is a table? */
113 Table *h = hvalue(t);
114 const TValue *res = luaH_get(h, key); /* do a primitive get */
115 if (!ttisnil(res) || /* result is no nil? */
116 (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */
117 setobj2s(L, val, res);
118 return;
119 }
120 /* else will try the tag method */
121 }
122 else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX)))
123 luaG_typeerror(L, t, "index");
124 if (ttisfunction(tm)) {
125 callTMres(L, val, tm, t, key);
126 return;
127 }
128 t = tm; /* else repeat with `tm' */
129 }
130 luaG_runerror(L, "loop in gettable");
131}
#define ttisfunction(o)
const TValue * luaH_get(Table *t, const TValue *key)
const TValue * luaT_gettmbyobj(lua_State *L, const TValue *o, TMS event)
#define fasttm(l, et, e)
@ TM_INDEX
#define MAXTAGLOOP
struct Table * metatable

◆ luaV_lessthan()

LUAI_FUNC int luaV_lessthan ( lua_State * L,
const TValue * l,
const TValue * r )

Definition at line 225 of file lua-5.1.5/src/lvm.c.

225 {
226 int res;
227 if (ttype(l) != ttype(r))
228 return luaG_ordererror(L, l, r);
229 else if (ttisnumber(l))
230 return luai_numlt(nvalue(l), nvalue(r));
231 else if (ttisstring(l))
232 return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0;
233 else if ((res = call_orderTM(L, l, r, TM_LT)) != -1)
234 return res;
235 return luaG_ordererror(L, l, r);
236}
int luaG_ordererror(lua_State *L, const TValue *p1, const TValue *p2)
#define rawtsvalue(o)
@ TM_LT
static int call_orderTM(lua_State *L, const TValue *p1, const TValue *p2, TMS event)
static int l_strcmp(const TString *ls, const TString *rs)

◆ luaV_settable()

LUAI_FUNC void luaV_settable ( lua_State * L,
const TValue * t,
TValue * key,
StkId val )

Definition at line 134 of file lua-5.1.5/src/lvm.c.

134 {
135 int loop;
136 TValue temp;
137 for (loop = 0; loop < MAXTAGLOOP; loop++) {
138 const TValue *tm;
139 if (ttistable(t)) { /* `t' is a table? */
140 Table *h = hvalue(t);
141 TValue *oldval = luaH_set(L, h, key); /* do a primitive set */
142 if (!ttisnil(oldval) || /* result is no nil? */
143 (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */
144 setobj2t(L, oldval, val);
145 h->flags = 0;
146 luaC_barriert(L, h, val);
147 return;
148 }
149 /* else will try the tag method */
150 }
151 else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX)))
152 luaG_typeerror(L, t, "index");
153 if (ttisfunction(tm)) {
154 callTM(L, tm, t, key, val);
155 return;
156 }
157 /* else repeat with `tm' */
158 setobj(L, &temp, tm); /* avoid pointing inside table (may rehash) */
159 t = &temp;
160 }
161 luaG_runerror(L, "loop in settable");
162}
TValue * luaH_set(lua_State *L, Table *t, const TValue *key)
@ TM_NEWINDEX
static void callTM(lua_State *L, const TValue *f, const TValue *p1, const TValue *p2, const TValue *p3)

◆ luaV_tonumber()

LUAI_FUNC const TValue * luaV_tonumber ( const TValue * obj,
TValue * n )

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

35 {
36 lua_Number num;
37 if (ttisnumber(obj)) return obj;
38 if (ttisstring(obj) && luaO_str2d(svalue(obj), &num)) {
39 setnvalue(n, num);
40 return n;
41 }
42 else
43 return NULL;
44}
int luaO_str2d(const char *s, lua_Number *result)

◆ luaV_tostring()

LUAI_FUNC int luaV_tostring ( lua_State * L,
StkId obj )

Definition at line 47 of file lua-5.1.5/src/lvm.c.

47 {
48 if (!ttisnumber(obj))
49 return 0;
50 else {
52 lua_Number n = nvalue(obj);
53 lua_number2str(s, n);
54 setsvalue2s(L, obj, luaS_new(L, s));
55 return 1;
56 }
57}
#define luaS_new(L, s)
#define lua_number2str(s, n)
#define LUAI_MAXNUMBER2STR
CURL_EXTERN CURLMcode curl_socket_t s
Definition multi.h:318