Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
c04f2578
Commit
c04f2578
authored
Jan 05, 2015
by
HuangRui
Browse files
Updated SDK to v0.9.5 and optimized memory.
parent
0420b6d7
Changes
78
Hide whitespace changes
Inline
Side-by-side
app/lua/linit.c
View file @
c04f2578
...
@@ -71,7 +71,7 @@ const luaR_table lua_rotable[] =
...
@@ -71,7 +71,7 @@ const luaR_table lua_rotable[] =
{
NULL
,
NULL
}
{
NULL
,
NULL
}
};
};
LUALIB_API
void
ICACHE_FLASH_ATTR
luaL_openlibs
(
lua_State
*
L
)
{
LUALIB_API
void
luaL_openlibs
(
lua_State
*
L
)
{
const
luaL_Reg
*
lib
=
lualibs
;
const
luaL_Reg
*
lib
=
lualibs
;
for
(;
lib
->
func
;
lib
++
)
{
for
(;
lib
->
func
;
lib
++
)
{
lua_pushcfunction
(
L
,
lib
->
func
);
lua_pushcfunction
(
L
,
lib
->
func
);
...
...
app/lua/liolib.c
View file @
c04f2578
...
@@ -38,7 +38,7 @@ static const int liolib_keys[] = {(int)&luaL_callmeta, (int)&luaL_typerror, (int
...
@@ -38,7 +38,7 @@ static const int liolib_keys[] = {(int)&luaL_callmeta, (int)&luaL_typerror, (int
static
const
char
*
const
fnames
[]
=
{
"input"
,
"output"
};
static
const
char
*
const
fnames
[]
=
{
"input"
,
"output"
};
static
int
ICACHE_FLASH_ATTR
pushresult
(
lua_State
*
L
,
int
i
,
const
char
*
filename
)
{
static
int
pushresult
(
lua_State
*
L
,
int
i
,
const
char
*
filename
)
{
int
en
=
fs_error
(
0
);
/* calls to Lua API may change this value */
int
en
=
fs_error
(
0
);
/* calls to Lua API may change this value */
if
(
i
)
{
if
(
i
)
{
lua_pushboolean
(
L
,
1
);
lua_pushboolean
(
L
,
1
);
...
@@ -56,7 +56,7 @@ static int ICACHE_FLASH_ATTR pushresult (lua_State *L, int i, const char *filena
...
@@ -56,7 +56,7 @@ static int ICACHE_FLASH_ATTR pushresult (lua_State *L, int i, const char *filena
}
}
static
void
ICACHE_FLASH_ATTR
fileerror
(
lua_State
*
L
,
int
arg
,
const
char
*
filename
)
{
static
void
fileerror
(
lua_State
*
L
,
int
arg
,
const
char
*
filename
)
{
lua_pushfstring
(
L
,
"%s: err(%d)"
,
filename
,
fs_error
(
0
));
lua_pushfstring
(
L
,
"%s: err(%d)"
,
filename
,
fs_error
(
0
));
luaL_argerror
(
L
,
arg
,
lua_tostring
(
L
,
-
1
));
luaL_argerror
(
L
,
arg
,
lua_tostring
(
L
,
-
1
));
}
}
...
@@ -65,7 +65,7 @@ static void ICACHE_FLASH_ATTR fileerror (lua_State *L, int arg, const char *file
...
@@ -65,7 +65,7 @@ static void ICACHE_FLASH_ATTR fileerror (lua_State *L, int arg, const char *file
#define tofilep(L) ((int *)luaL_checkudata(L, 1, LUA_FILEHANDLE))
#define tofilep(L) ((int *)luaL_checkudata(L, 1, LUA_FILEHANDLE))
static
int
ICACHE_FLASH_ATTR
io_type
(
lua_State
*
L
)
{
static
int
io_type
(
lua_State
*
L
)
{
void
*
ud
;
void
*
ud
;
luaL_checkany
(
L
,
1
);
luaL_checkany
(
L
,
1
);
ud
=
lua_touserdata
(
L
,
1
);
ud
=
lua_touserdata
(
L
,
1
);
...
@@ -80,7 +80,7 @@ static int ICACHE_FLASH_ATTR io_type (lua_State *L) {
...
@@ -80,7 +80,7 @@ static int ICACHE_FLASH_ATTR io_type (lua_State *L) {
}
}
static
int
ICACHE_FLASH_ATTR
tofile
(
lua_State
*
L
)
{
static
int
tofile
(
lua_State
*
L
)
{
int
*
f
=
tofilep
(
L
);
int
*
f
=
tofilep
(
L
);
if
(
*
f
<
FS_OPEN_OK
)
if
(
*
f
<
FS_OPEN_OK
)
luaL_error
(
L
,
"attempt to use a closed file"
);
luaL_error
(
L
,
"attempt to use a closed file"
);
...
@@ -94,7 +94,7 @@ static int ICACHE_FLASH_ATTR tofile (lua_State *L) {
...
@@ -94,7 +94,7 @@ static int ICACHE_FLASH_ATTR tofile (lua_State *L) {
** before opening the actual file; so, if there is a memory error, the
** before opening the actual file; so, if there is a memory error, the
** file is not left opened.
** file is not left opened.
*/
*/
static
int
*
ICACHE_FLASH_ATTR
newfile
(
lua_State
*
L
)
{
static
int
*
newfile
(
lua_State
*
L
)
{
int
*
pf
=
(
int
*
)
lua_newuserdata
(
L
,
sizeof
(
int
));
int
*
pf
=
(
int
*
)
lua_newuserdata
(
L
,
sizeof
(
int
));
*
pf
=
FS_OPEN_OK
-
1
;
/* file handle is currently `closed' */
*
pf
=
FS_OPEN_OK
-
1
;
/* file handle is currently `closed' */
luaL_getmetatable
(
L
,
LUA_FILEHANDLE
);
luaL_getmetatable
(
L
,
LUA_FILEHANDLE
);
...
@@ -107,7 +107,7 @@ static int *ICACHE_FLASH_ATTR newfile (lua_State *L) {
...
@@ -107,7 +107,7 @@ static int *ICACHE_FLASH_ATTR newfile (lua_State *L) {
/*
/*
** function to (not) close the standard files stdin, stdout, and stderr
** function to (not) close the standard files stdin, stdout, and stderr
*/
*/
static
int
ICACHE_FLASH_ATTR
io_noclose
(
lua_State
*
L
)
{
static
int
io_noclose
(
lua_State
*
L
)
{
lua_pushnil
(
L
);
lua_pushnil
(
L
);
lua_pushliteral
(
L
,
"cannot close standard file"
);
lua_pushliteral
(
L
,
"cannot close standard file"
);
return
2
;
return
2
;
...
@@ -117,7 +117,7 @@ static int ICACHE_FLASH_ATTR io_noclose (lua_State *L) {
...
@@ -117,7 +117,7 @@ static int ICACHE_FLASH_ATTR io_noclose (lua_State *L) {
/*
/*
** function to close 'popen' files
** function to close 'popen' files
*/
*/
static int
ICACHE_FLASH_ATTR
io_pclose (lua_State *L) {
static int io_pclose (lua_State *L) {
int *p = tofilep(L);
int *p = tofilep(L);
int ok = lua_pclose(L, *p);
int ok = lua_pclose(L, *p);
*p = FS_OPEN_OK - 1;
*p = FS_OPEN_OK - 1;
...
@@ -128,7 +128,7 @@ static int ICACHE_FLASH_ATTR io_pclose (lua_State *L) {
...
@@ -128,7 +128,7 @@ static int ICACHE_FLASH_ATTR io_pclose (lua_State *L) {
/*
/*
** function to close regular files
** function to close regular files
*/
*/
static
int
ICACHE_FLASH_ATTR
io_fclose
(
lua_State
*
L
)
{
static
int
io_fclose
(
lua_State
*
L
)
{
int
*
p
=
tofilep
(
L
);
int
*
p
=
tofilep
(
L
);
int
ok
=
(
fs_close
(
*
p
)
==
0
);
int
ok
=
(
fs_close
(
*
p
)
==
0
);
*
p
=
FS_OPEN_OK
-
1
;
*
p
=
FS_OPEN_OK
-
1
;
...
@@ -136,7 +136,7 @@ static int ICACHE_FLASH_ATTR io_fclose (lua_State *L) {
...
@@ -136,7 +136,7 @@ static int ICACHE_FLASH_ATTR io_fclose (lua_State *L) {
}
}
#endif
#endif
static
int
ICACHE_FLASH_ATTR
aux_close
(
lua_State
*
L
)
{
static
int
aux_close
(
lua_State
*
L
)
{
#if LUA_OPTIMIZE_MEMORY != 2
#if LUA_OPTIMIZE_MEMORY != 2
lua_getfenv
(
L
,
1
);
lua_getfenv
(
L
,
1
);
lua_getfield
(
L
,
-
1
,
"__close"
);
lua_getfield
(
L
,
-
1
,
"__close"
);
...
@@ -156,7 +156,7 @@ static int ICACHE_FLASH_ATTR aux_close (lua_State *L) {
...
@@ -156,7 +156,7 @@ static int ICACHE_FLASH_ATTR aux_close (lua_State *L) {
}
}
static
int
ICACHE_FLASH_ATTR
io_close
(
lua_State
*
L
)
{
static
int
io_close
(
lua_State
*
L
)
{
if
(
lua_isnone
(
L
,
1
))
if
(
lua_isnone
(
L
,
1
))
LUA_IO_GETFIELD
(
IO_OUTPUT
);
LUA_IO_GETFIELD
(
IO_OUTPUT
);
tofile
(
L
);
/* make sure argument is a file */
tofile
(
L
);
/* make sure argument is a file */
...
@@ -164,7 +164,7 @@ static int ICACHE_FLASH_ATTR io_close (lua_State *L) {
...
@@ -164,7 +164,7 @@ static int ICACHE_FLASH_ATTR io_close (lua_State *L) {
}
}
static
int
ICACHE_FLASH_ATTR
io_gc
(
lua_State
*
L
)
{
static
int
io_gc
(
lua_State
*
L
)
{
int
f
=
*
tofilep
(
L
);
int
f
=
*
tofilep
(
L
);
/* ignore closed files */
/* ignore closed files */
if
(
f
!=
FS_OPEN_OK
-
1
)
if
(
f
!=
FS_OPEN_OK
-
1
)
...
@@ -173,7 +173,7 @@ static int ICACHE_FLASH_ATTR io_gc (lua_State *L) {
...
@@ -173,7 +173,7 @@ static int ICACHE_FLASH_ATTR io_gc (lua_State *L) {
}
}
static
int
ICACHE_FLASH_ATTR
io_tostring
(
lua_State
*
L
)
{
static
int
io_tostring
(
lua_State
*
L
)
{
int
f
=
*
tofilep
(
L
);
int
f
=
*
tofilep
(
L
);
if
(
f
==
FS_OPEN_OK
-
1
)
if
(
f
==
FS_OPEN_OK
-
1
)
lua_pushliteral
(
L
,
"file (closed)"
);
lua_pushliteral
(
L
,
"file (closed)"
);
...
@@ -183,7 +183,7 @@ static int ICACHE_FLASH_ATTR io_tostring (lua_State *L) {
...
@@ -183,7 +183,7 @@ static int ICACHE_FLASH_ATTR io_tostring (lua_State *L) {
}
}
static
int
ICACHE_FLASH_ATTR
io_open
(
lua_State
*
L
)
{
static
int
io_open
(
lua_State
*
L
)
{
const
char
*
filename
=
luaL_checkstring
(
L
,
1
);
const
char
*
filename
=
luaL_checkstring
(
L
,
1
);
const
char
*
mode
=
luaL_optstring
(
L
,
2
,
"r"
);
const
char
*
mode
=
luaL_optstring
(
L
,
2
,
"r"
);
int
*
pf
=
newfile
(
L
);
int
*
pf
=
newfile
(
L
);
...
@@ -197,7 +197,7 @@ static int ICACHE_FLASH_ATTR io_open (lua_State *L) {
...
@@ -197,7 +197,7 @@ static int ICACHE_FLASH_ATTR io_open (lua_State *L) {
** correct __close for 'popen' files
** correct __close for 'popen' files
*/
*/
#if 0
#if 0
static int
ICACHE_FLASH_ATTR
io_popen (lua_State *L) {
static int io_popen (lua_State *L) {
const char *filename = luaL_checkstring(L, 1);
const char *filename = luaL_checkstring(L, 1);
const char *mode = luaL_optstring(L, 2, "r");
const char *mode = luaL_optstring(L, 2, "r");
int *pf = newfile(L);
int *pf = newfile(L);
...
@@ -206,14 +206,14 @@ static int ICACHE_FLASH_ATTR io_popen (lua_State *L) {
...
@@ -206,14 +206,14 @@ static int ICACHE_FLASH_ATTR io_popen (lua_State *L) {
}
}
static int
ICACHE_FLASH_ATTR
io_tmpfile (lua_State *L) {
static int io_tmpfile (lua_State *L) {
int *pf = newfile(L);
int *pf = newfile(L);
*pf = tmpfile();
*pf = tmpfile();
return (*pf == FS_OPEN_OK - 1) ? pushresult(L, 0, NULL) : 1;
return (*pf == FS_OPEN_OK - 1) ? pushresult(L, 0, NULL) : 1;
}
}
#endif
#endif
static
int
ICACHE_FLASH_ATTR
getiofile
(
lua_State
*
L
,
int
findex
)
{
static
int
getiofile
(
lua_State
*
L
,
int
findex
)
{
int
*
pf
;
int
*
pf
;
LUA_IO_GETFIELD
(
findex
);
LUA_IO_GETFIELD
(
findex
);
pf
=
(
int
*
)
lua_touserdata
(
L
,
-
1
);
pf
=
(
int
*
)
lua_touserdata
(
L
,
-
1
);
...
@@ -225,7 +225,7 @@ static int ICACHE_FLASH_ATTR getiofile (lua_State *L, int findex) {
...
@@ -225,7 +225,7 @@ static int ICACHE_FLASH_ATTR getiofile (lua_State *L, int findex) {
}
}
static
int
ICACHE_FLASH_ATTR
g_iofile
(
lua_State
*
L
,
int
f
,
const
char
*
mode
)
{
static
int
g_iofile
(
lua_State
*
L
,
int
f
,
const
char
*
mode
)
{
if
(
!
lua_isnoneornil
(
L
,
1
))
{
if
(
!
lua_isnoneornil
(
L
,
1
))
{
const
char
*
filename
=
lua_tostring
(
L
,
1
);
const
char
*
filename
=
lua_tostring
(
L
,
1
);
if
(
filename
)
{
if
(
filename
)
{
...
@@ -246,34 +246,34 @@ static int ICACHE_FLASH_ATTR g_iofile (lua_State *L, int f, const char *mode) {
...
@@ -246,34 +246,34 @@ static int ICACHE_FLASH_ATTR g_iofile (lua_State *L, int f, const char *mode) {
}
}
static
int
ICACHE_FLASH_ATTR
io_input
(
lua_State
*
L
)
{
static
int
io_input
(
lua_State
*
L
)
{
return
g_iofile
(
L
,
IO_INPUT
,
"r"
);
return
g_iofile
(
L
,
IO_INPUT
,
"r"
);
}
}
static
int
ICACHE_FLASH_ATTR
io_output
(
lua_State
*
L
)
{
static
int
io_output
(
lua_State
*
L
)
{
return
g_iofile
(
L
,
IO_OUTPUT
,
"w"
);
return
g_iofile
(
L
,
IO_OUTPUT
,
"w"
);
}
}
static
int
ICACHE_FLASH_ATTR
io_readline
(
lua_State
*
L
);
static
int
io_readline
(
lua_State
*
L
);
static
void
ICACHE_FLASH_ATTR
aux_lines
(
lua_State
*
L
,
int
idx
,
int
toclose
)
{
static
void
aux_lines
(
lua_State
*
L
,
int
idx
,
int
toclose
)
{
lua_pushvalue
(
L
,
idx
);
lua_pushvalue
(
L
,
idx
);
lua_pushboolean
(
L
,
toclose
);
/* close/not close file when finished */
lua_pushboolean
(
L
,
toclose
);
/* close/not close file when finished */
lua_pushcclosure
(
L
,
io_readline
,
2
);
lua_pushcclosure
(
L
,
io_readline
,
2
);
}
}
static
int
ICACHE_FLASH_ATTR
f_lines
(
lua_State
*
L
)
{
static
int
f_lines
(
lua_State
*
L
)
{
tofile
(
L
);
/* check that it's a valid file handle */
tofile
(
L
);
/* check that it's a valid file handle */
aux_lines
(
L
,
1
,
0
);
aux_lines
(
L
,
1
,
0
);
return
1
;
return
1
;
}
}
static
int
ICACHE_FLASH_ATTR
io_lines
(
lua_State
*
L
)
{
static
int
io_lines
(
lua_State
*
L
)
{
if
(
lua_isnoneornil
(
L
,
1
))
{
/* no arguments? */
if
(
lua_isnoneornil
(
L
,
1
))
{
/* no arguments? */
/* will iterate over default input */
/* will iterate over default input */
LUA_IO_GETFIELD
(
IO_INPUT
);
LUA_IO_GETFIELD
(
IO_INPUT
);
...
@@ -298,7 +298,7 @@ static int ICACHE_FLASH_ATTR io_lines (lua_State *L) {
...
@@ -298,7 +298,7 @@ static int ICACHE_FLASH_ATTR io_lines (lua_State *L) {
*/
*/
#if 0
#if 0
static int
ICACHE_FLASH_ATTR
read_number (lua_State *L, int f) {
static int read_number (lua_State *L, int f) {
lua_Number d;
lua_Number d;
if (fs_scanf(f, LUA_NUMBER_SCAN, &d) == 1) {
if (fs_scanf(f, LUA_NUMBER_SCAN, &d) == 1) {
lua_pushnumber(L, d);
lua_pushnumber(L, d);
...
@@ -311,7 +311,7 @@ static int ICACHE_FLASH_ATTR read_number (lua_State *L, int f) {
...
@@ -311,7 +311,7 @@ static int ICACHE_FLASH_ATTR read_number (lua_State *L, int f) {
}
}
#endif
#endif
static
int
ICACHE_FLASH_ATTR
test_eof
(
lua_State
*
L
,
int
f
)
{
static
int
test_eof
(
lua_State
*
L
,
int
f
)
{
int
c
=
fs_getc
(
f
);
int
c
=
fs_getc
(
f
);
fs_ungetc
(
c
,
f
);
fs_ungetc
(
c
,
f
);
lua_pushlstring
(
L
,
NULL
,
0
);
lua_pushlstring
(
L
,
NULL
,
0
);
...
@@ -319,7 +319,7 @@ static int ICACHE_FLASH_ATTR test_eof (lua_State *L, int f) {
...
@@ -319,7 +319,7 @@ static int ICACHE_FLASH_ATTR test_eof (lua_State *L, int f) {
}
}
#if 0
#if 0
static int
ICACHE_FLASH_ATTR
read_line (lua_State *L, int f) {
static int read_line (lua_State *L, int f) {
luaL_Buffer b;
luaL_Buffer b;
luaL_buffinit(L, &b);
luaL_buffinit(L, &b);
for (;;) {
for (;;) {
...
@@ -340,7 +340,7 @@ static int ICACHE_FLASH_ATTR read_line (lua_State *L, int f) {
...
@@ -340,7 +340,7 @@ static int ICACHE_FLASH_ATTR read_line (lua_State *L, int f) {
}
}
}
}
#else
#else
static
int
ICACHE_FLASH_ATTR
read_line
(
lua_State
*
L
,
int
f
)
{
static
int
read_line
(
lua_State
*
L
,
int
f
)
{
luaL_Buffer
b
;
luaL_Buffer
b
;
luaL_buffinit
(
L
,
&
b
);
luaL_buffinit
(
L
,
&
b
);
char
*
p
=
luaL_prepbuffer
(
&
b
);
char
*
p
=
luaL_prepbuffer
(
&
b
);
...
@@ -368,7 +368,7 @@ static int ICACHE_FLASH_ATTR read_line (lua_State *L, int f) {
...
@@ -368,7 +368,7 @@ static int ICACHE_FLASH_ATTR read_line (lua_State *L, int f) {
}
}
#endif
#endif
static
int
ICACHE_FLASH_ATTR
read_chars
(
lua_State
*
L
,
int
f
,
size_t
n
)
{
static
int
read_chars
(
lua_State
*
L
,
int
f
,
size_t
n
)
{
size_t
rlen
;
/* how much to read */
size_t
rlen
;
/* how much to read */
size_t
nr
;
/* number of chars actually read */
size_t
nr
;
/* number of chars actually read */
luaL_Buffer
b
;
luaL_Buffer
b
;
...
@@ -386,7 +386,7 @@ static int ICACHE_FLASH_ATTR read_chars (lua_State *L, int f, size_t n) {
...
@@ -386,7 +386,7 @@ static int ICACHE_FLASH_ATTR read_chars (lua_State *L, int f, size_t n) {
}
}
static
int
ICACHE_FLASH_ATTR
g_read
(
lua_State
*
L
,
int
f
,
int
first
)
{
static
int
g_read
(
lua_State
*
L
,
int
f
,
int
first
)
{
int
nargs
=
lua_gettop
(
L
)
-
1
;
int
nargs
=
lua_gettop
(
L
)
-
1
;
int
success
;
int
success
;
int
n
;
int
n
;
...
@@ -435,17 +435,17 @@ static int ICACHE_FLASH_ATTR g_read (lua_State *L, int f, int first) {
...
@@ -435,17 +435,17 @@ static int ICACHE_FLASH_ATTR g_read (lua_State *L, int f, int first) {
}
}
static
int
ICACHE_FLASH_ATTR
io_read
(
lua_State
*
L
)
{
static
int
io_read
(
lua_State
*
L
)
{
return
g_read
(
L
,
getiofile
(
L
,
IO_INPUT
),
1
);
return
g_read
(
L
,
getiofile
(
L
,
IO_INPUT
),
1
);
}
}
static
int
ICACHE_FLASH_ATTR
f_read
(
lua_State
*
L
)
{
static
int
f_read
(
lua_State
*
L
)
{
return
g_read
(
L
,
tofile
(
L
),
2
);
return
g_read
(
L
,
tofile
(
L
),
2
);
}
}
static
int
ICACHE_FLASH_ATTR
io_readline
(
lua_State
*
L
)
{
static
int
io_readline
(
lua_State
*
L
)
{
int
*
pf
=
(
int
*
)
lua_touserdata
(
L
,
lua_upvalueindex
(
1
));
int
*
pf
=
(
int
*
)
lua_touserdata
(
L
,
lua_upvalueindex
(
1
));
int
sucess
;
int
sucess
;
if
(
pf
==
NULL
||
*
pf
==
FS_OPEN_OK
-
1
){
/* file is already closed? */
if
(
pf
==
NULL
||
*
pf
==
FS_OPEN_OK
-
1
){
/* file is already closed? */
...
@@ -469,7 +469,7 @@ static int ICACHE_FLASH_ATTR io_readline (lua_State *L) {
...
@@ -469,7 +469,7 @@ static int ICACHE_FLASH_ATTR io_readline (lua_State *L) {
/* }====================================================== */
/* }====================================================== */
static
int
ICACHE_FLASH_ATTR
g_write
(
lua_State
*
L
,
int
f
,
int
arg
)
{
static
int
g_write
(
lua_State
*
L
,
int
f
,
int
arg
)
{
int
nargs
=
lua_gettop
(
L
)
-
1
;
int
nargs
=
lua_gettop
(
L
)
-
1
;
int
status
=
1
;
int
status
=
1
;
for
(;
nargs
--
;
arg
++
)
{
for
(;
nargs
--
;
arg
++
)
{
...
@@ -491,17 +491,17 @@ static int ICACHE_FLASH_ATTR g_write (lua_State *L, int f, int arg) {
...
@@ -491,17 +491,17 @@ static int ICACHE_FLASH_ATTR g_write (lua_State *L, int f, int arg) {
}
}
static
int
ICACHE_FLASH_ATTR
io_write
(
lua_State
*
L
)
{
static
int
io_write
(
lua_State
*
L
)
{
return
g_write
(
L
,
getiofile
(
L
,
IO_OUTPUT
),
1
);
return
g_write
(
L
,
getiofile
(
L
,
IO_OUTPUT
),
1
);
}
}
static
int
ICACHE_FLASH_ATTR
f_write
(
lua_State
*
L
)
{
static
int
f_write
(
lua_State
*
L
)
{
return
g_write
(
L
,
tofile
(
L
),
2
);
return
g_write
(
L
,
tofile
(
L
),
2
);
}
}
static
int
ICACHE_FLASH_ATTR
f_seek
(
lua_State
*
L
)
{
static
int
f_seek
(
lua_State
*
L
)
{
static
const
int
mode
[]
=
{
FS_SEEK_SET
,
FS_SEEK_CUR
,
FS_SEEK_END
};
static
const
int
mode
[]
=
{
FS_SEEK_SET
,
FS_SEEK_CUR
,
FS_SEEK_END
};
static
const
char
*
const
modenames
[]
=
{
"set"
,
"cur"
,
"end"
,
NULL
};
static
const
char
*
const
modenames
[]
=
{
"set"
,
"cur"
,
"end"
,
NULL
};
int
f
=
tofile
(
L
);
int
f
=
tofile
(
L
);
...
@@ -517,7 +517,7 @@ static int ICACHE_FLASH_ATTR f_seek (lua_State *L) {
...
@@ -517,7 +517,7 @@ static int ICACHE_FLASH_ATTR f_seek (lua_State *L) {
}
}
#if 0
#if 0
static int
ICACHE_FLASH_ATTR
f_setvbuf (lua_State *L) {
static int f_setvbuf (lua_State *L) {
static const int mode[] = {_IONBF, _IOFBF, _IOLBF};
static const int mode[] = {_IONBF, _IOFBF, _IOLBF};
static const char *const modenames[] = {"no", "full", "line", NULL};
static const char *const modenames[] = {"no", "full", "line", NULL};
int f = tofile(L);
int f = tofile(L);
...
@@ -529,12 +529,12 @@ static int ICACHE_FLASH_ATTR f_setvbuf (lua_State *L) {
...
@@ -529,12 +529,12 @@ static int ICACHE_FLASH_ATTR f_setvbuf (lua_State *L) {
#endif
#endif
static
int
ICACHE_FLASH_ATTR
io_flush
(
lua_State
*
L
)
{
static
int
io_flush
(
lua_State
*
L
)
{
return
pushresult
(
L
,
fs_flush
(
getiofile
(
L
,
IO_OUTPUT
))
==
0
,
NULL
);
return
pushresult
(
L
,
fs_flush
(
getiofile
(
L
,
IO_OUTPUT
))
==
0
,
NULL
);
}
}
static
int
ICACHE_FLASH_ATTR
f_flush
(
lua_State
*
L
)
{
static
int
f_flush
(
lua_State
*
L
)
{
return
pushresult
(
L
,
fs_flush
(
tofile
(
L
))
==
0
,
NULL
);
return
pushresult
(
L
,
fs_flush
(
tofile
(
L
))
==
0
,
NULL
);
}
}
...
@@ -560,7 +560,7 @@ const LUA_REG_TYPE iolib[] = {
...
@@ -560,7 +560,7 @@ const LUA_REG_TYPE iolib[] = {
};
};
#if LUA_OPTIMIZE_MEMORY == 2
#if LUA_OPTIMIZE_MEMORY == 2
static
int
ICACHE_FLASH_ATTR
luaL_index
(
lua_State
*
L
)
static
int
luaL_index
(
lua_State
*
L
)
{
{
return
luaR_findfunction
(
L
,
iolib_funcs
);
return
luaR_findfunction
(
L
,
iolib_funcs
);
}
}
...
@@ -590,7 +590,7 @@ const LUA_REG_TYPE flib[] = {
...
@@ -590,7 +590,7 @@ const LUA_REG_TYPE flib[] = {
{
LNILKEY
,
LNILVAL
}
{
LNILKEY
,
LNILVAL
}
};
};
static
void
ICACHE_FLASH_ATTR
createmeta
(
lua_State
*
L
)
{
static
void
createmeta
(
lua_State
*
L
)
{
#if LUA_OPTIMIZE_MEMORY == 0
#if LUA_OPTIMIZE_MEMORY == 0
luaL_newmetatable
(
L
,
LUA_FILEHANDLE
);
/* create metatable for file handles */
luaL_newmetatable
(
L
,
LUA_FILEHANDLE
);
/* create metatable for file handles */
lua_pushvalue
(
L
,
-
1
);
/* push metatable */
lua_pushvalue
(
L
,
-
1
);
/* push metatable */
...
@@ -602,7 +602,7 @@ static void ICACHE_FLASH_ATTR createmeta (lua_State *L) {
...
@@ -602,7 +602,7 @@ static void ICACHE_FLASH_ATTR createmeta (lua_State *L) {
}
}
static
void
ICACHE_FLASH_ATTR
createstdfile
(
lua_State
*
L
,
int
f
,
int
k
,
const
char
*
fname
)
{
static
void
createstdfile
(
lua_State
*
L
,
int
f
,
int
k
,
const
char
*
fname
)
{
*
newfile
(
L
)
=
f
;
*
newfile
(
L
)
=
f
;
#if LUA_OPTIMIZE_MEMORY != 2
#if LUA_OPTIMIZE_MEMORY != 2
if
(
k
>
0
)
{
if
(
k
>
0
)
{
...
@@ -620,14 +620,14 @@ static void ICACHE_FLASH_ATTR createstdfile (lua_State *L, int f, int k, const c
...
@@ -620,14 +620,14 @@ static void ICACHE_FLASH_ATTR createstdfile (lua_State *L, int f, int k, const c
}
}
#if LUA_OPTIMIZE_MEMORY != 2
#if LUA_OPTIMIZE_MEMORY != 2
static
void
ICACHE_FLASH_ATTR
newfenv
(
lua_State
*
L
,
lua_CFunction
cls
)
{
static
void
newfenv
(
lua_State
*
L
,
lua_CFunction
cls
)
{
lua_createtable
(
L
,
0
,
1
);
lua_createtable
(
L
,
0
,
1
);
lua_pushcfunction
(
L
,
cls
);
lua_pushcfunction
(
L
,
cls
);
lua_setfield
(
L
,
-
2
,
"__close"
);
lua_setfield
(
L
,
-
2
,
"__close"
);
}
}
#endif
#endif
LUALIB_API
int
ICACHE_FLASH_ATTR
luaopen_io
(
lua_State
*
L
)
{
LUALIB_API
int
luaopen_io
(
lua_State
*
L
)
{
createmeta
(
L
);
createmeta
(
L
);
#if LUA_OPTIMIZE_MEMORY != 2
#if LUA_OPTIMIZE_MEMORY != 2
/* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */
/* create (private) environment (with fields IO_INPUT, IO_OUTPUT, __close) */
...
...
app/lua/llex.c
View file @
c04f2578
...
@@ -48,7 +48,7 @@ const char *const luaX_tokens [] = {
...
@@ -48,7 +48,7 @@ const char *const luaX_tokens [] = {
#define save_and_next(ls) (save(ls, ls->current), next(ls))
#define save_and_next(ls) (save(ls, ls->current), next(ls))
static
void
ICACHE_FLASH_ATTR
save
(
LexState
*
ls
,
int
c
)
{
static
void
save
(
LexState
*
ls
,
int
c
)
{
Mbuffer
*
b
=
ls
->
buff
;
Mbuffer
*
b
=
ls
->
buff
;
if
(
b
->
n
+
1
>
b
->
buffsize
)
{
if
(
b
->
n
+
1
>
b
->
buffsize
)
{
size_t
newsize
;
size_t
newsize
;
...
@@ -61,14 +61,14 @@ static void ICACHE_FLASH_ATTR save (LexState *ls, int c) {
...
@@ -61,14 +61,14 @@ static void ICACHE_FLASH_ATTR save (LexState *ls, int c) {
}
}
void
ICACHE_FLASH_ATTR
luaX_init
(
lua_State
*
L
)
{
void
luaX_init
(
lua_State
*
L
)
{
}
}
#define MAXSRC 80
#define MAXSRC 80
const
char
*
ICACHE_FLASH_ATTR
luaX_token2str
(
LexState
*
ls
,
int
token
)
{
const
char
*
luaX_token2str
(
LexState
*
ls
,
int
token
)
{
if
(
token
<
FIRST_RESERVED
)
{
if
(
token
<
FIRST_RESERVED
)
{
lua_assert
(
token
==
cast
(
unsigned
char
,
token
));
lua_assert
(
token
==
cast
(
unsigned
char
,
token
));
return
(
iscntrl
(
token
))
?
luaO_pushfstring
(
ls
->
L
,
"char(%d)"
,
token
)
:
return
(
iscntrl
(
token
))
?
luaO_pushfstring
(
ls
->
L
,
"char(%d)"
,
token
)
:
...
@@ -79,7 +79,7 @@ const char *ICACHE_FLASH_ATTR luaX_token2str (LexState *ls, int token) {
...
@@ -79,7 +79,7 @@ const char *ICACHE_FLASH_ATTR luaX_token2str (LexState *ls, int token) {
}
}
static
const
char
*
ICACHE_FLASH_ATTR
txtToken
(
LexState
*
ls
,
int
token
)
{
static
const
char
*
txtToken
(
LexState
*
ls
,
int
token
)
{
switch
(
token
)
{
switch
(
token
)
{
case
TK_NAME
:
case
TK_NAME
:
case
TK_STRING
:
case
TK_STRING
:
...
@@ -92,7 +92,7 @@ static const char *ICACHE_FLASH_ATTR txtToken (LexState *ls, int token) {
...
@@ -92,7 +92,7 @@ static const char *ICACHE_FLASH_ATTR txtToken (LexState *ls, int token) {
}
}
void
ICACHE_FLASH_ATTR
luaX_lexerror
(
LexState
*
ls
,
const
char
*
msg
,
int
token
)
{
void
luaX_lexerror
(
LexState
*
ls
,
const
char
*
msg
,
int
token
)
{
char
buff
[
MAXSRC
];
char
buff
[
MAXSRC
];
luaO_chunkid
(
buff
,
getstr
(
ls
->
source
),
MAXSRC
);
luaO_chunkid
(
buff
,
getstr
(
ls
->
source
),
MAXSRC
);
msg
=
luaO_pushfstring
(
ls
->
L
,
"%s:%d: %s"
,
buff
,
ls
->
linenumber
,
msg
);
msg
=
luaO_pushfstring
(
ls
->
L
,
"%s:%d: %s"
,
buff
,
ls
->
linenumber
,
msg
);
...
@@ -102,12 +102,12 @@ void ICACHE_FLASH_ATTR luaX_lexerror (LexState *ls, const char *msg, int token)
...
@@ -102,12 +102,12 @@ void ICACHE_FLASH_ATTR luaX_lexerror (LexState *ls, const char *msg, int token)
}
}
void
ICACHE_FLASH_ATTR
luaX_syntaxerror
(
LexState
*
ls
,
const
char
*
msg
)
{
void
luaX_syntaxerror
(
LexState
*
ls
,
const
char
*
msg
)
{
luaX_lexerror
(
ls
,
msg
,
ls
->
t
.
token
);
luaX_lexerror
(
ls
,
msg
,
ls
->
t
.
token
);
}
}
TString
*
ICACHE_FLASH_ATTR
luaX_newstring
(
LexState
*
ls
,
const
char
*
str
,
size_t
l
)
{
TString
*
luaX_newstring
(
LexState
*
ls
,
const
char
*
str
,
size_t
l
)
{
lua_State
*
L
=
ls
->
L
;
lua_State
*
L
=
ls
->
L
;
TString
*
ts
=
luaS_newlstr
(
L
,
str
,
l
);
TString
*
ts
=
luaS_newlstr
(
L
,
str
,
l
);
TValue
*
o
=
luaH_setstr
(
L
,
ls
->
fs
->
h
,
ts
);
/* entry for `str' */
TValue
*
o
=
luaH_setstr
(
L
,
ls
->
fs
->
h
,
ts
);
/* entry for `str' */
...
@@ -119,7 +119,7 @@ TString *ICACHE_FLASH_ATTR luaX_newstring (LexState *ls, const char *str, size_t
...
@@ -119,7 +119,7 @@ TString *ICACHE_FLASH_ATTR luaX_newstring (LexState *ls, const char *str, size_t
}
}
static
void
ICACHE_FLASH_ATTR
inclinenumber
(
LexState
*
ls
)
{
static
void
inclinenumber
(
LexState
*
ls
)
{
int
old
=
ls
->
current
;
int
old
=
ls
->
current
;
lua_assert
(
currIsNewline
(
ls
));
lua_assert
(
currIsNewline
(
ls
));
next
(
ls
);
/* skip `\n' or `\r' */
next
(
ls
);
/* skip `\n' or `\r' */
...
@@ -130,7 +130,7 @@ static void ICACHE_FLASH_ATTR inclinenumber (LexState *ls) {
...
@@ -130,7 +130,7 @@ static void ICACHE_FLASH_ATTR inclinenumber (LexState *ls) {
}
}
void
ICACHE_FLASH_ATTR
luaX_setinput
(
lua_State
*
L
,
LexState
*
ls
,
ZIO
*
z
,
TString
*
source
)
{
void
luaX_setinput
(
lua_State
*
L
,
LexState
*
ls
,
ZIO
*
z
,
TString
*
source
)
{
ls
->
decpoint
=
'.'
;
ls
->
decpoint
=
'.'
;
ls
->
L
=
L
;
ls
->
L
=
L
;
ls
->
lookahead
.
token
=
TK_EOS
;
/* no look-ahead token */
ls
->
lookahead
.
token
=
TK_EOS
;
/* no look-ahead token */
...
@@ -153,7 +153,7 @@ void ICACHE_FLASH_ATTR luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TStrin
...
@@ -153,7 +153,7 @@ void ICACHE_FLASH_ATTR luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TStrin
static
int
ICACHE_FLASH_ATTR
check_next
(
LexState
*
ls
,
const
char
*
set
)
{
static
int
check_next
(
LexState
*
ls
,
const
char
*
set
)
{
if
(
!
c_strchr
(
set
,
ls
->
current
))
if
(
!
c_strchr
(
set
,
ls
->
current
))
return
0
;
return
0
;
save_and_next
(
ls
);
save_and_next
(
ls
);
...
@@ -161,7 +161,7 @@ static int ICACHE_FLASH_ATTR check_next (LexState *ls, const char *set) {
...
@@ -161,7 +161,7 @@ static int ICACHE_FLASH_ATTR check_next (LexState *ls, const char *set) {
}
}
static
void
ICACHE_FLASH_ATTR
buffreplace
(
LexState
*
ls
,
char
from
,
char
to
)
{
static
void
buffreplace
(
LexState
*
ls
,
char
from
,
char
to
)
{
size_t
n
=
luaZ_bufflen
(
ls
->
buff
);
size_t
n
=
luaZ_bufflen
(
ls
->
buff
);
char
*
p
=
luaZ_buffer
(
ls
->
buff
);
char
*
p
=
luaZ_buffer
(
ls
->
buff
);
while
(
n
--
)
while
(
n
--
)
...
@@ -169,7 +169,7 @@ static void ICACHE_FLASH_ATTR buffreplace (LexState *ls, char from, char to) {
...
@@ -169,7 +169,7 @@ static void ICACHE_FLASH_ATTR buffreplace (LexState *ls, char from, char to) {
}
}
static
void
ICACHE_FLASH_ATTR
trydecpoint
(
LexState
*
ls
,
SemInfo
*
seminfo
)
{
static
void
trydecpoint
(
LexState
*
ls
,
SemInfo
*
seminfo
)
{
/* format error: try to update decimal point separator */
/* format error: try to update decimal point separator */
struct
lconv
*
cv
=
localeconv
();
struct
lconv
*
cv
=
localeconv
();
char
old
=
ls
->
decpoint
;
char
old
=
ls
->
decpoint
;
...
@@ -184,7 +184,7 @@ static void ICACHE_FLASH_ATTR trydecpoint (LexState *ls, SemInfo *seminfo) {
...
@@ -184,7 +184,7 @@ static void ICACHE_FLASH_ATTR trydecpoint (LexState *ls, SemInfo *seminfo) {
/* LUA_NUMBER */
/* LUA_NUMBER */
static
void
ICACHE_FLASH_ATTR
read_numeral
(
LexState
*
ls
,
SemInfo
*
seminfo
)
{
static
void
read_numeral
(
LexState
*
ls
,
SemInfo
*
seminfo
)
{
lua_assert
(
isdigit
(
ls
->
current
));
lua_assert
(
isdigit
(
ls
->
current
));
do
{
do
{
save_and_next
(
ls
);
save_and_next
(
ls
);
...
@@ -200,7 +200,7 @@ static void ICACHE_FLASH_ATTR read_numeral (LexState *ls, SemInfo *seminfo) {
...
@@ -200,7 +200,7 @@ static void ICACHE_FLASH_ATTR read_numeral (LexState *ls, SemInfo *seminfo) {
}
}
static
int
ICACHE_FLASH_ATTR
skip_sep
(
LexState
*
ls
)
{
static
int
skip_sep
(
LexState
*
ls
)
{
int
count
=
0
;
int
count
=
0
;
int
s
=
ls
->
current
;
int
s
=
ls
->
current
;
lua_assert
(
s
==
'['
||
s
==
']'
);
lua_assert
(
s
==
'['
||
s
==
']'
);
...
@@ -213,7 +213,7 @@ static int ICACHE_FLASH_ATTR skip_sep (LexState *ls) {
...
@@ -213,7 +213,7 @@ static int ICACHE_FLASH_ATTR skip_sep (LexState *ls) {
}
}
static
void
ICACHE_FLASH_ATTR
read_long_string
(
LexState
*
ls
,
SemInfo
*
seminfo
,
int
sep
)
{
static
void
read_long_string
(
LexState
*
ls
,
SemInfo
*
seminfo
,
int
sep
)
{
int
cont
=
0
;
int
cont
=
0
;
(
void
)(
cont
);
/* avoid warnings when `cont' is not used */
(
void
)(
cont
);
/* avoid warnings when `cont' is not used */
save_and_next
(
ls
);
/* skip 2nd `[' */
save_and_next
(
ls
);
/* skip 2nd `[' */
...
@@ -268,7 +268,7 @@ static void ICACHE_FLASH_ATTR read_long_string (LexState *ls, SemInfo *seminfo,
...
@@ -268,7 +268,7 @@ static void ICACHE_FLASH_ATTR read_long_string (LexState *ls, SemInfo *seminfo,
}
}
static
void
ICACHE_FLASH_ATTR
read_string
(
LexState
*
ls
,
int
del
,
SemInfo
*
seminfo
)
{
static
void
read_string
(
LexState
*
ls
,
int
del
,
SemInfo
*
seminfo
)
{
save_and_next
(
ls
);
save_and_next
(
ls
);
while
(
ls
->
current
!=
del
)
{
while
(
ls
->
current
!=
del
)
{
switch
(
ls
->
current
)
{
switch
(
ls
->
current
)
{
...
@@ -324,7 +324,7 @@ static void ICACHE_FLASH_ATTR read_string (LexState *ls, int del, SemInfo *semin
...
@@ -324,7 +324,7 @@ static void ICACHE_FLASH_ATTR read_string (LexState *ls, int del, SemInfo *semin
}
}
static
int
ICACHE_FLASH_ATTR
llex
(
LexState
*
ls
,
SemInfo
*
seminfo
)
{
static
int
llex
(
LexState
*
ls
,
SemInfo
*
seminfo
)
{
luaZ_resetbuffer
(
ls
->
buff
);
luaZ_resetbuffer
(
ls
->
buff
);
for
(;;)
{
for
(;;)
{
switch
(
ls
->
current
)
{
switch
(
ls
->
current
)
{
...
@@ -440,7 +440,7 @@ static int ICACHE_FLASH_ATTR llex (LexState *ls, SemInfo *seminfo) {
...
@@ -440,7 +440,7 @@ static int ICACHE_FLASH_ATTR llex (LexState *ls, SemInfo *seminfo) {
}
}
void
ICACHE_FLASH_ATTR
luaX_next
(
LexState
*
ls
)
{
void
luaX_next
(
LexState
*
ls
)
{
ls
->
lastline
=
ls
->
linenumber
;
ls
->
lastline
=
ls
->
linenumber
;
if
(
ls
->
lookahead
.
token
!=
TK_EOS
)
{
/* is there a look-ahead token? */
if
(
ls
->
lookahead
.
token
!=
TK_EOS
)
{
/* is there a look-ahead token? */
ls
->
t
=
ls
->
lookahead
;
/* use this one */
ls
->
t
=
ls
->
lookahead
;
/* use this one */
...
@@ -451,7 +451,7 @@ void ICACHE_FLASH_ATTR luaX_next (LexState *ls) {
...
@@ -451,7 +451,7 @@ void ICACHE_FLASH_ATTR luaX_next (LexState *ls) {
}
}
void
ICACHE_FLASH_ATTR
luaX_lookahead
(
LexState
*
ls
)
{
void
luaX_lookahead
(
LexState
*
ls
)
{
lua_assert
(
ls
->
lookahead
.
token
==
TK_EOS
);
lua_assert
(
ls
->
lookahead
.
token
==
TK_EOS
);
ls
->
lookahead
.
token
=
llex
(
ls
,
&
ls
->
lookahead
.
seminfo
);
ls
->
lookahead
.
token
=
llex
(
ls
,
&
ls
->
lookahead
.
seminfo
);
}
}
...
...
app/lua/lmathlib.c
View file @
c04f2578
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
static
int
ICACHE_FLASH_ATTR
math_abs
(
lua_State
*
L
)
{
static
int
math_abs
(
lua_State
*
L
)
{
#ifdef LUA_NUMBER_INTEGRAL
#ifdef LUA_NUMBER_INTEGRAL
lua_Number
x
=
luaL_checknumber
(
L
,
1
);
lua_Number
x
=
luaL_checknumber
(
L
,
1
);
if
(
x
<
0
)
x
=
-
x
;
//fails for -2^31
if
(
x
<
0
)
x
=
-
x
;
//fails for -2^31
...
@@ -36,72 +36,72 @@ static int ICACHE_FLASH_ATTR math_abs (lua_State *L) {
...
@@ -36,72 +36,72 @@ static int ICACHE_FLASH_ATTR math_abs (lua_State *L) {
#ifndef LUA_NUMBER_INTEGRAL
#ifndef LUA_NUMBER_INTEGRAL
static
int
ICACHE_FLASH_ATTR
math_sin
(
lua_State
*
L
)
{
static
int
math_sin
(
lua_State
*
L
)
{
lua_pushnumber
(
L
,
sin
(
luaL_checknumber
(
L
,
1
)));
lua_pushnumber
(
L
,
sin
(
luaL_checknumber
(
L
,
1
)));
return
1
;
return
1
;
}
}
static
int
ICACHE_FLASH_ATTR
math_sinh
(
lua_State
*
L
)
{
static
int
math_sinh
(
lua_State
*
L
)
{
lua_pushnumber
(
L
,
sinh
(
luaL_checknumber
(
L
,
1
)));
lua_pushnumber
(
L
,
sinh
(
luaL_checknumber
(
L
,
1
)));
return
1
;
return
1
;
}
}
static
int
ICACHE_FLASH_ATTR
math_cos
(
lua_State
*
L
)
{
static
int
math_cos
(
lua_State
*
L
)
{
lua_pushnumber
(
L
,
cos
(
luaL_checknumber
(
L
,
1
)));
lua_pushnumber
(
L
,
cos
(
luaL_checknumber
(
L
,
1
)));
return
1
;
return
1
;
}
}
static
int
ICACHE_FLASH_ATTR
math_cosh
(
lua_State
*
L
)
{
static
int
math_cosh
(
lua_State
*
L
)
{
lua_pushnumber
(
L
,
cosh
(
luaL_checknumber
(
L
,
1
)));
lua_pushnumber
(
L
,
cosh
(
luaL_checknumber
(
L
,
1
)));
return
1
;
return
1
;
}
}
static
int
ICACHE_FLASH_ATTR
math_tan
(
lua_State
*
L
)
{
static
int
math_tan
(
lua_State
*
L
)
{
lua_pushnumber
(
L
,
tan
(
luaL_checknumber
(
L
,
1
)));
lua_pushnumber
(
L
,
tan
(
luaL_checknumber
(
L
,
1
)));
return
1
;
return
1
;
}
}
static
int
ICACHE_FLASH_ATTR
math_tanh
(
lua_State
*
L
)
{
static
int
math_tanh
(
lua_State
*
L
)
{
lua_pushnumber
(
L
,
tanh
(
luaL_checknumber
(
L
,
1
)));
lua_pushnumber
(
L
,
tanh
(
luaL_checknumber
(
L
,
1
)));
return
1
;
return
1
;
}
}
static
int
ICACHE_FLASH_ATTR
math_asin
(
lua_State
*
L
)
{
static
int
math_asin
(
lua_State
*
L
)
{
lua_pushnumber
(
L
,
asin
(
luaL_checknumber
(
L
,
1
)));
lua_pushnumber
(
L
,
asin
(
luaL_checknumber
(
L
,
1
)));
return
1
;
return
1
;
}
}
static
int
ICACHE_FLASH_ATTR
math_acos
(
lua_State
*
L
)
{
static
int
math_acos
(
lua_State
*
L
)
{
lua_pushnumber
(
L
,
acos
(
luaL_checknumber
(
L
,
1
)));
lua_pushnumber
(
L
,
acos
(
luaL_checknumber
(
L
,
1
)));
return
1
;
return
1
;
}
}
static
int
ICACHE_FLASH_ATTR
math_atan
(
lua_State
*
L
)
{
static
int
math_atan
(
lua_State
*
L
)
{
lua_pushnumber
(
L
,
atan
(
luaL_checknumber
(
L
,
1
)));
lua_pushnumber
(
L
,
atan
(
luaL_checknumber
(
L
,
1
)));
return
1
;
return
1
;
}
}
static
int
ICACHE_FLASH_ATTR
math_atan2
(
lua_State
*
L
)
{
static
int
math_atan2
(
lua_State
*
L
)
{
lua_pushnumber
(
L
,
atan2
(
luaL_checknumber
(
L
,
1
),
luaL_checknumber
(
L
,
2
)));
lua_pushnumber
(
L
,
atan2
(
luaL_checknumber
(
L
,
1
),
luaL_checknumber
(
L
,
2
)));
return
1
;
return
1
;
}
}
static
int
ICACHE_FLASH_ATTR
math_ceil
(
lua_State
*
L
)
{
static
int
math_ceil
(
lua_State
*
L
)
{
lua_pushnumber
(
L
,
ceil
(
luaL_checknumber
(
L
,
1
)));
lua_pushnumber
(
L
,
ceil
(
luaL_checknumber
(
L
,
1
)));
return
1
;
return
1
;
}
}
static
int
ICACHE_FLASH_ATTR
math_floor
(
lua_State
*
L
)
{
static
int
math_floor
(
lua_State
*
L
)
{
lua_pushnumber
(
L
,
floor
(
luaL_checknumber
(
L
,
1
)));
lua_pushnumber
(
L
,
floor
(
luaL_checknumber
(
L
,
1
)));
return
1
;
return
1
;
}
}
static
int
ICACHE_FLASH_ATTR
math_fmod
(
lua_State
*
L
)
{
static
int
math_fmod
(
lua_State
*
L
)
{
lua_pushnumber
(
L
,
fmod
(
luaL_checknumber
(
L
,
1
),
luaL_checknumber
(
L
,
2
)));
lua_pushnumber
(
L
,
fmod
(
luaL_checknumber
(
L
,
1
),
luaL_checknumber
(
L
,
2
)));
return
1
;
return
1
;
}
}
static
int
ICACHE_FLASH_ATTR
math_modf
(
lua_State
*
L
)
{
static
int
math_modf
(
lua_State
*
L
)
{
double
ip
;
double
ip
;
double
fp
=
modf
(
luaL_checknumber
(
L
,
1
),
&
ip
);
double
fp
=
modf
(
luaL_checknumber
(
L
,
1
),
&
ip
);
lua_pushnumber
(
L
,
ip
);
lua_pushnumber
(
L
,
ip
);
...
@@ -116,7 +116,7 @@ static int ICACHE_FLASH_ATTR math_modf (lua_State *L) {
...
@@ -116,7 +116,7 @@ static int ICACHE_FLASH_ATTR math_modf (lua_State *L) {
// works in both integer and floating point versions of Lua.
// works in both integer and floating point versions of Lua.
// This identity function is used for them.
// This identity function is used for them.
static
int
ICACHE_FLASH_ATTR
math_identity
(
lua_State
*
L
)
{
static
int
math_identity
(
lua_State
*
L
)
{
lua_pushnumber
(
L
,
luaL_checknumber
(
L
,
1
));
lua_pushnumber
(
L
,
luaL_checknumber
(
L
,
1
));
return
1
;
return
1
;
}
}
...
@@ -125,7 +125,7 @@ static int ICACHE_FLASH_ATTR math_identity (lua_State *L) {
...
@@ -125,7 +125,7 @@ static int ICACHE_FLASH_ATTR math_identity (lua_State *L) {
#ifdef LUA_NUMBER_INTEGRAL
#ifdef LUA_NUMBER_INTEGRAL
// Integer square root for integer version
// Integer square root for integer version
static
lua_Number
ICACHE_FLASH_ATTR
isqrt
(
lua_Number
x
)
static
lua_Number
isqrt
(
lua_Number
x
)
{
{
lua_Number
op
,
res
,
one
;
lua_Number
op
,
res
,
one
;
...
@@ -147,7 +147,7 @@ static lua_Number ICACHE_FLASH_ATTR isqrt(lua_Number x)
...
@@ -147,7 +147,7 @@ static lua_Number ICACHE_FLASH_ATTR isqrt(lua_Number x)
}
}
#endif
#endif
static
int
ICACHE_FLASH_ATTR
math_sqrt
(
lua_State
*
L
)
{
static
int
math_sqrt
(
lua_State
*
L
)
{
#ifdef LUA_NUMBER_INTEGRAL
#ifdef LUA_NUMBER_INTEGRAL
lua_Number
x
=
luaL_checknumber
(
L
,
1
);
lua_Number
x
=
luaL_checknumber
(
L
,
1
);
luaL_argcheck
(
L
,
0
<=
x
,
1
,
"negative"
);
luaL_argcheck
(
L
,
0
<=
x
,
1
,
"negative"
);
...
@@ -162,7 +162,7 @@ static int ICACHE_FLASH_ATTR math_sqrt (lua_State *L) {
...
@@ -162,7 +162,7 @@ static int ICACHE_FLASH_ATTR math_sqrt (lua_State *L) {
# define pow(a,b) luai_ipow(a,b)
# define pow(a,b) luai_ipow(a,b)
#endif
#endif
static
int
ICACHE_FLASH_ATTR
math_pow
(
lua_State
*
L
)
{
static
int
math_pow
(
lua_State
*
L
)
{
lua_pushnumber
(
L
,
pow
(
luaL_checknumber
(
L
,
1
),
luaL_checknumber
(
L
,
2
)));
lua_pushnumber
(
L
,
pow
(
luaL_checknumber
(
L
,
1
),
luaL_checknumber
(
L
,
2
)));
return
1
;
return
1
;
}
}
...
@@ -174,46 +174,46 @@ static int ICACHE_FLASH_ATTR math_pow (lua_State *L) {
...
@@ -174,46 +174,46 @@ static int ICACHE_FLASH_ATTR math_pow (lua_State *L) {
#ifndef LUA_NUMBER_INTEGRAL
#ifndef LUA_NUMBER_INTEGRAL
static
int
ICACHE_FLASH_ATTR
math_log
(
lua_State
*
L
)
{
static
int
math_log
(
lua_State
*
L
)
{
lua_pushnumber
(
L
,
log
(
luaL_checknumber
(
L
,
1
)));
lua_pushnumber
(
L
,
log
(
luaL_checknumber
(
L
,
1
)));
return
1
;
return
1
;
}
}
static
int
ICACHE_FLASH_ATTR
math_log10
(
lua_State
*
L
)
{
static
int
math_log10
(
lua_State
*
L
)
{
lua_pushnumber
(
L
,
log10
(
luaL_checknumber
(
L
,
1
)));
lua_pushnumber
(
L
,
log10
(
luaL_checknumber
(
L
,
1
)));
return
1
;
return
1
;
}
}
static
int
ICACHE_FLASH_ATTR
math_exp
(
lua_State
*
L
)
{
static
int
math_exp
(
lua_State
*
L
)
{
lua_pushnumber
(
L
,
exp
(
luaL_checknumber
(
L
,
1
)));
lua_pushnumber
(
L
,
exp
(
luaL_checknumber
(
L
,
1
)));
return
1
;
return
1
;
}
}
static
int
ICACHE_FLASH_ATTR
math_deg
(
lua_State
*
L
)
{
static
int
math_deg
(
lua_State
*
L
)
{
lua_pushnumber
(
L
,
luaL_checknumber
(
L
,
1
)
/
RADIANS_PER_DEGREE
);
lua_pushnumber
(
L
,
luaL_checknumber
(
L
,
1
)
/
RADIANS_PER_DEGREE
);
return
1
;
return
1
;
}
}
static
int
ICACHE_FLASH_ATTR
math_rad
(
lua_State
*
L
)
{
static
int
math_rad
(
lua_State
*
L
)
{
lua_pushnumber
(
L
,
luaL_checknumber
(
L
,
1
)
*
RADIANS_PER_DEGREE
);
lua_pushnumber
(
L
,
luaL_checknumber
(
L
,
1
)
*
RADIANS_PER_DEGREE
);
return
1
;
return
1
;
}
}
static
int
ICACHE_FLASH_ATTR
math_frexp
(
lua_State
*
L
)
{
static
int
math_frexp
(
lua_State
*
L
)
{
int
e
;
int
e
;
lua_pushnumber
(
L
,
frexp
(
luaL_checknumber
(
L
,
1
),
&
e
));
lua_pushnumber
(
L
,
frexp
(
luaL_checknumber
(
L
,
1
),
&
e
));
lua_pushinteger
(
L
,
e
);
lua_pushinteger
(
L
,
e
);
return
2
;
return
2
;
}
}
static
int
ICACHE_FLASH_ATTR
math_ldexp
(
lua_State
*
L
)
{
static
int
math_ldexp
(
lua_State
*
L
)
{
lua_pushnumber
(
L
,
ldexp
(
luaL_checknumber
(
L
,
1
),
luaL_checkint
(
L
,
2
)));
lua_pushnumber
(
L
,
ldexp
(
luaL_checknumber
(
L
,
1
),
luaL_checkint
(
L
,
2
)));
return
1
;
return
1
;
}
}
#endif // #ifdef LUA_NUMBER_INTEGRAL
#endif // #ifdef LUA_NUMBER_INTEGRAL
static
int
ICACHE_FLASH_ATTR
math_min
(
lua_State
*
L
)
{
static
int
math_min
(
lua_State
*
L
)
{
int
n
=
lua_gettop
(
L
);
/* number of arguments */
int
n
=
lua_gettop
(
L
);
/* number of arguments */
lua_Number
dmin
=
luaL_checknumber
(
L
,
1
);
lua_Number
dmin
=
luaL_checknumber
(
L
,
1
);
int
i
;
int
i
;
...
@@ -227,7 +227,7 @@ static int ICACHE_FLASH_ATTR math_min (lua_State *L) {
...
@@ -227,7 +227,7 @@ static int ICACHE_FLASH_ATTR math_min (lua_State *L) {
}
}
static
int
ICACHE_FLASH_ATTR
math_max
(
lua_State
*
L
)
{
static
int
math_max
(
lua_State
*
L
)
{
int
n
=
lua_gettop
(
L
);
/* number of arguments */
int
n
=
lua_gettop
(
L
);
/* number of arguments */
lua_Number
dmax
=
luaL_checknumber
(
L
,
1
);
lua_Number
dmax
=
luaL_checknumber
(
L
,
1
);
int
i
;
int
i
;
...
@@ -243,7 +243,7 @@ static int ICACHE_FLASH_ATTR math_max (lua_State *L) {
...
@@ -243,7 +243,7 @@ static int ICACHE_FLASH_ATTR math_max (lua_State *L) {
#ifdef LUA_NUMBER_INTEGRAL
#ifdef LUA_NUMBER_INTEGRAL
static
int
ICACHE_FLASH_ATTR
math_random
(
lua_State
*
L
)
{
static
int
math_random
(
lua_State
*
L
)
{
lua_Number
r
=
(
lua_Number
)(
rand
()
%
RAND_MAX
);
lua_Number
r
=
(
lua_Number
)(
rand
()
%
RAND_MAX
);
switch
(
lua_gettop
(
L
))
{
/* check number of arguments */
switch
(
lua_gettop
(
L
))
{
/* check number of arguments */
...
@@ -271,7 +271,7 @@ static int ICACHE_FLASH_ATTR math_random (lua_State *L) {
...
@@ -271,7 +271,7 @@ static int ICACHE_FLASH_ATTR math_random (lua_State *L) {
#else
#else
static
int
ICACHE_FLASH_ATTR
math_random
(
lua_State
*
L
)
{
static
int
math_random
(
lua_State
*
L
)
{
/* the `%' avoids the (rare) case of r==1, and is needed also because on
/* the `%' avoids the (rare) case of r==1, and is needed also because on
some systems (SunOS!) `rand()' may return a value larger than RAND_MAX */
some systems (SunOS!) `rand()' may return a value larger than RAND_MAX */
lua_Number
r
=
(
lua_Number
)(
rand
()
%
RAND_MAX
)
/
(
lua_Number
)
RAND_MAX
;
lua_Number
r
=
(
lua_Number
)(
rand
()
%
RAND_MAX
)
/
(
lua_Number
)
RAND_MAX
;
...
@@ -301,7 +301,7 @@ static int ICACHE_FLASH_ATTR math_random (lua_State *L) {
...
@@ -301,7 +301,7 @@ static int ICACHE_FLASH_ATTR math_random (lua_State *L) {
#endif
#endif
static
int
ICACHE_FLASH_ATTR
math_randomseed
(
lua_State
*
L
)
{
static
int
math_randomseed
(
lua_State
*
L
)
{
srand
(
luaL_checkint
(
L
,
1
));
srand
(
luaL_checkint
(
L
,
1
));
return
0
;
return
0
;
}
}
...
@@ -371,7 +371,7 @@ const LUA_REG_TYPE math_map[] = {
...
@@ -371,7 +371,7 @@ const LUA_REG_TYPE math_map[] = {
# include "c_limits.h"
/* for LONG_MAX */
# include "c_limits.h"
/* for LONG_MAX */
#endif
#endif
LUALIB_API
int
ICACHE_FLASH_ATTR
luaopen_math
(
lua_State
*
L
)
{
LUALIB_API
int
luaopen_math
(
lua_State
*
L
)
{
#if LUA_OPTIMIZE_MEMORY > 0
#if LUA_OPTIMIZE_MEMORY > 0
return
0
;
return
0
;
#else
#else
...
...
app/lua/lmem.c
View file @
c04f2578
...
@@ -43,7 +43,7 @@
...
@@ -43,7 +43,7 @@
#define MINSIZEARRAY 4
#define MINSIZEARRAY 4
void
*
ICACHE_FLASH_ATTR
luaM_growaux_
(
lua_State
*
L
,
void
*
block
,
int
*
size
,
size_t
size_elems
,
void
*
luaM_growaux_
(
lua_State
*
L
,
void
*
block
,
int
*
size
,
size_t
size_elems
,
int
limit
,
const
char
*
errormsg
)
{
int
limit
,
const
char
*
errormsg
)
{
void
*
newblock
;
void
*
newblock
;
int
newsize
;
int
newsize
;
...
@@ -63,7 +63,7 @@ void *ICACHE_FLASH_ATTR luaM_growaux_ (lua_State *L, void *block, int *size, siz
...
@@ -63,7 +63,7 @@ void *ICACHE_FLASH_ATTR luaM_growaux_ (lua_State *L, void *block, int *size, siz
}
}
void
*
ICACHE_FLASH_ATTR
luaM_toobig
(
lua_State
*
L
)
{
void
*
luaM_toobig
(
lua_State
*
L
)
{
luaG_runerror
(
L
,
"memory allocation error: block too big"
);
luaG_runerror
(
L
,
"memory allocation error: block too big"
);
return
NULL
;
/* to avoid warnings */
return
NULL
;
/* to avoid warnings */
}
}
...
@@ -73,7 +73,7 @@ void *ICACHE_FLASH_ATTR luaM_toobig (lua_State *L) {
...
@@ -73,7 +73,7 @@ void *ICACHE_FLASH_ATTR luaM_toobig (lua_State *L) {
/*
/*
** generic allocation routine.
** generic allocation routine.
*/
*/
void
*
ICACHE_FLASH_ATTR
luaM_realloc_
(
lua_State
*
L
,
void
*
block
,
size_t
osize
,
size_t
nsize
)
{
void
*
luaM_realloc_
(
lua_State
*
L
,
void
*
block
,
size_t
osize
,
size_t
nsize
)
{
global_State
*
g
=
G
(
L
);
global_State
*
g
=
G
(
L
);
lua_assert
((
osize
==
0
)
==
(
block
==
NULL
));
lua_assert
((
osize
==
0
)
==
(
block
==
NULL
));
block
=
(
*
g
->
frealloc
)(
g
->
ud
,
block
,
osize
,
nsize
);
block
=
(
*
g
->
frealloc
)(
g
->
ud
,
block
,
osize
,
nsize
);
...
...
app/lua/loadlib.c
View file @
c04f2578
...
@@ -237,19 +237,19 @@ static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
...
@@ -237,19 +237,19 @@ static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
#define DLMSG "dynamic libraries not enabled; check your Lua installation"
#define DLMSG "dynamic libraries not enabled; check your Lua installation"
static
void
ICACHE_FLASH_ATTR
ll_unloadlib
(
void
*
lib
)
{
static
void
ll_unloadlib
(
void
*
lib
)
{
(
void
)
lib
;
/* to avoid warnings */
(
void
)
lib
;
/* to avoid warnings */
}
}
static
void
*
ICACHE_FLASH_ATTR
ll_load
(
lua_State
*
L
,
const
char
*
path
)
{
static
void
*
ll_load
(
lua_State
*
L
,
const
char
*
path
)
{
(
void
)
path
;
/* to avoid warnings */
(
void
)
path
;
/* to avoid warnings */
lua_pushliteral
(
L
,
DLMSG
);
lua_pushliteral
(
L
,
DLMSG
);
return
NULL
;
return
NULL
;
}
}
static
lua_CFunction
ICACHE_FLASH_ATTR
ll_sym
(
lua_State
*
L
,
void
*
lib
,
const
char
*
sym
)
{
static
lua_CFunction
ll_sym
(
lua_State
*
L
,
void
*
lib
,
const
char
*
sym
)
{
(
void
)
lib
;
(
void
)
sym
;
/* to avoid warnings */
(
void
)
lib
;
(
void
)
sym
;
/* to avoid warnings */
lua_pushliteral
(
L
,
DLMSG
);
lua_pushliteral
(
L
,
DLMSG
);
return
NULL
;
return
NULL
;
...
@@ -260,7 +260,7 @@ static lua_CFunction ICACHE_FLASH_ATTR ll_sym (lua_State *L, void *lib, const ch
...
@@ -260,7 +260,7 @@ static lua_CFunction ICACHE_FLASH_ATTR ll_sym (lua_State *L, void *lib, const ch
static
void
**
ICACHE_FLASH_ATTR
ll_register
(
lua_State
*
L
,
const
char
*
path
)
{
static
void
**
ll_register
(
lua_State
*
L
,
const
char
*
path
)
{
void
**
plib
;
void
**
plib
;
lua_pushfstring
(
L
,
"%s%s"
,
LIBPREFIX
,
path
);
lua_pushfstring
(
L
,
"%s%s"
,
LIBPREFIX
,
path
);
lua_gettable
(
L
,
LUA_REGISTRYINDEX
);
/* check library in registry? */
lua_gettable
(
L
,
LUA_REGISTRYINDEX
);
/* check library in registry? */
...
@@ -284,7 +284,7 @@ static void ** ICACHE_FLASH_ATTR ll_register (lua_State *L, const char *path) {
...
@@ -284,7 +284,7 @@ static void ** ICACHE_FLASH_ATTR ll_register (lua_State *L, const char *path) {
** __gc tag method: calls library's `ll_unloadlib' function with the lib
** __gc tag method: calls library's `ll_unloadlib' function with the lib
** handle
** handle
*/
*/
static
int
ICACHE_FLASH_ATTR
gctm
(
lua_State
*
L
)
{
static
int
gctm
(
lua_State
*
L
)
{
void
**
lib
=
(
void
**
)
luaL_checkudata
(
L
,
1
,
"_LOADLIB"
);
void
**
lib
=
(
void
**
)
luaL_checkudata
(
L
,
1
,
"_LOADLIB"
);
if
(
*
lib
)
ll_unloadlib
(
*
lib
);
if
(
*
lib
)
ll_unloadlib
(
*
lib
);
*
lib
=
NULL
;
/* mark library as closed */
*
lib
=
NULL
;
/* mark library as closed */
...
@@ -292,7 +292,7 @@ static int ICACHE_FLASH_ATTR gctm (lua_State *L) {
...
@@ -292,7 +292,7 @@ static int ICACHE_FLASH_ATTR gctm (lua_State *L) {
}
}
static
int
ICACHE_FLASH_ATTR
ll_loadfunc
(
lua_State
*
L
,
const
char
*
path
,
const
char
*
sym
)
{
static
int
ll_loadfunc
(
lua_State
*
L
,
const
char
*
path
,
const
char
*
sym
)
{
void
**
reg
=
ll_register
(
L
,
path
);
void
**
reg
=
ll_register
(
L
,
path
);
if
(
*
reg
==
NULL
)
*
reg
=
ll_load
(
L
,
path
);
if
(
*
reg
==
NULL
)
*
reg
=
ll_load
(
L
,
path
);
if
(
*
reg
==
NULL
)
if
(
*
reg
==
NULL
)
...
@@ -307,7 +307,7 @@ static int ICACHE_FLASH_ATTR ll_loadfunc (lua_State *L, const char *path, const
...
@@ -307,7 +307,7 @@ static int ICACHE_FLASH_ATTR ll_loadfunc (lua_State *L, const char *path, const
}
}
static
int
ICACHE_FLASH_ATTR
ll_loadlib
(
lua_State
*
L
)
{
static
int
ll_loadlib
(
lua_State
*
L
)
{
const
char
*
path
=
luaL_checkstring
(
L
,
1
);
const
char
*
path
=
luaL_checkstring
(
L
,
1
);
const
char
*
init
=
luaL_checkstring
(
L
,
2
);
const
char
*
init
=
luaL_checkstring
(
L
,
2
);
int
stat
=
ll_loadfunc
(
L
,
path
,
init
);
int
stat
=
ll_loadfunc
(
L
,
path
,
init
);
...
@@ -336,7 +336,7 @@ static int readable (const char *filename) {
...
@@ -336,7 +336,7 @@ static int readable (const char *filename) {
return 1;
return 1;
}
}
#else
#else
static
int
ICACHE_FLASH_ATTR
readable
(
const
char
*
filename
)
{
static
int
readable
(
const
char
*
filename
)
{
int
f
=
fs_open
(
filename
,
FS_RDONLY
);
/* try to open file */
int
f
=
fs_open
(
filename
,
FS_RDONLY
);
/* try to open file */
if
(
f
<
FS_OPEN_OK
)
return
0
;
/* open failed */
if
(
f
<
FS_OPEN_OK
)
return
0
;
/* open failed */
fs_close
(
f
);
fs_close
(
f
);
...
@@ -344,7 +344,7 @@ static int ICACHE_FLASH_ATTR readable (const char *filename) {
...
@@ -344,7 +344,7 @@ static int ICACHE_FLASH_ATTR readable (const char *filename) {
}
}
#endif
#endif
static
const
char
*
ICACHE_FLASH_ATTR
pushnexttemplate
(
lua_State
*
L
,
const
char
*
path
)
{
static
const
char
*
pushnexttemplate
(
lua_State
*
L
,
const
char
*
path
)
{
const
char
*
l
;
const
char
*
l
;
while
(
*
path
==
*
LUA_PATHSEP
)
path
++
;
/* skip separators */
while
(
*
path
==
*
LUA_PATHSEP
)
path
++
;
/* skip separators */
if
(
*
path
==
'\0'
)
return
NULL
;
/* no more templates */
if
(
*
path
==
'\0'
)
return
NULL
;
/* no more templates */
...
@@ -355,7 +355,7 @@ static const char * ICACHE_FLASH_ATTR pushnexttemplate (lua_State *L, const char
...
@@ -355,7 +355,7 @@ static const char * ICACHE_FLASH_ATTR pushnexttemplate (lua_State *L, const char
}
}
static
const
char
*
ICACHE_FLASH_ATTR
findfile
(
lua_State
*
L
,
const
char
*
name
,
static
const
char
*
findfile
(
lua_State
*
L
,
const
char
*
name
,
const
char
*
pname
)
{
const
char
*
pname
)
{
const
char
*
path
;
const
char
*
path
;
name
=
luaL_gsub
(
L
,
name
,
"."
,
LUA_DIRSEP
);
name
=
luaL_gsub
(
L
,
name
,
"."
,
LUA_DIRSEP
);
...
@@ -378,13 +378,13 @@ static const char * ICACHE_FLASH_ATTR findfile (lua_State *L, const char *name,
...
@@ -378,13 +378,13 @@ static const char * ICACHE_FLASH_ATTR findfile (lua_State *L, const char *name,
}
}
static
void
ICACHE_FLASH_ATTR
loaderror
(
lua_State
*
L
,
const
char
*
filename
)
{
static
void
loaderror
(
lua_State
*
L
,
const
char
*
filename
)
{
luaL_error
(
L
,
"error loading module "
LUA_QS
" from file "
LUA_QS
":
\n\t
%s"
,
luaL_error
(
L
,
"error loading module "
LUA_QS
" from file "
LUA_QS
":
\n\t
%s"
,
lua_tostring
(
L
,
1
),
filename
,
lua_tostring
(
L
,
-
1
));
lua_tostring
(
L
,
1
),
filename
,
lua_tostring
(
L
,
-
1
));
}
}
static
int
ICACHE_FLASH_ATTR
loader_Lua
(
lua_State
*
L
)
{
static
int
loader_Lua
(
lua_State
*
L
)
{
const
char
*
filename
;
const
char
*
filename
;
const
char
*
name
=
luaL_checkstring
(
L
,
1
);
const
char
*
name
=
luaL_checkstring
(
L
,
1
);
filename
=
findfile
(
L
,
name
,
"path"
);
filename
=
findfile
(
L
,
name
,
"path"
);
...
@@ -410,7 +410,7 @@ static const char *mkfuncname (lua_State *L, const char *modname) {
...
@@ -410,7 +410,7 @@ static const char *mkfuncname (lua_State *L, const char *modname) {
}
}
static
int
ICACHE_FLASH_ATTR
loader_C
(
lua_State
*
L
)
{
static
int
loader_C
(
lua_State
*
L
)
{
const
char
*
funcname
;
const
char
*
funcname
;
const
char
*
name
=
luaL_checkstring
(
L
,
1
);
const
char
*
name
=
luaL_checkstring
(
L
,
1
);
const
char
*
filename
=
findfile
(
L
,
name
,
"cpath"
);
const
char
*
filename
=
findfile
(
L
,
name
,
"cpath"
);
...
@@ -422,7 +422,7 @@ static int ICACHE_FLASH_ATTR loader_C (lua_State *L) {
...
@@ -422,7 +422,7 @@ static int ICACHE_FLASH_ATTR loader_C (lua_State *L) {
}
}
static
int
ICACHE_FLASH_ATTR
loader_Croot
(
lua_State
*
L
)
{
static
int
loader_Croot
(
lua_State
*
L
)
{
const
char
*
funcname
;
const
char
*
funcname
;
const
char
*
filename
;
const
char
*
filename
;
const
char
*
name
=
luaL_checkstring
(
L
,
1
);
const
char
*
name
=
luaL_checkstring
(
L
,
1
);
...
@@ -443,7 +443,7 @@ static int ICACHE_FLASH_ATTR loader_Croot (lua_State *L) {
...
@@ -443,7 +443,7 @@ static int ICACHE_FLASH_ATTR loader_Croot (lua_State *L) {
}
}
static
int
ICACHE_FLASH_ATTR
loader_preload
(
lua_State
*
L
)
{
static
int
loader_preload
(
lua_State
*
L
)
{
const
char
*
name
=
luaL_checkstring
(
L
,
1
);
const
char
*
name
=
luaL_checkstring
(
L
,
1
);
lua_getfield
(
L
,
LUA_ENVIRONINDEX
,
"preload"
);
lua_getfield
(
L
,
LUA_ENVIRONINDEX
,
"preload"
);
if
(
!
lua_istable
(
L
,
-
1
))
if
(
!
lua_istable
(
L
,
-
1
))
...
@@ -459,7 +459,7 @@ static const int sentinel_ = 0;
...
@@ -459,7 +459,7 @@ static const int sentinel_ = 0;
#define sentinel ((void *)&sentinel_)
#define sentinel ((void *)&sentinel_)
static
int
ICACHE_FLASH_ATTR
ll_require
(
lua_State
*
L
)
{
static
int
ll_require
(
lua_State
*
L
)
{
const
char
*
name
=
luaL_checkstring
(
L
,
1
);
const
char
*
name
=
luaL_checkstring
(
L
,
1
);
int
i
;
int
i
;
lua_settop
(
L
,
1
);
/* _LOADED table will be at index 2 */
lua_settop
(
L
,
1
);
/* _LOADED table will be at index 2 */
...
@@ -521,7 +521,7 @@ static int ICACHE_FLASH_ATTR ll_require (lua_State *L) {
...
@@ -521,7 +521,7 @@ static int ICACHE_FLASH_ATTR ll_require (lua_State *L) {
*/
*/
static
void
ICACHE_FLASH_ATTR
setfenv
(
lua_State
*
L
)
{
static
void
setfenv
(
lua_State
*
L
)
{
lua_Debug
ar
;
lua_Debug
ar
;
if
(
lua_getstack
(
L
,
1
,
&
ar
)
==
0
||
if
(
lua_getstack
(
L
,
1
,
&
ar
)
==
0
||
lua_getinfo
(
L
,
"f"
,
&
ar
)
==
0
||
/* get calling function */
lua_getinfo
(
L
,
"f"
,
&
ar
)
==
0
||
/* get calling function */
...
@@ -533,7 +533,7 @@ static void ICACHE_FLASH_ATTR setfenv (lua_State *L) {
...
@@ -533,7 +533,7 @@ static void ICACHE_FLASH_ATTR setfenv (lua_State *L) {
}
}
static
void
ICACHE_FLASH_ATTR
dooptions
(
lua_State
*
L
,
int
n
)
{
static
void
dooptions
(
lua_State
*
L
,
int
n
)
{
int
i
;
int
i
;
for
(
i
=
2
;
i
<=
n
;
i
++
)
{
for
(
i
=
2
;
i
<=
n
;
i
++
)
{
lua_pushvalue
(
L
,
i
);
/* get option (a function) */
lua_pushvalue
(
L
,
i
);
/* get option (a function) */
...
@@ -543,7 +543,7 @@ static void ICACHE_FLASH_ATTR dooptions (lua_State *L, int n) {
...
@@ -543,7 +543,7 @@ static void ICACHE_FLASH_ATTR dooptions (lua_State *L, int n) {
}
}
static
void
ICACHE_FLASH_ATTR
modinit
(
lua_State
*
L
,
const
char
*
modname
)
{
static
void
modinit
(
lua_State
*
L
,
const
char
*
modname
)
{
const
char
*
dot
;
const
char
*
dot
;
lua_pushvalue
(
L
,
-
1
);
lua_pushvalue
(
L
,
-
1
);
lua_setfield
(
L
,
-
2
,
"_M"
);
/* module._M = module */
lua_setfield
(
L
,
-
2
,
"_M"
);
/* module._M = module */
...
@@ -558,7 +558,7 @@ static void ICACHE_FLASH_ATTR modinit (lua_State *L, const char *modname) {
...
@@ -558,7 +558,7 @@ static void ICACHE_FLASH_ATTR modinit (lua_State *L, const char *modname) {
}
}
static
int
ICACHE_FLASH_ATTR
ll_module
(
lua_State
*
L
)
{
static
int
ll_module
(
lua_State
*
L
)
{
const
char
*
modname
=
luaL_checkstring
(
L
,
1
);
const
char
*
modname
=
luaL_checkstring
(
L
,
1
);
if
(
luaR_findglobal
(
modname
,
c_strlen
(
modname
)))
if
(
luaR_findglobal
(
modname
,
c_strlen
(
modname
)))
return
0
;
return
0
;
...
@@ -608,7 +608,7 @@ static int ll_seeall (lua_State *L) {
...
@@ -608,7 +608,7 @@ static int ll_seeall (lua_State *L) {
/* auxiliary mark (for internal use) */
/* auxiliary mark (for internal use) */
#define AUXMARK "\1"
#define AUXMARK "\1"
static
void
ICACHE_FLASH_ATTR
setpath
(
lua_State
*
L
,
const
char
*
fieldname
,
const
char
*
envname
,
static
void
setpath
(
lua_State
*
L
,
const
char
*
fieldname
,
const
char
*
envname
,
const
char
*
def
)
{
const
char
*
def
)
{
const
char
*
path
=
c_getenv
(
envname
);
const
char
*
path
=
c_getenv
(
envname
);
if
(
path
==
NULL
)
/* no environment variable? */
if
(
path
==
NULL
)
/* no environment variable? */
...
@@ -643,13 +643,15 @@ static const lua_CFunction loaders[] =
...
@@ -643,13 +643,15 @@ static const lua_CFunction loaders[] =
{
loader_preload
,
loader_Lua
,
loader_C
,
loader_Croot
,
NULL
};
{
loader_preload
,
loader_Lua
,
loader_C
,
loader_Croot
,
NULL
};
#if LUA_OPTIMIZE_MEMORY > 0
#if LUA_OPTIMIZE_MEMORY > 0
const
luaR_entry
lmt
[]
=
{
#define MIN_OPT_LEVEL 1
#include "lrodefs.h"
const
LUA_REG_TYPE
lmt
[]
=
{
{
LRO_STRKEY
(
"__gc"
),
LRO_FUNCVAL
(
gctm
)},
{
LRO_STRKEY
(
"__gc"
),
LRO_FUNCVAL
(
gctm
)},
{
LRO_NILKEY
,
LRO_NILVAL
}
{
LRO_NILKEY
,
LRO_NILVAL
}
};
};
#endif
#endif
LUALIB_API
int
ICACHE_FLASH_ATTR
luaopen_package
(
lua_State
*
L
)
{
LUALIB_API
int
luaopen_package
(
lua_State
*
L
)
{
int
i
;
int
i
;
/* create new type _LOADLIB */
/* create new type _LOADLIB */
#if LUA_OPTIMIZE_MEMORY == 0
#if LUA_OPTIMIZE_MEMORY == 0
...
...
app/lua/lobject.c
View file @
c04f2578
...
@@ -32,7 +32,7 @@ const TValue luaO_nilobject_ = {LUA_TVALUE_NIL};
...
@@ -32,7 +32,7 @@ const TValue luaO_nilobject_ = {LUA_TVALUE_NIL};
** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if
** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if
** eeeee != 0 and (xxx) otherwise.
** eeeee != 0 and (xxx) otherwise.
*/
*/
int
ICACHE_FLASH_ATTR
luaO_int2fb
(
unsigned
int
x
)
{
int
luaO_int2fb
(
unsigned
int
x
)
{
int
e
=
0
;
/* expoent */
int
e
=
0
;
/* expoent */
while
(
x
>=
16
)
{
while
(
x
>=
16
)
{
x
=
(
x
+
1
)
>>
1
;
x
=
(
x
+
1
)
>>
1
;
...
@@ -44,14 +44,14 @@ int ICACHE_FLASH_ATTR luaO_int2fb (unsigned int x) {
...
@@ -44,14 +44,14 @@ int ICACHE_FLASH_ATTR luaO_int2fb (unsigned int x) {
/* converts back */
/* converts back */
int
ICACHE_FLASH_ATTR
luaO_fb2int
(
int
x
)
{
int
luaO_fb2int
(
int
x
)
{
int
e
=
(
x
>>
3
)
&
31
;
int
e
=
(
x
>>
3
)
&
31
;
if
(
e
==
0
)
return
x
;
if
(
e
==
0
)
return
x
;
else
return
((
x
&
7
)
+
8
)
<<
(
e
-
1
);
else
return
((
x
&
7
)
+
8
)
<<
(
e
-
1
);
}
}
int
ICACHE_FLASH_ATTR
luaO_log2
(
unsigned
int
x
)
{
int
luaO_log2
(
unsigned
int
x
)
{
static
const
lu_byte
log_2
[
256
]
=
{
static
const
lu_byte
log_2
[
256
]
=
{
0
,
1
,
2
,
2
,
3
,
3
,
3
,
3
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
0
,
1
,
2
,
2
,
3
,
3
,
3
,
3
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
4
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
5
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
6
,
...
@@ -69,7 +69,7 @@ int ICACHE_FLASH_ATTR luaO_log2 (unsigned int x) {
...
@@ -69,7 +69,7 @@ int ICACHE_FLASH_ATTR luaO_log2 (unsigned int x) {
}
}
int
ICACHE_FLASH_ATTR
luaO_rawequalObj
(
const
TValue
*
t1
,
const
TValue
*
t2
)
{
int
luaO_rawequalObj
(
const
TValue
*
t1
,
const
TValue
*
t2
)
{
if
(
ttype
(
t1
)
!=
ttype
(
t2
))
return
0
;
if
(
ttype
(
t1
)
!=
ttype
(
t2
))
return
0
;
else
switch
(
ttype
(
t1
))
{
else
switch
(
ttype
(
t1
))
{
case
LUA_TNIL
:
case
LUA_TNIL
:
...
@@ -89,7 +89,7 @@ int ICACHE_FLASH_ATTR luaO_rawequalObj (const TValue *t1, const TValue *t2) {
...
@@ -89,7 +89,7 @@ int ICACHE_FLASH_ATTR luaO_rawequalObj (const TValue *t1, const TValue *t2) {
}
}
int
ICACHE_FLASH_ATTR
luaO_str2d
(
const
char
*
s
,
lua_Number
*
result
)
{
int
luaO_str2d
(
const
char
*
s
,
lua_Number
*
result
)
{
char
*
endptr
;
char
*
endptr
;
*
result
=
lua_str2number
(
s
,
&
endptr
);
*
result
=
lua_str2number
(
s
,
&
endptr
);
if
(
endptr
==
s
)
return
0
;
/* conversion failed */
if
(
endptr
==
s
)
return
0
;
/* conversion failed */
...
@@ -103,14 +103,14 @@ int ICACHE_FLASH_ATTR luaO_str2d (const char *s, lua_Number *result) {
...
@@ -103,14 +103,14 @@ int ICACHE_FLASH_ATTR luaO_str2d (const char *s, lua_Number *result) {
static
void
ICACHE_FLASH_ATTR
pushstr
(
lua_State
*
L
,
const
char
*
str
)
{
static
void
pushstr
(
lua_State
*
L
,
const
char
*
str
)
{
setsvalue2s
(
L
,
L
->
top
,
luaS_new
(
L
,
str
));
setsvalue2s
(
L
,
L
->
top
,
luaS_new
(
L
,
str
));
incr_top
(
L
);
incr_top
(
L
);
}
}
/* this function handles only `%d', `%c', %f, %p, and `%s' formats */
/* this function handles only `%d', `%c', %f, %p, and `%s' formats */
const
char
*
ICACHE_FLASH_ATTR
luaO_pushvfstring
(
lua_State
*
L
,
const
char
*
fmt
,
va_list
argp
)
{
const
char
*
luaO_pushvfstring
(
lua_State
*
L
,
const
char
*
fmt
,
va_list
argp
)
{
int
n
=
1
;
int
n
=
1
;
pushstr
(
L
,
""
);
pushstr
(
L
,
""
);
for
(;;)
{
for
(;;)
{
...
@@ -171,7 +171,7 @@ const char *ICACHE_FLASH_ATTR luaO_pushvfstring (lua_State *L, const char *fmt,
...
@@ -171,7 +171,7 @@ const char *ICACHE_FLASH_ATTR luaO_pushvfstring (lua_State *L, const char *fmt,
}
}
const
char
*
ICACHE_FLASH_ATTR
luaO_pushfstring
(
lua_State
*
L
,
const
char
*
fmt
,
...)
{
const
char
*
luaO_pushfstring
(
lua_State
*
L
,
const
char
*
fmt
,
...)
{
const
char
*
msg
;
const
char
*
msg
;
va_list
argp
;
va_list
argp
;
va_start
(
argp
,
fmt
);
va_start
(
argp
,
fmt
);
...
@@ -181,7 +181,7 @@ const char *ICACHE_FLASH_ATTR luaO_pushfstring (lua_State *L, const char *fmt, .
...
@@ -181,7 +181,7 @@ const char *ICACHE_FLASH_ATTR luaO_pushfstring (lua_State *L, const char *fmt, .
}
}
void
ICACHE_FLASH_ATTR
luaO_chunkid
(
char
*
out
,
const
char
*
source
,
size_t
bufflen
)
{
void
luaO_chunkid
(
char
*
out
,
const
char
*
source
,
size_t
bufflen
)
{
if
(
*
source
==
'='
)
{
if
(
*
source
==
'='
)
{
c_strncpy
(
out
,
source
+
1
,
bufflen
);
/* remove first char */
c_strncpy
(
out
,
source
+
1
,
bufflen
);
/* remove first char */
out
[
bufflen
-
1
]
=
'\0'
;
/* ensures null termination */
out
[
bufflen
-
1
]
=
'\0'
;
/* ensures null termination */
...
...
app/lua/lparser.c
View file @
c04f2578
...
@@ -54,7 +54,7 @@ static void chunk (LexState *ls);
...
@@ -54,7 +54,7 @@ static void chunk (LexState *ls);
static
void
expr
(
LexState
*
ls
,
expdesc
*
v
);
static
void
expr
(
LexState
*
ls
,
expdesc
*
v
);
static
void
ICACHE_FLASH_ATTR
anchor_token
(
LexState
*
ls
)
{
static
void
anchor_token
(
LexState
*
ls
)
{
if
(
ls
->
t
.
token
==
TK_NAME
||
ls
->
t
.
token
==
TK_STRING
)
{
if
(
ls
->
t
.
token
==
TK_NAME
||
ls
->
t
.
token
==
TK_STRING
)
{
TString
*
ts
=
ls
->
t
.
seminfo
.
ts
;
TString
*
ts
=
ls
->
t
.
seminfo
.
ts
;
luaX_newstring
(
ls
,
getstr
(
ts
),
ts
->
tsv
.
len
);
luaX_newstring
(
ls
,
getstr
(
ts
),
ts
->
tsv
.
len
);
...
@@ -62,13 +62,13 @@ static void ICACHE_FLASH_ATTR anchor_token (LexState *ls) {
...
@@ -62,13 +62,13 @@ static void ICACHE_FLASH_ATTR anchor_token (LexState *ls) {
}
}
static
void
ICACHE_FLASH_ATTR
error_expected
(
LexState
*
ls
,
int
token
)
{
static
void
error_expected
(
LexState
*
ls
,
int
token
)
{
luaX_syntaxerror
(
ls
,
luaX_syntaxerror
(
ls
,
luaO_pushfstring
(
ls
->
L
,
LUA_QS
" expected"
,
luaX_token2str
(
ls
,
token
)));
luaO_pushfstring
(
ls
->
L
,
LUA_QS
" expected"
,
luaX_token2str
(
ls
,
token
)));
}
}
static
void
ICACHE_FLASH_ATTR
errorlimit
(
FuncState
*
fs
,
int
limit
,
const
char
*
what
)
{
static
void
errorlimit
(
FuncState
*
fs
,
int
limit
,
const
char
*
what
)
{
const
char
*
msg
=
(
fs
->
f
->
linedefined
==
0
)
?
const
char
*
msg
=
(
fs
->
f
->
linedefined
==
0
)
?
luaO_pushfstring
(
fs
->
L
,
"main function has more than %d %s"
,
limit
,
what
)
:
luaO_pushfstring
(
fs
->
L
,
"main function has more than %d %s"
,
limit
,
what
)
:
luaO_pushfstring
(
fs
->
L
,
"function at line %d has more than %d %s"
,
luaO_pushfstring
(
fs
->
L
,
"function at line %d has more than %d %s"
,
...
@@ -77,7 +77,7 @@ static void ICACHE_FLASH_ATTR errorlimit (FuncState *fs, int limit, const char *
...
@@ -77,7 +77,7 @@ static void ICACHE_FLASH_ATTR errorlimit (FuncState *fs, int limit, const char *
}
}
static
int
ICACHE_FLASH_ATTR
testnext
(
LexState
*
ls
,
int
c
)
{
static
int
testnext
(
LexState
*
ls
,
int
c
)
{
if
(
ls
->
t
.
token
==
c
)
{
if
(
ls
->
t
.
token
==
c
)
{
luaX_next
(
ls
);
luaX_next
(
ls
);
return
1
;
return
1
;
...
@@ -86,12 +86,12 @@ static int ICACHE_FLASH_ATTR testnext (LexState *ls, int c) {
...
@@ -86,12 +86,12 @@ static int ICACHE_FLASH_ATTR testnext (LexState *ls, int c) {
}
}
static
void
ICACHE_FLASH_ATTR
check
(
LexState
*
ls
,
int
c
)
{
static
void
check
(
LexState
*
ls
,
int
c
)
{
if
(
ls
->
t
.
token
!=
c
)
if
(
ls
->
t
.
token
!=
c
)
error_expected
(
ls
,
c
);
error_expected
(
ls
,
c
);
}
}
static
void
ICACHE_FLASH_ATTR
checknext
(
LexState
*
ls
,
int
c
)
{
static
void
checknext
(
LexState
*
ls
,
int
c
)
{
check
(
ls
,
c
);
check
(
ls
,
c
);
luaX_next
(
ls
);
luaX_next
(
ls
);
}
}
...
@@ -101,7 +101,7 @@ static void ICACHE_FLASH_ATTR checknext (LexState *ls, int c) {
...
@@ -101,7 +101,7 @@ static void ICACHE_FLASH_ATTR checknext (LexState *ls, int c) {
static
void
ICACHE_FLASH_ATTR
check_match
(
LexState
*
ls
,
int
what
,
int
who
,
int
where
)
{
static
void
check_match
(
LexState
*
ls
,
int
what
,
int
who
,
int
where
)
{
if
(
!
testnext
(
ls
,
what
))
{
if
(
!
testnext
(
ls
,
what
))
{
if
(
where
==
ls
->
linenumber
)
if
(
where
==
ls
->
linenumber
)
error_expected
(
ls
,
what
);
error_expected
(
ls
,
what
);
...
@@ -114,7 +114,7 @@ static void ICACHE_FLASH_ATTR check_match (LexState *ls, int what, int who, int
...
@@ -114,7 +114,7 @@ static void ICACHE_FLASH_ATTR check_match (LexState *ls, int what, int who, int
}
}
static
TString
*
ICACHE_FLASH_ATTR
str_checkname
(
LexState
*
ls
)
{
static
TString
*
str_checkname
(
LexState
*
ls
)
{
TString
*
ts
;
TString
*
ts
;
check
(
ls
,
TK_NAME
);
check
(
ls
,
TK_NAME
);
ts
=
ls
->
t
.
seminfo
.
ts
;
ts
=
ls
->
t
.
seminfo
.
ts
;
...
@@ -123,24 +123,24 @@ static TString *ICACHE_FLASH_ATTR str_checkname (LexState *ls) {
...
@@ -123,24 +123,24 @@ static TString *ICACHE_FLASH_ATTR str_checkname (LexState *ls) {
}
}
static
void
ICACHE_FLASH_ATTR
init_exp
(
expdesc
*
e
,
expkind
k
,
int
i
)
{
static
void
init_exp
(
expdesc
*
e
,
expkind
k
,
int
i
)
{
e
->
f
=
e
->
t
=
NO_JUMP
;
e
->
f
=
e
->
t
=
NO_JUMP
;
e
->
k
=
k
;
e
->
k
=
k
;
e
->
u
.
s
.
info
=
i
;
e
->
u
.
s
.
info
=
i
;
}
}
static
void
ICACHE_FLASH_ATTR
codestring
(
LexState
*
ls
,
expdesc
*
e
,
TString
*
s
)
{
static
void
codestring
(
LexState
*
ls
,
expdesc
*
e
,
TString
*
s
)
{
init_exp
(
e
,
VK
,
luaK_stringK
(
ls
->
fs
,
s
));
init_exp
(
e
,
VK
,
luaK_stringK
(
ls
->
fs
,
s
));
}
}
static
void
ICACHE_FLASH_ATTR
checkname
(
LexState
*
ls
,
expdesc
*
e
)
{
static
void
checkname
(
LexState
*
ls
,
expdesc
*
e
)
{
codestring
(
ls
,
e
,
str_checkname
(
ls
));
codestring
(
ls
,
e
,
str_checkname
(
ls
));
}
}
static
int
ICACHE_FLASH_ATTR
registerlocalvar
(
LexState
*
ls
,
TString
*
varname
)
{
static
int
registerlocalvar
(
LexState
*
ls
,
TString
*
varname
)
{
FuncState
*
fs
=
ls
->
fs
;
FuncState
*
fs
=
ls
->
fs
;
Proto
*
f
=
fs
->
f
;
Proto
*
f
=
fs
->
f
;
int
oldsize
=
f
->
sizelocvars
;
int
oldsize
=
f
->
sizelocvars
;
...
@@ -157,14 +157,14 @@ static int ICACHE_FLASH_ATTR registerlocalvar (LexState *ls, TString *varname) {
...
@@ -157,14 +157,14 @@ static int ICACHE_FLASH_ATTR registerlocalvar (LexState *ls, TString *varname) {
new_localvar(ls, luaX_newstring(ls, "" v, (sizeof(v)/sizeof(char))-1), n)
new_localvar(ls, luaX_newstring(ls, "" v, (sizeof(v)/sizeof(char))-1), n)
static
void
ICACHE_FLASH_ATTR
new_localvar
(
LexState
*
ls
,
TString
*
name
,
int
n
)
{
static
void
new_localvar
(
LexState
*
ls
,
TString
*
name
,
int
n
)
{
FuncState
*
fs
=
ls
->
fs
;
FuncState
*
fs
=
ls
->
fs
;
luaY_checklimit
(
fs
,
fs
->
nactvar
+
n
+
1
,
LUAI_MAXVARS
,
"local variables"
);
luaY_checklimit
(
fs
,
fs
->
nactvar
+
n
+
1
,
LUAI_MAXVARS
,
"local variables"
);
fs
->
actvar
[
fs
->
nactvar
+
n
]
=
cast
(
unsigned
short
,
registerlocalvar
(
ls
,
name
));
fs
->
actvar
[
fs
->
nactvar
+
n
]
=
cast
(
unsigned
short
,
registerlocalvar
(
ls
,
name
));
}
}
static
void
ICACHE_FLASH_ATTR
adjustlocalvars
(
LexState
*
ls
,
int
nvars
)
{
static
void
adjustlocalvars
(
LexState
*
ls
,
int
nvars
)
{
FuncState
*
fs
=
ls
->
fs
;
FuncState
*
fs
=
ls
->
fs
;
fs
->
nactvar
=
cast_byte
(
fs
->
nactvar
+
nvars
);
fs
->
nactvar
=
cast_byte
(
fs
->
nactvar
+
nvars
);
for
(;
nvars
;
nvars
--
)
{
for
(;
nvars
;
nvars
--
)
{
...
@@ -173,14 +173,14 @@ static void ICACHE_FLASH_ATTR adjustlocalvars (LexState *ls, int nvars) {
...
@@ -173,14 +173,14 @@ static void ICACHE_FLASH_ATTR adjustlocalvars (LexState *ls, int nvars) {
}
}
static
void
ICACHE_FLASH_ATTR
removevars
(
LexState
*
ls
,
int
tolevel
)
{
static
void
removevars
(
LexState
*
ls
,
int
tolevel
)
{
FuncState
*
fs
=
ls
->
fs
;
FuncState
*
fs
=
ls
->
fs
;
while
(
fs
->
nactvar
>
tolevel
)
while
(
fs
->
nactvar
>
tolevel
)
getlocvar
(
fs
,
--
fs
->
nactvar
).
endpc
=
fs
->
pc
;
getlocvar
(
fs
,
--
fs
->
nactvar
).
endpc
=
fs
->
pc
;
}
}
static
int
ICACHE_FLASH_ATTR
indexupvalue
(
FuncState
*
fs
,
TString
*
name
,
expdesc
*
v
)
{
static
int
indexupvalue
(
FuncState
*
fs
,
TString
*
name
,
expdesc
*
v
)
{
int
i
;
int
i
;
Proto
*
f
=
fs
->
f
;
Proto
*
f
=
fs
->
f
;
int
oldsize
=
f
->
sizeupvalues
;
int
oldsize
=
f
->
sizeupvalues
;
...
@@ -204,7 +204,7 @@ static int ICACHE_FLASH_ATTR indexupvalue (FuncState *fs, TString *name, expdesc
...
@@ -204,7 +204,7 @@ static int ICACHE_FLASH_ATTR indexupvalue (FuncState *fs, TString *name, expdesc
}
}
static
int
ICACHE_FLASH_ATTR
searchvar
(
FuncState
*
fs
,
TString
*
n
)
{
static
int
searchvar
(
FuncState
*
fs
,
TString
*
n
)
{
int
i
;
int
i
;
for
(
i
=
fs
->
nactvar
-
1
;
i
>=
0
;
i
--
)
{
for
(
i
=
fs
->
nactvar
-
1
;
i
>=
0
;
i
--
)
{
if
(
n
==
getlocvar
(
fs
,
i
).
varname
)
if
(
n
==
getlocvar
(
fs
,
i
).
varname
)
...
@@ -214,14 +214,14 @@ static int ICACHE_FLASH_ATTR searchvar (FuncState *fs, TString *n) {
...
@@ -214,14 +214,14 @@ static int ICACHE_FLASH_ATTR searchvar (FuncState *fs, TString *n) {
}
}
static
void
ICACHE_FLASH_ATTR
markupval
(
FuncState
*
fs
,
int
level
)
{
static
void
markupval
(
FuncState
*
fs
,
int
level
)
{
BlockCnt
*
bl
=
fs
->
bl
;
BlockCnt
*
bl
=
fs
->
bl
;
while
(
bl
&&
bl
->
nactvar
>
level
)
bl
=
bl
->
previous
;
while
(
bl
&&
bl
->
nactvar
>
level
)
bl
=
bl
->
previous
;
if
(
bl
)
bl
->
upval
=
1
;
if
(
bl
)
bl
->
upval
=
1
;
}
}
static
int
ICACHE_FLASH_ATTR
singlevaraux
(
FuncState
*
fs
,
TString
*
n
,
expdesc
*
var
,
int
base
)
{
static
int
singlevaraux
(
FuncState
*
fs
,
TString
*
n
,
expdesc
*
var
,
int
base
)
{
if
(
fs
==
NULL
)
{
/* no more levels? */
if
(
fs
==
NULL
)
{
/* no more levels? */
init_exp
(
var
,
VGLOBAL
,
NO_REG
);
/* default is global variable */
init_exp
(
var
,
VGLOBAL
,
NO_REG
);
/* default is global variable */
return
VGLOBAL
;
return
VGLOBAL
;
...
@@ -245,7 +245,7 @@ static int ICACHE_FLASH_ATTR singlevaraux (FuncState *fs, TString *n, expdesc *v
...
@@ -245,7 +245,7 @@ static int ICACHE_FLASH_ATTR singlevaraux (FuncState *fs, TString *n, expdesc *v
}
}
static
void
ICACHE_FLASH_ATTR
singlevar
(
LexState
*
ls
,
expdesc
*
var
)
{
static
void
singlevar
(
LexState
*
ls
,
expdesc
*
var
)
{
TString
*
varname
=
str_checkname
(
ls
);
TString
*
varname
=
str_checkname
(
ls
);
FuncState
*
fs
=
ls
->
fs
;
FuncState
*
fs
=
ls
->
fs
;
if
(
singlevaraux
(
fs
,
varname
,
var
,
1
)
==
VGLOBAL
)
if
(
singlevaraux
(
fs
,
varname
,
var
,
1
)
==
VGLOBAL
)
...
@@ -253,7 +253,7 @@ static void ICACHE_FLASH_ATTR singlevar (LexState *ls, expdesc *var) {
...
@@ -253,7 +253,7 @@ static void ICACHE_FLASH_ATTR singlevar (LexState *ls, expdesc *var) {
}
}
static
void
ICACHE_FLASH_ATTR
adjust_assign
(
LexState
*
ls
,
int
nvars
,
int
nexps
,
expdesc
*
e
)
{
static
void
adjust_assign
(
LexState
*
ls
,
int
nvars
,
int
nexps
,
expdesc
*
e
)
{
FuncState
*
fs
=
ls
->
fs
;
FuncState
*
fs
=
ls
->
fs
;
int
extra
=
nvars
-
nexps
;
int
extra
=
nvars
-
nexps
;
if
(
hasmultret
(
e
->
k
))
{
if
(
hasmultret
(
e
->
k
))
{
...
@@ -273,7 +273,7 @@ static void ICACHE_FLASH_ATTR adjust_assign (LexState *ls, int nvars, int nexps,
...
@@ -273,7 +273,7 @@ static void ICACHE_FLASH_ATTR adjust_assign (LexState *ls, int nvars, int nexps,
}
}
static
void
ICACHE_FLASH_ATTR
enterlevel
(
LexState
*
ls
)
{
static
void
enterlevel
(
LexState
*
ls
)
{
if
(
++
ls
->
L
->
nCcalls
>
LUAI_MAXCCALLS
)
if
(
++
ls
->
L
->
nCcalls
>
LUAI_MAXCCALLS
)
luaX_lexerror
(
ls
,
"chunk has too many syntax levels"
,
0
);
luaX_lexerror
(
ls
,
"chunk has too many syntax levels"
,
0
);
}
}
...
@@ -282,7 +282,7 @@ static void ICACHE_FLASH_ATTR enterlevel (LexState *ls) {
...
@@ -282,7 +282,7 @@ static void ICACHE_FLASH_ATTR enterlevel (LexState *ls) {
#define leavelevel(ls) ((ls)->L->nCcalls--)
#define leavelevel(ls) ((ls)->L->nCcalls--)
static
void
ICACHE_FLASH_ATTR
enterblock
(
FuncState
*
fs
,
BlockCnt
*
bl
,
lu_byte
isbreakable
)
{
static
void
enterblock
(
FuncState
*
fs
,
BlockCnt
*
bl
,
lu_byte
isbreakable
)
{
bl
->
breaklist
=
NO_JUMP
;
bl
->
breaklist
=
NO_JUMP
;
bl
->
isbreakable
=
isbreakable
;
bl
->
isbreakable
=
isbreakable
;
bl
->
nactvar
=
fs
->
nactvar
;
bl
->
nactvar
=
fs
->
nactvar
;
...
@@ -293,7 +293,7 @@ static void ICACHE_FLASH_ATTR enterblock (FuncState *fs, BlockCnt *bl, lu_byte i
...
@@ -293,7 +293,7 @@ static void ICACHE_FLASH_ATTR enterblock (FuncState *fs, BlockCnt *bl, lu_byte i
}
}
static
void
ICACHE_FLASH_ATTR
leaveblock
(
FuncState
*
fs
)
{
static
void
leaveblock
(
FuncState
*
fs
)
{
BlockCnt
*
bl
=
fs
->
bl
;
BlockCnt
*
bl
=
fs
->
bl
;
fs
->
bl
=
bl
->
previous
;
fs
->
bl
=
bl
->
previous
;
removevars
(
fs
->
ls
,
bl
->
nactvar
);
removevars
(
fs
->
ls
,
bl
->
nactvar
);
...
@@ -307,7 +307,7 @@ static void ICACHE_FLASH_ATTR leaveblock (FuncState *fs) {
...
@@ -307,7 +307,7 @@ static void ICACHE_FLASH_ATTR leaveblock (FuncState *fs) {
}
}
static
void
ICACHE_FLASH_ATTR
pushclosure
(
LexState
*
ls
,
FuncState
*
func
,
expdesc
*
v
)
{
static
void
pushclosure
(
LexState
*
ls
,
FuncState
*
func
,
expdesc
*
v
)
{
FuncState
*
fs
=
ls
->
fs
;
FuncState
*
fs
=
ls
->
fs
;
Proto
*
f
=
fs
->
f
;
Proto
*
f
=
fs
->
f
;
int
oldsize
=
f
->
sizep
;
int
oldsize
=
f
->
sizep
;
...
@@ -325,7 +325,7 @@ static void ICACHE_FLASH_ATTR pushclosure (LexState *ls, FuncState *func, expdes
...
@@ -325,7 +325,7 @@ static void ICACHE_FLASH_ATTR pushclosure (LexState *ls, FuncState *func, expdes
}
}
static
void
ICACHE_FLASH_ATTR
open_func
(
LexState
*
ls
,
FuncState
*
fs
)
{
static
void
open_func
(
LexState
*
ls
,
FuncState
*
fs
)
{
lua_State
*
L
=
ls
->
L
;
lua_State
*
L
=
ls
->
L
;
Proto
*
f
=
luaF_newproto
(
L
);
Proto
*
f
=
luaF_newproto
(
L
);
fs
->
f
=
f
;
fs
->
f
=
f
;
...
@@ -353,7 +353,7 @@ static void ICACHE_FLASH_ATTR open_func (LexState *ls, FuncState *fs) {
...
@@ -353,7 +353,7 @@ static void ICACHE_FLASH_ATTR open_func (LexState *ls, FuncState *fs) {
}
}
static
void
ICACHE_FLASH_ATTR
close_func
(
LexState
*
ls
)
{
static
void
close_func
(
LexState
*
ls
)
{
lua_State
*
L
=
ls
->
L
;
lua_State
*
L
=
ls
->
L
;
FuncState
*
fs
=
ls
->
fs
;
FuncState
*
fs
=
ls
->
fs
;
Proto
*
f
=
fs
->
f
;
Proto
*
f
=
fs
->
f
;
...
@@ -380,7 +380,7 @@ static void ICACHE_FLASH_ATTR close_func (LexState *ls) {
...
@@ -380,7 +380,7 @@ static void ICACHE_FLASH_ATTR close_func (LexState *ls) {
}
}
Proto
*
ICACHE_FLASH_ATTR
luaY_parser
(
lua_State
*
L
,
ZIO
*
z
,
Mbuffer
*
buff
,
const
char
*
name
)
{
Proto
*
luaY_parser
(
lua_State
*
L
,
ZIO
*
z
,
Mbuffer
*
buff
,
const
char
*
name
)
{
struct
LexState
lexstate
;
struct
LexState
lexstate
;
struct
FuncState
funcstate
;
struct
FuncState
funcstate
;
TString
*
tname
=
luaS_new
(
L
,
name
);
TString
*
tname
=
luaS_new
(
L
,
name
);
...
@@ -408,7 +408,7 @@ Proto *ICACHE_FLASH_ATTR luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const
...
@@ -408,7 +408,7 @@ Proto *ICACHE_FLASH_ATTR luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const
/*============================================================*/
/*============================================================*/
static
void
ICACHE_FLASH_ATTR
field
(
LexState
*
ls
,
expdesc
*
v
)
{
static
void
field
(
LexState
*
ls
,
expdesc
*
v
)
{
/* field -> ['.' | ':'] NAME */
/* field -> ['.' | ':'] NAME */
FuncState
*
fs
=
ls
->
fs
;
FuncState
*
fs
=
ls
->
fs
;
expdesc
key
;
expdesc
key
;
...
@@ -419,7 +419,7 @@ static void ICACHE_FLASH_ATTR field (LexState *ls, expdesc *v) {
...
@@ -419,7 +419,7 @@ static void ICACHE_FLASH_ATTR field (LexState *ls, expdesc *v) {
}
}
static
void
ICACHE_FLASH_ATTR
yindex
(
LexState
*
ls
,
expdesc
*
v
)
{
static
void
yindex
(
LexState
*
ls
,
expdesc
*
v
)
{
/* index -> '[' expr ']' */
/* index -> '[' expr ']' */
luaX_next
(
ls
);
/* skip the '[' */
luaX_next
(
ls
);
/* skip the '[' */
expr
(
ls
,
v
);
expr
(
ls
,
v
);
...
@@ -444,7 +444,7 @@ struct ConsControl {
...
@@ -444,7 +444,7 @@ struct ConsControl {
};
};
static
void
ICACHE_FLASH_ATTR
recfield
(
LexState
*
ls
,
struct
ConsControl
*
cc
)
{
static
void
recfield
(
LexState
*
ls
,
struct
ConsControl
*
cc
)
{
/* recfield -> (NAME | `['exp1`]') = exp1 */
/* recfield -> (NAME | `['exp1`]') = exp1 */
FuncState
*
fs
=
ls
->
fs
;
FuncState
*
fs
=
ls
->
fs
;
int
reg
=
ls
->
fs
->
freereg
;
int
reg
=
ls
->
fs
->
freereg
;
...
@@ -465,7 +465,7 @@ static void ICACHE_FLASH_ATTR recfield (LexState *ls, struct ConsControl *cc) {
...
@@ -465,7 +465,7 @@ static void ICACHE_FLASH_ATTR recfield (LexState *ls, struct ConsControl *cc) {
}
}
static
void
ICACHE_FLASH_ATTR
closelistfield
(
FuncState
*
fs
,
struct
ConsControl
*
cc
)
{
static
void
closelistfield
(
FuncState
*
fs
,
struct
ConsControl
*
cc
)
{
if
(
cc
->
v
.
k
==
VVOID
)
return
;
/* there is no list item */
if
(
cc
->
v
.
k
==
VVOID
)
return
;
/* there is no list item */
luaK_exp2nextreg
(
fs
,
&
cc
->
v
);
luaK_exp2nextreg
(
fs
,
&
cc
->
v
);
cc
->
v
.
k
=
VVOID
;
cc
->
v
.
k
=
VVOID
;
...
@@ -476,7 +476,7 @@ static void ICACHE_FLASH_ATTR closelistfield (FuncState *fs, struct ConsControl
...
@@ -476,7 +476,7 @@ static void ICACHE_FLASH_ATTR closelistfield (FuncState *fs, struct ConsControl
}
}
static
void
ICACHE_FLASH_ATTR
lastlistfield
(
FuncState
*
fs
,
struct
ConsControl
*
cc
)
{
static
void
lastlistfield
(
FuncState
*
fs
,
struct
ConsControl
*
cc
)
{
if
(
cc
->
tostore
==
0
)
return
;
if
(
cc
->
tostore
==
0
)
return
;
if
(
hasmultret
(
cc
->
v
.
k
))
{
if
(
hasmultret
(
cc
->
v
.
k
))
{
luaK_setmultret
(
fs
,
&
cc
->
v
);
luaK_setmultret
(
fs
,
&
cc
->
v
);
...
@@ -491,7 +491,7 @@ static void ICACHE_FLASH_ATTR lastlistfield (FuncState *fs, struct ConsControl *
...
@@ -491,7 +491,7 @@ static void ICACHE_FLASH_ATTR lastlistfield (FuncState *fs, struct ConsControl *
}
}
static
void
ICACHE_FLASH_ATTR
listfield
(
LexState
*
ls
,
struct
ConsControl
*
cc
)
{
static
void
listfield
(
LexState
*
ls
,
struct
ConsControl
*
cc
)
{
expr
(
ls
,
&
cc
->
v
);
expr
(
ls
,
&
cc
->
v
);
luaY_checklimit
(
ls
->
fs
,
cc
->
na
,
MAX_INT
,
"items in a constructor"
);
luaY_checklimit
(
ls
->
fs
,
cc
->
na
,
MAX_INT
,
"items in a constructor"
);
cc
->
na
++
;
cc
->
na
++
;
...
@@ -499,7 +499,7 @@ static void ICACHE_FLASH_ATTR listfield (LexState *ls, struct ConsControl *cc) {
...
@@ -499,7 +499,7 @@ static void ICACHE_FLASH_ATTR listfield (LexState *ls, struct ConsControl *cc) {
}
}
static
void
ICACHE_FLASH_ATTR
constructor
(
LexState
*
ls
,
expdesc
*
t
)
{
static
void
constructor
(
LexState
*
ls
,
expdesc
*
t
)
{
/* constructor -> ?? */
/* constructor -> ?? */
FuncState
*
fs
=
ls
->
fs
;
FuncState
*
fs
=
ls
->
fs
;
int
line
=
ls
->
linenumber
;
int
line
=
ls
->
linenumber
;
...
@@ -544,7 +544,7 @@ static void ICACHE_FLASH_ATTR constructor (LexState *ls, expdesc *t) {
...
@@ -544,7 +544,7 @@ static void ICACHE_FLASH_ATTR constructor (LexState *ls, expdesc *t) {
static
void
ICACHE_FLASH_ATTR
parlist
(
LexState
*
ls
)
{
static
void
parlist
(
LexState
*
ls
)
{
/* parlist -> [ param { `,' param } ] */
/* parlist -> [ param { `,' param } ] */
FuncState
*
fs
=
ls
->
fs
;
FuncState
*
fs
=
ls
->
fs
;
Proto
*
f
=
fs
->
f
;
Proto
*
f
=
fs
->
f
;
...
@@ -577,7 +577,7 @@ static void ICACHE_FLASH_ATTR parlist (LexState *ls) {
...
@@ -577,7 +577,7 @@ static void ICACHE_FLASH_ATTR parlist (LexState *ls) {
}
}
static
void
ICACHE_FLASH_ATTR
body
(
LexState
*
ls
,
expdesc
*
e
,
int
needself
,
int
line
)
{
static
void
body
(
LexState
*
ls
,
expdesc
*
e
,
int
needself
,
int
line
)
{
/* body -> `(' parlist `)' chunk END */
/* body -> `(' parlist `)' chunk END */
FuncState
new_fs
;
FuncState
new_fs
;
open_func
(
ls
,
&
new_fs
);
open_func
(
ls
,
&
new_fs
);
...
@@ -597,7 +597,7 @@ static void ICACHE_FLASH_ATTR body (LexState *ls, expdesc *e, int needself, int
...
@@ -597,7 +597,7 @@ static void ICACHE_FLASH_ATTR body (LexState *ls, expdesc *e, int needself, int
}
}
static
int
ICACHE_FLASH_ATTR
explist1
(
LexState
*
ls
,
expdesc
*
v
)
{
static
int
explist1
(
LexState
*
ls
,
expdesc
*
v
)
{
/* explist1 -> expr { `,' expr } */
/* explist1 -> expr { `,' expr } */
int
n
=
1
;
/* at least one expression */
int
n
=
1
;
/* at least one expression */
expr
(
ls
,
v
);
expr
(
ls
,
v
);
...
@@ -610,7 +610,7 @@ static int ICACHE_FLASH_ATTR explist1 (LexState *ls, expdesc *v) {
...
@@ -610,7 +610,7 @@ static int ICACHE_FLASH_ATTR explist1 (LexState *ls, expdesc *v) {
}
}
static
void
ICACHE_FLASH_ATTR
funcargs
(
LexState
*
ls
,
expdesc
*
f
)
{
static
void
funcargs
(
LexState
*
ls
,
expdesc
*
f
)
{
FuncState
*
fs
=
ls
->
fs
;
FuncState
*
fs
=
ls
->
fs
;
expdesc
args
;
expdesc
args
;
int
base
,
nparams
;
int
base
,
nparams
;
...
@@ -668,7 +668,7 @@ static void ICACHE_FLASH_ATTR funcargs (LexState *ls, expdesc *f) {
...
@@ -668,7 +668,7 @@ static void ICACHE_FLASH_ATTR funcargs (LexState *ls, expdesc *f) {
*/
*/
static
void
ICACHE_FLASH_ATTR
prefixexp
(
LexState
*
ls
,
expdesc
*
v
)
{
static
void
prefixexp
(
LexState
*
ls
,
expdesc
*
v
)
{
/* prefixexp -> NAME | '(' expr ')' */
/* prefixexp -> NAME | '(' expr ')' */
switch
(
ls
->
t
.
token
)
{
switch
(
ls
->
t
.
token
)
{
case
'('
:
{
case
'('
:
{
...
@@ -691,7 +691,7 @@ static void ICACHE_FLASH_ATTR prefixexp (LexState *ls, expdesc *v) {
...
@@ -691,7 +691,7 @@ static void ICACHE_FLASH_ATTR prefixexp (LexState *ls, expdesc *v) {
}
}
static
void
ICACHE_FLASH_ATTR
primaryexp
(
LexState
*
ls
,
expdesc
*
v
)
{
static
void
primaryexp
(
LexState
*
ls
,
expdesc
*
v
)
{
/* primaryexp ->
/* primaryexp ->
prefixexp { `.' NAME | `[' exp `]' | `:' NAME funcargs | funcargs } */
prefixexp { `.' NAME | `[' exp `]' | `:' NAME funcargs | funcargs } */
FuncState
*
fs
=
ls
->
fs
;
FuncState
*
fs
=
ls
->
fs
;
...
@@ -728,7 +728,7 @@ static void ICACHE_FLASH_ATTR primaryexp (LexState *ls, expdesc *v) {
...
@@ -728,7 +728,7 @@ static void ICACHE_FLASH_ATTR primaryexp (LexState *ls, expdesc *v) {
}
}
static
void
ICACHE_FLASH_ATTR
simpleexp
(
LexState
*
ls
,
expdesc
*
v
)
{
static
void
simpleexp
(
LexState
*
ls
,
expdesc
*
v
)
{
/* simpleexp -> NUMBER | STRING | NIL | true | false | ... |
/* simpleexp -> NUMBER | STRING | NIL | true | false | ... |
constructor | FUNCTION body | primaryexp */
constructor | FUNCTION body | primaryexp */
switch
(
ls
->
t
.
token
)
{
switch
(
ls
->
t
.
token
)
{
...
@@ -779,7 +779,7 @@ static void ICACHE_FLASH_ATTR simpleexp (LexState *ls, expdesc *v) {
...
@@ -779,7 +779,7 @@ static void ICACHE_FLASH_ATTR simpleexp (LexState *ls, expdesc *v) {
}
}
static
UnOpr
ICACHE_FLASH_ATTR
getunopr
(
int
op
)
{
static
UnOpr
getunopr
(
int
op
)
{
switch
(
op
)
{
switch
(
op
)
{
case
TK_NOT
:
return
OPR_NOT
;
case
TK_NOT
:
return
OPR_NOT
;
case
'-'
:
return
OPR_MINUS
;
case
'-'
:
return
OPR_MINUS
;
...
@@ -789,7 +789,7 @@ static UnOpr ICACHE_FLASH_ATTR getunopr (int op) {
...
@@ -789,7 +789,7 @@ static UnOpr ICACHE_FLASH_ATTR getunopr (int op) {
}
}
static
BinOpr
ICACHE_FLASH_ATTR
getbinopr
(
int
op
)
{
static
BinOpr
getbinopr
(
int
op
)
{
switch
(
op
)
{
switch
(
op
)
{
case
'+'
:
return
OPR_ADD
;
case
'+'
:
return
OPR_ADD
;
case
'-'
:
return
OPR_SUB
;
case
'-'
:
return
OPR_SUB
;
...
@@ -829,7 +829,7 @@ static const struct {
...
@@ -829,7 +829,7 @@ static const struct {
** subexpr -> (simpleexp | unop subexpr) { binop subexpr }
** subexpr -> (simpleexp | unop subexpr) { binop subexpr }
** where `binop' is any binary operator with a priority higher than `limit'
** where `binop' is any binary operator with a priority higher than `limit'
*/
*/
static
BinOpr
ICACHE_FLASH_ATTR
subexpr
(
LexState
*
ls
,
expdesc
*
v
,
unsigned
int
limit
)
{
static
BinOpr
subexpr
(
LexState
*
ls
,
expdesc
*
v
,
unsigned
int
limit
)
{
BinOpr
op
;
BinOpr
op
;
UnOpr
uop
;
UnOpr
uop
;
enterlevel
(
ls
);
enterlevel
(
ls
);
...
@@ -857,7 +857,7 @@ static BinOpr ICACHE_FLASH_ATTR subexpr (LexState *ls, expdesc *v, unsigned int
...
@@ -857,7 +857,7 @@ static BinOpr ICACHE_FLASH_ATTR subexpr (LexState *ls, expdesc *v, unsigned int
}
}
static
void
ICACHE_FLASH_ATTR
expr
(
LexState
*
ls
,
expdesc
*
v
)
{
static
void
expr
(
LexState
*
ls
,
expdesc
*
v
)
{
subexpr
(
ls
,
v
,
0
);
subexpr
(
ls
,
v
,
0
);
}
}
...
@@ -872,7 +872,7 @@ static void ICACHE_FLASH_ATTR expr (LexState *ls, expdesc *v) {
...
@@ -872,7 +872,7 @@ static void ICACHE_FLASH_ATTR expr (LexState *ls, expdesc *v) {
*/
*/
static
int
ICACHE_FLASH_ATTR
block_follow
(
int
token
)
{
static
int
block_follow
(
int
token
)
{
switch
(
token
)
{
switch
(
token
)
{
case
TK_ELSE
:
case
TK_ELSEIF
:
case
TK_END
:
case
TK_ELSE
:
case
TK_ELSEIF
:
case
TK_END
:
case
TK_UNTIL
:
case
TK_EOS
:
case
TK_UNTIL
:
case
TK_EOS
:
...
@@ -882,7 +882,7 @@ static int ICACHE_FLASH_ATTR block_follow (int token) {
...
@@ -882,7 +882,7 @@ static int ICACHE_FLASH_ATTR block_follow (int token) {
}
}
static
void
ICACHE_FLASH_ATTR
block
(
LexState
*
ls
)
{
static
void
block
(
LexState
*
ls
)
{
/* block -> chunk */
/* block -> chunk */
FuncState
*
fs
=
ls
->
fs
;
FuncState
*
fs
=
ls
->
fs
;
BlockCnt
*
pbl
=
(
BlockCnt
*
)
luaM_malloc
(
ls
->
L
,
sizeof
(
BlockCnt
));
BlockCnt
*
pbl
=
(
BlockCnt
*
)
luaM_malloc
(
ls
->
L
,
sizeof
(
BlockCnt
));
...
@@ -910,7 +910,7 @@ struct LHS_assign {
...
@@ -910,7 +910,7 @@ struct LHS_assign {
** local value in a safe place and use this safe copy in the previous
** local value in a safe place and use this safe copy in the previous
** assignment.
** assignment.
*/
*/
static
void
ICACHE_FLASH_ATTR
check_conflict
(
LexState
*
ls
,
struct
LHS_assign
*
lh
,
expdesc
*
v
)
{
static
void
check_conflict
(
LexState
*
ls
,
struct
LHS_assign
*
lh
,
expdesc
*
v
)
{
FuncState
*
fs
=
ls
->
fs
;
FuncState
*
fs
=
ls
->
fs
;
int
extra
=
fs
->
freereg
;
/* eventual position to save local variable */
int
extra
=
fs
->
freereg
;
/* eventual position to save local variable */
int
conflict
=
0
;
int
conflict
=
0
;
...
@@ -933,7 +933,7 @@ static void ICACHE_FLASH_ATTR check_conflict (LexState *ls, struct LHS_assign *l
...
@@ -933,7 +933,7 @@ static void ICACHE_FLASH_ATTR check_conflict (LexState *ls, struct LHS_assign *l
}
}
static
void
ICACHE_FLASH_ATTR
assignment
(
LexState
*
ls
,
struct
LHS_assign
*
lh
,
int
nvars
)
{
static
void
assignment
(
LexState
*
ls
,
struct
LHS_assign
*
lh
,
int
nvars
)
{
expdesc
e
;
expdesc
e
;
check_condition
(
ls
,
VLOCAL
<=
lh
->
v
.
k
&&
lh
->
v
.
k
<=
VINDEXED
,
check_condition
(
ls
,
VLOCAL
<=
lh
->
v
.
k
&&
lh
->
v
.
k
<=
VINDEXED
,
"syntax error"
);
"syntax error"
);
...
@@ -967,7 +967,7 @@ static void ICACHE_FLASH_ATTR assignment (LexState *ls, struct LHS_assign *lh, i
...
@@ -967,7 +967,7 @@ static void ICACHE_FLASH_ATTR assignment (LexState *ls, struct LHS_assign *lh, i
}
}
static
int
ICACHE_FLASH_ATTR
cond
(
LexState
*
ls
)
{
static
int
cond
(
LexState
*
ls
)
{
/* cond -> exp */
/* cond -> exp */
expdesc
v
;
expdesc
v
;
expr
(
ls
,
&
v
);
/* read condition */
expr
(
ls
,
&
v
);
/* read condition */
...
@@ -977,7 +977,7 @@ static int ICACHE_FLASH_ATTR cond (LexState *ls) {
...
@@ -977,7 +977,7 @@ static int ICACHE_FLASH_ATTR cond (LexState *ls) {
}
}
static
void
ICACHE_FLASH_ATTR
breakstat
(
LexState
*
ls
)
{
static
void
breakstat
(
LexState
*
ls
)
{
FuncState
*
fs
=
ls
->
fs
;
FuncState
*
fs
=
ls
->
fs
;
BlockCnt
*
bl
=
fs
->
bl
;
BlockCnt
*
bl
=
fs
->
bl
;
int
upval
=
0
;
int
upval
=
0
;
...
@@ -993,7 +993,7 @@ static void ICACHE_FLASH_ATTR breakstat (LexState *ls) {
...
@@ -993,7 +993,7 @@ static void ICACHE_FLASH_ATTR breakstat (LexState *ls) {
}
}
static
void
ICACHE_FLASH_ATTR
whilestat
(
LexState
*
ls
,
int
line
)
{
static
void
whilestat
(
LexState
*
ls
,
int
line
)
{
/* whilestat -> WHILE cond DO block END */
/* whilestat -> WHILE cond DO block END */
FuncState
*
fs
=
ls
->
fs
;
FuncState
*
fs
=
ls
->
fs
;
int
whileinit
;
int
whileinit
;
...
@@ -1012,7 +1012,7 @@ static void ICACHE_FLASH_ATTR whilestat (LexState *ls, int line) {
...
@@ -1012,7 +1012,7 @@ static void ICACHE_FLASH_ATTR whilestat (LexState *ls, int line) {
}
}
static
void
ICACHE_FLASH_ATTR
repeatstat
(
LexState
*
ls
,
int
line
)
{
static
void
repeatstat
(
LexState
*
ls
,
int
line
)
{
/* repeatstat -> REPEAT block UNTIL cond */
/* repeatstat -> REPEAT block UNTIL cond */
int
condexit
;
int
condexit
;
FuncState
*
fs
=
ls
->
fs
;
FuncState
*
fs
=
ls
->
fs
;
...
@@ -1038,7 +1038,7 @@ static void ICACHE_FLASH_ATTR repeatstat (LexState *ls, int line) {
...
@@ -1038,7 +1038,7 @@ static void ICACHE_FLASH_ATTR repeatstat (LexState *ls, int line) {
}
}
static
int
ICACHE_FLASH_ATTR
exp1
(
LexState
*
ls
)
{
static
int
exp1
(
LexState
*
ls
)
{
expdesc
e
;
expdesc
e
;
int
k
;
int
k
;
expr
(
ls
,
&
e
);
expr
(
ls
,
&
e
);
...
@@ -1048,7 +1048,7 @@ static int ICACHE_FLASH_ATTR exp1 (LexState *ls) {
...
@@ -1048,7 +1048,7 @@ static int ICACHE_FLASH_ATTR exp1 (LexState *ls) {
}
}
static
void
ICACHE_FLASH_ATTR
forbody
(
LexState
*
ls
,
int
base
,
int
line
,
int
nvars
,
int
isnum
)
{
static
void
forbody
(
LexState
*
ls
,
int
base
,
int
line
,
int
nvars
,
int
isnum
)
{
/* forbody -> DO block */
/* forbody -> DO block */
BlockCnt
*
pbl
=
(
BlockCnt
*
)
luaM_malloc
(
ls
->
L
,
sizeof
(
BlockCnt
));
BlockCnt
*
pbl
=
(
BlockCnt
*
)
luaM_malloc
(
ls
->
L
,
sizeof
(
BlockCnt
));
FuncState
*
fs
=
ls
->
fs
;
FuncState
*
fs
=
ls
->
fs
;
...
@@ -1070,7 +1070,7 @@ static void ICACHE_FLASH_ATTR forbody (LexState *ls, int base, int line, int nva
...
@@ -1070,7 +1070,7 @@ static void ICACHE_FLASH_ATTR forbody (LexState *ls, int base, int line, int nva
}
}
static
void
ICACHE_FLASH_ATTR
fornum
(
LexState
*
ls
,
TString
*
varname
,
int
line
)
{
static
void
fornum
(
LexState
*
ls
,
TString
*
varname
,
int
line
)
{
/* fornum -> NAME = exp1,exp1[,exp1] forbody */
/* fornum -> NAME = exp1,exp1[,exp1] forbody */
FuncState
*
fs
=
ls
->
fs
;
FuncState
*
fs
=
ls
->
fs
;
int
base
=
fs
->
freereg
;
int
base
=
fs
->
freereg
;
...
@@ -1092,7 +1092,7 @@ static void ICACHE_FLASH_ATTR fornum (LexState *ls, TString *varname, int line)
...
@@ -1092,7 +1092,7 @@ static void ICACHE_FLASH_ATTR fornum (LexState *ls, TString *varname, int line)
}
}
static
void
ICACHE_FLASH_ATTR
forlist
(
LexState
*
ls
,
TString
*
indexname
)
{
static
void
forlist
(
LexState
*
ls
,
TString
*
indexname
)
{
/* forlist -> NAME {,NAME} IN explist1 forbody */
/* forlist -> NAME {,NAME} IN explist1 forbody */
FuncState
*
fs
=
ls
->
fs
;
FuncState
*
fs
=
ls
->
fs
;
expdesc
e
;
expdesc
e
;
...
@@ -1115,7 +1115,7 @@ static void ICACHE_FLASH_ATTR forlist (LexState *ls, TString *indexname) {
...
@@ -1115,7 +1115,7 @@ static void ICACHE_FLASH_ATTR forlist (LexState *ls, TString *indexname) {
}
}
static
void
ICACHE_FLASH_ATTR
forstat
(
LexState
*
ls
,
int
line
)
{
static
void
forstat
(
LexState
*
ls
,
int
line
)
{
/* forstat -> FOR (fornum | forlist) END */
/* forstat -> FOR (fornum | forlist) END */
FuncState
*
fs
=
ls
->
fs
;
FuncState
*
fs
=
ls
->
fs
;
TString
*
varname
;
TString
*
varname
;
...
@@ -1133,7 +1133,7 @@ static void ICACHE_FLASH_ATTR forstat (LexState *ls, int line) {
...
@@ -1133,7 +1133,7 @@ static void ICACHE_FLASH_ATTR forstat (LexState *ls, int line) {
}
}
static
int
ICACHE_FLASH_ATTR
test_then_block
(
LexState
*
ls
)
{
static
int
test_then_block
(
LexState
*
ls
)
{
/* test_then_block -> [IF | ELSEIF] cond THEN block */
/* test_then_block -> [IF | ELSEIF] cond THEN block */
int
condexit
;
int
condexit
;
luaX_next
(
ls
);
/* skip IF or ELSEIF */
luaX_next
(
ls
);
/* skip IF or ELSEIF */
...
@@ -1144,7 +1144,7 @@ static int ICACHE_FLASH_ATTR test_then_block (LexState *ls) {
...
@@ -1144,7 +1144,7 @@ static int ICACHE_FLASH_ATTR test_then_block (LexState *ls) {
}
}
static
void
ICACHE_FLASH_ATTR
ifstat
(
LexState
*
ls
,
int
line
)
{
static
void
ifstat
(
LexState
*
ls
,
int
line
)
{
/* ifstat -> IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END */
/* ifstat -> IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END */
FuncState
*
fs
=
ls
->
fs
;
FuncState
*
fs
=
ls
->
fs
;
int
flist
;
int
flist
;
...
@@ -1168,7 +1168,7 @@ static void ICACHE_FLASH_ATTR ifstat (LexState *ls, int line) {
...
@@ -1168,7 +1168,7 @@ static void ICACHE_FLASH_ATTR ifstat (LexState *ls, int line) {
}
}
static
void
ICACHE_FLASH_ATTR
localfunc
(
LexState
*
ls
)
{
static
void
localfunc
(
LexState
*
ls
)
{
expdesc
v
,
b
;
expdesc
v
,
b
;
FuncState
*
fs
=
ls
->
fs
;
FuncState
*
fs
=
ls
->
fs
;
new_localvar
(
ls
,
str_checkname
(
ls
),
0
);
new_localvar
(
ls
,
str_checkname
(
ls
),
0
);
...
@@ -1182,7 +1182,7 @@ static void ICACHE_FLASH_ATTR localfunc (LexState *ls) {
...
@@ -1182,7 +1182,7 @@ static void ICACHE_FLASH_ATTR localfunc (LexState *ls) {
}
}
static
void
ICACHE_FLASH_ATTR
localstat
(
LexState
*
ls
)
{
static
void
localstat
(
LexState
*
ls
)
{
/* stat -> LOCAL NAME {`,' NAME} [`=' explist1] */
/* stat -> LOCAL NAME {`,' NAME} [`=' explist1] */
int
nvars
=
0
;
int
nvars
=
0
;
int
nexps
;
int
nexps
;
...
@@ -1201,7 +1201,7 @@ static void ICACHE_FLASH_ATTR localstat (LexState *ls) {
...
@@ -1201,7 +1201,7 @@ static void ICACHE_FLASH_ATTR localstat (LexState *ls) {
}
}
static
int
ICACHE_FLASH_ATTR
funcname
(
LexState
*
ls
,
expdesc
*
v
)
{
static
int
funcname
(
LexState
*
ls
,
expdesc
*
v
)
{
/* funcname -> NAME {field} [`:' NAME] */
/* funcname -> NAME {field} [`:' NAME] */
int
needself
=
0
;
int
needself
=
0
;
singlevar
(
ls
,
v
);
singlevar
(
ls
,
v
);
...
@@ -1215,7 +1215,7 @@ static int ICACHE_FLASH_ATTR funcname (LexState *ls, expdesc *v) {
...
@@ -1215,7 +1215,7 @@ static int ICACHE_FLASH_ATTR funcname (LexState *ls, expdesc *v) {
}
}
static
void
ICACHE_FLASH_ATTR
funcstat
(
LexState
*
ls
,
int
line
)
{
static
void
funcstat
(
LexState
*
ls
,
int
line
)
{
/* funcstat -> FUNCTION funcname body */
/* funcstat -> FUNCTION funcname body */
int
needself
;
int
needself
;
expdesc
v
,
b
;
expdesc
v
,
b
;
...
@@ -1227,7 +1227,7 @@ static void ICACHE_FLASH_ATTR funcstat (LexState *ls, int line) {
...
@@ -1227,7 +1227,7 @@ static void ICACHE_FLASH_ATTR funcstat (LexState *ls, int line) {
}
}
static
void
ICACHE_FLASH_ATTR
exprstat
(
LexState
*
ls
)
{
static
void
exprstat
(
LexState
*
ls
)
{
/* stat -> func | assignment */
/* stat -> func | assignment */
FuncState
*
fs
=
ls
->
fs
;
FuncState
*
fs
=
ls
->
fs
;
struct
LHS_assign
v
;
struct
LHS_assign
v
;
...
@@ -1241,7 +1241,7 @@ static void ICACHE_FLASH_ATTR exprstat (LexState *ls) {
...
@@ -1241,7 +1241,7 @@ static void ICACHE_FLASH_ATTR exprstat (LexState *ls) {
}
}
static
void
ICACHE_FLASH_ATTR
retstat
(
LexState
*
ls
)
{
static
void
retstat
(
LexState
*
ls
)
{
/* stat -> RETURN explist */
/* stat -> RETURN explist */
FuncState
*
fs
=
ls
->
fs
;
FuncState
*
fs
=
ls
->
fs
;
expdesc
e
;
expdesc
e
;
...
@@ -1274,7 +1274,7 @@ static void ICACHE_FLASH_ATTR retstat (LexState *ls) {
...
@@ -1274,7 +1274,7 @@ static void ICACHE_FLASH_ATTR retstat (LexState *ls) {
}
}
static
int
ICACHE_FLASH_ATTR
statement
(
LexState
*
ls
)
{
static
int
statement
(
LexState
*
ls
)
{
int
line
=
ls
->
linenumber
;
/* may be needed for error messages */
int
line
=
ls
->
linenumber
;
/* may be needed for error messages */
switch
(
ls
->
t
.
token
)
{
switch
(
ls
->
t
.
token
)
{
case
TK_IF
:
{
/* stat -> ifstat */
case
TK_IF
:
{
/* stat -> ifstat */
...
@@ -1328,7 +1328,7 @@ static int ICACHE_FLASH_ATTR statement (LexState *ls) {
...
@@ -1328,7 +1328,7 @@ static int ICACHE_FLASH_ATTR statement (LexState *ls) {
}
}
static
void
ICACHE_FLASH_ATTR
chunk
(
LexState
*
ls
)
{
static
void
chunk
(
LexState
*
ls
)
{
/* chunk -> { stat [`;'] } */
/* chunk -> { stat [`;'] } */
int
islast
=
0
;
int
islast
=
0
;
enterlevel
(
ls
);
enterlevel
(
ls
);
...
...
app/lua/lrodefs.h
View file @
c04f2578
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
#undef LREGISTER
#undef LREGISTER
#if (MIN_OPT_LEVEL > 0) && (LUA_OPTIMIZE_MEMORY >= MIN_OPT_LEVEL)
#if (MIN_OPT_LEVEL > 0) && (LUA_OPTIMIZE_MEMORY >= MIN_OPT_LEVEL)
#define LUA_REG_TYPE luaR_entry
#define LUA_REG_TYPE luaR_entry
ICACHE_FLASH_ATTR
#define LSTRKEY LRO_STRKEY
#define LSTRKEY LRO_STRKEY
#define LNUMKEY LRO_NUMKEY
#define LNUMKEY LRO_NUMKEY
#define LNILKEY LRO_NILKEY
#define LNILKEY LRO_NILKEY
...
...
app/lua/lrotable.c
View file @
c04f2578
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
extern
const
luaR_table
lua_rotable
[];
extern
const
luaR_table
lua_rotable
[];
/* Find a global "read only table" in the constant lua_rotable array */
/* Find a global "read only table" in the constant lua_rotable array */
void
*
ICACHE_FLASH_ATTR
luaR_findglobal
(
const
char
*
name
,
unsigned
len
)
{
void
*
luaR_findglobal
(
const
char
*
name
,
unsigned
len
)
{
unsigned
i
;
unsigned
i
;
if
(
c_strlen
(
name
)
>
LUA_MAX_ROTABLE_NAME
)
if
(
c_strlen
(
name
)
>
LUA_MAX_ROTABLE_NAME
)
...
@@ -29,7 +29,7 @@ void* ICACHE_FLASH_ATTR luaR_findglobal(const char *name, unsigned len) {
...
@@ -29,7 +29,7 @@ void* ICACHE_FLASH_ATTR luaR_findglobal(const char *name, unsigned len) {
}
}
/* Find an entry in a rotable and return it */
/* Find an entry in a rotable and return it */
static
const
TValue
*
ICACHE_FLASH_ATTR
luaR_auxfind
(
const
luaR_entry
*
pentry
,
const
char
*
strkey
,
luaR_numkey
numkey
,
unsigned
*
ppos
)
{
static
const
TValue
*
luaR_auxfind
(
const
luaR_entry
*
pentry
,
const
char
*
strkey
,
luaR_numkey
numkey
,
unsigned
*
ppos
)
{
const
TValue
*
res
=
NULL
;
const
TValue
*
res
=
NULL
;
unsigned
i
=
0
;
unsigned
i
=
0
;
...
@@ -48,7 +48,7 @@ static const TValue* ICACHE_FLASH_ATTR luaR_auxfind(const luaR_entry *pentry, co
...
@@ -48,7 +48,7 @@ static const TValue* ICACHE_FLASH_ATTR luaR_auxfind(const luaR_entry *pentry, co
return
res
;
return
res
;
}
}
int
ICACHE_FLASH_ATTR
luaR_findfunction
(
lua_State
*
L
,
const
luaR_entry
*
ptable
)
{
int
luaR_findfunction
(
lua_State
*
L
,
const
luaR_entry
*
ptable
)
{
const
TValue
*
res
=
NULL
;
const
TValue
*
res
=
NULL
;
const
char
*
key
=
luaL_checkstring
(
L
,
2
);
const
char
*
key
=
luaL_checkstring
(
L
,
2
);
...
@@ -64,12 +64,12 @@ int ICACHE_FLASH_ATTR luaR_findfunction(lua_State *L, const luaR_entry *ptable)
...
@@ -64,12 +64,12 @@ int ICACHE_FLASH_ATTR luaR_findfunction(lua_State *L, const luaR_entry *ptable)
/* Find an entry in a rotable and return its type
/* Find an entry in a rotable and return its type
If "strkey" is not NULL, the function will look for a string key,
If "strkey" is not NULL, the function will look for a string key,
otherwise it will look for a number key */
otherwise it will look for a number key */
const
TValue
*
ICACHE_FLASH_ATTR
luaR_findentry
(
void
*
data
,
const
char
*
strkey
,
luaR_numkey
numkey
,
unsigned
*
ppos
)
{
const
TValue
*
luaR_findentry
(
void
*
data
,
const
char
*
strkey
,
luaR_numkey
numkey
,
unsigned
*
ppos
)
{
return
luaR_auxfind
((
const
luaR_entry
*
)
data
,
strkey
,
numkey
,
ppos
);
return
luaR_auxfind
((
const
luaR_entry
*
)
data
,
strkey
,
numkey
,
ppos
);
}
}
/* Find the metatable of a given table */
/* Find the metatable of a given table */
void
*
ICACHE_FLASH_ATTR
luaR_getmeta
(
void
*
data
)
{
void
*
luaR_getmeta
(
void
*
data
)
{
#ifdef LUA_META_ROTABLES
#ifdef LUA_META_ROTABLES
const
TValue
*
res
=
luaR_auxfind
((
const
luaR_entry
*
)
data
,
"__metatable"
,
0
,
NULL
);
const
TValue
*
res
=
luaR_auxfind
((
const
luaR_entry
*
)
data
,
"__metatable"
,
0
,
NULL
);
return
res
&&
ttisrotable
(
res
)
?
rvalue
(
res
)
:
NULL
;
return
res
&&
ttisrotable
(
res
)
?
rvalue
(
res
)
:
NULL
;
...
@@ -78,7 +78,7 @@ void* ICACHE_FLASH_ATTR luaR_getmeta(void *data) {
...
@@ -78,7 +78,7 @@ void* ICACHE_FLASH_ATTR luaR_getmeta(void *data) {
#endif
#endif
}
}
static
void
ICACHE_FLASH_ATTR
luaR_next_helper
(
lua_State
*
L
,
const
luaR_entry
*
pentries
,
int
pos
,
TValue
*
key
,
TValue
*
val
)
{
static
void
luaR_next_helper
(
lua_State
*
L
,
const
luaR_entry
*
pentries
,
int
pos
,
TValue
*
key
,
TValue
*
val
)
{
setnilvalue
(
key
);
setnilvalue
(
key
);
setnilvalue
(
val
);
setnilvalue
(
val
);
if
(
pentries
[
pos
].
key
.
type
!=
LUA_TNIL
)
{
if
(
pentries
[
pos
].
key
.
type
!=
LUA_TNIL
)
{
...
@@ -91,7 +91,7 @@ static void ICACHE_FLASH_ATTR luaR_next_helper(lua_State *L, const luaR_entry *p
...
@@ -91,7 +91,7 @@ static void ICACHE_FLASH_ATTR luaR_next_helper(lua_State *L, const luaR_entry *p
}
}
}
}
/* next (used for iteration) */
/* next (used for iteration) */
void
ICACHE_FLASH_ATTR
luaR_next
(
lua_State
*
L
,
void
*
data
,
TValue
*
key
,
TValue
*
val
)
{
void
luaR_next
(
lua_State
*
L
,
void
*
data
,
TValue
*
key
,
TValue
*
val
)
{
const
luaR_entry
*
pentries
=
(
const
luaR_entry
*
)
data
;
const
luaR_entry
*
pentries
=
(
const
luaR_entry
*
)
data
;
char
strkey
[
LUA_MAX_ROTABLE_NAME
+
1
],
*
pstrkey
=
NULL
;
char
strkey
[
LUA_MAX_ROTABLE_NAME
+
1
],
*
pstrkey
=
NULL
;
luaR_numkey
numkey
=
0
;
luaR_numkey
numkey
=
0
;
...
@@ -115,7 +115,7 @@ void ICACHE_FLASH_ATTR luaR_next(lua_State *L, void *data, TValue *key, TValue *
...
@@ -115,7 +115,7 @@ void ICACHE_FLASH_ATTR luaR_next(lua_State *L, void *data, TValue *key, TValue *
}
}
/* Convert a Lua string to a C string */
/* Convert a Lua string to a C string */
void
ICACHE_FLASH_ATTR
luaR_getcstr
(
char
*
dest
,
const
TString
*
src
,
size_t
maxsize
)
{
void
luaR_getcstr
(
char
*
dest
,
const
TString
*
src
,
size_t
maxsize
)
{
if
(
src
->
tsv
.
len
+
1
>
maxsize
)
if
(
src
->
tsv
.
len
+
1
>
maxsize
)
dest
[
0
]
=
'\0'
;
dest
[
0
]
=
'\0'
;
else
{
else
{
...
@@ -129,7 +129,7 @@ void ICACHE_FLASH_ATTR luaR_getcstr(char *dest, const TString *src, size_t maxsi
...
@@ -129,7 +129,7 @@ void ICACHE_FLASH_ATTR luaR_getcstr(char *dest, const TString *src, size_t maxsi
#include "compiler.h"
#include "compiler.h"
int
ICACHE_FLASH_ATTR
luaR_isrotable
(
void
*
p
)
{
int
luaR_isrotable
(
void
*
p
)
{
return
RODATA_START_ADDRESS
<=
(
char
*
)
p
&&
(
char
*
)
p
<=
RODATA_END_ADDRESS
;
return
RODATA_START_ADDRESS
<=
(
char
*
)
p
&&
(
char
*
)
p
<=
RODATA_END_ADDRESS
;
}
}
#endif
#endif
app/lua/lstate.c
View file @
c04f2578
...
@@ -38,7 +38,7 @@ typedef struct LG {
...
@@ -38,7 +38,7 @@ typedef struct LG {
static
void
ICACHE_FLASH_ATTR
stack_init
(
lua_State
*
L1
,
lua_State
*
L
)
{
static
void
stack_init
(
lua_State
*
L1
,
lua_State
*
L
)
{
/* initialize CallInfo array */
/* initialize CallInfo array */
L1
->
base_ci
=
luaM_newvector
(
L
,
BASIC_CI_SIZE
,
CallInfo
);
L1
->
base_ci
=
luaM_newvector
(
L
,
BASIC_CI_SIZE
,
CallInfo
);
L1
->
ci
=
L1
->
base_ci
;
L1
->
ci
=
L1
->
base_ci
;
...
@@ -57,7 +57,7 @@ static void ICACHE_FLASH_ATTR stack_init (lua_State *L1, lua_State *L) {
...
@@ -57,7 +57,7 @@ static void ICACHE_FLASH_ATTR stack_init (lua_State *L1, lua_State *L) {
}
}
static
void
ICACHE_FLASH_ATTR
freestack
(
lua_State
*
L
,
lua_State
*
L1
)
{
static
void
freestack
(
lua_State
*
L
,
lua_State
*
L1
)
{
luaM_freearray
(
L
,
L1
->
base_ci
,
L1
->
size_ci
,
CallInfo
);
luaM_freearray
(
L
,
L1
->
base_ci
,
L1
->
size_ci
,
CallInfo
);
luaM_freearray
(
L
,
L1
->
stack
,
L1
->
stacksize
,
TValue
);
luaM_freearray
(
L
,
L1
->
stack
,
L1
->
stacksize
,
TValue
);
}
}
...
@@ -66,7 +66,7 @@ static void ICACHE_FLASH_ATTR freestack (lua_State *L, lua_State *L1) {
...
@@ -66,7 +66,7 @@ static void ICACHE_FLASH_ATTR freestack (lua_State *L, lua_State *L1) {
/*
/*
** open parts that may cause memory-allocation errors
** open parts that may cause memory-allocation errors
*/
*/
static
void
ICACHE_FLASH_ATTR
f_luaopen
(
lua_State
*
L
,
void
*
ud
)
{
static
void
f_luaopen
(
lua_State
*
L
,
void
*
ud
)
{
global_State
*
g
=
G
(
L
);
global_State
*
g
=
G
(
L
);
UNUSED
(
ud
);
UNUSED
(
ud
);
stack_init
(
L
,
L
);
/* init stack */
stack_init
(
L
,
L
);
/* init stack */
...
@@ -80,7 +80,7 @@ static void ICACHE_FLASH_ATTR f_luaopen (lua_State *L, void *ud) {
...
@@ -80,7 +80,7 @@ static void ICACHE_FLASH_ATTR f_luaopen (lua_State *L, void *ud) {
}
}
static
void
ICACHE_FLASH_ATTR
preinit_state
(
lua_State
*
L
,
global_State
*
g
)
{
static
void
preinit_state
(
lua_State
*
L
,
global_State
*
g
)
{
G
(
L
)
=
g
;
G
(
L
)
=
g
;
L
->
stack
=
NULL
;
L
->
stack
=
NULL
;
L
->
stacksize
=
0
;
L
->
stacksize
=
0
;
...
@@ -101,7 +101,7 @@ static void ICACHE_FLASH_ATTR preinit_state (lua_State *L, global_State *g) {
...
@@ -101,7 +101,7 @@ static void ICACHE_FLASH_ATTR preinit_state (lua_State *L, global_State *g) {
}
}
static
void
ICACHE_FLASH_ATTR
close_state
(
lua_State
*
L
)
{
static
void
close_state
(
lua_State
*
L
)
{
global_State
*
g
=
G
(
L
);
global_State
*
g
=
G
(
L
);
luaF_close
(
L
,
L
->
stack
);
/* close all upvalues for this thread */
luaF_close
(
L
,
L
->
stack
);
/* close all upvalues for this thread */
luaC_freeall
(
L
);
/* collect all objects */
luaC_freeall
(
L
);
/* collect all objects */
...
@@ -115,7 +115,7 @@ static void ICACHE_FLASH_ATTR close_state (lua_State *L) {
...
@@ -115,7 +115,7 @@ static void ICACHE_FLASH_ATTR close_state (lua_State *L) {
}
}
lua_State
*
ICACHE_FLASH_ATTR
luaE_newthread
(
lua_State
*
L
)
{
lua_State
*
luaE_newthread
(
lua_State
*
L
)
{
lua_State
*
L1
=
tostate
(
luaM_malloc
(
L
,
state_size
(
lua_State
)));
lua_State
*
L1
=
tostate
(
luaM_malloc
(
L
,
state_size
(
lua_State
)));
luaC_link
(
L
,
obj2gco
(
L1
),
LUA_TTHREAD
);
luaC_link
(
L
,
obj2gco
(
L1
),
LUA_TTHREAD
);
setthvalue
(
L
,
L
->
top
,
L1
);
/* put thread on stack */
setthvalue
(
L
,
L
->
top
,
L1
);
/* put thread on stack */
...
@@ -133,7 +133,7 @@ lua_State *ICACHE_FLASH_ATTR luaE_newthread (lua_State *L) {
...
@@ -133,7 +133,7 @@ lua_State *ICACHE_FLASH_ATTR luaE_newthread (lua_State *L) {
}
}
void
ICACHE_FLASH_ATTR
luaE_freethread
(
lua_State
*
L
,
lua_State
*
L1
)
{
void
luaE_freethread
(
lua_State
*
L
,
lua_State
*
L1
)
{
luaF_close
(
L1
,
L1
->
stack
);
/* close all upvalues for this thread */
luaF_close
(
L1
,
L1
->
stack
);
/* close all upvalues for this thread */
lua_assert
(
L1
->
openupval
==
NULL
);
lua_assert
(
L1
->
openupval
==
NULL
);
luai_userstatefree
(
L1
);
luai_userstatefree
(
L1
);
...
@@ -142,7 +142,7 @@ void ICACHE_FLASH_ATTR luaE_freethread (lua_State *L, lua_State *L1) {
...
@@ -142,7 +142,7 @@ void ICACHE_FLASH_ATTR luaE_freethread (lua_State *L, lua_State *L1) {
}
}
LUA_API
lua_State
*
ICACHE_FLASH_ATTR
lua_newstate
(
lua_Alloc
f
,
void
*
ud
)
{
LUA_API
lua_State
*
lua_newstate
(
lua_Alloc
f
,
void
*
ud
)
{
int
i
;
int
i
;
lua_State
*
L
;
lua_State
*
L
;
global_State
*
g
;
global_State
*
g
;
...
@@ -205,7 +205,7 @@ LUA_API lua_State *ICACHE_FLASH_ATTR lua_newstate (lua_Alloc f, void *ud) {
...
@@ -205,7 +205,7 @@ LUA_API lua_State *ICACHE_FLASH_ATTR lua_newstate (lua_Alloc f, void *ud) {
}
}
static
void
ICACHE_FLASH_ATTR
callallgcTM
(
lua_State
*
L
,
void
*
ud
)
{
static
void
callallgcTM
(
lua_State
*
L
,
void
*
ud
)
{
UNUSED
(
ud
);
UNUSED
(
ud
);
luaC_callGCTM
(
L
);
/* call GC metamethods for all udata */
luaC_callGCTM
(
L
);
/* call GC metamethods for all udata */
}
}
...
@@ -214,15 +214,15 @@ static void ICACHE_FLASH_ATTR callallgcTM (lua_State *L, void *ud) {
...
@@ -214,15 +214,15 @@ static void ICACHE_FLASH_ATTR callallgcTM (lua_State *L, void *ud) {
extern
lua_State
*
luaL_newstate
(
void
);
extern
lua_State
*
luaL_newstate
(
void
);
static
lua_State
*
lua_crtstate
;
static
lua_State
*
lua_crtstate
;
lua_State
*
ICACHE_FLASH_ATTR
lua_open
(
void
)
{
lua_State
*
lua_open
(
void
)
{
lua_crtstate
=
luaL_newstate
();
lua_crtstate
=
luaL_newstate
();
return
lua_crtstate
;
return
lua_crtstate
;
}
}
lua_State
*
ICACHE_FLASH_ATTR
lua_getstate
(
void
)
{
lua_State
*
lua_getstate
(
void
)
{
return
lua_crtstate
;
return
lua_crtstate
;
}
}
LUA_API
void
ICACHE_FLASH_ATTR
lua_close
(
lua_State
*
L
)
{
LUA_API
void
lua_close
(
lua_State
*
L
)
{
#ifndef LUA_CROSS_COMPILER
#ifndef LUA_CROSS_COMPILER
lua_sethook
(
L
,
NULL
,
0
,
0
);
lua_sethook
(
L
,
NULL
,
0
,
0
);
lua_crtstate
=
NULL
;
lua_crtstate
=
NULL
;
...
...
app/lua/lstring.c
View file @
c04f2578
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
#define LUAS_READONLY_STRING 1
#define LUAS_READONLY_STRING 1
#define LUAS_REGULAR_STRING 0
#define LUAS_REGULAR_STRING 0
void
ICACHE_FLASH_ATTR
luaS_resize
(
lua_State
*
L
,
int
newsize
)
{
void
luaS_resize
(
lua_State
*
L
,
int
newsize
)
{
stringtable
*
tb
;
stringtable
*
tb
;
int
i
;
int
i
;
tb
=
&
G
(
L
)
->
strt
;
tb
=
&
G
(
L
)
->
strt
;
...
@@ -51,7 +51,7 @@ void ICACHE_FLASH_ATTR luaS_resize (lua_State *L, int newsize) {
...
@@ -51,7 +51,7 @@ void ICACHE_FLASH_ATTR luaS_resize (lua_State *L, int newsize) {
unset_resizing_strings_gc
(
L
);
unset_resizing_strings_gc
(
L
);
}
}
static
TString
*
ICACHE_FLASH_ATTR
newlstr
(
lua_State
*
L
,
const
char
*
str
,
size_t
l
,
static
TString
*
newlstr
(
lua_State
*
L
,
const
char
*
str
,
size_t
l
,
unsigned
int
h
,
int
readonly
)
{
unsigned
int
h
,
int
readonly
)
{
TString
*
ts
;
TString
*
ts
;
stringtable
*
tb
;
stringtable
*
tb
;
...
@@ -80,7 +80,7 @@ static TString *ICACHE_FLASH_ATTR newlstr (lua_State *L, const char *str, size_t
...
@@ -80,7 +80,7 @@ static TString *ICACHE_FLASH_ATTR newlstr (lua_State *L, const char *str, size_t
}
}
static
TString
*
ICACHE_FLASH_ATTR
luaS_newlstr_helper
(
lua_State
*
L
,
const
char
*
str
,
size_t
l
,
int
readonly
)
{
static
TString
*
luaS_newlstr_helper
(
lua_State
*
L
,
const
char
*
str
,
size_t
l
,
int
readonly
)
{
GCObject
*
o
;
GCObject
*
o
;
unsigned
int
h
=
cast
(
unsigned
int
,
l
);
/* seed */
unsigned
int
h
=
cast
(
unsigned
int
,
l
);
/* seed */
size_t
step
=
(
l
>>
5
)
+
1
;
/* if string is too long, don't hash all its chars */
size_t
step
=
(
l
>>
5
)
+
1
;
/* if string is too long, don't hash all its chars */
...
@@ -100,7 +100,7 @@ static TString *ICACHE_FLASH_ATTR luaS_newlstr_helper (lua_State *L, const char
...
@@ -100,7 +100,7 @@ static TString *ICACHE_FLASH_ATTR luaS_newlstr_helper (lua_State *L, const char
return
newlstr
(
L
,
str
,
l
,
h
,
readonly
);
/* not found */
return
newlstr
(
L
,
str
,
l
,
h
,
readonly
);
/* not found */
}
}
static
int
ICACHE_FLASH_ATTR
lua_is_ptr_in_ro_area
(
const
char
*
p
)
{
static
int
lua_is_ptr_in_ro_area
(
const
char
*
p
)
{
#ifdef LUA_CROSS_COMPILER
#ifdef LUA_CROSS_COMPILER
return
0
;
return
0
;
#else
#else
...
@@ -111,7 +111,7 @@ static int ICACHE_FLASH_ATTR lua_is_ptr_in_ro_area(const char *p) {
...
@@ -111,7 +111,7 @@ static int ICACHE_FLASH_ATTR lua_is_ptr_in_ro_area(const char *p) {
#endif
#endif
}
}
TString
*
ICACHE_FLASH_ATTR
luaS_newlstr
(
lua_State
*
L
,
const
char
*
str
,
size_t
l
)
{
TString
*
luaS_newlstr
(
lua_State
*
L
,
const
char
*
str
,
size_t
l
)
{
// If the pointer is in a read-only memory and the string is at least 4 chars in length,
// If the pointer is in a read-only memory and the string is at least 4 chars in length,
// create it as a read-only string instead
// create it as a read-only string instead
if
(
lua_is_ptr_in_ro_area
(
str
)
&&
l
+
1
>
sizeof
(
char
**
)
&&
l
==
c_strlen
(
str
))
if
(
lua_is_ptr_in_ro_area
(
str
)
&&
l
+
1
>
sizeof
(
char
**
)
&&
l
==
c_strlen
(
str
))
...
@@ -121,7 +121,7 @@ TString *ICACHE_FLASH_ATTR luaS_newlstr (lua_State *L, const char *str, size_t l
...
@@ -121,7 +121,7 @@ TString *ICACHE_FLASH_ATTR luaS_newlstr (lua_State *L, const char *str, size_t l
}
}
LUAI_FUNC
TString
*
ICACHE_FLASH_ATTR
luaS_newrolstr
(
lua_State
*
L
,
const
char
*
str
,
size_t
l
)
{
LUAI_FUNC
TString
*
luaS_newrolstr
(
lua_State
*
L
,
const
char
*
str
,
size_t
l
)
{
if
(
l
+
1
>
sizeof
(
char
**
)
&&
l
==
c_strlen
(
str
))
if
(
l
+
1
>
sizeof
(
char
**
)
&&
l
==
c_strlen
(
str
))
return
luaS_newlstr_helper
(
L
,
str
,
l
,
LUAS_READONLY_STRING
);
return
luaS_newlstr_helper
(
L
,
str
,
l
,
LUAS_READONLY_STRING
);
else
// no point in creating a RO string, as it would actually be larger
else
// no point in creating a RO string, as it would actually be larger
...
@@ -129,7 +129,7 @@ LUAI_FUNC TString *ICACHE_FLASH_ATTR luaS_newrolstr (lua_State *L, const char *s
...
@@ -129,7 +129,7 @@ LUAI_FUNC TString *ICACHE_FLASH_ATTR luaS_newrolstr (lua_State *L, const char *s
}
}
Udata
*
ICACHE_FLASH_ATTR
luaS_newudata
(
lua_State
*
L
,
size_t
s
,
Table
*
e
)
{
Udata
*
luaS_newudata
(
lua_State
*
L
,
size_t
s
,
Table
*
e
)
{
Udata
*
u
;
Udata
*
u
;
if
(
s
>
MAX_SIZET
-
sizeof
(
Udata
))
if
(
s
>
MAX_SIZET
-
sizeof
(
Udata
))
luaM_toobig
(
L
);
luaM_toobig
(
L
);
...
...
app/lua/lstrlib.c
View file @
c04f2578
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
static
int
ICACHE_FLASH_ATTR
str_len
(
lua_State
*
L
)
{
static
int
str_len
(
lua_State
*
L
)
{
size_t
l
;
size_t
l
;
luaL_checklstring
(
L
,
1
,
&
l
);
luaL_checklstring
(
L
,
1
,
&
l
);
lua_pushinteger
(
L
,
l
);
lua_pushinteger
(
L
,
l
);
...
@@ -33,14 +33,14 @@ static int ICACHE_FLASH_ATTR str_len (lua_State *L) {
...
@@ -33,14 +33,14 @@ static int ICACHE_FLASH_ATTR str_len (lua_State *L) {
}
}
static
ptrdiff_t
ICACHE_FLASH_ATTR
posrelat
(
ptrdiff_t
pos
,
size_t
len
)
{
static
ptrdiff_t
posrelat
(
ptrdiff_t
pos
,
size_t
len
)
{
/* relative string position: negative means back from end */
/* relative string position: negative means back from end */
if
(
pos
<
0
)
pos
+=
(
ptrdiff_t
)
len
+
1
;
if
(
pos
<
0
)
pos
+=
(
ptrdiff_t
)
len
+
1
;
return
(
pos
>=
0
)
?
pos
:
0
;
return
(
pos
>=
0
)
?
pos
:
0
;
}
}
static
int
ICACHE_FLASH_ATTR
str_sub
(
lua_State
*
L
)
{
static
int
str_sub
(
lua_State
*
L
)
{
size_t
l
;
size_t
l
;
const
char
*
s
=
luaL_checklstring
(
L
,
1
,
&
l
);
const
char
*
s
=
luaL_checklstring
(
L
,
1
,
&
l
);
ptrdiff_t
start
=
posrelat
(
luaL_checkinteger
(
L
,
2
),
l
);
ptrdiff_t
start
=
posrelat
(
luaL_checkinteger
(
L
,
2
),
l
);
...
@@ -54,7 +54,7 @@ static int ICACHE_FLASH_ATTR str_sub (lua_State *L) {
...
@@ -54,7 +54,7 @@ static int ICACHE_FLASH_ATTR str_sub (lua_State *L) {
}
}
static
int
ICACHE_FLASH_ATTR
str_reverse
(
lua_State
*
L
)
{
static
int
str_reverse
(
lua_State
*
L
)
{
size_t
l
;
size_t
l
;
luaL_Buffer
b
;
luaL_Buffer
b
;
const
char
*
s
=
luaL_checklstring
(
L
,
1
,
&
l
);
const
char
*
s
=
luaL_checklstring
(
L
,
1
,
&
l
);
...
@@ -65,7 +65,7 @@ static int ICACHE_FLASH_ATTR str_reverse (lua_State *L) {
...
@@ -65,7 +65,7 @@ static int ICACHE_FLASH_ATTR str_reverse (lua_State *L) {
}
}
static
int
ICACHE_FLASH_ATTR
str_lower
(
lua_State
*
L
)
{
static
int
str_lower
(
lua_State
*
L
)
{
size_t
l
;
size_t
l
;
size_t
i
;
size_t
i
;
luaL_Buffer
b
;
luaL_Buffer
b
;
...
@@ -78,7 +78,7 @@ static int ICACHE_FLASH_ATTR str_lower (lua_State *L) {
...
@@ -78,7 +78,7 @@ static int ICACHE_FLASH_ATTR str_lower (lua_State *L) {
}
}
static
int
ICACHE_FLASH_ATTR
str_upper
(
lua_State
*
L
)
{
static
int
str_upper
(
lua_State
*
L
)
{
size_t
l
;
size_t
l
;
size_t
i
;
size_t
i
;
luaL_Buffer
b
;
luaL_Buffer
b
;
...
@@ -90,7 +90,7 @@ static int ICACHE_FLASH_ATTR str_upper (lua_State *L) {
...
@@ -90,7 +90,7 @@ static int ICACHE_FLASH_ATTR str_upper (lua_State *L) {
return
1
;
return
1
;
}
}
static
int
ICACHE_FLASH_ATTR
str_rep
(
lua_State
*
L
)
{
static
int
str_rep
(
lua_State
*
L
)
{
size_t
l
;
size_t
l
;
luaL_Buffer
b
;
luaL_Buffer
b
;
const
char
*
s
=
luaL_checklstring
(
L
,
1
,
&
l
);
const
char
*
s
=
luaL_checklstring
(
L
,
1
,
&
l
);
...
@@ -103,7 +103,7 @@ static int ICACHE_FLASH_ATTR str_rep (lua_State *L) {
...
@@ -103,7 +103,7 @@ static int ICACHE_FLASH_ATTR str_rep (lua_State *L) {
}
}
static
int
ICACHE_FLASH_ATTR
str_byte
(
lua_State
*
L
)
{
static
int
str_byte
(
lua_State
*
L
)
{
size_t
l
;
size_t
l
;
const
char
*
s
=
luaL_checklstring
(
L
,
1
,
&
l
);
const
char
*
s
=
luaL_checklstring
(
L
,
1
,
&
l
);
ptrdiff_t
posi
=
posrelat
(
luaL_optinteger
(
L
,
2
,
1
),
l
);
ptrdiff_t
posi
=
posrelat
(
luaL_optinteger
(
L
,
2
,
1
),
l
);
...
@@ -122,7 +122,7 @@ static int ICACHE_FLASH_ATTR str_byte (lua_State *L) {
...
@@ -122,7 +122,7 @@ static int ICACHE_FLASH_ATTR str_byte (lua_State *L) {
}
}
static
int
ICACHE_FLASH_ATTR
str_char
(
lua_State
*
L
)
{
static
int
str_char
(
lua_State
*
L
)
{
int
n
=
lua_gettop
(
L
);
/* number of arguments */
int
n
=
lua_gettop
(
L
);
/* number of arguments */
int
i
;
int
i
;
luaL_Buffer
b
;
luaL_Buffer
b
;
...
@@ -137,14 +137,14 @@ static int ICACHE_FLASH_ATTR str_char (lua_State *L) {
...
@@ -137,14 +137,14 @@ static int ICACHE_FLASH_ATTR str_char (lua_State *L) {
}
}
static
int
ICACHE_FLASH_ATTR
writer
(
lua_State
*
L
,
const
void
*
b
,
size_t
size
,
void
*
B
)
{
static
int
writer
(
lua_State
*
L
,
const
void
*
b
,
size_t
size
,
void
*
B
)
{
(
void
)
L
;
(
void
)
L
;
luaL_addlstring
((
luaL_Buffer
*
)
B
,
(
const
char
*
)
b
,
size
);
luaL_addlstring
((
luaL_Buffer
*
)
B
,
(
const
char
*
)
b
,
size
);
return
0
;
return
0
;
}
}
static
int
ICACHE_FLASH_ATTR
str_dump
(
lua_State
*
L
)
{
static
int
str_dump
(
lua_State
*
L
)
{
luaL_Buffer
b
;
luaL_Buffer
b
;
luaL_checktype
(
L
,
1
,
LUA_TFUNCTION
);
luaL_checktype
(
L
,
1
,
LUA_TFUNCTION
);
lua_settop
(
L
,
1
);
lua_settop
(
L
,
1
);
...
@@ -183,7 +183,7 @@ typedef struct MatchState {
...
@@ -183,7 +183,7 @@ typedef struct MatchState {
#define SPECIALS "^$*+?.([%-"
#define SPECIALS "^$*+?.([%-"
static
int
ICACHE_FLASH_ATTR
check_capture
(
MatchState
*
ms
,
int
l
)
{
static
int
check_capture
(
MatchState
*
ms
,
int
l
)
{
l
-=
'1'
;
l
-=
'1'
;
if
(
l
<
0
||
l
>=
ms
->
level
||
ms
->
capture
[
l
].
len
==
CAP_UNFINISHED
)
if
(
l
<
0
||
l
>=
ms
->
level
||
ms
->
capture
[
l
].
len
==
CAP_UNFINISHED
)
return
luaL_error
(
ms
->
L
,
"invalid capture index"
);
return
luaL_error
(
ms
->
L
,
"invalid capture index"
);
...
@@ -191,7 +191,7 @@ static int ICACHE_FLASH_ATTR check_capture (MatchState *ms, int l) {
...
@@ -191,7 +191,7 @@ static int ICACHE_FLASH_ATTR check_capture (MatchState *ms, int l) {
}
}
static
int
ICACHE_FLASH_ATTR
capture_to_close
(
MatchState
*
ms
)
{
static
int
capture_to_close
(
MatchState
*
ms
)
{
int
level
=
ms
->
level
;
int
level
=
ms
->
level
;
for
(
level
--
;
level
>=
0
;
level
--
)
for
(
level
--
;
level
>=
0
;
level
--
)
if
(
ms
->
capture
[
level
].
len
==
CAP_UNFINISHED
)
return
level
;
if
(
ms
->
capture
[
level
].
len
==
CAP_UNFINISHED
)
return
level
;
...
@@ -199,7 +199,7 @@ static int ICACHE_FLASH_ATTR capture_to_close (MatchState *ms) {
...
@@ -199,7 +199,7 @@ static int ICACHE_FLASH_ATTR capture_to_close (MatchState *ms) {
}
}
static
const
char
*
ICACHE_FLASH_ATTR
classend
(
MatchState
*
ms
,
const
char
*
p
)
{
static
const
char
*
classend
(
MatchState
*
ms
,
const
char
*
p
)
{
switch
(
*
p
++
)
{
switch
(
*
p
++
)
{
case
L_ESC
:
{
case
L_ESC
:
{
if
(
*
p
==
'\0'
)
if
(
*
p
==
'\0'
)
...
@@ -223,7 +223,7 @@ static const char *ICACHE_FLASH_ATTR classend (MatchState *ms, const char *p) {
...
@@ -223,7 +223,7 @@ static const char *ICACHE_FLASH_ATTR classend (MatchState *ms, const char *p) {
}
}
static
int
ICACHE_FLASH_ATTR
match_class
(
int
c
,
int
cl
)
{
static
int
match_class
(
int
c
,
int
cl
)
{
int
res
;
int
res
;
switch
(
tolower
(
cl
))
{
switch
(
tolower
(
cl
))
{
case
'a'
:
res
=
isalpha
(
c
);
break
;
case
'a'
:
res
=
isalpha
(
c
);
break
;
...
@@ -242,7 +242,7 @@ static int ICACHE_FLASH_ATTR match_class (int c, int cl) {
...
@@ -242,7 +242,7 @@ static int ICACHE_FLASH_ATTR match_class (int c, int cl) {
}
}
static
int
ICACHE_FLASH_ATTR
matchbracketclass
(
int
c
,
const
char
*
p
,
const
char
*
ec
)
{
static
int
matchbracketclass
(
int
c
,
const
char
*
p
,
const
char
*
ec
)
{
int
sig
=
1
;
int
sig
=
1
;
if
(
*
(
p
+
1
)
==
'^'
)
{
if
(
*
(
p
+
1
)
==
'^'
)
{
sig
=
0
;
sig
=
0
;
...
@@ -265,7 +265,7 @@ static int ICACHE_FLASH_ATTR matchbracketclass (int c, const char *p, const char
...
@@ -265,7 +265,7 @@ static int ICACHE_FLASH_ATTR matchbracketclass (int c, const char *p, const char
}
}
static
int
ICACHE_FLASH_ATTR
singlematch
(
int
c
,
const
char
*
p
,
const
char
*
ep
)
{
static
int
singlematch
(
int
c
,
const
char
*
p
,
const
char
*
ep
)
{
switch
(
*
p
)
{
switch
(
*
p
)
{
case
'.'
:
return
1
;
/* matches any char */
case
'.'
:
return
1
;
/* matches any char */
case
L_ESC
:
return
match_class
(
c
,
uchar
(
*
(
p
+
1
)));
case
L_ESC
:
return
match_class
(
c
,
uchar
(
*
(
p
+
1
)));
...
@@ -278,7 +278,7 @@ static int ICACHE_FLASH_ATTR singlematch (int c, const char *p, const char *ep)
...
@@ -278,7 +278,7 @@ static int ICACHE_FLASH_ATTR singlematch (int c, const char *p, const char *ep)
static
const
char
*
match
(
MatchState
*
ms
,
const
char
*
s
,
const
char
*
p
);
static
const
char
*
match
(
MatchState
*
ms
,
const
char
*
s
,
const
char
*
p
);
static
const
char
*
ICACHE_FLASH_ATTR
matchbalance
(
MatchState
*
ms
,
const
char
*
s
,
static
const
char
*
matchbalance
(
MatchState
*
ms
,
const
char
*
s
,
const
char
*
p
)
{
const
char
*
p
)
{
if
(
*
p
==
0
||
*
(
p
+
1
)
==
0
)
if
(
*
p
==
0
||
*
(
p
+
1
)
==
0
)
luaL_error
(
ms
->
L
,
"unbalanced pattern"
);
luaL_error
(
ms
->
L
,
"unbalanced pattern"
);
...
@@ -298,7 +298,7 @@ static const char *ICACHE_FLASH_ATTR matchbalance (MatchState *ms, const char *s
...
@@ -298,7 +298,7 @@ static const char *ICACHE_FLASH_ATTR matchbalance (MatchState *ms, const char *s
}
}
static
const
char
*
ICACHE_FLASH_ATTR
max_expand
(
MatchState
*
ms
,
const
char
*
s
,
static
const
char
*
max_expand
(
MatchState
*
ms
,
const
char
*
s
,
const
char
*
p
,
const
char
*
ep
)
{
const
char
*
p
,
const
char
*
ep
)
{
ptrdiff_t
i
=
0
;
/* counts maximum expand for item */
ptrdiff_t
i
=
0
;
/* counts maximum expand for item */
while
((
s
+
i
)
<
ms
->
src_end
&&
singlematch
(
uchar
(
*
(
s
+
i
)),
p
,
ep
))
while
((
s
+
i
)
<
ms
->
src_end
&&
singlematch
(
uchar
(
*
(
s
+
i
)),
p
,
ep
))
...
@@ -313,7 +313,7 @@ static const char *ICACHE_FLASH_ATTR max_expand (MatchState *ms, const char *s,
...
@@ -313,7 +313,7 @@ static const char *ICACHE_FLASH_ATTR max_expand (MatchState *ms, const char *s,
}
}
static
const
char
*
ICACHE_FLASH_ATTR
min_expand
(
MatchState
*
ms
,
const
char
*
s
,
static
const
char
*
min_expand
(
MatchState
*
ms
,
const
char
*
s
,
const
char
*
p
,
const
char
*
ep
)
{
const
char
*
p
,
const
char
*
ep
)
{
for
(;;)
{
for
(;;)
{
const
char
*
res
=
match
(
ms
,
s
,
ep
+
1
);
const
char
*
res
=
match
(
ms
,
s
,
ep
+
1
);
...
@@ -326,7 +326,7 @@ static const char *ICACHE_FLASH_ATTR min_expand (MatchState *ms, const char *s,
...
@@ -326,7 +326,7 @@ static const char *ICACHE_FLASH_ATTR min_expand (MatchState *ms, const char *s,
}
}
static
const
char
*
ICACHE_FLASH_ATTR
start_capture
(
MatchState
*
ms
,
const
char
*
s
,
static
const
char
*
start_capture
(
MatchState
*
ms
,
const
char
*
s
,
const
char
*
p
,
int
what
)
{
const
char
*
p
,
int
what
)
{
const
char
*
res
;
const
char
*
res
;
int
level
=
ms
->
level
;
int
level
=
ms
->
level
;
...
@@ -340,7 +340,7 @@ static const char *ICACHE_FLASH_ATTR start_capture (MatchState *ms, const char *
...
@@ -340,7 +340,7 @@ static const char *ICACHE_FLASH_ATTR start_capture (MatchState *ms, const char *
}
}
static
const
char
*
ICACHE_FLASH_ATTR
end_capture
(
MatchState
*
ms
,
const
char
*
s
,
static
const
char
*
end_capture
(
MatchState
*
ms
,
const
char
*
s
,
const
char
*
p
)
{
const
char
*
p
)
{
int
l
=
capture_to_close
(
ms
);
int
l
=
capture_to_close
(
ms
);
const
char
*
res
;
const
char
*
res
;
...
@@ -351,7 +351,7 @@ static const char *ICACHE_FLASH_ATTR end_capture (MatchState *ms, const char *s,
...
@@ -351,7 +351,7 @@ static const char *ICACHE_FLASH_ATTR end_capture (MatchState *ms, const char *s,
}
}
static
const
char
*
ICACHE_FLASH_ATTR
match_capture
(
MatchState
*
ms
,
const
char
*
s
,
int
l
)
{
static
const
char
*
match_capture
(
MatchState
*
ms
,
const
char
*
s
,
int
l
)
{
size_t
len
;
size_t
len
;
l
=
check_capture
(
ms
,
l
);
l
=
check_capture
(
ms
,
l
);
len
=
ms
->
capture
[
l
].
len
;
len
=
ms
->
capture
[
l
].
len
;
...
@@ -362,7 +362,7 @@ static const char *ICACHE_FLASH_ATTR match_capture (MatchState *ms, const char *
...
@@ -362,7 +362,7 @@ static const char *ICACHE_FLASH_ATTR match_capture (MatchState *ms, const char *
}
}
static
const
char
*
ICACHE_FLASH_ATTR
match
(
MatchState
*
ms
,
const
char
*
s
,
const
char
*
p
)
{
static
const
char
*
match
(
MatchState
*
ms
,
const
char
*
s
,
const
char
*
p
)
{
init:
/* using goto's to optimize tail recursion */
init:
/* using goto's to optimize tail recursion */
switch
(
*
p
)
{
switch
(
*
p
)
{
case
'('
:
{
/* start capture */
case
'('
:
{
/* start capture */
...
@@ -441,7 +441,7 @@ static const char *ICACHE_FLASH_ATTR match (MatchState *ms, const char *s, const
...
@@ -441,7 +441,7 @@ static const char *ICACHE_FLASH_ATTR match (MatchState *ms, const char *s, const
static
const
char
*
ICACHE_FLASH_ATTR
lmemfind
(
const
char
*
s1
,
size_t
l1
,
static
const
char
*
lmemfind
(
const
char
*
s1
,
size_t
l1
,
const
char
*
s2
,
size_t
l2
)
{
const
char
*
s2
,
size_t
l2
)
{
if
(
l2
==
0
)
return
s1
;
/* empty strings are everywhere */
if
(
l2
==
0
)
return
s1
;
/* empty strings are everywhere */
else
if
(
l2
>
l1
)
return
NULL
;
/* avoids a negative `l1' */
else
if
(
l2
>
l1
)
return
NULL
;
/* avoids a negative `l1' */
...
@@ -463,7 +463,7 @@ static const char *ICACHE_FLASH_ATTR lmemfind (const char *s1, size_t l1,
...
@@ -463,7 +463,7 @@ static const char *ICACHE_FLASH_ATTR lmemfind (const char *s1, size_t l1,
}
}
static
void
ICACHE_FLASH_ATTR
push_onecapture
(
MatchState
*
ms
,
int
i
,
const
char
*
s
,
static
void
push_onecapture
(
MatchState
*
ms
,
int
i
,
const
char
*
s
,
const
char
*
e
)
{
const
char
*
e
)
{
if
(
i
>=
ms
->
level
)
{
if
(
i
>=
ms
->
level
)
{
if
(
i
==
0
)
/* ms->level == 0, too */
if
(
i
==
0
)
/* ms->level == 0, too */
...
@@ -482,7 +482,7 @@ static void ICACHE_FLASH_ATTR push_onecapture (MatchState *ms, int i, const char
...
@@ -482,7 +482,7 @@ static void ICACHE_FLASH_ATTR push_onecapture (MatchState *ms, int i, const char
}
}
static
int
ICACHE_FLASH_ATTR
push_captures
(
MatchState
*
ms
,
const
char
*
s
,
const
char
*
e
)
{
static
int
push_captures
(
MatchState
*
ms
,
const
char
*
s
,
const
char
*
e
)
{
int
i
;
int
i
;
int
nlevels
=
(
ms
->
level
==
0
&&
s
)
?
1
:
ms
->
level
;
int
nlevels
=
(
ms
->
level
==
0
&&
s
)
?
1
:
ms
->
level
;
luaL_checkstack
(
ms
->
L
,
nlevels
,
"too many captures"
);
luaL_checkstack
(
ms
->
L
,
nlevels
,
"too many captures"
);
...
@@ -492,7 +492,7 @@ static int ICACHE_FLASH_ATTR push_captures (MatchState *ms, const char *s, const
...
@@ -492,7 +492,7 @@ static int ICACHE_FLASH_ATTR push_captures (MatchState *ms, const char *s, const
}
}
static
int
ICACHE_FLASH_ATTR
str_find_aux
(
lua_State
*
L
,
int
find
)
{
static
int
str_find_aux
(
lua_State
*
L
,
int
find
)
{
size_t
l1
,
l2
;
size_t
l1
,
l2
;
const
char
*
s
=
luaL_checklstring
(
L
,
1
,
&
l1
);
const
char
*
s
=
luaL_checklstring
(
L
,
1
,
&
l1
);
const
char
*
p
=
luaL_checklstring
(
L
,
2
,
&
l2
);
const
char
*
p
=
luaL_checklstring
(
L
,
2
,
&
l2
);
...
@@ -535,17 +535,17 @@ static int ICACHE_FLASH_ATTR str_find_aux (lua_State *L, int find) {
...
@@ -535,17 +535,17 @@ static int ICACHE_FLASH_ATTR str_find_aux (lua_State *L, int find) {
}
}
static
int
ICACHE_FLASH_ATTR
str_find
(
lua_State
*
L
)
{
static
int
str_find
(
lua_State
*
L
)
{
return
str_find_aux
(
L
,
1
);
return
str_find_aux
(
L
,
1
);
}
}
static
int
ICACHE_FLASH_ATTR
str_match
(
lua_State
*
L
)
{
static
int
str_match
(
lua_State
*
L
)
{
return
str_find_aux
(
L
,
0
);
return
str_find_aux
(
L
,
0
);
}
}
static
int
ICACHE_FLASH_ATTR
gmatch_aux
(
lua_State
*
L
)
{
static
int
gmatch_aux
(
lua_State
*
L
)
{
MatchState
ms
;
MatchState
ms
;
size_t
ls
;
size_t
ls
;
const
char
*
s
=
lua_tolstring
(
L
,
lua_upvalueindex
(
1
),
&
ls
);
const
char
*
s
=
lua_tolstring
(
L
,
lua_upvalueindex
(
1
),
&
ls
);
...
@@ -571,7 +571,7 @@ static int ICACHE_FLASH_ATTR gmatch_aux (lua_State *L) {
...
@@ -571,7 +571,7 @@ static int ICACHE_FLASH_ATTR gmatch_aux (lua_State *L) {
}
}
static
int
ICACHE_FLASH_ATTR
gmatch
(
lua_State
*
L
)
{
static
int
gmatch
(
lua_State
*
L
)
{
luaL_checkstring
(
L
,
1
);
luaL_checkstring
(
L
,
1
);
luaL_checkstring
(
L
,
2
);
luaL_checkstring
(
L
,
2
);
lua_settop
(
L
,
2
);
lua_settop
(
L
,
2
);
...
@@ -581,13 +581,13 @@ static int ICACHE_FLASH_ATTR gmatch (lua_State *L) {
...
@@ -581,13 +581,13 @@ static int ICACHE_FLASH_ATTR gmatch (lua_State *L) {
}
}
#if LUA_OPTIMIZE_MEMORY == 0 || !defined(LUA_COMPAT_GFIND)
#if LUA_OPTIMIZE_MEMORY == 0 || !defined(LUA_COMPAT_GFIND)
static
int
ICACHE_FLASH_ATTR
gfind_nodef
(
lua_State
*
L
)
{
static
int
gfind_nodef
(
lua_State
*
L
)
{
return
luaL_error
(
L
,
LUA_QL
(
"string.gfind"
)
" was renamed to "
return
luaL_error
(
L
,
LUA_QL
(
"string.gfind"
)
" was renamed to "
LUA_QL
(
"string.gmatch"
));
LUA_QL
(
"string.gmatch"
));
}
}
#endif
#endif
static
void
ICACHE_FLASH_ATTR
add_s
(
MatchState
*
ms
,
luaL_Buffer
*
b
,
const
char
*
s
,
static
void
add_s
(
MatchState
*
ms
,
luaL_Buffer
*
b
,
const
char
*
s
,
const
char
*
e
)
{
const
char
*
e
)
{
size_t
l
,
i
;
size_t
l
,
i
;
const
char
*
news
=
lua_tolstring
(
ms
->
L
,
3
,
&
l
);
const
char
*
news
=
lua_tolstring
(
ms
->
L
,
3
,
&
l
);
...
@@ -609,7 +609,7 @@ static void ICACHE_FLASH_ATTR add_s (MatchState *ms, luaL_Buffer *b, const char
...
@@ -609,7 +609,7 @@ static void ICACHE_FLASH_ATTR add_s (MatchState *ms, luaL_Buffer *b, const char
}
}
static
void
ICACHE_FLASH_ATTR
add_value
(
MatchState
*
ms
,
luaL_Buffer
*
b
,
const
char
*
s
,
static
void
add_value
(
MatchState
*
ms
,
luaL_Buffer
*
b
,
const
char
*
s
,
const
char
*
e
)
{
const
char
*
e
)
{
lua_State
*
L
=
ms
->
L
;
lua_State
*
L
=
ms
->
L
;
switch
(
lua_type
(
L
,
3
))
{
switch
(
lua_type
(
L
,
3
))
{
...
@@ -642,7 +642,7 @@ static void ICACHE_FLASH_ATTR add_value (MatchState *ms, luaL_Buffer *b, const c
...
@@ -642,7 +642,7 @@ static void ICACHE_FLASH_ATTR add_value (MatchState *ms, luaL_Buffer *b, const c
}
}
static
int
ICACHE_FLASH_ATTR
str_gsub
(
lua_State
*
L
)
{
static
int
str_gsub
(
lua_State
*
L
)
{
size_t
srcl
;
size_t
srcl
;
const
char
*
src
=
luaL_checklstring
(
L
,
1
,
&
srcl
);
const
char
*
src
=
luaL_checklstring
(
L
,
1
,
&
srcl
);
const
char
*
p
=
luaL_checkstring
(
L
,
2
);
const
char
*
p
=
luaL_checkstring
(
L
,
2
);
...
@@ -696,7 +696,7 @@ static int ICACHE_FLASH_ATTR str_gsub (lua_State *L) {
...
@@ -696,7 +696,7 @@ static int ICACHE_FLASH_ATTR str_gsub (lua_State *L) {
#define MAX_FORMAT (sizeof(FLAGS) + sizeof(LUA_INTFRMLEN) + 10)
#define MAX_FORMAT (sizeof(FLAGS) + sizeof(LUA_INTFRMLEN) + 10)
static
void
ICACHE_FLASH_ATTR
addquoted
(
lua_State
*
L
,
luaL_Buffer
*
b
,
int
arg
)
{
static
void
addquoted
(
lua_State
*
L
,
luaL_Buffer
*
b
,
int
arg
)
{
size_t
l
;
size_t
l
;
const
char
*
s
=
luaL_checklstring
(
L
,
arg
,
&
l
);
const
char
*
s
=
luaL_checklstring
(
L
,
arg
,
&
l
);
luaL_addchar
(
b
,
'"'
);
luaL_addchar
(
b
,
'"'
);
...
@@ -725,7 +725,7 @@ static void ICACHE_FLASH_ATTR addquoted (lua_State *L, luaL_Buffer *b, int arg)
...
@@ -725,7 +725,7 @@ static void ICACHE_FLASH_ATTR addquoted (lua_State *L, luaL_Buffer *b, int arg)
luaL_addchar
(
b
,
'"'
);
luaL_addchar
(
b
,
'"'
);
}
}
static
const
char
*
ICACHE_FLASH_ATTR
scanformat
(
lua_State
*
L
,
const
char
*
strfrmt
,
char
*
form
)
{
static
const
char
*
scanformat
(
lua_State
*
L
,
const
char
*
strfrmt
,
char
*
form
)
{
const
char
*
p
=
strfrmt
;
const
char
*
p
=
strfrmt
;
while
(
*
p
!=
'\0'
&&
c_strchr
(
FLAGS
,
*
p
)
!=
NULL
)
p
++
;
/* skip flags */
while
(
*
p
!=
'\0'
&&
c_strchr
(
FLAGS
,
*
p
)
!=
NULL
)
p
++
;
/* skip flags */
if
((
size_t
)(
p
-
strfrmt
)
>=
sizeof
(
FLAGS
))
if
((
size_t
)(
p
-
strfrmt
)
>=
sizeof
(
FLAGS
))
...
@@ -747,7 +747,7 @@ static const char *ICACHE_FLASH_ATTR scanformat (lua_State *L, const char *strfr
...
@@ -747,7 +747,7 @@ static const char *ICACHE_FLASH_ATTR scanformat (lua_State *L, const char *strfr
}
}
static
void
ICACHE_FLASH_ATTR
addintlen
(
char
*
form
)
{
static
void
addintlen
(
char
*
form
)
{
size_t
l
=
c_strlen
(
form
);
size_t
l
=
c_strlen
(
form
);
char
spec
=
form
[
l
-
1
];
char
spec
=
form
[
l
-
1
];
c_strcpy
(
form
+
l
-
1
,
LUA_INTFRMLEN
);
c_strcpy
(
form
+
l
-
1
,
LUA_INTFRMLEN
);
...
@@ -756,7 +756,7 @@ static void ICACHE_FLASH_ATTR addintlen (char *form) {
...
@@ -756,7 +756,7 @@ static void ICACHE_FLASH_ATTR addintlen (char *form) {
}
}
static
int
ICACHE_FLASH_ATTR
str_format
(
lua_State
*
L
)
{
static
int
str_format
(
lua_State
*
L
)
{
int
top
=
lua_gettop
(
L
);
int
top
=
lua_gettop
(
L
);
int
arg
=
1
;
int
arg
=
1
;
size_t
sfl
;
size_t
sfl
;
...
@@ -858,7 +858,7 @@ const LUA_REG_TYPE strlib[] = {
...
@@ -858,7 +858,7 @@ const LUA_REG_TYPE strlib[] = {
#if LUA_OPTIMIZE_MEMORY != 2
#if LUA_OPTIMIZE_MEMORY != 2
static
void
ICACHE_FLASH_ATTR
createmetatable
(
lua_State
*
L
)
{
static
void
createmetatable
(
lua_State
*
L
)
{
lua_createtable
(
L
,
0
,
1
);
/* create metatable for strings */
lua_createtable
(
L
,
0
,
1
);
/* create metatable for strings */
lua_pushliteral
(
L
,
""
);
/* dummy string */
lua_pushliteral
(
L
,
""
);
/* dummy string */
lua_pushvalue
(
L
,
-
2
);
lua_pushvalue
(
L
,
-
2
);
...
@@ -873,7 +873,7 @@ static void ICACHE_FLASH_ATTR createmetatable (lua_State *L) {
...
@@ -873,7 +873,7 @@ static void ICACHE_FLASH_ATTR createmetatable (lua_State *L) {
/*
/*
** Open string library
** Open string library
*/
*/
LUALIB_API
int
ICACHE_FLASH_ATTR
luaopen_string
(
lua_State
*
L
)
{
LUALIB_API
int
luaopen_string
(
lua_State
*
L
)
{
#if LUA_OPTIMIZE_MEMORY == 0
#if LUA_OPTIMIZE_MEMORY == 0
luaL_register
(
L
,
LUA_STRLIBNAME
,
strlib
);
luaL_register
(
L
,
LUA_STRLIBNAME
,
strlib
);
#if defined(LUA_COMPAT_GFIND)
#if defined(LUA_COMPAT_GFIND)
...
...
app/lua/ltable.c
View file @
c04f2578
...
@@ -81,7 +81,7 @@ static const Node dummynode_ = {
...
@@ -81,7 +81,7 @@ static const Node dummynode_ = {
/*
/*
** hash for lua_Numbers
** hash for lua_Numbers
*/
*/
static
Node
*
ICACHE_FLASH_ATTR
hashnum
(
const
Table
*
t
,
lua_Number
n
)
{
static
Node
*
hashnum
(
const
Table
*
t
,
lua_Number
n
)
{
unsigned
int
a
[
numints
];
unsigned
int
a
[
numints
];
int
i
;
int
i
;
if
(
luai_numeq
(
n
,
0
))
/* avoid problems with -0 */
if
(
luai_numeq
(
n
,
0
))
/* avoid problems with -0 */
...
@@ -97,7 +97,7 @@ static Node *ICACHE_FLASH_ATTR hashnum (const Table *t, lua_Number n) {
...
@@ -97,7 +97,7 @@ static Node *ICACHE_FLASH_ATTR hashnum (const Table *t, lua_Number n) {
** returns the `main' position of an element in a table (that is, the index
** returns the `main' position of an element in a table (that is, the index
** of its hash value)
** of its hash value)
*/
*/
static
Node
*
ICACHE_FLASH_ATTR
mainposition
(
const
Table
*
t
,
const
TValue
*
key
)
{
static
Node
*
mainposition
(
const
Table
*
t
,
const
TValue
*
key
)
{
switch
(
ttype
(
key
))
{
switch
(
ttype
(
key
))
{
case
LUA_TNUMBER
:
case
LUA_TNUMBER
:
return
hashnum
(
t
,
nvalue
(
key
));
return
hashnum
(
t
,
nvalue
(
key
));
...
@@ -119,7 +119,7 @@ static Node *ICACHE_FLASH_ATTR mainposition (const Table *t, const TValue *key)
...
@@ -119,7 +119,7 @@ static Node *ICACHE_FLASH_ATTR mainposition (const Table *t, const TValue *key)
** returns the index for `key' if `key' is an appropriate key to live in
** returns the index for `key' if `key' is an appropriate key to live in
** the array part of the table, -1 otherwise.
** the array part of the table, -1 otherwise.
*/
*/
static
int
ICACHE_FLASH_ATTR
arrayindex
(
const
TValue
*
key
)
{
static
int
arrayindex
(
const
TValue
*
key
)
{
if
(
ttisnumber
(
key
))
{
if
(
ttisnumber
(
key
))
{
lua_Number
n
=
nvalue
(
key
);
lua_Number
n
=
nvalue
(
key
);
int
k
;
int
k
;
...
@@ -136,7 +136,7 @@ static int ICACHE_FLASH_ATTR arrayindex (const TValue *key) {
...
@@ -136,7 +136,7 @@ static int ICACHE_FLASH_ATTR arrayindex (const TValue *key) {
** elements in the array part, then elements in the hash part. The
** elements in the array part, then elements in the hash part. The
** beginning of a traversal is signalled by -1.
** beginning of a traversal is signalled by -1.
*/
*/
static
int
ICACHE_FLASH_ATTR
findindex
(
lua_State
*
L
,
Table
*
t
,
StkId
key
)
{
static
int
findindex
(
lua_State
*
L
,
Table
*
t
,
StkId
key
)
{
int
i
;
int
i
;
if
(
ttisnil
(
key
))
return
-
1
;
/* first iteration */
if
(
ttisnil
(
key
))
return
-
1
;
/* first iteration */
i
=
arrayindex
(
key
);
i
=
arrayindex
(
key
);
...
@@ -161,7 +161,7 @@ static int ICACHE_FLASH_ATTR findindex (lua_State *L, Table *t, StkId key) {
...
@@ -161,7 +161,7 @@ static int ICACHE_FLASH_ATTR findindex (lua_State *L, Table *t, StkId key) {
}
}
int
ICACHE_FLASH_ATTR
luaH_next
(
lua_State
*
L
,
Table
*
t
,
StkId
key
)
{
int
luaH_next
(
lua_State
*
L
,
Table
*
t
,
StkId
key
)
{
int
i
=
findindex
(
L
,
t
,
key
);
/* find original element */
int
i
=
findindex
(
L
,
t
,
key
);
/* find original element */
for
(
i
++
;
i
<
t
->
sizearray
;
i
++
)
{
/* try first array part */
for
(
i
++
;
i
<
t
->
sizearray
;
i
++
)
{
/* try first array part */
if
(
!
ttisnil
(
&
t
->
array
[
i
]))
{
/* a non-nil value? */
if
(
!
ttisnil
(
&
t
->
array
[
i
]))
{
/* a non-nil value? */
...
@@ -181,7 +181,7 @@ int ICACHE_FLASH_ATTR luaH_next (lua_State *L, Table *t, StkId key) {
...
@@ -181,7 +181,7 @@ int ICACHE_FLASH_ATTR luaH_next (lua_State *L, Table *t, StkId key) {
}
}
int
ICACHE_FLASH_ATTR
luaH_next_ro
(
lua_State
*
L
,
void
*
t
,
StkId
key
)
{
int
luaH_next_ro
(
lua_State
*
L
,
void
*
t
,
StkId
key
)
{
luaR_next
(
L
,
t
,
key
,
key
+
1
);
luaR_next
(
L
,
t
,
key
,
key
+
1
);
return
ttisnil
(
key
)
?
0
:
1
;
return
ttisnil
(
key
)
?
0
:
1
;
}
}
...
@@ -194,7 +194,7 @@ int ICACHE_FLASH_ATTR luaH_next_ro (lua_State *L, void *t, StkId key) {
...
@@ -194,7 +194,7 @@ int ICACHE_FLASH_ATTR luaH_next_ro (lua_State *L, void *t, StkId key) {
*/
*/
static
int
ICACHE_FLASH_ATTR
computesizes
(
int
nums
[],
int
*
narray
)
{
static
int
computesizes
(
int
nums
[],
int
*
narray
)
{
int
i
;
int
i
;
int
twotoi
;
/* 2^i */
int
twotoi
;
/* 2^i */
int
a
=
0
;
/* number of elements smaller than 2^i */
int
a
=
0
;
/* number of elements smaller than 2^i */
...
@@ -216,7 +216,7 @@ static int ICACHE_FLASH_ATTR computesizes (int nums[], int *narray) {
...
@@ -216,7 +216,7 @@ static int ICACHE_FLASH_ATTR computesizes (int nums[], int *narray) {
}
}
static
int
ICACHE_FLASH_ATTR
countint
(
const
TValue
*
key
,
int
*
nums
)
{
static
int
countint
(
const
TValue
*
key
,
int
*
nums
)
{
int
k
=
arrayindex
(
key
);
int
k
=
arrayindex
(
key
);
if
(
0
<
k
&&
k
<=
MAXASIZE
)
{
/* is `key' an appropriate array index? */
if
(
0
<
k
&&
k
<=
MAXASIZE
)
{
/* is `key' an appropriate array index? */
nums
[
ceillog2
(
k
)]
++
;
/* count as such */
nums
[
ceillog2
(
k
)]
++
;
/* count as such */
...
@@ -227,7 +227,7 @@ static int ICACHE_FLASH_ATTR countint (const TValue *key, int *nums) {
...
@@ -227,7 +227,7 @@ static int ICACHE_FLASH_ATTR countint (const TValue *key, int *nums) {
}
}
static
int
ICACHE_FLASH_ATTR
numusearray
(
const
Table
*
t
,
int
*
nums
)
{
static
int
numusearray
(
const
Table
*
t
,
int
*
nums
)
{
int
lg
;
int
lg
;
int
ttlg
;
/* 2^lg */
int
ttlg
;
/* 2^lg */
int
ause
=
0
;
/* summation of `nums' */
int
ause
=
0
;
/* summation of `nums' */
...
@@ -252,7 +252,7 @@ static int ICACHE_FLASH_ATTR numusearray (const Table *t, int *nums) {
...
@@ -252,7 +252,7 @@ static int ICACHE_FLASH_ATTR numusearray (const Table *t, int *nums) {
}
}
static
int
ICACHE_FLASH_ATTR
numusehash
(
const
Table
*
t
,
int
*
nums
,
int
*
pnasize
)
{
static
int
numusehash
(
const
Table
*
t
,
int
*
nums
,
int
*
pnasize
)
{
int
totaluse
=
0
;
/* total number of elements */
int
totaluse
=
0
;
/* total number of elements */
int
ause
=
0
;
/* summation of `nums' */
int
ause
=
0
;
/* summation of `nums' */
int
i
=
sizenode
(
t
);
int
i
=
sizenode
(
t
);
...
@@ -268,7 +268,7 @@ static int ICACHE_FLASH_ATTR numusehash (const Table *t, int *nums, int *pnasize
...
@@ -268,7 +268,7 @@ static int ICACHE_FLASH_ATTR numusehash (const Table *t, int *nums, int *pnasize
}
}
static
void
ICACHE_FLASH_ATTR
setarrayvector
(
lua_State
*
L
,
Table
*
t
,
int
size
)
{
static
void
setarrayvector
(
lua_State
*
L
,
Table
*
t
,
int
size
)
{
int
i
;
int
i
;
luaM_reallocvector
(
L
,
t
->
array
,
t
->
sizearray
,
size
,
TValue
);
luaM_reallocvector
(
L
,
t
->
array
,
t
->
sizearray
,
size
,
TValue
);
for
(
i
=
t
->
sizearray
;
i
<
size
;
i
++
)
for
(
i
=
t
->
sizearray
;
i
<
size
;
i
++
)
...
@@ -277,7 +277,7 @@ static void ICACHE_FLASH_ATTR setarrayvector (lua_State *L, Table *t, int size)
...
@@ -277,7 +277,7 @@ static void ICACHE_FLASH_ATTR setarrayvector (lua_State *L, Table *t, int size)
}
}
static
Node
*
ICACHE_FLASH_ATTR
getfreepos
(
Table
*
t
)
{
static
Node
*
getfreepos
(
Table
*
t
)
{
while
(
t
->
lastfree
--
>
t
->
node
)
{
while
(
t
->
lastfree
--
>
t
->
node
)
{
if
(
ttisnil
(
gkey
(
t
->
lastfree
)))
if
(
ttisnil
(
gkey
(
t
->
lastfree
)))
return
t
->
lastfree
;
return
t
->
lastfree
;
...
@@ -286,7 +286,7 @@ static Node *ICACHE_FLASH_ATTR getfreepos (Table *t) {
...
@@ -286,7 +286,7 @@ static Node *ICACHE_FLASH_ATTR getfreepos (Table *t) {
}
}
static
void
ICACHE_FLASH_ATTR
resizenodevector
(
lua_State
*
L
,
Table
*
t
,
int
oldsize
,
int
newsize
)
{
static
void
resizenodevector
(
lua_State
*
L
,
Table
*
t
,
int
oldsize
,
int
newsize
)
{
int
lsize
;
int
lsize
;
if
(
newsize
==
0
)
{
/* no elements to hash part? */
if
(
newsize
==
0
)
{
/* no elements to hash part? */
t
->
node
=
cast
(
Node
*
,
dummynode
);
/* use common `dummynode' */
t
->
node
=
cast
(
Node
*
,
dummynode
);
/* use common `dummynode' */
...
@@ -317,7 +317,7 @@ static void ICACHE_FLASH_ATTR resizenodevector (lua_State *L, Table *t, int olds
...
@@ -317,7 +317,7 @@ static void ICACHE_FLASH_ATTR resizenodevector (lua_State *L, Table *t, int olds
}
}
static
Node
*
ICACHE_FLASH_ATTR
find_prev_node
(
Node
*
mp
,
Node
*
next
)
{
static
Node
*
find_prev_node
(
Node
*
mp
,
Node
*
next
)
{
Node
*
prev
=
mp
;
Node
*
prev
=
mp
;
while
(
prev
!=
NULL
&&
gnext
(
prev
)
!=
next
)
prev
=
gnext
(
prev
);
while
(
prev
!=
NULL
&&
gnext
(
prev
)
!=
next
)
prev
=
gnext
(
prev
);
return
prev
;
return
prev
;
...
@@ -331,7 +331,7 @@ static Node *ICACHE_FLASH_ATTR find_prev_node(Node *mp, Node *next) {
...
@@ -331,7 +331,7 @@ static Node *ICACHE_FLASH_ATTR find_prev_node(Node *mp, Node *next) {
** node to an empty place and put moving node in its main position; otherwise
** node to an empty place and put moving node in its main position; otherwise
** (colliding node is in its main position), moving node goes to an empty position.
** (colliding node is in its main position), moving node goes to an empty position.
*/
*/
static
int
ICACHE_FLASH_ATTR
move_node
(
lua_State
*
L
,
Table
*
t
,
Node
*
node
)
{
static
int
move_node
(
lua_State
*
L
,
Table
*
t
,
Node
*
node
)
{
Node
*
mp
=
mainposition
(
t
,
key2tval
(
node
));
Node
*
mp
=
mainposition
(
t
,
key2tval
(
node
));
/* if node is in it's main position, don't need to move node. */
/* if node is in it's main position, don't need to move node. */
if
(
mp
==
node
)
return
1
;
if
(
mp
==
node
)
return
1
;
...
@@ -369,7 +369,7 @@ static int ICACHE_FLASH_ATTR move_node (lua_State *L, Table *t, Node *node) {
...
@@ -369,7 +369,7 @@ static int ICACHE_FLASH_ATTR move_node (lua_State *L, Table *t, Node *node) {
}
}
static
int
ICACHE_FLASH_ATTR
move_number
(
lua_State
*
L
,
Table
*
t
,
Node
*
node
)
{
static
int
move_number
(
lua_State
*
L
,
Table
*
t
,
Node
*
node
)
{
int
key
;
int
key
;
lua_Number
n
=
nvalue
(
key2tval
(
node
));
lua_Number
n
=
nvalue
(
key2tval
(
node
));
lua_number2int
(
key
,
n
);
lua_number2int
(
key
,
n
);
...
@@ -386,7 +386,7 @@ static int ICACHE_FLASH_ATTR move_number (lua_State *L, Table *t, Node *node) {
...
@@ -386,7 +386,7 @@ static int ICACHE_FLASH_ATTR move_number (lua_State *L, Table *t, Node *node) {
}
}
static
void
ICACHE_FLASH_ATTR
resize_hashpart
(
lua_State
*
L
,
Table
*
t
,
int
nhsize
)
{
static
void
resize_hashpart
(
lua_State
*
L
,
Table
*
t
,
int
nhsize
)
{
int
i
;
int
i
;
int
lsize
=
0
;
int
lsize
=
0
;
int
oldhsize
=
(
t
->
node
!=
dummynode
)
?
twoto
(
t
->
lsizenode
)
:
0
;
int
oldhsize
=
(
t
->
node
!=
dummynode
)
?
twoto
(
t
->
lsizenode
)
:
0
;
...
@@ -439,7 +439,7 @@ static void ICACHE_FLASH_ATTR resize_hashpart (lua_State *L, Table *t, int nhsiz
...
@@ -439,7 +439,7 @@ static void ICACHE_FLASH_ATTR resize_hashpart (lua_State *L, Table *t, int nhsiz
}
}
static
void
ICACHE_FLASH_ATTR
resize
(
lua_State
*
L
,
Table
*
t
,
int
nasize
,
int
nhsize
)
{
static
void
resize
(
lua_State
*
L
,
Table
*
t
,
int
nasize
,
int
nhsize
)
{
int
i
;
int
i
;
int
oldasize
=
t
->
sizearray
;
int
oldasize
=
t
->
sizearray
;
if
(
nasize
>
oldasize
)
/* array part must grow? */
if
(
nasize
>
oldasize
)
/* array part must grow? */
...
@@ -458,13 +458,13 @@ static void ICACHE_FLASH_ATTR resize (lua_State *L, Table *t, int nasize, int nh
...
@@ -458,13 +458,13 @@ static void ICACHE_FLASH_ATTR resize (lua_State *L, Table *t, int nasize, int nh
}
}
void
ICACHE_FLASH_ATTR
luaH_resizearray
(
lua_State
*
L
,
Table
*
t
,
int
nasize
)
{
void
luaH_resizearray
(
lua_State
*
L
,
Table
*
t
,
int
nasize
)
{
int
nsize
=
(
t
->
node
==
dummynode
)
?
0
:
sizenode
(
t
);
int
nsize
=
(
t
->
node
==
dummynode
)
?
0
:
sizenode
(
t
);
resize
(
L
,
t
,
nasize
,
nsize
);
resize
(
L
,
t
,
nasize
,
nsize
);
}
}
static
void
ICACHE_FLASH_ATTR
rehash
(
lua_State
*
L
,
Table
*
t
,
const
TValue
*
ek
)
{
static
void
rehash
(
lua_State
*
L
,
Table
*
t
,
const
TValue
*
ek
)
{
int
nasize
,
na
;
int
nasize
,
na
;
int
nums
[
MAXBITS
+
1
];
/* nums[i] = number of keys between 2^(i-1) and 2^i */
int
nums
[
MAXBITS
+
1
];
/* nums[i] = number of keys between 2^(i-1) and 2^i */
int
i
;
int
i
;
...
@@ -489,7 +489,7 @@ static void ICACHE_FLASH_ATTR rehash (lua_State *L, Table *t, const TValue *ek)
...
@@ -489,7 +489,7 @@ static void ICACHE_FLASH_ATTR rehash (lua_State *L, Table *t, const TValue *ek)
*/
*/
Table
*
ICACHE_FLASH_ATTR
luaH_new
(
lua_State
*
L
,
int
narray
,
int
nhash
)
{
Table
*
luaH_new
(
lua_State
*
L
,
int
narray
,
int
nhash
)
{
Table
*
t
=
luaM_new
(
L
,
Table
);
Table
*
t
=
luaM_new
(
L
,
Table
);
luaC_link
(
L
,
obj2gco
(
t
),
LUA_TTABLE
);
luaC_link
(
L
,
obj2gco
(
t
),
LUA_TTABLE
);
sethvalue2s
(
L
,
L
->
top
,
t
);
/* put table on stack */
sethvalue2s
(
L
,
L
->
top
,
t
);
/* put table on stack */
...
@@ -508,7 +508,7 @@ Table *ICACHE_FLASH_ATTR luaH_new (lua_State *L, int narray, int nhash) {
...
@@ -508,7 +508,7 @@ Table *ICACHE_FLASH_ATTR luaH_new (lua_State *L, int narray, int nhash) {
}
}
void
ICACHE_FLASH_ATTR
luaH_free
(
lua_State
*
L
,
Table
*
t
)
{
void
luaH_free
(
lua_State
*
L
,
Table
*
t
)
{
if
(
t
->
node
!=
dummynode
)
if
(
t
->
node
!=
dummynode
)
luaM_freearray
(
L
,
t
->
node
,
sizenode
(
t
),
Node
);
luaM_freearray
(
L
,
t
->
node
,
sizenode
(
t
),
Node
);
luaM_freearray
(
L
,
t
->
array
,
t
->
sizearray
,
TValue
);
luaM_freearray
(
L
,
t
->
array
,
t
->
sizearray
,
TValue
);
...
@@ -524,7 +524,7 @@ void ICACHE_FLASH_ATTR luaH_free (lua_State *L, Table *t) {
...
@@ -524,7 +524,7 @@ void ICACHE_FLASH_ATTR luaH_free (lua_State *L, Table *t) {
** put new key in its main position; otherwise (colliding node is in its main
** put new key in its main position; otherwise (colliding node is in its main
** position), new key goes to an empty position.
** position), new key goes to an empty position.
*/
*/
static
TValue
*
ICACHE_FLASH_ATTR
newkey
(
lua_State
*
L
,
Table
*
t
,
const
TValue
*
key
)
{
static
TValue
*
newkey
(
lua_State
*
L
,
Table
*
t
,
const
TValue
*
key
)
{
Node
*
mp
=
mainposition
(
t
,
key
);
Node
*
mp
=
mainposition
(
t
,
key
);
if
(
!
ttisnil
(
gval
(
mp
))
||
mp
==
dummynode
)
{
if
(
!
ttisnil
(
gval
(
mp
))
||
mp
==
dummynode
)
{
Node
*
othern
;
Node
*
othern
;
...
@@ -560,7 +560,7 @@ static TValue *ICACHE_FLASH_ATTR newkey (lua_State *L, Table *t, const TValue *k
...
@@ -560,7 +560,7 @@ static TValue *ICACHE_FLASH_ATTR newkey (lua_State *L, Table *t, const TValue *k
/*
/*
** search function for integers
** search function for integers
*/
*/
const
TValue
*
ICACHE_FLASH_ATTR
luaH_getnum
(
Table
*
t
,
int
key
)
{
const
TValue
*
luaH_getnum
(
Table
*
t
,
int
key
)
{
/* (1 <= key && key <= t->sizearray) */
/* (1 <= key && key <= t->sizearray) */
if
(
cast
(
unsigned
int
,
key
-
1
)
<
cast
(
unsigned
int
,
t
->
sizearray
))
if
(
cast
(
unsigned
int
,
key
-
1
)
<
cast
(
unsigned
int
,
t
->
sizearray
))
return
&
t
->
array
[
key
-
1
];
return
&
t
->
array
[
key
-
1
];
...
@@ -577,7 +577,7 @@ const TValue *ICACHE_FLASH_ATTR luaH_getnum (Table *t, int key) {
...
@@ -577,7 +577,7 @@ const TValue *ICACHE_FLASH_ATTR luaH_getnum (Table *t, int key) {
}
}
/* same thing for rotables */
/* same thing for rotables */
const
TValue
*
ICACHE_FLASH_ATTR
luaH_getnum_ro
(
void
*
t
,
int
key
)
{
const
TValue
*
luaH_getnum_ro
(
void
*
t
,
int
key
)
{
const
TValue
*
res
=
luaR_findentry
(
t
,
NULL
,
key
,
NULL
);
const
TValue
*
res
=
luaR_findentry
(
t
,
NULL
,
key
,
NULL
);
return
res
?
res
:
luaO_nilobject
;
return
res
?
res
:
luaO_nilobject
;
}
}
...
@@ -586,7 +586,7 @@ const TValue *ICACHE_FLASH_ATTR luaH_getnum_ro (void *t, int key) {
...
@@ -586,7 +586,7 @@ const TValue *ICACHE_FLASH_ATTR luaH_getnum_ro (void *t, int key) {
/*
/*
** search function for strings
** search function for strings
*/
*/
const
TValue
*
ICACHE_FLASH_ATTR
luaH_getstr
(
Table
*
t
,
TString
*
key
)
{
const
TValue
*
luaH_getstr
(
Table
*
t
,
TString
*
key
)
{
Node
*
n
=
hashstr
(
t
,
key
);
Node
*
n
=
hashstr
(
t
,
key
);
do
{
/* check whether `key' is somewhere in the chain */
do
{
/* check whether `key' is somewhere in the chain */
if
(
ttisstring
(
gkey
(
n
))
&&
rawtsvalue
(
gkey
(
n
))
==
key
)
if
(
ttisstring
(
gkey
(
n
))
&&
rawtsvalue
(
gkey
(
n
))
==
key
)
...
@@ -597,7 +597,7 @@ const TValue *ICACHE_FLASH_ATTR luaH_getstr (Table *t, TString *key) {
...
@@ -597,7 +597,7 @@ const TValue *ICACHE_FLASH_ATTR luaH_getstr (Table *t, TString *key) {
}
}
/* same thing for rotables */
/* same thing for rotables */
const
TValue
*
ICACHE_FLASH_ATTR
luaH_getstr_ro
(
void
*
t
,
TString
*
key
)
{
const
TValue
*
luaH_getstr_ro
(
void
*
t
,
TString
*
key
)
{
char
keyname
[
LUA_MAX_ROTABLE_NAME
+
1
];
char
keyname
[
LUA_MAX_ROTABLE_NAME
+
1
];
const
TValue
*
res
;
const
TValue
*
res
;
if
(
!
t
)
if
(
!
t
)
...
@@ -611,7 +611,7 @@ const TValue *ICACHE_FLASH_ATTR luaH_getstr_ro (void *t, TString *key) {
...
@@ -611,7 +611,7 @@ const TValue *ICACHE_FLASH_ATTR luaH_getstr_ro (void *t, TString *key) {
/*
/*
** main search function
** main search function
*/
*/
const
TValue
*
ICACHE_FLASH_ATTR
luaH_get
(
Table
*
t
,
const
TValue
*
key
)
{
const
TValue
*
luaH_get
(
Table
*
t
,
const
TValue
*
key
)
{
switch
(
ttype
(
key
))
{
switch
(
ttype
(
key
))
{
case
LUA_TNIL
:
return
luaO_nilobject
;
case
LUA_TNIL
:
return
luaO_nilobject
;
case
LUA_TSTRING
:
return
luaH_getstr
(
t
,
rawtsvalue
(
key
));
case
LUA_TSTRING
:
return
luaH_getstr
(
t
,
rawtsvalue
(
key
));
...
@@ -636,7 +636,7 @@ const TValue *ICACHE_FLASH_ATTR luaH_get (Table *t, const TValue *key) {
...
@@ -636,7 +636,7 @@ const TValue *ICACHE_FLASH_ATTR luaH_get (Table *t, const TValue *key) {
}
}
/* same thing for rotables */
/* same thing for rotables */
const
TValue
*
ICACHE_FLASH_ATTR
luaH_get_ro
(
void
*
t
,
const
TValue
*
key
)
{
const
TValue
*
luaH_get_ro
(
void
*
t
,
const
TValue
*
key
)
{
switch
(
ttype
(
key
))
{
switch
(
ttype
(
key
))
{
case
LUA_TNIL
:
return
luaO_nilobject
;
case
LUA_TNIL
:
return
luaO_nilobject
;
case
LUA_TSTRING
:
return
luaH_getstr_ro
(
t
,
rawtsvalue
(
key
));
case
LUA_TSTRING
:
return
luaH_getstr_ro
(
t
,
rawtsvalue
(
key
));
...
@@ -655,7 +655,7 @@ const TValue *ICACHE_FLASH_ATTR luaH_get_ro (void *t, const TValue *key) {
...
@@ -655,7 +655,7 @@ const TValue *ICACHE_FLASH_ATTR luaH_get_ro (void *t, const TValue *key) {
}
}
TValue
*
ICACHE_FLASH_ATTR
luaH_set
(
lua_State
*
L
,
Table
*
t
,
const
TValue
*
key
)
{
TValue
*
luaH_set
(
lua_State
*
L
,
Table
*
t
,
const
TValue
*
key
)
{
const
TValue
*
p
=
luaH_get
(
t
,
key
);
const
TValue
*
p
=
luaH_get
(
t
,
key
);
t
->
flags
=
0
;
t
->
flags
=
0
;
if
(
p
!=
luaO_nilobject
)
if
(
p
!=
luaO_nilobject
)
...
@@ -669,7 +669,7 @@ TValue *ICACHE_FLASH_ATTR luaH_set (lua_State *L, Table *t, const TValue *key) {
...
@@ -669,7 +669,7 @@ TValue *ICACHE_FLASH_ATTR luaH_set (lua_State *L, Table *t, const TValue *key) {
}
}
TValue
*
ICACHE_FLASH_ATTR
luaH_setnum
(
lua_State
*
L
,
Table
*
t
,
int
key
)
{
TValue
*
luaH_setnum
(
lua_State
*
L
,
Table
*
t
,
int
key
)
{
const
TValue
*
p
=
luaH_getnum
(
t
,
key
);
const
TValue
*
p
=
luaH_getnum
(
t
,
key
);
if
(
p
!=
luaO_nilobject
)
if
(
p
!=
luaO_nilobject
)
return
cast
(
TValue
*
,
p
);
return
cast
(
TValue
*
,
p
);
...
@@ -681,7 +681,7 @@ TValue *ICACHE_FLASH_ATTR luaH_setnum (lua_State *L, Table *t, int key) {
...
@@ -681,7 +681,7 @@ TValue *ICACHE_FLASH_ATTR luaH_setnum (lua_State *L, Table *t, int key) {
}
}
TValue
*
ICACHE_FLASH_ATTR
luaH_setstr
(
lua_State
*
L
,
Table
*
t
,
TString
*
key
)
{
TValue
*
luaH_setstr
(
lua_State
*
L
,
Table
*
t
,
TString
*
key
)
{
const
TValue
*
p
=
luaH_getstr
(
t
,
key
);
const
TValue
*
p
=
luaH_getstr
(
t
,
key
);
if
(
p
!=
luaO_nilobject
)
if
(
p
!=
luaO_nilobject
)
return
cast
(
TValue
*
,
p
);
return
cast
(
TValue
*
,
p
);
...
@@ -693,7 +693,7 @@ TValue *ICACHE_FLASH_ATTR luaH_setstr (lua_State *L, Table *t, TString *key) {
...
@@ -693,7 +693,7 @@ TValue *ICACHE_FLASH_ATTR luaH_setstr (lua_State *L, Table *t, TString *key) {
}
}
static
int
ICACHE_FLASH_ATTR
unbound_search
(
Table
*
t
,
unsigned
int
j
)
{
static
int
unbound_search
(
Table
*
t
,
unsigned
int
j
)
{
unsigned
int
i
=
j
;
/* i is zero or a present index */
unsigned
int
i
=
j
;
/* i is zero or a present index */
j
++
;
j
++
;
/* find `i' and `j' such that i is present and j is not */
/* find `i' and `j' such that i is present and j is not */
...
@@ -721,7 +721,7 @@ static int ICACHE_FLASH_ATTR unbound_search (Table *t, unsigned int j) {
...
@@ -721,7 +721,7 @@ static int ICACHE_FLASH_ATTR unbound_search (Table *t, unsigned int j) {
** Try to find a boundary in table `t'. A `boundary' is an integer index
** Try to find a boundary in table `t'. A `boundary' is an integer index
** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil).
** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil).
*/
*/
int
ICACHE_FLASH_ATTR
luaH_getn
(
Table
*
t
)
{
int
luaH_getn
(
Table
*
t
)
{
unsigned
int
j
=
t
->
sizearray
;
unsigned
int
j
=
t
->
sizearray
;
if
(
j
>
0
&&
ttisnil
(
&
t
->
array
[
j
-
1
]))
{
if
(
j
>
0
&&
ttisnil
(
&
t
->
array
[
j
-
1
]))
{
/* there is a boundary in the array part: (binary) search for it */
/* there is a boundary in the array part: (binary) search for it */
...
@@ -740,7 +740,7 @@ int ICACHE_FLASH_ATTR luaH_getn (Table *t) {
...
@@ -740,7 +740,7 @@ int ICACHE_FLASH_ATTR luaH_getn (Table *t) {
}
}
/* same thing for rotables */
/* same thing for rotables */
int
ICACHE_FLASH_ATTR
luaH_getn_ro
(
void
*
t
)
{
int
luaH_getn_ro
(
void
*
t
)
{
int
i
=
1
,
len
=
0
;
int
i
=
1
,
len
=
0
;
while
(
luaR_findentry
(
t
,
NULL
,
i
++
,
NULL
))
while
(
luaR_findentry
(
t
,
NULL
,
i
++
,
NULL
))
...
@@ -750,10 +750,10 @@ int ICACHE_FLASH_ATTR luaH_getn_ro (void *t) {
...
@@ -750,10 +750,10 @@ int ICACHE_FLASH_ATTR luaH_getn_ro (void *t) {
#if defined(LUA_DEBUG)
#if defined(LUA_DEBUG)
Node
*
ICACHE_FLASH_ATTR
luaH_mainposition
(
const
Table
*
t
,
const
TValue
*
key
)
{
Node
*
luaH_mainposition
(
const
Table
*
t
,
const
TValue
*
key
)
{
return
mainposition
(
t
,
key
);
return
mainposition
(
t
,
key
);
}
}
int
ICACHE_FLASH_ATTR
luaH_isdummy
(
Node
*
n
)
{
return
n
==
dummynode
;
}
int
luaH_isdummy
(
Node
*
n
)
{
return
n
==
dummynode
;
}
#endif
#endif
app/lua/ltablib.c
View file @
c04f2578
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
#define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), luaL_getn(L, n))
#define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), luaL_getn(L, n))
static
int
ICACHE_FLASH_ATTR
foreachi
(
lua_State
*
L
)
{
static
int
foreachi
(
lua_State
*
L
)
{
int
i
;
int
i
;
int
n
=
aux_getn
(
L
,
1
);
int
n
=
aux_getn
(
L
,
1
);
luaL_checkanyfunction
(
L
,
2
);
luaL_checkanyfunction
(
L
,
2
);
...
@@ -37,7 +37,7 @@ static int ICACHE_FLASH_ATTR foreachi (lua_State *L) {
...
@@ -37,7 +37,7 @@ static int ICACHE_FLASH_ATTR foreachi (lua_State *L) {
}
}
static
int
ICACHE_FLASH_ATTR
foreach
(
lua_State
*
L
)
{
static
int
foreach
(
lua_State
*
L
)
{
luaL_checktype
(
L
,
1
,
LUA_TTABLE
);
luaL_checktype
(
L
,
1
,
LUA_TTABLE
);
luaL_checkanyfunction
(
L
,
2
);
luaL_checkanyfunction
(
L
,
2
);
lua_pushnil
(
L
);
/* first key */
lua_pushnil
(
L
);
/* first key */
...
@@ -54,7 +54,7 @@ static int ICACHE_FLASH_ATTR foreach (lua_State *L) {
...
@@ -54,7 +54,7 @@ static int ICACHE_FLASH_ATTR foreach (lua_State *L) {
}
}
static
int
ICACHE_FLASH_ATTR
maxn
(
lua_State
*
L
)
{
static
int
maxn
(
lua_State
*
L
)
{
lua_Number
max
=
0
;
lua_Number
max
=
0
;
luaL_checktype
(
L
,
1
,
LUA_TTABLE
);
luaL_checktype
(
L
,
1
,
LUA_TTABLE
);
lua_pushnil
(
L
);
/* first key */
lua_pushnil
(
L
);
/* first key */
...
@@ -70,13 +70,13 @@ static int ICACHE_FLASH_ATTR maxn (lua_State *L) {
...
@@ -70,13 +70,13 @@ static int ICACHE_FLASH_ATTR maxn (lua_State *L) {
}
}
static
int
ICACHE_FLASH_ATTR
getn
(
lua_State
*
L
)
{
static
int
getn
(
lua_State
*
L
)
{
lua_pushinteger
(
L
,
aux_getn
(
L
,
1
));
lua_pushinteger
(
L
,
aux_getn
(
L
,
1
));
return
1
;
return
1
;
}
}
static
int
ICACHE_FLASH_ATTR
setn
(
lua_State
*
L
)
{
static
int
setn
(
lua_State
*
L
)
{
luaL_checktype
(
L
,
1
,
LUA_TTABLE
);
luaL_checktype
(
L
,
1
,
LUA_TTABLE
);
#ifndef luaL_setn
#ifndef luaL_setn
luaL_setn
(
L
,
1
,
luaL_checkint
(
L
,
2
));
luaL_setn
(
L
,
1
,
luaL_checkint
(
L
,
2
));
...
@@ -88,7 +88,7 @@ static int ICACHE_FLASH_ATTR setn (lua_State *L) {
...
@@ -88,7 +88,7 @@ static int ICACHE_FLASH_ATTR setn (lua_State *L) {
}
}
static
int
ICACHE_FLASH_ATTR
tinsert
(
lua_State
*
L
)
{
static
int
tinsert
(
lua_State
*
L
)
{
int
e
=
aux_getn
(
L
,
1
)
+
1
;
/* first empty element */
int
e
=
aux_getn
(
L
,
1
)
+
1
;
/* first empty element */
int
pos
;
/* where to insert new element */
int
pos
;
/* where to insert new element */
switch
(
lua_gettop
(
L
))
{
switch
(
lua_gettop
(
L
))
{
...
@@ -116,7 +116,7 @@ static int ICACHE_FLASH_ATTR tinsert (lua_State *L) {
...
@@ -116,7 +116,7 @@ static int ICACHE_FLASH_ATTR tinsert (lua_State *L) {
}
}
static
int
ICACHE_FLASH_ATTR
tremove
(
lua_State
*
L
)
{
static
int
tremove
(
lua_State
*
L
)
{
int
e
=
aux_getn
(
L
,
1
);
int
e
=
aux_getn
(
L
,
1
);
int
pos
=
luaL_optint
(
L
,
2
,
e
);
int
pos
=
luaL_optint
(
L
,
2
,
e
);
if
(
!
(
1
<=
pos
&&
pos
<=
e
))
/* position is outside bounds? */
if
(
!
(
1
<=
pos
&&
pos
<=
e
))
/* position is outside bounds? */
...
@@ -133,7 +133,7 @@ static int ICACHE_FLASH_ATTR tremove (lua_State *L) {
...
@@ -133,7 +133,7 @@ static int ICACHE_FLASH_ATTR tremove (lua_State *L) {
}
}
static
void
ICACHE_FLASH_ATTR
addfield
(
lua_State
*
L
,
luaL_Buffer
*
b
,
int
i
)
{
static
void
addfield
(
lua_State
*
L
,
luaL_Buffer
*
b
,
int
i
)
{
lua_rawgeti
(
L
,
1
,
i
);
lua_rawgeti
(
L
,
1
,
i
);
if
(
!
lua_isstring
(
L
,
-
1
))
if
(
!
lua_isstring
(
L
,
-
1
))
luaL_error
(
L
,
"invalid value (%s) at index %d in table for "
luaL_error
(
L
,
"invalid value (%s) at index %d in table for "
...
@@ -142,7 +142,7 @@ static void ICACHE_FLASH_ATTR addfield (lua_State *L, luaL_Buffer *b, int i) {
...
@@ -142,7 +142,7 @@ static void ICACHE_FLASH_ATTR addfield (lua_State *L, luaL_Buffer *b, int i) {
}
}
static
int
ICACHE_FLASH_ATTR
tconcat
(
lua_State
*
L
)
{
static
int
tconcat
(
lua_State
*
L
)
{
luaL_Buffer
b
;
luaL_Buffer
b
;
size_t
lsep
;
size_t
lsep
;
int
i
,
last
;
int
i
,
last
;
...
@@ -171,12 +171,12 @@ static int ICACHE_FLASH_ATTR tconcat (lua_State *L) {
...
@@ -171,12 +171,12 @@ static int ICACHE_FLASH_ATTR tconcat (lua_State *L) {
*/
*/
static
void
ICACHE_FLASH_ATTR
set2
(
lua_State
*
L
,
int
i
,
int
j
)
{
static
void
set2
(
lua_State
*
L
,
int
i
,
int
j
)
{
lua_rawseti
(
L
,
1
,
i
);
lua_rawseti
(
L
,
1
,
i
);
lua_rawseti
(
L
,
1
,
j
);
lua_rawseti
(
L
,
1
,
j
);
}
}
static
int
ICACHE_FLASH_ATTR
sort_comp
(
lua_State
*
L
,
int
a
,
int
b
)
{
static
int
sort_comp
(
lua_State
*
L
,
int
a
,
int
b
)
{
if
(
!
lua_isnil
(
L
,
2
))
{
/* function? */
if
(
!
lua_isnil
(
L
,
2
))
{
/* function? */
int
res
;
int
res
;
lua_pushvalue
(
L
,
2
);
lua_pushvalue
(
L
,
2
);
...
@@ -191,7 +191,7 @@ static int ICACHE_FLASH_ATTR sort_comp (lua_State *L, int a, int b) {
...
@@ -191,7 +191,7 @@ static int ICACHE_FLASH_ATTR sort_comp (lua_State *L, int a, int b) {
return
lua_lessthan
(
L
,
a
,
b
);
return
lua_lessthan
(
L
,
a
,
b
);
}
}
static
void
ICACHE_FLASH_ATTR
auxsort
(
lua_State
*
L
,
int
l
,
int
u
)
{
static
void
auxsort
(
lua_State
*
L
,
int
l
,
int
u
)
{
while
(
l
<
u
)
{
/* for tail recursion */
while
(
l
<
u
)
{
/* for tail recursion */
int
i
,
j
;
int
i
,
j
;
/* sort elements a[l], a[(l+u)/2] and a[u] */
/* sort elements a[l], a[(l+u)/2] and a[u] */
...
@@ -254,7 +254,7 @@ static void ICACHE_FLASH_ATTR auxsort (lua_State *L, int l, int u) {
...
@@ -254,7 +254,7 @@ static void ICACHE_FLASH_ATTR auxsort (lua_State *L, int l, int u) {
}
/* repeat the routine for the larger one */
}
/* repeat the routine for the larger one */
}
}
static
int
ICACHE_FLASH_ATTR
sort
(
lua_State
*
L
)
{
static
int
sort
(
lua_State
*
L
)
{
int
n
=
aux_getn
(
L
,
1
);
int
n
=
aux_getn
(
L
,
1
);
luaL_checkstack
(
L
,
40
,
""
);
/* assume array is smaller than 2^40 */
luaL_checkstack
(
L
,
40
,
""
);
/* assume array is smaller than 2^40 */
if
(
!
lua_isnoneornil
(
L
,
2
))
/* is there a 2nd argument? */
if
(
!
lua_isnoneornil
(
L
,
2
))
/* is there a 2nd argument? */
...
@@ -282,6 +282,6 @@ const LUA_REG_TYPE tab_funcs[] = {
...
@@ -282,6 +282,6 @@ const LUA_REG_TYPE tab_funcs[] = {
{
LNILKEY
,
LNILVAL
}
{
LNILKEY
,
LNILVAL
}
};
};
LUALIB_API
int
ICACHE_FLASH_ATTR
luaopen_table
(
lua_State
*
L
)
{
LUALIB_API
int
luaopen_table
(
lua_State
*
L
)
{
LREGISTER
(
L
,
LUA_TABLIBNAME
,
tab_funcs
);
LREGISTER
(
L
,
LUA_TABLIBNAME
,
tab_funcs
);
}
}
app/lua/ltm.c
View file @
c04f2578
...
@@ -28,7 +28,7 @@ const char *const luaT_typenames[] = {
...
@@ -28,7 +28,7 @@ const char *const luaT_typenames[] = {
};
};
void
ICACHE_FLASH_ATTR
luaT_init
(
lua_State
*
L
)
{
void
luaT_init
(
lua_State
*
L
)
{
static
const
char
*
const
luaT_eventname
[]
=
{
/* ORDER TM */
static
const
char
*
const
luaT_eventname
[]
=
{
/* ORDER TM */
"__index"
,
"__newindex"
,
"__index"
,
"__newindex"
,
"__gc"
,
"__mode"
,
"__eq"
,
"__gc"
,
"__mode"
,
"__eq"
,
...
@@ -48,7 +48,7 @@ void ICACHE_FLASH_ATTR luaT_init (lua_State *L) {
...
@@ -48,7 +48,7 @@ void ICACHE_FLASH_ATTR luaT_init (lua_State *L) {
** function to be used with macro "fasttm": optimized for absence of
** function to be used with macro "fasttm": optimized for absence of
** tag methods
** tag methods
*/
*/
const
TValue
*
ICACHE_FLASH_ATTR
luaT_gettm
(
Table
*
events
,
TMS
event
,
TString
*
ename
)
{
const
TValue
*
luaT_gettm
(
Table
*
events
,
TMS
event
,
TString
*
ename
)
{
const
TValue
*
tm
=
luaR_isrotable
(
events
)
?
luaH_getstr_ro
(
events
,
ename
)
:
luaH_getstr
(
events
,
ename
);
const
TValue
*
tm
=
luaR_isrotable
(
events
)
?
luaH_getstr_ro
(
events
,
ename
)
:
luaH_getstr
(
events
,
ename
);
lua_assert
(
event
<=
TM_EQ
);
lua_assert
(
event
<=
TM_EQ
);
if
(
ttisnil
(
tm
))
{
/* no tag method? */
if
(
ttisnil
(
tm
))
{
/* no tag method? */
...
@@ -60,7 +60,7 @@ const TValue *ICACHE_FLASH_ATTR luaT_gettm (Table *events, TMS event, TString *e
...
@@ -60,7 +60,7 @@ const TValue *ICACHE_FLASH_ATTR luaT_gettm (Table *events, TMS event, TString *e
}
}
const
TValue
*
ICACHE_FLASH_ATTR
luaT_gettmbyobj
(
lua_State
*
L
,
const
TValue
*
o
,
TMS
event
)
{
const
TValue
*
luaT_gettmbyobj
(
lua_State
*
L
,
const
TValue
*
o
,
TMS
event
)
{
Table
*
mt
;
Table
*
mt
;
switch
(
ttype
(
o
))
{
switch
(
ttype
(
o
))
{
case
LUA_TTABLE
:
case
LUA_TTABLE
:
...
...
app/lua/lua.c
View file @
c04f2578
...
@@ -35,14 +35,14 @@ int led_high_count = LED_HIGH_COUNT_DEFAULT;
...
@@ -35,14 +35,14 @@ int led_high_count = LED_HIGH_COUNT_DEFAULT;
int
led_low_count
=
LED_LOW_COUNT_DEFAULT
;
int
led_low_count
=
LED_LOW_COUNT_DEFAULT
;
static
int
led_count
=
0
;
static
int
led_count
=
0
;
#if 0
#if 0
static void
ICACHE_FLASH_ATTR
lstop (lua_State *L, lua_Debug *ar) {
static void lstop (lua_State *L, lua_Debug *ar) {
(void)ar; /* unused arg. */
(void)ar; /* unused arg. */
lua_sethook(L, NULL, 0, 0);
lua_sethook(L, NULL, 0, 0);
luaL_error(L, "interrupted!");
luaL_error(L, "interrupted!");
}
}
static void
ICACHE_FLASH_ATTR
laction (int i) {
static void laction (int i) {
// signal(i, SIG_DFL);
// signal(i, SIG_DFL);
/* if another SIGINT happens before lstop,
/* if another SIGINT happens before lstop,
terminate process (default action) */
terminate process (default action) */
...
@@ -50,7 +50,7 @@ static void ICACHE_FLASH_ATTR laction (int i) {
...
@@ -50,7 +50,7 @@ static void ICACHE_FLASH_ATTR laction (int i) {
}
}
static void
ICACHE_FLASH_ATTR
print_usage (void) {
static void print_usage (void) {
#if defined(LUA_USE_STDIO)
#if defined(LUA_USE_STDIO)
c_fprintf(c_stderr,
c_fprintf(c_stderr,
#else
#else
...
@@ -73,7 +73,7 @@ static void ICACHE_FLASH_ATTR print_usage (void) {
...
@@ -73,7 +73,7 @@ static void ICACHE_FLASH_ATTR print_usage (void) {
}
}
#endif
#endif
static
void
ICACHE_FLASH_ATTR
l_message
(
const
char
*
pname
,
const
char
*
msg
)
{
static
void
l_message
(
const
char
*
pname
,
const
char
*
msg
)
{
#if defined(LUA_USE_STDIO)
#if defined(LUA_USE_STDIO)
if
(
pname
)
c_fprintf
(
c_stderr
,
"%s: "
,
pname
);
if
(
pname
)
c_fprintf
(
c_stderr
,
"%s: "
,
pname
);
c_fprintf
(
c_stderr
,
"%s
\n
"
,
msg
);
c_fprintf
(
c_stderr
,
"%s
\n
"
,
msg
);
...
@@ -85,7 +85,7 @@ static void ICACHE_FLASH_ATTR l_message (const char *pname, const char *msg) {
...
@@ -85,7 +85,7 @@ static void ICACHE_FLASH_ATTR l_message (const char *pname, const char *msg) {
}
}
static
int
ICACHE_FLASH_ATTR
report
(
lua_State
*
L
,
int
status
)
{
static
int
report
(
lua_State
*
L
,
int
status
)
{
if
(
status
&&
!
lua_isnil
(
L
,
-
1
))
{
if
(
status
&&
!
lua_isnil
(
L
,
-
1
))
{
const
char
*
msg
=
lua_tostring
(
L
,
-
1
);
const
char
*
msg
=
lua_tostring
(
L
,
-
1
);
if
(
msg
==
NULL
)
msg
=
"(error object is not a string)"
;
if
(
msg
==
NULL
)
msg
=
"(error object is not a string)"
;
...
@@ -96,7 +96,7 @@ static int ICACHE_FLASH_ATTR report (lua_State *L, int status) {
...
@@ -96,7 +96,7 @@ static int ICACHE_FLASH_ATTR report (lua_State *L, int status) {
}
}
static
int
ICACHE_FLASH_ATTR
traceback
(
lua_State
*
L
)
{
static
int
traceback
(
lua_State
*
L
)
{
if
(
!
lua_isstring
(
L
,
1
))
/* 'message' not a string? */
if
(
!
lua_isstring
(
L
,
1
))
/* 'message' not a string? */
return
1
;
/* keep it intact */
return
1
;
/* keep it intact */
lua_getfield
(
L
,
LUA_GLOBALSINDEX
,
"debug"
);
lua_getfield
(
L
,
LUA_GLOBALSINDEX
,
"debug"
);
...
@@ -116,7 +116,7 @@ static int ICACHE_FLASH_ATTR traceback (lua_State *L) {
...
@@ -116,7 +116,7 @@ static int ICACHE_FLASH_ATTR traceback (lua_State *L) {
}
}
static
int
ICACHE_FLASH_ATTR
docall
(
lua_State
*
L
,
int
narg
,
int
clear
)
{
static
int
docall
(
lua_State
*
L
,
int
narg
,
int
clear
)
{
int
status
;
int
status
;
int
base
=
lua_gettop
(
L
)
-
narg
;
/* function index */
int
base
=
lua_gettop
(
L
)
-
narg
;
/* function index */
lua_pushcfunction
(
L
,
traceback
);
/* push traceback function */
lua_pushcfunction
(
L
,
traceback
);
/* push traceback function */
...
@@ -131,13 +131,13 @@ static int ICACHE_FLASH_ATTR docall (lua_State *L, int narg, int clear) {
...
@@ -131,13 +131,13 @@ static int ICACHE_FLASH_ATTR docall (lua_State *L, int narg, int clear) {
}
}
static
void
ICACHE_FLASH_ATTR
print_version
(
void
)
{
static
void
print_version
(
void
)
{
// l_message(NULL, LUA_RELEASE " " LUA_COPYRIGHT);
// l_message(NULL, LUA_RELEASE " " LUA_COPYRIGHT);
l_message
(
NULL
,
NODE_VERSION
" "
BUILD_DATE
" powered by "
LUA_RELEASE
);
l_message
(
NULL
,
NODE_VERSION
" "
BUILD_DATE
" powered by "
LUA_RELEASE
);
}
}
static
int
ICACHE_FLASH_ATTR
getargs
(
lua_State
*
L
,
char
**
argv
,
int
n
)
{
static
int
getargs
(
lua_State
*
L
,
char
**
argv
,
int
n
)
{
int
narg
;
int
narg
;
int
i
;
int
i
;
int
argc
=
0
;
int
argc
=
0
;
...
@@ -155,30 +155,30 @@ static int ICACHE_FLASH_ATTR getargs (lua_State *L, char **argv, int n) {
...
@@ -155,30 +155,30 @@ static int ICACHE_FLASH_ATTR getargs (lua_State *L, char **argv, int n) {
}
}
#if 0
#if 0
static int
ICACHE_FLASH_ATTR
dofile (lua_State *L, const char *name) {
static int dofile (lua_State *L, const char *name) {
int status = luaL_loadfile(L, name) || docall(L, 0, 1);
int status = luaL_loadfile(L, name) || docall(L, 0, 1);
return report(L, status);
return report(L, status);
}
}
#else
#else
static
int
ICACHE_FLASH_ATTR
dofsfile
(
lua_State
*
L
,
const
char
*
name
)
{
static
int
dofsfile
(
lua_State
*
L
,
const
char
*
name
)
{
int
status
=
luaL_loadfsfile
(
L
,
name
)
||
docall
(
L
,
0
,
1
);
int
status
=
luaL_loadfsfile
(
L
,
name
)
||
docall
(
L
,
0
,
1
);
return
report
(
L
,
status
);
return
report
(
L
,
status
);
}
}
#endif
#endif
static
int
ICACHE_FLASH_ATTR
dostring
(
lua_State
*
L
,
const
char
*
s
,
const
char
*
name
)
{
static
int
dostring
(
lua_State
*
L
,
const
char
*
s
,
const
char
*
name
)
{
int
status
=
luaL_loadbuffer
(
L
,
s
,
c_strlen
(
s
),
name
)
||
docall
(
L
,
0
,
1
);
int
status
=
luaL_loadbuffer
(
L
,
s
,
c_strlen
(
s
),
name
)
||
docall
(
L
,
0
,
1
);
return
report
(
L
,
status
);
return
report
(
L
,
status
);
}
}
static
int
ICACHE_FLASH_ATTR
dolibrary
(
lua_State
*
L
,
const
char
*
name
)
{
static
int
dolibrary
(
lua_State
*
L
,
const
char
*
name
)
{
lua_getglobal
(
L
,
"require"
);
lua_getglobal
(
L
,
"require"
);
lua_pushstring
(
L
,
name
);
lua_pushstring
(
L
,
name
);
return
report
(
L
,
docall
(
L
,
1
,
1
));
return
report
(
L
,
docall
(
L
,
1
,
1
));
}
}
static
const
char
*
ICACHE_FLASH_ATTR
get_prompt
(
lua_State
*
L
,
int
firstline
)
{
static
const
char
*
get_prompt
(
lua_State
*
L
,
int
firstline
)
{
const
char
*
p
;
const
char
*
p
;
lua_getfield
(
L
,
LUA_GLOBALSINDEX
,
firstline
?
"_PROMPT"
:
"_PROMPT2"
);
lua_getfield
(
L
,
LUA_GLOBALSINDEX
,
firstline
?
"_PROMPT"
:
"_PROMPT2"
);
p
=
lua_tostring
(
L
,
-
1
);
p
=
lua_tostring
(
L
,
-
1
);
...
@@ -188,7 +188,7 @@ static const char *ICACHE_FLASH_ATTR get_prompt (lua_State *L, int firstline) {
...
@@ -188,7 +188,7 @@ static const char *ICACHE_FLASH_ATTR get_prompt (lua_State *L, int firstline) {
}
}
static
int
ICACHE_FLASH_ATTR
incomplete
(
lua_State
*
L
,
int
status
)
{
static
int
incomplete
(
lua_State
*
L
,
int
status
)
{
if
(
status
==
LUA_ERRSYNTAX
)
{
if
(
status
==
LUA_ERRSYNTAX
)
{
size_t
lmsg
;
size_t
lmsg
;
const
char
*
msg
=
lua_tolstring
(
L
,
-
1
,
&
lmsg
);
const
char
*
msg
=
lua_tolstring
(
L
,
-
1
,
&
lmsg
);
...
@@ -202,7 +202,7 @@ static int ICACHE_FLASH_ATTR incomplete (lua_State *L, int status) {
...
@@ -202,7 +202,7 @@ static int ICACHE_FLASH_ATTR incomplete (lua_State *L, int status) {
}
}
#if 0
#if 0
static int
ICACHE_FLASH_ATTR
pushline (lua_State *L, int firstline) {
static int pushline (lua_State *L, int firstline) {
char buffer[LUA_MAXINPUT];
char buffer[LUA_MAXINPUT];
char *b = buffer;
char *b = buffer;
size_t l;
size_t l;
...
@@ -221,7 +221,7 @@ static int ICACHE_FLASH_ATTR pushline (lua_State *L, int firstline) {
...
@@ -221,7 +221,7 @@ static int ICACHE_FLASH_ATTR pushline (lua_State *L, int firstline) {
}
}
static int
ICACHE_FLASH_ATTR
loadline (lua_State *L) {
static int loadline (lua_State *L) {
int status;
int status;
lua_settop(L, 0);
lua_settop(L, 0);
if (!pushline(L, 1))
if (!pushline(L, 1))
...
@@ -241,7 +241,7 @@ static int ICACHE_FLASH_ATTR loadline (lua_State *L) {
...
@@ -241,7 +241,7 @@ static int ICACHE_FLASH_ATTR loadline (lua_State *L) {
}
}
static void
ICACHE_FLASH_ATTR
dotty (lua_State *L) {
static void dotty (lua_State *L) {
int status;
int status;
const char *oldprogname = progname;
const char *oldprogname = progname;
progname = NULL;
progname = NULL;
...
@@ -270,7 +270,7 @@ static void ICACHE_FLASH_ATTR dotty (lua_State *L) {
...
@@ -270,7 +270,7 @@ static void ICACHE_FLASH_ATTR dotty (lua_State *L) {
}
}
static
int
ICACHE_FLASH_ATTR
handle_script
(
lua_State
*
L
,
char
**
argv
,
int
n
)
{
static
int
handle_script
(
lua_State
*
L
,
char
**
argv
,
int
n
)
{
int
status
;
int
status
;
const
char
*
fname
;
const
char
*
fname
;
int
narg
=
getargs
(
L
,
argv
,
n
);
/* collect arguments */
int
narg
=
getargs
(
L
,
argv
,
n
);
/* collect arguments */
...
@@ -292,7 +292,7 @@ static int ICACHE_FLASH_ATTR handle_script (lua_State *L, char **argv, int n) {
...
@@ -292,7 +292,7 @@ static int ICACHE_FLASH_ATTR handle_script (lua_State *L, char **argv, int n) {
#define notail(x) {if ((x)[2] != '\0') return -1;}
#define notail(x) {if ((x)[2] != '\0') return -1;}
static
int
ICACHE_FLASH_ATTR
collectargs
(
char
**
argv
,
int
*
pi
,
int
*
pv
,
int
*
pe
)
{
static
int
collectargs
(
char
**
argv
,
int
*
pi
,
int
*
pv
,
int
*
pe
)
{
int
i
;
int
i
;
for
(
i
=
1
;
argv
[
i
]
!=
NULL
;
i
++
)
{
for
(
i
=
1
;
argv
[
i
]
!=
NULL
;
i
++
)
{
if
(
argv
[
i
][
0
]
!=
'-'
)
/* not an option? */
if
(
argv
[
i
][
0
]
!=
'-'
)
/* not an option? */
...
@@ -326,7 +326,7 @@ static int ICACHE_FLASH_ATTR collectargs (char **argv, int *pi, int *pv, int *pe
...
@@ -326,7 +326,7 @@ static int ICACHE_FLASH_ATTR collectargs (char **argv, int *pi, int *pv, int *pe
}
}
static
int
ICACHE_FLASH_ATTR
runargs
(
lua_State
*
L
,
char
**
argv
,
int
n
)
{
static
int
runargs
(
lua_State
*
L
,
char
**
argv
,
int
n
)
{
int
i
;
int
i
;
for
(
i
=
1
;
i
<
n
;
i
++
)
{
for
(
i
=
1
;
i
<
n
;
i
++
)
{
if
(
argv
[
i
]
==
NULL
)
continue
;
if
(
argv
[
i
]
==
NULL
)
continue
;
...
@@ -364,7 +364,7 @@ static int ICACHE_FLASH_ATTR runargs (lua_State *L, char **argv, int n) {
...
@@ -364,7 +364,7 @@ static int ICACHE_FLASH_ATTR runargs (lua_State *L, char **argv, int n) {
}
}
static
int
ICACHE_FLASH_ATTR
handle_luainit
(
lua_State
*
L
)
{
static
int
handle_luainit
(
lua_State
*
L
)
{
const
char
*
init
=
c_getenv
(
LUA_INIT
);
const
char
*
init
=
c_getenv
(
LUA_INIT
);
if
(
init
==
NULL
)
return
0
;
/* status OK */
if
(
init
==
NULL
)
return
0
;
/* status OK */
else
if
(
init
[
0
]
==
'@'
)
else
if
(
init
[
0
]
==
'@'
)
...
@@ -385,7 +385,7 @@ struct Smain {
...
@@ -385,7 +385,7 @@ struct Smain {
};
};
static
int
ICACHE_FLASH_ATTR
pmain
(
lua_State
*
L
)
{
static
int
pmain
(
lua_State
*
L
)
{
struct
Smain
*
s
=
(
struct
Smain
*
)
lua_touserdata
(
L
,
1
);
struct
Smain
*
s
=
(
struct
Smain
*
)
lua_touserdata
(
L
,
1
);
char
**
argv
=
s
->
argv
;
char
**
argv
=
s
->
argv
;
int
script
;
int
script
;
...
@@ -433,9 +433,9 @@ void readline(lua_Load *load);
...
@@ -433,9 +433,9 @@ void readline(lua_Load *load);
char
line_buffer
[
LUA_MAXINPUT
];
char
line_buffer
[
LUA_MAXINPUT
];
#ifdef LUA_RPC
#ifdef LUA_RPC
int
ICACHE_FLASH_ATTR
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
#else
#else
int
ICACHE_FLASH_ATTR
lua_main
(
int
argc
,
char
**
argv
)
{
int
lua_main
(
int
argc
,
char
**
argv
)
{
#endif
#endif
int
status
;
int
status
;
struct
Smain
s
;
struct
Smain
s
;
...
@@ -469,7 +469,7 @@ int ICACHE_FLASH_ATTR lua_main (int argc, char **argv) {
...
@@ -469,7 +469,7 @@ int ICACHE_FLASH_ATTR lua_main (int argc, char **argv) {
return
(
status
||
s
.
status
)
?
EXIT_FAILURE
:
EXIT_SUCCESS
;
return
(
status
||
s
.
status
)
?
EXIT_FAILURE
:
EXIT_SUCCESS
;
}
}
void
ICACHE_FLASH_ATTR
donejob
(
lua_Load
*
load
){
void
donejob
(
lua_Load
*
load
){
lua_close
(
load
->
L
);
lua_close
(
load
->
L
);
}
}
...
@@ -478,7 +478,7 @@ int log_fd = -1;
...
@@ -478,7 +478,7 @@ int log_fd = -1;
int noparse = 0;
int noparse = 0;
#endif
#endif
void
ICACHE_FLASH_ATTR
dojob
(
lua_Load
*
load
){
void
dojob
(
lua_Load
*
load
){
size_t
l
,
rs
;
size_t
l
,
rs
;
int
status
;
int
status
;
char
*
b
=
load
->
line
;
char
*
b
=
load
->
line
;
...
@@ -545,7 +545,7 @@ extern void key_long_press(void *arg);
...
@@ -545,7 +545,7 @@ extern void key_long_press(void *arg);
extern
void
key_short_press
(
void
*
arg
);
extern
void
key_short_press
(
void
*
arg
);
static
bool
key_short_pressed
=
false
;
static
bool
key_short_pressed
=
false
;
static
bool
key_long_pressed
=
false
;
static
bool
key_long_pressed
=
false
;
void
ICACHE_FLASH_ATTR
update_key_led
(){
void
update_key_led
(){
uint8_t
temp
=
1
,
level
=
1
;
uint8_t
temp
=
1
,
level
=
1
;
led_count
++
;
led_count
++
;
if
(
led_count
>
led_low_count
+
led_high_count
){
if
(
led_count
>
led_low_count
+
led_high_count
){
...
@@ -588,7 +588,7 @@ extern bool uart0_echo;
...
@@ -588,7 +588,7 @@ extern bool uart0_echo;
extern
bool
run_input
;
extern
bool
run_input
;
extern
uint16_t
need_len
;
extern
uint16_t
need_len
;
extern
int16_t
end_char
;
extern
int16_t
end_char
;
void
ICACHE_FLASH_ATTR
readline
(
lua_Load
*
load
){
void
readline
(
lua_Load
*
load
){
// NODE_DBG("readline() is called.\n");
// NODE_DBG("readline() is called.\n");
update_key_led
();
update_key_led
();
char
ch
;
char
ch
;
...
...
app/lua/lundump.c
View file @
c04f2578
...
@@ -37,7 +37,7 @@ typedef struct {
...
@@ -37,7 +37,7 @@ typedef struct {
#else
#else
#define IF(c,s) if (c) error(S,s)
#define IF(c,s) if (c) error(S,s)
static
void
ICACHE_FLASH_ATTR
error
(
LoadState
*
S
,
const
char
*
why
)
static
void
error
(
LoadState
*
S
,
const
char
*
why
)
{
{
luaO_pushfstring
(
S
->
L
,
"%s: %s in precompiled chunk"
,
S
->
name
,
why
);
luaO_pushfstring
(
S
->
L
,
"%s: %s in precompiled chunk"
,
S
->
name
,
why
);
luaD_throw
(
S
->
L
,
LUA_ERRSYNTAX
);
luaD_throw
(
S
->
L
,
LUA_ERRSYNTAX
);
...
@@ -48,14 +48,14 @@ static void ICACHE_FLASH_ATTR error(LoadState* S, const char* why)
...
@@ -48,14 +48,14 @@ static void ICACHE_FLASH_ATTR error(LoadState* S, const char* why)
#define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x))
#define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x))
#define LoadVector(S,b,n,size) LoadMem(S,b,n,size)
#define LoadVector(S,b,n,size) LoadMem(S,b,n,size)
static
void
ICACHE_FLASH_ATTR
LoadBlock
(
LoadState
*
S
,
void
*
b
,
size_t
size
)
static
void
LoadBlock
(
LoadState
*
S
,
void
*
b
,
size_t
size
)
{
{
size_t
r
=
luaZ_read
(
S
->
Z
,
b
,
size
);
size_t
r
=
luaZ_read
(
S
->
Z
,
b
,
size
);
IF
(
r
!=
0
,
"unexpected end"
);
IF
(
r
!=
0
,
"unexpected end"
);
S
->
total
+=
size
;
S
->
total
+=
size
;
}
}
static
void
ICACHE_FLASH_ATTR
LoadMem
(
LoadState
*
S
,
void
*
b
,
int
n
,
size_t
size
)
static
void
LoadMem
(
LoadState
*
S
,
void
*
b
,
int
n
,
size_t
size
)
{
{
LoadBlock
(
S
,
b
,
n
*
size
);
LoadBlock
(
S
,
b
,
n
*
size
);
if
(
S
->
swap
&&
b
)
if
(
S
->
swap
&&
b
)
...
@@ -98,20 +98,20 @@ static void ICACHE_FLASH_ATTR LoadMem (LoadState* S, void* b, int n, size_t size
...
@@ -98,20 +98,20 @@ static void ICACHE_FLASH_ATTR LoadMem (LoadState* S, void* b, int n, size_t size
}
}
}
}
static
int
ICACHE_FLASH_ATTR
LoadChar
(
LoadState
*
S
)
static
int
LoadChar
(
LoadState
*
S
)
{
{
char
x
;
char
x
;
LoadVar
(
S
,
x
);
LoadVar
(
S
,
x
);
return
x
;
return
x
;
}
}
static
void
ICACHE_FLASH_ATTR
Align4
(
LoadState
*
S
)
static
void
Align4
(
LoadState
*
S
)
{
{
while
(
S
->
total
&
3
)
while
(
S
->
total
&
3
)
LoadChar
(
S
);
LoadChar
(
S
);
}
}
static
int
ICACHE_FLASH_ATTR
LoadInt
(
LoadState
*
S
)
static
int
LoadInt
(
LoadState
*
S
)
{
{
int
x
;
int
x
;
LoadVar
(
S
,
x
);
LoadVar
(
S
,
x
);
...
@@ -119,7 +119,7 @@ static int ICACHE_FLASH_ATTR LoadInt(LoadState* S)
...
@@ -119,7 +119,7 @@ static int ICACHE_FLASH_ATTR LoadInt(LoadState* S)
return
x
;
return
x
;
}
}
static
lua_Number
ICACHE_FLASH_ATTR
LoadNumber
(
LoadState
*
S
)
static
lua_Number
LoadNumber
(
LoadState
*
S
)
{
{
lua_Number
x
;
lua_Number
x
;
if
(
S
->
toflt
)
if
(
S
->
toflt
)
...
@@ -158,7 +158,7 @@ static lua_Number ICACHE_FLASH_ATTR LoadNumber(LoadState* S)
...
@@ -158,7 +158,7 @@ static lua_Number ICACHE_FLASH_ATTR LoadNumber(LoadState* S)
return
x
;
return
x
;
}
}
static
TString
*
ICACHE_FLASH_ATTR
LoadString
(
LoadState
*
S
)
static
TString
*
LoadString
(
LoadState
*
S
)
{
{
int32_t
size
;
int32_t
size
;
LoadVar
(
S
,
size
);
LoadVar
(
S
,
size
);
...
@@ -179,7 +179,7 @@ static TString* ICACHE_FLASH_ATTR LoadString(LoadState* S)
...
@@ -179,7 +179,7 @@ static TString* ICACHE_FLASH_ATTR LoadString(LoadState* S)
}
}
}
}
static
void
ICACHE_FLASH_ATTR
LoadCode
(
LoadState
*
S
,
Proto
*
f
)
static
void
LoadCode
(
LoadState
*
S
,
Proto
*
f
)
{
{
int
n
=
LoadInt
(
S
);
int
n
=
LoadInt
(
S
);
Align4
(
S
);
Align4
(
S
);
...
@@ -195,7 +195,7 @@ static void ICACHE_FLASH_ATTR LoadCode(LoadState* S, Proto* f)
...
@@ -195,7 +195,7 @@ static void ICACHE_FLASH_ATTR LoadCode(LoadState* S, Proto* f)
static
Proto
*
LoadFunction
(
LoadState
*
S
,
TString
*
p
);
static
Proto
*
LoadFunction
(
LoadState
*
S
,
TString
*
p
);
static
void
ICACHE_FLASH_ATTR
LoadConstants
(
LoadState
*
S
,
Proto
*
f
)
static
void
LoadConstants
(
LoadState
*
S
,
Proto
*
f
)
{
{
int
i
,
n
;
int
i
,
n
;
n
=
LoadInt
(
S
);
n
=
LoadInt
(
S
);
...
@@ -232,7 +232,7 @@ static void ICACHE_FLASH_ATTR LoadConstants(LoadState* S, Proto* f)
...
@@ -232,7 +232,7 @@ static void ICACHE_FLASH_ATTR LoadConstants(LoadState* S, Proto* f)
for
(
i
=
0
;
i
<
n
;
i
++
)
f
->
p
[
i
]
=
LoadFunction
(
S
,
f
->
source
);
for
(
i
=
0
;
i
<
n
;
i
++
)
f
->
p
[
i
]
=
LoadFunction
(
S
,
f
->
source
);
}
}
static
void
ICACHE_FLASH_ATTR
LoadDebug
(
LoadState
*
S
,
Proto
*
f
)
static
void
LoadDebug
(
LoadState
*
S
,
Proto
*
f
)
{
{
int
i
,
n
;
int
i
,
n
;
n
=
LoadInt
(
S
);
n
=
LoadInt
(
S
);
...
@@ -262,7 +262,7 @@ static void ICACHE_FLASH_ATTR LoadDebug(LoadState* S, Proto* f)
...
@@ -262,7 +262,7 @@ static void ICACHE_FLASH_ATTR LoadDebug(LoadState* S, Proto* f)
for
(
i
=
0
;
i
<
n
;
i
++
)
f
->
upvalues
[
i
]
=
LoadString
(
S
);
for
(
i
=
0
;
i
<
n
;
i
++
)
f
->
upvalues
[
i
]
=
LoadString
(
S
);
}
}
static
Proto
*
ICACHE_FLASH_ATTR
LoadFunction
(
LoadState
*
S
,
TString
*
p
)
static
Proto
*
LoadFunction
(
LoadState
*
S
,
TString
*
p
)
{
{
Proto
*
f
;
Proto
*
f
;
if
(
++
S
->
L
->
nCcalls
>
LUAI_MAXCCALLS
)
error
(
S
,
"code too deep"
);
if
(
++
S
->
L
->
nCcalls
>
LUAI_MAXCCALLS
)
error
(
S
,
"code too deep"
);
...
@@ -285,7 +285,7 @@ static Proto* ICACHE_FLASH_ATTR LoadFunction(LoadState* S, TString* p)
...
@@ -285,7 +285,7 @@ static Proto* ICACHE_FLASH_ATTR LoadFunction(LoadState* S, TString* p)
return
f
;
return
f
;
}
}
static
void
ICACHE_FLASH_ATTR
LoadHeader
(
LoadState
*
S
)
static
void
LoadHeader
(
LoadState
*
S
)
{
{
char
h
[
LUAC_HEADERSIZE
];
char
h
[
LUAC_HEADERSIZE
];
char
s
[
LUAC_HEADERSIZE
];
char
s
[
LUAC_HEADERSIZE
];
...
@@ -302,7 +302,7 @@ static void ICACHE_FLASH_ATTR LoadHeader(LoadState* S)
...
@@ -302,7 +302,7 @@ static void ICACHE_FLASH_ATTR LoadHeader(LoadState* S)
/*
/*
** load precompiled chunk
** load precompiled chunk
*/
*/
Proto
*
ICACHE_FLASH_ATTR
luaU_undump
(
lua_State
*
L
,
ZIO
*
Z
,
Mbuffer
*
buff
,
const
char
*
name
)
Proto
*
luaU_undump
(
lua_State
*
L
,
ZIO
*
Z
,
Mbuffer
*
buff
,
const
char
*
name
)
{
{
LoadState
S
;
LoadState
S
;
if
(
*
name
==
'@'
||
*
name
==
'='
)
if
(
*
name
==
'@'
||
*
name
==
'='
)
...
@@ -322,7 +322,7 @@ Proto* ICACHE_FLASH_ATTR luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const
...
@@ -322,7 +322,7 @@ Proto* ICACHE_FLASH_ATTR luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const
/*
/*
* make header
* make header
*/
*/
void
ICACHE_FLASH_ATTR
luaU_header
(
char
*
h
)
void
luaU_header
(
char
*
h
)
{
{
int
x
=
1
;
int
x
=
1
;
c_memcpy
(
h
,
LUA_SIGNATURE
,
sizeof
(
LUA_SIGNATURE
)
-
1
);
c_memcpy
(
h
,
LUA_SIGNATURE
,
sizeof
(
LUA_SIGNATURE
)
-
1
);
...
...
app/lua/lvm.c
View file @
c04f2578
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
#define MAXTAGLOOP 100
#define MAXTAGLOOP 100
#if defined LUA_NUMBER_INTEGRAL
#if defined LUA_NUMBER_INTEGRAL
LUA_NUMBER
ICACHE_FLASH_ATTR
luai_ipow
(
LUA_NUMBER
a
,
LUA_NUMBER
b
)
{
LUA_NUMBER
luai_ipow
(
LUA_NUMBER
a
,
LUA_NUMBER
b
)
{
if
(
b
<
0
)
if
(
b
<
0
)
return
0
;
return
0
;
else
if
(
b
==
0
)
else
if
(
b
==
0
)
...
@@ -51,7 +51,7 @@ LUA_NUMBER ICACHE_FLASH_ATTR luai_ipow(LUA_NUMBER a, LUA_NUMBER b) {
...
@@ -51,7 +51,7 @@ LUA_NUMBER ICACHE_FLASH_ATTR luai_ipow(LUA_NUMBER a, LUA_NUMBER b) {
}
}
#endif
#endif
const
TValue
*
ICACHE_FLASH_ATTR
luaV_tonumber
(
const
TValue
*
obj
,
TValue
*
n
)
{
const
TValue
*
luaV_tonumber
(
const
TValue
*
obj
,
TValue
*
n
)
{
lua_Number
num
;
lua_Number
num
;
if
(
ttisnumber
(
obj
))
return
obj
;
if
(
ttisnumber
(
obj
))
return
obj
;
if
(
ttisstring
(
obj
)
&&
luaO_str2d
(
svalue
(
obj
),
&
num
))
{
if
(
ttisstring
(
obj
)
&&
luaO_str2d
(
svalue
(
obj
),
&
num
))
{
...
@@ -63,7 +63,7 @@ const TValue *ICACHE_FLASH_ATTR luaV_tonumber (const TValue *obj, TValue *n) {
...
@@ -63,7 +63,7 @@ const TValue *ICACHE_FLASH_ATTR luaV_tonumber (const TValue *obj, TValue *n) {
}
}
int
ICACHE_FLASH_ATTR
luaV_tostring
(
lua_State
*
L
,
StkId
obj
)
{
int
luaV_tostring
(
lua_State
*
L
,
StkId
obj
)
{
if
(
!
ttisnumber
(
obj
))
if
(
!
ttisnumber
(
obj
))
return
0
;
return
0
;
else
{
else
{
...
@@ -77,7 +77,7 @@ int ICACHE_FLASH_ATTR luaV_tostring (lua_State *L, StkId obj) {
...
@@ -77,7 +77,7 @@ int ICACHE_FLASH_ATTR luaV_tostring (lua_State *L, StkId obj) {
}
}
static
void
ICACHE_FLASH_ATTR
traceexec
(
lua_State
*
L
,
const
Instruction
*
pc
)
{
static
void
traceexec
(
lua_State
*
L
,
const
Instruction
*
pc
)
{
lu_byte
mask
=
L
->
hookmask
;
lu_byte
mask
=
L
->
hookmask
;
const
Instruction
*
oldpc
=
L
->
savedpc
;
const
Instruction
*
oldpc
=
L
->
savedpc
;
L
->
savedpc
=
pc
;
L
->
savedpc
=
pc
;
...
@@ -97,7 +97,7 @@ static void ICACHE_FLASH_ATTR traceexec (lua_State *L, const Instruction *pc) {
...
@@ -97,7 +97,7 @@ static void ICACHE_FLASH_ATTR traceexec (lua_State *L, const Instruction *pc) {
}
}
static
void
ICACHE_FLASH_ATTR
callTMres
(
lua_State
*
L
,
StkId
res
,
const
TValue
*
f
,
static
void
callTMres
(
lua_State
*
L
,
StkId
res
,
const
TValue
*
f
,
const
TValue
*
p1
,
const
TValue
*
p2
)
{
const
TValue
*
p1
,
const
TValue
*
p2
)
{
ptrdiff_t
result
=
savestack
(
L
,
res
);
ptrdiff_t
result
=
savestack
(
L
,
res
);
setobj2s
(
L
,
L
->
top
,
f
);
/* push function */
setobj2s
(
L
,
L
->
top
,
f
);
/* push function */
...
@@ -113,7 +113,7 @@ static void ICACHE_FLASH_ATTR callTMres (lua_State *L, StkId res, const TValue *
...
@@ -113,7 +113,7 @@ static void ICACHE_FLASH_ATTR callTMres (lua_State *L, StkId res, const TValue *
static
void
ICACHE_FLASH_ATTR
callTM
(
lua_State
*
L
,
const
TValue
*
f
,
const
TValue
*
p1
,
static
void
callTM
(
lua_State
*
L
,
const
TValue
*
f
,
const
TValue
*
p1
,
const
TValue
*
p2
,
const
TValue
*
p3
)
{
const
TValue
*
p2
,
const
TValue
*
p3
)
{
setobj2s
(
L
,
L
->
top
,
f
);
/* push function */
setobj2s
(
L
,
L
->
top
,
f
);
/* push function */
setobj2s
(
L
,
L
->
top
+
1
,
p1
);
/* 1st argument */
setobj2s
(
L
,
L
->
top
+
1
,
p1
);
/* 1st argument */
...
@@ -125,7 +125,7 @@ static void ICACHE_FLASH_ATTR callTM (lua_State *L, const TValue *f, const TValu
...
@@ -125,7 +125,7 @@ static void ICACHE_FLASH_ATTR callTM (lua_State *L, const TValue *f, const TValu
}
}
void
ICACHE_FLASH_ATTR
luaV_gettable
(
lua_State
*
L
,
const
TValue
*
t
,
TValue
*
key
,
StkId
val
)
{
void
luaV_gettable
(
lua_State
*
L
,
const
TValue
*
t
,
TValue
*
key
,
StkId
val
)
{
int
loop
;
int
loop
;
TValue
temp
;
TValue
temp
;
for
(
loop
=
0
;
loop
<
MAXTAGLOOP
;
loop
++
)
{
for
(
loop
=
0
;
loop
<
MAXTAGLOOP
;
loop
++
)
{
...
@@ -154,7 +154,7 @@ void ICACHE_FLASH_ATTR luaV_gettable (lua_State *L, const TValue *t, TValue *key
...
@@ -154,7 +154,7 @@ void ICACHE_FLASH_ATTR luaV_gettable (lua_State *L, const TValue *t, TValue *key
}
}
void
ICACHE_FLASH_ATTR
luaV_settable
(
lua_State
*
L
,
const
TValue
*
t
,
TValue
*
key
,
StkId
val
)
{
void
luaV_settable
(
lua_State
*
L
,
const
TValue
*
t
,
TValue
*
key
,
StkId
val
)
{
int
loop
;
int
loop
;
TValue
temp
;
TValue
temp
;
setnilvalue
(
L
->
top
);
setnilvalue
(
L
->
top
);
...
@@ -195,7 +195,7 @@ void ICACHE_FLASH_ATTR luaV_settable (lua_State *L, const TValue *t, TValue *key
...
@@ -195,7 +195,7 @@ void ICACHE_FLASH_ATTR luaV_settable (lua_State *L, const TValue *t, TValue *key
}
}
static
int
ICACHE_FLASH_ATTR
call_binTM
(
lua_State
*
L
,
const
TValue
*
p1
,
const
TValue
*
p2
,
static
int
call_binTM
(
lua_State
*
L
,
const
TValue
*
p1
,
const
TValue
*
p2
,
StkId
res
,
TMS
event
)
{
StkId
res
,
TMS
event
)
{
const
TValue
*
tm
=
luaT_gettmbyobj
(
L
,
p1
,
event
);
/* try first operand */
const
TValue
*
tm
=
luaT_gettmbyobj
(
L
,
p1
,
event
);
/* try first operand */
if
(
ttisnil
(
tm
))
if
(
ttisnil
(
tm
))
...
@@ -206,7 +206,7 @@ static int ICACHE_FLASH_ATTR call_binTM (lua_State *L, const TValue *p1, const T
...
@@ -206,7 +206,7 @@ static int ICACHE_FLASH_ATTR call_binTM (lua_State *L, const TValue *p1, const T
}
}
static
const
TValue
*
ICACHE_FLASH_ATTR
get_compTM
(
lua_State
*
L
,
Table
*
mt1
,
Table
*
mt2
,
static
const
TValue
*
get_compTM
(
lua_State
*
L
,
Table
*
mt1
,
Table
*
mt2
,
TMS
event
)
{
TMS
event
)
{
const
TValue
*
tm1
=
fasttm
(
L
,
mt1
,
event
);
const
TValue
*
tm1
=
fasttm
(
L
,
mt1
,
event
);
const
TValue
*
tm2
;
const
TValue
*
tm2
;
...
@@ -220,7 +220,7 @@ static const TValue *ICACHE_FLASH_ATTR get_compTM (lua_State *L, Table *mt1, Tab
...
@@ -220,7 +220,7 @@ static const TValue *ICACHE_FLASH_ATTR get_compTM (lua_State *L, Table *mt1, Tab
}
}
static
int
ICACHE_FLASH_ATTR
call_orderTM
(
lua_State
*
L
,
const
TValue
*
p1
,
const
TValue
*
p2
,
static
int
call_orderTM
(
lua_State
*
L
,
const
TValue
*
p1
,
const
TValue
*
p2
,
TMS
event
)
{
TMS
event
)
{
const
TValue
*
tm1
=
luaT_gettmbyobj
(
L
,
p1
,
event
);
const
TValue
*
tm1
=
luaT_gettmbyobj
(
L
,
p1
,
event
);
const
TValue
*
tm2
;
const
TValue
*
tm2
;
...
@@ -233,7 +233,7 @@ static int ICACHE_FLASH_ATTR call_orderTM (lua_State *L, const TValue *p1, const
...
@@ -233,7 +233,7 @@ static int ICACHE_FLASH_ATTR call_orderTM (lua_State *L, const TValue *p1, const
}
}
static
int
ICACHE_FLASH_ATTR
l_strcmp
(
const
TString
*
ls
,
const
TString
*
rs
)
{
static
int
l_strcmp
(
const
TString
*
ls
,
const
TString
*
rs
)
{
const
char
*
l
=
getstr
(
ls
);
const
char
*
l
=
getstr
(
ls
);
size_t
ll
=
ls
->
tsv
.
len
;
size_t
ll
=
ls
->
tsv
.
len
;
const
char
*
r
=
getstr
(
rs
);
const
char
*
r
=
getstr
(
rs
);
...
@@ -255,7 +255,7 @@ static int ICACHE_FLASH_ATTR l_strcmp (const TString *ls, const TString *rs) {
...
@@ -255,7 +255,7 @@ static int ICACHE_FLASH_ATTR l_strcmp (const TString *ls, const TString *rs) {
}
}
int
ICACHE_FLASH_ATTR
luaV_lessthan
(
lua_State
*
L
,
const
TValue
*
l
,
const
TValue
*
r
)
{
int
luaV_lessthan
(
lua_State
*
L
,
const
TValue
*
l
,
const
TValue
*
r
)
{
int
res
;
int
res
;
if
(
ttype
(
l
)
!=
ttype
(
r
))
if
(
ttype
(
l
)
!=
ttype
(
r
))
return
luaG_ordererror
(
L
,
l
,
r
);
return
luaG_ordererror
(
L
,
l
,
r
);
...
@@ -269,7 +269,7 @@ int ICACHE_FLASH_ATTR luaV_lessthan (lua_State *L, const TValue *l, const TValue
...
@@ -269,7 +269,7 @@ int ICACHE_FLASH_ATTR luaV_lessthan (lua_State *L, const TValue *l, const TValue
}
}
static
int
ICACHE_FLASH_ATTR
lessequal
(
lua_State
*
L
,
const
TValue
*
l
,
const
TValue
*
r
)
{
static
int
lessequal
(
lua_State
*
L
,
const
TValue
*
l
,
const
TValue
*
r
)
{
int
res
;
int
res
;
if
(
ttype
(
l
)
!=
ttype
(
r
))
if
(
ttype
(
l
)
!=
ttype
(
r
))
return
luaG_ordererror
(
L
,
l
,
r
);
return
luaG_ordererror
(
L
,
l
,
r
);
...
@@ -285,7 +285,7 @@ static int ICACHE_FLASH_ATTR lessequal (lua_State *L, const TValue *l, const TVa
...
@@ -285,7 +285,7 @@ static int ICACHE_FLASH_ATTR lessequal (lua_State *L, const TValue *l, const TVa
}
}
int
ICACHE_FLASH_ATTR
luaV_equalval
(
lua_State
*
L
,
const
TValue
*
t1
,
const
TValue
*
t2
)
{
int
luaV_equalval
(
lua_State
*
L
,
const
TValue
*
t1
,
const
TValue
*
t2
)
{
const
TValue
*
tm
;
const
TValue
*
tm
;
lua_assert
(
ttype
(
t1
)
==
ttype
(
t2
));
lua_assert
(
ttype
(
t1
)
==
ttype
(
t2
));
switch
(
ttype
(
t1
))
{
switch
(
ttype
(
t1
))
{
...
@@ -315,7 +315,7 @@ int ICACHE_FLASH_ATTR luaV_equalval (lua_State *L, const TValue *t1, const TValu
...
@@ -315,7 +315,7 @@ int ICACHE_FLASH_ATTR luaV_equalval (lua_State *L, const TValue *t1, const TValu
}
}
void
ICACHE_FLASH_ATTR
luaV_concat
(
lua_State
*
L
,
int
total
,
int
last
)
{
void
luaV_concat
(
lua_State
*
L
,
int
total
,
int
last
)
{
lu_mem
max_sizet
=
MAX_SIZET
;
lu_mem
max_sizet
=
MAX_SIZET
;
if
(
G
(
L
)
->
memlimit
<
max_sizet
)
max_sizet
=
G
(
L
)
->
memlimit
;
if
(
G
(
L
)
->
memlimit
<
max_sizet
)
max_sizet
=
G
(
L
)
->
memlimit
;
do
{
do
{
...
@@ -359,7 +359,7 @@ void ICACHE_FLASH_ATTR luaV_concat (lua_State *L, int total, int last) {
...
@@ -359,7 +359,7 @@ void ICACHE_FLASH_ATTR luaV_concat (lua_State *L, int total, int last) {
}
}
static
void
ICACHE_FLASH_ATTR
Arith
(
lua_State
*
L
,
StkId
ra
,
const
TValue
*
rb
,
static
void
Arith
(
lua_State
*
L
,
StkId
ra
,
const
TValue
*
rb
,
const
TValue
*
rc
,
TMS
op
)
{
const
TValue
*
rc
,
TMS
op
)
{
TValue
tempb
,
tempc
;
TValue
tempb
,
tempc
;
const
TValue
*
b
,
*
c
;
const
TValue
*
b
,
*
c
;
...
@@ -424,7 +424,7 @@ static void ICACHE_FLASH_ATTR Arith (lua_State *L, StkId ra, const TValue *rb,
...
@@ -424,7 +424,7 @@ static void ICACHE_FLASH_ATTR Arith (lua_State *L, StkId ra, const TValue *rb,
void
ICACHE_FLASH_ATTR
luaV_execute
(
lua_State
*
L
,
int
nexeccalls
)
{
void
luaV_execute
(
lua_State
*
L
,
int
nexeccalls
)
{
LClosure
*
cl
;
LClosure
*
cl
;
StkId
base
;
StkId
base
;
TValue
*
k
;
TValue
*
k
;
...
...
app/lua/lzio.c
View file @
c04f2578
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
#include "lzio.h"
#include "lzio.h"
int
ICACHE_FLASH_ATTR
luaZ_fill
(
ZIO
*
z
)
{
int
luaZ_fill
(
ZIO
*
z
)
{
size_t
size
;
size_t
size
;
lua_State
*
L
=
z
->
L
;
lua_State
*
L
=
z
->
L
;
const
char
*
buff
;
const
char
*
buff
;
...
@@ -32,7 +32,7 @@ int ICACHE_FLASH_ATTR luaZ_fill (ZIO *z) {
...
@@ -32,7 +32,7 @@ int ICACHE_FLASH_ATTR luaZ_fill (ZIO *z) {
}
}
int
ICACHE_FLASH_ATTR
luaZ_lookahead
(
ZIO
*
z
)
{
int
luaZ_lookahead
(
ZIO
*
z
)
{
if
(
z
->
n
==
0
)
{
if
(
z
->
n
==
0
)
{
if
(
luaZ_fill
(
z
)
==
EOZ
)
if
(
luaZ_fill
(
z
)
==
EOZ
)
return
EOZ
;
return
EOZ
;
...
@@ -45,7 +45,7 @@ int ICACHE_FLASH_ATTR luaZ_lookahead (ZIO *z) {
...
@@ -45,7 +45,7 @@ int ICACHE_FLASH_ATTR luaZ_lookahead (ZIO *z) {
}
}
void
ICACHE_FLASH_ATTR
luaZ_init
(
lua_State
*
L
,
ZIO
*
z
,
lua_Reader
reader
,
void
*
data
)
{
void
luaZ_init
(
lua_State
*
L
,
ZIO
*
z
,
lua_Reader
reader
,
void
*
data
)
{
z
->
L
=
L
;
z
->
L
=
L
;
z
->
reader
=
reader
;
z
->
reader
=
reader
;
z
->
data
=
data
;
z
->
data
=
data
;
...
@@ -55,7 +55,7 @@ void ICACHE_FLASH_ATTR luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void
...
@@ -55,7 +55,7 @@ void ICACHE_FLASH_ATTR luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void
/* --------------------------------------------------------------- read --- */
/* --------------------------------------------------------------- read --- */
size_t
ICACHE_FLASH_ATTR
luaZ_read
(
ZIO
*
z
,
void
*
b
,
size_t
n
)
{
size_t
luaZ_read
(
ZIO
*
z
,
void
*
b
,
size_t
n
)
{
while
(
n
)
{
while
(
n
)
{
size_t
m
;
size_t
m
;
if
(
luaZ_lookahead
(
z
)
==
EOZ
)
if
(
luaZ_lookahead
(
z
)
==
EOZ
)
...
@@ -74,7 +74,7 @@ size_t ICACHE_FLASH_ATTR luaZ_read (ZIO *z, void *b, size_t n) {
...
@@ -74,7 +74,7 @@ size_t ICACHE_FLASH_ATTR luaZ_read (ZIO *z, void *b, size_t n) {
}
}
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
char
*
ICACHE_FLASH_ATTR
luaZ_openspace
(
lua_State
*
L
,
Mbuffer
*
buff
,
size_t
n
)
{
char
*
luaZ_openspace
(
lua_State
*
L
,
Mbuffer
*
buff
,
size_t
n
)
{
if
(
n
>
buff
->
buffsize
)
{
if
(
n
>
buff
->
buffsize
)
{
if
(
n
<
LUA_MINBUFFER
)
n
=
LUA_MINBUFFER
;
if
(
n
<
LUA_MINBUFFER
)
n
=
LUA_MINBUFFER
;
luaZ_resizebuffer
(
L
,
buff
,
n
);
luaZ_resizebuffer
(
L
,
buff
,
n
);
...
...
Prev
1
2
3
4
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment