aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2023-08-24 09:21:38 +0800
committerLi Jin <dragon-fly@qq.com>2023-08-24 09:21:38 +0800
commitcfcea12ba0e6a40d7c04ac64c75563db0896985c (patch)
tree8ee7c6d9cd5f7b60fd9bda035b703cc9969ab678
parenteb48c686a7ab5bd3f3f3a8628ed0423872a932c6 (diff)
downloadyuescript-cfcea12ba0e6a40d7c04ac64c75563db0896985c.tar.gz
yuescript-cfcea12ba0e6a40d7c04ac64c75563db0896985c.tar.bz2
yuescript-cfcea12ba0e6a40d7c04ac64c75563db0896985c.zip
update Lua 5.4.
-rw-r--r--src/3rdParty/lua/lapi.c4
-rw-r--r--src/3rdParty/lua/lcode.c104
-rw-r--r--src/3rdParty/lua/lcode.h3
-rw-r--r--src/3rdParty/lua/lcorolib.c4
-rw-r--r--src/3rdParty/lua/ldebug.c59
-rw-r--r--src/3rdParty/lua/ldebug.h1
-rw-r--r--src/3rdParty/lua/ldo.c20
-rw-r--r--src/3rdParty/lua/ldo.h1
-rw-r--r--src/3rdParty/lua/ldump.c8
-rw-r--r--src/3rdParty/lua/lgc.c29
-rw-r--r--src/3rdParty/lua/lgc.h17
-rw-r--r--src/3rdParty/lua/llex.c2
-rw-r--r--src/3rdParty/lua/llimits.h21
-rw-r--r--src/3rdParty/lua/lmathlib.c10
-rw-r--r--src/3rdParty/lua/lmem.c68
-rw-r--r--src/3rdParty/lua/loadlib.c9
-rw-r--r--src/3rdParty/lua/lobject.c2
-rw-r--r--src/3rdParty/lua/lobject.h18
-rw-r--r--src/3rdParty/lua/lopcodes.h10
-rw-r--r--src/3rdParty/lua/loslib.c32
-rw-r--r--src/3rdParty/lua/lparser.c8
-rw-r--r--src/3rdParty/lua/lstate.c16
-rw-r--r--src/3rdParty/lua/lstate.h14
-rw-r--r--src/3rdParty/lua/lstring.c11
-rw-r--r--src/3rdParty/lua/lstrlib.c2
-rw-r--r--src/3rdParty/lua/ltable.c5
-rw-r--r--src/3rdParty/lua/ltable.h2
-rw-r--r--src/3rdParty/lua/lua.h53
-rw-r--r--src/3rdParty/lua/luaconf.h15
-rw-r--r--src/3rdParty/lua/lundump.c4
-rw-r--r--src/3rdParty/lua/lundump.h3
-rw-r--r--src/3rdParty/lua/lvm.c80
32 files changed, 378 insertions, 257 deletions
diff --git a/src/3rdParty/lua/lapi.c b/src/3rdParty/lua/lapi.c
index 34e64af..332e97d 100644
--- a/src/3rdParty/lua/lapi.c
+++ b/src/3rdParty/lua/lapi.c
@@ -417,9 +417,9 @@ LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) {
417 o = index2value(L, idx); /* previous call may reallocate the stack */ 417 o = index2value(L, idx); /* previous call may reallocate the stack */
418 } 418 }
419 if (len != NULL) 419 if (len != NULL)
420 *len = vslen(o); 420 *len = tsslen(tsvalue(o));
421 lua_unlock(L); 421 lua_unlock(L);
422 return svalue(o); 422 return getstr(tsvalue(o));
423} 423}
424 424
425 425
diff --git a/src/3rdParty/lua/lcode.c b/src/3rdParty/lua/lcode.c
index 911dbd5..caac6ba 100644
--- a/src/3rdParty/lua/lcode.c
+++ b/src/3rdParty/lua/lcode.c
@@ -415,7 +415,7 @@ int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) {
415/* 415/*
416** Format and emit an 'iAsBx' instruction. 416** Format and emit an 'iAsBx' instruction.
417*/ 417*/
418int luaK_codeAsBx (FuncState *fs, OpCode o, int a, int bc) { 418static int codeAsBx (FuncState *fs, OpCode o, int a, int bc) {
419 unsigned int b = bc + OFFSET_sBx; 419 unsigned int b = bc + OFFSET_sBx;
420 lua_assert(getOpMode(o) == iAsBx); 420 lua_assert(getOpMode(o) == iAsBx);
421 lua_assert(a <= MAXARG_A && b <= MAXARG_Bx); 421 lua_assert(a <= MAXARG_A && b <= MAXARG_Bx);
@@ -671,7 +671,7 @@ static int fitsBx (lua_Integer i) {
671 671
672void luaK_int (FuncState *fs, int reg, lua_Integer i) { 672void luaK_int (FuncState *fs, int reg, lua_Integer i) {
673 if (fitsBx(i)) 673 if (fitsBx(i))
674 luaK_codeAsBx(fs, OP_LOADI, reg, cast_int(i)); 674 codeAsBx(fs, OP_LOADI, reg, cast_int(i));
675 else 675 else
676 luaK_codek(fs, reg, luaK_intK(fs, i)); 676 luaK_codek(fs, reg, luaK_intK(fs, i));
677} 677}
@@ -680,7 +680,7 @@ void luaK_int (FuncState *fs, int reg, lua_Integer i) {
680static void luaK_float (FuncState *fs, int reg, lua_Number f) { 680static void luaK_float (FuncState *fs, int reg, lua_Number f) {
681 lua_Integer fi; 681 lua_Integer fi;
682 if (luaV_flttointeger(f, &fi, F2Ieq) && fitsBx(fi)) 682 if (luaV_flttointeger(f, &fi, F2Ieq) && fitsBx(fi))
683 luaK_codeAsBx(fs, OP_LOADF, reg, cast_int(fi)); 683 codeAsBx(fs, OP_LOADF, reg, cast_int(fi));
684 else 684 else
685 luaK_codek(fs, reg, luaK_numberK(fs, f)); 685 luaK_codek(fs, reg, luaK_numberK(fs, f));
686} 686}
@@ -1025,7 +1025,7 @@ static int luaK_exp2K (FuncState *fs, expdesc *e) {
1025** in the range of R/K indices). 1025** in the range of R/K indices).
1026** Returns 1 iff expression is K. 1026** Returns 1 iff expression is K.
1027*/ 1027*/
1028int luaK_exp2RK (FuncState *fs, expdesc *e) { 1028static int exp2RK (FuncState *fs, expdesc *e) {
1029 if (luaK_exp2K(fs, e)) 1029 if (luaK_exp2K(fs, e))
1030 return 1; 1030 return 1;
1031 else { /* not a constant in the right range: put it in a register */ 1031 else { /* not a constant in the right range: put it in a register */
@@ -1037,7 +1037,7 @@ int luaK_exp2RK (FuncState *fs, expdesc *e) {
1037 1037
1038static void codeABRK (FuncState *fs, OpCode o, int a, int b, 1038static void codeABRK (FuncState *fs, OpCode o, int a, int b,
1039 expdesc *ec) { 1039 expdesc *ec) {
1040 int k = luaK_exp2RK(fs, ec); 1040 int k = exp2RK(fs, ec);
1041 luaK_codeABCk(fs, o, a, b, ec->u.info, k); 1041 luaK_codeABCk(fs, o, a, b, ec->u.info, k);
1042} 1042}
1043 1043
@@ -1215,7 +1215,7 @@ static void codenot (FuncState *fs, expdesc *e) {
1215 1215
1216 1216
1217/* 1217/*
1218** Check whether expression 'e' is a small literal string 1218** Check whether expression 'e' is a short literal string
1219*/ 1219*/
1220static int isKstr (FuncState *fs, expdesc *e) { 1220static int isKstr (FuncState *fs, expdesc *e) {
1221 return (e->k == VK && !hasjumps(e) && e->u.info <= MAXARG_B && 1221 return (e->k == VK && !hasjumps(e) && e->u.info <= MAXARG_B &&
@@ -1225,7 +1225,7 @@ static int isKstr (FuncState *fs, expdesc *e) {
1225/* 1225/*
1226** Check whether expression 'e' is a literal integer. 1226** Check whether expression 'e' is a literal integer.
1227*/ 1227*/
1228int luaK_isKint (expdesc *e) { 1228static int isKint (expdesc *e) {
1229 return (e->k == VKINT && !hasjumps(e)); 1229 return (e->k == VKINT && !hasjumps(e));
1230} 1230}
1231 1231
@@ -1235,7 +1235,7 @@ int luaK_isKint (expdesc *e) {
1235** proper range to fit in register C 1235** proper range to fit in register C
1236*/ 1236*/
1237static int isCint (expdesc *e) { 1237static int isCint (expdesc *e) {
1238 return luaK_isKint(e) && (l_castS2U(e->u.ival) <= l_castS2U(MAXARG_C)); 1238 return isKint(e) && (l_castS2U(e->u.ival) <= l_castS2U(MAXARG_C));
1239} 1239}
1240 1240
1241 1241
@@ -1244,7 +1244,7 @@ static int isCint (expdesc *e) {
1244** proper range to fit in register sC 1244** proper range to fit in register sC
1245*/ 1245*/
1246static int isSCint (expdesc *e) { 1246static int isSCint (expdesc *e) {
1247 return luaK_isKint(e) && fitsC(e->u.ival); 1247 return isKint(e) && fitsC(e->u.ival);
1248} 1248}
1249 1249
1250 1250
@@ -1283,15 +1283,16 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
1283 if (t->k == VUPVAL && !isKstr(fs, k)) /* upvalue indexed by non 'Kstr'? */ 1283 if (t->k == VUPVAL && !isKstr(fs, k)) /* upvalue indexed by non 'Kstr'? */
1284 luaK_exp2anyreg(fs, t); /* put it in a register */ 1284 luaK_exp2anyreg(fs, t); /* put it in a register */
1285 if (t->k == VUPVAL) { 1285 if (t->k == VUPVAL) {
1286 lua_assert(isKstr(fs, k));
1286 t->u.ind.t = t->u.info; /* upvalue index */ 1287 t->u.ind.t = t->u.info; /* upvalue index */
1287 t->u.ind.idx = k->u.info; /* literal string */ 1288 t->u.ind.idx = k->u.info; /* literal short string */
1288 t->k = VINDEXUP; 1289 t->k = VINDEXUP;
1289 } 1290 }
1290 else { 1291 else {
1291 /* register index of the table */ 1292 /* register index of the table */
1292 t->u.ind.t = (t->k == VLOCAL) ? t->u.var.ridx: t->u.info; 1293 t->u.ind.t = (t->k == VLOCAL) ? t->u.var.ridx: t->u.info;
1293 if (isKstr(fs, k)) { 1294 if (isKstr(fs, k)) {
1294 t->u.ind.idx = k->u.info; /* literal string */ 1295 t->u.ind.idx = k->u.info; /* literal short string */
1295 t->k = VINDEXSTR; 1296 t->k = VINDEXSTR;
1296 } 1297 }
1297 else if (isCint(k)) { 1298 else if (isCint(k)) {
@@ -1352,6 +1353,35 @@ static int constfolding (FuncState *fs, int op, expdesc *e1,
1352 1353
1353 1354
1354/* 1355/*
1356** Convert a BinOpr to an OpCode (ORDER OPR - ORDER OP)
1357*/
1358l_sinline OpCode binopr2op (BinOpr opr, BinOpr baser, OpCode base) {
1359 lua_assert(baser <= opr &&
1360 ((baser == OPR_ADD && opr <= OPR_SHR) ||
1361 (baser == OPR_LT && opr <= OPR_LE)));
1362 return cast(OpCode, (cast_int(opr) - cast_int(baser)) + cast_int(base));
1363}
1364
1365
1366/*
1367** Convert a UnOpr to an OpCode (ORDER OPR - ORDER OP)
1368*/
1369l_sinline OpCode unopr2op (UnOpr opr) {
1370 return cast(OpCode, (cast_int(opr) - cast_int(OPR_MINUS)) +
1371 cast_int(OP_UNM));
1372}
1373
1374
1375/*
1376** Convert a BinOpr to a tag method (ORDER OPR - ORDER TM)
1377*/
1378l_sinline TMS binopr2TM (BinOpr opr) {
1379 lua_assert(OPR_ADD <= opr && opr <= OPR_SHR);
1380 return cast(TMS, (cast_int(opr) - cast_int(OPR_ADD)) + cast_int(TM_ADD));
1381}
1382
1383
1384/*
1355** Emit code for unary expressions that "produce values" 1385** Emit code for unary expressions that "produce values"
1356** (everything but 'not'). 1386** (everything but 'not').
1357** Expression to produce final result will be encoded in 'e'. 1387** Expression to produce final result will be encoded in 'e'.
@@ -1389,15 +1419,15 @@ static void finishbinexpval (FuncState *fs, expdesc *e1, expdesc *e2,
1389** Emit code for binary expressions that "produce values" over 1419** Emit code for binary expressions that "produce values" over
1390** two registers. 1420** two registers.
1391*/ 1421*/
1392static void codebinexpval (FuncState *fs, OpCode op, 1422static void codebinexpval (FuncState *fs, BinOpr opr,
1393 expdesc *e1, expdesc *e2, int line) { 1423 expdesc *e1, expdesc *e2, int line) {
1424 OpCode op = binopr2op(opr, OPR_ADD, OP_ADD);
1394 int v2 = luaK_exp2anyreg(fs, e2); /* make sure 'e2' is in a register */ 1425 int v2 = luaK_exp2anyreg(fs, e2); /* make sure 'e2' is in a register */
1395 /* 'e1' must be already in a register or it is a constant */ 1426 /* 'e1' must be already in a register or it is a constant */
1396 lua_assert((VNIL <= e1->k && e1->k <= VKSTR) || 1427 lua_assert((VNIL <= e1->k && e1->k <= VKSTR) ||
1397 e1->k == VNONRELOC || e1->k == VRELOC); 1428 e1->k == VNONRELOC || e1->k == VRELOC);
1398 lua_assert(OP_ADD <= op && op <= OP_SHR); 1429 lua_assert(OP_ADD <= op && op <= OP_SHR);
1399 finishbinexpval(fs, e1, e2, op, v2, 0, line, OP_MMBIN, 1430 finishbinexpval(fs, e1, e2, op, v2, 0, line, OP_MMBIN, binopr2TM(opr));
1400 cast(TMS, (op - OP_ADD) + TM_ADD));
1401} 1431}
1402 1432
1403 1433
@@ -1418,9 +1448,9 @@ static void codebini (FuncState *fs, OpCode op,
1418*/ 1448*/
1419static void codebinK (FuncState *fs, BinOpr opr, 1449static void codebinK (FuncState *fs, BinOpr opr,
1420 expdesc *e1, expdesc *e2, int flip, int line) { 1450 expdesc *e1, expdesc *e2, int flip, int line) {
1421 TMS event = cast(TMS, opr + TM_ADD); 1451 TMS event = binopr2TM(opr);
1422 int v2 = e2->u.info; /* K index */ 1452 int v2 = e2->u.info; /* K index */
1423 OpCode op = cast(OpCode, opr + OP_ADDK); 1453 OpCode op = binopr2op(opr, OPR_ADD, OP_ADDK);
1424 finishbinexpval(fs, e1, e2, op, v2, flip, line, OP_MMBINK, event); 1454 finishbinexpval(fs, e1, e2, op, v2, flip, line, OP_MMBINK, event);
1425} 1455}
1426 1456
@@ -1430,7 +1460,7 @@ static void codebinK (FuncState *fs, BinOpr opr,
1430*/ 1460*/
1431static int finishbinexpneg (FuncState *fs, expdesc *e1, expdesc *e2, 1461static int finishbinexpneg (FuncState *fs, expdesc *e1, expdesc *e2,
1432 OpCode op, int line, TMS event) { 1462 OpCode op, int line, TMS event) {
1433 if (!luaK_isKint(e2)) 1463 if (!isKint(e2))
1434 return 0; /* not an integer constant */ 1464 return 0; /* not an integer constant */
1435 else { 1465 else {
1436 lua_Integer i2 = e2->u.ival; 1466 lua_Integer i2 = e2->u.ival;
@@ -1457,10 +1487,9 @@ static void swapexps (expdesc *e1, expdesc *e2) {
1457*/ 1487*/
1458static void codebinNoK (FuncState *fs, BinOpr opr, 1488static void codebinNoK (FuncState *fs, BinOpr opr,
1459 expdesc *e1, expdesc *e2, int flip, int line) { 1489 expdesc *e1, expdesc *e2, int flip, int line) {
1460 OpCode op = cast(OpCode, opr + OP_ADD);
1461 if (flip) 1490 if (flip)
1462 swapexps(e1, e2); /* back to original order */ 1491 swapexps(e1, e2); /* back to original order */
1463 codebinexpval(fs, op, e1, e2, line); /* use standard operators */ 1492 codebinexpval(fs, opr, e1, e2, line); /* use standard operators */
1464} 1493}
1465 1494
1466 1495
@@ -1490,7 +1519,7 @@ static void codecommutative (FuncState *fs, BinOpr op,
1490 flip = 1; 1519 flip = 1;
1491 } 1520 }
1492 if (op == OPR_ADD && isSCint(e2)) /* immediate operand? */ 1521 if (op == OPR_ADD && isSCint(e2)) /* immediate operand? */
1493 codebini(fs, cast(OpCode, OP_ADDI), e1, e2, flip, line, TM_ADD); 1522 codebini(fs, OP_ADDI, e1, e2, flip, line, TM_ADD);
1494 else 1523 else
1495 codearith(fs, op, e1, e2, flip, line); 1524 codearith(fs, op, e1, e2, flip, line);
1496} 1525}
@@ -1518,25 +1547,27 @@ static void codebitwise (FuncState *fs, BinOpr opr,
1518** Emit code for order comparisons. When using an immediate operand, 1547** Emit code for order comparisons. When using an immediate operand,
1519** 'isfloat' tells whether the original value was a float. 1548** 'isfloat' tells whether the original value was a float.
1520*/ 1549*/
1521static void codeorder (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) { 1550static void codeorder (FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2) {
1522 int r1, r2; 1551 int r1, r2;
1523 int im; 1552 int im;
1524 int isfloat = 0; 1553 int isfloat = 0;
1554 OpCode op;
1525 if (isSCnumber(e2, &im, &isfloat)) { 1555 if (isSCnumber(e2, &im, &isfloat)) {
1526 /* use immediate operand */ 1556 /* use immediate operand */
1527 r1 = luaK_exp2anyreg(fs, e1); 1557 r1 = luaK_exp2anyreg(fs, e1);
1528 r2 = im; 1558 r2 = im;
1529 op = cast(OpCode, (op - OP_LT) + OP_LTI); 1559 op = binopr2op(opr, OPR_LT, OP_LTI);
1530 } 1560 }
1531 else if (isSCnumber(e1, &im, &isfloat)) { 1561 else if (isSCnumber(e1, &im, &isfloat)) {
1532 /* transform (A < B) to (B > A) and (A <= B) to (B >= A) */ 1562 /* transform (A < B) to (B > A) and (A <= B) to (B >= A) */
1533 r1 = luaK_exp2anyreg(fs, e2); 1563 r1 = luaK_exp2anyreg(fs, e2);
1534 r2 = im; 1564 r2 = im;
1535 op = (op == OP_LT) ? OP_GTI : OP_GEI; 1565 op = binopr2op(opr, OPR_LT, OP_GTI);
1536 } 1566 }
1537 else { /* regular case, compare two registers */ 1567 else { /* regular case, compare two registers */
1538 r1 = luaK_exp2anyreg(fs, e1); 1568 r1 = luaK_exp2anyreg(fs, e1);
1539 r2 = luaK_exp2anyreg(fs, e2); 1569 r2 = luaK_exp2anyreg(fs, e2);
1570 op = binopr2op(opr, OPR_LT, OP_LT);
1540 } 1571 }
1541 freeexps(fs, e1, e2); 1572 freeexps(fs, e1, e2);
1542 e1->u.info = condjump(fs, op, r1, r2, isfloat, 1); 1573 e1->u.info = condjump(fs, op, r1, r2, isfloat, 1);
@@ -1562,7 +1593,7 @@ static void codeeq (FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2) {
1562 op = OP_EQI; 1593 op = OP_EQI;
1563 r2 = im; /* immediate operand */ 1594 r2 = im; /* immediate operand */
1564 } 1595 }
1565 else if (luaK_exp2RK(fs, e2)) { /* 2nd expression is constant? */ 1596 else if (exp2RK(fs, e2)) { /* 2nd expression is constant? */
1566 op = OP_EQK; 1597 op = OP_EQK;
1567 r2 = e2->u.info; /* constant index */ 1598 r2 = e2->u.info; /* constant index */
1568 } 1599 }
@@ -1579,16 +1610,16 @@ static void codeeq (FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2) {
1579/* 1610/*
1580** Apply prefix operation 'op' to expression 'e'. 1611** Apply prefix operation 'op' to expression 'e'.
1581*/ 1612*/
1582void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e, int line) { 1613void luaK_prefix (FuncState *fs, UnOpr opr, expdesc *e, int line) {
1583 static const expdesc ef = {VKINT, {0}, NO_JUMP, NO_JUMP}; 1614 static const expdesc ef = {VKINT, {0}, NO_JUMP, NO_JUMP};
1584 luaK_dischargevars(fs, e); 1615 luaK_dischargevars(fs, e);
1585 switch (op) { 1616 switch (opr) {
1586 case OPR_MINUS: case OPR_BNOT: /* use 'ef' as fake 2nd operand */ 1617 case OPR_MINUS: case OPR_BNOT: /* use 'ef' as fake 2nd operand */
1587 if (constfolding(fs, op + LUA_OPUNM, e, &ef)) 1618 if (constfolding(fs, opr + LUA_OPUNM, e, &ef))
1588 break; 1619 break;
1589 /* else */ /* FALLTHROUGH */ 1620 /* else */ /* FALLTHROUGH */
1590 case OPR_LEN: 1621 case OPR_LEN:
1591 codeunexpval(fs, cast(OpCode, op + OP_UNM), e, line); 1622 codeunexpval(fs, unopr2op(opr), e, line);
1592 break; 1623 break;
1593 case OPR_NOT: codenot(fs, e); break; 1624 case OPR_NOT: codenot(fs, e); break;
1594 default: lua_assert(0); 1625 default: lua_assert(0);
@@ -1628,7 +1659,7 @@ void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) {
1628 } 1659 }
1629 case OPR_EQ: case OPR_NE: { 1660 case OPR_EQ: case OPR_NE: {
1630 if (!tonumeral(v, NULL)) 1661 if (!tonumeral(v, NULL))
1631 luaK_exp2RK(fs, v); 1662 exp2RK(fs, v);
1632 /* else keep numeral, which may be an immediate operand */ 1663 /* else keep numeral, which may be an immediate operand */
1633 break; 1664 break;
1634 } 1665 }
@@ -1718,30 +1749,27 @@ void luaK_posfix (FuncState *fs, BinOpr opr,
1718 /* coded as (r1 >> -I) */; 1749 /* coded as (r1 >> -I) */;
1719 } 1750 }
1720 else /* regular case (two registers) */ 1751 else /* regular case (two registers) */
1721 codebinexpval(fs, OP_SHL, e1, e2, line); 1752 codebinexpval(fs, opr, e1, e2, line);
1722 break; 1753 break;
1723 } 1754 }
1724 case OPR_SHR: { 1755 case OPR_SHR: {
1725 if (isSCint(e2)) 1756 if (isSCint(e2))
1726 codebini(fs, OP_SHRI, e1, e2, 0, line, TM_SHR); /* r1 >> I */ 1757 codebini(fs, OP_SHRI, e1, e2, 0, line, TM_SHR); /* r1 >> I */
1727 else /* regular case (two registers) */ 1758 else /* regular case (two registers) */
1728 codebinexpval(fs, OP_SHR, e1, e2, line); 1759 codebinexpval(fs, opr, e1, e2, line);
1729 break; 1760 break;
1730 } 1761 }
1731 case OPR_EQ: case OPR_NE: { 1762 case OPR_EQ: case OPR_NE: {
1732 codeeq(fs, opr, e1, e2); 1763 codeeq(fs, opr, e1, e2);
1733 break; 1764 break;
1734 } 1765 }
1735 case OPR_LT: case OPR_LE: {
1736 OpCode op = cast(OpCode, (opr - OPR_EQ) + OP_EQ);
1737 codeorder(fs, op, e1, e2);
1738 break;
1739 }
1740 case OPR_GT: case OPR_GE: { 1766 case OPR_GT: case OPR_GE: {
1741 /* '(a > b)' <=> '(b < a)'; '(a >= b)' <=> '(b <= a)' */ 1767 /* '(a > b)' <=> '(b < a)'; '(a >= b)' <=> '(b <= a)' */
1742 OpCode op = cast(OpCode, (opr - OPR_NE) + OP_EQ);
1743 swapexps(e1, e2); 1768 swapexps(e1, e2);
1744 codeorder(fs, op, e1, e2); 1769 opr = cast(BinOpr, (opr - OPR_GT) + OPR_LT);
1770 } /* FALLTHROUGH */
1771 case OPR_LT: case OPR_LE: {
1772 codeorder(fs, opr, e1, e2);
1745 break; 1773 break;
1746 } 1774 }
1747 default: lua_assert(0); 1775 default: lua_assert(0);
diff --git a/src/3rdParty/lua/lcode.h b/src/3rdParty/lua/lcode.h
index 3265824..0b971fc 100644
--- a/src/3rdParty/lua/lcode.h
+++ b/src/3rdParty/lua/lcode.h
@@ -61,10 +61,8 @@ typedef enum UnOpr { OPR_MINUS, OPR_BNOT, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr;
61 61
62LUAI_FUNC int luaK_code (FuncState *fs, Instruction i); 62LUAI_FUNC int luaK_code (FuncState *fs, Instruction i);
63LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); 63LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx);
64LUAI_FUNC int luaK_codeAsBx (FuncState *fs, OpCode o, int A, int Bx);
65LUAI_FUNC int luaK_codeABCk (FuncState *fs, OpCode o, int A, 64LUAI_FUNC int luaK_codeABCk (FuncState *fs, OpCode o, int A,
66 int B, int C, int k); 65 int B, int C, int k);
67LUAI_FUNC int luaK_isKint (expdesc *e);
68LUAI_FUNC int luaK_exp2const (FuncState *fs, const expdesc *e, TValue *v); 66LUAI_FUNC int luaK_exp2const (FuncState *fs, const expdesc *e, TValue *v);
69LUAI_FUNC void luaK_fixline (FuncState *fs, int line); 67LUAI_FUNC void luaK_fixline (FuncState *fs, int line);
70LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); 68LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n);
@@ -76,7 +74,6 @@ LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e);
76LUAI_FUNC void luaK_exp2anyregup (FuncState *fs, expdesc *e); 74LUAI_FUNC void luaK_exp2anyregup (FuncState *fs, expdesc *e);
77LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e); 75LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e);
78LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e); 76LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e);
79LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e);
80LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key); 77LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key);
81LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k); 78LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k);
82LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e); 79LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e);
diff --git a/src/3rdParty/lua/lcorolib.c b/src/3rdParty/lua/lcorolib.c
index 40b880b..c64adf0 100644
--- a/src/3rdParty/lua/lcorolib.c
+++ b/src/3rdParty/lua/lcorolib.c
@@ -76,7 +76,7 @@ static int luaB_auxwrap (lua_State *L) {
76 if (l_unlikely(r < 0)) { /* error? */ 76 if (l_unlikely(r < 0)) { /* error? */
77 int stat = lua_status(co); 77 int stat = lua_status(co);
78 if (stat != LUA_OK && stat != LUA_YIELD) { /* error in the coroutine? */ 78 if (stat != LUA_OK && stat != LUA_YIELD) { /* error in the coroutine? */
79 stat = lua_resetthread(co, L); /* close its tbc variables */ 79 stat = lua_closethread(co, L); /* close its tbc variables */
80 lua_assert(stat != LUA_OK); 80 lua_assert(stat != LUA_OK);
81 lua_xmove(co, L, 1); /* move error message to the caller */ 81 lua_xmove(co, L, 1); /* move error message to the caller */
82 } 82 }
@@ -172,7 +172,7 @@ static int luaB_close (lua_State *L) {
172 int status = auxstatus(L, co); 172 int status = auxstatus(L, co);
173 switch (status) { 173 switch (status) {
174 case COS_DEAD: case COS_YIELD: { 174 case COS_DEAD: case COS_YIELD: {
175 status = lua_resetthread(co, L); 175 status = lua_closethread(co, L);
176 if (status == LUA_OK) { 176 if (status == LUA_OK) {
177 lua_pushboolean(L, 1); 177 lua_pushboolean(L, 1);
178 return 1; 178 return 1;
diff --git a/src/3rdParty/lua/ldebug.c b/src/3rdParty/lua/ldebug.c
index 3fae5cf..690ac38 100644
--- a/src/3rdParty/lua/ldebug.c
+++ b/src/3rdParty/lua/ldebug.c
@@ -426,7 +426,7 @@ static const char *getobjname (const Proto *p, int lastpc, int reg,
426*/ 426*/
427static void kname (const Proto *p, int c, const char **name) { 427static void kname (const Proto *p, int c, const char **name) {
428 TValue *kvalue = &p->k[c]; 428 TValue *kvalue = &p->k[c];
429 *name = (ttisstring(kvalue)) ? svalue(kvalue) : "?"; 429 *name = (ttisstring(kvalue)) ? getstr(tsvalue(kvalue)) : "?";
430} 430}
431 431
432 432
@@ -569,7 +569,7 @@ static const char *getobjname (const Proto *p, int lastpc, int reg,
569 int b = (op == OP_LOADK) ? GETARG_Bx(i) 569 int b = (op == OP_LOADK) ? GETARG_Bx(i)
570 : GETARG_Ax(p->code[pc + 1]); 570 : GETARG_Ax(p->code[pc + 1]);
571 if (ttisstring(&p->k[b])) { 571 if (ttisstring(&p->k[b])) {
572 *name = svalue(&p->k[b]); 572 *name = getstr(tsvalue(&p->k[b]));
573 return "constant"; 573 return "constant";
574 } 574 }
575 break; 575 break;
@@ -627,7 +627,7 @@ static const char *funcnamefromcode (lua_State *L, const Proto *p,
627 default: 627 default:
628 return NULL; /* cannot find a reasonable name */ 628 return NULL; /* cannot find a reasonable name */
629 } 629 }
630 *name = getstr(G(L)->tmname[tm]) + 2; 630 *name = getshrstr(G(L)->tmname[tm]) + 2;
631 return "metamethod"; 631 return "metamethod";
632} 632}
633 633
@@ -656,18 +656,19 @@ static const char *funcnamefromcall (lua_State *L, CallInfo *ci,
656 656
657 657
658/* 658/*
659** Check whether pointer 'o' points to some value in the stack 659** Check whether pointer 'o' points to some value in the stack frame of
660** frame of the current function. Because 'o' may not point to a 660** the current function and, if so, returns its index. Because 'o' may
661** value in this stack, we cannot compare it with the region 661** not point to a value in this stack, we cannot compare it with the
662** boundaries (undefined behaviour in ISO C). 662** region boundaries (undefined behavior in ISO C).
663*/ 663*/
664static int isinstack (CallInfo *ci, const TValue *o) { 664static int instack (CallInfo *ci, const TValue *o) {
665 StkId pos; 665 int pos;
666 for (pos = ci->func.p + 1; pos < ci->top.p; pos++) { 666 StkId base = ci->func.p + 1;
667 if (o == s2v(pos)) 667 for (pos = 0; base + pos < ci->top.p; pos++) {
668 return 1; 668 if (o == s2v(base + pos))
669 return pos;
669 } 670 }
670 return 0; /* not found */ 671 return -1; /* not found */
671} 672}
672 673
673 674
@@ -708,9 +709,11 @@ static const char *varinfo (lua_State *L, const TValue *o) {
708 const char *kind = NULL; 709 const char *kind = NULL;
709 if (isLua(ci)) { 710 if (isLua(ci)) {
710 kind = getupvalname(ci, o, &name); /* check whether 'o' is an upvalue */ 711 kind = getupvalname(ci, o, &name); /* check whether 'o' is an upvalue */
711 if (!kind && isinstack(ci, o)) /* no? try a register */ 712 if (!kind) { /* not an upvalue? */
712 kind = getobjname(ci_func(ci)->p, currentpc(ci), 713 int reg = instack(ci, o); /* try a register */
713 cast_int(cast(StkId, o) - (ci->func.p + 1)), &name); 714 if (reg >= 0) /* is 'o' a register? */
715 kind = getobjname(ci_func(ci)->p, currentpc(ci), reg, &name);
716 }
714 } 717 }
715 return formatvarinfo(L, kind, name); 718 return formatvarinfo(L, kind, name);
716} 719}
@@ -845,7 +848,7 @@ static int changedline (const Proto *p, int oldpc, int newpc) {
845 if (p->lineinfo == NULL) /* no debug information? */ 848 if (p->lineinfo == NULL) /* no debug information? */
846 return 0; 849 return 0;
847 if (newpc - oldpc < MAXIWTHABS / 2) { /* not too far apart? */ 850 if (newpc - oldpc < MAXIWTHABS / 2) { /* not too far apart? */
848 int delta = 0; /* line diference */ 851 int delta = 0; /* line difference */
849 int pc = oldpc; 852 int pc = oldpc;
850 for (;;) { 853 for (;;) {
851 int lineinfo = p->lineinfo[++pc]; 854 int lineinfo = p->lineinfo[++pc];
@@ -863,6 +866,28 @@ static int changedline (const Proto *p, int oldpc, int newpc) {
863 866
864 867
865/* 868/*
869** Traces Lua calls. If code is running the first instruction of a function,
870** and function is not vararg, and it is not coming from an yield,
871** calls 'luaD_hookcall'. (Vararg functions will call 'luaD_hookcall'
872** after adjusting its variable arguments; otherwise, they could call
873** a line/count hook before the call hook. Functions coming from
874** an yield already called 'luaD_hookcall' before yielding.)
875*/
876int luaG_tracecall (lua_State *L) {
877 CallInfo *ci = L->ci;
878 Proto *p = ci_func(ci)->p;
879 ci->u.l.trap = 1; /* ensure hooks will be checked */
880 if (ci->u.l.savedpc == p->code) { /* first instruction (not resuming)? */
881 if (p->is_vararg)
882 return 0; /* hooks will start at VARARGPREP instruction */
883 else if (!(ci->callstatus & CIST_HOOKYIELD)) /* not yieded? */
884 luaD_hookcall(L, ci); /* check 'call' hook */
885 }
886 return 1; /* keep 'trap' on */
887}
888
889
890/*
866** Traces the execution of a Lua function. Called before the execution 891** Traces the execution of a Lua function. Called before the execution
867** of each opcode, when debug is on. 'L->oldpc' stores the last 892** of each opcode, when debug is on. 'L->oldpc' stores the last
868** instruction traced, to detect line changes. When entering a new 893** instruction traced, to detect line changes. When entering a new
diff --git a/src/3rdParty/lua/ldebug.h b/src/3rdParty/lua/ldebug.h
index 2c3074c..2bfce3c 100644
--- a/src/3rdParty/lua/ldebug.h
+++ b/src/3rdParty/lua/ldebug.h
@@ -58,6 +58,7 @@ LUAI_FUNC const char *luaG_addinfo (lua_State *L, const char *msg,
58 TString *src, int line); 58 TString *src, int line);
59LUAI_FUNC l_noret luaG_errormsg (lua_State *L); 59LUAI_FUNC l_noret luaG_errormsg (lua_State *L);
60LUAI_FUNC int luaG_traceexec (lua_State *L, const Instruction *pc); 60LUAI_FUNC int luaG_traceexec (lua_State *L, const Instruction *pc);
61LUAI_FUNC int luaG_tracecall (lua_State *L);
61 62
62 63
63#endif 64#endif
diff --git a/src/3rdParty/lua/ldo.c b/src/3rdParty/lua/ldo.c
index c30cde7..bd8d965 100644
--- a/src/3rdParty/lua/ldo.c
+++ b/src/3rdParty/lua/ldo.c
@@ -299,17 +299,13 @@ static int stackinuse (lua_State *L) {
299*/ 299*/
300void luaD_shrinkstack (lua_State *L) { 300void luaD_shrinkstack (lua_State *L) {
301 int inuse = stackinuse(L); 301 int inuse = stackinuse(L);
302 int nsize = inuse * 2; /* proposed new size */ 302 int max = (inuse > LUAI_MAXSTACK / 3) ? LUAI_MAXSTACK : inuse * 3;
303 int max = inuse * 3; /* maximum "reasonable" size */
304 if (max > LUAI_MAXSTACK) {
305 max = LUAI_MAXSTACK; /* respect stack limit */
306 if (nsize > LUAI_MAXSTACK)
307 nsize = LUAI_MAXSTACK;
308 }
309 /* if thread is currently not handling a stack overflow and its 303 /* if thread is currently not handling a stack overflow and its
310 size is larger than maximum "reasonable" size, shrink it */ 304 size is larger than maximum "reasonable" size, shrink it */
311 if (inuse <= LUAI_MAXSTACK && stacksize(L) > max) 305 if (inuse <= LUAI_MAXSTACK && stacksize(L) > max) {
306 int nsize = (inuse > LUAI_MAXSTACK / 2) ? LUAI_MAXSTACK : inuse * 2;
312 luaD_reallocstack(L, nsize, 0); /* ok if that fails */ 307 luaD_reallocstack(L, nsize, 0); /* ok if that fails */
308 }
313 else /* don't change stack */ 309 else /* don't change stack */
314 condmovestack(L,{},{}); /* (change only for debugging) */ 310 condmovestack(L,{},{}); /* (change only for debugging) */
315 luaE_shrinkCI(L); /* shrink CI list */ 311 luaE_shrinkCI(L); /* shrink CI list */
@@ -413,7 +409,7 @@ static void rethook (lua_State *L, CallInfo *ci, int nres) {
413** stack, below original 'func', so that 'luaD_precall' can call it. Raise 409** stack, below original 'func', so that 'luaD_precall' can call it. Raise
414** an error if there is no '__call' metafield. 410** an error if there is no '__call' metafield.
415*/ 411*/
416StkId luaD_tryfuncTM (lua_State *L, StkId func) { 412static StkId tryfuncTM (lua_State *L, StkId func) {
417 const TValue *tm; 413 const TValue *tm;
418 StkId p; 414 StkId p;
419 checkstackGCp(L, 1, func); /* space for metamethod */ 415 checkstackGCp(L, 1, func); /* space for metamethod */
@@ -572,7 +568,7 @@ int luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func,
572 return -1; 568 return -1;
573 } 569 }
574 default: { /* not a function */ 570 default: { /* not a function */
575 func = luaD_tryfuncTM(L, func); /* try to get '__call' metamethod */ 571 func = tryfuncTM(L, func); /* try to get '__call' metamethod */
576 /* return luaD_pretailcall(L, ci, func, narg1 + 1, delta); */ 572 /* return luaD_pretailcall(L, ci, func, narg1 + 1, delta); */
577 narg1++; 573 narg1++;
578 goto retry; /* try again */ 574 goto retry; /* try again */
@@ -613,7 +609,7 @@ CallInfo *luaD_precall (lua_State *L, StkId func, int nresults) {
613 return ci; 609 return ci;
614 } 610 }
615 default: { /* not a function */ 611 default: { /* not a function */
616 func = luaD_tryfuncTM(L, func); /* try to get '__call' metamethod */ 612 func = tryfuncTM(L, func); /* try to get '__call' metamethod */
617 /* return luaD_precall(L, func, nresults); */ 613 /* return luaD_precall(L, func, nresults); */
618 goto retry; /* try again with metamethod */ 614 goto retry; /* try again with metamethod */
619 } 615 }
@@ -629,7 +625,7 @@ CallInfo *luaD_precall (lua_State *L, StkId func, int nresults) {
629** check the stack before doing anything else. 'luaD_precall' already 625** check the stack before doing anything else. 'luaD_precall' already
630** does that. 626** does that.
631*/ 627*/
632l_sinline void ccall (lua_State *L, StkId func, int nResults, int inc) { 628l_sinline void ccall (lua_State *L, StkId func, int nResults, l_uint32 inc) {
633 CallInfo *ci; 629 CallInfo *ci;
634 L->nCcalls += inc; 630 L->nCcalls += inc;
635 if (l_unlikely(getCcalls(L) >= LUAI_MAXCCALLS)) { 631 if (l_unlikely(getCcalls(L) >= LUAI_MAXCCALLS)) {
diff --git a/src/3rdParty/lua/ldo.h b/src/3rdParty/lua/ldo.h
index 1aa446a..56008ab 100644
--- a/src/3rdParty/lua/ldo.h
+++ b/src/3rdParty/lua/ldo.h
@@ -71,7 +71,6 @@ LUAI_FUNC int luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func,
71LUAI_FUNC CallInfo *luaD_precall (lua_State *L, StkId func, int nResults); 71LUAI_FUNC CallInfo *luaD_precall (lua_State *L, StkId func, int nResults);
72LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); 72LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults);
73LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults); 73LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults);
74LUAI_FUNC StkId luaD_tryfuncTM (lua_State *L, StkId func);
75LUAI_FUNC int luaD_closeprotected (lua_State *L, ptrdiff_t level, int status); 74LUAI_FUNC int luaD_closeprotected (lua_State *L, ptrdiff_t level, int status);
76LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, 75LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u,
77 ptrdiff_t oldtop, ptrdiff_t ef); 76 ptrdiff_t oldtop, ptrdiff_t ef);
diff --git a/src/3rdParty/lua/ldump.c b/src/3rdParty/lua/ldump.c
index f848b66..f231691 100644
--- a/src/3rdParty/lua/ldump.c
+++ b/src/3rdParty/lua/ldump.c
@@ -10,6 +10,7 @@
10#include "lprefix.h" 10#include "lprefix.h"
11 11
12 12
13#include <limits.h>
13#include <stddef.h> 14#include <stddef.h>
14 15
15#include "lua.h" 16#include "lua.h"
@@ -55,8 +56,11 @@ static void dumpByte (DumpState *D, int y) {
55} 56}
56 57
57 58
58/* dumpInt Buff Size */ 59/*
59#define DIBS ((sizeof(size_t) * 8 / 7) + 1) 60** 'dumpSize' buffer size: each byte can store up to 7 bits. (The "+6"
61** rounds up the division.)
62*/
63#define DIBS ((sizeof(size_t) * CHAR_BIT + 6) / 7)
60 64
61static void dumpSize (DumpState *D, size_t x) { 65static void dumpSize (DumpState *D, size_t x) {
62 lu_byte buff[DIBS]; 66 lu_byte buff[DIBS];
diff --git a/src/3rdParty/lua/lgc.c b/src/3rdParty/lua/lgc.c
index 2e74990..253a289 100644
--- a/src/3rdParty/lua/lgc.c
+++ b/src/3rdParty/lua/lgc.c
@@ -542,10 +542,12 @@ static void traversestrongtable (global_State *g, Table *h) {
542static lu_mem traversetable (global_State *g, Table *h) { 542static lu_mem traversetable (global_State *g, Table *h) {
543 const char *weakkey, *weakvalue; 543 const char *weakkey, *weakvalue;
544 const TValue *mode = gfasttm(g, h->metatable, TM_MODE); 544 const TValue *mode = gfasttm(g, h->metatable, TM_MODE);
545 TString *smode;
545 markobjectN(g, h->metatable); 546 markobjectN(g, h->metatable);
546 if (mode && ttisstring(mode) && /* is there a weak mode? */ 547 if (mode && ttisshrstring(mode) && /* is there a weak mode? */
547 (cast_void(weakkey = strchr(svalue(mode), 'k')), 548 (cast_void(smode = tsvalue(mode)),
548 cast_void(weakvalue = strchr(svalue(mode), 'v')), 549 cast_void(weakkey = strchr(getshrstr(smode), 'k')),
550 cast_void(weakvalue = strchr(getshrstr(smode), 'v')),
549 (weakkey || weakvalue))) { /* is really weak? */ 551 (weakkey || weakvalue))) { /* is really weak? */
550 if (!weakkey) /* strong keys? */ 552 if (!weakkey) /* strong keys? */
551 traverseweakvalue(g, h); 553 traverseweakvalue(g, h);
@@ -638,7 +640,9 @@ static int traversethread (global_State *g, lua_State *th) {
638 for (uv = th->openupval; uv != NULL; uv = uv->u.open.next) 640 for (uv = th->openupval; uv != NULL; uv = uv->u.open.next)
639 markobject(g, uv); /* open upvalues cannot be collected */ 641 markobject(g, uv); /* open upvalues cannot be collected */
640 if (g->gcstate == GCSatomic) { /* final traversal? */ 642 if (g->gcstate == GCSatomic) { /* final traversal? */
641 for (; o < th->stack_last.p + EXTRA_STACK; o++) 643 if (!g->gcemergency)
644 luaD_shrinkstack(th); /* do not change stack in emergency cycle */
645 for (o = th->top.p; o < th->stack_last.p + EXTRA_STACK; o++)
642 setnilvalue(s2v(o)); /* clear dead stack slice */ 646 setnilvalue(s2v(o)); /* clear dead stack slice */
643 /* 'remarkupvals' may have removed thread from 'twups' list */ 647 /* 'remarkupvals' may have removed thread from 'twups' list */
644 if (!isintwups(th) && th->openupval != NULL) { 648 if (!isintwups(th) && th->openupval != NULL) {
@@ -646,8 +650,6 @@ static int traversethread (global_State *g, lua_State *th) {
646 g->twups = th; 650 g->twups = th;
647 } 651 }
648 } 652 }
649 else if (!g->gcemergency)
650 luaD_shrinkstack(th); /* do not change stack in emergency cycle */
651 return 1 + stacksize(th); 653 return 1 + stacksize(th);
652} 654}
653 655
@@ -1409,7 +1411,7 @@ static void stepgenfull (lua_State *L, global_State *g) {
1409 setminordebt(g); 1411 setminordebt(g);
1410 } 1412 }
1411 else { /* another bad collection; stay in incremental mode */ 1413 else { /* another bad collection; stay in incremental mode */
1412 g->GCestimate = gettotalbytes(g); /* first estimate */; 1414 g->GCestimate = gettotalbytes(g); /* first estimate */
1413 entersweep(L); 1415 entersweep(L);
1414 luaC_runtilstate(L, bitmask(GCSpause)); /* finish collection */ 1416 luaC_runtilstate(L, bitmask(GCSpause)); /* finish collection */
1415 setpause(g); 1417 setpause(g);
@@ -1604,7 +1606,7 @@ static lu_mem singlestep (lua_State *L) {
1604 case GCSenteratomic: { 1606 case GCSenteratomic: {
1605 work = atomic(L); /* work is what was traversed by 'atomic' */ 1607 work = atomic(L); /* work is what was traversed by 'atomic' */
1606 entersweep(L); 1608 entersweep(L);
1607 g->GCestimate = gettotalbytes(g); /* first estimate */; 1609 g->GCestimate = gettotalbytes(g); /* first estimate */
1608 break; 1610 break;
1609 } 1611 }
1610 case GCSswpallgc: { /* sweep "regular" objects */ 1612 case GCSswpallgc: { /* sweep "regular" objects */
@@ -1681,12 +1683,15 @@ static void incstep (lua_State *L, global_State *g) {
1681} 1683}
1682 1684
1683/* 1685/*
1684** performs a basic GC step if collector is running 1686** Performs a basic GC step if collector is running. (If collector is
1687** not running, set a reasonable debt to avoid it being called at
1688** every single check.)
1685*/ 1689*/
1686void luaC_step (lua_State *L) { 1690void luaC_step (lua_State *L) {
1687 global_State *g = G(L); 1691 global_State *g = G(L);
1688 lua_assert(!g->gcemergency); 1692 if (!gcrunning(g)) /* not running? */
1689 if (gcrunning(g)) { /* running? */ 1693 luaE_setdebt(g, -2000);
1694 else {
1690 if(isdecGCmodegen(g)) 1695 if(isdecGCmodegen(g))
1691 genstep(L, g); 1696 genstep(L, g);
1692 else 1697 else
@@ -1707,6 +1712,8 @@ static void fullinc (lua_State *L, global_State *g) {
1707 entersweep(L); /* sweep everything to turn them back to white */ 1712 entersweep(L); /* sweep everything to turn them back to white */
1708 /* finish any pending sweep phase to start a new cycle */ 1713 /* finish any pending sweep phase to start a new cycle */
1709 luaC_runtilstate(L, bitmask(GCSpause)); 1714 luaC_runtilstate(L, bitmask(GCSpause));
1715 luaC_runtilstate(L, bitmask(GCSpropagate)); /* start new cycle */
1716 g->gcstate = GCSenteratomic; /* go straight to atomic phase ??? */
1710 luaC_runtilstate(L, bitmask(GCScallfin)); /* run up to finalizers */ 1717 luaC_runtilstate(L, bitmask(GCScallfin)); /* run up to finalizers */
1711 /* estimate must be correct after a full GC cycle */ 1718 /* estimate must be correct after a full GC cycle */
1712 lua_assert(g->GCestimate == gettotalbytes(g)); 1719 lua_assert(g->GCestimate == gettotalbytes(g));
diff --git a/src/3rdParty/lua/lgc.h b/src/3rdParty/lua/lgc.h
index c960e70..538f6ed 100644
--- a/src/3rdParty/lua/lgc.h
+++ b/src/3rdParty/lua/lgc.h
@@ -172,18 +172,19 @@
172#define luaC_checkGC(L) luaC_condGC(L,(void)0,(void)0) 172#define luaC_checkGC(L) luaC_condGC(L,(void)0,(void)0)
173 173
174 174
175#define luaC_barrier(L,p,v) ( \
176 (iscollectable(v) && isblack(p) && iswhite(gcvalue(v))) ? \
177 luaC_barrier_(L,obj2gco(p),gcvalue(v)) : cast_void(0))
178
179#define luaC_barrierback(L,p,v) ( \
180 (iscollectable(v) && isblack(p) && iswhite(gcvalue(v))) ? \
181 luaC_barrierback_(L,p) : cast_void(0))
182
183#define luaC_objbarrier(L,p,o) ( \ 175#define luaC_objbarrier(L,p,o) ( \
184 (isblack(p) && iswhite(o)) ? \ 176 (isblack(p) && iswhite(o)) ? \
185 luaC_barrier_(L,obj2gco(p),obj2gco(o)) : cast_void(0)) 177 luaC_barrier_(L,obj2gco(p),obj2gco(o)) : cast_void(0))
186 178
179#define luaC_barrier(L,p,v) ( \
180 iscollectable(v) ? luaC_objbarrier(L,p,gcvalue(v)) : cast_void(0))
181
182#define luaC_objbarrierback(L,p,o) ( \
183 (isblack(p) && iswhite(o)) ? luaC_barrierback_(L,p) : cast_void(0))
184
185#define luaC_barrierback(L,p,v) ( \
186 iscollectable(v) ? luaC_objbarrierback(L, p, gcvalue(v)) : cast_void(0))
187
187LUAI_FUNC void luaC_fix (lua_State *L, GCObject *o); 188LUAI_FUNC void luaC_fix (lua_State *L, GCObject *o);
188LUAI_FUNC void luaC_freeallobjects (lua_State *L); 189LUAI_FUNC void luaC_freeallobjects (lua_State *L);
189LUAI_FUNC void luaC_step (lua_State *L); 190LUAI_FUNC void luaC_step (lua_State *L);
diff --git a/src/3rdParty/lua/llex.c b/src/3rdParty/lua/llex.c
index b0dc0ac..5fc39a5 100644
--- a/src/3rdParty/lua/llex.c
+++ b/src/3rdParty/lua/llex.c
@@ -128,7 +128,7 @@ l_noret luaX_syntaxerror (LexState *ls, const char *msg) {
128** ensuring there is only one copy of each unique string. The table 128** ensuring there is only one copy of each unique string. The table
129** here is used as a set: the string enters as the key, while its value 129** here is used as a set: the string enters as the key, while its value
130** is irrelevant. We use the string itself as the value only because it 130** is irrelevant. We use the string itself as the value only because it
131** is a TValue readly available. Later, the code generation can change 131** is a TValue readily available. Later, the code generation can change
132** this value. 132** this value.
133*/ 133*/
134TString *luaX_newstring (LexState *ls, const char *str, size_t l) { 134TString *luaX_newstring (LexState *ls, const char *str, size_t l) {
diff --git a/src/3rdParty/lua/llimits.h b/src/3rdParty/lua/llimits.h
index 52a32f9..1c826f7 100644
--- a/src/3rdParty/lua/llimits.h
+++ b/src/3rdParty/lua/llimits.h
@@ -71,11 +71,24 @@ typedef signed char ls_byte;
71 71
72 72
73/* 73/*
74** conversion of pointer to unsigned integer: 74** conversion of pointer to unsigned integer: this is for hashing only;
75** this is for hashing only; there is no problem if the integer 75** there is no problem if the integer cannot hold the whole pointer
76** cannot hold the whole pointer value 76** value. (In strict ISO C this may cause undefined behavior, but no
77** actual machine seems to bother.)
77*/ 78*/
78#define point2uint(p) ((unsigned int)((size_t)(p) & UINT_MAX)) 79#if !defined(LUA_USE_C89) && defined(__STDC_VERSION__) && \
80 __STDC_VERSION__ >= 199901L
81#include <stdint.h>
82#if defined(UINTPTR_MAX) /* even in C99 this type is optional */
83#define L_P2I uintptr_t
84#else /* no 'intptr'? */
85#define L_P2I uintmax_t /* use the largest available integer */
86#endif
87#else /* C89 option */
88#define L_P2I size_t
89#endif
90
91#define point2uint(p) ((unsigned int)((L_P2I)(p) & UINT_MAX))
79 92
80 93
81 94
diff --git a/src/3rdParty/lua/lmathlib.c b/src/3rdParty/lua/lmathlib.c
index e0c61a1..d0b1e1e 100644
--- a/src/3rdParty/lua/lmathlib.c
+++ b/src/3rdParty/lua/lmathlib.c
@@ -267,7 +267,7 @@ static int math_type (lua_State *L) {
267 267
268/* try to find an integer type with at least 64 bits */ 268/* try to find an integer type with at least 64 bits */
269 269
270#if (ULONG_MAX >> 31 >> 31) >= 3 270#if ((ULONG_MAX >> 31) >> 31) >= 3
271 271
272/* 'long' has at least 64 bits */ 272/* 'long' has at least 64 bits */
273#define Rand64 unsigned long 273#define Rand64 unsigned long
@@ -277,9 +277,9 @@ static int math_type (lua_State *L) {
277/* there is a 'long long' type (which must have at least 64 bits) */ 277/* there is a 'long long' type (which must have at least 64 bits) */
278#define Rand64 unsigned long long 278#define Rand64 unsigned long long
279 279
280#elif (LUA_MAXUNSIGNED >> 31 >> 31) >= 3 280#elif ((LUA_MAXUNSIGNED >> 31) >> 31) >= 3
281 281
282/* 'lua_Integer' has at least 64 bits */ 282/* 'lua_Unsigned' has at least 64 bits */
283#define Rand64 lua_Unsigned 283#define Rand64 lua_Unsigned
284 284
285#endif 285#endif
@@ -500,12 +500,12 @@ static lua_Number I2d (Rand64 x) {
500 500
501/* convert a 'Rand64' to a 'lua_Unsigned' */ 501/* convert a 'Rand64' to a 'lua_Unsigned' */
502static lua_Unsigned I2UInt (Rand64 x) { 502static lua_Unsigned I2UInt (Rand64 x) {
503 return ((lua_Unsigned)trim32(x.h) << 31 << 1) | (lua_Unsigned)trim32(x.l); 503 return (((lua_Unsigned)trim32(x.h) << 31) << 1) | (lua_Unsigned)trim32(x.l);
504} 504}
505 505
506/* convert a 'lua_Unsigned' to a 'Rand64' */ 506/* convert a 'lua_Unsigned' to a 'Rand64' */
507static Rand64 Int2I (lua_Unsigned n) { 507static Rand64 Int2I (lua_Unsigned n) {
508 return packI((lu_int32)(n >> 31 >> 1), (lu_int32)n); 508 return packI((lu_int32)((n >> 31) >> 1), (lu_int32)n);
509} 509}
510 510
511#endif /* } */ 511#endif /* } */
diff --git a/src/3rdParty/lua/lmem.c b/src/3rdParty/lua/lmem.c
index 9029d58..9800a86 100644
--- a/src/3rdParty/lua/lmem.c
+++ b/src/3rdParty/lua/lmem.c
@@ -22,25 +22,6 @@
22#include "lstate.h" 22#include "lstate.h"
23 23
24 24
25#if defined(EMERGENCYGCTESTS)
26/*
27** First allocation will fail whenever not building initial state.
28** (This fail will trigger 'tryagain' and a full GC cycle at every
29** allocation.)
30*/
31static void *firsttry (global_State *g, void *block, size_t os, size_t ns) {
32 if (completestate(g) && ns > 0) /* frees never fail */
33 return NULL; /* fail */
34 else /* normal allocation */
35 return (*g->frealloc)(g->ud, block, os, ns);
36}
37#else
38#define firsttry(g,block,os,ns) ((*g->frealloc)(g->ud, block, os, ns))
39#endif
40
41
42
43
44 25
45/* 26/*
46** About the realloc function: 27** About the realloc function:
@@ -60,6 +41,43 @@ static void *firsttry (global_State *g, void *block, size_t os, size_t ns) {
60*/ 41*/
61 42
62 43
44/*
45** Macro to call the allocation function.
46*/
47#define callfrealloc(g,block,os,ns) ((*g->frealloc)(g->ud, block, os, ns))
48
49
50/*
51** When an allocation fails, it will try again after an emergency
52** collection, except when it cannot run a collection. The GC should
53** not be called while the state is not fully built, as the collector
54** is not yet fully initialized. Also, it should not be called when
55** 'gcstopem' is true, because then the interpreter is in the middle of
56** a collection step.
57*/
58#define cantryagain(g) (completestate(g) && !g->gcstopem)
59
60
61
62
63#if defined(EMERGENCYGCTESTS)
64/*
65** First allocation will fail except when freeing a block (frees never
66** fail) and when it cannot try again; this fail will trigger 'tryagain'
67** and a full GC cycle at every allocation.
68*/
69static void *firsttry (global_State *g, void *block, size_t os, size_t ns) {
70 if (ns > 0 && cantryagain(g))
71 return NULL; /* fail */
72 else /* normal allocation */
73 return callfrealloc(g, block, os, ns);
74}
75#else
76#define firsttry(g,block,os,ns) callfrealloc(g, block, os, ns)
77#endif
78
79
80
63 81
64 82
65/* 83/*
@@ -132,7 +150,7 @@ l_noret luaM_toobig (lua_State *L) {
132void luaM_free_ (lua_State *L, void *block, size_t osize) { 150void luaM_free_ (lua_State *L, void *block, size_t osize) {
133 global_State *g = G(L); 151 global_State *g = G(L);
134 lua_assert((osize == 0) == (block == NULL)); 152 lua_assert((osize == 0) == (block == NULL));
135 (*g->frealloc)(g->ud, block, osize, 0); 153 callfrealloc(g, block, osize, 0);
136 g->GCdebt -= osize; 154 g->GCdebt -= osize;
137} 155}
138 156
@@ -140,19 +158,15 @@ void luaM_free_ (lua_State *L, void *block, size_t osize) {
140/* 158/*
141** In case of allocation fail, this function will do an emergency 159** In case of allocation fail, this function will do an emergency
142** collection to free some memory and then try the allocation again. 160** collection to free some memory and then try the allocation again.
143** The GC should not be called while state is not fully built, as the
144** collector is not yet fully initialized. Also, it should not be called
145** when 'gcstopem' is true, because then the interpreter is in the
146** middle of a collection step.
147*/ 161*/
148static void *tryagain (lua_State *L, void *block, 162static void *tryagain (lua_State *L, void *block,
149 size_t osize, size_t nsize) { 163 size_t osize, size_t nsize) {
150 global_State *g = G(L); 164 global_State *g = G(L);
151 if (completestate(g) && !g->gcstopem) { 165 if (cantryagain(g)) {
152 luaC_fullgc(L, 1); /* try to free some memory... */ 166 luaC_fullgc(L, 1); /* try to free some memory... */
153 return (*g->frealloc)(g->ud, block, osize, nsize); /* try again */ 167 return callfrealloc(g, block, osize, nsize); /* try again */
154 } 168 }
155 else return NULL; /* cannot free any memory without a full state */ 169 else return NULL; /* cannot run an emergency collection */
156} 170}
157 171
158 172
diff --git a/src/3rdParty/lua/loadlib.c b/src/3rdParty/lua/loadlib.c
index d792dff..6d289fc 100644
--- a/src/3rdParty/lua/loadlib.c
+++ b/src/3rdParty/lua/loadlib.c
@@ -25,15 +25,6 @@
25 25
26 26
27/* 27/*
28** LUA_IGMARK is a mark to ignore all before it when building the
29** luaopen_ function name.
30*/
31#if !defined (LUA_IGMARK)
32#define LUA_IGMARK "-"
33#endif
34
35
36/*
37** LUA_CSUBSEP is the character that replaces dots in submodule names 28** LUA_CSUBSEP is the character that replaces dots in submodule names
38** when searching for a C loader. 29** when searching for a C loader.
39** LUA_LSUBSEP is the character that replaces dots in submodule names 30** LUA_LSUBSEP is the character that replaces dots in submodule names
diff --git a/src/3rdParty/lua/lobject.c b/src/3rdParty/lua/lobject.c
index f73ffc6..9cfa522 100644
--- a/src/3rdParty/lua/lobject.c
+++ b/src/3rdParty/lua/lobject.c
@@ -542,7 +542,7 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
542 addstr2buff(&buff, fmt, strlen(fmt)); /* rest of 'fmt' */ 542 addstr2buff(&buff, fmt, strlen(fmt)); /* rest of 'fmt' */
543 clearbuff(&buff); /* empty buffer into the stack */ 543 clearbuff(&buff); /* empty buffer into the stack */
544 lua_assert(buff.pushed == 1); 544 lua_assert(buff.pushed == 1);
545 return svalue(s2v(L->top.p - 1)); 545 return getstr(tsvalue(s2v(L->top.p - 1)));
546} 546}
547 547
548 548
diff --git a/src/3rdParty/lua/lobject.h b/src/3rdParty/lua/lobject.h
index 556608e..980e42f 100644
--- a/src/3rdParty/lua/lobject.h
+++ b/src/3rdParty/lua/lobject.h
@@ -386,7 +386,7 @@ typedef struct GCObject {
386typedef struct TString { 386typedef struct TString {
387 CommonHeader; 387 CommonHeader;
388 lu_byte extra; /* reserved words for short strings; "has hash" for longs */ 388 lu_byte extra; /* reserved words for short strings; "has hash" for longs */
389 lu_byte shrlen; /* length for short strings */ 389 lu_byte shrlen; /* length for short strings, 0xFF for long strings */
390 unsigned int hash; 390 unsigned int hash;
391 union { 391 union {
392 size_t lnglen; /* length for long strings */ 392 size_t lnglen; /* length for long strings */
@@ -398,19 +398,17 @@ typedef struct TString {
398 398
399 399
400/* 400/*
401** Get the actual string (array of bytes) from a 'TString'. 401** Get the actual string (array of bytes) from a 'TString'. (Generic
402** version and specialized versions for long and short strings.)
402*/ 403*/
403#define getstr(ts) ((ts)->contents) 404#define getstr(ts) ((ts)->contents)
405#define getlngstr(ts) check_exp((ts)->shrlen == 0xFF, (ts)->contents)
406#define getshrstr(ts) check_exp((ts)->shrlen != 0xFF, (ts)->contents)
404 407
405 408
406/* get the actual string (array of bytes) from a Lua value */
407#define svalue(o) getstr(tsvalue(o))
408
409/* get string length from 'TString *s' */ 409/* get string length from 'TString *s' */
410#define tsslen(s) ((s)->tt == LUA_VSHRSTR ? (s)->shrlen : (s)->u.lnglen) 410#define tsslen(s) \
411 411 ((s)->shrlen != 0xFF ? (s)->shrlen : (s)->u.lnglen)
412/* get string length from 'TValue *o' */
413#define vslen(o) tsslen(tsvalue(o))
414 412
415/* }================================================================== */ 413/* }================================================================== */
416 414
diff --git a/src/3rdParty/lua/lopcodes.h b/src/3rdParty/lua/lopcodes.h
index 7c27451..46911ca 100644
--- a/src/3rdParty/lua/lopcodes.h
+++ b/src/3rdParty/lua/lopcodes.h
@@ -21,7 +21,7 @@ iABC C(8) | B(8) |k| A(8) | Op(7) |
21iABx Bx(17) | A(8) | Op(7) | 21iABx Bx(17) | A(8) | Op(7) |
22iAsBx sBx (signed)(17) | A(8) | Op(7) | 22iAsBx sBx (signed)(17) | A(8) | Op(7) |
23iAx Ax(25) | Op(7) | 23iAx Ax(25) | Op(7) |
24isJ sJ(25) | Op(7) | 24isJ sJ (signed)(25) | Op(7) |
25 25
26 A signed argument is represented in excess K: the represented value is 26 A signed argument is represented in excess K: the represented value is
27 the written unsigned value minus K, where K is half the maximum for the 27 the written unsigned value minus K, where K is half the maximum for the
@@ -210,15 +210,15 @@ OP_LOADNIL,/* A B R[A], R[A+1], ..., R[A+B] := nil */
210OP_GETUPVAL,/* A B R[A] := UpValue[B] */ 210OP_GETUPVAL,/* A B R[A] := UpValue[B] */
211OP_SETUPVAL,/* A B UpValue[B] := R[A] */ 211OP_SETUPVAL,/* A B UpValue[B] := R[A] */
212 212
213OP_GETTABUP,/* A B C R[A] := UpValue[B][K[C]:string] */ 213OP_GETTABUP,/* A B C R[A] := UpValue[B][K[C]:shortstring] */
214OP_GETTABLE,/* A B C R[A] := R[B][R[C]] */ 214OP_GETTABLE,/* A B C R[A] := R[B][R[C]] */
215OP_GETI,/* A B C R[A] := R[B][C] */ 215OP_GETI,/* A B C R[A] := R[B][C] */
216OP_GETFIELD,/* A B C R[A] := R[B][K[C]:string] */ 216OP_GETFIELD,/* A B C R[A] := R[B][K[C]:shortstring] */
217 217
218OP_SETTABUP,/* A B C UpValue[A][K[B]:string] := RK(C) */ 218OP_SETTABUP,/* A B C UpValue[A][K[B]:shortstring] := RK(C) */
219OP_SETTABLE,/* A B C R[A][R[B]] := RK(C) */ 219OP_SETTABLE,/* A B C R[A][R[B]] := RK(C) */
220OP_SETI,/* A B C R[A][B] := RK(C) */ 220OP_SETI,/* A B C R[A][B] := RK(C) */
221OP_SETFIELD,/* A B C R[A][K[B]:string] := RK(C) */ 221OP_SETFIELD,/* A B C R[A][K[B]:shortstring] := RK(C) */
222 222
223OP_NEWTABLE,/* A B C k R[A] := {} */ 223OP_NEWTABLE,/* A B C k R[A] := {} */
224 224
diff --git a/src/3rdParty/lua/loslib.c b/src/3rdParty/lua/loslib.c
index 854dcf6..ad5a927 100644
--- a/src/3rdParty/lua/loslib.c
+++ b/src/3rdParty/lua/loslib.c
@@ -30,23 +30,14 @@
30*/ 30*/
31#if !defined(LUA_STRFTIMEOPTIONS) /* { */ 31#if !defined(LUA_STRFTIMEOPTIONS) /* { */
32 32
33/* options for ANSI C 89 (only 1-char options) */
34#define L_STRFTIMEC89 "aAbBcdHIjmMpSUwWxXyYZ%"
35
36/* options for ISO C 99 and POSIX */
37#define L_STRFTIMEC99 "aAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%" \
38 "||" "EcECExEXEyEY" "OdOeOHOIOmOMOSOuOUOVOwOWOy" /* two-char options */
39
40/* options for Windows */
41#define L_STRFTIMEWIN "aAbBcdHIjmMpSUwWxXyYzZ%" \
42 "||" "#c#x#d#H#I#j#m#M#S#U#w#W#y#Y" /* two-char options */
43
44#if defined(LUA_USE_WINDOWS) 33#if defined(LUA_USE_WINDOWS)
45#define LUA_STRFTIMEOPTIONS L_STRFTIMEWIN 34#define LUA_STRFTIMEOPTIONS "aAbBcdHIjmMpSUwWxXyYzZ%" \
46#elif defined(LUA_USE_C89) 35 "||" "#c#x#d#H#I#j#m#M#S#U#w#W#y#Y" /* two-char options */
47#define LUA_STRFTIMEOPTIONS L_STRFTIMEC89 36#elif defined(LUA_USE_C89) /* ANSI C 89 (only 1-char options) */
37#define LUA_STRFTIMEOPTIONS "aAbBcdHIjmMpSUwWxXyYZ%"
48#else /* C99 specification */ 38#else /* C99 specification */
49#define LUA_STRFTIMEOPTIONS L_STRFTIMEC99 39#define LUA_STRFTIMEOPTIONS "aAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%" \
40 "||" "EcECExEXEyEY" "OdOeOHOIOmOMOSOuOUOVOwOWOy" /* two-char options */
50#endif 41#endif
51 42
52#endif /* } */ 43#endif /* } */
@@ -138,12 +129,21 @@
138/* }================================================================== */ 129/* }================================================================== */
139 130
140 131
132#if !defined(l_system)
133#if defined(LUA_USE_IOS)
134/* Despite claiming to be ISO C, iOS does not implement 'system'. */
135#define l_system(cmd) ((cmd) == NULL ? 0 : -1)
136#else
137#define l_system(cmd) system(cmd) /* default definition */
138#endif
139#endif
140
141 141
142static int os_execute (lua_State *L) { 142static int os_execute (lua_State *L) {
143 const char *cmd = luaL_optstring(L, 1, NULL); 143 const char *cmd = luaL_optstring(L, 1, NULL);
144 int stat; 144 int stat;
145 errno = 0; 145 errno = 0;
146 stat = system(cmd); 146 stat = l_system(cmd);
147 if (cmd != NULL) 147 if (cmd != NULL)
148 return luaL_execresult(L, stat); 148 return luaL_execresult(L, stat);
149 else { 149 else {
diff --git a/src/3rdParty/lua/lparser.c b/src/3rdParty/lua/lparser.c
index 24668c2..b745f23 100644
--- a/src/3rdParty/lua/lparser.c
+++ b/src/3rdParty/lua/lparser.c
@@ -521,12 +521,12 @@ static l_noret jumpscopeerror (LexState *ls, Labeldesc *gt) {
521 521
522/* 522/*
523** Solves the goto at index 'g' to given 'label' and removes it 523** Solves the goto at index 'g' to given 'label' and removes it
524** from the list of pending goto's. 524** from the list of pending gotos.
525** If it jumps into the scope of some variable, raises an error. 525** If it jumps into the scope of some variable, raises an error.
526*/ 526*/
527static void solvegoto (LexState *ls, int g, Labeldesc *label) { 527static void solvegoto (LexState *ls, int g, Labeldesc *label) {
528 int i; 528 int i;
529 Labellist *gl = &ls->dyd->gt; /* list of goto's */ 529 Labellist *gl = &ls->dyd->gt; /* list of gotos */
530 Labeldesc *gt = &gl->arr[g]; /* goto to be resolved */ 530 Labeldesc *gt = &gl->arr[g]; /* goto to be resolved */
531 lua_assert(eqstr(gt->name, label->name)); 531 lua_assert(eqstr(gt->name, label->name));
532 if (l_unlikely(gt->nactvar < label->nactvar)) /* enter some scope? */ 532 if (l_unlikely(gt->nactvar < label->nactvar)) /* enter some scope? */
@@ -580,7 +580,7 @@ static int newgotoentry (LexState *ls, TString *name, int line, int pc) {
580/* 580/*
581** Solves forward jumps. Check whether new label 'lb' matches any 581** Solves forward jumps. Check whether new label 'lb' matches any
582** pending gotos in current block and solves them. Return true 582** pending gotos in current block and solves them. Return true
583** if any of the goto's need to close upvalues. 583** if any of the gotos need to close upvalues.
584*/ 584*/
585static int solvegotos (LexState *ls, Labeldesc *lb) { 585static int solvegotos (LexState *ls, Labeldesc *lb) {
586 Labellist *gl = &ls->dyd->gt; 586 Labellist *gl = &ls->dyd->gt;
@@ -601,7 +601,7 @@ static int solvegotos (LexState *ls, Labeldesc *lb) {
601/* 601/*
602** Create a new label with the given 'name' at the given 'line'. 602** Create a new label with the given 'name' at the given 'line'.
603** 'last' tells whether label is the last non-op statement in its 603** 'last' tells whether label is the last non-op statement in its
604** block. Solves all pending goto's to this new label and adds 604** block. Solves all pending gotos to this new label and adds
605** a close instruction if necessary. 605** a close instruction if necessary.
606** Returns true iff it added a close instruction. 606** Returns true iff it added a close instruction.
607*/ 607*/
diff --git a/src/3rdParty/lua/lstate.c b/src/3rdParty/lua/lstate.c
index 1fbefb4..7fefacb 100644
--- a/src/3rdParty/lua/lstate.c
+++ b/src/3rdParty/lua/lstate.c
@@ -119,7 +119,7 @@ CallInfo *luaE_extendCI (lua_State *L) {
119/* 119/*
120** free all CallInfo structures not in use by a thread 120** free all CallInfo structures not in use by a thread
121*/ 121*/
122void luaE_freeCI (lua_State *L) { 122static void freeCI (lua_State *L) {
123 CallInfo *ci = L->ci; 123 CallInfo *ci = L->ci;
124 CallInfo *next = ci->next; 124 CallInfo *next = ci->next;
125 ci->next = NULL; 125 ci->next = NULL;
@@ -204,7 +204,7 @@ static void freestack (lua_State *L) {
204 if (L->stack.p == NULL) 204 if (L->stack.p == NULL)
205 return; /* stack not completely built yet */ 205 return; /* stack not completely built yet */
206 L->ci = &L->base_ci; /* free the entire 'ci' list */ 206 L->ci = &L->base_ci; /* free the entire 'ci' list */
207 luaE_freeCI(L); 207 freeCI(L);
208 lua_assert(L->nci == 0); 208 lua_assert(L->nci == 0);
209 luaM_freearray(L, L->stack.p, stacksize(L) + EXTRA_STACK); /* free stack */ 209 luaM_freearray(L, L->stack.p, stacksize(L) + EXTRA_STACK); /* free stack */
210} 210}
@@ -339,7 +339,7 @@ int luaE_resetthread (lua_State *L, int status) {
339} 339}
340 340
341 341
342LUA_API int lua_resetthread (lua_State *L, lua_State *from) { 342LUA_API int lua_closethread (lua_State *L, lua_State *from) {
343 int status; 343 int status;
344 lua_lock(L); 344 lua_lock(L);
345 L->nCcalls = (from) ? getCcalls(from) : 0; 345 L->nCcalls = (from) ? getCcalls(from) : 0;
@@ -349,6 +349,14 @@ LUA_API int lua_resetthread (lua_State *L, lua_State *from) {
349} 349}
350 350
351 351
352/*
353** Deprecated! Use 'lua_closethread' instead.
354*/
355LUA_API int lua_resetthread (lua_State *L) {
356 return lua_closethread(L, NULL);
357}
358
359
352LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { 360LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
353 int i; 361 int i;
354 lua_State *L; 362 lua_State *L;
@@ -425,7 +433,7 @@ void luaE_warning (lua_State *L, const char *msg, int tocont) {
425void luaE_warnerror (lua_State *L, const char *where) { 433void luaE_warnerror (lua_State *L, const char *where) {
426 TValue *errobj = s2v(L->top.p - 1); /* error object */ 434 TValue *errobj = s2v(L->top.p - 1); /* error object */
427 const char *msg = (ttisstring(errobj)) 435 const char *msg = (ttisstring(errobj))
428 ? svalue(errobj) 436 ? getstr(tsvalue(errobj))
429 : "error object is not a string"; 437 : "error object is not a string";
430 /* produce warning "error in %s (%s)" (where, msg) */ 438 /* produce warning "error in %s (%s)" (where, msg) */
431 luaE_warning(L, "error in ", 1); 439 luaE_warning(L, "error in ", 1);
diff --git a/src/3rdParty/lua/lstate.h b/src/3rdParty/lua/lstate.h
index 2e90781..007704c 100644
--- a/src/3rdParty/lua/lstate.h
+++ b/src/3rdParty/lua/lstate.h
@@ -9,6 +9,11 @@
9 9
10#include "lua.h" 10#include "lua.h"
11 11
12
13/* Some header files included here need this definition */
14typedef struct CallInfo CallInfo;
15
16
12#include "lobject.h" 17#include "lobject.h"
13#include "ltm.h" 18#include "ltm.h"
14#include "lzio.h" 19#include "lzio.h"
@@ -169,14 +174,14 @@ typedef struct stringtable {
169** - field 'transferinfo' is used only during call/returnhooks, 174** - field 'transferinfo' is used only during call/returnhooks,
170** before the function starts or after it ends. 175** before the function starts or after it ends.
171*/ 176*/
172typedef struct CallInfo { 177struct CallInfo {
173 StkIdRel func; /* function index in the stack */ 178 StkIdRel func; /* function index in the stack */
174 StkIdRel top; /* top for this function */ 179 StkIdRel top; /* top for this function */
175 struct CallInfo *previous, *next; /* dynamic call link */ 180 struct CallInfo *previous, *next; /* dynamic call link */
176 union { 181 union {
177 struct { /* only for Lua functions */ 182 struct { /* only for Lua functions */
178 const Instruction *savedpc; 183 const Instruction *savedpc;
179 volatile l_signalT trap; 184 volatile l_signalT trap; /* function is tracing lines/counts */
180 int nextraargs; /* # of extra arguments in vararg functions */ 185 int nextraargs; /* # of extra arguments in vararg functions */
181 } l; 186 } l;
182 struct { /* only for C functions */ 187 struct { /* only for C functions */
@@ -196,7 +201,7 @@ typedef struct CallInfo {
196 } u2; 201 } u2;
197 short nresults; /* expected number of results from this function */ 202 short nresults; /* expected number of results from this function */
198 unsigned short callstatus; 203 unsigned short callstatus;
199} CallInfo; 204};
200 205
201 206
202/* 207/*
@@ -291,7 +296,7 @@ typedef struct global_State {
291 struct lua_State *mainthread; 296 struct lua_State *mainthread;
292 TString *memerrmsg; /* message for memory-allocation errors */ 297 TString *memerrmsg; /* message for memory-allocation errors */
293 TString *tmname[TM_N]; /* array with tag-method names */ 298 TString *tmname[TM_N]; /* array with tag-method names */
294 struct Table *mt[LUA_NUMTAGS]; /* metatables for basic types */ 299 struct Table *mt[LUA_NUMTYPES]; /* metatables for basic types */
295 TString *strcache[STRCACHE_N][STRCACHE_M]; /* cache for strings in API */ 300 TString *strcache[STRCACHE_N][STRCACHE_M]; /* cache for strings in API */
296 lua_WarnFunction warnf; /* warning function */ 301 lua_WarnFunction warnf; /* warning function */
297 void *ud_warn; /* auxiliary data to 'warnf' */ 302 void *ud_warn; /* auxiliary data to 'warnf' */
@@ -391,7 +396,6 @@ union GCUnion {
391LUAI_FUNC void luaE_setdebt (global_State *g, l_mem debt); 396LUAI_FUNC void luaE_setdebt (global_State *g, l_mem debt);
392LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1); 397LUAI_FUNC void luaE_freethread (lua_State *L, lua_State *L1);
393LUAI_FUNC CallInfo *luaE_extendCI (lua_State *L); 398LUAI_FUNC CallInfo *luaE_extendCI (lua_State *L);
394LUAI_FUNC void luaE_freeCI (lua_State *L);
395LUAI_FUNC void luaE_shrinkCI (lua_State *L); 399LUAI_FUNC void luaE_shrinkCI (lua_State *L);
396LUAI_FUNC void luaE_checkcstack (lua_State *L); 400LUAI_FUNC void luaE_checkcstack (lua_State *L);
397LUAI_FUNC void luaE_incCstack (lua_State *L); 401LUAI_FUNC void luaE_incCstack (lua_State *L);
diff --git a/src/3rdParty/lua/lstring.c b/src/3rdParty/lua/lstring.c
index 13dcaf4..1032ad8 100644
--- a/src/3rdParty/lua/lstring.c
+++ b/src/3rdParty/lua/lstring.c
@@ -36,7 +36,7 @@ int luaS_eqlngstr (TString *a, TString *b) {
36 lua_assert(a->tt == LUA_VLNGSTR && b->tt == LUA_VLNGSTR); 36 lua_assert(a->tt == LUA_VLNGSTR && b->tt == LUA_VLNGSTR);
37 return (a == b) || /* same instance or... */ 37 return (a == b) || /* same instance or... */
38 ((len == b->u.lnglen) && /* equal length and ... */ 38 ((len == b->u.lnglen) && /* equal length and ... */
39 (memcmp(getstr(a), getstr(b), len) == 0)); /* equal contents */ 39 (memcmp(getlngstr(a), getlngstr(b), len) == 0)); /* equal contents */
40} 40}
41 41
42 42
@@ -52,7 +52,7 @@ unsigned int luaS_hashlongstr (TString *ts) {
52 lua_assert(ts->tt == LUA_VLNGSTR); 52 lua_assert(ts->tt == LUA_VLNGSTR);
53 if (ts->extra == 0) { /* no hash? */ 53 if (ts->extra == 0) { /* no hash? */
54 size_t len = ts->u.lnglen; 54 size_t len = ts->u.lnglen;
55 ts->hash = luaS_hash(getstr(ts), len, ts->hash); 55 ts->hash = luaS_hash(getlngstr(ts), len, ts->hash);
56 ts->extra = 1; /* now it has its hash */ 56 ts->extra = 1; /* now it has its hash */
57 } 57 }
58 return ts->hash; 58 return ts->hash;
@@ -157,6 +157,7 @@ static TString *createstrobj (lua_State *L, size_t l, int tag, unsigned int h) {
157TString *luaS_createlngstrobj (lua_State *L, size_t l) { 157TString *luaS_createlngstrobj (lua_State *L, size_t l) {
158 TString *ts = createstrobj(L, l, LUA_VLNGSTR, G(L)->seed); 158 TString *ts = createstrobj(L, l, LUA_VLNGSTR, G(L)->seed);
159 ts->u.lnglen = l; 159 ts->u.lnglen = l;
160 ts->shrlen = 0xFF; /* signals that it is a long string */
160 return ts; 161 return ts;
161} 162}
162 163
@@ -193,7 +194,7 @@ static TString *internshrstr (lua_State *L, const char *str, size_t l) {
193 TString **list = &tb->hash[lmod(h, tb->size)]; 194 TString **list = &tb->hash[lmod(h, tb->size)];
194 lua_assert(str != NULL); /* otherwise 'memcmp'/'memcpy' are undefined */ 195 lua_assert(str != NULL); /* otherwise 'memcmp'/'memcpy' are undefined */
195 for (ts = *list; ts != NULL; ts = ts->u.hnext) { 196 for (ts = *list; ts != NULL; ts = ts->u.hnext) {
196 if (l == ts->shrlen && (memcmp(str, getstr(ts), l * sizeof(char)) == 0)) { 197 if (l == ts->shrlen && (memcmp(str, getshrstr(ts), l * sizeof(char)) == 0)) {
197 /* found! */ 198 /* found! */
198 if (isdead(g, ts)) /* dead (but not collected yet)? */ 199 if (isdead(g, ts)) /* dead (but not collected yet)? */
199 changewhite(ts); /* resurrect it */ 200 changewhite(ts); /* resurrect it */
@@ -206,7 +207,7 @@ static TString *internshrstr (lua_State *L, const char *str, size_t l) {
206 list = &tb->hash[lmod(h, tb->size)]; /* rehash with new size */ 207 list = &tb->hash[lmod(h, tb->size)]; /* rehash with new size */
207 } 208 }
208 ts = createstrobj(L, l, LUA_VSHRSTR, h); 209 ts = createstrobj(L, l, LUA_VSHRSTR, h);
209 memcpy(getstr(ts), str, l * sizeof(char)); 210 memcpy(getshrstr(ts), str, l * sizeof(char));
210 ts->shrlen = cast_byte(l); 211 ts->shrlen = cast_byte(l);
211 ts->u.hnext = *list; 212 ts->u.hnext = *list;
212 *list = ts; 213 *list = ts;
@@ -226,7 +227,7 @@ TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
226 if (l_unlikely(l >= (MAX_SIZE - sizeof(TString))/sizeof(char))) 227 if (l_unlikely(l >= (MAX_SIZE - sizeof(TString))/sizeof(char)))
227 luaM_toobig(L); 228 luaM_toobig(L);
228 ts = luaS_createlngstrobj(L, l); 229 ts = luaS_createlngstrobj(L, l);
229 memcpy(getstr(ts), str, l * sizeof(char)); 230 memcpy(getlngstr(ts), str, l * sizeof(char));
230 return ts; 231 return ts;
231 } 232 }
232} 233}
diff --git a/src/3rdParty/lua/lstrlib.c b/src/3rdParty/lua/lstrlib.c
index 0b4fdbb..0316716 100644
--- a/src/3rdParty/lua/lstrlib.c
+++ b/src/3rdParty/lua/lstrlib.c
@@ -570,7 +570,7 @@ static const char *match_capture (MatchState *ms, const char *s, int l) {
570static const char *match (MatchState *ms, const char *s, const char *p) { 570static const char *match (MatchState *ms, const char *s, const char *p) {
571 if (l_unlikely(ms->matchdepth-- == 0)) 571 if (l_unlikely(ms->matchdepth-- == 0))
572 luaL_error(ms->L, "pattern too complex"); 572 luaL_error(ms->L, "pattern too complex");
573 init: /* using goto's to optimize tail recursion */ 573 init: /* using goto to optimize tail recursion */
574 if (p != ms->p_end) { /* end of pattern? */ 574 if (p != ms->p_end) { /* end of pattern? */
575 switch (*p) { 575 switch (*p) {
576 case '(': { /* start capture */ 576 case '(': { /* start capture */
diff --git a/src/3rdParty/lua/ltable.c b/src/3rdParty/lua/ltable.c
index cc7993e..3fb575a 100644
--- a/src/3rdParty/lua/ltable.c
+++ b/src/3rdParty/lua/ltable.c
@@ -257,10 +257,12 @@ LUAI_FUNC unsigned int luaH_realasize (const Table *t) {
257 size |= (size >> 2); 257 size |= (size >> 2);
258 size |= (size >> 4); 258 size |= (size >> 4);
259 size |= (size >> 8); 259 size |= (size >> 8);
260#if (UINT_MAX >> 14) > 3 /* unsigned int has more than 16 bits */
260 size |= (size >> 16); 261 size |= (size >> 16);
261#if (UINT_MAX >> 30) > 3 262#if (UINT_MAX >> 30) > 3
262 size |= (size >> 32); /* unsigned int has more than 32 bits */ 263 size |= (size >> 32); /* unsigned int has more than 32 bits */
263#endif 264#endif
265#endif
264 size++; 266 size++;
265 lua_assert(ispow2(size) && size/2 < t->alimit && t->alimit < size); 267 lua_assert(ispow2(size) && size/2 < t->alimit && t->alimit < size);
266 return size; 268 return size;
@@ -660,7 +662,8 @@ static Node *getfreepos (Table *t) {
660** put new key in its main position; otherwise (colliding node is in its main 662** put new key in its main position; otherwise (colliding node is in its main
661** position), new key goes to an empty position. 663** position), new key goes to an empty position.
662*/ 664*/
663void luaH_newkey (lua_State *L, Table *t, const TValue *key, TValue *value) { 665static void luaH_newkey (lua_State *L, Table *t, const TValue *key,
666 TValue *value) {
664 Node *mp; 667 Node *mp;
665 TValue aux; 668 TValue aux;
666 if (l_unlikely(ttisnil(key))) 669 if (l_unlikely(ttisnil(key)))
diff --git a/src/3rdParty/lua/ltable.h b/src/3rdParty/lua/ltable.h
index 75dd9e2..8e68903 100644
--- a/src/3rdParty/lua/ltable.h
+++ b/src/3rdParty/lua/ltable.h
@@ -41,8 +41,6 @@ LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key,
41LUAI_FUNC const TValue *luaH_getshortstr (Table *t, TString *key); 41LUAI_FUNC const TValue *luaH_getshortstr (Table *t, TString *key);
42LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); 42LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key);
43LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); 43LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key);
44LUAI_FUNC void luaH_newkey (lua_State *L, Table *t, const TValue *key,
45 TValue *value);
46LUAI_FUNC void luaH_set (lua_State *L, Table *t, const TValue *key, 44LUAI_FUNC void luaH_set (lua_State *L, Table *t, const TValue *key,
47 TValue *value); 45 TValue *value);
48LUAI_FUNC void luaH_finishset (lua_State *L, Table *t, const TValue *key, 46LUAI_FUNC void luaH_finishset (lua_State *L, Table *t, const TValue *key,
diff --git a/src/3rdParty/lua/lua.h b/src/3rdParty/lua/lua.h
index bfba4d1..040cc8e 100644
--- a/src/3rdParty/lua/lua.h
+++ b/src/3rdParty/lua/lua.h
@@ -1,7 +1,7 @@
1/* 1/*
2** $Id: lua.h $ 2** $Id: lua.h $
3** Lua - A Scripting Language 3** Lua - A Scripting Language
4** Lua.org, PUC-Rio, Brazil (http://www.lua.org) 4** Lua.org, PUC-Rio, Brazil (www.lua.org)
5** See Copyright Notice at the end of this file 5** See Copyright Notice at the end of this file
6*/ 6*/
7 7
@@ -13,20 +13,19 @@
13#include <stddef.h> 13#include <stddef.h>
14 14
15 15
16#include "luaconf.h" 16#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2023 Lua.org, PUC-Rio"
17#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes"
17 18
18 19
19#define LUA_VERSION_MAJOR "5" 20#define LUA_VERSION_MAJOR_N 5
20#define LUA_VERSION_MINOR "4" 21#define LUA_VERSION_MINOR_N 4
21#define LUA_VERSION_RELEASE "5" 22#define LUA_VERSION_RELEASE_N 6
22 23
23#define LUA_VERSION_NUM 504 24#define LUA_VERSION_NUM (LUA_VERSION_MAJOR_N * 100 + LUA_VERSION_MINOR_N)
24#define LUA_VERSION_RELEASE_NUM (LUA_VERSION_NUM * 100 + 5) 25#define LUA_VERSION_RELEASE_NUM (LUA_VERSION_NUM * 100 + LUA_VERSION_RELEASE_N)
25 26
26#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR 27
27#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE 28#include "luaconf.h"
28#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2022 Lua.org, PUC-Rio"
29#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes"
30 29
31 30
32/* mark for precompiled code ('<esc>Lua') */ 31/* mark for precompiled code ('<esc>Lua') */
@@ -131,6 +130,16 @@ typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
131typedef void (*lua_WarnFunction) (void *ud, const char *msg, int tocont); 130typedef void (*lua_WarnFunction) (void *ud, const char *msg, int tocont);
132 131
133 132
133/*
134** Type used by the debug API to collect debug information
135*/
136typedef struct lua_Debug lua_Debug;
137
138
139/*
140** Functions to be called by the debugger in specific events
141*/
142typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
134 143
135 144
136/* 145/*
@@ -153,7 +162,8 @@ extern const char lua_ident[];
153LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); 162LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);
154LUA_API void (lua_close) (lua_State *L); 163LUA_API void (lua_close) (lua_State *L);
155LUA_API lua_State *(lua_newthread) (lua_State *L); 164LUA_API lua_State *(lua_newthread) (lua_State *L);
156LUA_API int (lua_resetthread) (lua_State *L, lua_State *from); 165LUA_API int (lua_closethread) (lua_State *L, lua_State *from);
166LUA_API int (lua_resetthread) (lua_State *L); /* Deprecated! */
157 167
158LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); 168LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);
159 169
@@ -442,12 +452,6 @@ LUA_API void (lua_closeslot) (lua_State *L, int idx);
442#define LUA_MASKLINE (1 << LUA_HOOKLINE) 452#define LUA_MASKLINE (1 << LUA_HOOKLINE)
443#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT) 453#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT)
444 454
445typedef struct lua_Debug lua_Debug; /* activation record */
446
447
448/* Functions to be called by the debugger in specific events */
449typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
450
451 455
452LUA_API int (lua_getstack) (lua_State *L, int level, lua_Debug *ar); 456LUA_API int (lua_getstack) (lua_State *L, int level, lua_Debug *ar);
453LUA_API int (lua_getinfo) (lua_State *L, const char *what, lua_Debug *ar); 457LUA_API int (lua_getinfo) (lua_State *L, const char *what, lua_Debug *ar);
@@ -491,8 +495,19 @@ struct lua_Debug {
491/* }====================================================================== */ 495/* }====================================================================== */
492 496
493 497
498#define LUAI_TOSTRAUX(x) #x
499#define LUAI_TOSTR(x) LUAI_TOSTRAUX(x)
500
501#define LUA_VERSION_MAJOR LUAI_TOSTR(LUA_VERSION_MAJOR_N)
502#define LUA_VERSION_MINOR LUAI_TOSTR(LUA_VERSION_MINOR_N)
503#define LUA_VERSION_RELEASE LUAI_TOSTR(LUA_VERSION_RELEASE_N)
504
505#define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR
506#define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE
507
508
494/****************************************************************************** 509/******************************************************************************
495* Copyright (C) 1994-2022 Lua.org, PUC-Rio. 510* Copyright (C) 1994-2023 Lua.org, PUC-Rio.
496* 511*
497* Permission is hereby granted, free of charge, to any person obtaining 512* Permission is hereby granted, free of charge, to any person obtaining
498* a copy of this software and associated documentation files (the 513* a copy of this software and associated documentation files (the
diff --git a/src/3rdParty/lua/luaconf.h b/src/3rdParty/lua/luaconf.h
index e4650fb..acebe29 100644
--- a/src/3rdParty/lua/luaconf.h
+++ b/src/3rdParty/lua/luaconf.h
@@ -70,6 +70,12 @@
70#endif 70#endif
71 71
72 72
73#if defined(LUA_USE_IOS)
74#define LUA_USE_POSIX
75#define LUA_USE_DLOPEN
76#endif
77
78
73/* 79/*
74@@ LUAI_IS32INT is true iff 'int' has (at least) 32 bits. 80@@ LUAI_IS32INT is true iff 'int' has (at least) 32 bits.
75*/ 81*/
@@ -251,6 +257,15 @@
251 257
252#endif 258#endif
253 259
260
261/*
262** LUA_IGMARK is a mark to ignore all after it when building the
263** module name (e.g., used to build the luaopen_ function name).
264** Typically, the sufix after the mark is the module version,
265** as in "mod-v1.2.so".
266*/
267#define LUA_IGMARK "-"
268
254/* }================================================================== */ 269/* }================================================================== */
255 270
256 271
diff --git a/src/3rdParty/lua/lundump.c b/src/3rdParty/lua/lundump.c
index aba93f8..f1852c3 100644
--- a/src/3rdParty/lua/lundump.c
+++ b/src/3rdParty/lua/lundump.c
@@ -122,7 +122,7 @@ static TString *loadStringN (LoadState *S, Proto *p) {
122 ts = luaS_createlngstrobj(L, size); /* create string */ 122 ts = luaS_createlngstrobj(L, size); /* create string */
123 setsvalue2s(L, L->top.p, ts); /* anchor it ('loadVector' can GC) */ 123 setsvalue2s(L, L->top.p, ts); /* anchor it ('loadVector' can GC) */
124 luaD_inctop(L); 124 luaD_inctop(L);
125 loadVector(S, getstr(ts), size); /* load directly in final place */ 125 loadVector(S, getlngstr(ts), size); /* load directly in final place */
126 L->top.p--; /* pop string */ 126 L->top.p--; /* pop string */
127 } 127 }
128 luaC_objbarrier(L, p, ts); 128 luaC_objbarrier(L, p, ts);
@@ -248,6 +248,8 @@ static void loadDebug (LoadState *S, Proto *f) {
248 f->locvars[i].endpc = loadInt(S); 248 f->locvars[i].endpc = loadInt(S);
249 } 249 }
250 n = loadInt(S); 250 n = loadInt(S);
251 if (n != 0) /* does it have debug information? */
252 n = f->sizeupvalues; /* must be this many */
251 for (i = 0; i < n; i++) 253 for (i = 0; i < n; i++)
252 f->upvalues[i].name = loadStringN(S, f); 254 f->upvalues[i].name = loadStringN(S, f);
253} 255}
diff --git a/src/3rdParty/lua/lundump.h b/src/3rdParty/lua/lundump.h
index f3748a9..bc71ced 100644
--- a/src/3rdParty/lua/lundump.h
+++ b/src/3rdParty/lua/lundump.h
@@ -21,8 +21,7 @@
21/* 21/*
22** Encode major-minor version in one byte, one nibble for each 22** Encode major-minor version in one byte, one nibble for each
23*/ 23*/
24#define MYINT(s) (s[0]-'0') /* assume one-digit numerals */ 24#define LUAC_VERSION (LUA_VERSION_MAJOR_N*16+LUA_VERSION_MINOR_N)
25#define LUAC_VERSION (MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR))
26 25
27#define LUAC_FORMAT 0 /* this is the official format */ 26#define LUAC_FORMAT 0 /* this is the official format */
28 27
diff --git a/src/3rdParty/lua/lvm.c b/src/3rdParty/lua/lvm.c
index 2e84dc6..4d71cff 100644
--- a/src/3rdParty/lua/lvm.c
+++ b/src/3rdParty/lua/lvm.c
@@ -91,8 +91,10 @@ static int l_strton (const TValue *obj, TValue *result) {
91 lua_assert(obj != result); 91 lua_assert(obj != result);
92 if (!cvt2num(obj)) /* is object not a string? */ 92 if (!cvt2num(obj)) /* is object not a string? */
93 return 0; 93 return 0;
94 else 94 else {
95 return (luaO_str2num(svalue(obj), result) == vslen(obj) + 1); 95 TString *st = tsvalue(obj);
96 return (luaO_str2num(getstr(st), result) == tsslen(st) + 1);
97 }
96} 98}
97 99
98 100
@@ -366,30 +368,32 @@ void luaV_finishset (lua_State *L, const TValue *t, TValue *key,
366 368
367 369
368/* 370/*
369** Compare two strings 'ls' x 'rs', returning an integer less-equal- 371** Compare two strings 'ts1' x 'ts2', returning an integer less-equal-
370** -greater than zero if 'ls' is less-equal-greater than 'rs'. 372** -greater than zero if 'ts1' is less-equal-greater than 'ts2'.
371** The code is a little tricky because it allows '\0' in the strings 373** The code is a little tricky because it allows '\0' in the strings
372** and it uses 'strcoll' (to respect locales) for each segments 374** and it uses 'strcoll' (to respect locales) for each segment
373** of the strings. 375** of the strings. Note that segments can compare equal but still
376** have different lengths.
374*/ 377*/
375static int l_strcmp (const TString *ls, const TString *rs) { 378static int l_strcmp (const TString *ts1, const TString *ts2) {
376 const char *l = getstr(ls); 379 const char *s1 = getstr(ts1);
377 size_t ll = tsslen(ls); 380 size_t rl1 = tsslen(ts1); /* real length */
378 const char *r = getstr(rs); 381 const char *s2 = getstr(ts2);
379 size_t lr = tsslen(rs); 382 size_t rl2 = tsslen(ts2);
380 for (;;) { /* for each segment */ 383 for (;;) { /* for each segment */
381 int temp = strcoll(l, r); 384 int temp = strcoll(s1, s2);
382 if (temp != 0) /* not equal? */ 385 if (temp != 0) /* not equal? */
383 return temp; /* done */ 386 return temp; /* done */
384 else { /* strings are equal up to a '\0' */ 387 else { /* strings are equal up to a '\0' */
385 size_t len = strlen(l); /* index of first '\0' in both strings */ 388 size_t zl1 = strlen(s1); /* index of first '\0' in 's1' */
386 if (len == lr) /* 'rs' is finished? */ 389 size_t zl2 = strlen(s2); /* index of first '\0' in 's2' */
387 return (len == ll) ? 0 : 1; /* check 'ls' */ 390 if (zl2 == rl2) /* 's2' is finished? */
388 else if (len == ll) /* 'ls' is finished? */ 391 return (zl1 == rl1) ? 0 : 1; /* check 's1' */
389 return -1; /* 'ls' is less than 'rs' ('rs' is not finished) */ 392 else if (zl1 == rl1) /* 's1' is finished? */
390 /* both strings longer than 'len'; go on comparing after the '\0' */ 393 return -1; /* 's1' is less than 's2' ('s2' is not finished) */
391 len++; 394 /* both strings longer than 'zl'; go on comparing after the '\0' */
392 l += len; ll -= len; r += len; lr -= len; 395 zl1++; zl2++;
396 s1 += zl1; rl1 -= zl1; s2 += zl2; rl2 -= zl2;
393 } 397 }
394 } 398 }
395} 399}
@@ -624,8 +628,9 @@ int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2) {
624static void copy2buff (StkId top, int n, char *buff) { 628static void copy2buff (StkId top, int n, char *buff) {
625 size_t tl = 0; /* size already copied */ 629 size_t tl = 0; /* size already copied */
626 do { 630 do {
627 size_t l = vslen(s2v(top - n)); /* length of string being copied */ 631 TString *st = tsvalue(s2v(top - n));
628 memcpy(buff + tl, svalue(s2v(top - n)), l * sizeof(char)); 632 size_t l = tsslen(st); /* length of string being copied */
633 memcpy(buff + tl, getstr(st), l * sizeof(char));
629 tl += l; 634 tl += l;
630 } while (--n > 0); 635 } while (--n > 0);
631} 636}
@@ -651,11 +656,11 @@ void luaV_concat (lua_State *L, int total) {
651 } 656 }
652 else { 657 else {
653 /* at least two non-empty string values; get as many as possible */ 658 /* at least two non-empty string values; get as many as possible */
654 size_t tl = vslen(s2v(top - 1)); 659 size_t tl = tsslen(tsvalue(s2v(top - 1)));
655 TString *ts; 660 TString *ts;
656 /* collect total length and number of strings */ 661 /* collect total length and number of strings */
657 for (n = 1; n < total && tostring(L, s2v(top - n - 1)); n++) { 662 for (n = 1; n < total && tostring(L, s2v(top - n - 1)); n++) {
658 size_t l = vslen(s2v(top - n - 1)); 663 size_t l = tsslen(tsvalue(s2v(top - n - 1)));
659 if (l_unlikely(l >= (MAX_SIZE/sizeof(char)) - tl)) { 664 if (l_unlikely(l >= (MAX_SIZE/sizeof(char)) - tl)) {
660 L->top.p = top - total; /* pop strings to avoid wasting stack */ 665 L->top.p = top - total; /* pop strings to avoid wasting stack */
661 luaG_runerror(L, "string length overflow"); 666 luaG_runerror(L, "string length overflow");
@@ -669,7 +674,7 @@ void luaV_concat (lua_State *L, int total) {
669 } 674 }
670 else { /* long string; copy strings directly to final result */ 675 else { /* long string; copy strings directly to final result */
671 ts = luaS_createlngstrobj(L, tl); 676 ts = luaS_createlngstrobj(L, tl);
672 copy2buff(top, n, getstr(ts)); 677 copy2buff(top, n, getlngstr(ts));
673 } 678 }
674 setsvalue2s(L, top - n, ts); /* create result */ 679 setsvalue2s(L, top - n, ts); /* create result */
675 } 680 }
@@ -1155,18 +1160,11 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1155 startfunc: 1160 startfunc:
1156 trap = L->hookmask; 1161 trap = L->hookmask;
1157 returning: /* trap already set */ 1162 returning: /* trap already set */
1158 cl = clLvalue(s2v(ci->func.p)); 1163 cl = ci_func(ci);
1159 k = cl->p->k; 1164 k = cl->p->k;
1160 pc = ci->u.l.savedpc; 1165 pc = ci->u.l.savedpc;
1161 if (l_unlikely(trap)) { 1166 if (l_unlikely(trap))
1162 if (pc == cl->p->code) { /* first instruction (not resuming)? */ 1167 trap = luaG_tracecall(L);
1163 if (cl->p->is_vararg)
1164 trap = 0; /* hooks will start after VARARGPREP instruction */
1165 else /* check 'call' hook */
1166 luaD_hookcall(L, ci);
1167 }
1168 ci->u.l.trap = 1; /* assume trap is on, for now */
1169 }
1170 base = ci->func.p + 1; 1168 base = ci->func.p + 1;
1171 /* main loop of interpreter */ 1169 /* main loop of interpreter */
1172 for (;;) { 1170 for (;;) {
@@ -1253,7 +1251,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1253 const TValue *slot; 1251 const TValue *slot;
1254 TValue *upval = cl->upvals[GETARG_B(i)]->v.p; 1252 TValue *upval = cl->upvals[GETARG_B(i)]->v.p;
1255 TValue *rc = KC(i); 1253 TValue *rc = KC(i);
1256 TString *key = tsvalue(rc); /* key must be a string */ 1254 TString *key = tsvalue(rc); /* key must be a short string */
1257 if (luaV_fastget(L, upval, key, slot, luaH_getshortstr)) { 1255 if (luaV_fastget(L, upval, key, slot, luaH_getshortstr)) {
1258 setobj2s(L, ra, slot); 1256 setobj2s(L, ra, slot);
1259 } 1257 }
@@ -1296,7 +1294,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1296 const TValue *slot; 1294 const TValue *slot;
1297 TValue *rb = vRB(i); 1295 TValue *rb = vRB(i);
1298 TValue *rc = KC(i); 1296 TValue *rc = KC(i);
1299 TString *key = tsvalue(rc); /* key must be a string */ 1297 TString *key = tsvalue(rc); /* key must be a short string */
1300 if (luaV_fastget(L, rb, key, slot, luaH_getshortstr)) { 1298 if (luaV_fastget(L, rb, key, slot, luaH_getshortstr)) {
1301 setobj2s(L, ra, slot); 1299 setobj2s(L, ra, slot);
1302 } 1300 }
@@ -1309,7 +1307,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1309 TValue *upval = cl->upvals[GETARG_A(i)]->v.p; 1307 TValue *upval = cl->upvals[GETARG_A(i)]->v.p;
1310 TValue *rb = KB(i); 1308 TValue *rb = KB(i);
1311 TValue *rc = RKC(i); 1309 TValue *rc = RKC(i);
1312 TString *key = tsvalue(rb); /* key must be a string */ 1310 TString *key = tsvalue(rb); /* key must be a short string */
1313 if (luaV_fastget(L, upval, key, slot, luaH_getshortstr)) { 1311 if (luaV_fastget(L, upval, key, slot, luaH_getshortstr)) {
1314 luaV_finishfastset(L, upval, slot, rc); 1312 luaV_finishfastset(L, upval, slot, rc);
1315 } 1313 }
@@ -1352,7 +1350,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1352 const TValue *slot; 1350 const TValue *slot;
1353 TValue *rb = KB(i); 1351 TValue *rb = KB(i);
1354 TValue *rc = RKC(i); 1352 TValue *rc = RKC(i);
1355 TString *key = tsvalue(rb); /* key must be a string */ 1353 TString *key = tsvalue(rb); /* key must be a short string */
1356 if (luaV_fastget(L, s2v(ra), key, slot, luaH_getshortstr)) { 1354 if (luaV_fastget(L, s2v(ra), key, slot, luaH_getshortstr)) {
1357 luaV_finishfastset(L, s2v(ra), slot, rc); 1355 luaV_finishfastset(L, s2v(ra), slot, rc);
1358 } 1356 }
@@ -1410,6 +1408,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1410 vmbreak; 1408 vmbreak;
1411 } 1409 }
1412 vmcase(OP_MODK) { 1410 vmcase(OP_MODK) {
1411 savestate(L, ci); /* in case of division by 0 */
1413 op_arithK(L, luaV_mod, luaV_modf); 1412 op_arithK(L, luaV_mod, luaV_modf);
1414 vmbreak; 1413 vmbreak;
1415 } 1414 }
@@ -1422,6 +1421,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1422 vmbreak; 1421 vmbreak;
1423 } 1422 }
1424 vmcase(OP_IDIVK) { 1423 vmcase(OP_IDIVK) {
1424 savestate(L, ci); /* in case of division by 0 */
1425 op_arithK(L, luaV_idiv, luai_numidiv); 1425 op_arithK(L, luaV_idiv, luai_numidiv);
1426 vmbreak; 1426 vmbreak;
1427 } 1427 }
@@ -1470,6 +1470,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1470 vmbreak; 1470 vmbreak;
1471 } 1471 }
1472 vmcase(OP_MOD) { 1472 vmcase(OP_MOD) {
1473 savestate(L, ci); /* in case of division by 0 */
1473 op_arith(L, luaV_mod, luaV_modf); 1474 op_arith(L, luaV_mod, luaV_modf);
1474 vmbreak; 1475 vmbreak;
1475 } 1476 }
@@ -1482,6 +1483,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
1482 vmbreak; 1483 vmbreak;
1483 } 1484 }
1484 vmcase(OP_IDIV) { /* floor division */ 1485 vmcase(OP_IDIV) { /* floor division */
1486 savestate(L, ci); /* in case of division by 0 */
1485 op_arith(L, luaV_idiv, luai_numidiv); 1487 op_arith(L, luaV_idiv, luai_numidiv);
1486 vmbreak; 1488 vmbreak;
1487 } 1489 }