Commit bf3463d0 authored by zeroday's avatar zeroday
Browse files

Merge pull request #75 from nodemcu/dev095

Dev095
parents 0a3702f8 729603fa
...@@ -49,12 +49,13 @@ extern int c_stderr; ...@@ -49,12 +49,13 @@ extern int c_stderr;
extern void output_redirect(const char *str); extern void output_redirect(const char *str);
#define c_puts output_redirect #define c_puts output_redirect
extern unsigned char __print_buf[BUFSIZ];
// #define c_printf os_printf // #define c_printf os_printf
// int c_printf(const char *c, ...); // int c_printf(const char *c, ...);
#define c_sprintf os_sprintf #define c_sprintf os_sprintf
// #define c_vsprintf ets_vsprintf // #define c_vsprintf ets_vsprintf
#define c_printf(...) do { \ #define c_printf(...) do { \
unsigned char __print_buf[BUFSIZ]; \
c_sprintf(__print_buf, __VA_ARGS__); \ c_sprintf(__print_buf, __VA_ARGS__); \
c_puts(__print_buf); \ c_puts(__print_buf); \
} while(0) } while(0)
......
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
// const char *lua_init_value = "print(\"Hello world\")"; // const char *lua_init_value = "print(\"Hello world\")";
const char *lua_init_value = "@init.lua"; const char *lua_init_value = "@init.lua";
// int ICACHE_FLASH_ATTR c_abs(int x){ // int c_abs(int x){
// return x>0?x:0-x; // return x>0?x:0-x;
// } // }
// void ICACHE_FLASH_ATTR c_exit(int e){ // void c_exit(int e){
// } // }
const char *ICACHE_FLASH_ATTR c_getenv(const char *__string){ const char *c_getenv(const char *__string){
if (c_strcmp(__string, "LUA_INIT") == 0){ if (c_strcmp(__string, "LUA_INIT") == 0){
return lua_init_value; return lua_init_value;
} }
...@@ -20,7 +20,7 @@ const char *ICACHE_FLASH_ATTR c_getenv(const char *__string){ ...@@ -20,7 +20,7 @@ const char *ICACHE_FLASH_ATTR c_getenv(const char *__string){
} }
// make sure there is enough memory before real malloc, otherwise malloc will panic and reset // make sure there is enough memory before real malloc, otherwise malloc will panic and reset
void *ICACHE_FLASH_ATTR c_malloc(size_t __size){ void *c_malloc(size_t __size){
if(__size>system_get_free_heap_size()){ if(__size>system_get_free_heap_size()){
NODE_ERR("malloc: not enough memory\n"); NODE_ERR("malloc: not enough memory\n");
return NULL; return NULL;
...@@ -28,7 +28,7 @@ void *ICACHE_FLASH_ATTR c_malloc(size_t __size){ ...@@ -28,7 +28,7 @@ void *ICACHE_FLASH_ATTR c_malloc(size_t __size){
return (void *)os_malloc(__size); return (void *)os_malloc(__size);
} }
void *ICACHE_FLASH_ATTR c_zalloc(size_t __size){ void *c_zalloc(size_t __size){
if(__size>system_get_free_heap_size()){ if(__size>system_get_free_heap_size()){
NODE_ERR("zalloc: not enough memory\n"); NODE_ERR("zalloc: not enough memory\n");
return NULL; return NULL;
...@@ -36,25 +36,25 @@ void *ICACHE_FLASH_ATTR c_zalloc(size_t __size){ ...@@ -36,25 +36,25 @@ void *ICACHE_FLASH_ATTR c_zalloc(size_t __size){
return (void *)os_zalloc(__size); return (void *)os_zalloc(__size);
} }
void ICACHE_FLASH_ATTR c_free(void *p){ void c_free(void *p){
// NODE_ERR("free1: %d\n", system_get_free_heap_size()); // NODE_ERR("free1: %d\n", system_get_free_heap_size());
os_free(p); os_free(p);
// NODE_ERR("-free1: %d\n", system_get_free_heap_size()); // NODE_ERR("-free1: %d\n", system_get_free_heap_size());
} }
// int ICACHE_FLASH_ATTR c_rand(void){ // int c_rand(void){
// } // }
// void ICACHE_FLASH_ATTR c_srand(unsigned int __seed){ // void c_srand(unsigned int __seed){
// } // }
// int ICACHE_FLASH_ATTR c_atoi(const char *__nptr){ // int c_atoi(const char *__nptr){
// } // }
// double ICACHE_FLASH_ATTR c_strtod(const char *__n, char **__end_PTR){ // double c_strtod(const char *__n, char **__end_PTR){
// } // }
// long ICACHE_FLASH_ATTR c_strtol(const char *__n, char **__end_PTR, int __base){ // long c_strtol(const char *__n, char **__end_PTR, int __base){
// } // }
// unsigned long ICACHE_FLASH_ATTR c_strtoul(const char *__n, char **__end_PTR, int __base){ // unsigned long c_strtoul(const char *__n, char **__end_PTR, int __base){
// } // }
// long long ICACHE_FLASH_ATTR c_strtoll(const char *__n, char **__end_PTR, int __base){ // long long c_strtoll(const char *__n, char **__end_PTR, int __base){
// } // }
...@@ -22,15 +22,15 @@ extern char Image$$ER_IROM1$$Limit; ...@@ -22,15 +22,15 @@ extern char Image$$ER_IROM1$$Limit;
//#warning "Please check linker script to ensure rodata is between _stext and _etext." //#warning "Please check linker script to ensure rodata is between _stext and _etext."
/* symbols defined in linker script */ /* symbols defined in linker script */
extern char _rodata_start; // extern char _rodata_start;
extern char _rodata_end; // extern char _rodata_end;
// extern char _irom0_text_start; extern char _irom0_text_start;
// extern char _irom0_text_end; extern char _irom0_text_end;
// modify linker script to ensure rodata and rodata1 is between _rodata_start and _rodata_end. // modify linker script to ensure rodata and rodata1 is between _rodata_start and _rodata_end.
#define RODATA_START_ADDRESS (&_rodata_start) // #define RODATA_START_ADDRESS (&_rodata_start)
#define RODATA_END_ADDRESS (&_rodata_end) // #define RODATA_END_ADDRESS (&_rodata_end)
// #define RODATA_START_ADDRESS (&_irom0_text_start) #define RODATA_START_ADDRESS (&_irom0_text_start)
// #define RODATA_END_ADDRESS (&_irom0_text_end) #define RODATA_END_ADDRESS (&_irom0_text_end)
#else // other compilers #else // other compilers
......
This diff is collapsed.
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
*/ */
LUALIB_API int ICACHE_FLASH_ATTR luaL_argerror (lua_State *L, int narg, const char *extramsg) { LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) {
lua_Debug ar; lua_Debug ar;
if (!lua_getstack(L, 0, &ar)) /* no stack frame? */ if (!lua_getstack(L, 0, &ar)) /* no stack frame? */
return luaL_error(L, "bad argument #%d (%s)", narg, extramsg); return luaL_error(L, "bad argument #%d (%s)", narg, extramsg);
...@@ -67,19 +67,19 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_argerror (lua_State *L, int narg, const ch ...@@ -67,19 +67,19 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_argerror (lua_State *L, int narg, const ch
} }
LUALIB_API int ICACHE_FLASH_ATTR luaL_typerror (lua_State *L, int narg, const char *tname) { LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) {
const char *msg = lua_pushfstring(L, "%s expected, got %s", const char *msg = lua_pushfstring(L, "%s expected, got %s",
tname, luaL_typename(L, narg)); tname, luaL_typename(L, narg));
return luaL_argerror(L, narg, msg); return luaL_argerror(L, narg, msg);
} }
static void ICACHE_FLASH_ATTR tag_error (lua_State *L, int narg, int tag) { static void tag_error (lua_State *L, int narg, int tag) {
luaL_typerror(L, narg, lua_typename(L, tag)); luaL_typerror(L, narg, lua_typename(L, tag));
} }
LUALIB_API void ICACHE_FLASH_ATTR luaL_where (lua_State *L, int level) { LUALIB_API void luaL_where (lua_State *L, int level) {
lua_Debug ar; lua_Debug ar;
if (lua_getstack(L, level, &ar)) { /* check function at level */ if (lua_getstack(L, level, &ar)) { /* check function at level */
lua_getinfo(L, "Sl", &ar); /* get info about it */ lua_getinfo(L, "Sl", &ar); /* get info about it */
...@@ -92,7 +92,7 @@ LUALIB_API void ICACHE_FLASH_ATTR luaL_where (lua_State *L, int level) { ...@@ -92,7 +92,7 @@ LUALIB_API void ICACHE_FLASH_ATTR luaL_where (lua_State *L, int level) {
} }
LUALIB_API int ICACHE_FLASH_ATTR luaL_error (lua_State *L, const char *fmt, ...) { LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) {
va_list argp; va_list argp;
va_start(argp, fmt); va_start(argp, fmt);
luaL_where(L, 1); luaL_where(L, 1);
...@@ -105,7 +105,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_error (lua_State *L, const char *fmt, ...) ...@@ -105,7 +105,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_error (lua_State *L, const char *fmt, ...)
/* }====================================================== */ /* }====================================================== */
LUALIB_API int ICACHE_FLASH_ATTR luaL_checkoption (lua_State *L, int narg, const char *def, LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def,
const char *const lst[]) { const char *const lst[]) {
const char *name = (def) ? luaL_optstring(L, narg, def) : const char *name = (def) ? luaL_optstring(L, narg, def) :
luaL_checkstring(L, narg); luaL_checkstring(L, narg);
...@@ -118,7 +118,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_checkoption (lua_State *L, int narg, const ...@@ -118,7 +118,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_checkoption (lua_State *L, int narg, const
} }
LUALIB_API int ICACHE_FLASH_ATTR luaL_newmetatable (lua_State *L, const char *tname) { LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) {
lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */ lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */
if (!lua_isnil(L, -1)) /* name already in use? */ if (!lua_isnil(L, -1)) /* name already in use? */
return 0; /* leave previous value on top, but return 0 */ return 0; /* leave previous value on top, but return 0 */
...@@ -129,7 +129,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_newmetatable (lua_State *L, const char *tn ...@@ -129,7 +129,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_newmetatable (lua_State *L, const char *tn
return 1; return 1;
} }
LUALIB_API int ICACHE_FLASH_ATTR luaL_rometatable (lua_State *L, const char* tname, void *p) { LUALIB_API int luaL_rometatable (lua_State *L, const char* tname, void *p) {
lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */ lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */
if (!lua_isnil(L, -1)) /* name already in use? */ if (!lua_isnil(L, -1)) /* name already in use? */
return 0; /* leave previous value on top, but return 0 */ return 0; /* leave previous value on top, but return 0 */
...@@ -140,7 +140,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_rometatable (lua_State *L, const char* tna ...@@ -140,7 +140,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_rometatable (lua_State *L, const char* tna
return 1; return 1;
} }
LUALIB_API void *ICACHE_FLASH_ATTR luaL_checkudata (lua_State *L, int ud, const char *tname) { LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) {
void *p = lua_touserdata(L, ud); void *p = lua_touserdata(L, ud);
if (p != NULL) { /* value is a userdata? */ if (p != NULL) { /* value is a userdata? */
if (lua_getmetatable(L, ud)) { /* does it have a metatable? */ if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
...@@ -156,18 +156,18 @@ LUALIB_API void *ICACHE_FLASH_ATTR luaL_checkudata (lua_State *L, int ud, const ...@@ -156,18 +156,18 @@ LUALIB_API void *ICACHE_FLASH_ATTR luaL_checkudata (lua_State *L, int ud, const
} }
LUALIB_API void ICACHE_FLASH_ATTR luaL_checkstack (lua_State *L, int space, const char *mes) { LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) {
if (!lua_checkstack(L, space)) if (!lua_checkstack(L, space))
luaL_error(L, "stack overflow (%s)", mes); luaL_error(L, "stack overflow (%s)", mes);
} }
LUALIB_API void ICACHE_FLASH_ATTR luaL_checktype (lua_State *L, int narg, int t) { LUALIB_API void luaL_checktype (lua_State *L, int narg, int t) {
if (lua_type(L, narg) != t) if (lua_type(L, narg) != t)
tag_error(L, narg, t); tag_error(L, narg, t);
} }
LUALIB_API void ICACHE_FLASH_ATTR luaL_checkanyfunction (lua_State *L, int narg) { LUALIB_API void luaL_checkanyfunction (lua_State *L, int narg) {
if (lua_type(L, narg) != LUA_TFUNCTION && lua_type(L, narg) != LUA_TLIGHTFUNCTION) { if (lua_type(L, narg) != LUA_TFUNCTION && lua_type(L, narg) != LUA_TLIGHTFUNCTION) {
const char *msg = lua_pushfstring(L, "function or lightfunction expected, got %s", const char *msg = lua_pushfstring(L, "function or lightfunction expected, got %s",
luaL_typename(L, narg)); luaL_typename(L, narg));
...@@ -175,7 +175,7 @@ LUALIB_API void ICACHE_FLASH_ATTR luaL_checkanyfunction (lua_State *L, int narg) ...@@ -175,7 +175,7 @@ LUALIB_API void ICACHE_FLASH_ATTR luaL_checkanyfunction (lua_State *L, int narg)
} }
} }
LUALIB_API void ICACHE_FLASH_ATTR luaL_checkanytable (lua_State *L, int narg) { LUALIB_API void luaL_checkanytable (lua_State *L, int narg) {
if (lua_type(L, narg) != LUA_TTABLE && lua_type(L, narg) != LUA_TROTABLE) { if (lua_type(L, narg) != LUA_TTABLE && lua_type(L, narg) != LUA_TROTABLE) {
const char *msg = lua_pushfstring(L, "table or rotable expected, got %s", const char *msg = lua_pushfstring(L, "table or rotable expected, got %s",
luaL_typename(L, narg)); luaL_typename(L, narg));
...@@ -184,20 +184,20 @@ LUALIB_API void ICACHE_FLASH_ATTR luaL_checkanytable (lua_State *L, int narg) { ...@@ -184,20 +184,20 @@ LUALIB_API void ICACHE_FLASH_ATTR luaL_checkanytable (lua_State *L, int narg) {
} }
LUALIB_API void ICACHE_FLASH_ATTR luaL_checkany (lua_State *L, int narg) { LUALIB_API void luaL_checkany (lua_State *L, int narg) {
if (lua_type(L, narg) == LUA_TNONE) if (lua_type(L, narg) == LUA_TNONE)
luaL_argerror(L, narg, "value expected"); luaL_argerror(L, narg, "value expected");
} }
LUALIB_API const char *ICACHE_FLASH_ATTR luaL_checklstring (lua_State *L, int narg, size_t *len) { LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t *len) {
const char *s = lua_tolstring(L, narg, len); const char *s = lua_tolstring(L, narg, len);
if (!s) tag_error(L, narg, LUA_TSTRING); if (!s) tag_error(L, narg, LUA_TSTRING);
return s; return s;
} }
LUALIB_API const char *ICACHE_FLASH_ATTR luaL_optlstring (lua_State *L, int narg, LUALIB_API const char *luaL_optlstring (lua_State *L, int narg,
const char *def, size_t *len) { const char *def, size_t *len) {
if (lua_isnoneornil(L, narg)) { if (lua_isnoneornil(L, narg)) {
if (len) if (len)
...@@ -208,7 +208,7 @@ LUALIB_API const char *ICACHE_FLASH_ATTR luaL_optlstring (lua_State *L, int narg ...@@ -208,7 +208,7 @@ LUALIB_API const char *ICACHE_FLASH_ATTR luaL_optlstring (lua_State *L, int narg
} }
LUALIB_API lua_Number ICACHE_FLASH_ATTR luaL_checknumber (lua_State *L, int narg) { LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) {
lua_Number d = lua_tonumber(L, narg); lua_Number d = lua_tonumber(L, narg);
if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */
tag_error(L, narg, LUA_TNUMBER); tag_error(L, narg, LUA_TNUMBER);
...@@ -216,12 +216,12 @@ LUALIB_API lua_Number ICACHE_FLASH_ATTR luaL_checknumber (lua_State *L, int narg ...@@ -216,12 +216,12 @@ LUALIB_API lua_Number ICACHE_FLASH_ATTR luaL_checknumber (lua_State *L, int narg
} }
LUALIB_API lua_Number ICACHE_FLASH_ATTR luaL_optnumber (lua_State *L, int narg, lua_Number def) { LUALIB_API lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number def) {
return luaL_opt(L, luaL_checknumber, narg, def); return luaL_opt(L, luaL_checknumber, narg, def);
} }
LUALIB_API lua_Integer ICACHE_FLASH_ATTR luaL_checkinteger (lua_State *L, int narg) { LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) {
lua_Integer d = lua_tointeger(L, narg); lua_Integer d = lua_tointeger(L, narg);
if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */
tag_error(L, narg, LUA_TNUMBER); tag_error(L, narg, LUA_TNUMBER);
...@@ -229,13 +229,13 @@ LUALIB_API lua_Integer ICACHE_FLASH_ATTR luaL_checkinteger (lua_State *L, int na ...@@ -229,13 +229,13 @@ LUALIB_API lua_Integer ICACHE_FLASH_ATTR luaL_checkinteger (lua_State *L, int na
} }
LUALIB_API lua_Integer ICACHE_FLASH_ATTR luaL_optinteger (lua_State *L, int narg, LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int narg,
lua_Integer def) { lua_Integer def) {
return luaL_opt(L, luaL_checkinteger, narg, def); return luaL_opt(L, luaL_checkinteger, narg, def);
} }
LUALIB_API int ICACHE_FLASH_ATTR luaL_getmetafield (lua_State *L, int obj, const char *event) { LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) {
if (!lua_getmetatable(L, obj)) /* no metatable? */ if (!lua_getmetatable(L, obj)) /* no metatable? */
return 0; return 0;
lua_pushstring(L, event); lua_pushstring(L, event);
...@@ -251,7 +251,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_getmetafield (lua_State *L, int obj, const ...@@ -251,7 +251,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_getmetafield (lua_State *L, int obj, const
} }
LUALIB_API int ICACHE_FLASH_ATTR luaL_callmeta (lua_State *L, int obj, const char *event) { LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) {
obj = abs_index(L, obj); obj = abs_index(L, obj);
if (!luaL_getmetafield(L, obj, event)) /* no metafield? */ if (!luaL_getmetafield(L, obj, event)) /* no metafield? */
return 0; return 0;
...@@ -261,12 +261,12 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_callmeta (lua_State *L, int obj, const cha ...@@ -261,12 +261,12 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_callmeta (lua_State *L, int obj, const cha
} }
LUALIB_API void ICACHE_FLASH_ATTR (luaL_register) (lua_State *L, const char *libname, LUALIB_API void (luaL_register) (lua_State *L, const char *libname,
const luaL_Reg *l) { const luaL_Reg *l) {
luaI_openlib(L, libname, l, 0, LUA_USECCLOSURES); luaI_openlib(L, libname, l, 0, LUA_USECCLOSURES);
} }
LUALIB_API void ICACHE_FLASH_ATTR (luaL_register_light) (lua_State *L, const char *libname, LUALIB_API void (luaL_register_light) (lua_State *L, const char *libname,
const luaL_Reg *l) { const luaL_Reg *l) {
#if LUA_OPTIMIZE_MEMORY > 0 #if LUA_OPTIMIZE_MEMORY > 0
luaI_openlib(L, libname, l, 0, LUA_USELIGHTFUNCTIONS); luaI_openlib(L, libname, l, 0, LUA_USELIGHTFUNCTIONS);
...@@ -275,14 +275,14 @@ LUALIB_API void ICACHE_FLASH_ATTR (luaL_register_light) (lua_State *L, const cha ...@@ -275,14 +275,14 @@ LUALIB_API void ICACHE_FLASH_ATTR (luaL_register_light) (lua_State *L, const cha
#endif #endif
} }
static int ICACHE_FLASH_ATTR libsize (const luaL_Reg *l) { static int libsize (const luaL_Reg *l) {
int size = 0; int size = 0;
for (; l->name; l++) size++; for (; l->name; l++) size++;
return size; return size;
} }
LUALIB_API void ICACHE_FLASH_ATTR luaI_openlib (lua_State *L, const char *libname, LUALIB_API void luaI_openlib (lua_State *L, const char *libname,
const luaL_Reg *l, int nup, int ftype) { const luaL_Reg *l, int nup, int ftype) {
if (libname) { if (libname) {
int size = libsize(l); int size = libsize(l);
...@@ -323,14 +323,14 @@ LUALIB_API void ICACHE_FLASH_ATTR luaI_openlib (lua_State *L, const char *libnam ...@@ -323,14 +323,14 @@ LUALIB_API void ICACHE_FLASH_ATTR luaI_openlib (lua_State *L, const char *libnam
#if defined(LUA_COMPAT_GETN) #if defined(LUA_COMPAT_GETN)
static int ICACHE_FLASH_ATTR checkint (lua_State *L, int topop) { static int checkint (lua_State *L, int topop) {
int n = (lua_type(L, -1) == LUA_TNUMBER) ? lua_tointeger(L, -1) : -1; int n = (lua_type(L, -1) == LUA_TNUMBER) ? lua_tointeger(L, -1) : -1;
lua_pop(L, topop); lua_pop(L, topop);
return n; return n;
} }
static void ICACHE_FLASH_ATTR getsizes (lua_State *L) { static void getsizes (lua_State *L) {
lua_getfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); lua_getfield(L, LUA_REGISTRYINDEX, "LUA_SIZES");
if (lua_isnil(L, -1)) { /* no `size' table? */ if (lua_isnil(L, -1)) { /* no `size' table? */
lua_pop(L, 1); /* remove nil */ lua_pop(L, 1); /* remove nil */
...@@ -345,7 +345,7 @@ static void ICACHE_FLASH_ATTR getsizes (lua_State *L) { ...@@ -345,7 +345,7 @@ static void ICACHE_FLASH_ATTR getsizes (lua_State *L) {
} }
LUALIB_API void ICACHE_FLASH_ATTR luaL_setn (lua_State *L, int t, int n) { LUALIB_API void luaL_setn (lua_State *L, int t, int n) {
t = abs_index(L, t); t = abs_index(L, t);
lua_pushliteral(L, "n"); lua_pushliteral(L, "n");
lua_rawget(L, t); lua_rawget(L, t);
...@@ -364,7 +364,7 @@ LUALIB_API void ICACHE_FLASH_ATTR luaL_setn (lua_State *L, int t, int n) { ...@@ -364,7 +364,7 @@ LUALIB_API void ICACHE_FLASH_ATTR luaL_setn (lua_State *L, int t, int n) {
} }
LUALIB_API int ICACHE_FLASH_ATTR luaL_getn (lua_State *L, int t) { LUALIB_API int luaL_getn (lua_State *L, int t) {
int n; int n;
t = abs_index(L, t); t = abs_index(L, t);
lua_pushliteral(L, "n"); /* try t.n */ lua_pushliteral(L, "n"); /* try t.n */
...@@ -383,7 +383,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_getn (lua_State *L, int t) { ...@@ -383,7 +383,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_getn (lua_State *L, int t) {
LUALIB_API const char *ICACHE_FLASH_ATTR luaL_gsub (lua_State *L, const char *s, const char *p, LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p,
const char *r) { const char *r) {
const char *wild; const char *wild;
size_t l = c_strlen(p); size_t l = c_strlen(p);
...@@ -400,7 +400,7 @@ LUALIB_API const char *ICACHE_FLASH_ATTR luaL_gsub (lua_State *L, const char *s, ...@@ -400,7 +400,7 @@ LUALIB_API const char *ICACHE_FLASH_ATTR luaL_gsub (lua_State *L, const char *s,
} }
LUALIB_API const char *ICACHE_FLASH_ATTR luaL_findtable (lua_State *L, int idx, LUALIB_API const char *luaL_findtable (lua_State *L, int idx,
const char *fname, int szhint) { const char *fname, int szhint) {
const char *e; const char *e;
lua_pushvalue(L, idx); lua_pushvalue(L, idx);
...@@ -449,7 +449,7 @@ LUALIB_API const char *ICACHE_FLASH_ATTR luaL_findtable (lua_State *L, int idx, ...@@ -449,7 +449,7 @@ LUALIB_API const char *ICACHE_FLASH_ATTR luaL_findtable (lua_State *L, int idx,
#define LIMIT (LUA_MINSTACK/2) #define LIMIT (LUA_MINSTACK/2)
static int ICACHE_FLASH_ATTR emptybuffer (luaL_Buffer *B) { static int emptybuffer (luaL_Buffer *B) {
size_t l = bufflen(B); size_t l = bufflen(B);
if (l == 0) return 0; /* put nothing on stack */ if (l == 0) return 0; /* put nothing on stack */
else { else {
...@@ -461,7 +461,7 @@ static int ICACHE_FLASH_ATTR emptybuffer (luaL_Buffer *B) { ...@@ -461,7 +461,7 @@ static int ICACHE_FLASH_ATTR emptybuffer (luaL_Buffer *B) {
} }
static void ICACHE_FLASH_ATTR adjuststack (luaL_Buffer *B) { static void adjuststack (luaL_Buffer *B) {
if (B->lvl > 1) { if (B->lvl > 1) {
lua_State *L = B->L; lua_State *L = B->L;
int toget = 1; /* number of levels to concat */ int toget = 1; /* number of levels to concat */
...@@ -480,32 +480,32 @@ static void ICACHE_FLASH_ATTR adjuststack (luaL_Buffer *B) { ...@@ -480,32 +480,32 @@ static void ICACHE_FLASH_ATTR adjuststack (luaL_Buffer *B) {
} }
LUALIB_API char *ICACHE_FLASH_ATTR luaL_prepbuffer (luaL_Buffer *B) { LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) {
if (emptybuffer(B)) if (emptybuffer(B))
adjuststack(B); adjuststack(B);
return B->buffer; return B->buffer;
} }
LUALIB_API void ICACHE_FLASH_ATTR luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) {
while (l--) while (l--)
luaL_addchar(B, *s++); luaL_addchar(B, *s++);
} }
LUALIB_API void ICACHE_FLASH_ATTR luaL_addstring (luaL_Buffer *B, const char *s) { LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) {
luaL_addlstring(B, s, c_strlen(s)); luaL_addlstring(B, s, c_strlen(s));
} }
LUALIB_API void ICACHE_FLASH_ATTR luaL_pushresult (luaL_Buffer *B) { LUALIB_API void luaL_pushresult (luaL_Buffer *B) {
emptybuffer(B); emptybuffer(B);
lua_concat(B->L, B->lvl); lua_concat(B->L, B->lvl);
B->lvl = 1; B->lvl = 1;
} }
LUALIB_API void ICACHE_FLASH_ATTR luaL_addvalue (luaL_Buffer *B) { LUALIB_API void luaL_addvalue (luaL_Buffer *B) {
lua_State *L = B->L; lua_State *L = B->L;
size_t vl; size_t vl;
const char *s = lua_tolstring(L, -1, &vl); const char *s = lua_tolstring(L, -1, &vl);
...@@ -523,7 +523,7 @@ LUALIB_API void ICACHE_FLASH_ATTR luaL_addvalue (luaL_Buffer *B) { ...@@ -523,7 +523,7 @@ LUALIB_API void ICACHE_FLASH_ATTR luaL_addvalue (luaL_Buffer *B) {
} }
LUALIB_API void ICACHE_FLASH_ATTR luaL_buffinit (lua_State *L, luaL_Buffer *B) { LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) {
B->L = L; B->L = L;
B->p = B->buffer; B->p = B->buffer;
B->lvl = 0; B->lvl = 0;
...@@ -532,7 +532,7 @@ LUALIB_API void ICACHE_FLASH_ATTR luaL_buffinit (lua_State *L, luaL_Buffer *B) { ...@@ -532,7 +532,7 @@ LUALIB_API void ICACHE_FLASH_ATTR luaL_buffinit (lua_State *L, luaL_Buffer *B) {
/* }====================================================== */ /* }====================================================== */
LUALIB_API int ICACHE_FLASH_ATTR luaL_ref (lua_State *L, int t) { LUALIB_API int luaL_ref (lua_State *L, int t) {
int ref; int ref;
t = abs_index(L, t); t = abs_index(L, t);
if (lua_isnil(L, -1)) { if (lua_isnil(L, -1)) {
...@@ -555,7 +555,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_ref (lua_State *L, int t) { ...@@ -555,7 +555,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_ref (lua_State *L, int t) {
} }
LUALIB_API void ICACHE_FLASH_ATTR luaL_unref (lua_State *L, int t, int ref) { LUALIB_API void luaL_unref (lua_State *L, int t, int ref) {
if (ref >= 0) { if (ref >= 0) {
t = abs_index(L, t); t = abs_index(L, t);
lua_rawgeti(L, t, FREELIST_REF); lua_rawgeti(L, t, FREELIST_REF);
...@@ -582,7 +582,7 @@ typedef struct LoadF { ...@@ -582,7 +582,7 @@ typedef struct LoadF {
} LoadF; } LoadF;
static const char *ICACHE_FLASH_ATTR getF (lua_State *L, void *ud, size_t *size) { static const char *getF (lua_State *L, void *ud, size_t *size) {
LoadF *lf = (LoadF *)ud; LoadF *lf = (LoadF *)ud;
(void)L; (void)L;
if (lf->extraline) { if (lf->extraline) {
...@@ -596,7 +596,7 @@ static const char *ICACHE_FLASH_ATTR getF (lua_State *L, void *ud, size_t *size) ...@@ -596,7 +596,7 @@ static const char *ICACHE_FLASH_ATTR getF (lua_State *L, void *ud, size_t *size)
} }
static int ICACHE_FLASH_ATTR errfile (lua_State *L, const char *what, int fnameindex) { static int errfile (lua_State *L, const char *what, int fnameindex) {
const char *serr = c_strerror(errno); const char *serr = c_strerror(errno);
const char *filename = lua_tostring(L, fnameindex) + 1; const char *filename = lua_tostring(L, fnameindex) + 1;
lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr); lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr);
...@@ -605,7 +605,7 @@ static int ICACHE_FLASH_ATTR errfile (lua_State *L, const char *what, int fnamei ...@@ -605,7 +605,7 @@ static int ICACHE_FLASH_ATTR errfile (lua_State *L, const char *what, int fnamei
} }
LUALIB_API int ICACHE_FLASH_ATTR luaL_loadfile (lua_State *L, const char *filename) { LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
LoadF lf; LoadF lf;
int status, readstatus; int status, readstatus;
int c; int c;
...@@ -656,7 +656,7 @@ typedef struct LoadFSF { ...@@ -656,7 +656,7 @@ typedef struct LoadFSF {
} LoadFSF; } LoadFSF;
static const char *ICACHE_FLASH_ATTR getFSF (lua_State *L, void *ud, size_t *size) { static const char *getFSF (lua_State *L, void *ud, size_t *size) {
LoadFSF *lf = (LoadFSF *)ud; LoadFSF *lf = (LoadFSF *)ud;
(void)L; (void)L;
if (lf->extraline) { if (lf->extraline) {
...@@ -670,7 +670,7 @@ static const char *ICACHE_FLASH_ATTR getFSF (lua_State *L, void *ud, size_t *siz ...@@ -670,7 +670,7 @@ static const char *ICACHE_FLASH_ATTR getFSF (lua_State *L, void *ud, size_t *siz
} }
static int ICACHE_FLASH_ATTR errfsfile (lua_State *L, const char *what, int fnameindex) { static int errfsfile (lua_State *L, const char *what, int fnameindex) {
const char *filename = lua_tostring(L, fnameindex) + 1; const char *filename = lua_tostring(L, fnameindex) + 1;
lua_pushfstring(L, "cannot %s %s", what, filename); lua_pushfstring(L, "cannot %s %s", what, filename);
lua_remove(L, fnameindex); lua_remove(L, fnameindex);
...@@ -678,7 +678,7 @@ static int ICACHE_FLASH_ATTR errfsfile (lua_State *L, const char *what, int fnam ...@@ -678,7 +678,7 @@ static int ICACHE_FLASH_ATTR errfsfile (lua_State *L, const char *what, int fnam
} }
LUALIB_API int ICACHE_FLASH_ATTR luaL_loadfsfile (lua_State *L, const char *filename) { LUALIB_API int luaL_loadfsfile (lua_State *L, const char *filename) {
LoadFSF lf; LoadFSF lf;
int status, readstatus; int status, readstatus;
int c; int c;
...@@ -722,7 +722,7 @@ typedef struct LoadS { ...@@ -722,7 +722,7 @@ typedef struct LoadS {
} LoadS; } LoadS;
static const char *ICACHE_FLASH_ATTR getS (lua_State *L, void *ud, size_t *size) { static const char *getS (lua_State *L, void *ud, size_t *size) {
LoadS *ls = (LoadS *)ud; LoadS *ls = (LoadS *)ud;
(void)L; (void)L;
if (L == NULL && size == NULL) // direct mode check if (L == NULL && size == NULL) // direct mode check
...@@ -734,7 +734,7 @@ static const char *ICACHE_FLASH_ATTR getS (lua_State *L, void *ud, size_t *size) ...@@ -734,7 +734,7 @@ static const char *ICACHE_FLASH_ATTR getS (lua_State *L, void *ud, size_t *size)
} }
LUALIB_API int ICACHE_FLASH_ATTR luaL_loadbuffer (lua_State *L, const char *buff, size_t size, LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size,
const char *name) { const char *name) {
LoadS ls; LoadS ls;
ls.s = buff; ls.s = buff;
...@@ -743,7 +743,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_loadbuffer (lua_State *L, const char *buff ...@@ -743,7 +743,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_loadbuffer (lua_State *L, const char *buff
} }
LUALIB_API int ICACHE_FLASH_ATTR (luaL_loadstring) (lua_State *L, const char *s) { LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s) {
return luaL_loadbuffer(L, s, c_strlen(s), s); return luaL_loadbuffer(L, s, c_strlen(s), s);
} }
...@@ -752,7 +752,7 @@ LUALIB_API int ICACHE_FLASH_ATTR (luaL_loadstring) (lua_State *L, const char *s) ...@@ -752,7 +752,7 @@ LUALIB_API int ICACHE_FLASH_ATTR (luaL_loadstring) (lua_State *L, const char *s)
/* }====================================================== */ /* }====================================================== */
static int ICACHE_FLASH_ATTR l_check_memlimit(lua_State *L, size_t needbytes) { static int l_check_memlimit(lua_State *L, size_t needbytes) {
global_State *g = G(L); global_State *g = G(L);
int cycle_count = 0; int cycle_count = 0;
lu_mem limit = g->memlimit - needbytes; lu_mem limit = g->memlimit - needbytes;
...@@ -770,7 +770,7 @@ static int ICACHE_FLASH_ATTR l_check_memlimit(lua_State *L, size_t needbytes) { ...@@ -770,7 +770,7 @@ static int ICACHE_FLASH_ATTR l_check_memlimit(lua_State *L, size_t needbytes) {
} }
static void *ICACHE_FLASH_ATTR l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
lua_State *L = (lua_State *)ud; lua_State *L = (lua_State *)ud;
int mode = L == NULL ? 0 : G(L)->egcmode; int mode = L == NULL ? 0 : G(L)->egcmode;
void *nptr; void *nptr;
...@@ -797,7 +797,7 @@ static void *ICACHE_FLASH_ATTR l_alloc (void *ud, void *ptr, size_t osize, size_ ...@@ -797,7 +797,7 @@ static void *ICACHE_FLASH_ATTR l_alloc (void *ud, void *ptr, size_t osize, size_
} }
static int ICACHE_FLASH_ATTR panic (lua_State *L) { static int panic (lua_State *L) {
(void)L; /* to avoid warnings */ (void)L; /* to avoid warnings */
#if defined(LUA_USE_STDIO) #if defined(LUA_USE_STDIO)
c_fprintf(c_stderr, "PANIC: unprotected error in call to Lua API (%s)\n", c_fprintf(c_stderr, "PANIC: unprotected error in call to Lua API (%s)\n",
...@@ -810,7 +810,7 @@ static int ICACHE_FLASH_ATTR panic (lua_State *L) { ...@@ -810,7 +810,7 @@ static int ICACHE_FLASH_ATTR panic (lua_State *L) {
} }
LUALIB_API lua_State *ICACHE_FLASH_ATTR luaL_newstate (void) { LUALIB_API lua_State *luaL_newstate (void) {
lua_State *L = lua_newstate(l_alloc, NULL); lua_State *L = lua_newstate(l_alloc, NULL);
lua_setallocf(L, l_alloc, L); /* allocator need lua_State. */ lua_setallocf(L, l_alloc, L); /* allocator need lua_State. */
if (L) lua_atpanic(L, &panic); if (L) lua_atpanic(L, &panic);
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
** model but changing `fputs' to put the strings at a proper place ** model but changing `fputs' to put the strings at a proper place
** (a console window or a log file, for instance). ** (a console window or a log file, for instance).
*/ */
static int ICACHE_FLASH_ATTR luaB_print (lua_State *L) { static int luaB_print (lua_State *L) {
int n = lua_gettop(L); /* number of arguments */ int n = lua_gettop(L); /* number of arguments */
int i; int i;
lua_getglobal(L, "tostring"); lua_getglobal(L, "tostring");
...@@ -60,7 +60,7 @@ static int ICACHE_FLASH_ATTR luaB_print (lua_State *L) { ...@@ -60,7 +60,7 @@ static int ICACHE_FLASH_ATTR luaB_print (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_tonumber (lua_State *L) { static int luaB_tonumber (lua_State *L) {
int base = luaL_optint(L, 2, 10); int base = luaL_optint(L, 2, 10);
if (base == 10) { /* standard conversion */ if (base == 10) { /* standard conversion */
luaL_checkany(L, 1); luaL_checkany(L, 1);
...@@ -88,7 +88,7 @@ static int ICACHE_FLASH_ATTR luaB_tonumber (lua_State *L) { ...@@ -88,7 +88,7 @@ static int ICACHE_FLASH_ATTR luaB_tonumber (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_error (lua_State *L) { static int luaB_error (lua_State *L) {
int level = luaL_optint(L, 2, 1); int level = luaL_optint(L, 2, 1);
lua_settop(L, 1); lua_settop(L, 1);
if (lua_isstring(L, 1) && level > 0) { /* add extra information? */ if (lua_isstring(L, 1) && level > 0) { /* add extra information? */
...@@ -100,7 +100,7 @@ static int ICACHE_FLASH_ATTR luaB_error (lua_State *L) { ...@@ -100,7 +100,7 @@ static int ICACHE_FLASH_ATTR luaB_error (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_getmetatable (lua_State *L) { static int luaB_getmetatable (lua_State *L) {
luaL_checkany(L, 1); luaL_checkany(L, 1);
if (!lua_getmetatable(L, 1)) { if (!lua_getmetatable(L, 1)) {
lua_pushnil(L); lua_pushnil(L);
...@@ -111,7 +111,7 @@ static int ICACHE_FLASH_ATTR luaB_getmetatable (lua_State *L) { ...@@ -111,7 +111,7 @@ static int ICACHE_FLASH_ATTR luaB_getmetatable (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_setmetatable (lua_State *L) { static int luaB_setmetatable (lua_State *L) {
int t = lua_type(L, 2); int t = lua_type(L, 2);
luaL_checktype(L, 1, LUA_TTABLE); luaL_checktype(L, 1, LUA_TTABLE);
luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE || t == LUA_TROTABLE, 2, luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE || t == LUA_TROTABLE, 2,
...@@ -124,7 +124,7 @@ static int ICACHE_FLASH_ATTR luaB_setmetatable (lua_State *L) { ...@@ -124,7 +124,7 @@ static int ICACHE_FLASH_ATTR luaB_setmetatable (lua_State *L) {
} }
static void ICACHE_FLASH_ATTR getfunc (lua_State *L, int opt) { static void getfunc (lua_State *L, int opt) {
if (lua_isfunction(L, 1)) lua_pushvalue(L, 1); if (lua_isfunction(L, 1)) lua_pushvalue(L, 1);
else { else {
lua_Debug ar; lua_Debug ar;
...@@ -140,7 +140,7 @@ static void ICACHE_FLASH_ATTR getfunc (lua_State *L, int opt) { ...@@ -140,7 +140,7 @@ static void ICACHE_FLASH_ATTR getfunc (lua_State *L, int opt) {
} }
static int ICACHE_FLASH_ATTR luaB_getfenv (lua_State *L) { static int luaB_getfenv (lua_State *L) {
getfunc(L, 1); getfunc(L, 1);
if (lua_iscfunction(L, -1)) /* is a C function? */ if (lua_iscfunction(L, -1)) /* is a C function? */
lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the thread's global env. */ lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the thread's global env. */
...@@ -150,7 +150,7 @@ static int ICACHE_FLASH_ATTR luaB_getfenv (lua_State *L) { ...@@ -150,7 +150,7 @@ static int ICACHE_FLASH_ATTR luaB_getfenv (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_setfenv (lua_State *L) { static int luaB_setfenv (lua_State *L) {
luaL_checktype(L, 2, LUA_TTABLE); luaL_checktype(L, 2, LUA_TTABLE);
getfunc(L, 0); getfunc(L, 0);
lua_pushvalue(L, 2); lua_pushvalue(L, 2);
...@@ -168,7 +168,7 @@ static int ICACHE_FLASH_ATTR luaB_setfenv (lua_State *L) { ...@@ -168,7 +168,7 @@ static int ICACHE_FLASH_ATTR luaB_setfenv (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_rawequal (lua_State *L) { static int luaB_rawequal (lua_State *L) {
luaL_checkany(L, 1); luaL_checkany(L, 1);
luaL_checkany(L, 2); luaL_checkany(L, 2);
lua_pushboolean(L, lua_rawequal(L, 1, 2)); lua_pushboolean(L, lua_rawequal(L, 1, 2));
...@@ -176,7 +176,7 @@ static int ICACHE_FLASH_ATTR luaB_rawequal (lua_State *L) { ...@@ -176,7 +176,7 @@ static int ICACHE_FLASH_ATTR luaB_rawequal (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_rawget (lua_State *L) { static int luaB_rawget (lua_State *L) {
luaL_checkanytable(L, 1); luaL_checkanytable(L, 1);
luaL_checkany(L, 2); luaL_checkany(L, 2);
lua_settop(L, 2); lua_settop(L, 2);
...@@ -184,7 +184,7 @@ static int ICACHE_FLASH_ATTR luaB_rawget (lua_State *L) { ...@@ -184,7 +184,7 @@ static int ICACHE_FLASH_ATTR luaB_rawget (lua_State *L) {
return 1; return 1;
} }
static int ICACHE_FLASH_ATTR luaB_rawset (lua_State *L) { static int luaB_rawset (lua_State *L) {
luaL_checktype(L, 1, LUA_TTABLE); luaL_checktype(L, 1, LUA_TTABLE);
luaL_checkany(L, 2); luaL_checkany(L, 2);
luaL_checkany(L, 3); luaL_checkany(L, 3);
...@@ -194,13 +194,13 @@ static int ICACHE_FLASH_ATTR luaB_rawset (lua_State *L) { ...@@ -194,13 +194,13 @@ static int ICACHE_FLASH_ATTR luaB_rawset (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_gcinfo (lua_State *L) { static int luaB_gcinfo (lua_State *L) {
lua_pushinteger(L, lua_getgccount(L)); lua_pushinteger(L, lua_getgccount(L));
return 1; return 1;
} }
static int ICACHE_FLASH_ATTR luaB_collectgarbage (lua_State *L) { static int luaB_collectgarbage (lua_State *L) {
static const char *const opts[] = {"stop", "restart", "collect", static const char *const opts[] = {"stop", "restart", "collect",
"count", "step", "setpause", "setstepmul","setmemlimit","getmemlimit", NULL}; "count", "step", "setpause", "setstepmul","setmemlimit","getmemlimit", NULL};
static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT, static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT,
...@@ -227,14 +227,14 @@ static int ICACHE_FLASH_ATTR luaB_collectgarbage (lua_State *L) { ...@@ -227,14 +227,14 @@ static int ICACHE_FLASH_ATTR luaB_collectgarbage (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_type (lua_State *L) { static int luaB_type (lua_State *L) {
luaL_checkany(L, 1); luaL_checkany(L, 1);
lua_pushstring(L, luaL_typename(L, 1)); lua_pushstring(L, luaL_typename(L, 1));
return 1; return 1;
} }
static int ICACHE_FLASH_ATTR luaB_next (lua_State *L) { static int luaB_next (lua_State *L) {
luaL_checkanytable(L, 1); luaL_checkanytable(L, 1);
lua_settop(L, 2); /* create a 2nd argument if there isn't one */ lua_settop(L, 2); /* create a 2nd argument if there isn't one */
if (lua_next(L, 1)) if (lua_next(L, 1))
...@@ -246,7 +246,7 @@ static int ICACHE_FLASH_ATTR luaB_next (lua_State *L) { ...@@ -246,7 +246,7 @@ static int ICACHE_FLASH_ATTR luaB_next (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_pairs (lua_State *L) { static int luaB_pairs (lua_State *L) {
luaL_checkanytable(L, 1); luaL_checkanytable(L, 1);
lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */ lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */
lua_pushvalue(L, 1); /* state, */ lua_pushvalue(L, 1); /* state, */
...@@ -255,7 +255,7 @@ static int ICACHE_FLASH_ATTR luaB_pairs (lua_State *L) { ...@@ -255,7 +255,7 @@ static int ICACHE_FLASH_ATTR luaB_pairs (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR ipairsaux (lua_State *L) { static int ipairsaux (lua_State *L) {
int i = luaL_checkint(L, 2); int i = luaL_checkint(L, 2);
luaL_checkanytable(L, 1); luaL_checkanytable(L, 1);
i++; /* next value */ i++; /* next value */
...@@ -265,7 +265,7 @@ static int ICACHE_FLASH_ATTR ipairsaux (lua_State *L) { ...@@ -265,7 +265,7 @@ static int ICACHE_FLASH_ATTR ipairsaux (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_ipairs (lua_State *L) { static int luaB_ipairs (lua_State *L) {
luaL_checkanytable(L, 1); luaL_checkanytable(L, 1);
lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */ lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */
lua_pushvalue(L, 1); /* state, */ lua_pushvalue(L, 1); /* state, */
...@@ -274,7 +274,7 @@ static int ICACHE_FLASH_ATTR luaB_ipairs (lua_State *L) { ...@@ -274,7 +274,7 @@ static int ICACHE_FLASH_ATTR luaB_ipairs (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR load_aux (lua_State *L, int status) { static int load_aux (lua_State *L, int status) {
if (status == 0) /* OK? */ if (status == 0) /* OK? */
return 1; return 1;
else { else {
...@@ -285,7 +285,7 @@ static int ICACHE_FLASH_ATTR load_aux (lua_State *L, int status) { ...@@ -285,7 +285,7 @@ static int ICACHE_FLASH_ATTR load_aux (lua_State *L, int status) {
} }
static int ICACHE_FLASH_ATTR luaB_loadstring (lua_State *L) { static int luaB_loadstring (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);
const char *chunkname = luaL_optstring(L, 2, s); const char *chunkname = luaL_optstring(L, 2, s);
...@@ -293,7 +293,7 @@ static int ICACHE_FLASH_ATTR luaB_loadstring (lua_State *L) { ...@@ -293,7 +293,7 @@ static int ICACHE_FLASH_ATTR luaB_loadstring (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_loadfile (lua_State *L) { static int luaB_loadfile (lua_State *L) {
const char *fname = luaL_optstring(L, 1, NULL); const char *fname = luaL_optstring(L, 1, NULL);
#if 0 #if 0
return load_aux(L, luaL_loadfile(L, fname)); return load_aux(L, luaL_loadfile(L, fname));
...@@ -309,7 +309,7 @@ static int ICACHE_FLASH_ATTR luaB_loadfile (lua_State *L) { ...@@ -309,7 +309,7 @@ static int ICACHE_FLASH_ATTR luaB_loadfile (lua_State *L) {
** stack top. Instead, it keeps its resulting string in a ** stack top. Instead, it keeps its resulting string in a
** reserved slot inside the stack. ** reserved slot inside the stack.
*/ */
static const char *ICACHE_FLASH_ATTR generic_reader (lua_State *L, void *ud, size_t *size) { static const char *generic_reader (lua_State *L, void *ud, size_t *size) {
(void)ud; /* to avoid warnings */ (void)ud; /* to avoid warnings */
if (L == NULL && size == NULL) // direct mode check, doesn't happen if (L == NULL && size == NULL) // direct mode check, doesn't happen
return NULL; return NULL;
...@@ -329,7 +329,7 @@ static const char *ICACHE_FLASH_ATTR generic_reader (lua_State *L, void *ud, siz ...@@ -329,7 +329,7 @@ static const char *ICACHE_FLASH_ATTR generic_reader (lua_State *L, void *ud, siz
} }
static int ICACHE_FLASH_ATTR luaB_load (lua_State *L) { static int luaB_load (lua_State *L) {
int status; int status;
const char *cname = luaL_optstring(L, 2, "=(load)"); const char *cname = luaL_optstring(L, 2, "=(load)");
luaL_checktype(L, 1, LUA_TFUNCTION); luaL_checktype(L, 1, LUA_TFUNCTION);
...@@ -339,7 +339,7 @@ static int ICACHE_FLASH_ATTR luaB_load (lua_State *L) { ...@@ -339,7 +339,7 @@ static int ICACHE_FLASH_ATTR luaB_load (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_dofile (lua_State *L) { static int luaB_dofile (lua_State *L) {
const char *fname = luaL_optstring(L, 1, NULL); const char *fname = luaL_optstring(L, 1, NULL);
int n = lua_gettop(L); int n = lua_gettop(L);
#if 0 #if 0
...@@ -352,7 +352,7 @@ static int ICACHE_FLASH_ATTR luaB_dofile (lua_State *L) { ...@@ -352,7 +352,7 @@ static int ICACHE_FLASH_ATTR luaB_dofile (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_assert (lua_State *L) { static int luaB_assert (lua_State *L) {
luaL_checkany(L, 1); luaL_checkany(L, 1);
if (!lua_toboolean(L, 1)) if (!lua_toboolean(L, 1))
return luaL_error(L, "%s", luaL_optstring(L, 2, "assertion failed!")); return luaL_error(L, "%s", luaL_optstring(L, 2, "assertion failed!"));
...@@ -360,7 +360,7 @@ static int ICACHE_FLASH_ATTR luaB_assert (lua_State *L) { ...@@ -360,7 +360,7 @@ static int ICACHE_FLASH_ATTR luaB_assert (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_unpack (lua_State *L) { static int luaB_unpack (lua_State *L) {
int i, e, n; int i, e, n;
luaL_checktype(L, 1, LUA_TTABLE); luaL_checktype(L, 1, LUA_TTABLE);
i = luaL_optint(L, 2, 1); i = luaL_optint(L, 2, 1);
...@@ -376,7 +376,7 @@ static int ICACHE_FLASH_ATTR luaB_unpack (lua_State *L) { ...@@ -376,7 +376,7 @@ static int ICACHE_FLASH_ATTR luaB_unpack (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_select (lua_State *L) { static int luaB_select (lua_State *L) {
int n = lua_gettop(L); int n = lua_gettop(L);
if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') { if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') {
lua_pushinteger(L, n-1); lua_pushinteger(L, n-1);
...@@ -392,7 +392,7 @@ static int ICACHE_FLASH_ATTR luaB_select (lua_State *L) { ...@@ -392,7 +392,7 @@ static int ICACHE_FLASH_ATTR luaB_select (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_pcall (lua_State *L) { static int luaB_pcall (lua_State *L) {
int status; int status;
luaL_checkany(L, 1); luaL_checkany(L, 1);
status = lua_pcall(L, lua_gettop(L) - 1, LUA_MULTRET, 0); status = lua_pcall(L, lua_gettop(L) - 1, LUA_MULTRET, 0);
...@@ -402,7 +402,7 @@ static int ICACHE_FLASH_ATTR luaB_pcall (lua_State *L) { ...@@ -402,7 +402,7 @@ static int ICACHE_FLASH_ATTR luaB_pcall (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_xpcall (lua_State *L) { static int luaB_xpcall (lua_State *L) {
int status; int status;
luaL_checkany(L, 2); luaL_checkany(L, 2);
lua_settop(L, 2); lua_settop(L, 2);
...@@ -414,7 +414,7 @@ static int ICACHE_FLASH_ATTR luaB_xpcall (lua_State *L) { ...@@ -414,7 +414,7 @@ static int ICACHE_FLASH_ATTR luaB_xpcall (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_tostring (lua_State *L) { static int luaB_tostring (lua_State *L) {
luaL_checkany(L, 1); luaL_checkany(L, 1);
if (luaL_callmeta(L, 1, "__tostring")) /* is there a metafield? */ if (luaL_callmeta(L, 1, "__tostring")) /* is there a metafield? */
return 1; /* use its value */ return 1; /* use its value */
...@@ -439,7 +439,7 @@ static int ICACHE_FLASH_ATTR luaB_tostring (lua_State *L) { ...@@ -439,7 +439,7 @@ static int ICACHE_FLASH_ATTR luaB_tostring (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_newproxy (lua_State *L) { static int luaB_newproxy (lua_State *L) {
lua_settop(L, 1); lua_settop(L, 1);
lua_newuserdata(L, 0); /* create proxy */ lua_newuserdata(L, 0); /* create proxy */
if (lua_toboolean(L, 1) == 0) if (lua_toboolean(L, 1) == 0)
...@@ -500,7 +500,7 @@ const LUA_REG_TYPE base_funcs_list[] = { ...@@ -500,7 +500,7 @@ const LUA_REG_TYPE base_funcs_list[] = {
#endif #endif
static int ICACHE_FLASH_ATTR luaB_index(lua_State *L) { static int luaB_index(lua_State *L) {
#if LUA_OPTIMIZE_MEMORY == 2 #if LUA_OPTIMIZE_MEMORY == 2
int fres; int fres;
if ((fres = luaR_findfunction(L, base_funcs_list)) != 0) if ((fres = luaR_findfunction(L, base_funcs_list)) != 0)
...@@ -546,7 +546,7 @@ static const luaL_Reg base_funcs[] = { ...@@ -546,7 +546,7 @@ static const luaL_Reg base_funcs[] = {
static const char *const statnames[] = static const char *const statnames[] =
{"running", "suspended", "normal", "dead"}; {"running", "suspended", "normal", "dead"};
static int ICACHE_FLASH_ATTR costatus (lua_State *L, lua_State *co) { static int costatus (lua_State *L, lua_State *co) {
if (L == co) return CO_RUN; if (L == co) return CO_RUN;
switch (lua_status(co)) { switch (lua_status(co)) {
case LUA_YIELD: case LUA_YIELD:
...@@ -566,7 +566,7 @@ static int ICACHE_FLASH_ATTR costatus (lua_State *L, lua_State *co) { ...@@ -566,7 +566,7 @@ static int ICACHE_FLASH_ATTR costatus (lua_State *L, lua_State *co) {
} }
static int ICACHE_FLASH_ATTR luaB_costatus (lua_State *L) { static int luaB_costatus (lua_State *L) {
lua_State *co = lua_tothread(L, 1); lua_State *co = lua_tothread(L, 1);
luaL_argcheck(L, co, 1, "coroutine expected"); luaL_argcheck(L, co, 1, "coroutine expected");
lua_pushstring(L, statnames[costatus(L, co)]); lua_pushstring(L, statnames[costatus(L, co)]);
...@@ -574,7 +574,7 @@ static int ICACHE_FLASH_ATTR luaB_costatus (lua_State *L) { ...@@ -574,7 +574,7 @@ static int ICACHE_FLASH_ATTR luaB_costatus (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR auxresume (lua_State *L, lua_State *co, int narg) { static int auxresume (lua_State *L, lua_State *co, int narg) {
int status = costatus(L, co); int status = costatus(L, co);
if (!lua_checkstack(co, narg)) if (!lua_checkstack(co, narg))
luaL_error(L, "too many arguments to resume"); luaL_error(L, "too many arguments to resume");
...@@ -599,7 +599,7 @@ static int ICACHE_FLASH_ATTR auxresume (lua_State *L, lua_State *co, int narg) { ...@@ -599,7 +599,7 @@ static int ICACHE_FLASH_ATTR auxresume (lua_State *L, lua_State *co, int narg) {
} }
static int ICACHE_FLASH_ATTR luaB_coresume (lua_State *L) { static int luaB_coresume (lua_State *L) {
lua_State *co = lua_tothread(L, 1); lua_State *co = lua_tothread(L, 1);
int r; int r;
luaL_argcheck(L, co, 1, "coroutine expected"); luaL_argcheck(L, co, 1, "coroutine expected");
...@@ -617,7 +617,7 @@ static int ICACHE_FLASH_ATTR luaB_coresume (lua_State *L) { ...@@ -617,7 +617,7 @@ static int ICACHE_FLASH_ATTR luaB_coresume (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_auxwrap (lua_State *L) { static int luaB_auxwrap (lua_State *L) {
lua_State *co = lua_tothread(L, lua_upvalueindex(1)); lua_State *co = lua_tothread(L, lua_upvalueindex(1));
int r = auxresume(L, co, lua_gettop(L)); int r = auxresume(L, co, lua_gettop(L));
if (r < 0) { if (r < 0) {
...@@ -632,7 +632,7 @@ static int ICACHE_FLASH_ATTR luaB_auxwrap (lua_State *L) { ...@@ -632,7 +632,7 @@ static int ICACHE_FLASH_ATTR luaB_auxwrap (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_cocreate (lua_State *L) { static int luaB_cocreate (lua_State *L) {
lua_State *NL = lua_newthread(L); lua_State *NL = lua_newthread(L);
luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1, luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1,
"Lua function expected"); "Lua function expected");
...@@ -642,19 +642,19 @@ static int ICACHE_FLASH_ATTR luaB_cocreate (lua_State *L) { ...@@ -642,19 +642,19 @@ static int ICACHE_FLASH_ATTR luaB_cocreate (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_cowrap (lua_State *L) { static int luaB_cowrap (lua_State *L) {
luaB_cocreate(L); luaB_cocreate(L);
lua_pushcclosure(L, luaB_auxwrap, 1); lua_pushcclosure(L, luaB_auxwrap, 1);
return 1; return 1;
} }
static int ICACHE_FLASH_ATTR luaB_yield (lua_State *L) { static int luaB_yield (lua_State *L) {
return lua_yield(L, lua_gettop(L)); return lua_yield(L, lua_gettop(L));
} }
static int ICACHE_FLASH_ATTR luaB_corunning (lua_State *L) { static int luaB_corunning (lua_State *L) {
if (lua_pushthread(L)) if (lua_pushthread(L))
lua_pushnil(L); /* main thread is not a coroutine */ lua_pushnil(L); /* main thread is not a coroutine */
return 1; return 1;
...@@ -676,7 +676,7 @@ const LUA_REG_TYPE co_funcs[] = { ...@@ -676,7 +676,7 @@ const LUA_REG_TYPE co_funcs[] = {
/* }====================================================== */ /* }====================================================== */
static void ICACHE_FLASH_ATTR auxopen (lua_State *L, const char *name, static void auxopen (lua_State *L, const char *name,
lua_CFunction f, lua_CFunction u) { lua_CFunction f, lua_CFunction u) {
lua_pushcfunction(L, u); lua_pushcfunction(L, u);
lua_pushcclosure(L, f, 1); lua_pushcclosure(L, f, 1);
...@@ -684,7 +684,7 @@ static void ICACHE_FLASH_ATTR auxopen (lua_State *L, const char *name, ...@@ -684,7 +684,7 @@ static void ICACHE_FLASH_ATTR auxopen (lua_State *L, const char *name,
} }
static void ICACHE_FLASH_ATTR base_open (lua_State *L) { static void base_open (lua_State *L) {
/* set global _G */ /* set global _G */
lua_pushvalue(L, LUA_GLOBALSINDEX); lua_pushvalue(L, LUA_GLOBALSINDEX);
lua_setglobal(L, "_G"); lua_setglobal(L, "_G");
...@@ -711,7 +711,7 @@ static void ICACHE_FLASH_ATTR base_open (lua_State *L) { ...@@ -711,7 +711,7 @@ static void ICACHE_FLASH_ATTR base_open (lua_State *L) {
} }
LUALIB_API int ICACHE_FLASH_ATTR luaopen_base (lua_State *L) { LUALIB_API int luaopen_base (lua_State *L) {
base_open(L); base_open(L);
#if LUA_OPTIMIZE_MEMORY == 0 #if LUA_OPTIMIZE_MEMORY == 0
luaL_register(L, LUA_COLIBNAME, co_funcs); luaL_register(L, LUA_COLIBNAME, co_funcs);
......
...@@ -27,12 +27,12 @@ ...@@ -27,12 +27,12 @@
#define hasjumps(e) ((e)->t != (e)->f) #define hasjumps(e) ((e)->t != (e)->f)
static int ICACHE_FLASH_ATTR isnumeral(expdesc *e) { static int isnumeral(expdesc *e) {
return (e->k == VKNUM && e->t == NO_JUMP && e->f == NO_JUMP); return (e->k == VKNUM && e->t == NO_JUMP && e->f == NO_JUMP);
} }
void ICACHE_FLASH_ATTR luaK_nil (FuncState *fs, int from, int n) { void luaK_nil (FuncState *fs, int from, int n) {
Instruction *previous; Instruction *previous;
if (fs->pc > fs->lasttarget) { /* no jumps to current position? */ if (fs->pc > fs->lasttarget) { /* no jumps to current position? */
if (fs->pc == 0) { /* function start? */ if (fs->pc == 0) { /* function start? */
...@@ -56,7 +56,7 @@ void ICACHE_FLASH_ATTR luaK_nil (FuncState *fs, int from, int n) { ...@@ -56,7 +56,7 @@ void ICACHE_FLASH_ATTR luaK_nil (FuncState *fs, int from, int n) {
} }
int ICACHE_FLASH_ATTR luaK_jump (FuncState *fs) { int luaK_jump (FuncState *fs) {
int jpc = fs->jpc; /* save list of jumps to here */ int jpc = fs->jpc; /* save list of jumps to here */
int j; int j;
fs->jpc = NO_JUMP; fs->jpc = NO_JUMP;
...@@ -66,18 +66,18 @@ int ICACHE_FLASH_ATTR luaK_jump (FuncState *fs) { ...@@ -66,18 +66,18 @@ int ICACHE_FLASH_ATTR luaK_jump (FuncState *fs) {
} }
void ICACHE_FLASH_ATTR luaK_ret (FuncState *fs, int first, int nret) { void luaK_ret (FuncState *fs, int first, int nret) {
luaK_codeABC(fs, OP_RETURN, first, nret+1, 0); luaK_codeABC(fs, OP_RETURN, first, nret+1, 0);
} }
static int ICACHE_FLASH_ATTR condjump (FuncState *fs, OpCode op, int A, int B, int C) { static int condjump (FuncState *fs, OpCode op, int A, int B, int C) {
luaK_codeABC(fs, op, A, B, C); luaK_codeABC(fs, op, A, B, C);
return luaK_jump(fs); return luaK_jump(fs);
} }
static void ICACHE_FLASH_ATTR fixjump (FuncState *fs, int pc, int dest) { static void fixjump (FuncState *fs, int pc, int dest) {
Instruction *jmp = &fs->f->code[pc]; Instruction *jmp = &fs->f->code[pc];
int offset = dest-(pc+1); int offset = dest-(pc+1);
lua_assert(dest != NO_JUMP); lua_assert(dest != NO_JUMP);
...@@ -91,13 +91,13 @@ static void ICACHE_FLASH_ATTR fixjump (FuncState *fs, int pc, int dest) { ...@@ -91,13 +91,13 @@ static void ICACHE_FLASH_ATTR fixjump (FuncState *fs, int pc, int dest) {
** returns current `pc' and marks it as a jump target (to avoid wrong ** returns current `pc' and marks it as a jump target (to avoid wrong
** optimizations with consecutive instructions not in the same basic block). ** optimizations with consecutive instructions not in the same basic block).
*/ */
int ICACHE_FLASH_ATTR luaK_getlabel (FuncState *fs) { int luaK_getlabel (FuncState *fs) {
fs->lasttarget = fs->pc; fs->lasttarget = fs->pc;
return fs->pc; return fs->pc;
} }
static int ICACHE_FLASH_ATTR getjump (FuncState *fs, int pc) { static int getjump (FuncState *fs, int pc) {
int offset = GETARG_sBx(fs->f->code[pc]); int offset = GETARG_sBx(fs->f->code[pc]);
if (offset == NO_JUMP) /* point to itself represents end of list */ if (offset == NO_JUMP) /* point to itself represents end of list */
return NO_JUMP; /* end of list */ return NO_JUMP; /* end of list */
...@@ -106,7 +106,7 @@ static int ICACHE_FLASH_ATTR getjump (FuncState *fs, int pc) { ...@@ -106,7 +106,7 @@ static int ICACHE_FLASH_ATTR getjump (FuncState *fs, int pc) {
} }
static Instruction *ICACHE_FLASH_ATTR getjumpcontrol (FuncState *fs, int pc) { static Instruction *getjumpcontrol (FuncState *fs, int pc) {
Instruction *pi = &fs->f->code[pc]; Instruction *pi = &fs->f->code[pc];
if (pc >= 1 && testTMode(GET_OPCODE(*(pi-1)))) if (pc >= 1 && testTMode(GET_OPCODE(*(pi-1))))
return pi-1; return pi-1;
...@@ -119,7 +119,7 @@ static Instruction *ICACHE_FLASH_ATTR getjumpcontrol (FuncState *fs, int pc) { ...@@ -119,7 +119,7 @@ static Instruction *ICACHE_FLASH_ATTR getjumpcontrol (FuncState *fs, int pc) {
** check whether list has any jump that do not produce a value ** check whether list has any jump that do not produce a value
** (or produce an inverted value) ** (or produce an inverted value)
*/ */
static int ICACHE_FLASH_ATTR need_value (FuncState *fs, int list) { static int need_value (FuncState *fs, int list) {
for (; list != NO_JUMP; list = getjump(fs, list)) { for (; list != NO_JUMP; list = getjump(fs, list)) {
Instruction i = *getjumpcontrol(fs, list); Instruction i = *getjumpcontrol(fs, list);
if (GET_OPCODE(i) != OP_TESTSET) return 1; if (GET_OPCODE(i) != OP_TESTSET) return 1;
...@@ -128,7 +128,7 @@ static int ICACHE_FLASH_ATTR need_value (FuncState *fs, int list) { ...@@ -128,7 +128,7 @@ static int ICACHE_FLASH_ATTR need_value (FuncState *fs, int list) {
} }
static int ICACHE_FLASH_ATTR patchtestreg (FuncState *fs, int node, int reg) { static int patchtestreg (FuncState *fs, int node, int reg) {
Instruction *i = getjumpcontrol(fs, node); Instruction *i = getjumpcontrol(fs, node);
if (GET_OPCODE(*i) != OP_TESTSET) if (GET_OPCODE(*i) != OP_TESTSET)
return 0; /* cannot patch other instructions */ return 0; /* cannot patch other instructions */
...@@ -141,13 +141,13 @@ static int ICACHE_FLASH_ATTR patchtestreg (FuncState *fs, int node, int reg) { ...@@ -141,13 +141,13 @@ static int ICACHE_FLASH_ATTR patchtestreg (FuncState *fs, int node, int reg) {
} }
static void ICACHE_FLASH_ATTR removevalues (FuncState *fs, int list) { static void removevalues (FuncState *fs, int list) {
for (; list != NO_JUMP; list = getjump(fs, list)) for (; list != NO_JUMP; list = getjump(fs, list))
patchtestreg(fs, list, NO_REG); patchtestreg(fs, list, NO_REG);
} }
static void ICACHE_FLASH_ATTR patchlistaux (FuncState *fs, int list, int vtarget, int reg, static void patchlistaux (FuncState *fs, int list, int vtarget, int reg,
int dtarget) { int dtarget) {
while (list != NO_JUMP) { while (list != NO_JUMP) {
int next = getjump(fs, list); int next = getjump(fs, list);
...@@ -160,13 +160,13 @@ static void ICACHE_FLASH_ATTR patchlistaux (FuncState *fs, int list, int vtarget ...@@ -160,13 +160,13 @@ static void ICACHE_FLASH_ATTR patchlistaux (FuncState *fs, int list, int vtarget
} }
static void ICACHE_FLASH_ATTR dischargejpc (FuncState *fs) { static void dischargejpc (FuncState *fs) {
patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc); patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc);
fs->jpc = NO_JUMP; fs->jpc = NO_JUMP;
} }
void ICACHE_FLASH_ATTR luaK_patchlist (FuncState *fs, int list, int target) { void luaK_patchlist (FuncState *fs, int list, int target) {
if (target == fs->pc) if (target == fs->pc)
luaK_patchtohere(fs, list); luaK_patchtohere(fs, list);
else { else {
...@@ -176,13 +176,13 @@ void ICACHE_FLASH_ATTR luaK_patchlist (FuncState *fs, int list, int target) { ...@@ -176,13 +176,13 @@ void ICACHE_FLASH_ATTR luaK_patchlist (FuncState *fs, int list, int target) {
} }
void ICACHE_FLASH_ATTR luaK_patchtohere (FuncState *fs, int list) { void luaK_patchtohere (FuncState *fs, int list) {
luaK_getlabel(fs); luaK_getlabel(fs);
luaK_concat(fs, &fs->jpc, list); luaK_concat(fs, &fs->jpc, list);
} }
void ICACHE_FLASH_ATTR luaK_concat (FuncState *fs, int *l1, int l2) { void luaK_concat (FuncState *fs, int *l1, int l2) {
if (l2 == NO_JUMP) return; if (l2 == NO_JUMP) return;
else if (*l1 == NO_JUMP) else if (*l1 == NO_JUMP)
*l1 = l2; *l1 = l2;
...@@ -196,7 +196,7 @@ void ICACHE_FLASH_ATTR luaK_concat (FuncState *fs, int *l1, int l2) { ...@@ -196,7 +196,7 @@ void ICACHE_FLASH_ATTR luaK_concat (FuncState *fs, int *l1, int l2) {
} }
void ICACHE_FLASH_ATTR luaK_checkstack (FuncState *fs, int n) { void luaK_checkstack (FuncState *fs, int n) {
int newstack = fs->freereg + n; int newstack = fs->freereg + n;
if (newstack > fs->f->maxstacksize) { if (newstack > fs->f->maxstacksize) {
if (newstack >= MAXSTACK) if (newstack >= MAXSTACK)
...@@ -206,13 +206,13 @@ void ICACHE_FLASH_ATTR luaK_checkstack (FuncState *fs, int n) { ...@@ -206,13 +206,13 @@ void ICACHE_FLASH_ATTR luaK_checkstack (FuncState *fs, int n) {
} }
void ICACHE_FLASH_ATTR luaK_reserveregs (FuncState *fs, int n) { void luaK_reserveregs (FuncState *fs, int n) {
luaK_checkstack(fs, n); luaK_checkstack(fs, n);
fs->freereg += n; fs->freereg += n;
} }
static void ICACHE_FLASH_ATTR freereg (FuncState *fs, int reg) { static void freereg (FuncState *fs, int reg) {
if (!ISK(reg) && reg >= fs->nactvar) { if (!ISK(reg) && reg >= fs->nactvar) {
fs->freereg--; fs->freereg--;
lua_assert(reg == fs->freereg); lua_assert(reg == fs->freereg);
...@@ -220,13 +220,13 @@ static void ICACHE_FLASH_ATTR freereg (FuncState *fs, int reg) { ...@@ -220,13 +220,13 @@ static void ICACHE_FLASH_ATTR freereg (FuncState *fs, int reg) {
} }
static void ICACHE_FLASH_ATTR freeexp (FuncState *fs, expdesc *e) { static void freeexp (FuncState *fs, expdesc *e) {
if (e->k == VNONRELOC) if (e->k == VNONRELOC)
freereg(fs, e->u.s.info); freereg(fs, e->u.s.info);
} }
static int ICACHE_FLASH_ATTR addk (FuncState *fs, TValue *k, TValue *v) { static int addk (FuncState *fs, TValue *k, TValue *v) {
lua_State *L = fs->L; lua_State *L = fs->L;
TValue *idx = luaH_set(L, fs->h, k); TValue *idx = luaH_set(L, fs->h, k);
Proto *f = fs->f; Proto *f = fs->f;
...@@ -247,28 +247,28 @@ static int ICACHE_FLASH_ATTR addk (FuncState *fs, TValue *k, TValue *v) { ...@@ -247,28 +247,28 @@ static int ICACHE_FLASH_ATTR addk (FuncState *fs, TValue *k, TValue *v) {
} }
int ICACHE_FLASH_ATTR luaK_stringK (FuncState *fs, TString *s) { int luaK_stringK (FuncState *fs, TString *s) {
TValue o; TValue o;
setsvalue(fs->L, &o, s); setsvalue(fs->L, &o, s);
return addk(fs, &o, &o); return addk(fs, &o, &o);
} }
int ICACHE_FLASH_ATTR luaK_numberK (FuncState *fs, lua_Number r) { int luaK_numberK (FuncState *fs, lua_Number r) {
TValue o; TValue o;
setnvalue(&o, r); setnvalue(&o, r);
return addk(fs, &o, &o); return addk(fs, &o, &o);
} }
static int ICACHE_FLASH_ATTR boolK (FuncState *fs, int b) { static int boolK (FuncState *fs, int b) {
TValue o; TValue o;
setbvalue(&o, b); setbvalue(&o, b);
return addk(fs, &o, &o); return addk(fs, &o, &o);
} }
static int ICACHE_FLASH_ATTR nilK (FuncState *fs) { static int nilK (FuncState *fs) {
TValue k, v; TValue k, v;
setnilvalue(&v); setnilvalue(&v);
/* cannot use nil as key; instead use table itself to represent nil */ /* cannot use nil as key; instead use table itself to represent nil */
...@@ -277,7 +277,7 @@ static int ICACHE_FLASH_ATTR nilK (FuncState *fs) { ...@@ -277,7 +277,7 @@ static int ICACHE_FLASH_ATTR nilK (FuncState *fs) {
} }
void ICACHE_FLASH_ATTR luaK_setreturns (FuncState *fs, expdesc *e, int nresults) { void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) {
if (e->k == VCALL) { /* expression is an open function call? */ if (e->k == VCALL) { /* expression is an open function call? */
SETARG_C(getcode(fs, e), nresults+1); SETARG_C(getcode(fs, e), nresults+1);
} }
...@@ -289,7 +289,7 @@ void ICACHE_FLASH_ATTR luaK_setreturns (FuncState *fs, expdesc *e, int nresults) ...@@ -289,7 +289,7 @@ void ICACHE_FLASH_ATTR luaK_setreturns (FuncState *fs, expdesc *e, int nresults)
} }
void ICACHE_FLASH_ATTR luaK_setoneret (FuncState *fs, expdesc *e) { void luaK_setoneret (FuncState *fs, expdesc *e) {
if (e->k == VCALL) { /* expression is an open function call? */ if (e->k == VCALL) { /* expression is an open function call? */
e->k = VNONRELOC; e->k = VNONRELOC;
e->u.s.info = GETARG_A(getcode(fs, e)); e->u.s.info = GETARG_A(getcode(fs, e));
...@@ -301,7 +301,7 @@ void ICACHE_FLASH_ATTR luaK_setoneret (FuncState *fs, expdesc *e) { ...@@ -301,7 +301,7 @@ void ICACHE_FLASH_ATTR luaK_setoneret (FuncState *fs, expdesc *e) {
} }
void ICACHE_FLASH_ATTR luaK_dischargevars (FuncState *fs, expdesc *e) { void luaK_dischargevars (FuncState *fs, expdesc *e) {
switch (e->k) { switch (e->k) {
case VLOCAL: { case VLOCAL: {
e->k = VNONRELOC; e->k = VNONRELOC;
...@@ -334,13 +334,13 @@ void ICACHE_FLASH_ATTR luaK_dischargevars (FuncState *fs, expdesc *e) { ...@@ -334,13 +334,13 @@ void ICACHE_FLASH_ATTR luaK_dischargevars (FuncState *fs, expdesc *e) {
} }
static int ICACHE_FLASH_ATTR code_label (FuncState *fs, int A, int b, int jump) { static int code_label (FuncState *fs, int A, int b, int jump) {
luaK_getlabel(fs); /* those instructions may be jump targets */ luaK_getlabel(fs); /* those instructions may be jump targets */
return luaK_codeABC(fs, OP_LOADBOOL, A, b, jump); return luaK_codeABC(fs, OP_LOADBOOL, A, b, jump);
} }
static void ICACHE_FLASH_ATTR discharge2reg (FuncState *fs, expdesc *e, int reg) { static void discharge2reg (FuncState *fs, expdesc *e, int reg) {
luaK_dischargevars(fs, e); luaK_dischargevars(fs, e);
switch (e->k) { switch (e->k) {
case VNIL: { case VNIL: {
...@@ -379,7 +379,7 @@ static void ICACHE_FLASH_ATTR discharge2reg (FuncState *fs, expdesc *e, int reg) ...@@ -379,7 +379,7 @@ static void ICACHE_FLASH_ATTR discharge2reg (FuncState *fs, expdesc *e, int reg)
} }
static void ICACHE_FLASH_ATTR discharge2anyreg (FuncState *fs, expdesc *e) { static void discharge2anyreg (FuncState *fs, expdesc *e) {
if (e->k != VNONRELOC) { if (e->k != VNONRELOC) {
luaK_reserveregs(fs, 1); luaK_reserveregs(fs, 1);
discharge2reg(fs, e, fs->freereg-1); discharge2reg(fs, e, fs->freereg-1);
...@@ -387,7 +387,7 @@ static void ICACHE_FLASH_ATTR discharge2anyreg (FuncState *fs, expdesc *e) { ...@@ -387,7 +387,7 @@ static void ICACHE_FLASH_ATTR discharge2anyreg (FuncState *fs, expdesc *e) {
} }
static void ICACHE_FLASH_ATTR exp2reg (FuncState *fs, expdesc *e, int reg) { static void exp2reg (FuncState *fs, expdesc *e, int reg) {
discharge2reg(fs, e, reg); discharge2reg(fs, e, reg);
if (e->k == VJMP) if (e->k == VJMP)
luaK_concat(fs, &e->t, e->u.s.info); /* put this jump in `t' list */ luaK_concat(fs, &e->t, e->u.s.info); /* put this jump in `t' list */
...@@ -411,7 +411,7 @@ static void ICACHE_FLASH_ATTR exp2reg (FuncState *fs, expdesc *e, int reg) { ...@@ -411,7 +411,7 @@ static void ICACHE_FLASH_ATTR exp2reg (FuncState *fs, expdesc *e, int reg) {
} }
void ICACHE_FLASH_ATTR luaK_exp2nextreg (FuncState *fs, expdesc *e) { void luaK_exp2nextreg (FuncState *fs, expdesc *e) {
luaK_dischargevars(fs, e); luaK_dischargevars(fs, e);
freeexp(fs, e); freeexp(fs, e);
luaK_reserveregs(fs, 1); luaK_reserveregs(fs, 1);
...@@ -419,7 +419,7 @@ void ICACHE_FLASH_ATTR luaK_exp2nextreg (FuncState *fs, expdesc *e) { ...@@ -419,7 +419,7 @@ void ICACHE_FLASH_ATTR luaK_exp2nextreg (FuncState *fs, expdesc *e) {
} }
int ICACHE_FLASH_ATTR luaK_exp2anyreg (FuncState *fs, expdesc *e) { int luaK_exp2anyreg (FuncState *fs, expdesc *e) {
luaK_dischargevars(fs, e); luaK_dischargevars(fs, e);
if (e->k == VNONRELOC) { if (e->k == VNONRELOC) {
if (!hasjumps(e)) return e->u.s.info; /* exp is already in a register */ if (!hasjumps(e)) return e->u.s.info; /* exp is already in a register */
...@@ -433,7 +433,7 @@ int ICACHE_FLASH_ATTR luaK_exp2anyreg (FuncState *fs, expdesc *e) { ...@@ -433,7 +433,7 @@ int ICACHE_FLASH_ATTR luaK_exp2anyreg (FuncState *fs, expdesc *e) {
} }
void ICACHE_FLASH_ATTR luaK_exp2val (FuncState *fs, expdesc *e) { void luaK_exp2val (FuncState *fs, expdesc *e) {
if (hasjumps(e)) if (hasjumps(e))
luaK_exp2anyreg(fs, e); luaK_exp2anyreg(fs, e);
else else
...@@ -441,7 +441,7 @@ void ICACHE_FLASH_ATTR luaK_exp2val (FuncState *fs, expdesc *e) { ...@@ -441,7 +441,7 @@ void ICACHE_FLASH_ATTR luaK_exp2val (FuncState *fs, expdesc *e) {
} }
int ICACHE_FLASH_ATTR luaK_exp2RK (FuncState *fs, expdesc *e) { int luaK_exp2RK (FuncState *fs, expdesc *e) {
luaK_exp2val(fs, e); luaK_exp2val(fs, e);
switch (e->k) { switch (e->k) {
case VKNUM: case VKNUM:
...@@ -469,7 +469,7 @@ int ICACHE_FLASH_ATTR luaK_exp2RK (FuncState *fs, expdesc *e) { ...@@ -469,7 +469,7 @@ int ICACHE_FLASH_ATTR luaK_exp2RK (FuncState *fs, expdesc *e) {
} }
void ICACHE_FLASH_ATTR luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) { void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) {
switch (var->k) { switch (var->k) {
case VLOCAL: { case VLOCAL: {
freeexp(fs, ex); freeexp(fs, ex);
...@@ -500,7 +500,7 @@ void ICACHE_FLASH_ATTR luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) ...@@ -500,7 +500,7 @@ void ICACHE_FLASH_ATTR luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex)
} }
void ICACHE_FLASH_ATTR luaK_self (FuncState *fs, expdesc *e, expdesc *key) { void luaK_self (FuncState *fs, expdesc *e, expdesc *key) {
int func; int func;
luaK_exp2anyreg(fs, e); luaK_exp2anyreg(fs, e);
freeexp(fs, e); freeexp(fs, e);
...@@ -513,7 +513,7 @@ void ICACHE_FLASH_ATTR luaK_self (FuncState *fs, expdesc *e, expdesc *key) { ...@@ -513,7 +513,7 @@ void ICACHE_FLASH_ATTR luaK_self (FuncState *fs, expdesc *e, expdesc *key) {
} }
static void ICACHE_FLASH_ATTR invertjump (FuncState *fs, expdesc *e) { static void invertjump (FuncState *fs, expdesc *e) {
Instruction *pc = getjumpcontrol(fs, e->u.s.info); Instruction *pc = getjumpcontrol(fs, e->u.s.info);
lua_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET && lua_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET &&
GET_OPCODE(*pc) != OP_TEST); GET_OPCODE(*pc) != OP_TEST);
...@@ -521,7 +521,7 @@ static void ICACHE_FLASH_ATTR invertjump (FuncState *fs, expdesc *e) { ...@@ -521,7 +521,7 @@ static void ICACHE_FLASH_ATTR invertjump (FuncState *fs, expdesc *e) {
} }
static int ICACHE_FLASH_ATTR jumponcond (FuncState *fs, expdesc *e, int cond) { static int jumponcond (FuncState *fs, expdesc *e, int cond) {
if (e->k == VRELOCABLE) { if (e->k == VRELOCABLE) {
Instruction ie = getcode(fs, e); Instruction ie = getcode(fs, e);
if (GET_OPCODE(ie) == OP_NOT) { if (GET_OPCODE(ie) == OP_NOT) {
...@@ -536,7 +536,7 @@ static int ICACHE_FLASH_ATTR jumponcond (FuncState *fs, expdesc *e, int cond) { ...@@ -536,7 +536,7 @@ static int ICACHE_FLASH_ATTR jumponcond (FuncState *fs, expdesc *e, int cond) {
} }
void ICACHE_FLASH_ATTR luaK_goiftrue (FuncState *fs, expdesc *e) { void luaK_goiftrue (FuncState *fs, expdesc *e) {
int pc; /* pc of last jump */ int pc; /* pc of last jump */
luaK_dischargevars(fs, e); luaK_dischargevars(fs, e);
switch (e->k) { switch (e->k) {
...@@ -560,7 +560,7 @@ void ICACHE_FLASH_ATTR luaK_goiftrue (FuncState *fs, expdesc *e) { ...@@ -560,7 +560,7 @@ void ICACHE_FLASH_ATTR luaK_goiftrue (FuncState *fs, expdesc *e) {
} }
static void ICACHE_FLASH_ATTR luaK_goiffalse (FuncState *fs, expdesc *e) { static void luaK_goiffalse (FuncState *fs, expdesc *e) {
int pc; /* pc of last jump */ int pc; /* pc of last jump */
luaK_dischargevars(fs, e); luaK_dischargevars(fs, e);
switch (e->k) { switch (e->k) {
...@@ -583,7 +583,7 @@ static void ICACHE_FLASH_ATTR luaK_goiffalse (FuncState *fs, expdesc *e) { ...@@ -583,7 +583,7 @@ static void ICACHE_FLASH_ATTR luaK_goiffalse (FuncState *fs, expdesc *e) {
} }
static void ICACHE_FLASH_ATTR codenot (FuncState *fs, expdesc *e) { static void codenot (FuncState *fs, expdesc *e) {
luaK_dischargevars(fs, e); luaK_dischargevars(fs, e);
switch (e->k) { switch (e->k) {
case VNIL: case VFALSE: { case VNIL: case VFALSE: {
...@@ -618,13 +618,13 @@ static void ICACHE_FLASH_ATTR codenot (FuncState *fs, expdesc *e) { ...@@ -618,13 +618,13 @@ static void ICACHE_FLASH_ATTR codenot (FuncState *fs, expdesc *e) {
} }
void ICACHE_FLASH_ATTR luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
t->u.s.aux = luaK_exp2RK(fs, k); t->u.s.aux = luaK_exp2RK(fs, k);
t->k = VINDEXED; t->k = VINDEXED;
} }
static int ICACHE_FLASH_ATTR constfolding (OpCode op, expdesc *e1, expdesc *e2) { static int constfolding (OpCode op, expdesc *e1, expdesc *e2) {
lua_Number v1, v2, r; lua_Number v1, v2, r;
if (!isnumeral(e1) || !isnumeral(e2)) return 0; if (!isnumeral(e1) || !isnumeral(e2)) return 0;
v1 = e1->u.nval; v1 = e1->u.nval;
...@@ -650,7 +650,7 @@ static int ICACHE_FLASH_ATTR constfolding (OpCode op, expdesc *e1, expdesc *e2) ...@@ -650,7 +650,7 @@ static int ICACHE_FLASH_ATTR constfolding (OpCode op, expdesc *e1, expdesc *e2)
} }
static void ICACHE_FLASH_ATTR codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) { static void codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) {
if (constfolding(op, e1, e2)) if (constfolding(op, e1, e2))
return; return;
else { else {
...@@ -670,7 +670,7 @@ static void ICACHE_FLASH_ATTR codearith (FuncState *fs, OpCode op, expdesc *e1, ...@@ -670,7 +670,7 @@ static void ICACHE_FLASH_ATTR codearith (FuncState *fs, OpCode op, expdesc *e1,
} }
static void ICACHE_FLASH_ATTR codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1, static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1,
expdesc *e2) { expdesc *e2) {
int o1 = luaK_exp2RK(fs, e1); int o1 = luaK_exp2RK(fs, e1);
int o2 = luaK_exp2RK(fs, e2); int o2 = luaK_exp2RK(fs, e2);
...@@ -686,7 +686,7 @@ static void ICACHE_FLASH_ATTR codecomp (FuncState *fs, OpCode op, int cond, expd ...@@ -686,7 +686,7 @@ static void ICACHE_FLASH_ATTR codecomp (FuncState *fs, OpCode op, int cond, expd
} }
void ICACHE_FLASH_ATTR luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) { void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
expdesc e2; expdesc e2;
e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0; e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
switch (op) { switch (op) {
...@@ -707,7 +707,7 @@ void ICACHE_FLASH_ATTR luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) { ...@@ -707,7 +707,7 @@ void ICACHE_FLASH_ATTR luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
} }
void ICACHE_FLASH_ATTR luaK_infix (FuncState *fs, BinOpr op, expdesc *v) { void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) {
switch (op) { switch (op) {
case OPR_AND: { case OPR_AND: {
luaK_goiftrue(fs, v); luaK_goiftrue(fs, v);
...@@ -734,7 +734,7 @@ void ICACHE_FLASH_ATTR luaK_infix (FuncState *fs, BinOpr op, expdesc *v) { ...@@ -734,7 +734,7 @@ void ICACHE_FLASH_ATTR luaK_infix (FuncState *fs, BinOpr op, expdesc *v) {
} }
void ICACHE_FLASH_ATTR luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) { void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) {
switch (op) { switch (op) {
case OPR_AND: { case OPR_AND: {
lua_assert(e1->t == NO_JUMP); /* list must be closed */ lua_assert(e1->t == NO_JUMP); /* list must be closed */
...@@ -781,12 +781,12 @@ void ICACHE_FLASH_ATTR luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expde ...@@ -781,12 +781,12 @@ void ICACHE_FLASH_ATTR luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expde
} }
void ICACHE_FLASH_ATTR luaK_fixline (FuncState *fs, int line) { void luaK_fixline (FuncState *fs, int line) {
fs->f->lineinfo[fs->pc - 1] = line; fs->f->lineinfo[fs->pc - 1] = line;
} }
static int ICACHE_FLASH_ATTR luaK_code (FuncState *fs, Instruction i, int line) { static int luaK_code (FuncState *fs, Instruction i, int line) {
Proto *f = fs->f; Proto *f = fs->f;
dischargejpc(fs); /* `pc' will change */ dischargejpc(fs); /* `pc' will change */
/* put new instruction in code array */ /* put new instruction in code array */
...@@ -801,7 +801,7 @@ static int ICACHE_FLASH_ATTR luaK_code (FuncState *fs, Instruction i, int line) ...@@ -801,7 +801,7 @@ static int ICACHE_FLASH_ATTR luaK_code (FuncState *fs, Instruction i, int line)
} }
int ICACHE_FLASH_ATTR luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) { int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) {
lua_assert(getOpMode(o) == iABC); lua_assert(getOpMode(o) == iABC);
lua_assert(getBMode(o) != OpArgN || b == 0); lua_assert(getBMode(o) != OpArgN || b == 0);
lua_assert(getCMode(o) != OpArgN || c == 0); lua_assert(getCMode(o) != OpArgN || c == 0);
...@@ -809,14 +809,14 @@ int ICACHE_FLASH_ATTR luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c ...@@ -809,14 +809,14 @@ int ICACHE_FLASH_ATTR luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c
} }
int ICACHE_FLASH_ATTR luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) { int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) {
lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx); lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx);
lua_assert(getCMode(o) == OpArgN); lua_assert(getCMode(o) == OpArgN);
return luaK_code(fs, CREATE_ABx(o, a, bc), fs->ls->lastline); return luaK_code(fs, CREATE_ABx(o, a, bc), fs->ls->lastline);
} }
void ICACHE_FLASH_ATTR luaK_setlist (FuncState *fs, int base, int nelems, int tostore) { void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) {
int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1; int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1;
int b = (tostore == LUA_MULTRET) ? 0 : tostore; int b = (tostore == LUA_MULTRET) ? 0 : tostore;
lua_assert(tostore != 0); lua_assert(tostore != 0);
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name); static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name);
static int ICACHE_FLASH_ATTR currentpc (lua_State *L, CallInfo *ci) { static int currentpc (lua_State *L, CallInfo *ci) {
if (!isLua(ci)) return -1; /* function is not a Lua function? */ if (!isLua(ci)) return -1; /* function is not a Lua function? */
if (ci == L->ci) if (ci == L->ci)
ci->savedpc = L->savedpc; ci->savedpc = L->savedpc;
...@@ -41,7 +41,7 @@ static int ICACHE_FLASH_ATTR currentpc (lua_State *L, CallInfo *ci) { ...@@ -41,7 +41,7 @@ static int ICACHE_FLASH_ATTR currentpc (lua_State *L, CallInfo *ci) {
} }
static int ICACHE_FLASH_ATTR currentline (lua_State *L, CallInfo *ci) { static int currentline (lua_State *L, CallInfo *ci) {
int pc = currentpc(L, ci); int pc = currentpc(L, ci);
if (pc < 0) if (pc < 0)
return -1; /* only active lua functions have current-line information */ return -1; /* only active lua functions have current-line information */
...@@ -53,7 +53,7 @@ static int ICACHE_FLASH_ATTR currentline (lua_State *L, CallInfo *ci) { ...@@ -53,7 +53,7 @@ static int ICACHE_FLASH_ATTR currentline (lua_State *L, CallInfo *ci) {
/* /*
** this function can be called asynchronous (e.g. during a signal) ** this function can be called asynchronous (e.g. during a signal)
*/ */
LUA_API int ICACHE_FLASH_ATTR lua_sethook (lua_State *L, lua_Hook func, int mask, int count) { LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count) {
if (func == NULL || mask == 0) { /* turn off hooks? */ if (func == NULL || mask == 0) { /* turn off hooks? */
mask = 0; mask = 0;
func = NULL; func = NULL;
...@@ -66,22 +66,22 @@ LUA_API int ICACHE_FLASH_ATTR lua_sethook (lua_State *L, lua_Hook func, int mask ...@@ -66,22 +66,22 @@ LUA_API int ICACHE_FLASH_ATTR lua_sethook (lua_State *L, lua_Hook func, int mask
} }
LUA_API lua_Hook ICACHE_FLASH_ATTR lua_gethook (lua_State *L) { LUA_API lua_Hook lua_gethook (lua_State *L) {
return L->hook; return L->hook;
} }
LUA_API int ICACHE_FLASH_ATTR lua_gethookmask (lua_State *L) { LUA_API int lua_gethookmask (lua_State *L) {
return L->hookmask; return L->hookmask;
} }
LUA_API int ICACHE_FLASH_ATTR lua_gethookcount (lua_State *L) { LUA_API int lua_gethookcount (lua_State *L) {
return L->basehookcount; return L->basehookcount;
} }
LUA_API int ICACHE_FLASH_ATTR lua_getstack (lua_State *L, int level, lua_Debug *ar) { LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) {
int status; int status;
CallInfo *ci; CallInfo *ci;
lua_lock(L); lua_lock(L);
...@@ -104,12 +104,12 @@ LUA_API int ICACHE_FLASH_ATTR lua_getstack (lua_State *L, int level, lua_Debug * ...@@ -104,12 +104,12 @@ LUA_API int ICACHE_FLASH_ATTR lua_getstack (lua_State *L, int level, lua_Debug *
} }
static Proto *ICACHE_FLASH_ATTR getluaproto (CallInfo *ci) { static Proto *getluaproto (CallInfo *ci) {
return (isLua(ci) ? ci_func(ci)->l.p : NULL); return (isLua(ci) ? ci_func(ci)->l.p : NULL);
} }
static const char *ICACHE_FLASH_ATTR findlocal (lua_State *L, CallInfo *ci, int n) { static const char *findlocal (lua_State *L, CallInfo *ci, int n) {
const char *name; const char *name;
Proto *fp = getluaproto(ci); Proto *fp = getluaproto(ci);
if (fp && (name = luaF_getlocalname(fp, n, currentpc(L, ci))) != NULL) if (fp && (name = luaF_getlocalname(fp, n, currentpc(L, ci))) != NULL)
...@@ -124,7 +124,7 @@ static const char *ICACHE_FLASH_ATTR findlocal (lua_State *L, CallInfo *ci, int ...@@ -124,7 +124,7 @@ static const char *ICACHE_FLASH_ATTR findlocal (lua_State *L, CallInfo *ci, int
} }
LUA_API const char *ICACHE_FLASH_ATTR lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) {
CallInfo *ci = L->base_ci + ar->i_ci; CallInfo *ci = L->base_ci + ar->i_ci;
const char *name = findlocal(L, ci, n); const char *name = findlocal(L, ci, n);
lua_lock(L); lua_lock(L);
...@@ -135,7 +135,7 @@ LUA_API const char *ICACHE_FLASH_ATTR lua_getlocal (lua_State *L, const lua_Debu ...@@ -135,7 +135,7 @@ LUA_API const char *ICACHE_FLASH_ATTR lua_getlocal (lua_State *L, const lua_Debu
} }
LUA_API const char *ICACHE_FLASH_ATTR lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) {
CallInfo *ci = L->base_ci + ar->i_ci; CallInfo *ci = L->base_ci + ar->i_ci;
const char *name = findlocal(L, ci, n); const char *name = findlocal(L, ci, n);
lua_lock(L); lua_lock(L);
...@@ -147,7 +147,7 @@ LUA_API const char *ICACHE_FLASH_ATTR lua_setlocal (lua_State *L, const lua_Debu ...@@ -147,7 +147,7 @@ LUA_API const char *ICACHE_FLASH_ATTR lua_setlocal (lua_State *L, const lua_Debu
} }
static void ICACHE_FLASH_ATTR funcinfo (lua_Debug *ar, Closure *cl, void *plight) { static void funcinfo (lua_Debug *ar, Closure *cl, void *plight) {
if (plight || cl->c.isC) { if (plight || cl->c.isC) {
ar->source = "=[C]"; ar->source = "=[C]";
ar->linedefined = -1; ar->linedefined = -1;
...@@ -164,7 +164,7 @@ static void ICACHE_FLASH_ATTR funcinfo (lua_Debug *ar, Closure *cl, void *plight ...@@ -164,7 +164,7 @@ static void ICACHE_FLASH_ATTR funcinfo (lua_Debug *ar, Closure *cl, void *plight
} }
static void ICACHE_FLASH_ATTR info_tailcall (lua_Debug *ar) { static void info_tailcall (lua_Debug *ar) {
ar->name = ar->namewhat = ""; ar->name = ar->namewhat = "";
ar->what = "tail"; ar->what = "tail";
ar->lastlinedefined = ar->linedefined = ar->currentline = -1; ar->lastlinedefined = ar->linedefined = ar->currentline = -1;
...@@ -174,7 +174,7 @@ static void ICACHE_FLASH_ATTR info_tailcall (lua_Debug *ar) { ...@@ -174,7 +174,7 @@ static void ICACHE_FLASH_ATTR info_tailcall (lua_Debug *ar) {
} }
static void ICACHE_FLASH_ATTR collectvalidlines (lua_State *L, Closure *f) { static void collectvalidlines (lua_State *L, Closure *f) {
if (f == NULL || f->c.isC) { if (f == NULL || f->c.isC) {
setnilvalue(L->top); setnilvalue(L->top);
} }
...@@ -190,7 +190,7 @@ static void ICACHE_FLASH_ATTR collectvalidlines (lua_State *L, Closure *f) { ...@@ -190,7 +190,7 @@ static void ICACHE_FLASH_ATTR collectvalidlines (lua_State *L, Closure *f) {
} }
static int ICACHE_FLASH_ATTR auxgetinfo (lua_State *L, const char *what, lua_Debug *ar, static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar,
Closure *f, void *plight, CallInfo *ci) { Closure *f, void *plight, CallInfo *ci) {
int status = 1; int status = 1;
if (plight == NULL && f == NULL) { if (plight == NULL && f == NULL) {
...@@ -229,7 +229,7 @@ static int ICACHE_FLASH_ATTR auxgetinfo (lua_State *L, const char *what, lua_Deb ...@@ -229,7 +229,7 @@ static int ICACHE_FLASH_ATTR auxgetinfo (lua_State *L, const char *what, lua_Deb
} }
LUA_API int ICACHE_FLASH_ATTR lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
int status; int status;
Closure *f = NULL; Closure *f = NULL;
CallInfo *ci = NULL; CallInfo *ci = NULL;
...@@ -284,7 +284,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_getinfo (lua_State *L, const char *what, lua_D ...@@ -284,7 +284,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_getinfo (lua_State *L, const char *what, lua_D
static int ICACHE_FLASH_ATTR precheck (const Proto *pt) { static int precheck (const Proto *pt) {
check(pt->maxstacksize <= MAXSTACK); check(pt->maxstacksize <= MAXSTACK);
check(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize); check(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize);
check(!(pt->is_vararg & VARARG_NEEDSARG) || check(!(pt->is_vararg & VARARG_NEEDSARG) ||
...@@ -298,7 +298,7 @@ static int ICACHE_FLASH_ATTR precheck (const Proto *pt) { ...@@ -298,7 +298,7 @@ static int ICACHE_FLASH_ATTR precheck (const Proto *pt) {
#define checkopenop(pt,pc) luaG_checkopenop((pt)->code[(pc)+1]) #define checkopenop(pt,pc) luaG_checkopenop((pt)->code[(pc)+1])
int ICACHE_FLASH_ATTR luaG_checkopenop (Instruction i) { int luaG_checkopenop (Instruction i) {
switch (GET_OPCODE(i)) { switch (GET_OPCODE(i)) {
case OP_CALL: case OP_CALL:
case OP_TAILCALL: case OP_TAILCALL:
...@@ -312,7 +312,7 @@ int ICACHE_FLASH_ATTR luaG_checkopenop (Instruction i) { ...@@ -312,7 +312,7 @@ int ICACHE_FLASH_ATTR luaG_checkopenop (Instruction i) {
} }
static int ICACHE_FLASH_ATTR checkArgMode (const Proto *pt, int r, enum OpArgMask mode) { static int checkArgMode (const Proto *pt, int r, enum OpArgMask mode) {
switch (mode) { switch (mode) {
case OpArgN: check(r == 0); break; case OpArgN: check(r == 0); break;
case OpArgU: break; case OpArgU: break;
...@@ -325,7 +325,7 @@ static int ICACHE_FLASH_ATTR checkArgMode (const Proto *pt, int r, enum OpArgMas ...@@ -325,7 +325,7 @@ static int ICACHE_FLASH_ATTR checkArgMode (const Proto *pt, int r, enum OpArgMas
} }
static Instruction ICACHE_FLASH_ATTR symbexec (const Proto *pt, int lastpc, int reg) { static Instruction symbexec (const Proto *pt, int lastpc, int reg) {
int pc; int pc;
int last; /* stores position of last instruction that changed `reg' */ int last; /* stores position of last instruction that changed `reg' */
last = pt->sizecode-1; /* points to final return (a `neutral' instruction) */ last = pt->sizecode-1; /* points to final return (a `neutral' instruction) */
...@@ -492,12 +492,12 @@ static Instruction ICACHE_FLASH_ATTR symbexec (const Proto *pt, int lastpc, int ...@@ -492,12 +492,12 @@ static Instruction ICACHE_FLASH_ATTR symbexec (const Proto *pt, int lastpc, int
/* }====================================================== */ /* }====================================================== */
int ICACHE_FLASH_ATTR luaG_checkcode (const Proto *pt) { int luaG_checkcode (const Proto *pt) {
return (symbexec(pt, pt->sizecode, NO_REG) != 0); return (symbexec(pt, pt->sizecode, NO_REG) != 0);
} }
static const char *ICACHE_FLASH_ATTR kname (Proto *p, int c) { static const char *kname (Proto *p, int c) {
if (ISK(c) && ttisstring(&p->k[INDEXK(c)])) if (ISK(c) && ttisstring(&p->k[INDEXK(c)]))
return svalue(&p->k[INDEXK(c)]); return svalue(&p->k[INDEXK(c)]);
else else
...@@ -505,7 +505,7 @@ static const char *ICACHE_FLASH_ATTR kname (Proto *p, int c) { ...@@ -505,7 +505,7 @@ static const char *ICACHE_FLASH_ATTR kname (Proto *p, int c) {
} }
static const char *ICACHE_FLASH_ATTR getobjname (lua_State *L, CallInfo *ci, int stackpos, static const char *getobjname (lua_State *L, CallInfo *ci, int stackpos,
const char **name) { const char **name) {
if (isLua(ci)) { /* a Lua function? */ if (isLua(ci)) { /* a Lua function? */
Proto *p = ci_func(ci)->l.p; Proto *p = ci_func(ci)->l.p;
...@@ -552,7 +552,7 @@ static const char *ICACHE_FLASH_ATTR getobjname (lua_State *L, CallInfo *ci, int ...@@ -552,7 +552,7 @@ static const char *ICACHE_FLASH_ATTR getobjname (lua_State *L, CallInfo *ci, int
} }
static const char *ICACHE_FLASH_ATTR getfuncname (lua_State *L, CallInfo *ci, const char **name) { static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) {
Instruction i; Instruction i;
if ((isLua(ci) && ci->tailcalls > 0) || !isLua(ci - 1)) if ((isLua(ci) && ci->tailcalls > 0) || !isLua(ci - 1))
return NULL; /* calling function is not Lua (or is unknown) */ return NULL; /* calling function is not Lua (or is unknown) */
...@@ -567,7 +567,7 @@ static const char *ICACHE_FLASH_ATTR getfuncname (lua_State *L, CallInfo *ci, co ...@@ -567,7 +567,7 @@ static const char *ICACHE_FLASH_ATTR getfuncname (lua_State *L, CallInfo *ci, co
/* only ANSI way to check whether a pointer points to an array */ /* only ANSI way to check whether a pointer points to an array */
static int ICACHE_FLASH_ATTR isinstack (CallInfo *ci, const TValue *o) { static int isinstack (CallInfo *ci, const TValue *o) {
StkId p; StkId p;
for (p = ci->base; p < ci->top; p++) for (p = ci->base; p < ci->top; p++)
if (o == p) return 1; if (o == p) return 1;
...@@ -575,7 +575,7 @@ static int ICACHE_FLASH_ATTR isinstack (CallInfo *ci, const TValue *o) { ...@@ -575,7 +575,7 @@ static int ICACHE_FLASH_ATTR isinstack (CallInfo *ci, const TValue *o) {
} }
void ICACHE_FLASH_ATTR luaG_typeerror (lua_State *L, const TValue *o, const char *op) { void luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
const char *name = NULL; const char *name = NULL;
const char *t = luaT_typenames[ttype(o)]; const char *t = luaT_typenames[ttype(o)];
const char *kind = (isinstack(L->ci, o)) ? const char *kind = (isinstack(L->ci, o)) ?
...@@ -589,14 +589,14 @@ void ICACHE_FLASH_ATTR luaG_typeerror (lua_State *L, const TValue *o, const char ...@@ -589,14 +589,14 @@ void ICACHE_FLASH_ATTR luaG_typeerror (lua_State *L, const TValue *o, const char
} }
void ICACHE_FLASH_ATTR luaG_concaterror (lua_State *L, StkId p1, StkId p2) { void luaG_concaterror (lua_State *L, StkId p1, StkId p2) {
if (ttisstring(p1) || ttisnumber(p1)) p1 = p2; if (ttisstring(p1) || ttisnumber(p1)) p1 = p2;
lua_assert(!ttisstring(p1) && !ttisnumber(p1)); lua_assert(!ttisstring(p1) && !ttisnumber(p1));
luaG_typeerror(L, p1, "concatenate"); luaG_typeerror(L, p1, "concatenate");
} }
void ICACHE_FLASH_ATTR luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) { void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) {
TValue temp; TValue temp;
if (luaV_tonumber(p1, &temp) == NULL) if (luaV_tonumber(p1, &temp) == NULL)
p2 = p1; /* first operand is wrong */ p2 = p1; /* first operand is wrong */
...@@ -604,7 +604,7 @@ void ICACHE_FLASH_ATTR luaG_aritherror (lua_State *L, const TValue *p1, const TV ...@@ -604,7 +604,7 @@ void ICACHE_FLASH_ATTR luaG_aritherror (lua_State *L, const TValue *p1, const TV
} }
int ICACHE_FLASH_ATTR luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) { int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
const char *t1 = luaT_typenames[ttype(p1)]; const char *t1 = luaT_typenames[ttype(p1)];
const char *t2 = luaT_typenames[ttype(p2)]; const char *t2 = luaT_typenames[ttype(p2)];
if (t1[2] == t2[2]) if (t1[2] == t2[2])
...@@ -615,7 +615,7 @@ int ICACHE_FLASH_ATTR luaG_ordererror (lua_State *L, const TValue *p1, const TVa ...@@ -615,7 +615,7 @@ int ICACHE_FLASH_ATTR luaG_ordererror (lua_State *L, const TValue *p1, const TVa
} }
static void ICACHE_FLASH_ATTR addinfo (lua_State *L, const char *msg) { static void addinfo (lua_State *L, const char *msg) {
CallInfo *ci = L->ci; CallInfo *ci = L->ci;
if (isLua(ci)) { /* is Lua code? */ if (isLua(ci)) { /* is Lua code? */
char buff[LUA_IDSIZE]; /* add file:line information */ char buff[LUA_IDSIZE]; /* add file:line information */
...@@ -626,7 +626,7 @@ static void ICACHE_FLASH_ATTR addinfo (lua_State *L, const char *msg) { ...@@ -626,7 +626,7 @@ static void ICACHE_FLASH_ATTR addinfo (lua_State *L, const char *msg) {
} }
void ICACHE_FLASH_ATTR luaG_errormsg (lua_State *L) { void luaG_errormsg (lua_State *L) {
if (L->errfunc != 0) { /* is there an error handling function? */ if (L->errfunc != 0) { /* is there an error handling function? */
StkId errfunc = restorestack(L, L->errfunc); StkId errfunc = restorestack(L, L->errfunc);
if (!ttisfunction(errfunc) && !ttislightfunction(errfunc)) luaD_throw(L, LUA_ERRERR); if (!ttisfunction(errfunc) && !ttislightfunction(errfunc)) luaD_throw(L, LUA_ERRERR);
...@@ -639,7 +639,7 @@ void ICACHE_FLASH_ATTR luaG_errormsg (lua_State *L) { ...@@ -639,7 +639,7 @@ void ICACHE_FLASH_ATTR luaG_errormsg (lua_State *L) {
} }
void ICACHE_FLASH_ATTR luaG_runerror (lua_State *L, const char *fmt, ...) { void luaG_runerror (lua_State *L, const char *fmt, ...) {
va_list argp; va_list argp;
va_start(argp, fmt); va_start(argp, fmt);
addinfo(L, luaO_pushvfstring(L, fmt, argp)); addinfo(L, luaO_pushvfstring(L, fmt, argp));
......
...@@ -48,7 +48,7 @@ struct lua_longjmp { ...@@ -48,7 +48,7 @@ struct lua_longjmp {
}; };
void ICACHE_FLASH_ATTR luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) { void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) {
switch (errcode) { switch (errcode) {
case LUA_ERRMEM: { case LUA_ERRMEM: {
ptrdiff_t oldtopr = savestack(L, oldtop); ptrdiff_t oldtopr = savestack(L, oldtop);
...@@ -70,7 +70,7 @@ void ICACHE_FLASH_ATTR luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop ...@@ -70,7 +70,7 @@ void ICACHE_FLASH_ATTR luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop
} }
static void ICACHE_FLASH_ATTR restore_stack_limit (lua_State *L) { static void restore_stack_limit (lua_State *L) {
lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1); lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1);
if (L->size_ci > LUAI_MAXCALLS) { /* there was an overflow? */ if (L->size_ci > LUAI_MAXCALLS) { /* there was an overflow? */
int inuse = cast_int(L->ci - L->base_ci); int inuse = cast_int(L->ci - L->base_ci);
...@@ -80,7 +80,7 @@ static void ICACHE_FLASH_ATTR restore_stack_limit (lua_State *L) { ...@@ -80,7 +80,7 @@ static void ICACHE_FLASH_ATTR restore_stack_limit (lua_State *L) {
} }
static void ICACHE_FLASH_ATTR resetstack (lua_State *L, int status) { static void resetstack (lua_State *L, int status) {
L->ci = L->base_ci; L->ci = L->base_ci;
L->base = L->ci->base; L->base = L->ci->base;
luaF_close(L, L->base); /* close eventual pending closures */ luaF_close(L, L->base); /* close eventual pending closures */
...@@ -93,7 +93,7 @@ static void ICACHE_FLASH_ATTR resetstack (lua_State *L, int status) { ...@@ -93,7 +93,7 @@ static void ICACHE_FLASH_ATTR resetstack (lua_State *L, int status) {
} }
void ICACHE_FLASH_ATTR luaD_throw (lua_State *L, int errcode) { void luaD_throw (lua_State *L, int errcode) {
unfixedstack(L); /* make sure the fixedstack & block_gc flags get reset. */ unfixedstack(L); /* make sure the fixedstack & block_gc flags get reset. */
unset_block_gc(L); unset_block_gc(L);
if (L->errorJmp) { if (L->errorJmp) {
...@@ -112,7 +112,7 @@ void ICACHE_FLASH_ATTR luaD_throw (lua_State *L, int errcode) { ...@@ -112,7 +112,7 @@ void ICACHE_FLASH_ATTR luaD_throw (lua_State *L, int errcode) {
} }
int ICACHE_FLASH_ATTR luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) {
struct lua_longjmp lj; struct lua_longjmp lj;
lj.status = 0; lj.status = 0;
lj.previous = L->errorJmp; /* chain new error handler */ lj.previous = L->errorJmp; /* chain new error handler */
...@@ -127,7 +127,7 @@ int ICACHE_FLASH_ATTR luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { ...@@ -127,7 +127,7 @@ int ICACHE_FLASH_ATTR luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) {
/* }====================================================== */ /* }====================================================== */
static void ICACHE_FLASH_ATTR correctstack (lua_State *L, TValue *oldstack) { static void correctstack (lua_State *L, TValue *oldstack) {
CallInfo *ci; CallInfo *ci;
GCObject *up; GCObject *up;
L->top = (L->top - oldstack) + L->stack; L->top = (L->top - oldstack) + L->stack;
...@@ -142,7 +142,7 @@ static void ICACHE_FLASH_ATTR correctstack (lua_State *L, TValue *oldstack) { ...@@ -142,7 +142,7 @@ static void ICACHE_FLASH_ATTR correctstack (lua_State *L, TValue *oldstack) {
} }
void ICACHE_FLASH_ATTR luaD_reallocstack (lua_State *L, int newsize) { void luaD_reallocstack (lua_State *L, int newsize) {
TValue *oldstack = L->stack; TValue *oldstack = L->stack;
int realsize = newsize + 1 + EXTRA_STACK; int realsize = newsize + 1 + EXTRA_STACK;
lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1); lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1);
...@@ -153,7 +153,7 @@ void ICACHE_FLASH_ATTR luaD_reallocstack (lua_State *L, int newsize) { ...@@ -153,7 +153,7 @@ void ICACHE_FLASH_ATTR luaD_reallocstack (lua_State *L, int newsize) {
} }
void ICACHE_FLASH_ATTR luaD_reallocCI (lua_State *L, int newsize) { void luaD_reallocCI (lua_State *L, int newsize) {
CallInfo *oldci = L->base_ci; CallInfo *oldci = L->base_ci;
luaM_reallocvector(L, L->base_ci, L->size_ci, newsize, CallInfo); luaM_reallocvector(L, L->base_ci, L->size_ci, newsize, CallInfo);
L->size_ci = newsize; L->size_ci = newsize;
...@@ -162,7 +162,7 @@ void ICACHE_FLASH_ATTR luaD_reallocCI (lua_State *L, int newsize) { ...@@ -162,7 +162,7 @@ void ICACHE_FLASH_ATTR luaD_reallocCI (lua_State *L, int newsize) {
} }
void ICACHE_FLASH_ATTR luaD_growstack (lua_State *L, int n) { void luaD_growstack (lua_State *L, int n) {
if (n <= L->stacksize) /* double size is enough? */ if (n <= L->stacksize) /* double size is enough? */
luaD_reallocstack(L, 2*L->stacksize); luaD_reallocstack(L, 2*L->stacksize);
else else
...@@ -170,7 +170,7 @@ void ICACHE_FLASH_ATTR luaD_growstack (lua_State *L, int n) { ...@@ -170,7 +170,7 @@ void ICACHE_FLASH_ATTR luaD_growstack (lua_State *L, int n) {
} }
static CallInfo *ICACHE_FLASH_ATTR growCI (lua_State *L) { static CallInfo *growCI (lua_State *L) {
if (L->size_ci > LUAI_MAXCALLS) /* overflow while handling overflow? */ if (L->size_ci > LUAI_MAXCALLS) /* overflow while handling overflow? */
luaD_throw(L, LUA_ERRERR); luaD_throw(L, LUA_ERRERR);
else { else {
...@@ -182,7 +182,7 @@ static CallInfo *ICACHE_FLASH_ATTR growCI (lua_State *L) { ...@@ -182,7 +182,7 @@ static CallInfo *ICACHE_FLASH_ATTR growCI (lua_State *L) {
} }
void ICACHE_FLASH_ATTR luaD_callhook (lua_State *L, int event, int line) { void luaD_callhook (lua_State *L, int event, int line) {
lua_Hook hook = L->hook; lua_Hook hook = L->hook;
if (hook && L->allowhook) { if (hook && L->allowhook) {
ptrdiff_t top = savestack(L, L->top); ptrdiff_t top = savestack(L, L->top);
...@@ -209,7 +209,7 @@ void ICACHE_FLASH_ATTR luaD_callhook (lua_State *L, int event, int line) { ...@@ -209,7 +209,7 @@ void ICACHE_FLASH_ATTR luaD_callhook (lua_State *L, int event, int line) {
} }
static StkId ICACHE_FLASH_ATTR adjust_varargs (lua_State *L, Proto *p, int actual) { static StkId adjust_varargs (lua_State *L, Proto *p, int actual) {
int i; int i;
int nfixargs = p->numparams; int nfixargs = p->numparams;
#if defined(LUA_COMPAT_VARARG) #if defined(LUA_COMPAT_VARARG)
...@@ -253,7 +253,7 @@ static StkId ICACHE_FLASH_ATTR adjust_varargs (lua_State *L, Proto *p, int actua ...@@ -253,7 +253,7 @@ static StkId ICACHE_FLASH_ATTR adjust_varargs (lua_State *L, Proto *p, int actua
} }
static StkId ICACHE_FLASH_ATTR tryfuncTM (lua_State *L, StkId func) { static StkId tryfuncTM (lua_State *L, StkId func) {
const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL); const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL);
StkId p; StkId p;
ptrdiff_t funcr = savestack(L, func); ptrdiff_t funcr = savestack(L, func);
...@@ -274,7 +274,7 @@ static StkId ICACHE_FLASH_ATTR tryfuncTM (lua_State *L, StkId func) { ...@@ -274,7 +274,7 @@ static StkId ICACHE_FLASH_ATTR tryfuncTM (lua_State *L, StkId func) {
(condhardstacktests(luaD_reallocCI(L, L->size_ci)), ++L->ci)) (condhardstacktests(luaD_reallocCI(L, L->size_ci)), ++L->ci))
int ICACHE_FLASH_ATTR luaD_precall (lua_State *L, StkId func, int nresults) { int luaD_precall (lua_State *L, StkId func, int nresults) {
ptrdiff_t funcr; ptrdiff_t funcr;
LClosure *cl = NULL; LClosure *cl = NULL;
if (!ttisfunction(func) && !ttislightfunction(func)) /* `func' is not a function? */ if (!ttisfunction(func) && !ttislightfunction(func)) /* `func' is not a function? */
...@@ -345,7 +345,7 @@ int ICACHE_FLASH_ATTR luaD_precall (lua_State *L, StkId func, int nresults) { ...@@ -345,7 +345,7 @@ int ICACHE_FLASH_ATTR luaD_precall (lua_State *L, StkId func, int nresults) {
} }
static StkId ICACHE_FLASH_ATTR callrethooks (lua_State *L, StkId firstResult) { static StkId callrethooks (lua_State *L, StkId firstResult) {
ptrdiff_t fr = savestack(L, firstResult); /* next call may change stack */ ptrdiff_t fr = savestack(L, firstResult); /* next call may change stack */
luaD_callhook(L, LUA_HOOKRET, -1); luaD_callhook(L, LUA_HOOKRET, -1);
if (f_isLua(L->ci)) { /* Lua function? */ if (f_isLua(L->ci)) { /* Lua function? */
...@@ -356,7 +356,7 @@ static StkId ICACHE_FLASH_ATTR callrethooks (lua_State *L, StkId firstResult) { ...@@ -356,7 +356,7 @@ static StkId ICACHE_FLASH_ATTR callrethooks (lua_State *L, StkId firstResult) {
} }
int ICACHE_FLASH_ATTR luaD_poscall (lua_State *L, StkId firstResult) { int luaD_poscall (lua_State *L, StkId firstResult) {
StkId res; StkId res;
int wanted, i; int wanted, i;
CallInfo *ci; CallInfo *ci;
...@@ -383,7 +383,7 @@ int ICACHE_FLASH_ATTR luaD_poscall (lua_State *L, StkId firstResult) { ...@@ -383,7 +383,7 @@ int ICACHE_FLASH_ATTR luaD_poscall (lua_State *L, StkId firstResult) {
** When returns, all the results are on the stack, starting at the original ** When returns, all the results are on the stack, starting at the original
** function position. ** function position.
*/ */
void ICACHE_FLASH_ATTR luaD_call (lua_State *L, StkId func, int nResults) { void luaD_call (lua_State *L, StkId func, int nResults) {
if (++L->nCcalls >= LUAI_MAXCCALLS) { if (++L->nCcalls >= LUAI_MAXCCALLS) {
if (L->nCcalls == LUAI_MAXCCALLS) if (L->nCcalls == LUAI_MAXCCALLS)
luaG_runerror(L, "C stack overflow"); luaG_runerror(L, "C stack overflow");
...@@ -397,7 +397,7 @@ void ICACHE_FLASH_ATTR luaD_call (lua_State *L, StkId func, int nResults) { ...@@ -397,7 +397,7 @@ void ICACHE_FLASH_ATTR luaD_call (lua_State *L, StkId func, int nResults) {
} }
static void ICACHE_FLASH_ATTR resume (lua_State *L, void *ud) { static void resume (lua_State *L, void *ud) {
StkId firstArg = cast(StkId, ud); StkId firstArg = cast(StkId, ud);
CallInfo *ci = L->ci; CallInfo *ci = L->ci;
if (L->status == 0) { /* start coroutine? */ if (L->status == 0) { /* start coroutine? */
...@@ -422,7 +422,7 @@ static void ICACHE_FLASH_ATTR resume (lua_State *L, void *ud) { ...@@ -422,7 +422,7 @@ static void ICACHE_FLASH_ATTR resume (lua_State *L, void *ud) {
} }
static int ICACHE_FLASH_ATTR resume_error (lua_State *L, const char *msg) { static int resume_error (lua_State *L, const char *msg) {
L->top = L->ci->base; L->top = L->ci->base;
setsvalue2s(L, L->top, luaS_new(L, msg)); setsvalue2s(L, L->top, luaS_new(L, msg));
incr_top(L); incr_top(L);
...@@ -431,7 +431,7 @@ static int ICACHE_FLASH_ATTR resume_error (lua_State *L, const char *msg) { ...@@ -431,7 +431,7 @@ static int ICACHE_FLASH_ATTR resume_error (lua_State *L, const char *msg) {
} }
LUA_API int ICACHE_FLASH_ATTR lua_resume (lua_State *L, int nargs) { LUA_API int lua_resume (lua_State *L, int nargs) {
int status; int status;
lua_lock(L); lua_lock(L);
if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci)) if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci))
...@@ -457,7 +457,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_resume (lua_State *L, int nargs) { ...@@ -457,7 +457,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_resume (lua_State *L, int nargs) {
} }
LUA_API int ICACHE_FLASH_ATTR lua_yield (lua_State *L, int nresults) { LUA_API int lua_yield (lua_State *L, int nresults) {
luai_userstateyield(L, nresults); luai_userstateyield(L, nresults);
lua_lock(L); lua_lock(L);
if (L->nCcalls > L->baseCcalls) if (L->nCcalls > L->baseCcalls)
...@@ -469,7 +469,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_yield (lua_State *L, int nresults) { ...@@ -469,7 +469,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_yield (lua_State *L, int nresults) {
} }
int ICACHE_FLASH_ATTR luaD_pcall (lua_State *L, Pfunc func, void *u, int luaD_pcall (lua_State *L, Pfunc func, void *u,
ptrdiff_t old_top, ptrdiff_t ef) { ptrdiff_t old_top, ptrdiff_t ef) {
int status; int status;
unsigned short oldnCcalls = L->nCcalls; unsigned short oldnCcalls = L->nCcalls;
...@@ -504,7 +504,7 @@ struct SParser { /* data to `f_parser' */ ...@@ -504,7 +504,7 @@ struct SParser { /* data to `f_parser' */
const char *name; const char *name;
}; };
static void ICACHE_FLASH_ATTR f_parser (lua_State *L, void *ud) { static void f_parser (lua_State *L, void *ud) {
int i; int i;
Proto *tf; Proto *tf;
Closure *cl; Closure *cl;
...@@ -524,7 +524,7 @@ static void ICACHE_FLASH_ATTR f_parser (lua_State *L, void *ud) { ...@@ -524,7 +524,7 @@ static void ICACHE_FLASH_ATTR f_parser (lua_State *L, void *ud) {
} }
int ICACHE_FLASH_ATTR luaD_protectedparser (lua_State *L, ZIO *z, const char *name) { int luaD_protectedparser (lua_State *L, ZIO *z, const char *name) {
struct SParser p; struct SParser p;
int status; int status;
p.z = z; p.name = name; p.z = z; p.name = name;
......
...@@ -29,7 +29,7 @@ typedef struct { ...@@ -29,7 +29,7 @@ typedef struct {
#define DumpMem(b,n,size,D) DumpBlock(b,(n)*(size),D) #define DumpMem(b,n,size,D) DumpBlock(b,(n)*(size),D)
#define DumpVar(x,D) DumpMem(&x,1,sizeof(x),D) #define DumpVar(x,D) DumpMem(&x,1,sizeof(x),D)
static void ICACHE_FLASH_ATTR DumpBlock(const void* b, size_t size, DumpState* D) static void DumpBlock(const void* b, size_t size, DumpState* D)
{ {
if (D->status==0) if (D->status==0)
{ {
...@@ -40,19 +40,19 @@ static void ICACHE_FLASH_ATTR DumpBlock(const void* b, size_t size, DumpState* D ...@@ -40,19 +40,19 @@ static void ICACHE_FLASH_ATTR DumpBlock(const void* b, size_t size, DumpState* D
} }
} }
static void ICACHE_FLASH_ATTR DumpChar(int y, DumpState* D) static void DumpChar(int y, DumpState* D)
{ {
char x=(char)y; char x=(char)y;
DumpVar(x,D); DumpVar(x,D);
} }
static void ICACHE_FLASH_ATTR Align4(DumpState *D) static void Align4(DumpState *D)
{ {
while(D->wrote&3) while(D->wrote&3)
DumpChar(0,D); DumpChar(0,D);
} }
static void ICACHE_FLASH_ATTR MaybeByteSwap(char *number, size_t numbersize, DumpState *D) static void MaybeByteSwap(char *number, size_t numbersize, DumpState *D)
{ {
int x=1; int x=1;
int platform_little_endian = *(char*)&x; int platform_little_endian = *(char*)&x;
...@@ -68,7 +68,7 @@ static void ICACHE_FLASH_ATTR MaybeByteSwap(char *number, size_t numbersize, Dum ...@@ -68,7 +68,7 @@ static void ICACHE_FLASH_ATTR MaybeByteSwap(char *number, size_t numbersize, Dum
} }
} }
static void ICACHE_FLASH_ATTR DumpIntWithSize(int x, int sizeof_int, DumpState* D) static void DumpIntWithSize(int x, int sizeof_int, DumpState* D)
{ {
/* dump signed integer */ /* dump signed integer */
switch(sizeof_int) { switch(sizeof_int) {
...@@ -93,12 +93,12 @@ static void ICACHE_FLASH_ATTR DumpIntWithSize(int x, int sizeof_int, DumpState* ...@@ -93,12 +93,12 @@ static void ICACHE_FLASH_ATTR DumpIntWithSize(int x, int sizeof_int, DumpState*
} }
} }
static void ICACHE_FLASH_ATTR DumpInt(int x, DumpState* D) static void DumpInt(int x, DumpState* D)
{ {
DumpIntWithSize(x,D->target.sizeof_int,D); DumpIntWithSize(x,D->target.sizeof_int,D);
} }
static void ICACHE_FLASH_ATTR DumpSize(uint32_t x, DumpState* D) static void DumpSize(uint32_t x, DumpState* D)
{ {
/* dump unsigned integer */ /* dump unsigned integer */
switch(D->target.sizeof_strsize_t) { switch(D->target.sizeof_strsize_t) {
...@@ -123,7 +123,7 @@ static void ICACHE_FLASH_ATTR DumpSize(uint32_t x, DumpState* D) ...@@ -123,7 +123,7 @@ static void ICACHE_FLASH_ATTR DumpSize(uint32_t x, DumpState* D)
} }
} }
static void ICACHE_FLASH_ATTR DumpNumber(lua_Number x, DumpState* D) static void DumpNumber(lua_Number x, DumpState* D)
{ {
#if defined( LUA_NUMBER_INTEGRAL ) && !defined( LUA_CROSS_COMPILER ) #if defined( LUA_NUMBER_INTEGRAL ) && !defined( LUA_CROSS_COMPILER )
DumpIntWithSize(x,D->target.sizeof_lua_Number,D); DumpIntWithSize(x,D->target.sizeof_lua_Number,D);
...@@ -164,7 +164,7 @@ static void ICACHE_FLASH_ATTR DumpNumber(lua_Number x, DumpState* D) ...@@ -164,7 +164,7 @@ static void ICACHE_FLASH_ATTR DumpNumber(lua_Number x, DumpState* D)
#endif // #if defined( LUA_NUMBER_INTEGRAL ) && !defined( LUA_CROSS_COMPILER ) #endif // #if defined( LUA_NUMBER_INTEGRAL ) && !defined( LUA_CROSS_COMPILER )
} }
static void ICACHE_FLASH_ATTR DumpCode(const Proto *f, DumpState* D) static void DumpCode(const Proto *f, DumpState* D)
{ {
DumpInt(f->sizecode,D); DumpInt(f->sizecode,D);
char buf[10]; char buf[10];
...@@ -178,7 +178,7 @@ static void ICACHE_FLASH_ATTR DumpCode(const Proto *f, DumpState* D) ...@@ -178,7 +178,7 @@ static void ICACHE_FLASH_ATTR DumpCode(const Proto *f, DumpState* D)
} }
} }
static void ICACHE_FLASH_ATTR DumpString(const TString* s, DumpState* D) static void DumpString(const TString* s, DumpState* D)
{ {
if (s==NULL || getstr(s)==NULL) if (s==NULL || getstr(s)==NULL)
{ {
...@@ -195,7 +195,7 @@ static void ICACHE_FLASH_ATTR DumpString(const TString* s, DumpState* D) ...@@ -195,7 +195,7 @@ static void ICACHE_FLASH_ATTR DumpString(const TString* s, DumpState* D)
static void DumpFunction(const Proto* f, const TString* p, DumpState* D); static void DumpFunction(const Proto* f, const TString* p, DumpState* D);
static void ICACHE_FLASH_ATTR DumpConstants(const Proto* f, DumpState* D) static void DumpConstants(const Proto* f, DumpState* D)
{ {
int i,n=f->sizek; int i,n=f->sizek;
DumpInt(n,D); DumpInt(n,D);
...@@ -226,7 +226,7 @@ static void ICACHE_FLASH_ATTR DumpConstants(const Proto* f, DumpState* D) ...@@ -226,7 +226,7 @@ static void ICACHE_FLASH_ATTR DumpConstants(const Proto* f, DumpState* D)
for (i=0; i<n; i++) DumpFunction(f->p[i],f->source,D); for (i=0; i<n; i++) DumpFunction(f->p[i],f->source,D);
} }
static void ICACHE_FLASH_ATTR DumpDebug(const Proto* f, DumpState* D) static void DumpDebug(const Proto* f, DumpState* D)
{ {
int i,n; int i,n;
n= (D->strip) ? 0 : f->sizelineinfo; n= (D->strip) ? 0 : f->sizelineinfo;
...@@ -251,7 +251,7 @@ static void ICACHE_FLASH_ATTR DumpDebug(const Proto* f, DumpState* D) ...@@ -251,7 +251,7 @@ static void ICACHE_FLASH_ATTR DumpDebug(const Proto* f, DumpState* D)
for (i=0; i<n; i++) DumpString(f->upvalues[i],D); for (i=0; i<n; i++) DumpString(f->upvalues[i],D);
} }
static void ICACHE_FLASH_ATTR DumpFunction(const Proto* f, const TString* p, DumpState* D) static void DumpFunction(const Proto* f, const TString* p, DumpState* D)
{ {
DumpString((f->source==p || D->strip) ? NULL : f->source,D); DumpString((f->source==p || D->strip) ? NULL : f->source,D);
DumpInt(f->linedefined,D); DumpInt(f->linedefined,D);
...@@ -265,7 +265,7 @@ static void ICACHE_FLASH_ATTR DumpFunction(const Proto* f, const TString* p, Dum ...@@ -265,7 +265,7 @@ static void ICACHE_FLASH_ATTR DumpFunction(const Proto* f, const TString* p, Dum
DumpDebug(f,D); DumpDebug(f,D);
} }
static void ICACHE_FLASH_ATTR DumpHeader(DumpState* D) static void DumpHeader(DumpState* D)
{ {
char buf[LUAC_HEADERSIZE]; char buf[LUAC_HEADERSIZE];
char *h=buf; char *h=buf;
...@@ -288,7 +288,7 @@ static void ICACHE_FLASH_ATTR DumpHeader(DumpState* D) ...@@ -288,7 +288,7 @@ static void ICACHE_FLASH_ATTR DumpHeader(DumpState* D)
/* /*
** dump Lua function as precompiled chunk with specified target ** dump Lua function as precompiled chunk with specified target
*/ */
int ICACHE_FLASH_ATTR luaU_dump_crosscompile (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip, DumpTargetInfo target) int luaU_dump_crosscompile (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip, DumpTargetInfo target)
{ {
DumpState D; DumpState D;
D.L=L; D.L=L;
...@@ -306,7 +306,7 @@ int ICACHE_FLASH_ATTR luaU_dump_crosscompile (lua_State* L, const Proto* f, lua_ ...@@ -306,7 +306,7 @@ int ICACHE_FLASH_ATTR luaU_dump_crosscompile (lua_State* L, const Proto* f, lua_
/* /*
** dump Lua function as precompiled chunk with local machine as target ** dump Lua function as precompiled chunk with local machine as target
*/ */
int ICACHE_FLASH_ATTR luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip) int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip)
{ {
DumpTargetInfo target; DumpTargetInfo target;
int test=1; int test=1;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "lstate.h" #include "lstate.h"
#include "c_types.h" #include "c_types.h"
void ICACHE_FLASH_ATTR legc_set_mode(lua_State *L, int mode, unsigned limit) { void legc_set_mode(lua_State *L, int mode, unsigned limit) {
global_State *g = G(L); global_State *g = G(L);
g->egcmode = mode; g->egcmode = mode;
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
Closure *ICACHE_FLASH_ATTR luaF_newCclosure (lua_State *L, int nelems, Table *e) { Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e) {
Closure *c = cast(Closure *, luaM_malloc(L, sizeCclosure(nelems))); Closure *c = cast(Closure *, luaM_malloc(L, sizeCclosure(nelems)));
luaC_link(L, obj2gco(c), LUA_TFUNCTION); luaC_link(L, obj2gco(c), LUA_TFUNCTION);
c->c.isC = 1; c->c.isC = 1;
...@@ -30,7 +30,7 @@ Closure *ICACHE_FLASH_ATTR luaF_newCclosure (lua_State *L, int nelems, Table *e) ...@@ -30,7 +30,7 @@ Closure *ICACHE_FLASH_ATTR luaF_newCclosure (lua_State *L, int nelems, Table *e)
} }
Closure *ICACHE_FLASH_ATTR luaF_newLclosure (lua_State *L, int nelems, Table *e) { Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e) {
Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems))); Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems)));
luaC_link(L, obj2gco(c), LUA_TFUNCTION); luaC_link(L, obj2gco(c), LUA_TFUNCTION);
c->l.isC = 0; c->l.isC = 0;
...@@ -41,7 +41,7 @@ Closure *ICACHE_FLASH_ATTR luaF_newLclosure (lua_State *L, int nelems, Table *e) ...@@ -41,7 +41,7 @@ Closure *ICACHE_FLASH_ATTR luaF_newLclosure (lua_State *L, int nelems, Table *e)
} }
UpVal *ICACHE_FLASH_ATTR luaF_newupval (lua_State *L) { UpVal *luaF_newupval (lua_State *L) {
UpVal *uv = luaM_new(L, UpVal); UpVal *uv = luaM_new(L, UpVal);
luaC_link(L, obj2gco(uv), LUA_TUPVAL); luaC_link(L, obj2gco(uv), LUA_TUPVAL);
uv->v = &uv->u.value; uv->v = &uv->u.value;
...@@ -50,7 +50,7 @@ UpVal *ICACHE_FLASH_ATTR luaF_newupval (lua_State *L) { ...@@ -50,7 +50,7 @@ UpVal *ICACHE_FLASH_ATTR luaF_newupval (lua_State *L) {
} }
UpVal *ICACHE_FLASH_ATTR luaF_findupval (lua_State *L, StkId level) { UpVal *luaF_findupval (lua_State *L, StkId level) {
global_State *g = G(L); global_State *g = G(L);
GCObject **pp = &L->openupval; GCObject **pp = &L->openupval;
UpVal *p; UpVal *p;
...@@ -79,21 +79,21 @@ UpVal *ICACHE_FLASH_ATTR luaF_findupval (lua_State *L, StkId level) { ...@@ -79,21 +79,21 @@ UpVal *ICACHE_FLASH_ATTR luaF_findupval (lua_State *L, StkId level) {
} }
static void ICACHE_FLASH_ATTR unlinkupval (UpVal *uv) { static void unlinkupval (UpVal *uv) {
lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
uv->u.l.next->u.l.prev = uv->u.l.prev; /* remove from `uvhead' list */ uv->u.l.next->u.l.prev = uv->u.l.prev; /* remove from `uvhead' list */
uv->u.l.prev->u.l.next = uv->u.l.next; uv->u.l.prev->u.l.next = uv->u.l.next;
} }
void ICACHE_FLASH_ATTR luaF_freeupval (lua_State *L, UpVal *uv) { void luaF_freeupval (lua_State *L, UpVal *uv) {
if (uv->v != &uv->u.value) /* is it open? */ if (uv->v != &uv->u.value) /* is it open? */
unlinkupval(uv); /* remove from open list */ unlinkupval(uv); /* remove from open list */
luaM_free(L, uv); /* free upvalue */ luaM_free(L, uv); /* free upvalue */
} }
void ICACHE_FLASH_ATTR luaF_close (lua_State *L, StkId level) { void luaF_close (lua_State *L, StkId level) {
UpVal *uv; UpVal *uv;
global_State *g = G(L); global_State *g = G(L);
while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) { while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) {
...@@ -112,7 +112,7 @@ void ICACHE_FLASH_ATTR luaF_close (lua_State *L, StkId level) { ...@@ -112,7 +112,7 @@ void ICACHE_FLASH_ATTR luaF_close (lua_State *L, StkId level) {
} }
Proto *ICACHE_FLASH_ATTR luaF_newproto (lua_State *L) { Proto *luaF_newproto (lua_State *L) {
Proto *f = luaM_new(L, Proto); Proto *f = luaM_new(L, Proto);
luaC_link(L, obj2gco(f), LUA_TPROTO); luaC_link(L, obj2gco(f), LUA_TPROTO);
f->k = NULL; f->k = NULL;
...@@ -138,7 +138,7 @@ Proto *ICACHE_FLASH_ATTR luaF_newproto (lua_State *L) { ...@@ -138,7 +138,7 @@ Proto *ICACHE_FLASH_ATTR luaF_newproto (lua_State *L) {
} }
void ICACHE_FLASH_ATTR luaF_freeproto (lua_State *L, Proto *f) { void luaF_freeproto (lua_State *L, Proto *f) {
luaM_freearray(L, f->p, f->sizep, Proto *); luaM_freearray(L, f->p, f->sizep, Proto *);
luaM_freearray(L, f->k, f->sizek, TValue); luaM_freearray(L, f->k, f->sizek, TValue);
luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar); luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar);
...@@ -151,7 +151,7 @@ void ICACHE_FLASH_ATTR luaF_freeproto (lua_State *L, Proto *f) { ...@@ -151,7 +151,7 @@ void ICACHE_FLASH_ATTR luaF_freeproto (lua_State *L, Proto *f) {
} }
void ICACHE_FLASH_ATTR luaF_freeclosure (lua_State *L, Closure *c) { void luaF_freeclosure (lua_State *L, Closure *c) {
int size = (c->c.isC) ? sizeCclosure(c->c.nupvalues) : int size = (c->c.isC) ? sizeCclosure(c->c.nupvalues) :
sizeLclosure(c->l.nupvalues); sizeLclosure(c->l.nupvalues);
luaM_freemem(L, c, size); luaM_freemem(L, c, size);
...@@ -162,7 +162,7 @@ void ICACHE_FLASH_ATTR luaF_freeclosure (lua_State *L, Closure *c) { ...@@ -162,7 +162,7 @@ void ICACHE_FLASH_ATTR luaF_freeclosure (lua_State *L, Closure *c) {
** Look for n-th local variable at line `line' in function `func'. ** Look for n-th local variable at line `line' in function `func'.
** Returns NULL if not found. ** Returns NULL if not found.
*/ */
const char *ICACHE_FLASH_ATTR luaF_getlocalname (const Proto *f, int local_number, int pc) { const char *luaF_getlocalname (const Proto *f, int local_number, int pc) {
int i; int i;
for (i = 0; i<f->sizelocvars && f->locvars[i].startpc <= pc; i++) { for (i = 0; i<f->sizelocvars && f->locvars[i].startpc <= pc; i++) {
if (pc < f->locvars[i].endpc) { /* is variable active? */ if (pc < f->locvars[i].endpc) { /* is variable active? */
......
...@@ -59,14 +59,14 @@ ...@@ -59,14 +59,14 @@
#define setthreshold(g) (g->GCthreshold = (g->estimate/100) * g->gcpause) #define setthreshold(g) (g->GCthreshold = (g->estimate/100) * g->gcpause)
static void ICACHE_FLASH_ATTR removeentry (Node *n) { static void removeentry (Node *n) {
lua_assert(ttisnil(gval(n))); lua_assert(ttisnil(gval(n)));
if (iscollectable(gkey(n))) if (iscollectable(gkey(n)))
setttype(gkey(n), LUA_TDEADKEY); /* dead key; remove it */ setttype(gkey(n), LUA_TDEADKEY); /* dead key; remove it */
} }
static void ICACHE_FLASH_ATTR reallymarkobject (global_State *g, GCObject *o) { static void reallymarkobject (global_State *g, GCObject *o) {
lua_assert(iswhite(o) && !isdead(g, o)); lua_assert(iswhite(o) && !isdead(g, o));
white2gray(o); white2gray(o);
switch (o->gch.tt) { switch (o->gch.tt) {
...@@ -112,7 +112,7 @@ static void ICACHE_FLASH_ATTR reallymarkobject (global_State *g, GCObject *o) { ...@@ -112,7 +112,7 @@ static void ICACHE_FLASH_ATTR reallymarkobject (global_State *g, GCObject *o) {
} }
static void ICACHE_FLASH_ATTR marktmu (global_State *g) { static void marktmu (global_State *g) {
GCObject *u = g->tmudata; GCObject *u = g->tmudata;
if (u) { if (u) {
do { do {
...@@ -125,7 +125,7 @@ static void ICACHE_FLASH_ATTR marktmu (global_State *g) { ...@@ -125,7 +125,7 @@ static void ICACHE_FLASH_ATTR marktmu (global_State *g) {
/* move `dead' udata that need finalization to list `tmudata' */ /* move `dead' udata that need finalization to list `tmudata' */
size_t ICACHE_FLASH_ATTR luaC_separateudata (lua_State *L, int all) { size_t luaC_separateudata (lua_State *L, int all) {
global_State *g = G(L); global_State *g = G(L);
size_t deadmem = 0; size_t deadmem = 0;
GCObject **p = &g->mainthread->next; GCObject **p = &g->mainthread->next;
...@@ -155,7 +155,7 @@ size_t ICACHE_FLASH_ATTR luaC_separateudata (lua_State *L, int all) { ...@@ -155,7 +155,7 @@ size_t ICACHE_FLASH_ATTR luaC_separateudata (lua_State *L, int all) {
} }
static int ICACHE_FLASH_ATTR traversetable (global_State *g, Table *h) { static int traversetable (global_State *g, Table *h) {
int i; int i;
int weakkey = 0; int weakkey = 0;
int weakvalue = 0; int weakvalue = 0;
...@@ -200,7 +200,7 @@ static int ICACHE_FLASH_ATTR traversetable (global_State *g, Table *h) { ...@@ -200,7 +200,7 @@ static int ICACHE_FLASH_ATTR traversetable (global_State *g, Table *h) {
** All marks are conditional because a GC may happen while the ** All marks are conditional because a GC may happen while the
** prototype is still being created ** prototype is still being created
*/ */
static void ICACHE_FLASH_ATTR traverseproto (global_State *g, Proto *f) { static void traverseproto (global_State *g, Proto *f) {
int i; int i;
if (f->source) stringmark(f->source); if (f->source) stringmark(f->source);
for (i=0; i<f->sizek; i++) /* mark literals */ for (i=0; i<f->sizek; i++) /* mark literals */
...@@ -221,7 +221,7 @@ static void ICACHE_FLASH_ATTR traverseproto (global_State *g, Proto *f) { ...@@ -221,7 +221,7 @@ static void ICACHE_FLASH_ATTR traverseproto (global_State *g, Proto *f) {
static void ICACHE_FLASH_ATTR traverseclosure (global_State *g, Closure *cl) { static void traverseclosure (global_State *g, Closure *cl) {
markobject(g, cl->c.env); markobject(g, cl->c.env);
if (cl->c.isC) { if (cl->c.isC) {
int i; int i;
...@@ -240,7 +240,7 @@ static void ICACHE_FLASH_ATTR traverseclosure (global_State *g, Closure *cl) { ...@@ -240,7 +240,7 @@ static void ICACHE_FLASH_ATTR traverseclosure (global_State *g, Closure *cl) {
} }
static void ICACHE_FLASH_ATTR checkstacksizes (lua_State *L, StkId max) { static void checkstacksizes (lua_State *L, StkId max) {
int ci_used = cast_int(L->ci - L->base_ci); /* number of `ci' in use */ int ci_used = cast_int(L->ci - L->base_ci); /* number of `ci' in use */
int s_used = cast_int(max - L->stack); /* part of stack in use */ int s_used = cast_int(max - L->stack); /* part of stack in use */
if (L->size_ci > LUAI_MAXCALLS) /* handling overflow? */ if (L->size_ci > LUAI_MAXCALLS) /* handling overflow? */
...@@ -255,7 +255,7 @@ static void ICACHE_FLASH_ATTR checkstacksizes (lua_State *L, StkId max) { ...@@ -255,7 +255,7 @@ static void ICACHE_FLASH_ATTR checkstacksizes (lua_State *L, StkId max) {
} }
static void ICACHE_FLASH_ATTR traversestack (global_State *g, lua_State *l) { static void traversestack (global_State *g, lua_State *l) {
StkId o, lim; StkId o, lim;
CallInfo *ci; CallInfo *ci;
markvalue(g, gt(l)); markvalue(g, gt(l));
...@@ -278,7 +278,7 @@ static void ICACHE_FLASH_ATTR traversestack (global_State *g, lua_State *l) { ...@@ -278,7 +278,7 @@ static void ICACHE_FLASH_ATTR traversestack (global_State *g, lua_State *l) {
** traverse one gray object, turning it to black. ** traverse one gray object, turning it to black.
** Returns `quantity' traversed. ** Returns `quantity' traversed.
*/ */
static l_mem ICACHE_FLASH_ATTR propagatemark (global_State *g) { static l_mem propagatemark (global_State *g) {
GCObject *o = g->gray; GCObject *o = g->gray;
lua_assert(isgray(o)); lua_assert(isgray(o));
gray2black(o); gray2black(o);
...@@ -324,7 +324,7 @@ static l_mem ICACHE_FLASH_ATTR propagatemark (global_State *g) { ...@@ -324,7 +324,7 @@ static l_mem ICACHE_FLASH_ATTR propagatemark (global_State *g) {
} }
static size_t ICACHE_FLASH_ATTR propagateall (global_State *g) { static size_t propagateall (global_State *g) {
size_t m = 0; size_t m = 0;
while (g->gray) m += propagatemark(g); while (g->gray) m += propagatemark(g);
return m; return m;
...@@ -338,7 +338,7 @@ static size_t ICACHE_FLASH_ATTR propagateall (global_State *g) { ...@@ -338,7 +338,7 @@ static size_t ICACHE_FLASH_ATTR propagateall (global_State *g) {
** other objects: if really collected, cannot keep them; for userdata ** other objects: if really collected, cannot keep them; for userdata
** being finalized, keep them in keys, but not in values ** being finalized, keep them in keys, but not in values
*/ */
static int ICACHE_FLASH_ATTR iscleared (const TValue *o, int iskey) { static int iscleared (const TValue *o, int iskey) {
if (!iscollectable(o)) return 0; if (!iscollectable(o)) return 0;
if (ttisstring(o)) { if (ttisstring(o)) {
stringmark(rawtsvalue(o)); /* strings are `values', so are never weak */ stringmark(rawtsvalue(o)); /* strings are `values', so are never weak */
...@@ -352,7 +352,7 @@ static int ICACHE_FLASH_ATTR iscleared (const TValue *o, int iskey) { ...@@ -352,7 +352,7 @@ static int ICACHE_FLASH_ATTR iscleared (const TValue *o, int iskey) {
/* /*
** clear collected entries from weaktables ** clear collected entries from weaktables
*/ */
static void ICACHE_FLASH_ATTR cleartable (GCObject *l) { static void cleartable (GCObject *l) {
while (l) { while (l) {
Table *h = gco2h(l); Table *h = gco2h(l);
int i = h->sizearray; int i = h->sizearray;
...@@ -379,7 +379,7 @@ static void ICACHE_FLASH_ATTR cleartable (GCObject *l) { ...@@ -379,7 +379,7 @@ static void ICACHE_FLASH_ATTR cleartable (GCObject *l) {
} }
static void ICACHE_FLASH_ATTR freeobj (lua_State *L, GCObject *o) { static void freeobj (lua_State *L, GCObject *o) {
switch (o->gch.tt) { switch (o->gch.tt) {
case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break; case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break;
case LUA_TFUNCTION: luaF_freeclosure(L, gco2cl(o)); break; case LUA_TFUNCTION: luaF_freeclosure(L, gco2cl(o)); break;
...@@ -408,7 +408,7 @@ static void ICACHE_FLASH_ATTR freeobj (lua_State *L, GCObject *o) { ...@@ -408,7 +408,7 @@ static void ICACHE_FLASH_ATTR freeobj (lua_State *L, GCObject *o) {
#define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM) #define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM)
static GCObject **ICACHE_FLASH_ATTR sweeplist (lua_State *L, GCObject **p, lu_mem count) { static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) {
GCObject *curr; GCObject *curr;
global_State *g = G(L); global_State *g = G(L);
int deadmask = otherwhite(g); int deadmask = otherwhite(g);
...@@ -430,7 +430,7 @@ static GCObject **ICACHE_FLASH_ATTR sweeplist (lua_State *L, GCObject **p, lu_me ...@@ -430,7 +430,7 @@ static GCObject **ICACHE_FLASH_ATTR sweeplist (lua_State *L, GCObject **p, lu_me
} }
static void ICACHE_FLASH_ATTR checkSizes (lua_State *L) { static void checkSizes (lua_State *L) {
global_State *g = G(L); global_State *g = G(L);
/* check size of string hash */ /* check size of string hash */
if (g->strt.nuse < cast(lu_int32, g->strt.size/4) && if (g->strt.nuse < cast(lu_int32, g->strt.size/4) &&
...@@ -446,7 +446,7 @@ static void ICACHE_FLASH_ATTR checkSizes (lua_State *L) { ...@@ -446,7 +446,7 @@ static void ICACHE_FLASH_ATTR checkSizes (lua_State *L) {
} }
static void ICACHE_FLASH_ATTR GCTM (lua_State *L) { static void GCTM (lua_State *L) {
global_State *g = G(L); global_State *g = G(L);
GCObject *o = g->tmudata->gch.next; /* get first element */ GCObject *o = g->tmudata->gch.next; /* get first element */
Udata *udata = rawgco2u(o); Udata *udata = rawgco2u(o);
...@@ -478,13 +478,13 @@ static void ICACHE_FLASH_ATTR GCTM (lua_State *L) { ...@@ -478,13 +478,13 @@ static void ICACHE_FLASH_ATTR GCTM (lua_State *L) {
/* /*
** Call all GC tag methods ** Call all GC tag methods
*/ */
void ICACHE_FLASH_ATTR luaC_callGCTM (lua_State *L) { void luaC_callGCTM (lua_State *L) {
while (G(L)->tmudata) while (G(L)->tmudata)
GCTM(L); GCTM(L);
} }
void ICACHE_FLASH_ATTR luaC_freeall (lua_State *L) { void luaC_freeall (lua_State *L) {
global_State *g = G(L); global_State *g = G(L);
int i; int i;
g->currentwhite = WHITEBITS | bitmask(SFIXEDBIT); /* mask to collect all elements */ g->currentwhite = WHITEBITS | bitmask(SFIXEDBIT); /* mask to collect all elements */
...@@ -494,7 +494,7 @@ void ICACHE_FLASH_ATTR luaC_freeall (lua_State *L) { ...@@ -494,7 +494,7 @@ void ICACHE_FLASH_ATTR luaC_freeall (lua_State *L) {
} }
static void ICACHE_FLASH_ATTR markmt (global_State *g) { static void markmt (global_State *g) {
int i; int i;
for (i=0; i<NUM_TAGS; i++) for (i=0; i<NUM_TAGS; i++)
if (g->mt[i] && !luaR_isrotable(g->mt[i])) markobject(g, g->mt[i]); if (g->mt[i] && !luaR_isrotable(g->mt[i])) markobject(g, g->mt[i]);
...@@ -502,7 +502,7 @@ static void ICACHE_FLASH_ATTR markmt (global_State *g) { ...@@ -502,7 +502,7 @@ static void ICACHE_FLASH_ATTR markmt (global_State *g) {
/* mark root set */ /* mark root set */
static void ICACHE_FLASH_ATTR markroot (lua_State *L) { static void markroot (lua_State *L) {
global_State *g = G(L); global_State *g = G(L);
g->gray = NULL; g->gray = NULL;
g->grayagain = NULL; g->grayagain = NULL;
...@@ -516,7 +516,7 @@ static void ICACHE_FLASH_ATTR markroot (lua_State *L) { ...@@ -516,7 +516,7 @@ static void ICACHE_FLASH_ATTR markroot (lua_State *L) {
} }
static void ICACHE_FLASH_ATTR remarkupvals (global_State *g) { static void remarkupvals (global_State *g) {
UpVal *uv; UpVal *uv;
for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) { for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) {
lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
...@@ -526,7 +526,7 @@ static void ICACHE_FLASH_ATTR remarkupvals (global_State *g) { ...@@ -526,7 +526,7 @@ static void ICACHE_FLASH_ATTR remarkupvals (global_State *g) {
} }
static void ICACHE_FLASH_ATTR atomic (lua_State *L) { static void atomic (lua_State *L) {
global_State *g = G(L); global_State *g = G(L);
size_t udsize; /* total size of userdata to be finalized */ size_t udsize; /* total size of userdata to be finalized */
/* remark occasional upvalues of (maybe) dead threads */ /* remark occasional upvalues of (maybe) dead threads */
...@@ -556,7 +556,7 @@ static void ICACHE_FLASH_ATTR atomic (lua_State *L) { ...@@ -556,7 +556,7 @@ static void ICACHE_FLASH_ATTR atomic (lua_State *L) {
g->estimate = g->totalbytes - udsize; /* first estimate */ g->estimate = g->totalbytes - udsize; /* first estimate */
} }
static void ICACHE_FLASH_ATTR sweepstrstep (global_State *g, lua_State *L) { static void sweepstrstep (global_State *g, lua_State *L) {
lu_mem old = g->totalbytes; lu_mem old = g->totalbytes;
sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]); sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]);
if (g->sweepstrgc >= g->strt.size) /* nothing more to sweep? */ if (g->sweepstrgc >= g->strt.size) /* nothing more to sweep? */
...@@ -566,7 +566,7 @@ static void ICACHE_FLASH_ATTR sweepstrstep (global_State *g, lua_State *L) { ...@@ -566,7 +566,7 @@ static void ICACHE_FLASH_ATTR sweepstrstep (global_State *g, lua_State *L) {
} }
static l_mem ICACHE_FLASH_ATTR singlestep (lua_State *L) { static l_mem singlestep (lua_State *L) {
global_State *g = G(L); global_State *g = G(L);
/*lua_checkmemory(L);*/ /*lua_checkmemory(L);*/
switch (g->gcstate) { switch (g->gcstate) {
...@@ -615,7 +615,7 @@ static l_mem ICACHE_FLASH_ATTR singlestep (lua_State *L) { ...@@ -615,7 +615,7 @@ static l_mem ICACHE_FLASH_ATTR singlestep (lua_State *L) {
} }
void ICACHE_FLASH_ATTR luaC_step (lua_State *L) { void luaC_step (lua_State *L) {
global_State *g = G(L); global_State *g = G(L);
if(is_block_gc(L)) return; if(is_block_gc(L)) return;
set_block_gc(L); set_block_gc(L);
...@@ -645,7 +645,7 @@ void ICACHE_FLASH_ATTR luaC_step (lua_State *L) { ...@@ -645,7 +645,7 @@ void ICACHE_FLASH_ATTR luaC_step (lua_State *L) {
unset_block_gc(L); unset_block_gc(L);
} }
int ICACHE_FLASH_ATTR luaC_sweepstrgc (lua_State *L) { int luaC_sweepstrgc (lua_State *L) {
global_State *g = G(L); global_State *g = G(L);
if (g->gcstate == GCSsweepstring) { if (g->gcstate == GCSsweepstring) {
sweepstrstep(g, L); sweepstrstep(g, L);
...@@ -654,7 +654,7 @@ int ICACHE_FLASH_ATTR luaC_sweepstrgc (lua_State *L) { ...@@ -654,7 +654,7 @@ int ICACHE_FLASH_ATTR luaC_sweepstrgc (lua_State *L) {
return 0; return 0;
} }
void ICACHE_FLASH_ATTR luaC_fullgc (lua_State *L) { void luaC_fullgc (lua_State *L) {
global_State *g = G(L); global_State *g = G(L);
if(is_block_gc(L)) return; if(is_block_gc(L)) return;
set_block_gc(L); set_block_gc(L);
...@@ -683,7 +683,7 @@ void ICACHE_FLASH_ATTR luaC_fullgc (lua_State *L) { ...@@ -683,7 +683,7 @@ void ICACHE_FLASH_ATTR luaC_fullgc (lua_State *L) {
} }
void ICACHE_FLASH_ATTR luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) { void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) {
global_State *g = G(L); global_State *g = G(L);
lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o)); lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o));
lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause); lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause);
...@@ -696,7 +696,7 @@ void ICACHE_FLASH_ATTR luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) { ...@@ -696,7 +696,7 @@ void ICACHE_FLASH_ATTR luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) {
} }
void ICACHE_FLASH_ATTR luaC_barrierback (lua_State *L, Table *t) { void luaC_barrierback (lua_State *L, Table *t) {
global_State *g = G(L); global_State *g = G(L);
GCObject *o = obj2gco(t); GCObject *o = obj2gco(t);
lua_assert(isblack(o) && !isdead(g, o)); lua_assert(isblack(o) && !isdead(g, o));
...@@ -707,7 +707,7 @@ void ICACHE_FLASH_ATTR luaC_barrierback (lua_State *L, Table *t) { ...@@ -707,7 +707,7 @@ void ICACHE_FLASH_ATTR luaC_barrierback (lua_State *L, Table *t) {
} }
void ICACHE_FLASH_ATTR luaC_marknew (lua_State *L, GCObject *o) { void luaC_marknew (lua_State *L, GCObject *o) {
global_State *g = G(L); global_State *g = G(L);
o->gch.marked = luaC_white(g); o->gch.marked = luaC_white(g);
if (g->gcstate == GCSpropagate) if (g->gcstate == GCSpropagate)
...@@ -715,7 +715,7 @@ void ICACHE_FLASH_ATTR luaC_marknew (lua_State *L, GCObject *o) { ...@@ -715,7 +715,7 @@ void ICACHE_FLASH_ATTR luaC_marknew (lua_State *L, GCObject *o) {
} }
void ICACHE_FLASH_ATTR luaC_link (lua_State *L, GCObject *o, lu_byte tt) { void luaC_link (lua_State *L, GCObject *o, lu_byte tt) {
global_State *g = G(L); global_State *g = G(L);
o->gch.next = g->rootgc; o->gch.next = g->rootgc;
g->rootgc = o; g->rootgc = o;
...@@ -724,7 +724,7 @@ void ICACHE_FLASH_ATTR luaC_link (lua_State *L, GCObject *o, lu_byte tt) { ...@@ -724,7 +724,7 @@ void ICACHE_FLASH_ATTR luaC_link (lua_State *L, GCObject *o, lu_byte tt) {
} }
void ICACHE_FLASH_ATTR luaC_linkupval (lua_State *L, UpVal *uv) { void luaC_linkupval (lua_State *L, UpVal *uv) {
global_State *g = G(L); global_State *g = G(L);
GCObject *o = obj2gco(uv); GCObject *o = obj2gco(uv);
o->gch.next = g->rootgc; /* link upvalue into `rootgc' list */ o->gch.next = g->rootgc; /* link upvalue into `rootgc' list */
......
...@@ -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);
......
...@@ -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) */
......
...@@ -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);
} }
......
...@@ -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
......
...@@ -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);
......
...@@ -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
......
...@@ -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 */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment