Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
c04f2578
Commit
c04f2578
authored
Jan 05, 2015
by
HuangRui
Browse files
Updated SDK to v0.9.5 and optimized memory.
parent
0420b6d7
Changes
78
Expand all
Show whitespace changes
Inline
Side-by-side
app/Makefile
View file @
c04f2578
...
...
@@ -41,7 +41,38 @@ endif # } PDIR
APPDIR
=
.
LDDIR
=
../ld
CCFLAGS
+=
-Os
ifeq
($(OS),Windows_NT)
# WIN32
# We are under windows. Assume using xcc.
CCFLAGS
+=
-Os
--rename-section
.text
=
.irom0.text
--rename-section
.literal
=
.irom0.literal
ifeq
($(PROCESSOR_ARCHITECTURE),AMD64)
# ->AMD64
endif
ifeq
($(PROCESSOR_ARCHITECTURE),x86)
# ->IA32
endif
else
# We are under other system, may be Linux. Assume using gcc.
# Can we use -fdata-sections?
CCFLAGS
+=
-Os
-ffunction-sections
-fno-jump-tables
UNAME_S
:=
$(
shell
uname
-s
)
ifeq
($(UNAME_S),Linux)
# LINUX
endif
ifeq
($(UNAME_S),Darwin)
# OSX
endif
UNAME_P
:=
$(
shell
uname
-p
)
ifeq
($(UNAME_P),x86_64)
# ->AMD64
endif
ifneq
($(filter %86,$(UNAME_P)),)
# ->IA32
endif
ifneq
($(filter arm%,$(UNAME_P)),)
# ->ARM
endif
endif
TARGET_LDFLAGS
=
\
-nostdlib
\
...
...
@@ -49,6 +80,7 @@ TARGET_LDFLAGS = \
--longcalls
\
--text-section-literals
ifeq
($(FLAVOR),debug)
TARGET_LDFLAGS
+=
-g
-O2
endif
...
...
app/driver/onewire.c
View file @
c04f2578
...
...
@@ -72,7 +72,7 @@ static uint8_t LastFamilyDiscrepancy[NUM_OW];
static
uint8_t
LastDeviceFlag
[
NUM_OW
];
#endif
void
ICACHE_FLASH_ATTR
onewire_init
(
uint8_t
pin
)
void
onewire_init
(
uint8_t
pin
)
{
// pinMode(pin, INPUT);
platform_gpio_mode
(
pin
,
PLATFORM_GPIO_INPUT
,
PLATFORM_GPIO_PULLUP
);
...
...
@@ -88,7 +88,7 @@ void ICACHE_FLASH_ATTR onewire_init(uint8_t pin)
//
// Returns 1 if a device asserted a presence pulse, 0 otherwise.
//
uint8_t
ICACHE_FLASH_ATTR
onewire_reset
(
uint8_t
pin
)
uint8_t
onewire_reset
(
uint8_t
pin
)
{
uint8_t
r
;
uint8_t
retries
=
125
;
...
...
@@ -120,7 +120,7 @@ uint8_t ICACHE_FLASH_ATTR onewire_reset(uint8_t pin)
// Write a bit. Port and bit is used to cut lookup time and provide
// more certain timing.
//
static
void
ICACHE_FLASH_ATTR
onewire_write_bit
(
uint8_t
pin
,
uint8_t
v
)
static
void
onewire_write_bit
(
uint8_t
pin
,
uint8_t
v
)
{
if
(
v
&
1
)
{
noInterrupts
();
...
...
@@ -145,7 +145,7 @@ static void ICACHE_FLASH_ATTR onewire_write_bit(uint8_t pin, uint8_t v)
// Read a bit. Port and bit is used to cut lookup time and provide
// more certain timing.
//
static
uint8_t
ICACHE_FLASH_ATTR
onewire_read_bit
(
uint8_t
pin
)
static
uint8_t
onewire_read_bit
(
uint8_t
pin
)
{
uint8_t
r
;
...
...
@@ -168,7 +168,7 @@ static uint8_t ICACHE_FLASH_ATTR onewire_read_bit(uint8_t pin)
// go tri-state at the end of the write to avoid heating in a short or
// other mishap.
//
void
ICACHE_FLASH_ATTR
onewire_write
(
uint8_t
pin
,
uint8_t
v
,
uint8_t
power
/* = 0 */
)
{
void
onewire_write
(
uint8_t
pin
,
uint8_t
v
,
uint8_t
power
/* = 0 */
)
{
uint8_t
bitMask
;
for
(
bitMask
=
0x01
;
bitMask
;
bitMask
<<=
1
)
{
...
...
@@ -182,7 +182,7 @@ void ICACHE_FLASH_ATTR onewire_write(uint8_t pin, uint8_t v, uint8_t power /* =
}
}
void
ICACHE_FLASH_ATTR
onewire_write_bytes
(
uint8_t
pin
,
const
uint8_t
*
buf
,
uint16_t
count
,
bool
power
/* = 0 */
)
{
void
onewire_write_bytes
(
uint8_t
pin
,
const
uint8_t
*
buf
,
uint16_t
count
,
bool
power
/* = 0 */
)
{
uint16_t
i
;
for
(
i
=
0
;
i
<
count
;
i
++
)
onewire_write
(
pin
,
buf
[
i
],
0
);
...
...
@@ -197,7 +197,7 @@ void ICACHE_FLASH_ATTR onewire_write_bytes(uint8_t pin, const uint8_t *buf, uint
//
// Read a byte
//
uint8_t
ICACHE_FLASH_ATTR
onewire_read
(
uint8_t
pin
)
{
uint8_t
onewire_read
(
uint8_t
pin
)
{
uint8_t
bitMask
;
uint8_t
r
=
0
;
...
...
@@ -207,7 +207,7 @@ uint8_t ICACHE_FLASH_ATTR onewire_read(uint8_t pin) {
return
r
;
}
void
ICACHE_FLASH_ATTR
onewire_read_bytes
(
uint8_t
pin
,
uint8_t
*
buf
,
uint16_t
count
)
{
void
onewire_read_bytes
(
uint8_t
pin
,
uint8_t
*
buf
,
uint16_t
count
)
{
uint16_t
i
;
for
(
i
=
0
;
i
<
count
;
i
++
)
buf
[
i
]
=
onewire_read
(
pin
);
...
...
@@ -216,7 +216,7 @@ void ICACHE_FLASH_ATTR onewire_read_bytes(uint8_t pin, uint8_t *buf, uint16_t co
//
// Do a ROM select
//
void
ICACHE_FLASH_ATTR
onewire_select
(
uint8_t
pin
,
const
uint8_t
rom
[
8
])
void
onewire_select
(
uint8_t
pin
,
const
uint8_t
rom
[
8
])
{
uint8_t
i
;
...
...
@@ -228,12 +228,12 @@ void ICACHE_FLASH_ATTR onewire_select(uint8_t pin, const uint8_t rom[8])
//
// Do a ROM skip
//
void
ICACHE_FLASH_ATTR
onewire_skip
(
uint8_t
pin
)
void
onewire_skip
(
uint8_t
pin
)
{
onewire_write
(
pin
,
0xCC
,
0
);
// Skip ROM
}
void
ICACHE_FLASH_ATTR
onewire_depower
(
uint8_t
pin
)
void
onewire_depower
(
uint8_t
pin
)
{
noInterrupts
();
DIRECT_MODE_INPUT
(
pin
);
...
...
@@ -246,7 +246,7 @@ void ICACHE_FLASH_ATTR onewire_depower(uint8_t pin)
// You need to use this function to start a search again from the beginning.
// You do not need to do it for the first search, though you could.
//
void
ICACHE_FLASH_ATTR
onewire_reset_search
(
uint8_t
pin
)
void
onewire_reset_search
(
uint8_t
pin
)
{
// reset the search state
LastDiscrepancy
[
pin
]
=
0
;
...
...
@@ -262,7 +262,7 @@ void ICACHE_FLASH_ATTR onewire_reset_search(uint8_t pin)
// Setup the search to find the device type 'family_code' on the next call
// to search(*newAddr) if it is present.
//
void
ICACHE_FLASH_ATTR
onewire_target_search
(
uint8_t
pin
,
uint8_t
family_code
)
void
onewire_target_search
(
uint8_t
pin
,
uint8_t
family_code
)
{
// set the search state to find SearchFamily type devices
ROM_NO
[
pin
][
0
]
=
family_code
;
...
...
@@ -290,7 +290,7 @@ void ICACHE_FLASH_ATTR onewire_target_search(uint8_t pin, uint8_t family_code)
// Return TRUE : device found, ROM number in ROM_NO buffer
// FALSE : device not found, end of search
//
uint8_t
ICACHE_FLASH_ATTR
onewire_search
(
uint8_t
pin
,
uint8_t
*
newAddr
)
uint8_t
onewire_search
(
uint8_t
pin
,
uint8_t
*
newAddr
)
{
uint8_t
id_bit_number
;
uint8_t
last_zero
,
rom_byte_number
,
search_result
;
...
...
@@ -449,7 +449,7 @@ static const uint8_t dscrc_table[] = {
// compared to all those delayMicrosecond() calls. But I got
// confused, so I use this table from the examples.)
//
uint8_t
ICACHE_FLASH_ATTR
onewire_crc8
(
const
uint8_t
*
addr
,
uint8_t
len
)
uint8_t
onewire_crc8
(
const
uint8_t
*
addr
,
uint8_t
len
)
{
uint8_t
crc
=
0
;
...
...
@@ -463,7 +463,7 @@ uint8_t ICACHE_FLASH_ATTR onewire_crc8(const uint8_t *addr, uint8_t len)
// Compute a Dallas Semiconductor 8 bit CRC directly.
// this is much slower, but much smaller, than the lookup table.
//
uint8_t
ICACHE_FLASH_ATTR
onewire_crc8
(
const
uint8_t
*
addr
,
uint8_t
len
)
uint8_t
onewire_crc8
(
const
uint8_t
*
addr
,
uint8_t
len
)
{
uint8_t
crc
=
0
;
...
...
@@ -501,7 +501,7 @@ uint8_t ICACHE_FLASH_ATTR onewire_crc8(const uint8_t *addr, uint8_t len)
// *not* at a 16-bit integer.
// @param crc - The crc starting value (optional)
// @return True, iff the CRC matches.
bool
ICACHE_FLASH_ATTR
onewire_check_crc16
(
const
uint8_t
*
input
,
uint16_t
len
,
const
uint8_t
*
inverted_crc
,
uint16_t
crc
)
bool
onewire_check_crc16
(
const
uint8_t
*
input
,
uint16_t
len
,
const
uint8_t
*
inverted_crc
,
uint16_t
crc
)
{
crc
=
~
onewire_crc16
(
input
,
len
,
crc
);
return
(
crc
&
0xFF
)
==
inverted_crc
[
0
]
&&
(
crc
>>
8
)
==
inverted_crc
[
1
];
...
...
@@ -519,7 +519,7 @@ bool ICACHE_FLASH_ATTR onewire_check_crc16(const uint8_t* input, uint16_t len, c
// @param len - How many bytes to use.
// @param crc - The crc starting value (optional)
// @return The CRC16, as defined by Dallas Semiconductor.
uint16_t
ICACHE_FLASH_ATTR
onewire_crc16
(
const
uint8_t
*
input
,
uint16_t
len
,
uint16_t
crc
)
uint16_t
onewire_crc16
(
const
uint8_t
*
input
,
uint16_t
len
,
uint16_t
crc
)
{
static
const
uint8_t
oddparity
[
16
]
=
{
0
,
1
,
1
,
0
,
1
,
0
,
0
,
1
,
1
,
0
,
0
,
1
,
0
,
1
,
1
,
0
};
...
...
app/driver/pwm.c
View file @
c04f2578
...
...
@@ -305,7 +305,7 @@ pwm_get_freq(uint8 channel)
* Parameters : NONE
* Returns : NONE
*******************************************************************************/
LOCAL
void
LOCAL
void
ICACHE_RAM_ATTR
pwm_tim1_intr_handler
(
void
)
{
uint8
local_toggle
=
pwm_toggle
;
// pwm_toggle may change outside
...
...
app/driver/readline.c
View file @
c04f2578
...
...
@@ -11,7 +11,7 @@ extern UartDevice UartDev;
#define uart_putc uart0_putc
bool
ICACHE_FLASH_ATTR
uart_getc
(
char
*
c
){
bool
uart_getc
(
char
*
c
){
RcvMsgBuff
*
pRxBuff
=
&
(
UartDev
.
rcv_buff
);
if
(
pRxBuff
->
pWritePos
==
pRxBuff
->
pReadPos
){
// empty
return
false
;
...
...
@@ -30,7 +30,7 @@ bool ICACHE_FLASH_ATTR uart_getc(char *c){
}
#if 0
int
ICACHE_FLASH_ATTR
readline4lua(const char *prompt, char *buffer, int length){
int readline4lua(const char *prompt, char *buffer, int length){
char ch;
int line_position;
...
...
app/driver/uart.c
View file @
c04f2578
...
...
@@ -20,7 +20,8 @@
// UartDev is defined and initialized in rom code.
extern
UartDevice
UartDev
;
LOCAL
void
uart0_rx_intr_handler
(
void
*
para
);
LOCAL
void
ICACHE_RAM_ATTR
uart0_rx_intr_handler
(
void
*
para
);
/******************************************************************************
* FunctionName : uart_config
...
...
app/include/user_config.h
View file @
c04f2578
...
...
@@ -3,11 +3,11 @@
#define NODE_VERSION_MAJOR 0U
#define NODE_VERSION_MINOR 9U
#define NODE_VERSION_REVISION
4
U
#define NODE_VERSION_REVISION
5
U
#define NODE_VERSION_INTERNAL 0U
#define NODE_VERSION "NodeMcu 0.9.
4
"
#define BUILD_DATE "build 2015010
1
"
#define NODE_VERSION "NodeMcu 0.9.
5
"
#define BUILD_DATE "build 2015010
5
"
// #define FLASH_512K
// #define FLASH_1M
...
...
@@ -35,8 +35,9 @@
#define NODE_ERR
#endif
/* NODE_ERROR */
#define NODE_STORE_TYPEDEF_ATTR __attribute__((aligned(4),packed))
#define NODE_STORE_ATTR __attribute__((aligned(4)))
#define ICACHE_STORE_TYPEDEF_ATTR __attribute__((aligned(4),packed))
#define ICACHE_STORE_ATTR __attribute__((aligned(4)))
#define ICACHE_RAM_ATTR __attribute__((section(".iram0.text")))
#define CLIENT_SSL_ENABLE
#define GPIO_INTERRUPT_ENABLE
...
...
app/libc/c_ctype.c
View file @
c04f2578
#include "c_ctype.h"
#include "c_types.h"
// int
ICACHE_FLASH_ATTR
isalnum(int c){}
// int
ICACHE_FLASH_ATTR
isalpha(int c){}
// int
ICACHE_FLASH_ATTR
iscntrl(int c){}
// int
ICACHE_FLASH_ATTR
isdigit(int c){}
// // int
ICACHE_FLASH_ATTR
isgraph(int c){}
// int
ICACHE_FLASH_ATTR
islower(int c){}
// int
ICACHE_FLASH_ATTR
isprint(int c){}
// int
ICACHE_FLASH_ATTR
ispunct(int c){}
// int
ICACHE_FLASH_ATTR
isspace(int c){}
// int
ICACHE_FLASH_ATTR
isupper(int c){}
// int
ICACHE_FLASH_ATTR
isxdigit(int c){}
// int
ICACHE_FLASH_ATTR
tolower(int c){}
// int
ICACHE_FLASH_ATTR
toupper(int c){}
// int isalnum(int c){}
// int isalpha(int c){}
// int iscntrl(int c){}
// int isdigit(int c){}
// // int isgraph(int c){}
// int islower(int c){}
// int isprint(int c){}
// int ispunct(int c){}
// int isspace(int c){}
// int isupper(int c){}
// int isxdigit(int c){}
// int tolower(int c){}
// int toupper(int c){}
app/libc/c_math.c
View file @
c04f2578
...
...
@@ -3,34 +3,34 @@
#if 0
#ifndef __math_68881
double
ICACHE_FLASH_ATTR
atan(double x){
double atan(double x){
return x;
}
double
ICACHE_FLASH_ATTR
cos(double x){
double cos(double x){
return x;
}
double
ICACHE_FLASH_ATTR
sin(double x){
double sin(double x){
return x;
}
double
ICACHE_FLASH_ATTR
tan(double x){
double tan(double x){
return x;
}
double
ICACHE_FLASH_ATTR
tanh(double x){
double tanh(double x){
return x;
}
double
ICACHE_FLASH_ATTR
frexp(double x, int *y){
double frexp(double x, int *y){
return x;
}
double
ICACHE_FLASH_ATTR
modf(double x, double *y){
double modf(double x, double *y){
return x;
}
double
ICACHE_FLASH_ATTR
ceil(double x){
double ceil(double x){
return x;
}
double
ICACHE_FLASH_ATTR
fabs(double x){
double fabs(double x){
return x;
}
double
ICACHE_FLASH_ATTR
floor(double x){
double floor(double x){
return x;
}
#endif /* ! defined (__math_68881) */
...
...
@@ -39,40 +39,40 @@ double ICACHE_FLASH_ATTR floor(double x){
#ifndef _REENT_ONLY
#ifndef __math_68881
double
ICACHE_FLASH_ATTR
acos(double x){
double acos(double x){
return x;
}
double
ICACHE_FLASH_ATTR
asin(double x){
double asin(double x){
return x;
}
double
ICACHE_FLASH_ATTR
atan2(double x, double y){
double atan2(double x, double y){
return x;
}
double
ICACHE_FLASH_ATTR
cosh(double x){
double cosh(double x){
return x;
}
double
ICACHE_FLASH_ATTR
sinh(double x){
double sinh(double x){
return x;
}
double
ICACHE_FLASH_ATTR
exp(double x){
double exp(double x){
return x;
}
double
ICACHE_FLASH_ATTR
ldexp(double x, int y){
double ldexp(double x, int y){
return x;
}
double
ICACHE_FLASH_ATTR
log(double x){
double log(double x){
return x;
}
double
ICACHE_FLASH_ATTR
log10(double x){
double log10(double x){
return x;
}
double
ICACHE_FLASH_ATTR
pow(double x, double y){
double pow(double x, double y){
return x;
}
double
ICACHE_FLASH_ATTR
sqrt(double x){
double sqrt(double x){
return x;
}
double
ICACHE_FLASH_ATTR
fmod(double x, double y){
double fmod(double x, double y){
return x;
}
#endif /* ! defined (__math_68881) */
...
...
app/libc/c_stdlib.c
View file @
c04f2578
...
...
@@ -7,12 +7,12 @@
// const char *lua_init_value = "print(\"Hello world\")";
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;
// }
// 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
){
return
lua_init_value
;
}
...
...
@@ -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
void
*
ICACHE_FLASH_ATTR
c_malloc
(
size_t
__size
){
void
*
c_malloc
(
size_t
__size
){
if
(
__size
>
system_get_free_heap_size
()){
NODE_ERR
(
"malloc: not enough memory
\n
"
);
return
NULL
;
...
...
@@ -28,7 +28,7 @@ void *ICACHE_FLASH_ATTR c_malloc(size_t __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
()){
NODE_ERR
(
"zalloc: not enough memory
\n
"
);
return
NULL
;
...
...
@@ -36,25 +36,25 @@ void *ICACHE_FLASH_ATTR c_zalloc(size_t __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());
os_free
(
p
);
// 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){
// }
app/lua/compiler.h
View file @
c04f2578
...
...
@@ -22,15 +22,15 @@ extern char Image$$ER_IROM1$$Limit;
//#warning "Please check linker script to ensure rodata is between _stext and _etext."
/* symbols defined in linker script */
extern
char
_rodata_start
;
extern
char
_rodata_end
;
//
extern char _irom0_text_start;
//
extern char _irom0_text_end;
//
extern char _rodata_start;
//
extern char _rodata_end;
extern
char
_irom0_text_start
;
extern
char
_irom0_text_end
;
// modify linker script to ensure rodata and rodata1 is between _rodata_start and _rodata_end.
#define RODATA_START_ADDRESS (&_rodata_start)
#define RODATA_END_ADDRESS (&_rodata_end)
//
#define RODATA_START_ADDRESS (&_irom0_text_start)
//
#define RODATA_END_ADDRESS (&_irom0_text_end)
//
#define RODATA_START_ADDRESS (&_rodata_start)
//
#define RODATA_END_ADDRESS (&_rodata_end)
#define RODATA_START_ADDRESS (&_irom0_text_start)
#define RODATA_END_ADDRESS (&_irom0_text_end)
#else // other compilers
...
...
app/lua/lapi.c
View file @
c04f2578
This diff is collapsed.
Click to expand it.
app/lua/lauxlib.c
View file @
c04f2578
...
...
@@ -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
;
if
(
!
lua_getstack
(
L
,
0
,
&
ar
))
/* no stack frame? */
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
}
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"
,
tname
,
luaL_typename
(
L
,
narg
));
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
));
}
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
;
if
(
lua_getstack
(
L
,
level
,
&
ar
))
{
/* check function at level */
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) {
}
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_start
(
argp
,
fmt
);
luaL_where
(
L
,
1
);
...
...
@@ -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
*
name
=
(
def
)
?
luaL_optstring
(
L
,
narg
,
def
)
:
luaL_checkstring
(
L
,
narg
);
...
...
@@ -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 */
if
(
!
lua_isnil
(
L
,
-
1
))
/* name already in use? */
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
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 */
if
(
!
lua_isnil
(
L
,
-
1
))
/* name already in use? */
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
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
);
if
(
p
!=
NULL
)
{
/* value is a userdata? */
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
}
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
))
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
)
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
)
{
const
char
*
msg
=
lua_pushfstring
(
L
,
"function or lightfunction expected, got %s"
,
luaL_typename
(
L
,
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
)
{
const
char
*
msg
=
lua_pushfstring
(
L
,
"table or rotable expected, got %s"
,
luaL_typename
(
L
,
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
)
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
);
if
(
!
s
)
tag_error
(
L
,
narg
,
LUA_TSTRING
);
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
)
{
if
(
lua_isnoneornil
(
L
,
narg
))
{
if
(
len
)
...
...
@@ -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
);
if
(
d
==
0
&&
!
lua_isnumber
(
L
,
narg
))
/* avoid extra test when d is not 0 */
tag_error
(
L
,
narg
,
LUA_TNUMBER
);
...
...
@@ -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
);
}
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
);
if
(
d
==
0
&&
!
lua_isnumber
(
L
,
narg
))
/* avoid extra test when d is not 0 */
tag_error
(
L
,
narg
,
LUA_TNUMBER
);
...
...
@@ -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
)
{
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? */
return
0
;
lua_pushstring
(
L
,
event
);
...
...
@@ -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
);
if
(
!
luaL_getmetafield
(
L
,
obj
,
event
))
/* no metafield? */
return
0
;
...
...
@@ -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
)
{
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
)
{
#if LUA_OPTIMIZE_MEMORY > 0
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
#endif
}
static
int
ICACHE_FLASH_ATTR
libsize
(
const
luaL_Reg
*
l
)
{
static
int
libsize
(
const
luaL_Reg
*
l
)
{
int
size
=
0
;
for
(;
l
->
name
;
l
++
)
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
)
{
if
(
libname
)
{
int
size
=
libsize
(
l
);
...
...
@@ -323,14 +323,14 @@ LUALIB_API void ICACHE_FLASH_ATTR luaI_openlib (lua_State *L, const char *libnam
#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
;
lua_pop
(
L
,
topop
);
return
n
;
}
static
void
ICACHE_FLASH_ATTR
getsizes
(
lua_State
*
L
)
{
static
void
getsizes
(
lua_State
*
L
)
{
lua_getfield
(
L
,
LUA_REGISTRYINDEX
,
"LUA_SIZES"
);
if
(
lua_isnil
(
L
,
-
1
))
{
/* no `size' table? */
lua_pop
(
L
,
1
);
/* remove nil */
...
...
@@ -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
);
lua_pushliteral
(
L
,
"n"
);
lua_rawget
(
L
,
t
);
...
...
@@ -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
;
t
=
abs_index
(
L
,
t
);
lua_pushliteral
(
L
,
"n"
);
/* try t.n */
...
...
@@ -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
*
wild
;
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,
}
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
*
e
;
lua_pushvalue
(
L
,
idx
);
...
...
@@ -449,7 +449,7 @@ LUALIB_API const char *ICACHE_FLASH_ATTR luaL_findtable (lua_State *L, int idx,
#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
);
if
(
l
==
0
)
return
0
;
/* put nothing on stack */
else
{
...
...
@@ -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
)
{
lua_State
*
L
=
B
->
L
;
int
toget
=
1
;
/* number of levels to concat */
...
...
@@ -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
))
adjuststack
(
B
);
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
--
)
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
));
}
LUALIB_API
void
ICACHE_FLASH_ATTR
luaL_pushresult
(
luaL_Buffer
*
B
)
{
LUALIB_API
void
luaL_pushresult
(
luaL_Buffer
*
B
)
{
emptybuffer
(
B
);
lua_concat
(
B
->
L
,
B
->
lvl
);
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
;
size_t
vl
;
const
char
*
s
=
lua_tolstring
(
L
,
-
1
,
&
vl
);
...
...
@@ -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
->
p
=
B
->
buffer
;
B
->
lvl
=
0
;
...
...
@@ -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
;
t
=
abs_index
(
L
,
t
);
if
(
lua_isnil
(
L
,
-
1
))
{
...
...
@@ -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
)
{
t
=
abs_index
(
L
,
t
);
lua_rawgeti
(
L
,
t
,
FREELIST_REF
);
...
...
@@ -582,7 +582,7 @@ typedef struct 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;
(void)L;
if (lf->extraline) {
...
...
@@ -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 *filename = lua_tostring(L, fnameindex) + 1;
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
}
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;
int status, readstatus;
int c;
...
...
@@ -656,7 +656,7 @@ typedef struct 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
;
(
void
)
L
;
if
(
lf
->
extraline
)
{
...
...
@@ -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
;
lua_pushfstring
(
L
,
"cannot %s %s"
,
what
,
filename
);
lua_remove
(
L
,
fnameindex
);
...
...
@@ -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
;
int
status
,
readstatus
;
int
c
;
...
...
@@ -722,7 +722,7 @@ typedef struct 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
;
(
void
)
L
;
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)
}
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
)
{
LoadS
ls
;
ls
.
s
=
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
);
}
...
...
@@ -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
);
int
cycle_count
=
0
;
lu_mem
limit
=
g
->
memlimit
-
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
;
int
mode
=
L
==
NULL
?
0
:
G
(
L
)
->
egcmode
;
void
*
nptr
;
...
...
@@ -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 */
#if defined(LUA_USE_STDIO)
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) {
}
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_setallocf
(
L
,
l_alloc
,
L
);
/* allocator need lua_State. */
if
(
L
)
lua_atpanic
(
L
,
&
panic
);
...
...
app/lua/lbaselib.c
View file @
c04f2578
...
...
@@ -29,7 +29,7 @@
** model but changing `fputs' to put the strings at a proper place
** (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
i
;
lua_getglobal
(
L
,
"tostring"
);
...
...
@@ -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
);
if
(
base
==
10
)
{
/* standard conversion */
luaL_checkany
(
L
,
1
);
...
...
@@ -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
);
lua_settop
(
L
,
1
);
if
(
lua_isstring
(
L
,
1
)
&&
level
>
0
)
{
/* add extra information? */
...
...
@@ -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
);
if
(
!
lua_getmetatable
(
L
,
1
))
{
lua_pushnil
(
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
);
luaL_checktype
(
L
,
1
,
LUA_TTABLE
);
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) {
}
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
);
else
{
lua_Debug
ar
;
...
...
@@ -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
);
if
(
lua_iscfunction
(
L
,
-
1
))
/* is a C function? */
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) {
}
static
int
ICACHE_FLASH_ATTR
luaB_setfenv
(
lua_State
*
L
)
{
static
int
luaB_setfenv
(
lua_State
*
L
)
{
luaL_checktype
(
L
,
2
,
LUA_TTABLE
);
getfunc
(
L
,
0
);
lua_pushvalue
(
L
,
2
);
...
...
@@ -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
,
2
);
lua_pushboolean
(
L
,
lua_rawequal
(
L
,
1
,
2
));
...
...
@@ -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_checkany
(
L
,
2
);
lua_settop
(
L
,
2
);
...
...
@@ -184,7 +184,7 @@ static int ICACHE_FLASH_ATTR luaB_rawget (lua_State *L) {
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_checkany
(
L
,
2
);
luaL_checkany
(
L
,
3
);
...
...
@@ -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
));
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"
,
"count"
,
"step"
,
"setpause"
,
"setstepmul"
,
"setmemlimit"
,
"getmemlimit"
,
NULL
};
static
const
int
optsnum
[]
=
{
LUA_GCSTOP
,
LUA_GCRESTART
,
LUA_GCCOLLECT
,
...
...
@@ -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
);
lua_pushstring
(
L
,
luaL_typename
(
L
,
1
));
return
1
;
}
static
int
ICACHE_FLASH_ATTR
luaB_next
(
lua_State
*
L
)
{
static
int
luaB_next
(
lua_State
*
L
)
{
luaL_checkanytable
(
L
,
1
);
lua_settop
(
L
,
2
);
/* create a 2nd argument if there isn't one */
if
(
lua_next
(
L
,
1
))
...
...
@@ -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
);
lua_pushvalue
(
L
,
lua_upvalueindex
(
1
));
/* return generator, */
lua_pushvalue
(
L
,
1
);
/* state, */
...
...
@@ -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
);
luaL_checkanytable
(
L
,
1
);
i
++
;
/* next value */
...
...
@@ -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
);
lua_pushvalue
(
L
,
lua_upvalueindex
(
1
));
/* return generator, */
lua_pushvalue
(
L
,
1
);
/* state, */
...
...
@@ -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? */
return
1
;
else
{
...
...
@@ -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
;
const
char
*
s
=
luaL_checklstring
(
L
,
1
,
&
l
);
const
char
*
chunkname
=
luaL_optstring
(
L
,
2
,
s
);
...
...
@@ -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
);
#if 0
return load_aux(L, luaL_loadfile(L, fname));
...
...
@@ -309,7 +309,7 @@ static int ICACHE_FLASH_ATTR luaB_loadfile (lua_State *L) {
** stack top. Instead, it keeps its resulting string in a
** 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 */
if
(
L
==
NULL
&&
size
==
NULL
)
// direct mode check, doesn't happen
return
NULL
;
...
...
@@ -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
;
const
char
*
cname
=
luaL_optstring
(
L
,
2
,
"=(load)"
);
luaL_checktype
(
L
,
1
,
LUA_TFUNCTION
);
...
...
@@ -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
);
int
n
=
lua_gettop
(
L
);
#if 0
...
...
@@ -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
);
if
(
!
lua_toboolean
(
L
,
1
))
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) {
}
static
int
ICACHE_FLASH_ATTR
luaB_unpack
(
lua_State
*
L
)
{
static
int
luaB_unpack
(
lua_State
*
L
)
{
int
i
,
e
,
n
;
luaL_checktype
(
L
,
1
,
LUA_TTABLE
);
i
=
luaL_optint
(
L
,
2
,
1
);
...
...
@@ -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
);
if
(
lua_type
(
L
,
1
)
==
LUA_TSTRING
&&
*
lua_tostring
(
L
,
1
)
==
'#'
)
{
lua_pushinteger
(
L
,
n
-
1
);
...
...
@@ -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
;
luaL_checkany
(
L
,
1
);
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) {
}
static
int
ICACHE_FLASH_ATTR
luaB_xpcall
(
lua_State
*
L
)
{
static
int
luaB_xpcall
(
lua_State
*
L
)
{
int
status
;
luaL_checkany
(
L
,
2
);
lua_settop
(
L
,
2
);
...
...
@@ -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
);
if
(
luaL_callmeta
(
L
,
1
,
"__tostring"
))
/* is there a metafield? */
return
1
;
/* use its value */
...
...
@@ -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_newuserdata
(
L
,
0
);
/* create proxy */
if
(
lua_toboolean
(
L
,
1
)
==
0
)
...
...
@@ -500,7 +500,7 @@ const LUA_REG_TYPE base_funcs_list[] = {
#endif
static
int
ICACHE_FLASH_ATTR
luaB_index
(
lua_State
*
L
)
{
static
int
luaB_index
(
lua_State
*
L
)
{
#if LUA_OPTIMIZE_MEMORY == 2
int
fres
;
if
((
fres
=
luaR_findfunction
(
L
,
base_funcs_list
))
!=
0
)
...
...
@@ -546,7 +546,7 @@ static const luaL_Reg base_funcs[] = {
static
const
char
*
const
statnames
[]
=
{
"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
;
switch
(
lua_status
(
co
))
{
case
LUA_YIELD
:
...
...
@@ -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
);
luaL_argcheck
(
L
,
co
,
1
,
"coroutine expected"
);
lua_pushstring
(
L
,
statnames
[
costatus
(
L
,
co
)]);
...
...
@@ -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
);
if
(
!
lua_checkstack
(
co
,
narg
))
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) {
}
static
int
ICACHE_FLASH_ATTR
luaB_coresume
(
lua_State
*
L
)
{
static
int
luaB_coresume
(
lua_State
*
L
)
{
lua_State
*
co
=
lua_tothread
(
L
,
1
);
int
r
;
luaL_argcheck
(
L
,
co
,
1
,
"coroutine expected"
);
...
...
@@ -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
));
int
r
=
auxresume
(
L
,
co
,
lua_gettop
(
L
));
if
(
r
<
0
)
{
...
...
@@ -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
);
luaL_argcheck
(
L
,
lua_isfunction
(
L
,
1
)
&&
!
lua_iscfunction
(
L
,
1
),
1
,
"Lua function expected"
);
...
...
@@ -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
);
lua_pushcclosure
(
L
,
luaB_auxwrap
,
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
));
}
static
int
ICACHE_FLASH_ATTR
luaB_corunning
(
lua_State
*
L
)
{
static
int
luaB_corunning
(
lua_State
*
L
)
{
if
(
lua_pushthread
(
L
))
lua_pushnil
(
L
);
/* main thread is not a coroutine */
return
1
;
...
...
@@ -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_pushcfunction
(
L
,
u
);
lua_pushcclosure
(
L
,
f
,
1
);
...
...
@@ -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 */
lua_pushvalue
(
L
,
LUA_GLOBALSINDEX
);
lua_setglobal
(
L
,
"_G"
);
...
...
@@ -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
);
#if LUA_OPTIMIZE_MEMORY == 0
luaL_register
(
L
,
LUA_COLIBNAME
,
co_funcs
);
...
...
app/lua/lcode.c
View file @
c04f2578
...
...
@@ -27,12 +27,12 @@
#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
);
}
void
ICACHE_FLASH_ATTR
luaK_nil
(
FuncState
*
fs
,
int
from
,
int
n
)
{
void
luaK_nil
(
FuncState
*
fs
,
int
from
,
int
n
)
{
Instruction
*
previous
;
if
(
fs
->
pc
>
fs
->
lasttarget
)
{
/* no jumps to current position? */
if
(
fs
->
pc
==
0
)
{
/* function start? */
...
...
@@ -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
j
;
fs
->
jpc
=
NO_JUMP
;
...
...
@@ -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
);
}
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
);
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
];
int
offset
=
dest
-
(
pc
+
1
);
lua_assert
(
dest
!=
NO_JUMP
);
...
...
@@ -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
** 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
;
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
]);
if
(
offset
==
NO_JUMP
)
/* point to itself represents end of list */
return
NO_JUMP
;
/* end of list */
...
...
@@ -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
];
if
(
pc
>=
1
&&
testTMode
(
GET_OPCODE
(
*
(
pi
-
1
))))
return
pi
-
1
;
...
...
@@ -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
** (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
))
{
Instruction
i
=
*
getjumpcontrol
(
fs
,
list
);
if
(
GET_OPCODE
(
i
)
!=
OP_TESTSET
)
return
1
;
...
...
@@ -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
);
if
(
GET_OPCODE
(
*
i
)
!=
OP_TESTSET
)
return
0
;
/* cannot patch other instructions */
...
...
@@ -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
))
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
)
{
while
(
list
!=
NO_JUMP
)
{
int
next
=
getjump
(
fs
,
list
);
...
...
@@ -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
);
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
)
luaK_patchtohere
(
fs
,
list
);
else
{
...
...
@@ -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_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
;
else
if
(
*
l1
==
NO_JUMP
)
*
l1
=
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
;
if
(
newstack
>
fs
->
f
->
maxstacksize
)
{
if
(
newstack
>=
MAXSTACK
)
...
...
@@ -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
);
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
)
{
fs
->
freereg
--
;
lua_assert
(
reg
==
fs
->
freereg
);
...
...
@@ -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
)
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
;
TValue
*
idx
=
luaH_set
(
L
,
fs
->
h
,
k
);
Proto
*
f
=
fs
->
f
;
...
...
@@ -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
;
setsvalue
(
fs
->
L
,
&
o
,
s
);
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
;
setnvalue
(
&
o
,
r
);
return
addk
(
fs
,
&
o
,
&
o
);
}
static
int
ICACHE_FLASH_ATTR
boolK
(
FuncState
*
fs
,
int
b
)
{
static
int
boolK
(
FuncState
*
fs
,
int
b
)
{
TValue
o
;
setbvalue
(
&
o
,
b
);
return
addk
(
fs
,
&
o
,
&
o
);
}
static
int
ICACHE_FLASH_ATTR
nilK
(
FuncState
*
fs
)
{
static
int
nilK
(
FuncState
*
fs
)
{
TValue
k
,
v
;
setnilvalue
(
&
v
);
/* cannot use nil as key; instead use table itself to represent nil */
...
...
@@ -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? */
SETARG_C
(
getcode
(
fs
,
e
),
nresults
+
1
);
}
...
...
@@ -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? */
e
->
k
=
VNONRELOC
;
e
->
u
.
s
.
info
=
GETARG_A
(
getcode
(
fs
,
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
)
{
case
VLOCAL
:
{
e
->
k
=
VNONRELOC
;
...
...
@@ -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 */
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
);
switch
(
e
->
k
)
{
case
VNIL
:
{
...
...
@@ -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
)
{
luaK_reserveregs
(
fs
,
1
);
discharge2reg
(
fs
,
e
,
fs
->
freereg
-
1
);
...
...
@@ -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
);
if
(
e
->
k
==
VJMP
)
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) {
}
void
ICACHE_FLASH_ATTR
luaK_exp2nextreg
(
FuncState
*
fs
,
expdesc
*
e
)
{
void
luaK_exp2nextreg
(
FuncState
*
fs
,
expdesc
*
e
)
{
luaK_dischargevars
(
fs
,
e
);
freeexp
(
fs
,
e
);
luaK_reserveregs
(
fs
,
1
);
...
...
@@ -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
);
if
(
e
->
k
==
VNONRELOC
)
{
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) {
}
void
ICACHE_FLASH_ATTR
luaK_exp2val
(
FuncState
*
fs
,
expdesc
*
e
)
{
void
luaK_exp2val
(
FuncState
*
fs
,
expdesc
*
e
)
{
if
(
hasjumps
(
e
))
luaK_exp2anyreg
(
fs
,
e
);
else
...
...
@@ -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
);
switch
(
e
->
k
)
{
case
VKNUM
:
...
...
@@ -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
)
{
case
VLOCAL
:
{
freeexp
(
fs
,
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
;
luaK_exp2anyreg
(
fs
,
e
);
freeexp
(
fs
,
e
);
...
...
@@ -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
);
lua_assert
(
testTMode
(
GET_OPCODE
(
*
pc
))
&&
GET_OPCODE
(
*
pc
)
!=
OP_TESTSET
&&
GET_OPCODE
(
*
pc
)
!=
OP_TEST
);
...
...
@@ -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
)
{
Instruction
ie
=
getcode
(
fs
,
e
);
if
(
GET_OPCODE
(
ie
)
==
OP_NOT
)
{
...
...
@@ -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 */
luaK_dischargevars
(
fs
,
e
);
switch
(
e
->
k
)
{
...
...
@@ -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 */
luaK_dischargevars
(
fs
,
e
);
switch
(
e
->
k
)
{
...
...
@@ -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
);
switch
(
e
->
k
)
{
case
VNIL
:
case
VFALSE
:
{
...
...
@@ -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
->
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
;
if
(
!
isnumeral
(
e1
)
||
!
isnumeral
(
e2
))
return
0
;
v1
=
e1
->
u
.
nval
;
...
...
@@ -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
))
return
;
else
{
...
...
@@ -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
)
{
int
o1
=
luaK_exp2RK
(
fs
,
e1
);
int
o2
=
luaK_exp2RK
(
fs
,
e2
);
...
...
@@ -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
;
e2
.
t
=
e2
.
f
=
NO_JUMP
;
e2
.
k
=
VKNUM
;
e2
.
u
.
nval
=
0
;
switch
(
op
)
{
...
...
@@ -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
)
{
case
OPR_AND
:
{
luaK_goiftrue
(
fs
,
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
)
{
case
OPR_AND
:
{
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
}
void
ICACHE_FLASH_ATTR
luaK_fixline
(
FuncState
*
fs
,
int
line
)
{
void
luaK_fixline
(
FuncState
*
fs
,
int
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
;
dischargejpc
(
fs
);
/* `pc' will change */
/* put new instruction in code array */
...
...
@@ -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
(
getBMode
(
o
)
!=
OpArgN
||
b
==
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
}
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
(
getCMode
(
o
)
==
OpArgN
);
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
b
=
(
tostore
==
LUA_MULTRET
)
?
0
:
tostore
;
lua_assert
(
tostore
!=
0
);
...
...
app/lua/ldebug.c
View file @
c04f2578
...
...
@@ -33,7 +33,7 @@
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
(
ci
==
L
->
ci
)
ci
->
savedpc
=
L
->
savedpc
;
...
...
@@ -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
);
if
(
pc
<
0
)
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) {
/*
** 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? */
mask
=
0
;
func
=
NULL
;
...
...
@@ -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
;
}
LUA_API
int
ICACHE_FLASH_ATTR
lua_gethookmask
(
lua_State
*
L
)
{
LUA_API
int
lua_gethookmask
(
lua_State
*
L
)
{
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
;
}
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
;
CallInfo
*
ci
;
lua_lock
(
L
);
...
...
@@ -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
);
}
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
;
Proto
*
fp
=
getluaproto
(
ci
);
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
}
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
;
const
char
*
name
=
findlocal
(
L
,
ci
,
n
);
lua_lock
(
L
);
...
...
@@ -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
;
const
char
*
name
=
findlocal
(
L
,
ci
,
n
);
lua_lock
(
L
);
...
...
@@ -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
)
{
ar
->
source
=
"=[C]"
;
ar
->
linedefined
=
-
1
;
...
...
@@ -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
->
what
=
"tail"
;
ar
->
lastlinedefined
=
ar
->
linedefined
=
ar
->
currentline
=
-
1
;
...
...
@@ -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
)
{
setnilvalue
(
L
->
top
);
}
...
...
@@ -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
)
{
int
status
=
1
;
if
(
plight
==
NULL
&&
f
==
NULL
)
{
...
...
@@ -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
;
Closure
*
f
=
NULL
;
CallInfo
*
ci
=
NULL
;
...
...
@@ -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
->
numparams
+
(
pt
->
is_vararg
&
VARARG_HASARG
)
<=
pt
->
maxstacksize
);
check
(
!
(
pt
->
is_vararg
&
VARARG_NEEDSARG
)
||
...
...
@@ -298,7 +298,7 @@ static int ICACHE_FLASH_ATTR precheck (const Proto *pt) {
#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
))
{
case
OP_CALL
:
case
OP_TAILCALL
:
...
...
@@ -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
)
{
case
OpArgN
:
check
(
r
==
0
);
break
;
case
OpArgU
:
break
;
...
...
@@ -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
last
;
/* stores position of last instruction that changed `reg' */
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
/* }====================================================== */
int
ICACHE_FLASH_ATTR
luaG_checkcode
(
const
Proto
*
pt
)
{
int
luaG_checkcode
(
const
Proto
*
pt
)
{
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
)]))
return
svalue
(
&
p
->
k
[
INDEXK
(
c
)]);
else
...
...
@@ -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
)
{
if
(
isLua
(
ci
))
{
/* a Lua function? */
Proto
*
p
=
ci_func
(
ci
)
->
l
.
p
;
...
...
@@ -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
;
if
((
isLua
(
ci
)
&&
ci
->
tailcalls
>
0
)
||
!
isLua
(
ci
-
1
))
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
/* 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
;
for
(
p
=
ci
->
base
;
p
<
ci
->
top
;
p
++
)
if
(
o
==
p
)
return
1
;
...
...
@@ -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
*
t
=
luaT_typenames
[
ttype
(
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
}
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
;
lua_assert
(
!
ttisstring
(
p1
)
&&
!
ttisnumber
(
p1
));
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
;
if
(
luaV_tonumber
(
p1
,
&
temp
)
==
NULL
)
p2
=
p1
;
/* first operand is wrong */
...
...
@@ -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
*
t2
=
luaT_typenames
[
ttype
(
p2
)];
if
(
t1
[
2
]
==
t2
[
2
])
...
...
@@ -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
;
if
(
isLua
(
ci
))
{
/* is Lua code? */
char
buff
[
LUA_IDSIZE
];
/* add file:line information */
...
...
@@ -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? */
StkId
errfunc
=
restorestack
(
L
,
L
->
errfunc
);
if
(
!
ttisfunction
(
errfunc
)
&&
!
ttislightfunction
(
errfunc
))
luaD_throw
(
L
,
LUA_ERRERR
);
...
...
@@ -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_start
(
argp
,
fmt
);
addinfo
(
L
,
luaO_pushvfstring
(
L
,
fmt
,
argp
));
...
...
app/lua/ldo.c
View file @
c04f2578
...
...
@@ -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
)
{
case
LUA_ERRMEM
:
{
ptrdiff_t
oldtopr
=
savestack
(
L
,
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
);
if
(
L
->
size_ci
>
LUAI_MAXCALLS
)
{
/* there was an overflow? */
int
inuse
=
cast_int
(
L
->
ci
-
L
->
base_ci
);
...
...
@@ -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
->
base
=
L
->
ci
->
base
;
luaF_close
(
L
,
L
->
base
);
/* close eventual pending closures */
...
...
@@ -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. */
unset_block_gc
(
L
);
if
(
L
->
errorJmp
)
{
...
...
@@ -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
;
lj
.
status
=
0
;
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) {
/* }====================================================== */
static
void
ICACHE_FLASH_ATTR
correctstack
(
lua_State
*
L
,
TValue
*
oldstack
)
{
static
void
correctstack
(
lua_State
*
L
,
TValue
*
oldstack
)
{
CallInfo
*
ci
;
GCObject
*
up
;
L
->
top
=
(
L
->
top
-
oldstack
)
+
L
->
stack
;
...
...
@@ -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
;
int
realsize
=
newsize
+
1
+
EXTRA_STACK
;
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) {
}
void
ICACHE_FLASH_ATTR
luaD_reallocCI
(
lua_State
*
L
,
int
newsize
)
{
void
luaD_reallocCI
(
lua_State
*
L
,
int
newsize
)
{
CallInfo
*
oldci
=
L
->
base_ci
;
luaM_reallocvector
(
L
,
L
->
base_ci
,
L
->
size_ci
,
newsize
,
CallInfo
);
L
->
size_ci
=
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? */
luaD_reallocstack
(
L
,
2
*
L
->
stacksize
);
else
...
...
@@ -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? */
luaD_throw
(
L
,
LUA_ERRERR
);
else
{
...
...
@@ -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
;
if
(
hook
&&
L
->
allowhook
)
{
ptrdiff_t
top
=
savestack
(
L
,
L
->
top
);
...
...
@@ -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
nfixargs
=
p
->
numparams
;
#if defined(LUA_COMPAT_VARARG)
...
...
@@ -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
);
StkId
p
;
ptrdiff_t
funcr
=
savestack
(
L
,
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))
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
;
LClosure
*
cl
=
NULL
;
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) {
}
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 */
luaD_callhook
(
L
,
LUA_HOOKRET
,
-
1
);
if
(
f_isLua
(
L
->
ci
))
{
/* Lua function? */
...
...
@@ -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
;
int
wanted
,
i
;
CallInfo
*
ci
;
...
...
@@ -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
** 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
)
luaG_runerror
(
L
,
"C stack overflow"
);
...
...
@@ -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
);
CallInfo
*
ci
=
L
->
ci
;
if
(
L
->
status
==
0
)
{
/* start coroutine? */
...
...
@@ -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
;
setsvalue2s
(
L
,
L
->
top
,
luaS_new
(
L
,
msg
));
incr_top
(
L
);
...
...
@@ -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
;
lua_lock
(
L
);
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) {
}
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
);
lua_lock
(
L
);
if
(
L
->
nCcalls
>
L
->
baseCcalls
)
...
...
@@ -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
)
{
int
status
;
unsigned
short
oldnCcalls
=
L
->
nCcalls
;
...
...
@@ -504,7 +504,7 @@ struct SParser { /* data to `f_parser' */
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
;
Proto
*
tf
;
Closure
*
cl
;
...
...
@@ -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
;
int
status
;
p
.
z
=
z
;
p
.
name
=
name
;
...
...
app/lua/ldump.c
View file @
c04f2578
...
...
@@ -29,7 +29,7 @@ typedef struct {
#define DumpMem(b,n,size,D) DumpBlock(b,(n)*(size),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
)
{
...
...
@@ -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
;
DumpVar
(
x
,
D
);
}
static
void
ICACHE_FLASH_ATTR
Align4
(
DumpState
*
D
)
static
void
Align4
(
DumpState
*
D
)
{
while
(
D
->
wrote
&
3
)
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
platform_little_endian
=
*
(
char
*
)
&
x
;
...
...
@@ -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 */
switch
(
sizeof_int
)
{
...
...
@@ -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
);
}
static
void
ICACHE_FLASH_ATTR
DumpSize
(
uint32_t
x
,
DumpState
*
D
)
static
void
DumpSize
(
uint32_t
x
,
DumpState
*
D
)
{
/* dump unsigned integer */
switch
(
D
->
target
.
sizeof_strsize_t
)
{
...
...
@@ -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 )
DumpIntWithSize
(
x
,
D
->
target
.
sizeof_lua_Number
,
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 )
}
static
void
ICACHE_FLASH_ATTR
DumpCode
(
const
Proto
*
f
,
DumpState
*
D
)
static
void
DumpCode
(
const
Proto
*
f
,
DumpState
*
D
)
{
DumpInt
(
f
->
sizecode
,
D
);
char
buf
[
10
];
...
...
@@ -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
)
{
...
...
@@ -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
ICACHE_FLASH_ATTR
DumpConstants
(
const
Proto
*
f
,
DumpState
*
D
)
static
void
DumpConstants
(
const
Proto
*
f
,
DumpState
*
D
)
{
int
i
,
n
=
f
->
sizek
;
DumpInt
(
n
,
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
);
}
static
void
ICACHE_FLASH_ATTR
DumpDebug
(
const
Proto
*
f
,
DumpState
*
D
)
static
void
DumpDebug
(
const
Proto
*
f
,
DumpState
*
D
)
{
int
i
,
n
;
n
=
(
D
->
strip
)
?
0
:
f
->
sizelineinfo
;
...
...
@@ -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
);
}
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
);
DumpInt
(
f
->
linedefined
,
D
);
...
...
@@ -265,7 +265,7 @@ static void ICACHE_FLASH_ATTR DumpFunction(const Proto* f, const TString* p, Dum
DumpDebug
(
f
,
D
);
}
static
void
ICACHE_FLASH_ATTR
DumpHeader
(
DumpState
*
D
)
static
void
DumpHeader
(
DumpState
*
D
)
{
char
buf
[
LUAC_HEADERSIZE
];
char
*
h
=
buf
;
...
...
@@ -288,7 +288,7 @@ static void ICACHE_FLASH_ATTR DumpHeader(DumpState* D)
/*
** 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
;
D
.
L
=
L
;
...
...
@@ -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
*/
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
;
int
test
=
1
;
...
...
app/lua/legc.c
View file @
c04f2578
...
...
@@ -4,7 +4,7 @@
#include "lstate.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
);
g
->
egcmode
=
mode
;
...
...
app/lua/lfunc.c
View file @
c04f2578
...
...
@@ -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
)));
luaC_link
(
L
,
obj2gco
(
c
),
LUA_TFUNCTION
);
c
->
c
.
isC
=
1
;
...
...
@@ -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
)));
luaC_link
(
L
,
obj2gco
(
c
),
LUA_TFUNCTION
);
c
->
l
.
isC
=
0
;
...
...
@@ -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
);
luaC_link
(
L
,
obj2gco
(
uv
),
LUA_TUPVAL
);
uv
->
v
=
&
uv
->
u
.
value
;
...
...
@@ -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
);
GCObject
**
pp
=
&
L
->
openupval
;
UpVal
*
p
;
...
...
@@ -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
);
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
;
}
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? */
unlinkupval
(
uv
);
/* remove from open list */
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
;
global_State
*
g
=
G
(
L
);
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) {
}
Proto
*
ICACHE_FLASH_ATTR
luaF_newproto
(
lua_State
*
L
)
{
Proto
*
luaF_newproto
(
lua_State
*
L
)
{
Proto
*
f
=
luaM_new
(
L
,
Proto
);
luaC_link
(
L
,
obj2gco
(
f
),
LUA_TPROTO
);
f
->
k
=
NULL
;
...
...
@@ -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
->
k
,
f
->
sizek
,
TValue
);
luaM_freearray
(
L
,
f
->
locvars
,
f
->
sizelocvars
,
struct
LocVar
);
...
...
@@ -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
)
:
sizeLclosure
(
c
->
l
.
nupvalues
);
luaM_freemem
(
L
,
c
,
size
);
...
...
@@ -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'.
** 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
;
for
(
i
=
0
;
i
<
f
->
sizelocvars
&&
f
->
locvars
[
i
].
startpc
<=
pc
;
i
++
)
{
if
(
pc
<
f
->
locvars
[
i
].
endpc
)
{
/* is variable active? */
...
...
app/lua/lgc.c
View file @
c04f2578
...
...
@@ -59,14 +59,14 @@
#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
)));
if
(
iscollectable
(
gkey
(
n
)))
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
));
white2gray
(
o
);
switch
(
o
->
gch
.
tt
)
{
...
...
@@ -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
;
if
(
u
)
{
do
{
...
...
@@ -125,7 +125,7 @@ static void ICACHE_FLASH_ATTR marktmu (global_State *g) {
/* 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
);
size_t
deadmem
=
0
;
GCObject
**
p
=
&
g
->
mainthread
->
next
;
...
...
@@ -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
weakkey
=
0
;
int
weakvalue
=
0
;
...
...
@@ -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
** 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
;
if
(
f
->
source
)
stringmark
(
f
->
source
);
for
(
i
=
0
;
i
<
f
->
sizek
;
i
++
)
/* mark literals */
...
...
@@ -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
);
if
(
cl
->
c
.
isC
)
{
int
i
;
...
...
@@ -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
s_used
=
cast_int
(
max
-
L
->
stack
);
/* part of stack in use */
if
(
L
->
size_ci
>
LUAI_MAXCALLS
)
/* handling overflow? */
...
...
@@ -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
;
CallInfo
*
ci
;
markvalue
(
g
,
gt
(
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.
** Returns `quantity' traversed.
*/
static
l_mem
ICACHE_FLASH_ATTR
propagatemark
(
global_State
*
g
)
{
static
l_mem
propagatemark
(
global_State
*
g
)
{
GCObject
*
o
=
g
->
gray
;
lua_assert
(
isgray
(
o
));
gray2black
(
o
);
...
...
@@ -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
;
while
(
g
->
gray
)
m
+=
propagatemark
(
g
);
return
m
;
...
...
@@ -338,7 +338,7 @@ static size_t ICACHE_FLASH_ATTR propagateall (global_State *g) {
** other objects: if really collected, cannot keep them; for userdata
** 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
(
ttisstring
(
o
))
{
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) {
/*
** clear collected entries from weaktables
*/
static
void
ICACHE_FLASH_ATTR
cleartable
(
GCObject
*
l
)
{
static
void
cleartable
(
GCObject
*
l
)
{
while
(
l
)
{
Table
*
h
=
gco2h
(
l
);
int
i
=
h
->
sizearray
;
...
...
@@ -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
)
{
case
LUA_TPROTO
:
luaF_freeproto
(
L
,
gco2p
(
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) {
#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
;
global_State
*
g
=
G
(
L
);
int
deadmask
=
otherwhite
(
g
);
...
...
@@ -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
);
/* check size of string hash */
if
(
g
->
strt
.
nuse
<
cast
(
lu_int32
,
g
->
strt
.
size
/
4
)
&&
...
...
@@ -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
);
GCObject
*
o
=
g
->
tmudata
->
gch
.
next
;
/* get first element */
Udata
*
udata
=
rawgco2u
(
o
);
...
...
@@ -478,13 +478,13 @@ static void ICACHE_FLASH_ATTR GCTM (lua_State *L) {
/*
** Call all GC tag methods
*/
void
ICACHE_FLASH_ATTR
luaC_callGCTM
(
lua_State
*
L
)
{
void
luaC_callGCTM
(
lua_State
*
L
)
{
while
(
G
(
L
)
->
tmudata
)
GCTM
(
L
);
}
void
ICACHE_FLASH_ATTR
luaC_freeall
(
lua_State
*
L
)
{
void
luaC_freeall
(
lua_State
*
L
)
{
global_State
*
g
=
G
(
L
);
int
i
;
g
->
currentwhite
=
WHITEBITS
|
bitmask
(
SFIXEDBIT
);
/* mask to collect all elements */
...
...
@@ -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
;
for
(
i
=
0
;
i
<
NUM_TAGS
;
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) {
/* mark root set */
static
void
ICACHE_FLASH_ATTR
markroot
(
lua_State
*
L
)
{
static
void
markroot
(
lua_State
*
L
)
{
global_State
*
g
=
G
(
L
);
g
->
gray
=
NULL
;
g
->
grayagain
=
NULL
;
...
...
@@ -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
;
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
);
...
...
@@ -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
);
size_t
udsize
;
/* total size of userdata to be finalized */
/* remark occasional upvalues of (maybe) dead threads */
...
...
@@ -556,7 +556,7 @@ static void ICACHE_FLASH_ATTR atomic (lua_State *L) {
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
;
sweepwholelist
(
L
,
&
g
->
strt
.
hash
[
g
->
sweepstrgc
++
]);
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) {
}
static
l_mem
ICACHE_FLASH_ATTR
singlestep
(
lua_State
*
L
)
{
static
l_mem
singlestep
(
lua_State
*
L
)
{
global_State
*
g
=
G
(
L
);
/*lua_checkmemory(L);*/
switch
(
g
->
gcstate
)
{
...
...
@@ -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
);
if
(
is_block_gc
(
L
))
return
;
set_block_gc
(
L
);
...
...
@@ -645,7 +645,7 @@ void ICACHE_FLASH_ATTR luaC_step (lua_State *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
);
if
(
g
->
gcstate
==
GCSsweepstring
)
{
sweepstrstep
(
g
,
L
);
...
...
@@ -654,7 +654,7 @@ int ICACHE_FLASH_ATTR luaC_sweepstrgc (lua_State *L) {
return
0
;
}
void
ICACHE_FLASH_ATTR
luaC_fullgc
(
lua_State
*
L
)
{
void
luaC_fullgc
(
lua_State
*
L
)
{
global_State
*
g
=
G
(
L
);
if
(
is_block_gc
(
L
))
return
;
set_block_gc
(
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
);
lua_assert
(
isblack
(
o
)
&&
iswhite
(
v
)
&&
!
isdead
(
g
,
v
)
&&
!
isdead
(
g
,
o
));
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) {
}
void
ICACHE_FLASH_ATTR
luaC_barrierback
(
lua_State
*
L
,
Table
*
t
)
{
void
luaC_barrierback
(
lua_State
*
L
,
Table
*
t
)
{
global_State
*
g
=
G
(
L
);
GCObject
*
o
=
obj2gco
(
t
);
lua_assert
(
isblack
(
o
)
&&
!
isdead
(
g
,
o
));
...
...
@@ -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
);
o
->
gch
.
marked
=
luaC_white
(
g
);
if
(
g
->
gcstate
==
GCSpropagate
)
...
...
@@ -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
);
o
->
gch
.
next
=
g
->
rootgc
;
g
->
rootgc
=
o
;
...
...
@@ -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
);
GCObject
*
o
=
obj2gco
(
uv
);
o
->
gch
.
next
=
g
->
rootgc
;
/* link upvalue into `rootgc' list */
...
...
Prev
1
2
3
4
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment