Skip to content

Commit b37c74b

Browse files
committed
update lua5.5 and lua5.4.6
2 parents 5c1deb5 + 118a4b7 commit b37c74b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+46416
-280
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ jobs:
1111
include:
1212
- { os: windows-latest, target: windows, platform: win32-x64}
1313
- { os: windows-latest, target: windows, platform: win32-x86, cmake_arch: "-A Win32"}
14+
<<<<<<< HEAD
1415
- { os: ubuntu-latest, target: linux, platform: linux-x64, zig_build: true}
16+
=======
17+
- { os: ubuntu-latest, target: linux, platform: linux-x64}
18+
- { os: ubuntu-latest, target: linux, platform: linux-x64-zig, zig_build: true}
19+
>>>>>>> 118a4b74e7d2e05faf11ef900f3d16397e50990f
1520
- { os: macos-latest, target: darwin, platform: darwin-x64}
1621
- { os: macos-latest, target: darwin, platform: darwin-arm64}
1722
steps:
@@ -45,8 +50,8 @@ jobs:
4550
if [[ "${{ matrix.zig_build }}" == "true" ]]; then
4651
sudo snap install zig --classic --beta
4752
mkdir -p build
48-
# 使用zig-build.cmake配置文件编译C++项目
49-
cmake -B build -G Ninja -DCMAKE_TOOLCHAIN_FILE=cmake/zig-build.cmake -DCMAKE_BUILD_TYPE=Release -DEMMY_CORE_VERSION=${{env.TAG}}
53+
# 使用Zig作为工具链编译C++项目
54+
cmake -B build -G Ninja -DCMAKE_C_COMPILER=zig -DCMAKE_C_COMPILER_ARG1=cc -DCMAKE_CXX_COMPILER=zig -DCMAKE_CXX_COMPILER_ARG1=c++ -DCMAKE_BUILD_TYPE=Release -DEMMY_CORE_VERSION=${{env.TAG}}
5055
cmake --build build --config Release
5156
cmake --install build --config Release --prefix ${{ github.workspace }}/artifact/
5257
else

build_script/lua_exe/CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ project (lua)
44

55
add_executable(lua)
66

7-
set(EMMY_LUA_VERSION "54" CACHE STRING "Lua version: 51/52/53/54")
7+
set(EMMY_LUA_VERSION "54" CACHE STRING "Lua version: 51/52/53/54/55")
88

9-
if(${EMMY_LUA_VERSION} STREQUAL "54")
10-
set(EMMY_LUA_DIR "lua-5.4.0")
9+
if(${EMMY_LUA_VERSION} STREQUAL "55")
10+
set(EMMY_LUA_DIR "lua-5.5.0-beta")
11+
elseif(${EMMY_LUA_VERSION} STREQUAL "54")
12+
set(EMMY_LUA_DIR "lua-5.4.6")
1113
elseif(${EMMY_LUA_VERSION} STREQUAL "53")
1214
set(EMMY_LUA_DIR "lua-5.3.5")
1315
elseif(${EMMY_LUA_VERSION} STREQUAL "52")

emmy_tool/src/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <string>
33
#include "emmy_tool.h"
44
#include "command_line.h"
5+
#include <thread>
56

67
int main(int argc, char **argv) {
78
CommandLine commandLine;

emmy_tool/src/windows/emmy_tool.windows.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "emmy_tool.h"
22
#include <string>
3-
#include "utility.h"
3+
#include "utility.h"
44
#include "Psapi.h"
55
#include <thread>
66

third-party/lua-5.4.6/src/lapi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,9 @@ LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) {
417417
o = index2value(L, idx); /* previous call may reallocate the stack */
418418
}
419419
if (len != NULL)
420-
*len = vslen(o);
420+
*len = tsslen(tsvalue(o));
421421
lua_unlock(L);
422-
return svalue(o);
422+
return getstr(tsvalue(o));
423423
}
424424

425425

