diff --git a/radio/src/debug.h b/radio/src/debug.h index 41cdfda30..90aca3d88 100644 --- a/radio/src/debug.h +++ b/radio/src/debug.h @@ -70,8 +70,18 @@ extern "C" { #if defined(TRACE_LUA_INTERNALS_ENABLED) #define TRACE_LUA_INTERNALS(f_, ...) debugPrintf(("[LUA INT] " f_ "\r\n"), ##__VA_ARGS__) + + #define TRACE_LUA_INTERNALS_WITH_LINEINFO(L, f_, ...) do { \ + lua_Debug ar; \ + if (lua_getstack(L, 1, &ar)) { \ + lua_getinfo(L, ">Sl", &ar); \ + debugPrintf("%s:%d: ", ar.short_src, ar.currentline); \ + } \ + debugPrintf(("[LUA INT] " f_ "\r\n"), ##__VA_ARGS__); \ + } while(0) #else #define TRACE_LUA_INTERNALS(...) + #define TRACE_LUA_INTERNALS_WITH_LINEINFO(L, f_, ...) #endif #if defined(DEBUG) && !defined(SIMU) diff --git a/radio/src/thirdparty/Lua/src/lobject.h b/radio/src/thirdparty/Lua/src/lobject.h index 7e5c03ab4..919b2c304 100644 --- a/radio/src/thirdparty/Lua/src/lobject.h +++ b/radio/src/thirdparty/Lua/src/lobject.h @@ -569,7 +569,7 @@ typedef struct Node { typedef struct Table { CommonHeader; lu_byte flags; /* 1<
lsizenode)
+#define sizenode(t) (twoto((t)->lsizenode))
/*
diff --git a/radio/src/thirdparty/Lua/src/lparser.c b/radio/src/thirdparty/Lua/src/lparser.c
index d8f5b4ffc..43a8967ff 100644
--- a/radio/src/thirdparty/Lua/src/lparser.c
+++ b/radio/src/thirdparty/Lua/src/lparser.c
@@ -181,6 +181,7 @@ static void new_localvar (LexState *ls, TString *name) {
int reg = registerlocalvar(ls, name);
checklimit(fs, dyd->actvar.n + 1 - fs->firstlocal,
MAXVARS, "local variables");
+ TRACE_LUA_INTERNALS("new_localvar %s %d", getstr(name), dyd->actvar.n + 1 - fs->firstlocal);
luaM_growvector(ls->L, dyd->actvar.arr, dyd->actvar.n + 1,
dyd->actvar.size, Vardesc, MAX_INT, "local variables");
dyd->actvar.arr[dyd->actvar.n++].idx = cast(short, reg);
@@ -1529,6 +1530,7 @@ static void retstat (LexState *ls) {
static void statement (LexState *ls) {
int line = ls->linenumber; /* may be needed for error messages */
enterlevel(ls);
+ TRACE_LUA_INTERNALS("statement %02x at line %d", ls->t.token, line);
switch (ls->t.token) {
case ';': { /* stat -> ';' (empty statement) */
luaX_next(ls); /* skip ';' */
diff --git a/radio/src/thirdparty/Lua/src/ltable.c b/radio/src/thirdparty/Lua/src/ltable.c
index 6cea6e5e2..902e09fae 100644
--- a/radio/src/thirdparty/Lua/src/ltable.c
+++ b/radio/src/thirdparty/Lua/src/ltable.c
@@ -282,16 +282,14 @@ static void setnodevector (lua_State *L, Table *t, int size) {
int lsize;
if (size == 0) { /* no elements to hash part? */
t->node = cast(Node *, dummynode); /* use common `dummynode' */
- lsize = 1;
+ lsize = 0;
}
else {
int i;
- // lsize = luaO_ceillog2(size);
- // if (lsize > MAXBITS)
- // luaG_runerror(L, "table overflow");
- // size = twoto(lsize);
- // size += size/2;
- lsize = size;
+ lsize = luaO_ceillog2(size);
+ if (lsize > MAXBITS)
+ luaG_runerror(L, "table overflow");
+ size = twoto(lsize);
t->node = luaM_newvector(L, size, Node);
for (i=0; i