@@ -1343,7 +1343,7 @@ void lua_warning (lua_State *L, const char *msg, int tocont) {
13431343
LUA_API void *lua_newuserdatauv (lua_State *L, size_t size, int nuvalue) {
13441344
Udata *u;
13451345
lua_lock(L);
1346-
api_check(L, 0 <= nuvalue && nuvalue < USHRT_MAX, "invalid value");
1346+
api_check(L, 0 <= nuvalue && nuvalue < SHRT_MAX, "invalid value");
13471347
u = luaS_newudata(L, size, nuvalue);
13481348
setuvalue(L, s2v(L->top.p), u);
13491349
api_incr_top(L);

third-party/lua-5.4.6/src/lauxlib.c

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ static int pushglobalfuncname (lua_State *L, lua_Debug *ar) {
8080
int top = lua_gettop(L);
8181
lua_getinfo(L, "f", ar); /* push function */
8282
lua_getfield(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE);
83+
luaL_checkstack(L, 6, "not enough stack"); /* slots for 'findfield' */
8384
if (findfield(L, top + 1, 2)) {
8485
const char *name = lua_tostring(L, -1);
8586
if (strncmp(name, LUA_GNAME ".", 3) == 0) { /* name start with '_G.'? */
@@ -249,11 +250,13 @@ LUALIB_API int luaL_fileresult (lua_State *L, int stat, const char *fname) {
249250
return 1;
250251
}
251252
else {
253+
const char *msg;
252254
luaL_pushfail(L);
255+
msg = (en != 0) ? strerror(en) : "(no extra info)";
253256
if (fname)
254-
lua_pushfstring(L, "%s: %s", fname, strerror(en));
257+
lua_pushfstring(L, "%s: %s", fname, msg);
255258
else
256-
lua_pushstring(L, strerror(en));
259+
lua_pushstring(L, msg);
257260
lua_pushinteger(L, en);
258261
return 3;
259262
}
@@ -732,9 +735,12 @@ static const char *getF (lua_State *L, void *ud, size_t *size) {
732735

733736

734737
static int errfile (lua_State *L, const char *what, int fnameindex) {
735-
const char *serr = strerror(errno);
738+
int err = errno;
736739
const char *filename = lua_tostring(L, fnameindex) + 1;
737-
lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr);
740+
if (err != 0)
741+
lua_pushfstring(L, "cannot %s %s: %s", what, filename, strerror(err));
742+
else
743+
lua_pushfstring(L, "cannot %s %s", what, filename);
738744
lua_remove(L, fnameindex);
739745
return LUA_ERRFILE;
740746
}
@@ -787,6 +793,7 @@ LUALIB_API int luaL_loadfilex (lua_State *L, const char *filename,
787793
}
788794
else {
789795
lua_pushfstring(L, "@%s", filename);
796+
errno = 0;
790797
lf.f = fopen(filename, "r");
791798
if (lf.f == NULL) return errfile(L, "open", fnameindex);
792799
}
@@ -796,13 +803,15 @@ LUALIB_API int luaL_loadfilex (lua_State *L, const char *filename,
796803
if (c == LUA_SIGNATURE[0]) { /* binary file? */
797804
lf.n = 0; /* remove possible newline */
798805
if (filename) { /* "real" file? */
806+
errno = 0;
799807
lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */
800808
if (lf.f == NULL) return errfile(L, "reopen", fnameindex);
801809
skipcomment(lf.f, &c); /* re-read initial portion */
802810
}
803811
}
804812
if (c != EOF)
805813
lf.buff[lf.n++] = c; /* 'c' is the first character of the stream */
814+
errno = 0;
806815
status = lua_load(L, getF, &lf, lua_tostring(L, -1), mode);
807816
readstatus = ferror(lf.f);
808817
if (filename) fclose(lf.f); /* close file (even in case of errors) */
@@ -933,7 +942,7 @@ LUALIB_API const char *luaL_tolstring (lua_State *L, int idx, size_t *len) {
933942
LUALIB_API void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {
934943
luaL_checkstack(L, nup, "too many upvalues");
935944
for (; l->name != NULL; l++) { /* fill the table with given functions */
936-
if (l->func == NULL) /* place holder? */
945+
if (l->func == NULL) /* placeholder? */
937946
lua_pushboolean(L, 0);
938947
else {
939948
int i;
@@ -1025,9 +1034,14 @@ static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
10251034
}
10261035

10271036

1037+
/*
1038+
** Standard panic funcion just prints an error message. The test
1039+
** with 'lua_type' avoids possible memory errors in 'lua_tostring'.
1040+
*/
10281041
static int panic (lua_State *L) {
1029-
const char *msg = lua_tostring(L, -1);
1030-
if (msg == NULL) msg = "error object is not a string";
1042+
const char *msg = (lua_type(L, -1) == LUA_TSTRING)
1043+
? lua_tostring(L, -1)
1044+
: "error object is not a string";
10311045
lua_writestringerror("PANIC: unprotected error in call to Lua API (%s)\n",
10321046
msg);
10331047
return 0; /* return to Lua to abort */

third-party/lua-5.4.6/src/lcode.c

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#define MAXREGS 255
3636

3737

38+
/* (note that expressions VJMP also have jumps.) */
3839
#define hasjumps(e) ((e)->t != (e)->f)
3940

4041

@@ -415,7 +416,7 @@ int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) {
415416
/*
416417
** Format and emit an 'iAsBx' instruction.
417418
*/
418-
int luaK_codeAsBx (FuncState *fs, OpCode o, int a, int bc) {
419+
static int codeAsBx (FuncState *fs, OpCode o, int a, int bc) {
419420
unsigned int b = bc + OFFSET_sBx;
420421
lua_assert(getOpMode(o) == iAsBx);
421422
lua_assert(a <= MAXARG_A && b <= MAXARG_Bx);
@@ -671,7 +672,7 @@ static int fitsBx (lua_Integer i) {
671672

672673
void luaK_int (FuncState *fs, int reg, lua_Integer i) {
673674
if (fitsBx(i))
674-
luaK_codeAsBx(fs, OP_LOADI, reg, cast_int(i));
675+
codeAsBx(fs, OP_LOADI, reg, cast_int(i));
675676
else
676677
luaK_codek(fs, reg, luaK_intK(fs, i));
677678
}
@@ -680,7 +681,7 @@ void luaK_int (FuncState *fs, int reg, lua_Integer i) {
680681
static void luaK_float (FuncState *fs, int reg, lua_Number f) {
681682
lua_Integer fi;
682683
if (luaV_flttointeger(f, &fi, F2Ieq) && fitsBx(fi))
683-
luaK_codeAsBx(fs, OP_LOADF, reg, cast_int(fi));
684+
codeAsBx(fs, OP_LOADF, reg, cast_int(fi));
684685
else
685686
luaK_codek(fs, reg, luaK_numberK(fs, f));
686687
}
@@ -776,7 +777,8 @@ void luaK_dischargevars (FuncState *fs, expdesc *e) {
776777
break;
777778
}
778779
case VLOCAL: { /* already in a register */
779-
e->u.info = e->u.var.ridx;
780+
int temp = e->u.var.ridx;
781+
e->u.info = temp; /* (can't do a direct assignment; values overlap) */
780782
e->k = VNONRELOC; /* becomes a non-relocatable value */
781783
break;
782784
}
@@ -984,7 +986,7 @@ void luaK_exp2anyregup (FuncState *fs, expdesc *e) {
984986
** or it is a constant.
985987
*/
986988
void luaK_exp2val (FuncState *fs, expdesc *e) {
987-
if (hasjumps(e))
989+
if (e->k == VJMP || hasjumps(e))
988990
luaK_exp2anyreg(fs, e);
989991
else
990992
luaK_dischargevars(fs, e);
@@ -1025,7 +1027,7 @@ static int luaK_exp2K (FuncState *fs, expdesc *e) {
10251027
** in the range of R/K indices).
10261028
** Returns 1 iff expression is K.
10271029
*/
1028-
int luaK_exp2RK (FuncState *fs, expdesc *e) {
1030+
static int exp2RK (FuncState *fs, expdesc *e) {
10291031
if (luaK_exp2K(fs, e))
10301032
return 1;
10311033
else { /* not a constant in the right range: put it in a register */
@@ -1037,7 +1039,7 @@ int luaK_exp2RK (FuncState *fs, expdesc *e) {
10371039

10381040
static void codeABRK (FuncState *fs, OpCode o, int a, int b,
10391041
expdesc *ec) {
1040-
int k = luaK_exp2RK(fs, ec);
1042+
int k = exp2RK(fs, ec);
10411043
luaK_codeABCk(fs, o, a, b, ec->u.info, k);
10421044
}
10431045

@@ -1215,7 +1217,7 @@ static void codenot (FuncState *fs, expdesc *e) {
12151217

12161218

12171219
/*
1218-
** Check whether expression 'e' is a small literal string
1220+
** Check whether expression 'e' is a short literal string
12191221
*/
12201222
static int isKstr (FuncState *fs, expdesc *e) {
12211223
return (e->k == VK && !hasjumps(e) && e->u.info <= MAXARG_B &&
@@ -1225,7 +1227,7 @@ static int isKstr (FuncState *fs, expdesc *e) {
12251227
/*
12261228
** Check whether expression 'e' is a literal integer.
12271229
*/
1228-
int luaK_isKint (expdesc *e) {
1230+
static int isKint (expdesc *e) {
12291231
return (e->k == VKINT && !hasjumps(e));
12301232
}
12311233

@@ -1235,7 +1237,7 @@ int luaK_isKint (expdesc *e) {
12351237
** proper range to fit in register C
12361238
*/
12371239
static int isCint (expdesc *e) {
1238-
return luaK_isKint(e) && (l_castS2U(e->u.ival) <= l_castS2U(MAXARG_C));
1240+
return isKint(e) && (l_castS2U(e->u.ival) <= l_castS2U(MAXARG_C));
12391241
}
12401242

12411243

@@ -1244,7 +1246,7 @@ static int isCint (expdesc *e) {
12441246
** proper range to fit in register sC
12451247
*/
12461248
static int isSCint (expdesc *e) {
1247-
return luaK_isKint(e) && fitsC(e->u.ival);
1249+
return isKint(e) && fitsC(e->u.ival);
12481250
}
12491251

12501252

@@ -1283,15 +1285,17 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
12831285
if (t->k == VUPVAL && !isKstr(fs, k)) /* upvalue indexed by non 'Kstr'? */
12841286
luaK_exp2anyreg(fs, t); /* put it in a register */
12851287
if (t->k == VUPVAL) {
1286-
t->u.ind.t = t->u.info; /* upvalue index */
1287-
t->u.ind.idx = k->u.info; /* literal string */
1288+
int temp = t->u.info; /* upvalue index */
1289+
lua_assert(isKstr(fs, k));
1290+
t->u.ind.t = temp; /* (can't do a direct assignment; values overlap) */
1291+
t->u.ind.idx = k->u.info; /* literal short string */
12881292
t->k = VINDEXUP;
12891293
}
12901294
else {
12911295
/* register index of the table */
12921296
t->u.ind.t = (t->k == VLOCAL) ? t->u.var.ridx: t->u.info;
12931297
if (isKstr(fs, k)) {
1294-
t->u.ind.idx = k->u.info; /* literal string */
1298+
t->u.ind.idx = k->u.info; /* literal short string */
12951299
t->k = VINDEXSTR;
12961300
}
12971301
else if (isCint(k)) {
@@ -1459,7 +1463,7 @@ static void codebinK (FuncState *fs, BinOpr opr,
14591463
*/
14601464
static int finishbinexpneg (FuncState *fs, expdesc *e1, expdesc *e2,
14611465
OpCode op, int line, TMS event) {
1462-
if (!luaK_isKint(e2))
1466+
if (!isKint(e2))
14631467
return 0; /* not an integer constant */
14641468
else {
14651469
lua_Integer i2 = e2->u.ival;
@@ -1592,7 +1596,7 @@ static void codeeq (FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2) {
15921596
op = OP_EQI;
15931597
r2 = im; /* immediate operand */
15941598
}
1595-
else if (luaK_exp2RK(fs, e2)) { /* 2nd expression is constant? */
1599+
else if (exp2RK(fs, e2)) { /* 2nd expression is constant? */
15961600
op = OP_EQK;
15971601
r2 = e2->u.info; /* constant index */
15981602
}
@@ -1658,7 +1662,7 @@ void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) {
16581662
}
16591663
case OPR_EQ: case OPR_NE: {
16601664
if (!tonumeral(v, NULL))
1661-
luaK_exp2RK(fs, v);
1665+
exp2RK(fs, v);
16621666
/* else keep numeral, which may be an immediate operand */
16631667
break;
16641668
}

third-party/lua-5.4.6/src/lcode.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,8 @@ typedef enum UnOpr { OPR_MINUS, OPR_BNOT, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr;
6161

6262
LUAI_FUNC int luaK_code (FuncState *fs, Instruction i);
6363
LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx);
64-
LUAI_FUNC int luaK_codeAsBx (FuncState *fs, OpCode o, int A, int Bx);
6564
LUAI_FUNC int luaK_codeABCk (FuncState *fs, OpCode o, int A,
6665
int B, int C, int k);
67-
LUAI_FUNC int luaK_isKint (expdesc *e);
6866
LUAI_FUNC int luaK_exp2const (FuncState *fs, const expdesc *e, TValue *v);
6967
LUAI_FUNC void luaK_fixline (FuncState *fs, int line);
7068
LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n);
@@ -76,7 +74,6 @@ LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e);
7674
LUAI_FUNC void luaK_exp2anyregup (FuncState *fs, expdesc *e);
7775
LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e);
7876
LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e);
79-
LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e);
8077
LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key);
8178
LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k);
8279
LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e);

0 commit comments

Comments
 (0)