Commit c04f2578 authored by HuangRui's avatar HuangRui
Browse files

Updated SDK to v0.9.5 and optimized memory.

parent 0420b6d7
...@@ -41,7 +41,38 @@ endif # } PDIR ...@@ -41,7 +41,38 @@ endif # } PDIR
APPDIR = . APPDIR = .
LDDIR = ../ld 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 = \ TARGET_LDFLAGS = \
-nostdlib \ -nostdlib \
...@@ -49,6 +80,7 @@ TARGET_LDFLAGS = \ ...@@ -49,6 +80,7 @@ TARGET_LDFLAGS = \
--longcalls \ --longcalls \
--text-section-literals --text-section-literals
ifeq ($(FLAVOR),debug) ifeq ($(FLAVOR),debug)
TARGET_LDFLAGS += -g -O2 TARGET_LDFLAGS += -g -O2
endif endif
......
...@@ -72,7 +72,7 @@ static uint8_t LastFamilyDiscrepancy[NUM_OW]; ...@@ -72,7 +72,7 @@ static uint8_t LastFamilyDiscrepancy[NUM_OW];
static uint8_t LastDeviceFlag[NUM_OW]; static uint8_t LastDeviceFlag[NUM_OW];
#endif #endif
void ICACHE_FLASH_ATTR onewire_init(uint8_t pin) void onewire_init(uint8_t pin)
{ {
// pinMode(pin, INPUT); // pinMode(pin, INPUT);
platform_gpio_mode(pin, PLATFORM_GPIO_INPUT, PLATFORM_GPIO_PULLUP); platform_gpio_mode(pin, PLATFORM_GPIO_INPUT, PLATFORM_GPIO_PULLUP);
...@@ -88,7 +88,7 @@ void ICACHE_FLASH_ATTR onewire_init(uint8_t pin) ...@@ -88,7 +88,7 @@ void ICACHE_FLASH_ATTR onewire_init(uint8_t pin)
// //
// Returns 1 if a device asserted a presence pulse, 0 otherwise. // 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 r;
uint8_t retries = 125; uint8_t retries = 125;
...@@ -120,7 +120,7 @@ uint8_t ICACHE_FLASH_ATTR onewire_reset(uint8_t pin) ...@@ -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 // Write a bit. Port and bit is used to cut lookup time and provide
// more certain timing. // 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) { if (v & 1) {
noInterrupts(); noInterrupts();
...@@ -145,7 +145,7 @@ static void ICACHE_FLASH_ATTR onewire_write_bit(uint8_t pin, uint8_t v) ...@@ -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 // Read a bit. Port and bit is used to cut lookup time and provide
// more certain timing. // 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; uint8_t r;
...@@ -168,7 +168,7 @@ static uint8_t ICACHE_FLASH_ATTR onewire_read_bit(uint8_t pin) ...@@ -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 // go tri-state at the end of the write to avoid heating in a short or
// other mishap. // 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; uint8_t bitMask;
for (bitMask = 0x01; bitMask; bitMask <<= 1) { 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 /* = ...@@ -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; uint16_t i;
for (i = 0 ; i < count ; i++) for (i = 0 ; i < count ; i++)
onewire_write(pin, buf[i], 0); 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 ...@@ -197,7 +197,7 @@ void ICACHE_FLASH_ATTR onewire_write_bytes(uint8_t pin, const uint8_t *buf, uint
// //
// Read a byte // 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 bitMask;
uint8_t r = 0; uint8_t r = 0;
...@@ -207,7 +207,7 @@ uint8_t ICACHE_FLASH_ATTR onewire_read(uint8_t pin) { ...@@ -207,7 +207,7 @@ uint8_t ICACHE_FLASH_ATTR onewire_read(uint8_t pin) {
return r; 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; uint16_t i;
for (i = 0 ; i < count ; i++) for (i = 0 ; i < count ; i++)
buf[i] = onewire_read(pin); 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 ...@@ -216,7 +216,7 @@ void ICACHE_FLASH_ATTR onewire_read_bytes(uint8_t pin, uint8_t *buf, uint16_t co
// //
// Do a ROM select // 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; uint8_t i;
...@@ -228,12 +228,12 @@ void ICACHE_FLASH_ATTR onewire_select(uint8_t pin, const uint8_t rom[8]) ...@@ -228,12 +228,12 @@ void ICACHE_FLASH_ATTR onewire_select(uint8_t pin, const uint8_t rom[8])
// //
// Do a ROM skip // 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 onewire_write(pin, 0xCC, 0); // Skip ROM
} }
void ICACHE_FLASH_ATTR onewire_depower(uint8_t pin) void onewire_depower(uint8_t pin)
{ {
noInterrupts(); noInterrupts();
DIRECT_MODE_INPUT(pin); DIRECT_MODE_INPUT(pin);
...@@ -246,7 +246,7 @@ void ICACHE_FLASH_ATTR onewire_depower(uint8_t 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 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. // 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 // reset the search state
LastDiscrepancy[pin] = 0; LastDiscrepancy[pin] = 0;
...@@ -262,7 +262,7 @@ void ICACHE_FLASH_ATTR onewire_reset_search(uint8_t pin) ...@@ -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 // Setup the search to find the device type 'family_code' on the next call
// to search(*newAddr) if it is present. // 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 // set the search state to find SearchFamily type devices
ROM_NO[pin][0] = family_code; ROM_NO[pin][0] = family_code;
...@@ -290,7 +290,7 @@ void ICACHE_FLASH_ATTR onewire_target_search(uint8_t pin, uint8_t 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 // Return TRUE : device found, ROM number in ROM_NO buffer
// FALSE : device not found, end of search // 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 id_bit_number;
uint8_t last_zero, rom_byte_number, search_result; uint8_t last_zero, rom_byte_number, search_result;
...@@ -449,7 +449,7 @@ static const uint8_t dscrc_table[] = { ...@@ -449,7 +449,7 @@ static const uint8_t dscrc_table[] = {
// compared to all those delayMicrosecond() calls. But I got // compared to all those delayMicrosecond() calls. But I got
// confused, so I use this table from the examples.) // 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; uint8_t crc = 0;
...@@ -463,7 +463,7 @@ uint8_t ICACHE_FLASH_ATTR onewire_crc8(const uint8_t *addr, uint8_t len) ...@@ -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. // Compute a Dallas Semiconductor 8 bit CRC directly.
// this is much slower, but much smaller, than the lookup table. // 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; uint8_t crc = 0;
...@@ -501,7 +501,7 @@ uint8_t ICACHE_FLASH_ATTR onewire_crc8(const uint8_t *addr, uint8_t len) ...@@ -501,7 +501,7 @@ uint8_t ICACHE_FLASH_ATTR onewire_crc8(const uint8_t *addr, uint8_t len)
// *not* at a 16-bit integer. // *not* at a 16-bit integer.
// @param crc - The crc starting value (optional) // @param crc - The crc starting value (optional)
// @return True, iff the CRC matches. // @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); crc = ~onewire_crc16(input, len, crc);
return (crc & 0xFF) == inverted_crc[0] && (crc >> 8) == inverted_crc[1]; 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 ...@@ -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 len - How many bytes to use.
// @param crc - The crc starting value (optional) // @param crc - The crc starting value (optional)
// @return The CRC16, as defined by Dallas Semiconductor. // @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] = static const uint8_t oddparity[16] =
{ 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0 }; { 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0 };
......
...@@ -305,7 +305,7 @@ pwm_get_freq(uint8 channel) ...@@ -305,7 +305,7 @@ pwm_get_freq(uint8 channel)
* Parameters : NONE * Parameters : NONE
* Returns : NONE * Returns : NONE
*******************************************************************************/ *******************************************************************************/
LOCAL void LOCAL void ICACHE_RAM_ATTR
pwm_tim1_intr_handler(void) pwm_tim1_intr_handler(void)
{ {
uint8 local_toggle = pwm_toggle; // pwm_toggle may change outside uint8 local_toggle = pwm_toggle; // pwm_toggle may change outside
......
...@@ -11,7 +11,7 @@ extern UartDevice UartDev; ...@@ -11,7 +11,7 @@ extern UartDevice UartDev;
#define uart_putc uart0_putc #define uart_putc uart0_putc
bool ICACHE_FLASH_ATTR uart_getc(char *c){ bool uart_getc(char *c){
RcvMsgBuff *pRxBuff = &(UartDev.rcv_buff); RcvMsgBuff *pRxBuff = &(UartDev.rcv_buff);
if(pRxBuff->pWritePos == pRxBuff->pReadPos){ // empty if(pRxBuff->pWritePos == pRxBuff->pReadPos){ // empty
return false; return false;
...@@ -30,7 +30,7 @@ bool ICACHE_FLASH_ATTR uart_getc(char *c){ ...@@ -30,7 +30,7 @@ bool ICACHE_FLASH_ATTR uart_getc(char *c){
} }
#if 0 #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; char ch;
int line_position; int line_position;
......
...@@ -20,7 +20,8 @@ ...@@ -20,7 +20,8 @@
// UartDev is defined and initialized in rom code. // UartDev is defined and initialized in rom code.
extern UartDevice UartDev; 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 * FunctionName : uart_config
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
#define NODE_VERSION_MAJOR 0U #define NODE_VERSION_MAJOR 0U
#define NODE_VERSION_MINOR 9U #define NODE_VERSION_MINOR 9U
#define NODE_VERSION_REVISION 4U #define NODE_VERSION_REVISION 5U
#define NODE_VERSION_INTERNAL 0U #define NODE_VERSION_INTERNAL 0U
#define NODE_VERSION "NodeMcu 0.9.4" #define NODE_VERSION "NodeMcu 0.9.5"
#define BUILD_DATE "build 20150101" #define BUILD_DATE "build 20150105"
// #define FLASH_512K // #define FLASH_512K
// #define FLASH_1M // #define FLASH_1M
...@@ -35,8 +35,9 @@ ...@@ -35,8 +35,9 @@
#define NODE_ERR #define NODE_ERR
#endif /* NODE_ERROR */ #endif /* NODE_ERROR */
#define NODE_STORE_TYPEDEF_ATTR __attribute__((aligned(4),packed)) #define ICACHE_STORE_TYPEDEF_ATTR __attribute__((aligned(4),packed))
#define NODE_STORE_ATTR __attribute__((aligned(4))) #define ICACHE_STORE_ATTR __attribute__((aligned(4)))
#define ICACHE_RAM_ATTR __attribute__((section(".iram0.text")))
#define CLIENT_SSL_ENABLE #define CLIENT_SSL_ENABLE
#define GPIO_INTERRUPT_ENABLE #define GPIO_INTERRUPT_ENABLE
......
#include "c_ctype.h" #include "c_ctype.h"
#include "c_types.h" #include "c_types.h"
// int ICACHE_FLASH_ATTR isalnum(int c){} // int isalnum(int c){}
// int ICACHE_FLASH_ATTR isalpha(int c){} // int isalpha(int c){}
// int ICACHE_FLASH_ATTR iscntrl(int c){} // int iscntrl(int c){}
// int ICACHE_FLASH_ATTR isdigit(int c){} // int isdigit(int c){}
// // int ICACHE_FLASH_ATTR isgraph(int c){} // // int isgraph(int c){}
// int ICACHE_FLASH_ATTR islower(int c){} // int islower(int c){}
// int ICACHE_FLASH_ATTR isprint(int c){} // int isprint(int c){}
// int ICACHE_FLASH_ATTR ispunct(int c){} // int ispunct(int c){}
// int ICACHE_FLASH_ATTR isspace(int c){} // int isspace(int c){}
// int ICACHE_FLASH_ATTR isupper(int c){} // int isupper(int c){}
// int ICACHE_FLASH_ATTR isxdigit(int c){} // int isxdigit(int c){}
// int ICACHE_FLASH_ATTR tolower(int c){} // int tolower(int c){}
// int ICACHE_FLASH_ATTR toupper(int c){} // int toupper(int c){}
...@@ -3,34 +3,34 @@ ...@@ -3,34 +3,34 @@
#if 0 #if 0
#ifndef __math_68881 #ifndef __math_68881
double ICACHE_FLASH_ATTR atan(double x){ double atan(double x){
return x; return x;
} }
double ICACHE_FLASH_ATTR cos(double x){ double cos(double x){
return x; return x;
} }
double ICACHE_FLASH_ATTR sin(double x){ double sin(double x){
return x; return x;
} }
double ICACHE_FLASH_ATTR tan(double x){ double tan(double x){
return x; return x;
} }
double ICACHE_FLASH_ATTR tanh(double x){ double tanh(double x){
return x; return x;
} }
double ICACHE_FLASH_ATTR frexp(double x, int *y){ double frexp(double x, int *y){
return x; return x;
} }
double ICACHE_FLASH_ATTR modf(double x, double *y){ double modf(double x, double *y){
return x; return x;
} }
double ICACHE_FLASH_ATTR ceil(double x){ double ceil(double x){
return x; return x;
} }
double ICACHE_FLASH_ATTR fabs(double x){ double fabs(double x){
return x; return x;
} }
double ICACHE_FLASH_ATTR floor(double x){ double floor(double x){
return x; return x;
} }
#endif /* ! defined (__math_68881) */ #endif /* ! defined (__math_68881) */
...@@ -39,40 +39,40 @@ double ICACHE_FLASH_ATTR floor(double x){ ...@@ -39,40 +39,40 @@ double ICACHE_FLASH_ATTR floor(double x){
#ifndef _REENT_ONLY #ifndef _REENT_ONLY
#ifndef __math_68881 #ifndef __math_68881
double ICACHE_FLASH_ATTR acos(double x){ double acos(double x){
return x; return x;
} }
double ICACHE_FLASH_ATTR asin(double x){ double asin(double x){
return x; return x;
} }
double ICACHE_FLASH_ATTR atan2(double x, double y){ double atan2(double x, double y){
return x; return x;
} }
double ICACHE_FLASH_ATTR cosh(double x){ double cosh(double x){
return x; return x;
} }
double ICACHE_FLASH_ATTR sinh(double x){ double sinh(double x){
return x; return x;
} }
double ICACHE_FLASH_ATTR exp(double x){ double exp(double x){
return x; return x;
} }
double ICACHE_FLASH_ATTR ldexp(double x, int y){ double ldexp(double x, int y){
return x; return x;
} }
double ICACHE_FLASH_ATTR log(double x){ double log(double x){
return x; return x;
} }
double ICACHE_FLASH_ATTR log10(double x){ double log10(double x){
return x; return x;
} }
double ICACHE_FLASH_ATTR pow(double x, double y){ double pow(double x, double y){
return x; return x;
} }
double ICACHE_FLASH_ATTR sqrt(double x){ double sqrt(double x){
return x; return x;
} }
double ICACHE_FLASH_ATTR fmod(double x, double y){ double fmod(double x, double y){
return x; return x;
} }
#endif /* ! defined (__math_68881) */ #endif /* ! defined (__math_68881) */
......
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
// const char *lua_init_value = "print(\"Hello world\")"; // const char *lua_init_value = "print(\"Hello world\")";
const char *lua_init_value = "@init.lua"; const char *lua_init_value = "@init.lua";
// int ICACHE_FLASH_ATTR c_abs(int x){ // int c_abs(int x){
// return x>0?x:0-x; // return x>0?x:0-x;
// } // }
// void ICACHE_FLASH_ATTR c_exit(int e){ // void c_exit(int e){
// } // }
const char *ICACHE_FLASH_ATTR c_getenv(const char *__string){ const char *c_getenv(const char *__string){
if (c_strcmp(__string, "LUA_INIT") == 0){ if (c_strcmp(__string, "LUA_INIT") == 0){
return lua_init_value; return lua_init_value;
} }
...@@ -20,7 +20,7 @@ const char *ICACHE_FLASH_ATTR c_getenv(const char *__string){ ...@@ -20,7 +20,7 @@ const char *ICACHE_FLASH_ATTR c_getenv(const char *__string){
} }
// make sure there is enough memory before real malloc, otherwise malloc will panic and reset // make sure there is enough memory before real malloc, otherwise malloc will panic and reset
void *ICACHE_FLASH_ATTR c_malloc(size_t __size){ void *c_malloc(size_t __size){
if(__size>system_get_free_heap_size()){ if(__size>system_get_free_heap_size()){
NODE_ERR("malloc: not enough memory\n"); NODE_ERR("malloc: not enough memory\n");
return NULL; return NULL;
...@@ -28,7 +28,7 @@ void *ICACHE_FLASH_ATTR c_malloc(size_t __size){ ...@@ -28,7 +28,7 @@ void *ICACHE_FLASH_ATTR c_malloc(size_t __size){
return (void *)os_malloc(__size); return (void *)os_malloc(__size);
} }
void *ICACHE_FLASH_ATTR c_zalloc(size_t __size){ void *c_zalloc(size_t __size){
if(__size>system_get_free_heap_size()){ if(__size>system_get_free_heap_size()){
NODE_ERR("zalloc: not enough memory\n"); NODE_ERR("zalloc: not enough memory\n");
return NULL; return NULL;
...@@ -36,25 +36,25 @@ void *ICACHE_FLASH_ATTR c_zalloc(size_t __size){ ...@@ -36,25 +36,25 @@ void *ICACHE_FLASH_ATTR c_zalloc(size_t __size){
return (void *)os_zalloc(__size); return (void *)os_zalloc(__size);
} }
void ICACHE_FLASH_ATTR c_free(void *p){ void c_free(void *p){
// NODE_ERR("free1: %d\n", system_get_free_heap_size()); // NODE_ERR("free1: %d\n", system_get_free_heap_size());
os_free(p); os_free(p);
// NODE_ERR("-free1: %d\n", system_get_free_heap_size()); // NODE_ERR("-free1: %d\n", system_get_free_heap_size());
} }
// int ICACHE_FLASH_ATTR c_rand(void){ // int c_rand(void){
// } // }
// void ICACHE_FLASH_ATTR c_srand(unsigned int __seed){ // void c_srand(unsigned int __seed){
// } // }
// int ICACHE_FLASH_ATTR c_atoi(const char *__nptr){ // int c_atoi(const char *__nptr){
// } // }
// double ICACHE_FLASH_ATTR c_strtod(const char *__n, char **__end_PTR){ // double c_strtod(const char *__n, char **__end_PTR){
// } // }
// long ICACHE_FLASH_ATTR c_strtol(const char *__n, char **__end_PTR, int __base){ // long c_strtol(const char *__n, char **__end_PTR, int __base){
// } // }
// unsigned long ICACHE_FLASH_ATTR c_strtoul(const char *__n, char **__end_PTR, int __base){ // unsigned long c_strtoul(const char *__n, char **__end_PTR, int __base){
// } // }
// long long ICACHE_FLASH_ATTR c_strtoll(const char *__n, char **__end_PTR, int __base){ // long long c_strtoll(const char *__n, char **__end_PTR, int __base){
// } // }
...@@ -22,15 +22,15 @@ extern char Image$$ER_IROM1$$Limit; ...@@ -22,15 +22,15 @@ extern char Image$$ER_IROM1$$Limit;
//#warning "Please check linker script to ensure rodata is between _stext and _etext." //#warning "Please check linker script to ensure rodata is between _stext and _etext."
/* symbols defined in linker script */ /* symbols defined in linker script */
extern char _rodata_start; // extern char _rodata_start;
extern char _rodata_end; // extern char _rodata_end;
// extern char _irom0_text_start; extern char _irom0_text_start;
// extern char _irom0_text_end; extern char _irom0_text_end;
// modify linker script to ensure rodata and rodata1 is between _rodata_start and _rodata_end. // modify linker script to ensure rodata and rodata1 is between _rodata_start and _rodata_end.
#define RODATA_START_ADDRESS (&_rodata_start) // #define RODATA_START_ADDRESS (&_rodata_start)
#define RODATA_END_ADDRESS (&_rodata_end) // #define RODATA_END_ADDRESS (&_rodata_end)
// #define RODATA_START_ADDRESS (&_irom0_text_start) #define RODATA_START_ADDRESS (&_irom0_text_start)
// #define RODATA_END_ADDRESS (&_irom0_text_end) #define RODATA_END_ADDRESS (&_irom0_text_end)
#else // other compilers #else // other compilers
......
...@@ -46,7 +46,7 @@ const char lua_ident[] = ...@@ -46,7 +46,7 @@ const char lua_ident[] =
static TValue *ICACHE_FLASH_ATTR index2adr (lua_State *L, int idx) { static TValue *index2adr (lua_State *L, int idx) {
if (idx > 0) { if (idx > 0) {
TValue *o = L->base + (idx - 1); TValue *o = L->base + (idx - 1);
api_check(L, idx <= L->ci->top - L->base); api_check(L, idx <= L->ci->top - L->base);
...@@ -77,7 +77,7 @@ static TValue *ICACHE_FLASH_ATTR index2adr (lua_State *L, int idx) { ...@@ -77,7 +77,7 @@ static TValue *ICACHE_FLASH_ATTR index2adr (lua_State *L, int idx) {
} }
static Table *ICACHE_FLASH_ATTR getcurrenv (lua_State *L) { static Table *getcurrenv (lua_State *L) {
if (L->ci == L->base_ci) /* no enclosing function? */ if (L->ci == L->base_ci) /* no enclosing function? */
return hvalue(gt(L)); /* use global table as environment */ return hvalue(gt(L)); /* use global table as environment */
else { else {
...@@ -87,13 +87,13 @@ static Table *ICACHE_FLASH_ATTR getcurrenv (lua_State *L) { ...@@ -87,13 +87,13 @@ static Table *ICACHE_FLASH_ATTR getcurrenv (lua_State *L) {
} }
void ICACHE_FLASH_ATTR luaA_pushobject (lua_State *L, const TValue *o) { void luaA_pushobject (lua_State *L, const TValue *o) {
setobj2s(L, L->top, o); setobj2s(L, L->top, o);
api_incr_top(L); api_incr_top(L);
} }
LUA_API int ICACHE_FLASH_ATTR lua_checkstack (lua_State *L, int size) { LUA_API int lua_checkstack (lua_State *L, int size) {
int res = 1; int res = 1;
lua_lock(L); lua_lock(L);
if (size > LUAI_MAXCSTACK || (L->top - L->base + size) > LUAI_MAXCSTACK) if (size > LUAI_MAXCSTACK || (L->top - L->base + size) > LUAI_MAXCSTACK)
...@@ -108,7 +108,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_checkstack (lua_State *L, int size) { ...@@ -108,7 +108,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_checkstack (lua_State *L, int size) {
} }
LUA_API void ICACHE_FLASH_ATTR lua_xmove (lua_State *from, lua_State *to, int n) { LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) {
int i; int i;
if (from == to) return; if (from == to) return;
lua_lock(to); lua_lock(to);
...@@ -123,12 +123,12 @@ LUA_API void ICACHE_FLASH_ATTR lua_xmove (lua_State *from, lua_State *to, int n) ...@@ -123,12 +123,12 @@ LUA_API void ICACHE_FLASH_ATTR lua_xmove (lua_State *from, lua_State *to, int n)
} }
LUA_API void ICACHE_FLASH_ATTR lua_setlevel (lua_State *from, lua_State *to) { LUA_API void lua_setlevel (lua_State *from, lua_State *to) {
to->nCcalls = from->nCcalls; to->nCcalls = from->nCcalls;
} }
LUA_API lua_CFunction ICACHE_FLASH_ATTR lua_atpanic (lua_State *L, lua_CFunction panicf) { LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) {
lua_CFunction old; lua_CFunction old;
lua_lock(L); lua_lock(L);
old = G(L)->panic; old = G(L)->panic;
...@@ -138,7 +138,7 @@ LUA_API lua_CFunction ICACHE_FLASH_ATTR lua_atpanic (lua_State *L, lua_CFunction ...@@ -138,7 +138,7 @@ LUA_API lua_CFunction ICACHE_FLASH_ATTR lua_atpanic (lua_State *L, lua_CFunction
} }
LUA_API lua_State *ICACHE_FLASH_ATTR lua_newthread (lua_State *L) { LUA_API lua_State *lua_newthread (lua_State *L) {
lua_State *L1; lua_State *L1;
lua_lock(L); lua_lock(L);
luaC_checkGC(L); luaC_checkGC(L);
...@@ -157,12 +157,12 @@ LUA_API lua_State *ICACHE_FLASH_ATTR lua_newthread (lua_State *L) { ...@@ -157,12 +157,12 @@ LUA_API lua_State *ICACHE_FLASH_ATTR lua_newthread (lua_State *L) {
*/ */
LUA_API int ICACHE_FLASH_ATTR lua_gettop (lua_State *L) { LUA_API int lua_gettop (lua_State *L) {
return cast_int(L->top - L->base); return cast_int(L->top - L->base);
} }
LUA_API void ICACHE_FLASH_ATTR lua_settop (lua_State *L, int idx) { LUA_API void lua_settop (lua_State *L, int idx) {
lua_lock(L); lua_lock(L);
if (idx >= 0) { if (idx >= 0) {
api_check(L, idx <= L->stack_last - L->base); api_check(L, idx <= L->stack_last - L->base);
...@@ -178,7 +178,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_settop (lua_State *L, int idx) { ...@@ -178,7 +178,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_settop (lua_State *L, int idx) {
} }
LUA_API void ICACHE_FLASH_ATTR lua_remove (lua_State *L, int idx) { LUA_API void lua_remove (lua_State *L, int idx) {
StkId p; StkId p;
lua_lock(L); lua_lock(L);
p = index2adr(L, idx); p = index2adr(L, idx);
...@@ -189,7 +189,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_remove (lua_State *L, int idx) { ...@@ -189,7 +189,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_remove (lua_State *L, int idx) {
} }
LUA_API void ICACHE_FLASH_ATTR lua_insert (lua_State *L, int idx) { LUA_API void lua_insert (lua_State *L, int idx) {
StkId p; StkId p;
StkId q; StkId q;
lua_lock(L); lua_lock(L);
...@@ -201,7 +201,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_insert (lua_State *L, int idx) { ...@@ -201,7 +201,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_insert (lua_State *L, int idx) {
} }
LUA_API void ICACHE_FLASH_ATTR lua_replace (lua_State *L, int idx) { LUA_API void lua_replace (lua_State *L, int idx) {
StkId o; StkId o;
lua_lock(L); lua_lock(L);
/* explicit test for incompatible code */ /* explicit test for incompatible code */
...@@ -230,7 +230,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_replace (lua_State *L, int idx) { ...@@ -230,7 +230,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_replace (lua_State *L, int idx) {
} }
LUA_API void ICACHE_FLASH_ATTR lua_pushvalue (lua_State *L, int idx) { LUA_API void lua_pushvalue (lua_State *L, int idx) {
lua_lock(L); lua_lock(L);
setobj2s(L, L->top, index2adr(L, idx)); setobj2s(L, L->top, index2adr(L, idx));
api_incr_top(L); api_incr_top(L);
...@@ -244,44 +244,44 @@ LUA_API void ICACHE_FLASH_ATTR lua_pushvalue (lua_State *L, int idx) { ...@@ -244,44 +244,44 @@ LUA_API void ICACHE_FLASH_ATTR lua_pushvalue (lua_State *L, int idx) {
*/ */
LUA_API int ICACHE_FLASH_ATTR lua_type (lua_State *L, int idx) { LUA_API int lua_type (lua_State *L, int idx) {
StkId o = index2adr(L, idx); StkId o = index2adr(L, idx);
return (o == luaO_nilobject) ? LUA_TNONE : ttype(o); return (o == luaO_nilobject) ? LUA_TNONE : ttype(o);
} }
LUA_API const char *ICACHE_FLASH_ATTR lua_typename (lua_State *L, int t) { LUA_API const char *lua_typename (lua_State *L, int t) {
UNUSED(L); UNUSED(L);
return (t == LUA_TNONE) ? "no value" : luaT_typenames[t]; return (t == LUA_TNONE) ? "no value" : luaT_typenames[t];
} }
LUA_API int ICACHE_FLASH_ATTR lua_iscfunction (lua_State *L, int idx) { LUA_API int lua_iscfunction (lua_State *L, int idx) {
StkId o = index2adr(L, idx); StkId o = index2adr(L, idx);
return iscfunction(o); return iscfunction(o);
} }
LUA_API int ICACHE_FLASH_ATTR lua_isnumber (lua_State *L, int idx) { LUA_API int lua_isnumber (lua_State *L, int idx) {
TValue n; TValue n;
const TValue *o = index2adr(L, idx); const TValue *o = index2adr(L, idx);
return tonumber(o, &n); return tonumber(o, &n);
} }
LUA_API int ICACHE_FLASH_ATTR lua_isstring (lua_State *L, int idx) { LUA_API int lua_isstring (lua_State *L, int idx) {
int t = lua_type(L, idx); int t = lua_type(L, idx);
return (t == LUA_TSTRING || t == LUA_TNUMBER); return (t == LUA_TSTRING || t == LUA_TNUMBER);
} }
LUA_API int ICACHE_FLASH_ATTR lua_isuserdata (lua_State *L, int idx) { LUA_API int lua_isuserdata (lua_State *L, int idx) {
const TValue *o = index2adr(L, idx); const TValue *o = index2adr(L, idx);
return (ttisuserdata(o) || ttislightuserdata(o)); return (ttisuserdata(o) || ttislightuserdata(o));
} }
LUA_API int ICACHE_FLASH_ATTR lua_rawequal (lua_State *L, int index1, int index2) { LUA_API int lua_rawequal (lua_State *L, int index1, int index2) {
StkId o1 = index2adr(L, index1); StkId o1 = index2adr(L, index1);
StkId o2 = index2adr(L, index2); StkId o2 = index2adr(L, index2);
return (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0 return (o1 == luaO_nilobject || o2 == luaO_nilobject) ? 0
...@@ -289,7 +289,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_rawequal (lua_State *L, int index1, int index2 ...@@ -289,7 +289,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_rawequal (lua_State *L, int index1, int index2
} }
LUA_API int ICACHE_FLASH_ATTR lua_equal (lua_State *L, int index1, int index2) { LUA_API int lua_equal (lua_State *L, int index1, int index2) {
StkId o1, o2; StkId o1, o2;
int i; int i;
lua_lock(L); /* may call tag method */ lua_lock(L); /* may call tag method */
...@@ -301,7 +301,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_equal (lua_State *L, int index1, int index2) { ...@@ -301,7 +301,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_equal (lua_State *L, int index1, int index2) {
} }
LUA_API int ICACHE_FLASH_ATTR lua_lessthan (lua_State *L, int index1, int index2) { LUA_API int lua_lessthan (lua_State *L, int index1, int index2) {
StkId o1, o2; StkId o1, o2;
int i; int i;
lua_lock(L); /* may call tag method */ lua_lock(L); /* may call tag method */
...@@ -315,7 +315,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_lessthan (lua_State *L, int index1, int index2 ...@@ -315,7 +315,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_lessthan (lua_State *L, int index1, int index2
LUA_API lua_Number ICACHE_FLASH_ATTR lua_tonumber (lua_State *L, int idx) { LUA_API lua_Number lua_tonumber (lua_State *L, int idx) {
TValue n; TValue n;
const TValue *o = index2adr(L, idx); const TValue *o = index2adr(L, idx);
if (tonumber(o, &n)) if (tonumber(o, &n))
...@@ -325,7 +325,7 @@ LUA_API lua_Number ICACHE_FLASH_ATTR lua_tonumber (lua_State *L, int idx) { ...@@ -325,7 +325,7 @@ LUA_API lua_Number ICACHE_FLASH_ATTR lua_tonumber (lua_State *L, int idx) {
} }
LUA_API lua_Integer ICACHE_FLASH_ATTR lua_tointeger (lua_State *L, int idx) { LUA_API lua_Integer lua_tointeger (lua_State *L, int idx) {
TValue n; TValue n;
const TValue *o = index2adr(L, idx); const TValue *o = index2adr(L, idx);
if (tonumber(o, &n)) { if (tonumber(o, &n)) {
...@@ -339,13 +339,13 @@ LUA_API lua_Integer ICACHE_FLASH_ATTR lua_tointeger (lua_State *L, int idx) { ...@@ -339,13 +339,13 @@ LUA_API lua_Integer ICACHE_FLASH_ATTR lua_tointeger (lua_State *L, int idx) {
} }
LUA_API int ICACHE_FLASH_ATTR lua_toboolean (lua_State *L, int idx) { LUA_API int lua_toboolean (lua_State *L, int idx) {
const TValue *o = index2adr(L, idx); const TValue *o = index2adr(L, idx);
return !l_isfalse(o); return !l_isfalse(o);
} }
LUA_API const char *ICACHE_FLASH_ATTR lua_tolstring (lua_State *L, int idx, size_t *len) { LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) {
StkId o = index2adr(L, idx); StkId o = index2adr(L, idx);
if (!ttisstring(o)) { if (!ttisstring(o)) {
lua_lock(L); /* `luaV_tostring' may create a new string */ lua_lock(L); /* `luaV_tostring' may create a new string */
...@@ -363,7 +363,7 @@ LUA_API const char *ICACHE_FLASH_ATTR lua_tolstring (lua_State *L, int idx, size ...@@ -363,7 +363,7 @@ LUA_API const char *ICACHE_FLASH_ATTR lua_tolstring (lua_State *L, int idx, size
} }
LUA_API size_t ICACHE_FLASH_ATTR lua_objlen (lua_State *L, int idx) { LUA_API size_t lua_objlen (lua_State *L, int idx) {
StkId o = index2adr(L, idx); StkId o = index2adr(L, idx);
switch (ttype(o)) { switch (ttype(o)) {
case LUA_TSTRING: return tsvalue(o)->len; case LUA_TSTRING: return tsvalue(o)->len;
...@@ -382,13 +382,13 @@ LUA_API size_t ICACHE_FLASH_ATTR lua_objlen (lua_State *L, int idx) { ...@@ -382,13 +382,13 @@ LUA_API size_t ICACHE_FLASH_ATTR lua_objlen (lua_State *L, int idx) {
} }
LUA_API lua_CFunction ICACHE_FLASH_ATTR lua_tocfunction (lua_State *L, int idx) { LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) {
StkId o = index2adr(L, idx); StkId o = index2adr(L, idx);
return (!iscfunction(o)) ? NULL : clvalue(o)->c.f; return (!iscfunction(o)) ? NULL : clvalue(o)->c.f;
} }
LUA_API void *ICACHE_FLASH_ATTR lua_touserdata (lua_State *L, int idx) { LUA_API void *lua_touserdata (lua_State *L, int idx) {
StkId o = index2adr(L, idx); StkId o = index2adr(L, idx);
switch (ttype(o)) { switch (ttype(o)) {
case LUA_TUSERDATA: return (rawuvalue(o) + 1); case LUA_TUSERDATA: return (rawuvalue(o) + 1);
...@@ -398,13 +398,13 @@ LUA_API void *ICACHE_FLASH_ATTR lua_touserdata (lua_State *L, int idx) { ...@@ -398,13 +398,13 @@ LUA_API void *ICACHE_FLASH_ATTR lua_touserdata (lua_State *L, int idx) {
} }
LUA_API lua_State *ICACHE_FLASH_ATTR lua_tothread (lua_State *L, int idx) { LUA_API lua_State *lua_tothread (lua_State *L, int idx) {
StkId o = index2adr(L, idx); StkId o = index2adr(L, idx);
return (!ttisthread(o)) ? NULL : thvalue(o); return (!ttisthread(o)) ? NULL : thvalue(o);
} }
LUA_API const void *ICACHE_FLASH_ATTR lua_topointer (lua_State *L, int idx) { LUA_API const void *lua_topointer (lua_State *L, int idx) {
StkId o = index2adr(L, idx); StkId o = index2adr(L, idx);
switch (ttype(o)) { switch (ttype(o)) {
case LUA_TTABLE: return hvalue(o); case LUA_TTABLE: return hvalue(o);
...@@ -427,7 +427,7 @@ LUA_API const void *ICACHE_FLASH_ATTR lua_topointer (lua_State *L, int idx) { ...@@ -427,7 +427,7 @@ LUA_API const void *ICACHE_FLASH_ATTR lua_topointer (lua_State *L, int idx) {
*/ */
LUA_API void ICACHE_FLASH_ATTR lua_pushnil (lua_State *L) { LUA_API void lua_pushnil (lua_State *L) {
lua_lock(L); lua_lock(L);
setnilvalue(L->top); setnilvalue(L->top);
api_incr_top(L); api_incr_top(L);
...@@ -435,7 +435,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_pushnil (lua_State *L) { ...@@ -435,7 +435,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_pushnil (lua_State *L) {
} }
LUA_API void ICACHE_FLASH_ATTR lua_pushnumber (lua_State *L, lua_Number n) { LUA_API void lua_pushnumber (lua_State *L, lua_Number n) {
lua_lock(L); lua_lock(L);
setnvalue(L->top, n); setnvalue(L->top, n);
api_incr_top(L); api_incr_top(L);
...@@ -443,7 +443,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_pushnumber (lua_State *L, lua_Number n) { ...@@ -443,7 +443,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_pushnumber (lua_State *L, lua_Number n) {
} }
LUA_API void ICACHE_FLASH_ATTR lua_pushinteger (lua_State *L, lua_Integer n) { LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) {
lua_lock(L); lua_lock(L);
setnvalue(L->top, cast_num(n)); setnvalue(L->top, cast_num(n));
api_incr_top(L); api_incr_top(L);
...@@ -451,7 +451,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_pushinteger (lua_State *L, lua_Integer n) { ...@@ -451,7 +451,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_pushinteger (lua_State *L, lua_Integer n) {
} }
LUA_API void ICACHE_FLASH_ATTR lua_pushlstring (lua_State *L, const char *s, size_t len) { LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) {
lua_lock(L); lua_lock(L);
luaC_checkGC(L); luaC_checkGC(L);
setsvalue2s(L, L->top, luaS_newlstr(L, s, len)); setsvalue2s(L, L->top, luaS_newlstr(L, s, len));
...@@ -460,7 +460,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_pushlstring (lua_State *L, const char *s, siz ...@@ -460,7 +460,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_pushlstring (lua_State *L, const char *s, siz
} }
LUA_API void ICACHE_FLASH_ATTR lua_pushrolstring (lua_State *L, const char *s, size_t len) { LUA_API void lua_pushrolstring (lua_State *L, const char *s, size_t len) {
lua_lock(L); lua_lock(L);
luaC_checkGC(L); luaC_checkGC(L);
setsvalue2s(L, L->top, luaS_newrolstr(L, s, len)); setsvalue2s(L, L->top, luaS_newrolstr(L, s, len));
...@@ -469,7 +469,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_pushrolstring (lua_State *L, const char *s, s ...@@ -469,7 +469,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_pushrolstring (lua_State *L, const char *s, s
} }
LUA_API void ICACHE_FLASH_ATTR lua_pushstring (lua_State *L, const char *s) { LUA_API void lua_pushstring (lua_State *L, const char *s) {
if (s == NULL) if (s == NULL)
lua_pushnil(L); lua_pushnil(L);
else else
...@@ -477,7 +477,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_pushstring (lua_State *L, const char *s) { ...@@ -477,7 +477,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_pushstring (lua_State *L, const char *s) {
} }
LUA_API const char *ICACHE_FLASH_ATTR lua_pushvfstring (lua_State *L, const char *fmt, LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt,
va_list argp) { va_list argp) {
const char *ret; const char *ret;
lua_lock(L); lua_lock(L);
...@@ -488,7 +488,7 @@ LUA_API const char *ICACHE_FLASH_ATTR lua_pushvfstring (lua_State *L, const char ...@@ -488,7 +488,7 @@ LUA_API const char *ICACHE_FLASH_ATTR lua_pushvfstring (lua_State *L, const char
} }
LUA_API const char *ICACHE_FLASH_ATTR lua_pushfstring (lua_State *L, const char *fmt, ...) { LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) {
const char *ret; const char *ret;
va_list argp; va_list argp;
lua_lock(L); lua_lock(L);
...@@ -501,7 +501,7 @@ LUA_API const char *ICACHE_FLASH_ATTR lua_pushfstring (lua_State *L, const char ...@@ -501,7 +501,7 @@ LUA_API const char *ICACHE_FLASH_ATTR lua_pushfstring (lua_State *L, const char
} }
LUA_API void ICACHE_FLASH_ATTR lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
Closure *cl; Closure *cl;
lua_lock(L); lua_lock(L);
luaC_checkGC(L); luaC_checkGC(L);
...@@ -518,7 +518,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_pushcclosure (lua_State *L, lua_CFunction fn, ...@@ -518,7 +518,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_pushcclosure (lua_State *L, lua_CFunction fn,
} }
LUA_API void ICACHE_FLASH_ATTR lua_pushboolean (lua_State *L, int b) { LUA_API void lua_pushboolean (lua_State *L, int b) {
lua_lock(L); lua_lock(L);
setbvalue(L->top, (b != 0)); /* ensure that true is 1 */ setbvalue(L->top, (b != 0)); /* ensure that true is 1 */
api_incr_top(L); api_incr_top(L);
...@@ -526,21 +526,21 @@ LUA_API void ICACHE_FLASH_ATTR lua_pushboolean (lua_State *L, int b) { ...@@ -526,21 +526,21 @@ LUA_API void ICACHE_FLASH_ATTR lua_pushboolean (lua_State *L, int b) {
} }
LUA_API void ICACHE_FLASH_ATTR lua_pushlightuserdata (lua_State *L, void *p) { LUA_API void lua_pushlightuserdata (lua_State *L, void *p) {
lua_lock(L); lua_lock(L);
setpvalue(L->top, p); setpvalue(L->top, p);
api_incr_top(L); api_incr_top(L);
lua_unlock(L); lua_unlock(L);
} }
LUA_API void ICACHE_FLASH_ATTR lua_pushrotable (lua_State *L, void *p) { LUA_API void lua_pushrotable (lua_State *L, void *p) {
lua_lock(L); lua_lock(L);
setrvalue(L->top, p); setrvalue(L->top, p);
api_incr_top(L); api_incr_top(L);
lua_unlock(L); lua_unlock(L);
} }
LUA_API void ICACHE_FLASH_ATTR lua_pushlightfunction(lua_State *L, void *p) { LUA_API void lua_pushlightfunction(lua_State *L, void *p) {
lua_lock(L); lua_lock(L);
setfvalue(L->top, p); setfvalue(L->top, p);
api_incr_top(L); api_incr_top(L);
...@@ -548,7 +548,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_pushlightfunction(lua_State *L, void *p) { ...@@ -548,7 +548,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_pushlightfunction(lua_State *L, void *p) {
} }
LUA_API int ICACHE_FLASH_ATTR lua_pushthread (lua_State *L) { LUA_API int lua_pushthread (lua_State *L) {
lua_lock(L); lua_lock(L);
setthvalue(L, L->top, L); setthvalue(L, L->top, L);
api_incr_top(L); api_incr_top(L);
...@@ -563,7 +563,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_pushthread (lua_State *L) { ...@@ -563,7 +563,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_pushthread (lua_State *L) {
*/ */
LUA_API void ICACHE_FLASH_ATTR lua_gettable (lua_State *L, int idx) { LUA_API void lua_gettable (lua_State *L, int idx) {
StkId t; StkId t;
lua_lock(L); lua_lock(L);
t = index2adr(L, idx); t = index2adr(L, idx);
...@@ -573,7 +573,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_gettable (lua_State *L, int idx) { ...@@ -573,7 +573,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_gettable (lua_State *L, int idx) {
} }
LUA_API void ICACHE_FLASH_ATTR lua_getfield (lua_State *L, int idx, const char *k) { LUA_API void lua_getfield (lua_State *L, int idx, const char *k) {
StkId t; StkId t;
TValue key; TValue key;
lua_lock(L); lua_lock(L);
...@@ -588,7 +588,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_getfield (lua_State *L, int idx, const char * ...@@ -588,7 +588,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_getfield (lua_State *L, int idx, const char *
} }
LUA_API void ICACHE_FLASH_ATTR lua_rawget (lua_State *L, int idx) { LUA_API void lua_rawget (lua_State *L, int idx) {
StkId t; StkId t;
const TValue *res; const TValue *res;
lua_lock(L); lua_lock(L);
...@@ -600,7 +600,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_rawget (lua_State *L, int idx) { ...@@ -600,7 +600,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_rawget (lua_State *L, int idx) {
} }
LUA_API void ICACHE_FLASH_ATTR lua_rawgeti (lua_State *L, int idx, int n) { LUA_API void lua_rawgeti (lua_State *L, int idx, int n) {
StkId o; StkId o;
lua_lock(L); lua_lock(L);
o = index2adr(L, idx); o = index2adr(L, idx);
...@@ -611,7 +611,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_rawgeti (lua_State *L, int idx, int n) { ...@@ -611,7 +611,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_rawgeti (lua_State *L, int idx, int n) {
} }
LUA_API void ICACHE_FLASH_ATTR lua_createtable (lua_State *L, int narray, int nrec) { LUA_API void lua_createtable (lua_State *L, int narray, int nrec) {
lua_lock(L); lua_lock(L);
luaC_checkGC(L); luaC_checkGC(L);
sethvalue(L, L->top, luaH_new(L, narray, nrec)); sethvalue(L, L->top, luaH_new(L, narray, nrec));
...@@ -620,7 +620,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_createtable (lua_State *L, int narray, int nr ...@@ -620,7 +620,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_createtable (lua_State *L, int narray, int nr
} }
LUA_API int ICACHE_FLASH_ATTR lua_getmetatable (lua_State *L, int objindex) { LUA_API int lua_getmetatable (lua_State *L, int objindex) {
const TValue *obj; const TValue *obj;
Table *mt = NULL; Table *mt = NULL;
int res; int res;
...@@ -655,7 +655,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_getmetatable (lua_State *L, int objindex) { ...@@ -655,7 +655,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_getmetatable (lua_State *L, int objindex) {
} }
LUA_API void ICACHE_FLASH_ATTR lua_getfenv (lua_State *L, int idx) { LUA_API void lua_getfenv (lua_State *L, int idx) {
StkId o; StkId o;
lua_lock(L); lua_lock(L);
o = index2adr(L, idx); o = index2adr(L, idx);
...@@ -684,7 +684,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_getfenv (lua_State *L, int idx) { ...@@ -684,7 +684,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_getfenv (lua_State *L, int idx) {
*/ */
LUA_API void ICACHE_FLASH_ATTR lua_settable (lua_State *L, int idx) { LUA_API void lua_settable (lua_State *L, int idx) {
StkId t; StkId t;
lua_lock(L); lua_lock(L);
api_checknelems(L, 2); api_checknelems(L, 2);
...@@ -696,7 +696,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_settable (lua_State *L, int idx) { ...@@ -696,7 +696,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_settable (lua_State *L, int idx) {
} }
LUA_API void ICACHE_FLASH_ATTR lua_setfield (lua_State *L, int idx, const char *k) { LUA_API void lua_setfield (lua_State *L, int idx, const char *k) {
StkId t; StkId t;
lua_lock(L); lua_lock(L);
api_checknelems(L, 1); api_checknelems(L, 1);
...@@ -710,7 +710,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_setfield (lua_State *L, int idx, const char * ...@@ -710,7 +710,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_setfield (lua_State *L, int idx, const char *
} }
LUA_API void ICACHE_FLASH_ATTR lua_rawset (lua_State *L, int idx) { LUA_API void lua_rawset (lua_State *L, int idx) {
StkId t; StkId t;
lua_lock(L); lua_lock(L);
api_checknelems(L, 2); api_checknelems(L, 2);
...@@ -725,7 +725,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_rawset (lua_State *L, int idx) { ...@@ -725,7 +725,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_rawset (lua_State *L, int idx) {
} }
LUA_API void ICACHE_FLASH_ATTR lua_rawseti (lua_State *L, int idx, int n) { LUA_API void lua_rawseti (lua_State *L, int idx, int n) {
StkId o; StkId o;
lua_lock(L); lua_lock(L);
api_checknelems(L, 1); api_checknelems(L, 1);
...@@ -740,7 +740,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_rawseti (lua_State *L, int idx, int n) { ...@@ -740,7 +740,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_rawseti (lua_State *L, int idx, int n) {
} }
LUA_API int ICACHE_FLASH_ATTR lua_setmetatable (lua_State *L, int objindex) { LUA_API int lua_setmetatable (lua_State *L, int objindex) {
TValue *obj; TValue *obj;
Table *mt; Table *mt;
int isrometa = 0; int isrometa = 0;
...@@ -783,7 +783,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_setmetatable (lua_State *L, int objindex) { ...@@ -783,7 +783,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_setmetatable (lua_State *L, int objindex) {
} }
LUA_API int ICACHE_FLASH_ATTR lua_setfenv (lua_State *L, int idx) { LUA_API int lua_setfenv (lua_State *L, int idx) {
StkId o; StkId o;
int res = 1; int res = 1;
lua_lock(L); lua_lock(L);
...@@ -825,7 +825,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_setfenv (lua_State *L, int idx) { ...@@ -825,7 +825,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_setfenv (lua_State *L, int idx) {
api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na))) api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)))
LUA_API void ICACHE_FLASH_ATTR lua_call (lua_State *L, int nargs, int nresults) { LUA_API void lua_call (lua_State *L, int nargs, int nresults) {
StkId func; StkId func;
lua_lock(L); lua_lock(L);
api_checknelems(L, nargs+1); api_checknelems(L, nargs+1);
...@@ -847,14 +847,14 @@ struct CallS { /* data to `f_call' */ ...@@ -847,14 +847,14 @@ struct CallS { /* data to `f_call' */
}; };
static void ICACHE_FLASH_ATTR f_call (lua_State *L, void *ud) { static void f_call (lua_State *L, void *ud) {
struct CallS *c = cast(struct CallS *, ud); struct CallS *c = cast(struct CallS *, ud);
luaD_call(L, c->func, c->nresults); luaD_call(L, c->func, c->nresults);
} }
LUA_API int ICACHE_FLASH_ATTR lua_pcall (lua_State *L, int nargs, int nresults, int errfunc) { LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc) {
struct CallS c; struct CallS c;
int status; int status;
ptrdiff_t func; ptrdiff_t func;
...@@ -886,7 +886,7 @@ struct CCallS { /* data to `f_Ccall' */ ...@@ -886,7 +886,7 @@ struct CCallS { /* data to `f_Ccall' */
}; };
static void ICACHE_FLASH_ATTR f_Ccall (lua_State *L, void *ud) { static void f_Ccall (lua_State *L, void *ud) {
struct CCallS *c = cast(struct CCallS *, ud); struct CCallS *c = cast(struct CCallS *, ud);
Closure *cl; Closure *cl;
cl = luaF_newCclosure(L, 0, getcurrenv(L)); cl = luaF_newCclosure(L, 0, getcurrenv(L));
...@@ -899,7 +899,7 @@ static void ICACHE_FLASH_ATTR f_Ccall (lua_State *L, void *ud) { ...@@ -899,7 +899,7 @@ static void ICACHE_FLASH_ATTR f_Ccall (lua_State *L, void *ud) {
} }
LUA_API int ICACHE_FLASH_ATTR lua_cpcall (lua_State *L, lua_CFunction func, void *ud) { LUA_API int lua_cpcall (lua_State *L, lua_CFunction func, void *ud) {
struct CCallS c; struct CCallS c;
int status; int status;
lua_lock(L); lua_lock(L);
...@@ -911,7 +911,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_cpcall (lua_State *L, lua_CFunction func, void ...@@ -911,7 +911,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_cpcall (lua_State *L, lua_CFunction func, void
} }
LUA_API int ICACHE_FLASH_ATTR lua_load (lua_State *L, lua_Reader reader, void *data, LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data,
const char *chunkname) { const char *chunkname) {
ZIO z; ZIO z;
int status; int status;
...@@ -924,7 +924,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_load (lua_State *L, lua_Reader reader, void *d ...@@ -924,7 +924,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_load (lua_State *L, lua_Reader reader, void *d
} }
LUA_API int ICACHE_FLASH_ATTR lua_dump (lua_State *L, lua_Writer writer, void *data) { LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) {
int status; int status;
TValue *o; TValue *o;
lua_lock(L); lua_lock(L);
...@@ -939,7 +939,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_dump (lua_State *L, lua_Writer writer, void *d ...@@ -939,7 +939,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_dump (lua_State *L, lua_Writer writer, void *d
} }
LUA_API int ICACHE_FLASH_ATTR lua_status (lua_State *L) { LUA_API int lua_status (lua_State *L) {
return L->status; return L->status;
} }
...@@ -948,7 +948,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_status (lua_State *L) { ...@@ -948,7 +948,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_status (lua_State *L) {
** Garbage-collection function ** Garbage-collection function
*/ */
LUA_API int ICACHE_FLASH_ATTR lua_gc (lua_State *L, int what, int data) { LUA_API int lua_gc (lua_State *L, int what, int data) {
int res = 0; int res = 0;
global_State *g; global_State *g;
lua_lock(L); lua_lock(L);
...@@ -1035,7 +1035,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_gc (lua_State *L, int what, int data) { ...@@ -1035,7 +1035,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_gc (lua_State *L, int what, int data) {
*/ */
LUA_API int ICACHE_FLASH_ATTR lua_error (lua_State *L) { LUA_API int lua_error (lua_State *L) {
lua_lock(L); lua_lock(L);
api_checknelems(L, 1); api_checknelems(L, 1);
luaG_errormsg(L); luaG_errormsg(L);
...@@ -1044,7 +1044,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_error (lua_State *L) { ...@@ -1044,7 +1044,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_error (lua_State *L) {
} }
LUA_API int ICACHE_FLASH_ATTR lua_next (lua_State *L, int idx) { LUA_API int lua_next (lua_State *L, int idx) {
StkId t; StkId t;
int more; int more;
lua_lock(L); lua_lock(L);
...@@ -1061,7 +1061,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_next (lua_State *L, int idx) { ...@@ -1061,7 +1061,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_next (lua_State *L, int idx) {
} }
LUA_API void ICACHE_FLASH_ATTR lua_concat (lua_State *L, int n) { LUA_API void lua_concat (lua_State *L, int n) {
lua_lock(L); lua_lock(L);
api_checknelems(L, n); api_checknelems(L, n);
if (n >= 2) { if (n >= 2) {
...@@ -1078,7 +1078,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_concat (lua_State *L, int n) { ...@@ -1078,7 +1078,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_concat (lua_State *L, int n) {
} }
LUA_API lua_Alloc ICACHE_FLASH_ATTR lua_getallocf (lua_State *L, void **ud) { LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud) {
lua_Alloc f; lua_Alloc f;
lua_lock(L); lua_lock(L);
if (ud) *ud = G(L)->ud; if (ud) *ud = G(L)->ud;
...@@ -1088,7 +1088,7 @@ LUA_API lua_Alloc ICACHE_FLASH_ATTR lua_getallocf (lua_State *L, void **ud) { ...@@ -1088,7 +1088,7 @@ LUA_API lua_Alloc ICACHE_FLASH_ATTR lua_getallocf (lua_State *L, void **ud) {
} }
LUA_API void ICACHE_FLASH_ATTR lua_setallocf (lua_State *L, lua_Alloc f, void *ud) { LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud) {
lua_lock(L); lua_lock(L);
G(L)->ud = ud; G(L)->ud = ud;
G(L)->frealloc = f; G(L)->frealloc = f;
...@@ -1096,7 +1096,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_setallocf (lua_State *L, lua_Alloc f, void *u ...@@ -1096,7 +1096,7 @@ LUA_API void ICACHE_FLASH_ATTR lua_setallocf (lua_State *L, lua_Alloc f, void *u
} }
LUA_API void *ICACHE_FLASH_ATTR lua_newuserdata (lua_State *L, size_t size) { LUA_API void *lua_newuserdata (lua_State *L, size_t size) {
Udata *u; Udata *u;
lua_lock(L); lua_lock(L);
luaC_checkGC(L); luaC_checkGC(L);
...@@ -1110,7 +1110,7 @@ LUA_API void *ICACHE_FLASH_ATTR lua_newuserdata (lua_State *L, size_t size) { ...@@ -1110,7 +1110,7 @@ LUA_API void *ICACHE_FLASH_ATTR lua_newuserdata (lua_State *L, size_t size) {
static const char *ICACHE_FLASH_ATTR aux_upvalue (StkId fi, int n, TValue **val) { static const char *aux_upvalue (StkId fi, int n, TValue **val) {
Closure *f; Closure *f;
if (!ttisfunction(fi)) return NULL; if (!ttisfunction(fi)) return NULL;
f = clvalue(fi); f = clvalue(fi);
...@@ -1128,7 +1128,7 @@ static const char *ICACHE_FLASH_ATTR aux_upvalue (StkId fi, int n, TValue **val) ...@@ -1128,7 +1128,7 @@ static const char *ICACHE_FLASH_ATTR aux_upvalue (StkId fi, int n, TValue **val)
} }
LUA_API const char *ICACHE_FLASH_ATTR lua_getupvalue (lua_State *L, int funcindex, int n) { LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) {
const char *name; const char *name;
TValue *val; TValue *val;
lua_lock(L); lua_lock(L);
...@@ -1142,7 +1142,7 @@ LUA_API const char *ICACHE_FLASH_ATTR lua_getupvalue (lua_State *L, int funcinde ...@@ -1142,7 +1142,7 @@ LUA_API const char *ICACHE_FLASH_ATTR lua_getupvalue (lua_State *L, int funcinde
} }
LUA_API const char *ICACHE_FLASH_ATTR lua_setupvalue (lua_State *L, int funcindex, int n) { LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) {
const char *name; const char *name;
TValue *val; TValue *val;
StkId fi; StkId fi;
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
*/ */
LUALIB_API int ICACHE_FLASH_ATTR luaL_argerror (lua_State *L, int narg, const char *extramsg) { LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) {
lua_Debug ar; lua_Debug ar;
if (!lua_getstack(L, 0, &ar)) /* no stack frame? */ if (!lua_getstack(L, 0, &ar)) /* no stack frame? */
return luaL_error(L, "bad argument #%d (%s)", narg, extramsg); return luaL_error(L, "bad argument #%d (%s)", narg, extramsg);
...@@ -67,19 +67,19 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_argerror (lua_State *L, int narg, const ch ...@@ -67,19 +67,19 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_argerror (lua_State *L, int narg, const ch
} }
LUALIB_API int ICACHE_FLASH_ATTR luaL_typerror (lua_State *L, int narg, const char *tname) { LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) {
const char *msg = lua_pushfstring(L, "%s expected, got %s", const char *msg = lua_pushfstring(L, "%s expected, got %s",
tname, luaL_typename(L, narg)); tname, luaL_typename(L, narg));
return luaL_argerror(L, narg, msg); return luaL_argerror(L, narg, msg);
} }
static void ICACHE_FLASH_ATTR tag_error (lua_State *L, int narg, int tag) { static void tag_error (lua_State *L, int narg, int tag) {
luaL_typerror(L, narg, lua_typename(L, tag)); luaL_typerror(L, narg, lua_typename(L, tag));
} }
LUALIB_API void ICACHE_FLASH_ATTR luaL_where (lua_State *L, int level) { LUALIB_API void luaL_where (lua_State *L, int level) {
lua_Debug ar; lua_Debug ar;
if (lua_getstack(L, level, &ar)) { /* check function at level */ if (lua_getstack(L, level, &ar)) { /* check function at level */
lua_getinfo(L, "Sl", &ar); /* get info about it */ lua_getinfo(L, "Sl", &ar); /* get info about it */
...@@ -92,7 +92,7 @@ LUALIB_API void ICACHE_FLASH_ATTR luaL_where (lua_State *L, int level) { ...@@ -92,7 +92,7 @@ LUALIB_API void ICACHE_FLASH_ATTR luaL_where (lua_State *L, int level) {
} }
LUALIB_API int ICACHE_FLASH_ATTR luaL_error (lua_State *L, const char *fmt, ...) { LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) {
va_list argp; va_list argp;
va_start(argp, fmt); va_start(argp, fmt);
luaL_where(L, 1); luaL_where(L, 1);
...@@ -105,7 +105,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_error (lua_State *L, const char *fmt, ...) ...@@ -105,7 +105,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_error (lua_State *L, const char *fmt, ...)
/* }====================================================== */ /* }====================================================== */
LUALIB_API int ICACHE_FLASH_ATTR luaL_checkoption (lua_State *L, int narg, const char *def, LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def,
const char *const lst[]) { const char *const lst[]) {
const char *name = (def) ? luaL_optstring(L, narg, def) : const char *name = (def) ? luaL_optstring(L, narg, def) :
luaL_checkstring(L, narg); luaL_checkstring(L, narg);
...@@ -118,7 +118,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_checkoption (lua_State *L, int narg, const ...@@ -118,7 +118,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_checkoption (lua_State *L, int narg, const
} }
LUALIB_API int ICACHE_FLASH_ATTR luaL_newmetatable (lua_State *L, const char *tname) { LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) {
lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */ lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */
if (!lua_isnil(L, -1)) /* name already in use? */ if (!lua_isnil(L, -1)) /* name already in use? */
return 0; /* leave previous value on top, but return 0 */ return 0; /* leave previous value on top, but return 0 */
...@@ -129,7 +129,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_newmetatable (lua_State *L, const char *tn ...@@ -129,7 +129,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_newmetatable (lua_State *L, const char *tn
return 1; return 1;
} }
LUALIB_API int ICACHE_FLASH_ATTR luaL_rometatable (lua_State *L, const char* tname, void *p) { LUALIB_API int luaL_rometatable (lua_State *L, const char* tname, void *p) {
lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */ lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */
if (!lua_isnil(L, -1)) /* name already in use? */ if (!lua_isnil(L, -1)) /* name already in use? */
return 0; /* leave previous value on top, but return 0 */ return 0; /* leave previous value on top, but return 0 */
...@@ -140,7 +140,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_rometatable (lua_State *L, const char* tna ...@@ -140,7 +140,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_rometatable (lua_State *L, const char* tna
return 1; return 1;
} }
LUALIB_API void *ICACHE_FLASH_ATTR luaL_checkudata (lua_State *L, int ud, const char *tname) { LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) {
void *p = lua_touserdata(L, ud); void *p = lua_touserdata(L, ud);
if (p != NULL) { /* value is a userdata? */ if (p != NULL) { /* value is a userdata? */
if (lua_getmetatable(L, ud)) { /* does it have a metatable? */ if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
...@@ -156,18 +156,18 @@ LUALIB_API void *ICACHE_FLASH_ATTR luaL_checkudata (lua_State *L, int ud, const ...@@ -156,18 +156,18 @@ LUALIB_API void *ICACHE_FLASH_ATTR luaL_checkudata (lua_State *L, int ud, const
} }
LUALIB_API void ICACHE_FLASH_ATTR luaL_checkstack (lua_State *L, int space, const char *mes) { LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) {
if (!lua_checkstack(L, space)) if (!lua_checkstack(L, space))
luaL_error(L, "stack overflow (%s)", mes); luaL_error(L, "stack overflow (%s)", mes);
} }
LUALIB_API void ICACHE_FLASH_ATTR luaL_checktype (lua_State *L, int narg, int t) { LUALIB_API void luaL_checktype (lua_State *L, int narg, int t) {
if (lua_type(L, narg) != t) if (lua_type(L, narg) != t)
tag_error(L, narg, t); tag_error(L, narg, t);
} }
LUALIB_API void ICACHE_FLASH_ATTR luaL_checkanyfunction (lua_State *L, int narg) { LUALIB_API void luaL_checkanyfunction (lua_State *L, int narg) {
if (lua_type(L, narg) != LUA_TFUNCTION && lua_type(L, narg) != LUA_TLIGHTFUNCTION) { if (lua_type(L, narg) != LUA_TFUNCTION && lua_type(L, narg) != LUA_TLIGHTFUNCTION) {
const char *msg = lua_pushfstring(L, "function or lightfunction expected, got %s", const char *msg = lua_pushfstring(L, "function or lightfunction expected, got %s",
luaL_typename(L, narg)); luaL_typename(L, narg));
...@@ -175,7 +175,7 @@ LUALIB_API void ICACHE_FLASH_ATTR luaL_checkanyfunction (lua_State *L, int narg) ...@@ -175,7 +175,7 @@ LUALIB_API void ICACHE_FLASH_ATTR luaL_checkanyfunction (lua_State *L, int narg)
} }
} }
LUALIB_API void ICACHE_FLASH_ATTR luaL_checkanytable (lua_State *L, int narg) { LUALIB_API void luaL_checkanytable (lua_State *L, int narg) {
if (lua_type(L, narg) != LUA_TTABLE && lua_type(L, narg) != LUA_TROTABLE) { if (lua_type(L, narg) != LUA_TTABLE && lua_type(L, narg) != LUA_TROTABLE) {
const char *msg = lua_pushfstring(L, "table or rotable expected, got %s", const char *msg = lua_pushfstring(L, "table or rotable expected, got %s",
luaL_typename(L, narg)); luaL_typename(L, narg));
...@@ -184,20 +184,20 @@ LUALIB_API void ICACHE_FLASH_ATTR luaL_checkanytable (lua_State *L, int narg) { ...@@ -184,20 +184,20 @@ LUALIB_API void ICACHE_FLASH_ATTR luaL_checkanytable (lua_State *L, int narg) {
} }
LUALIB_API void ICACHE_FLASH_ATTR luaL_checkany (lua_State *L, int narg) { LUALIB_API void luaL_checkany (lua_State *L, int narg) {
if (lua_type(L, narg) == LUA_TNONE) if (lua_type(L, narg) == LUA_TNONE)
luaL_argerror(L, narg, "value expected"); luaL_argerror(L, narg, "value expected");
} }
LUALIB_API const char *ICACHE_FLASH_ATTR luaL_checklstring (lua_State *L, int narg, size_t *len) { LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t *len) {
const char *s = lua_tolstring(L, narg, len); const char *s = lua_tolstring(L, narg, len);
if (!s) tag_error(L, narg, LUA_TSTRING); if (!s) tag_error(L, narg, LUA_TSTRING);
return s; return s;
} }
LUALIB_API const char *ICACHE_FLASH_ATTR luaL_optlstring (lua_State *L, int narg, LUALIB_API const char *luaL_optlstring (lua_State *L, int narg,
const char *def, size_t *len) { const char *def, size_t *len) {
if (lua_isnoneornil(L, narg)) { if (lua_isnoneornil(L, narg)) {
if (len) if (len)
...@@ -208,7 +208,7 @@ LUALIB_API const char *ICACHE_FLASH_ATTR luaL_optlstring (lua_State *L, int narg ...@@ -208,7 +208,7 @@ LUALIB_API const char *ICACHE_FLASH_ATTR luaL_optlstring (lua_State *L, int narg
} }
LUALIB_API lua_Number ICACHE_FLASH_ATTR luaL_checknumber (lua_State *L, int narg) { LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) {
lua_Number d = lua_tonumber(L, narg); lua_Number d = lua_tonumber(L, narg);
if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */
tag_error(L, narg, LUA_TNUMBER); tag_error(L, narg, LUA_TNUMBER);
...@@ -216,12 +216,12 @@ LUALIB_API lua_Number ICACHE_FLASH_ATTR luaL_checknumber (lua_State *L, int narg ...@@ -216,12 +216,12 @@ LUALIB_API lua_Number ICACHE_FLASH_ATTR luaL_checknumber (lua_State *L, int narg
} }
LUALIB_API lua_Number ICACHE_FLASH_ATTR luaL_optnumber (lua_State *L, int narg, lua_Number def) { LUALIB_API lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number def) {
return luaL_opt(L, luaL_checknumber, narg, def); return luaL_opt(L, luaL_checknumber, narg, def);
} }
LUALIB_API lua_Integer ICACHE_FLASH_ATTR luaL_checkinteger (lua_State *L, int narg) { LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) {
lua_Integer d = lua_tointeger(L, narg); lua_Integer d = lua_tointeger(L, narg);
if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */ if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */
tag_error(L, narg, LUA_TNUMBER); tag_error(L, narg, LUA_TNUMBER);
...@@ -229,13 +229,13 @@ LUALIB_API lua_Integer ICACHE_FLASH_ATTR luaL_checkinteger (lua_State *L, int na ...@@ -229,13 +229,13 @@ LUALIB_API lua_Integer ICACHE_FLASH_ATTR luaL_checkinteger (lua_State *L, int na
} }
LUALIB_API lua_Integer ICACHE_FLASH_ATTR luaL_optinteger (lua_State *L, int narg, LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int narg,
lua_Integer def) { lua_Integer def) {
return luaL_opt(L, luaL_checkinteger, narg, def); return luaL_opt(L, luaL_checkinteger, narg, def);
} }
LUALIB_API int ICACHE_FLASH_ATTR luaL_getmetafield (lua_State *L, int obj, const char *event) { LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *event) {
if (!lua_getmetatable(L, obj)) /* no metatable? */ if (!lua_getmetatable(L, obj)) /* no metatable? */
return 0; return 0;
lua_pushstring(L, event); lua_pushstring(L, event);
...@@ -251,7 +251,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_getmetafield (lua_State *L, int obj, const ...@@ -251,7 +251,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_getmetafield (lua_State *L, int obj, const
} }
LUALIB_API int ICACHE_FLASH_ATTR luaL_callmeta (lua_State *L, int obj, const char *event) { LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) {
obj = abs_index(L, obj); obj = abs_index(L, obj);
if (!luaL_getmetafield(L, obj, event)) /* no metafield? */ if (!luaL_getmetafield(L, obj, event)) /* no metafield? */
return 0; return 0;
...@@ -261,12 +261,12 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_callmeta (lua_State *L, int obj, const cha ...@@ -261,12 +261,12 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_callmeta (lua_State *L, int obj, const cha
} }
LUALIB_API void ICACHE_FLASH_ATTR (luaL_register) (lua_State *L, const char *libname, LUALIB_API void (luaL_register) (lua_State *L, const char *libname,
const luaL_Reg *l) { const luaL_Reg *l) {
luaI_openlib(L, libname, l, 0, LUA_USECCLOSURES); luaI_openlib(L, libname, l, 0, LUA_USECCLOSURES);
} }
LUALIB_API void ICACHE_FLASH_ATTR (luaL_register_light) (lua_State *L, const char *libname, LUALIB_API void (luaL_register_light) (lua_State *L, const char *libname,
const luaL_Reg *l) { const luaL_Reg *l) {
#if LUA_OPTIMIZE_MEMORY > 0 #if LUA_OPTIMIZE_MEMORY > 0
luaI_openlib(L, libname, l, 0, LUA_USELIGHTFUNCTIONS); luaI_openlib(L, libname, l, 0, LUA_USELIGHTFUNCTIONS);
...@@ -275,14 +275,14 @@ LUALIB_API void ICACHE_FLASH_ATTR (luaL_register_light) (lua_State *L, const cha ...@@ -275,14 +275,14 @@ LUALIB_API void ICACHE_FLASH_ATTR (luaL_register_light) (lua_State *L, const cha
#endif #endif
} }
static int ICACHE_FLASH_ATTR libsize (const luaL_Reg *l) { static int libsize (const luaL_Reg *l) {
int size = 0; int size = 0;
for (; l->name; l++) size++; for (; l->name; l++) size++;
return size; return size;
} }
LUALIB_API void ICACHE_FLASH_ATTR luaI_openlib (lua_State *L, const char *libname, LUALIB_API void luaI_openlib (lua_State *L, const char *libname,
const luaL_Reg *l, int nup, int ftype) { const luaL_Reg *l, int nup, int ftype) {
if (libname) { if (libname) {
int size = libsize(l); int size = libsize(l);
...@@ -323,14 +323,14 @@ LUALIB_API void ICACHE_FLASH_ATTR luaI_openlib (lua_State *L, const char *libnam ...@@ -323,14 +323,14 @@ LUALIB_API void ICACHE_FLASH_ATTR luaI_openlib (lua_State *L, const char *libnam
#if defined(LUA_COMPAT_GETN) #if defined(LUA_COMPAT_GETN)
static int ICACHE_FLASH_ATTR checkint (lua_State *L, int topop) { static int checkint (lua_State *L, int topop) {
int n = (lua_type(L, -1) == LUA_TNUMBER) ? lua_tointeger(L, -1) : -1; int n = (lua_type(L, -1) == LUA_TNUMBER) ? lua_tointeger(L, -1) : -1;
lua_pop(L, topop); lua_pop(L, topop);
return n; return n;
} }
static void ICACHE_FLASH_ATTR getsizes (lua_State *L) { static void getsizes (lua_State *L) {
lua_getfield(L, LUA_REGISTRYINDEX, "LUA_SIZES"); lua_getfield(L, LUA_REGISTRYINDEX, "LUA_SIZES");
if (lua_isnil(L, -1)) { /* no `size' table? */ if (lua_isnil(L, -1)) { /* no `size' table? */
lua_pop(L, 1); /* remove nil */ lua_pop(L, 1); /* remove nil */
...@@ -345,7 +345,7 @@ static void ICACHE_FLASH_ATTR getsizes (lua_State *L) { ...@@ -345,7 +345,7 @@ static void ICACHE_FLASH_ATTR getsizes (lua_State *L) {
} }
LUALIB_API void ICACHE_FLASH_ATTR luaL_setn (lua_State *L, int t, int n) { LUALIB_API void luaL_setn (lua_State *L, int t, int n) {
t = abs_index(L, t); t = abs_index(L, t);
lua_pushliteral(L, "n"); lua_pushliteral(L, "n");
lua_rawget(L, t); lua_rawget(L, t);
...@@ -364,7 +364,7 @@ LUALIB_API void ICACHE_FLASH_ATTR luaL_setn (lua_State *L, int t, int n) { ...@@ -364,7 +364,7 @@ LUALIB_API void ICACHE_FLASH_ATTR luaL_setn (lua_State *L, int t, int n) {
} }
LUALIB_API int ICACHE_FLASH_ATTR luaL_getn (lua_State *L, int t) { LUALIB_API int luaL_getn (lua_State *L, int t) {
int n; int n;
t = abs_index(L, t); t = abs_index(L, t);
lua_pushliteral(L, "n"); /* try t.n */ lua_pushliteral(L, "n"); /* try t.n */
...@@ -383,7 +383,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_getn (lua_State *L, int t) { ...@@ -383,7 +383,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_getn (lua_State *L, int t) {
LUALIB_API const char *ICACHE_FLASH_ATTR luaL_gsub (lua_State *L, const char *s, const char *p, LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p,
const char *r) { const char *r) {
const char *wild; const char *wild;
size_t l = c_strlen(p); size_t l = c_strlen(p);
...@@ -400,7 +400,7 @@ LUALIB_API const char *ICACHE_FLASH_ATTR luaL_gsub (lua_State *L, const char *s, ...@@ -400,7 +400,7 @@ LUALIB_API const char *ICACHE_FLASH_ATTR luaL_gsub (lua_State *L, const char *s,
} }
LUALIB_API const char *ICACHE_FLASH_ATTR luaL_findtable (lua_State *L, int idx, LUALIB_API const char *luaL_findtable (lua_State *L, int idx,
const char *fname, int szhint) { const char *fname, int szhint) {
const char *e; const char *e;
lua_pushvalue(L, idx); lua_pushvalue(L, idx);
...@@ -449,7 +449,7 @@ LUALIB_API const char *ICACHE_FLASH_ATTR luaL_findtable (lua_State *L, int idx, ...@@ -449,7 +449,7 @@ LUALIB_API const char *ICACHE_FLASH_ATTR luaL_findtable (lua_State *L, int idx,
#define LIMIT (LUA_MINSTACK/2) #define LIMIT (LUA_MINSTACK/2)
static int ICACHE_FLASH_ATTR emptybuffer (luaL_Buffer *B) { static int emptybuffer (luaL_Buffer *B) {
size_t l = bufflen(B); size_t l = bufflen(B);
if (l == 0) return 0; /* put nothing on stack */ if (l == 0) return 0; /* put nothing on stack */
else { else {
...@@ -461,7 +461,7 @@ static int ICACHE_FLASH_ATTR emptybuffer (luaL_Buffer *B) { ...@@ -461,7 +461,7 @@ static int ICACHE_FLASH_ATTR emptybuffer (luaL_Buffer *B) {
} }
static void ICACHE_FLASH_ATTR adjuststack (luaL_Buffer *B) { static void adjuststack (luaL_Buffer *B) {
if (B->lvl > 1) { if (B->lvl > 1) {
lua_State *L = B->L; lua_State *L = B->L;
int toget = 1; /* number of levels to concat */ int toget = 1; /* number of levels to concat */
...@@ -480,32 +480,32 @@ static void ICACHE_FLASH_ATTR adjuststack (luaL_Buffer *B) { ...@@ -480,32 +480,32 @@ static void ICACHE_FLASH_ATTR adjuststack (luaL_Buffer *B) {
} }
LUALIB_API char *ICACHE_FLASH_ATTR luaL_prepbuffer (luaL_Buffer *B) { LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) {
if (emptybuffer(B)) if (emptybuffer(B))
adjuststack(B); adjuststack(B);
return B->buffer; return B->buffer;
} }
LUALIB_API void ICACHE_FLASH_ATTR luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) {
while (l--) while (l--)
luaL_addchar(B, *s++); luaL_addchar(B, *s++);
} }
LUALIB_API void ICACHE_FLASH_ATTR luaL_addstring (luaL_Buffer *B, const char *s) { LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) {
luaL_addlstring(B, s, c_strlen(s)); luaL_addlstring(B, s, c_strlen(s));
} }
LUALIB_API void ICACHE_FLASH_ATTR luaL_pushresult (luaL_Buffer *B) { LUALIB_API void luaL_pushresult (luaL_Buffer *B) {
emptybuffer(B); emptybuffer(B);
lua_concat(B->L, B->lvl); lua_concat(B->L, B->lvl);
B->lvl = 1; B->lvl = 1;
} }
LUALIB_API void ICACHE_FLASH_ATTR luaL_addvalue (luaL_Buffer *B) { LUALIB_API void luaL_addvalue (luaL_Buffer *B) {
lua_State *L = B->L; lua_State *L = B->L;
size_t vl; size_t vl;
const char *s = lua_tolstring(L, -1, &vl); const char *s = lua_tolstring(L, -1, &vl);
...@@ -523,7 +523,7 @@ LUALIB_API void ICACHE_FLASH_ATTR luaL_addvalue (luaL_Buffer *B) { ...@@ -523,7 +523,7 @@ LUALIB_API void ICACHE_FLASH_ATTR luaL_addvalue (luaL_Buffer *B) {
} }
LUALIB_API void ICACHE_FLASH_ATTR luaL_buffinit (lua_State *L, luaL_Buffer *B) { LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) {
B->L = L; B->L = L;
B->p = B->buffer; B->p = B->buffer;
B->lvl = 0; B->lvl = 0;
...@@ -532,7 +532,7 @@ LUALIB_API void ICACHE_FLASH_ATTR luaL_buffinit (lua_State *L, luaL_Buffer *B) { ...@@ -532,7 +532,7 @@ LUALIB_API void ICACHE_FLASH_ATTR luaL_buffinit (lua_State *L, luaL_Buffer *B) {
/* }====================================================== */ /* }====================================================== */
LUALIB_API int ICACHE_FLASH_ATTR luaL_ref (lua_State *L, int t) { LUALIB_API int luaL_ref (lua_State *L, int t) {
int ref; int ref;
t = abs_index(L, t); t = abs_index(L, t);
if (lua_isnil(L, -1)) { if (lua_isnil(L, -1)) {
...@@ -555,7 +555,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_ref (lua_State *L, int t) { ...@@ -555,7 +555,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_ref (lua_State *L, int t) {
} }
LUALIB_API void ICACHE_FLASH_ATTR luaL_unref (lua_State *L, int t, int ref) { LUALIB_API void luaL_unref (lua_State *L, int t, int ref) {
if (ref >= 0) { if (ref >= 0) {
t = abs_index(L, t); t = abs_index(L, t);
lua_rawgeti(L, t, FREELIST_REF); lua_rawgeti(L, t, FREELIST_REF);
...@@ -582,7 +582,7 @@ typedef struct LoadF { ...@@ -582,7 +582,7 @@ typedef struct LoadF {
} LoadF; } LoadF;
static const char *ICACHE_FLASH_ATTR getF (lua_State *L, void *ud, size_t *size) { static const char *getF (lua_State *L, void *ud, size_t *size) {
LoadF *lf = (LoadF *)ud; LoadF *lf = (LoadF *)ud;
(void)L; (void)L;
if (lf->extraline) { if (lf->extraline) {
...@@ -596,7 +596,7 @@ static const char *ICACHE_FLASH_ATTR getF (lua_State *L, void *ud, size_t *size) ...@@ -596,7 +596,7 @@ static const char *ICACHE_FLASH_ATTR getF (lua_State *L, void *ud, size_t *size)
} }
static int ICACHE_FLASH_ATTR errfile (lua_State *L, const char *what, int fnameindex) { static int errfile (lua_State *L, const char *what, int fnameindex) {
const char *serr = c_strerror(errno); const char *serr = c_strerror(errno);
const char *filename = lua_tostring(L, fnameindex) + 1; const char *filename = lua_tostring(L, fnameindex) + 1;
lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr); lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr);
...@@ -605,7 +605,7 @@ static int ICACHE_FLASH_ATTR errfile (lua_State *L, const char *what, int fnamei ...@@ -605,7 +605,7 @@ static int ICACHE_FLASH_ATTR errfile (lua_State *L, const char *what, int fnamei
} }
LUALIB_API int ICACHE_FLASH_ATTR luaL_loadfile (lua_State *L, const char *filename) { LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
LoadF lf; LoadF lf;
int status, readstatus; int status, readstatus;
int c; int c;
...@@ -656,7 +656,7 @@ typedef struct LoadFSF { ...@@ -656,7 +656,7 @@ typedef struct LoadFSF {
} LoadFSF; } LoadFSF;
static const char *ICACHE_FLASH_ATTR getFSF (lua_State *L, void *ud, size_t *size) { static const char *getFSF (lua_State *L, void *ud, size_t *size) {
LoadFSF *lf = (LoadFSF *)ud; LoadFSF *lf = (LoadFSF *)ud;
(void)L; (void)L;
if (lf->extraline) { if (lf->extraline) {
...@@ -670,7 +670,7 @@ static const char *ICACHE_FLASH_ATTR getFSF (lua_State *L, void *ud, size_t *siz ...@@ -670,7 +670,7 @@ static const char *ICACHE_FLASH_ATTR getFSF (lua_State *L, void *ud, size_t *siz
} }
static int ICACHE_FLASH_ATTR errfsfile (lua_State *L, const char *what, int fnameindex) { static int errfsfile (lua_State *L, const char *what, int fnameindex) {
const char *filename = lua_tostring(L, fnameindex) + 1; const char *filename = lua_tostring(L, fnameindex) + 1;
lua_pushfstring(L, "cannot %s %s", what, filename); lua_pushfstring(L, "cannot %s %s", what, filename);
lua_remove(L, fnameindex); lua_remove(L, fnameindex);
...@@ -678,7 +678,7 @@ static int ICACHE_FLASH_ATTR errfsfile (lua_State *L, const char *what, int fnam ...@@ -678,7 +678,7 @@ static int ICACHE_FLASH_ATTR errfsfile (lua_State *L, const char *what, int fnam
} }
LUALIB_API int ICACHE_FLASH_ATTR luaL_loadfsfile (lua_State *L, const char *filename) { LUALIB_API int luaL_loadfsfile (lua_State *L, const char *filename) {
LoadFSF lf; LoadFSF lf;
int status, readstatus; int status, readstatus;
int c; int c;
...@@ -722,7 +722,7 @@ typedef struct LoadS { ...@@ -722,7 +722,7 @@ typedef struct LoadS {
} LoadS; } LoadS;
static const char *ICACHE_FLASH_ATTR getS (lua_State *L, void *ud, size_t *size) { static const char *getS (lua_State *L, void *ud, size_t *size) {
LoadS *ls = (LoadS *)ud; LoadS *ls = (LoadS *)ud;
(void)L; (void)L;
if (L == NULL && size == NULL) // direct mode check if (L == NULL && size == NULL) // direct mode check
...@@ -734,7 +734,7 @@ static const char *ICACHE_FLASH_ATTR getS (lua_State *L, void *ud, size_t *size) ...@@ -734,7 +734,7 @@ static const char *ICACHE_FLASH_ATTR getS (lua_State *L, void *ud, size_t *size)
} }
LUALIB_API int ICACHE_FLASH_ATTR luaL_loadbuffer (lua_State *L, const char *buff, size_t size, LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size,
const char *name) { const char *name) {
LoadS ls; LoadS ls;
ls.s = buff; ls.s = buff;
...@@ -743,7 +743,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_loadbuffer (lua_State *L, const char *buff ...@@ -743,7 +743,7 @@ LUALIB_API int ICACHE_FLASH_ATTR luaL_loadbuffer (lua_State *L, const char *buff
} }
LUALIB_API int ICACHE_FLASH_ATTR (luaL_loadstring) (lua_State *L, const char *s) { LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s) {
return luaL_loadbuffer(L, s, c_strlen(s), s); return luaL_loadbuffer(L, s, c_strlen(s), s);
} }
...@@ -752,7 +752,7 @@ LUALIB_API int ICACHE_FLASH_ATTR (luaL_loadstring) (lua_State *L, const char *s) ...@@ -752,7 +752,7 @@ LUALIB_API int ICACHE_FLASH_ATTR (luaL_loadstring) (lua_State *L, const char *s)
/* }====================================================== */ /* }====================================================== */
static int ICACHE_FLASH_ATTR l_check_memlimit(lua_State *L, size_t needbytes) { static int l_check_memlimit(lua_State *L, size_t needbytes) {
global_State *g = G(L); global_State *g = G(L);
int cycle_count = 0; int cycle_count = 0;
lu_mem limit = g->memlimit - needbytes; lu_mem limit = g->memlimit - needbytes;
...@@ -770,7 +770,7 @@ static int ICACHE_FLASH_ATTR l_check_memlimit(lua_State *L, size_t needbytes) { ...@@ -770,7 +770,7 @@ static int ICACHE_FLASH_ATTR l_check_memlimit(lua_State *L, size_t needbytes) {
} }
static void *ICACHE_FLASH_ATTR l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) { static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
lua_State *L = (lua_State *)ud; lua_State *L = (lua_State *)ud;
int mode = L == NULL ? 0 : G(L)->egcmode; int mode = L == NULL ? 0 : G(L)->egcmode;
void *nptr; void *nptr;
...@@ -797,7 +797,7 @@ static void *ICACHE_FLASH_ATTR l_alloc (void *ud, void *ptr, size_t osize, size_ ...@@ -797,7 +797,7 @@ static void *ICACHE_FLASH_ATTR l_alloc (void *ud, void *ptr, size_t osize, size_
} }
static int ICACHE_FLASH_ATTR panic (lua_State *L) { static int panic (lua_State *L) {
(void)L; /* to avoid warnings */ (void)L; /* to avoid warnings */
#if defined(LUA_USE_STDIO) #if defined(LUA_USE_STDIO)
c_fprintf(c_stderr, "PANIC: unprotected error in call to Lua API (%s)\n", c_fprintf(c_stderr, "PANIC: unprotected error in call to Lua API (%s)\n",
...@@ -810,7 +810,7 @@ static int ICACHE_FLASH_ATTR panic (lua_State *L) { ...@@ -810,7 +810,7 @@ static int ICACHE_FLASH_ATTR panic (lua_State *L) {
} }
LUALIB_API lua_State *ICACHE_FLASH_ATTR luaL_newstate (void) { LUALIB_API lua_State *luaL_newstate (void) {
lua_State *L = lua_newstate(l_alloc, NULL); lua_State *L = lua_newstate(l_alloc, NULL);
lua_setallocf(L, l_alloc, L); /* allocator need lua_State. */ lua_setallocf(L, l_alloc, L); /* allocator need lua_State. */
if (L) lua_atpanic(L, &panic); if (L) lua_atpanic(L, &panic);
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
** model but changing `fputs' to put the strings at a proper place ** model but changing `fputs' to put the strings at a proper place
** (a console window or a log file, for instance). ** (a console window or a log file, for instance).
*/ */
static int ICACHE_FLASH_ATTR luaB_print (lua_State *L) { static int luaB_print (lua_State *L) {
int n = lua_gettop(L); /* number of arguments */ int n = lua_gettop(L); /* number of arguments */
int i; int i;
lua_getglobal(L, "tostring"); lua_getglobal(L, "tostring");
...@@ -60,7 +60,7 @@ static int ICACHE_FLASH_ATTR luaB_print (lua_State *L) { ...@@ -60,7 +60,7 @@ static int ICACHE_FLASH_ATTR luaB_print (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_tonumber (lua_State *L) { static int luaB_tonumber (lua_State *L) {
int base = luaL_optint(L, 2, 10); int base = luaL_optint(L, 2, 10);
if (base == 10) { /* standard conversion */ if (base == 10) { /* standard conversion */
luaL_checkany(L, 1); luaL_checkany(L, 1);
...@@ -88,7 +88,7 @@ static int ICACHE_FLASH_ATTR luaB_tonumber (lua_State *L) { ...@@ -88,7 +88,7 @@ static int ICACHE_FLASH_ATTR luaB_tonumber (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_error (lua_State *L) { static int luaB_error (lua_State *L) {
int level = luaL_optint(L, 2, 1); int level = luaL_optint(L, 2, 1);
lua_settop(L, 1); lua_settop(L, 1);
if (lua_isstring(L, 1) && level > 0) { /* add extra information? */ if (lua_isstring(L, 1) && level > 0) { /* add extra information? */
...@@ -100,7 +100,7 @@ static int ICACHE_FLASH_ATTR luaB_error (lua_State *L) { ...@@ -100,7 +100,7 @@ static int ICACHE_FLASH_ATTR luaB_error (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_getmetatable (lua_State *L) { static int luaB_getmetatable (lua_State *L) {
luaL_checkany(L, 1); luaL_checkany(L, 1);
if (!lua_getmetatable(L, 1)) { if (!lua_getmetatable(L, 1)) {
lua_pushnil(L); lua_pushnil(L);
...@@ -111,7 +111,7 @@ static int ICACHE_FLASH_ATTR luaB_getmetatable (lua_State *L) { ...@@ -111,7 +111,7 @@ static int ICACHE_FLASH_ATTR luaB_getmetatable (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_setmetatable (lua_State *L) { static int luaB_setmetatable (lua_State *L) {
int t = lua_type(L, 2); int t = lua_type(L, 2);
luaL_checktype(L, 1, LUA_TTABLE); luaL_checktype(L, 1, LUA_TTABLE);
luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE || t == LUA_TROTABLE, 2, luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE || t == LUA_TROTABLE, 2,
...@@ -124,7 +124,7 @@ static int ICACHE_FLASH_ATTR luaB_setmetatable (lua_State *L) { ...@@ -124,7 +124,7 @@ static int ICACHE_FLASH_ATTR luaB_setmetatable (lua_State *L) {
} }
static void ICACHE_FLASH_ATTR getfunc (lua_State *L, int opt) { static void getfunc (lua_State *L, int opt) {
if (lua_isfunction(L, 1)) lua_pushvalue(L, 1); if (lua_isfunction(L, 1)) lua_pushvalue(L, 1);
else { else {
lua_Debug ar; lua_Debug ar;
...@@ -140,7 +140,7 @@ static void ICACHE_FLASH_ATTR getfunc (lua_State *L, int opt) { ...@@ -140,7 +140,7 @@ static void ICACHE_FLASH_ATTR getfunc (lua_State *L, int opt) {
} }
static int ICACHE_FLASH_ATTR luaB_getfenv (lua_State *L) { static int luaB_getfenv (lua_State *L) {
getfunc(L, 1); getfunc(L, 1);
if (lua_iscfunction(L, -1)) /* is a C function? */ if (lua_iscfunction(L, -1)) /* is a C function? */
lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the thread's global env. */ lua_pushvalue(L, LUA_GLOBALSINDEX); /* return the thread's global env. */
...@@ -150,7 +150,7 @@ static int ICACHE_FLASH_ATTR luaB_getfenv (lua_State *L) { ...@@ -150,7 +150,7 @@ static int ICACHE_FLASH_ATTR luaB_getfenv (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_setfenv (lua_State *L) { static int luaB_setfenv (lua_State *L) {
luaL_checktype(L, 2, LUA_TTABLE); luaL_checktype(L, 2, LUA_TTABLE);
getfunc(L, 0); getfunc(L, 0);
lua_pushvalue(L, 2); lua_pushvalue(L, 2);
...@@ -168,7 +168,7 @@ static int ICACHE_FLASH_ATTR luaB_setfenv (lua_State *L) { ...@@ -168,7 +168,7 @@ static int ICACHE_FLASH_ATTR luaB_setfenv (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_rawequal (lua_State *L) { static int luaB_rawequal (lua_State *L) {
luaL_checkany(L, 1); luaL_checkany(L, 1);
luaL_checkany(L, 2); luaL_checkany(L, 2);
lua_pushboolean(L, lua_rawequal(L, 1, 2)); lua_pushboolean(L, lua_rawequal(L, 1, 2));
...@@ -176,7 +176,7 @@ static int ICACHE_FLASH_ATTR luaB_rawequal (lua_State *L) { ...@@ -176,7 +176,7 @@ static int ICACHE_FLASH_ATTR luaB_rawequal (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_rawget (lua_State *L) { static int luaB_rawget (lua_State *L) {
luaL_checkanytable(L, 1); luaL_checkanytable(L, 1);
luaL_checkany(L, 2); luaL_checkany(L, 2);
lua_settop(L, 2); lua_settop(L, 2);
...@@ -184,7 +184,7 @@ static int ICACHE_FLASH_ATTR luaB_rawget (lua_State *L) { ...@@ -184,7 +184,7 @@ static int ICACHE_FLASH_ATTR luaB_rawget (lua_State *L) {
return 1; return 1;
} }
static int ICACHE_FLASH_ATTR luaB_rawset (lua_State *L) { static int luaB_rawset (lua_State *L) {
luaL_checktype(L, 1, LUA_TTABLE); luaL_checktype(L, 1, LUA_TTABLE);
luaL_checkany(L, 2); luaL_checkany(L, 2);
luaL_checkany(L, 3); luaL_checkany(L, 3);
...@@ -194,13 +194,13 @@ static int ICACHE_FLASH_ATTR luaB_rawset (lua_State *L) { ...@@ -194,13 +194,13 @@ static int ICACHE_FLASH_ATTR luaB_rawset (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_gcinfo (lua_State *L) { static int luaB_gcinfo (lua_State *L) {
lua_pushinteger(L, lua_getgccount(L)); lua_pushinteger(L, lua_getgccount(L));
return 1; return 1;
} }
static int ICACHE_FLASH_ATTR luaB_collectgarbage (lua_State *L) { static int luaB_collectgarbage (lua_State *L) {
static const char *const opts[] = {"stop", "restart", "collect", static const char *const opts[] = {"stop", "restart", "collect",
"count", "step", "setpause", "setstepmul","setmemlimit","getmemlimit", NULL}; "count", "step", "setpause", "setstepmul","setmemlimit","getmemlimit", NULL};
static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT, static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT,
...@@ -227,14 +227,14 @@ static int ICACHE_FLASH_ATTR luaB_collectgarbage (lua_State *L) { ...@@ -227,14 +227,14 @@ static int ICACHE_FLASH_ATTR luaB_collectgarbage (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_type (lua_State *L) { static int luaB_type (lua_State *L) {
luaL_checkany(L, 1); luaL_checkany(L, 1);
lua_pushstring(L, luaL_typename(L, 1)); lua_pushstring(L, luaL_typename(L, 1));
return 1; return 1;
} }
static int ICACHE_FLASH_ATTR luaB_next (lua_State *L) { static int luaB_next (lua_State *L) {
luaL_checkanytable(L, 1); luaL_checkanytable(L, 1);
lua_settop(L, 2); /* create a 2nd argument if there isn't one */ lua_settop(L, 2); /* create a 2nd argument if there isn't one */
if (lua_next(L, 1)) if (lua_next(L, 1))
...@@ -246,7 +246,7 @@ static int ICACHE_FLASH_ATTR luaB_next (lua_State *L) { ...@@ -246,7 +246,7 @@ static int ICACHE_FLASH_ATTR luaB_next (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_pairs (lua_State *L) { static int luaB_pairs (lua_State *L) {
luaL_checkanytable(L, 1); luaL_checkanytable(L, 1);
lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */ lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */
lua_pushvalue(L, 1); /* state, */ lua_pushvalue(L, 1); /* state, */
...@@ -255,7 +255,7 @@ static int ICACHE_FLASH_ATTR luaB_pairs (lua_State *L) { ...@@ -255,7 +255,7 @@ static int ICACHE_FLASH_ATTR luaB_pairs (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR ipairsaux (lua_State *L) { static int ipairsaux (lua_State *L) {
int i = luaL_checkint(L, 2); int i = luaL_checkint(L, 2);
luaL_checkanytable(L, 1); luaL_checkanytable(L, 1);
i++; /* next value */ i++; /* next value */
...@@ -265,7 +265,7 @@ static int ICACHE_FLASH_ATTR ipairsaux (lua_State *L) { ...@@ -265,7 +265,7 @@ static int ICACHE_FLASH_ATTR ipairsaux (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_ipairs (lua_State *L) { static int luaB_ipairs (lua_State *L) {
luaL_checkanytable(L, 1); luaL_checkanytable(L, 1);
lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */ lua_pushvalue(L, lua_upvalueindex(1)); /* return generator, */
lua_pushvalue(L, 1); /* state, */ lua_pushvalue(L, 1); /* state, */
...@@ -274,7 +274,7 @@ static int ICACHE_FLASH_ATTR luaB_ipairs (lua_State *L) { ...@@ -274,7 +274,7 @@ static int ICACHE_FLASH_ATTR luaB_ipairs (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR load_aux (lua_State *L, int status) { static int load_aux (lua_State *L, int status) {
if (status == 0) /* OK? */ if (status == 0) /* OK? */
return 1; return 1;
else { else {
...@@ -285,7 +285,7 @@ static int ICACHE_FLASH_ATTR load_aux (lua_State *L, int status) { ...@@ -285,7 +285,7 @@ static int ICACHE_FLASH_ATTR load_aux (lua_State *L, int status) {
} }
static int ICACHE_FLASH_ATTR luaB_loadstring (lua_State *L) { static int luaB_loadstring (lua_State *L) {
size_t l; size_t l;
const char *s = luaL_checklstring(L, 1, &l); const char *s = luaL_checklstring(L, 1, &l);
const char *chunkname = luaL_optstring(L, 2, s); const char *chunkname = luaL_optstring(L, 2, s);
...@@ -293,7 +293,7 @@ static int ICACHE_FLASH_ATTR luaB_loadstring (lua_State *L) { ...@@ -293,7 +293,7 @@ static int ICACHE_FLASH_ATTR luaB_loadstring (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_loadfile (lua_State *L) { static int luaB_loadfile (lua_State *L) {
const char *fname = luaL_optstring(L, 1, NULL); const char *fname = luaL_optstring(L, 1, NULL);
#if 0 #if 0
return load_aux(L, luaL_loadfile(L, fname)); return load_aux(L, luaL_loadfile(L, fname));
...@@ -309,7 +309,7 @@ static int ICACHE_FLASH_ATTR luaB_loadfile (lua_State *L) { ...@@ -309,7 +309,7 @@ static int ICACHE_FLASH_ATTR luaB_loadfile (lua_State *L) {
** stack top. Instead, it keeps its resulting string in a ** stack top. Instead, it keeps its resulting string in a
** reserved slot inside the stack. ** reserved slot inside the stack.
*/ */
static const char *ICACHE_FLASH_ATTR generic_reader (lua_State *L, void *ud, size_t *size) { static const char *generic_reader (lua_State *L, void *ud, size_t *size) {
(void)ud; /* to avoid warnings */ (void)ud; /* to avoid warnings */
if (L == NULL && size == NULL) // direct mode check, doesn't happen if (L == NULL && size == NULL) // direct mode check, doesn't happen
return NULL; return NULL;
...@@ -329,7 +329,7 @@ static const char *ICACHE_FLASH_ATTR generic_reader (lua_State *L, void *ud, siz ...@@ -329,7 +329,7 @@ static const char *ICACHE_FLASH_ATTR generic_reader (lua_State *L, void *ud, siz
} }
static int ICACHE_FLASH_ATTR luaB_load (lua_State *L) { static int luaB_load (lua_State *L) {
int status; int status;
const char *cname = luaL_optstring(L, 2, "=(load)"); const char *cname = luaL_optstring(L, 2, "=(load)");
luaL_checktype(L, 1, LUA_TFUNCTION); luaL_checktype(L, 1, LUA_TFUNCTION);
...@@ -339,7 +339,7 @@ static int ICACHE_FLASH_ATTR luaB_load (lua_State *L) { ...@@ -339,7 +339,7 @@ static int ICACHE_FLASH_ATTR luaB_load (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_dofile (lua_State *L) { static int luaB_dofile (lua_State *L) {
const char *fname = luaL_optstring(L, 1, NULL); const char *fname = luaL_optstring(L, 1, NULL);
int n = lua_gettop(L); int n = lua_gettop(L);
#if 0 #if 0
...@@ -352,7 +352,7 @@ static int ICACHE_FLASH_ATTR luaB_dofile (lua_State *L) { ...@@ -352,7 +352,7 @@ static int ICACHE_FLASH_ATTR luaB_dofile (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_assert (lua_State *L) { static int luaB_assert (lua_State *L) {
luaL_checkany(L, 1); luaL_checkany(L, 1);
if (!lua_toboolean(L, 1)) if (!lua_toboolean(L, 1))
return luaL_error(L, "%s", luaL_optstring(L, 2, "assertion failed!")); return luaL_error(L, "%s", luaL_optstring(L, 2, "assertion failed!"));
...@@ -360,7 +360,7 @@ static int ICACHE_FLASH_ATTR luaB_assert (lua_State *L) { ...@@ -360,7 +360,7 @@ static int ICACHE_FLASH_ATTR luaB_assert (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_unpack (lua_State *L) { static int luaB_unpack (lua_State *L) {
int i, e, n; int i, e, n;
luaL_checktype(L, 1, LUA_TTABLE); luaL_checktype(L, 1, LUA_TTABLE);
i = luaL_optint(L, 2, 1); i = luaL_optint(L, 2, 1);
...@@ -376,7 +376,7 @@ static int ICACHE_FLASH_ATTR luaB_unpack (lua_State *L) { ...@@ -376,7 +376,7 @@ static int ICACHE_FLASH_ATTR luaB_unpack (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_select (lua_State *L) { static int luaB_select (lua_State *L) {
int n = lua_gettop(L); int n = lua_gettop(L);
if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') { if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') {
lua_pushinteger(L, n-1); lua_pushinteger(L, n-1);
...@@ -392,7 +392,7 @@ static int ICACHE_FLASH_ATTR luaB_select (lua_State *L) { ...@@ -392,7 +392,7 @@ static int ICACHE_FLASH_ATTR luaB_select (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_pcall (lua_State *L) { static int luaB_pcall (lua_State *L) {
int status; int status;
luaL_checkany(L, 1); luaL_checkany(L, 1);
status = lua_pcall(L, lua_gettop(L) - 1, LUA_MULTRET, 0); status = lua_pcall(L, lua_gettop(L) - 1, LUA_MULTRET, 0);
...@@ -402,7 +402,7 @@ static int ICACHE_FLASH_ATTR luaB_pcall (lua_State *L) { ...@@ -402,7 +402,7 @@ static int ICACHE_FLASH_ATTR luaB_pcall (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_xpcall (lua_State *L) { static int luaB_xpcall (lua_State *L) {
int status; int status;
luaL_checkany(L, 2); luaL_checkany(L, 2);
lua_settop(L, 2); lua_settop(L, 2);
...@@ -414,7 +414,7 @@ static int ICACHE_FLASH_ATTR luaB_xpcall (lua_State *L) { ...@@ -414,7 +414,7 @@ static int ICACHE_FLASH_ATTR luaB_xpcall (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_tostring (lua_State *L) { static int luaB_tostring (lua_State *L) {
luaL_checkany(L, 1); luaL_checkany(L, 1);
if (luaL_callmeta(L, 1, "__tostring")) /* is there a metafield? */ if (luaL_callmeta(L, 1, "__tostring")) /* is there a metafield? */
return 1; /* use its value */ return 1; /* use its value */
...@@ -439,7 +439,7 @@ static int ICACHE_FLASH_ATTR luaB_tostring (lua_State *L) { ...@@ -439,7 +439,7 @@ static int ICACHE_FLASH_ATTR luaB_tostring (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_newproxy (lua_State *L) { static int luaB_newproxy (lua_State *L) {
lua_settop(L, 1); lua_settop(L, 1);
lua_newuserdata(L, 0); /* create proxy */ lua_newuserdata(L, 0); /* create proxy */
if (lua_toboolean(L, 1) == 0) if (lua_toboolean(L, 1) == 0)
...@@ -500,7 +500,7 @@ const LUA_REG_TYPE base_funcs_list[] = { ...@@ -500,7 +500,7 @@ const LUA_REG_TYPE base_funcs_list[] = {
#endif #endif
static int ICACHE_FLASH_ATTR luaB_index(lua_State *L) { static int luaB_index(lua_State *L) {
#if LUA_OPTIMIZE_MEMORY == 2 #if LUA_OPTIMIZE_MEMORY == 2
int fres; int fres;
if ((fres = luaR_findfunction(L, base_funcs_list)) != 0) if ((fres = luaR_findfunction(L, base_funcs_list)) != 0)
...@@ -546,7 +546,7 @@ static const luaL_Reg base_funcs[] = { ...@@ -546,7 +546,7 @@ static const luaL_Reg base_funcs[] = {
static const char *const statnames[] = static const char *const statnames[] =
{"running", "suspended", "normal", "dead"}; {"running", "suspended", "normal", "dead"};
static int ICACHE_FLASH_ATTR costatus (lua_State *L, lua_State *co) { static int costatus (lua_State *L, lua_State *co) {
if (L == co) return CO_RUN; if (L == co) return CO_RUN;
switch (lua_status(co)) { switch (lua_status(co)) {
case LUA_YIELD: case LUA_YIELD:
...@@ -566,7 +566,7 @@ static int ICACHE_FLASH_ATTR costatus (lua_State *L, lua_State *co) { ...@@ -566,7 +566,7 @@ static int ICACHE_FLASH_ATTR costatus (lua_State *L, lua_State *co) {
} }
static int ICACHE_FLASH_ATTR luaB_costatus (lua_State *L) { static int luaB_costatus (lua_State *L) {
lua_State *co = lua_tothread(L, 1); lua_State *co = lua_tothread(L, 1);
luaL_argcheck(L, co, 1, "coroutine expected"); luaL_argcheck(L, co, 1, "coroutine expected");
lua_pushstring(L, statnames[costatus(L, co)]); lua_pushstring(L, statnames[costatus(L, co)]);
...@@ -574,7 +574,7 @@ static int ICACHE_FLASH_ATTR luaB_costatus (lua_State *L) { ...@@ -574,7 +574,7 @@ static int ICACHE_FLASH_ATTR luaB_costatus (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR auxresume (lua_State *L, lua_State *co, int narg) { static int auxresume (lua_State *L, lua_State *co, int narg) {
int status = costatus(L, co); int status = costatus(L, co);
if (!lua_checkstack(co, narg)) if (!lua_checkstack(co, narg))
luaL_error(L, "too many arguments to resume"); luaL_error(L, "too many arguments to resume");
...@@ -599,7 +599,7 @@ static int ICACHE_FLASH_ATTR auxresume (lua_State *L, lua_State *co, int narg) { ...@@ -599,7 +599,7 @@ static int ICACHE_FLASH_ATTR auxresume (lua_State *L, lua_State *co, int narg) {
} }
static int ICACHE_FLASH_ATTR luaB_coresume (lua_State *L) { static int luaB_coresume (lua_State *L) {
lua_State *co = lua_tothread(L, 1); lua_State *co = lua_tothread(L, 1);
int r; int r;
luaL_argcheck(L, co, 1, "coroutine expected"); luaL_argcheck(L, co, 1, "coroutine expected");
...@@ -617,7 +617,7 @@ static int ICACHE_FLASH_ATTR luaB_coresume (lua_State *L) { ...@@ -617,7 +617,7 @@ static int ICACHE_FLASH_ATTR luaB_coresume (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_auxwrap (lua_State *L) { static int luaB_auxwrap (lua_State *L) {
lua_State *co = lua_tothread(L, lua_upvalueindex(1)); lua_State *co = lua_tothread(L, lua_upvalueindex(1));
int r = auxresume(L, co, lua_gettop(L)); int r = auxresume(L, co, lua_gettop(L));
if (r < 0) { if (r < 0) {
...@@ -632,7 +632,7 @@ static int ICACHE_FLASH_ATTR luaB_auxwrap (lua_State *L) { ...@@ -632,7 +632,7 @@ static int ICACHE_FLASH_ATTR luaB_auxwrap (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_cocreate (lua_State *L) { static int luaB_cocreate (lua_State *L) {
lua_State *NL = lua_newthread(L); lua_State *NL = lua_newthread(L);
luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1, luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 1,
"Lua function expected"); "Lua function expected");
...@@ -642,19 +642,19 @@ static int ICACHE_FLASH_ATTR luaB_cocreate (lua_State *L) { ...@@ -642,19 +642,19 @@ static int ICACHE_FLASH_ATTR luaB_cocreate (lua_State *L) {
} }
static int ICACHE_FLASH_ATTR luaB_cowrap (lua_State *L) { static int luaB_cowrap (lua_State *L) {
luaB_cocreate(L); luaB_cocreate(L);
lua_pushcclosure(L, luaB_auxwrap, 1); lua_pushcclosure(L, luaB_auxwrap, 1);
return 1; return 1;
} }
static int ICACHE_FLASH_ATTR luaB_yield (lua_State *L) { static int luaB_yield (lua_State *L) {
return lua_yield(L, lua_gettop(L)); return lua_yield(L, lua_gettop(L));
} }
static int ICACHE_FLASH_ATTR luaB_corunning (lua_State *L) { static int luaB_corunning (lua_State *L) {
if (lua_pushthread(L)) if (lua_pushthread(L))
lua_pushnil(L); /* main thread is not a coroutine */ lua_pushnil(L); /* main thread is not a coroutine */
return 1; return 1;
...@@ -676,7 +676,7 @@ const LUA_REG_TYPE co_funcs[] = { ...@@ -676,7 +676,7 @@ const LUA_REG_TYPE co_funcs[] = {
/* }====================================================== */ /* }====================================================== */
static void ICACHE_FLASH_ATTR auxopen (lua_State *L, const char *name, static void auxopen (lua_State *L, const char *name,
lua_CFunction f, lua_CFunction u) { lua_CFunction f, lua_CFunction u) {
lua_pushcfunction(L, u); lua_pushcfunction(L, u);
lua_pushcclosure(L, f, 1); lua_pushcclosure(L, f, 1);
...@@ -684,7 +684,7 @@ static void ICACHE_FLASH_ATTR auxopen (lua_State *L, const char *name, ...@@ -684,7 +684,7 @@ static void ICACHE_FLASH_ATTR auxopen (lua_State *L, const char *name,
} }
static void ICACHE_FLASH_ATTR base_open (lua_State *L) { static void base_open (lua_State *L) {
/* set global _G */ /* set global _G */
lua_pushvalue(L, LUA_GLOBALSINDEX); lua_pushvalue(L, LUA_GLOBALSINDEX);
lua_setglobal(L, "_G"); lua_setglobal(L, "_G");
...@@ -711,7 +711,7 @@ static void ICACHE_FLASH_ATTR base_open (lua_State *L) { ...@@ -711,7 +711,7 @@ static void ICACHE_FLASH_ATTR base_open (lua_State *L) {
} }
LUALIB_API int ICACHE_FLASH_ATTR luaopen_base (lua_State *L) { LUALIB_API int luaopen_base (lua_State *L) {
base_open(L); base_open(L);
#if LUA_OPTIMIZE_MEMORY == 0 #if LUA_OPTIMIZE_MEMORY == 0
luaL_register(L, LUA_COLIBNAME, co_funcs); luaL_register(L, LUA_COLIBNAME, co_funcs);
......
...@@ -27,12 +27,12 @@ ...@@ -27,12 +27,12 @@
#define hasjumps(e) ((e)->t != (e)->f) #define hasjumps(e) ((e)->t != (e)->f)
static int ICACHE_FLASH_ATTR isnumeral(expdesc *e) { static int isnumeral(expdesc *e) {
return (e->k == VKNUM && e->t == NO_JUMP && e->f == NO_JUMP); return (e->k == VKNUM && e->t == NO_JUMP && e->f == NO_JUMP);
} }
void ICACHE_FLASH_ATTR luaK_nil (FuncState *fs, int from, int n) { void luaK_nil (FuncState *fs, int from, int n) {
Instruction *previous; Instruction *previous;
if (fs->pc > fs->lasttarget) { /* no jumps to current position? */ if (fs->pc > fs->lasttarget) { /* no jumps to current position? */
if (fs->pc == 0) { /* function start? */ if (fs->pc == 0) { /* function start? */
...@@ -56,7 +56,7 @@ void ICACHE_FLASH_ATTR luaK_nil (FuncState *fs, int from, int n) { ...@@ -56,7 +56,7 @@ void ICACHE_FLASH_ATTR luaK_nil (FuncState *fs, int from, int n) {
} }
int ICACHE_FLASH_ATTR luaK_jump (FuncState *fs) { int luaK_jump (FuncState *fs) {
int jpc = fs->jpc; /* save list of jumps to here */ int jpc = fs->jpc; /* save list of jumps to here */
int j; int j;
fs->jpc = NO_JUMP; fs->jpc = NO_JUMP;
...@@ -66,18 +66,18 @@ int ICACHE_FLASH_ATTR luaK_jump (FuncState *fs) { ...@@ -66,18 +66,18 @@ int ICACHE_FLASH_ATTR luaK_jump (FuncState *fs) {
} }
void ICACHE_FLASH_ATTR luaK_ret (FuncState *fs, int first, int nret) { void luaK_ret (FuncState *fs, int first, int nret) {
luaK_codeABC(fs, OP_RETURN, first, nret+1, 0); luaK_codeABC(fs, OP_RETURN, first, nret+1, 0);
} }
static int ICACHE_FLASH_ATTR condjump (FuncState *fs, OpCode op, int A, int B, int C) { static int condjump (FuncState *fs, OpCode op, int A, int B, int C) {
luaK_codeABC(fs, op, A, B, C); luaK_codeABC(fs, op, A, B, C);
return luaK_jump(fs); return luaK_jump(fs);
} }
static void ICACHE_FLASH_ATTR fixjump (FuncState *fs, int pc, int dest) { static void fixjump (FuncState *fs, int pc, int dest) {
Instruction *jmp = &fs->f->code[pc]; Instruction *jmp = &fs->f->code[pc];
int offset = dest-(pc+1); int offset = dest-(pc+1);
lua_assert(dest != NO_JUMP); lua_assert(dest != NO_JUMP);
...@@ -91,13 +91,13 @@ static void ICACHE_FLASH_ATTR fixjump (FuncState *fs, int pc, int dest) { ...@@ -91,13 +91,13 @@ static void ICACHE_FLASH_ATTR fixjump (FuncState *fs, int pc, int dest) {
** returns current `pc' and marks it as a jump target (to avoid wrong ** returns current `pc' and marks it as a jump target (to avoid wrong
** optimizations with consecutive instructions not in the same basic block). ** optimizations with consecutive instructions not in the same basic block).
*/ */
int ICACHE_FLASH_ATTR luaK_getlabel (FuncState *fs) { int luaK_getlabel (FuncState *fs) {
fs->lasttarget = fs->pc; fs->lasttarget = fs->pc;
return fs->pc; return fs->pc;
} }
static int ICACHE_FLASH_ATTR getjump (FuncState *fs, int pc) { static int getjump (FuncState *fs, int pc) {
int offset = GETARG_sBx(fs->f->code[pc]); int offset = GETARG_sBx(fs->f->code[pc]);
if (offset == NO_JUMP) /* point to itself represents end of list */ if (offset == NO_JUMP) /* point to itself represents end of list */
return NO_JUMP; /* end of list */ return NO_JUMP; /* end of list */
...@@ -106,7 +106,7 @@ static int ICACHE_FLASH_ATTR getjump (FuncState *fs, int pc) { ...@@ -106,7 +106,7 @@ static int ICACHE_FLASH_ATTR getjump (FuncState *fs, int pc) {
} }
static Instruction *ICACHE_FLASH_ATTR getjumpcontrol (FuncState *fs, int pc) { static Instruction *getjumpcontrol (FuncState *fs, int pc) {
Instruction *pi = &fs->f->code[pc]; Instruction *pi = &fs->f->code[pc];
if (pc >= 1 && testTMode(GET_OPCODE(*(pi-1)))) if (pc >= 1 && testTMode(GET_OPCODE(*(pi-1))))
return pi-1; return pi-1;
...@@ -119,7 +119,7 @@ static Instruction *ICACHE_FLASH_ATTR getjumpcontrol (FuncState *fs, int pc) { ...@@ -119,7 +119,7 @@ static Instruction *ICACHE_FLASH_ATTR getjumpcontrol (FuncState *fs, int pc) {
** check whether list has any jump that do not produce a value ** check whether list has any jump that do not produce a value
** (or produce an inverted value) ** (or produce an inverted value)
*/ */
static int ICACHE_FLASH_ATTR need_value (FuncState *fs, int list) { static int need_value (FuncState *fs, int list) {
for (; list != NO_JUMP; list = getjump(fs, list)) { for (; list != NO_JUMP; list = getjump(fs, list)) {
Instruction i = *getjumpcontrol(fs, list); Instruction i = *getjumpcontrol(fs, list);
if (GET_OPCODE(i) != OP_TESTSET) return 1; if (GET_OPCODE(i) != OP_TESTSET) return 1;
...@@ -128,7 +128,7 @@ static int ICACHE_FLASH_ATTR need_value (FuncState *fs, int list) { ...@@ -128,7 +128,7 @@ static int ICACHE_FLASH_ATTR need_value (FuncState *fs, int list) {
} }
static int ICACHE_FLASH_ATTR patchtestreg (FuncState *fs, int node, int reg) { static int patchtestreg (FuncState *fs, int node, int reg) {
Instruction *i = getjumpcontrol(fs, node); Instruction *i = getjumpcontrol(fs, node);
if (GET_OPCODE(*i) != OP_TESTSET) if (GET_OPCODE(*i) != OP_TESTSET)
return 0; /* cannot patch other instructions */ return 0; /* cannot patch other instructions */
...@@ -141,13 +141,13 @@ static int ICACHE_FLASH_ATTR patchtestreg (FuncState *fs, int node, int reg) { ...@@ -141,13 +141,13 @@ static int ICACHE_FLASH_ATTR patchtestreg (FuncState *fs, int node, int reg) {
} }
static void ICACHE_FLASH_ATTR removevalues (FuncState *fs, int list) { static void removevalues (FuncState *fs, int list) {
for (; list != NO_JUMP; list = getjump(fs, list)) for (; list != NO_JUMP; list = getjump(fs, list))
patchtestreg(fs, list, NO_REG); patchtestreg(fs, list, NO_REG);
} }
static void ICACHE_FLASH_ATTR patchlistaux (FuncState *fs, int list, int vtarget, int reg, static void patchlistaux (FuncState *fs, int list, int vtarget, int reg,
int dtarget) { int dtarget) {
while (list != NO_JUMP) { while (list != NO_JUMP) {
int next = getjump(fs, list); int next = getjump(fs, list);
...@@ -160,13 +160,13 @@ static void ICACHE_FLASH_ATTR patchlistaux (FuncState *fs, int list, int vtarget ...@@ -160,13 +160,13 @@ static void ICACHE_FLASH_ATTR patchlistaux (FuncState *fs, int list, int vtarget
} }
static void ICACHE_FLASH_ATTR dischargejpc (FuncState *fs) { static void dischargejpc (FuncState *fs) {
patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc); patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc);
fs->jpc = NO_JUMP; fs->jpc = NO_JUMP;
} }
void ICACHE_FLASH_ATTR luaK_patchlist (FuncState *fs, int list, int target) { void luaK_patchlist (FuncState *fs, int list, int target) {
if (target == fs->pc) if (target == fs->pc)
luaK_patchtohere(fs, list); luaK_patchtohere(fs, list);
else { else {
...@@ -176,13 +176,13 @@ void ICACHE_FLASH_ATTR luaK_patchlist (FuncState *fs, int list, int target) { ...@@ -176,13 +176,13 @@ void ICACHE_FLASH_ATTR luaK_patchlist (FuncState *fs, int list, int target) {
} }
void ICACHE_FLASH_ATTR luaK_patchtohere (FuncState *fs, int list) { void luaK_patchtohere (FuncState *fs, int list) {
luaK_getlabel(fs); luaK_getlabel(fs);
luaK_concat(fs, &fs->jpc, list); luaK_concat(fs, &fs->jpc, list);
} }
void ICACHE_FLASH_ATTR luaK_concat (FuncState *fs, int *l1, int l2) { void luaK_concat (FuncState *fs, int *l1, int l2) {
if (l2 == NO_JUMP) return; if (l2 == NO_JUMP) return;
else if (*l1 == NO_JUMP) else if (*l1 == NO_JUMP)
*l1 = l2; *l1 = l2;
...@@ -196,7 +196,7 @@ void ICACHE_FLASH_ATTR luaK_concat (FuncState *fs, int *l1, int l2) { ...@@ -196,7 +196,7 @@ void ICACHE_FLASH_ATTR luaK_concat (FuncState *fs, int *l1, int l2) {
} }
void ICACHE_FLASH_ATTR luaK_checkstack (FuncState *fs, int n) { void luaK_checkstack (FuncState *fs, int n) {
int newstack = fs->freereg + n; int newstack = fs->freereg + n;
if (newstack > fs->f->maxstacksize) { if (newstack > fs->f->maxstacksize) {
if (newstack >= MAXSTACK) if (newstack >= MAXSTACK)
...@@ -206,13 +206,13 @@ void ICACHE_FLASH_ATTR luaK_checkstack (FuncState *fs, int n) { ...@@ -206,13 +206,13 @@ void ICACHE_FLASH_ATTR luaK_checkstack (FuncState *fs, int n) {
} }
void ICACHE_FLASH_ATTR luaK_reserveregs (FuncState *fs, int n) { void luaK_reserveregs (FuncState *fs, int n) {
luaK_checkstack(fs, n); luaK_checkstack(fs, n);
fs->freereg += n; fs->freereg += n;
} }
static void ICACHE_FLASH_ATTR freereg (FuncState *fs, int reg) { static void freereg (FuncState *fs, int reg) {
if (!ISK(reg) && reg >= fs->nactvar) { if (!ISK(reg) && reg >= fs->nactvar) {
fs->freereg--; fs->freereg--;
lua_assert(reg == fs->freereg); lua_assert(reg == fs->freereg);
...@@ -220,13 +220,13 @@ static void ICACHE_FLASH_ATTR freereg (FuncState *fs, int reg) { ...@@ -220,13 +220,13 @@ static void ICACHE_FLASH_ATTR freereg (FuncState *fs, int reg) {
} }
static void ICACHE_FLASH_ATTR freeexp (FuncState *fs, expdesc *e) { static void freeexp (FuncState *fs, expdesc *e) {
if (e->k == VNONRELOC) if (e->k == VNONRELOC)
freereg(fs, e->u.s.info); freereg(fs, e->u.s.info);
} }
static int ICACHE_FLASH_ATTR addk (FuncState *fs, TValue *k, TValue *v) { static int addk (FuncState *fs, TValue *k, TValue *v) {
lua_State *L = fs->L; lua_State *L = fs->L;
TValue *idx = luaH_set(L, fs->h, k); TValue *idx = luaH_set(L, fs->h, k);
Proto *f = fs->f; Proto *f = fs->f;
...@@ -247,28 +247,28 @@ static int ICACHE_FLASH_ATTR addk (FuncState *fs, TValue *k, TValue *v) { ...@@ -247,28 +247,28 @@ static int ICACHE_FLASH_ATTR addk (FuncState *fs, TValue *k, TValue *v) {
} }
int ICACHE_FLASH_ATTR luaK_stringK (FuncState *fs, TString *s) { int luaK_stringK (FuncState *fs, TString *s) {
TValue o; TValue o;
setsvalue(fs->L, &o, s); setsvalue(fs->L, &o, s);
return addk(fs, &o, &o); return addk(fs, &o, &o);
} }
int ICACHE_FLASH_ATTR luaK_numberK (FuncState *fs, lua_Number r) { int luaK_numberK (FuncState *fs, lua_Number r) {
TValue o; TValue o;
setnvalue(&o, r); setnvalue(&o, r);
return addk(fs, &o, &o); return addk(fs, &o, &o);
} }
static int ICACHE_FLASH_ATTR boolK (FuncState *fs, int b) { static int boolK (FuncState *fs, int b) {
TValue o; TValue o;
setbvalue(&o, b); setbvalue(&o, b);
return addk(fs, &o, &o); return addk(fs, &o, &o);
} }
static int ICACHE_FLASH_ATTR nilK (FuncState *fs) { static int nilK (FuncState *fs) {
TValue k, v; TValue k, v;
setnilvalue(&v); setnilvalue(&v);
/* cannot use nil as key; instead use table itself to represent nil */ /* cannot use nil as key; instead use table itself to represent nil */
...@@ -277,7 +277,7 @@ static int ICACHE_FLASH_ATTR nilK (FuncState *fs) { ...@@ -277,7 +277,7 @@ static int ICACHE_FLASH_ATTR nilK (FuncState *fs) {
} }
void ICACHE_FLASH_ATTR luaK_setreturns (FuncState *fs, expdesc *e, int nresults) { void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) {
if (e->k == VCALL) { /* expression is an open function call? */ if (e->k == VCALL) { /* expression is an open function call? */
SETARG_C(getcode(fs, e), nresults+1); SETARG_C(getcode(fs, e), nresults+1);
} }
...@@ -289,7 +289,7 @@ void ICACHE_FLASH_ATTR luaK_setreturns (FuncState *fs, expdesc *e, int nresults) ...@@ -289,7 +289,7 @@ void ICACHE_FLASH_ATTR luaK_setreturns (FuncState *fs, expdesc *e, int nresults)
} }
void ICACHE_FLASH_ATTR luaK_setoneret (FuncState *fs, expdesc *e) { void luaK_setoneret (FuncState *fs, expdesc *e) {
if (e->k == VCALL) { /* expression is an open function call? */ if (e->k == VCALL) { /* expression is an open function call? */
e->k = VNONRELOC; e->k = VNONRELOC;
e->u.s.info = GETARG_A(getcode(fs, e)); e->u.s.info = GETARG_A(getcode(fs, e));
...@@ -301,7 +301,7 @@ void ICACHE_FLASH_ATTR luaK_setoneret (FuncState *fs, expdesc *e) { ...@@ -301,7 +301,7 @@ void ICACHE_FLASH_ATTR luaK_setoneret (FuncState *fs, expdesc *e) {
} }
void ICACHE_FLASH_ATTR luaK_dischargevars (FuncState *fs, expdesc *e) { void luaK_dischargevars (FuncState *fs, expdesc *e) {
switch (e->k) { switch (e->k) {
case VLOCAL: { case VLOCAL: {
e->k = VNONRELOC; e->k = VNONRELOC;
...@@ -334,13 +334,13 @@ void ICACHE_FLASH_ATTR luaK_dischargevars (FuncState *fs, expdesc *e) { ...@@ -334,13 +334,13 @@ void ICACHE_FLASH_ATTR luaK_dischargevars (FuncState *fs, expdesc *e) {
} }
static int ICACHE_FLASH_ATTR code_label (FuncState *fs, int A, int b, int jump) { static int code_label (FuncState *fs, int A, int b, int jump) {
luaK_getlabel(fs); /* those instructions may be jump targets */ luaK_getlabel(fs); /* those instructions may be jump targets */
return luaK_codeABC(fs, OP_LOADBOOL, A, b, jump); return luaK_codeABC(fs, OP_LOADBOOL, A, b, jump);
} }
static void ICACHE_FLASH_ATTR discharge2reg (FuncState *fs, expdesc *e, int reg) { static void discharge2reg (FuncState *fs, expdesc *e, int reg) {
luaK_dischargevars(fs, e); luaK_dischargevars(fs, e);
switch (e->k) { switch (e->k) {
case VNIL: { case VNIL: {
...@@ -379,7 +379,7 @@ static void ICACHE_FLASH_ATTR discharge2reg (FuncState *fs, expdesc *e, int reg) ...@@ -379,7 +379,7 @@ static void ICACHE_FLASH_ATTR discharge2reg (FuncState *fs, expdesc *e, int reg)
} }
static void ICACHE_FLASH_ATTR discharge2anyreg (FuncState *fs, expdesc *e) { static void discharge2anyreg (FuncState *fs, expdesc *e) {
if (e->k != VNONRELOC) { if (e->k != VNONRELOC) {
luaK_reserveregs(fs, 1); luaK_reserveregs(fs, 1);
discharge2reg(fs, e, fs->freereg-1); discharge2reg(fs, e, fs->freereg-1);
...@@ -387,7 +387,7 @@ static void ICACHE_FLASH_ATTR discharge2anyreg (FuncState *fs, expdesc *e) { ...@@ -387,7 +387,7 @@ static void ICACHE_FLASH_ATTR discharge2anyreg (FuncState *fs, expdesc *e) {
} }
static void ICACHE_FLASH_ATTR exp2reg (FuncState *fs, expdesc *e, int reg) { static void exp2reg (FuncState *fs, expdesc *e, int reg) {
discharge2reg(fs, e, reg); discharge2reg(fs, e, reg);
if (e->k == VJMP) if (e->k == VJMP)
luaK_concat(fs, &e->t, e->u.s.info); /* put this jump in `t' list */ luaK_concat(fs, &e->t, e->u.s.info); /* put this jump in `t' list */
...@@ -411,7 +411,7 @@ static void ICACHE_FLASH_ATTR exp2reg (FuncState *fs, expdesc *e, int reg) { ...@@ -411,7 +411,7 @@ static void ICACHE_FLASH_ATTR exp2reg (FuncState *fs, expdesc *e, int reg) {
} }
void ICACHE_FLASH_ATTR luaK_exp2nextreg (FuncState *fs, expdesc *e) { void luaK_exp2nextreg (FuncState *fs, expdesc *e) {
luaK_dischargevars(fs, e); luaK_dischargevars(fs, e);
freeexp(fs, e); freeexp(fs, e);
luaK_reserveregs(fs, 1); luaK_reserveregs(fs, 1);
...@@ -419,7 +419,7 @@ void ICACHE_FLASH_ATTR luaK_exp2nextreg (FuncState *fs, expdesc *e) { ...@@ -419,7 +419,7 @@ void ICACHE_FLASH_ATTR luaK_exp2nextreg (FuncState *fs, expdesc *e) {
} }
int ICACHE_FLASH_ATTR luaK_exp2anyreg (FuncState *fs, expdesc *e) { int luaK_exp2anyreg (FuncState *fs, expdesc *e) {
luaK_dischargevars(fs, e); luaK_dischargevars(fs, e);
if (e->k == VNONRELOC) { if (e->k == VNONRELOC) {
if (!hasjumps(e)) return e->u.s.info; /* exp is already in a register */ if (!hasjumps(e)) return e->u.s.info; /* exp is already in a register */
...@@ -433,7 +433,7 @@ int ICACHE_FLASH_ATTR luaK_exp2anyreg (FuncState *fs, expdesc *e) { ...@@ -433,7 +433,7 @@ int ICACHE_FLASH_ATTR luaK_exp2anyreg (FuncState *fs, expdesc *e) {
} }
void ICACHE_FLASH_ATTR luaK_exp2val (FuncState *fs, expdesc *e) { void luaK_exp2val (FuncState *fs, expdesc *e) {
if (hasjumps(e)) if (hasjumps(e))
luaK_exp2anyreg(fs, e); luaK_exp2anyreg(fs, e);
else else
...@@ -441,7 +441,7 @@ void ICACHE_FLASH_ATTR luaK_exp2val (FuncState *fs, expdesc *e) { ...@@ -441,7 +441,7 @@ void ICACHE_FLASH_ATTR luaK_exp2val (FuncState *fs, expdesc *e) {
} }
int ICACHE_FLASH_ATTR luaK_exp2RK (FuncState *fs, expdesc *e) { int luaK_exp2RK (FuncState *fs, expdesc *e) {
luaK_exp2val(fs, e); luaK_exp2val(fs, e);
switch (e->k) { switch (e->k) {
case VKNUM: case VKNUM:
...@@ -469,7 +469,7 @@ int ICACHE_FLASH_ATTR luaK_exp2RK (FuncState *fs, expdesc *e) { ...@@ -469,7 +469,7 @@ int ICACHE_FLASH_ATTR luaK_exp2RK (FuncState *fs, expdesc *e) {
} }
void ICACHE_FLASH_ATTR luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) { void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) {
switch (var->k) { switch (var->k) {
case VLOCAL: { case VLOCAL: {
freeexp(fs, ex); freeexp(fs, ex);
...@@ -500,7 +500,7 @@ void ICACHE_FLASH_ATTR luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) ...@@ -500,7 +500,7 @@ void ICACHE_FLASH_ATTR luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex)
} }
void ICACHE_FLASH_ATTR luaK_self (FuncState *fs, expdesc *e, expdesc *key) { void luaK_self (FuncState *fs, expdesc *e, expdesc *key) {
int func; int func;
luaK_exp2anyreg(fs, e); luaK_exp2anyreg(fs, e);
freeexp(fs, e); freeexp(fs, e);
...@@ -513,7 +513,7 @@ void ICACHE_FLASH_ATTR luaK_self (FuncState *fs, expdesc *e, expdesc *key) { ...@@ -513,7 +513,7 @@ void ICACHE_FLASH_ATTR luaK_self (FuncState *fs, expdesc *e, expdesc *key) {
} }
static void ICACHE_FLASH_ATTR invertjump (FuncState *fs, expdesc *e) { static void invertjump (FuncState *fs, expdesc *e) {
Instruction *pc = getjumpcontrol(fs, e->u.s.info); Instruction *pc = getjumpcontrol(fs, e->u.s.info);
lua_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET && lua_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET &&
GET_OPCODE(*pc) != OP_TEST); GET_OPCODE(*pc) != OP_TEST);
...@@ -521,7 +521,7 @@ static void ICACHE_FLASH_ATTR invertjump (FuncState *fs, expdesc *e) { ...@@ -521,7 +521,7 @@ static void ICACHE_FLASH_ATTR invertjump (FuncState *fs, expdesc *e) {
} }
static int ICACHE_FLASH_ATTR jumponcond (FuncState *fs, expdesc *e, int cond) { static int jumponcond (FuncState *fs, expdesc *e, int cond) {
if (e->k == VRELOCABLE) { if (e->k == VRELOCABLE) {
Instruction ie = getcode(fs, e); Instruction ie = getcode(fs, e);
if (GET_OPCODE(ie) == OP_NOT) { if (GET_OPCODE(ie) == OP_NOT) {
...@@ -536,7 +536,7 @@ static int ICACHE_FLASH_ATTR jumponcond (FuncState *fs, expdesc *e, int cond) { ...@@ -536,7 +536,7 @@ static int ICACHE_FLASH_ATTR jumponcond (FuncState *fs, expdesc *e, int cond) {
} }
void ICACHE_FLASH_ATTR luaK_goiftrue (FuncState *fs, expdesc *e) { void luaK_goiftrue (FuncState *fs, expdesc *e) {
int pc; /* pc of last jump */ int pc; /* pc of last jump */
luaK_dischargevars(fs, e); luaK_dischargevars(fs, e);
switch (e->k) { switch (e->k) {
...@@ -560,7 +560,7 @@ void ICACHE_FLASH_ATTR luaK_goiftrue (FuncState *fs, expdesc *e) { ...@@ -560,7 +560,7 @@ void ICACHE_FLASH_ATTR luaK_goiftrue (FuncState *fs, expdesc *e) {
} }
static void ICACHE_FLASH_ATTR luaK_goiffalse (FuncState *fs, expdesc *e) { static void luaK_goiffalse (FuncState *fs, expdesc *e) {
int pc; /* pc of last jump */ int pc; /* pc of last jump */
luaK_dischargevars(fs, e); luaK_dischargevars(fs, e);
switch (e->k) { switch (e->k) {
...@@ -583,7 +583,7 @@ static void ICACHE_FLASH_ATTR luaK_goiffalse (FuncState *fs, expdesc *e) { ...@@ -583,7 +583,7 @@ static void ICACHE_FLASH_ATTR luaK_goiffalse (FuncState *fs, expdesc *e) {
} }
static void ICACHE_FLASH_ATTR codenot (FuncState *fs, expdesc *e) { static void codenot (FuncState *fs, expdesc *e) {
luaK_dischargevars(fs, e); luaK_dischargevars(fs, e);
switch (e->k) { switch (e->k) {
case VNIL: case VFALSE: { case VNIL: case VFALSE: {
...@@ -618,13 +618,13 @@ static void ICACHE_FLASH_ATTR codenot (FuncState *fs, expdesc *e) { ...@@ -618,13 +618,13 @@ static void ICACHE_FLASH_ATTR codenot (FuncState *fs, expdesc *e) {
} }
void ICACHE_FLASH_ATTR luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
t->u.s.aux = luaK_exp2RK(fs, k); t->u.s.aux = luaK_exp2RK(fs, k);
t->k = VINDEXED; t->k = VINDEXED;
} }
static int ICACHE_FLASH_ATTR constfolding (OpCode op, expdesc *e1, expdesc *e2) { static int constfolding (OpCode op, expdesc *e1, expdesc *e2) {
lua_Number v1, v2, r; lua_Number v1, v2, r;
if (!isnumeral(e1) || !isnumeral(e2)) return 0; if (!isnumeral(e1) || !isnumeral(e2)) return 0;
v1 = e1->u.nval; v1 = e1->u.nval;
...@@ -650,7 +650,7 @@ static int ICACHE_FLASH_ATTR constfolding (OpCode op, expdesc *e1, expdesc *e2) ...@@ -650,7 +650,7 @@ static int ICACHE_FLASH_ATTR constfolding (OpCode op, expdesc *e1, expdesc *e2)
} }
static void ICACHE_FLASH_ATTR codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) { static void codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) {
if (constfolding(op, e1, e2)) if (constfolding(op, e1, e2))
return; return;
else { else {
...@@ -670,7 +670,7 @@ static void ICACHE_FLASH_ATTR codearith (FuncState *fs, OpCode op, expdesc *e1, ...@@ -670,7 +670,7 @@ static void ICACHE_FLASH_ATTR codearith (FuncState *fs, OpCode op, expdesc *e1,
} }
static void ICACHE_FLASH_ATTR codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1, static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1,
expdesc *e2) { expdesc *e2) {
int o1 = luaK_exp2RK(fs, e1); int o1 = luaK_exp2RK(fs, e1);
int o2 = luaK_exp2RK(fs, e2); int o2 = luaK_exp2RK(fs, e2);
...@@ -686,7 +686,7 @@ static void ICACHE_FLASH_ATTR codecomp (FuncState *fs, OpCode op, int cond, expd ...@@ -686,7 +686,7 @@ static void ICACHE_FLASH_ATTR codecomp (FuncState *fs, OpCode op, int cond, expd
} }
void ICACHE_FLASH_ATTR luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) { void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
expdesc e2; expdesc e2;
e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0; e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
switch (op) { switch (op) {
...@@ -707,7 +707,7 @@ void ICACHE_FLASH_ATTR luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) { ...@@ -707,7 +707,7 @@ void ICACHE_FLASH_ATTR luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
} }
void ICACHE_FLASH_ATTR luaK_infix (FuncState *fs, BinOpr op, expdesc *v) { void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) {
switch (op) { switch (op) {
case OPR_AND: { case OPR_AND: {
luaK_goiftrue(fs, v); luaK_goiftrue(fs, v);
...@@ -734,7 +734,7 @@ void ICACHE_FLASH_ATTR luaK_infix (FuncState *fs, BinOpr op, expdesc *v) { ...@@ -734,7 +734,7 @@ void ICACHE_FLASH_ATTR luaK_infix (FuncState *fs, BinOpr op, expdesc *v) {
} }
void ICACHE_FLASH_ATTR luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) { void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) {
switch (op) { switch (op) {
case OPR_AND: { case OPR_AND: {
lua_assert(e1->t == NO_JUMP); /* list must be closed */ lua_assert(e1->t == NO_JUMP); /* list must be closed */
...@@ -781,12 +781,12 @@ void ICACHE_FLASH_ATTR luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expde ...@@ -781,12 +781,12 @@ void ICACHE_FLASH_ATTR luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expde
} }
void ICACHE_FLASH_ATTR luaK_fixline (FuncState *fs, int line) { void luaK_fixline (FuncState *fs, int line) {
fs->f->lineinfo[fs->pc - 1] = line; fs->f->lineinfo[fs->pc - 1] = line;
} }
static int ICACHE_FLASH_ATTR luaK_code (FuncState *fs, Instruction i, int line) { static int luaK_code (FuncState *fs, Instruction i, int line) {
Proto *f = fs->f; Proto *f = fs->f;
dischargejpc(fs); /* `pc' will change */ dischargejpc(fs); /* `pc' will change */
/* put new instruction in code array */ /* put new instruction in code array */
...@@ -801,7 +801,7 @@ static int ICACHE_FLASH_ATTR luaK_code (FuncState *fs, Instruction i, int line) ...@@ -801,7 +801,7 @@ static int ICACHE_FLASH_ATTR luaK_code (FuncState *fs, Instruction i, int line)
} }
int ICACHE_FLASH_ATTR luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) { int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) {
lua_assert(getOpMode(o) == iABC); lua_assert(getOpMode(o) == iABC);
lua_assert(getBMode(o) != OpArgN || b == 0); lua_assert(getBMode(o) != OpArgN || b == 0);
lua_assert(getCMode(o) != OpArgN || c == 0); lua_assert(getCMode(o) != OpArgN || c == 0);
...@@ -809,14 +809,14 @@ int ICACHE_FLASH_ATTR luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c ...@@ -809,14 +809,14 @@ int ICACHE_FLASH_ATTR luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c
} }
int ICACHE_FLASH_ATTR luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) { int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) {
lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx); lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx);
lua_assert(getCMode(o) == OpArgN); lua_assert(getCMode(o) == OpArgN);
return luaK_code(fs, CREATE_ABx(o, a, bc), fs->ls->lastline); return luaK_code(fs, CREATE_ABx(o, a, bc), fs->ls->lastline);
} }
void ICACHE_FLASH_ATTR luaK_setlist (FuncState *fs, int base, int nelems, int tostore) { void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) {
int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1; int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1;
int b = (tostore == LUA_MULTRET) ? 0 : tostore; int b = (tostore == LUA_MULTRET) ? 0 : tostore;
lua_assert(tostore != 0); lua_assert(tostore != 0);
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name); static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name);
static int ICACHE_FLASH_ATTR currentpc (lua_State *L, CallInfo *ci) { static int currentpc (lua_State *L, CallInfo *ci) {
if (!isLua(ci)) return -1; /* function is not a Lua function? */ if (!isLua(ci)) return -1; /* function is not a Lua function? */
if (ci == L->ci) if (ci == L->ci)
ci->savedpc = L->savedpc; ci->savedpc = L->savedpc;
...@@ -41,7 +41,7 @@ static int ICACHE_FLASH_ATTR currentpc (lua_State *L, CallInfo *ci) { ...@@ -41,7 +41,7 @@ static int ICACHE_FLASH_ATTR currentpc (lua_State *L, CallInfo *ci) {
} }
static int ICACHE_FLASH_ATTR currentline (lua_State *L, CallInfo *ci) { static int currentline (lua_State *L, CallInfo *ci) {
int pc = currentpc(L, ci); int pc = currentpc(L, ci);
if (pc < 0) if (pc < 0)
return -1; /* only active lua functions have current-line information */ return -1; /* only active lua functions have current-line information */
...@@ -53,7 +53,7 @@ static int ICACHE_FLASH_ATTR currentline (lua_State *L, CallInfo *ci) { ...@@ -53,7 +53,7 @@ static int ICACHE_FLASH_ATTR currentline (lua_State *L, CallInfo *ci) {
/* /*
** this function can be called asynchronous (e.g. during a signal) ** this function can be called asynchronous (e.g. during a signal)
*/ */
LUA_API int ICACHE_FLASH_ATTR lua_sethook (lua_State *L, lua_Hook func, int mask, int count) { LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count) {
if (func == NULL || mask == 0) { /* turn off hooks? */ if (func == NULL || mask == 0) { /* turn off hooks? */
mask = 0; mask = 0;
func = NULL; func = NULL;
...@@ -66,22 +66,22 @@ LUA_API int ICACHE_FLASH_ATTR lua_sethook (lua_State *L, lua_Hook func, int mask ...@@ -66,22 +66,22 @@ LUA_API int ICACHE_FLASH_ATTR lua_sethook (lua_State *L, lua_Hook func, int mask
} }
LUA_API lua_Hook ICACHE_FLASH_ATTR lua_gethook (lua_State *L) { LUA_API lua_Hook lua_gethook (lua_State *L) {
return L->hook; return L->hook;
} }
LUA_API int ICACHE_FLASH_ATTR lua_gethookmask (lua_State *L) { LUA_API int lua_gethookmask (lua_State *L) {
return L->hookmask; return L->hookmask;
} }
LUA_API int ICACHE_FLASH_ATTR lua_gethookcount (lua_State *L) { LUA_API int lua_gethookcount (lua_State *L) {
return L->basehookcount; return L->basehookcount;
} }
LUA_API int ICACHE_FLASH_ATTR lua_getstack (lua_State *L, int level, lua_Debug *ar) { LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) {
int status; int status;
CallInfo *ci; CallInfo *ci;
lua_lock(L); lua_lock(L);
...@@ -104,12 +104,12 @@ LUA_API int ICACHE_FLASH_ATTR lua_getstack (lua_State *L, int level, lua_Debug * ...@@ -104,12 +104,12 @@ LUA_API int ICACHE_FLASH_ATTR lua_getstack (lua_State *L, int level, lua_Debug *
} }
static Proto *ICACHE_FLASH_ATTR getluaproto (CallInfo *ci) { static Proto *getluaproto (CallInfo *ci) {
return (isLua(ci) ? ci_func(ci)->l.p : NULL); return (isLua(ci) ? ci_func(ci)->l.p : NULL);
} }
static const char *ICACHE_FLASH_ATTR findlocal (lua_State *L, CallInfo *ci, int n) { static const char *findlocal (lua_State *L, CallInfo *ci, int n) {
const char *name; const char *name;
Proto *fp = getluaproto(ci); Proto *fp = getluaproto(ci);
if (fp && (name = luaF_getlocalname(fp, n, currentpc(L, ci))) != NULL) if (fp && (name = luaF_getlocalname(fp, n, currentpc(L, ci))) != NULL)
...@@ -124,7 +124,7 @@ static const char *ICACHE_FLASH_ATTR findlocal (lua_State *L, CallInfo *ci, int ...@@ -124,7 +124,7 @@ static const char *ICACHE_FLASH_ATTR findlocal (lua_State *L, CallInfo *ci, int
} }
LUA_API const char *ICACHE_FLASH_ATTR lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) {
CallInfo *ci = L->base_ci + ar->i_ci; CallInfo *ci = L->base_ci + ar->i_ci;
const char *name = findlocal(L, ci, n); const char *name = findlocal(L, ci, n);
lua_lock(L); lua_lock(L);
...@@ -135,7 +135,7 @@ LUA_API const char *ICACHE_FLASH_ATTR lua_getlocal (lua_State *L, const lua_Debu ...@@ -135,7 +135,7 @@ LUA_API const char *ICACHE_FLASH_ATTR lua_getlocal (lua_State *L, const lua_Debu
} }
LUA_API const char *ICACHE_FLASH_ATTR lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) {
CallInfo *ci = L->base_ci + ar->i_ci; CallInfo *ci = L->base_ci + ar->i_ci;
const char *name = findlocal(L, ci, n); const char *name = findlocal(L, ci, n);
lua_lock(L); lua_lock(L);
...@@ -147,7 +147,7 @@ LUA_API const char *ICACHE_FLASH_ATTR lua_setlocal (lua_State *L, const lua_Debu ...@@ -147,7 +147,7 @@ LUA_API const char *ICACHE_FLASH_ATTR lua_setlocal (lua_State *L, const lua_Debu
} }
static void ICACHE_FLASH_ATTR funcinfo (lua_Debug *ar, Closure *cl, void *plight) { static void funcinfo (lua_Debug *ar, Closure *cl, void *plight) {
if (plight || cl->c.isC) { if (plight || cl->c.isC) {
ar->source = "=[C]"; ar->source = "=[C]";
ar->linedefined = -1; ar->linedefined = -1;
...@@ -164,7 +164,7 @@ static void ICACHE_FLASH_ATTR funcinfo (lua_Debug *ar, Closure *cl, void *plight ...@@ -164,7 +164,7 @@ static void ICACHE_FLASH_ATTR funcinfo (lua_Debug *ar, Closure *cl, void *plight
} }
static void ICACHE_FLASH_ATTR info_tailcall (lua_Debug *ar) { static void info_tailcall (lua_Debug *ar) {
ar->name = ar->namewhat = ""; ar->name = ar->namewhat = "";
ar->what = "tail"; ar->what = "tail";
ar->lastlinedefined = ar->linedefined = ar->currentline = -1; ar->lastlinedefined = ar->linedefined = ar->currentline = -1;
...@@ -174,7 +174,7 @@ static void ICACHE_FLASH_ATTR info_tailcall (lua_Debug *ar) { ...@@ -174,7 +174,7 @@ static void ICACHE_FLASH_ATTR info_tailcall (lua_Debug *ar) {
} }
static void ICACHE_FLASH_ATTR collectvalidlines (lua_State *L, Closure *f) { static void collectvalidlines (lua_State *L, Closure *f) {
if (f == NULL || f->c.isC) { if (f == NULL || f->c.isC) {
setnilvalue(L->top); setnilvalue(L->top);
} }
...@@ -190,7 +190,7 @@ static void ICACHE_FLASH_ATTR collectvalidlines (lua_State *L, Closure *f) { ...@@ -190,7 +190,7 @@ static void ICACHE_FLASH_ATTR collectvalidlines (lua_State *L, Closure *f) {
} }
static int ICACHE_FLASH_ATTR auxgetinfo (lua_State *L, const char *what, lua_Debug *ar, static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar,
Closure *f, void *plight, CallInfo *ci) { Closure *f, void *plight, CallInfo *ci) {
int status = 1; int status = 1;
if (plight == NULL && f == NULL) { if (plight == NULL && f == NULL) {
...@@ -229,7 +229,7 @@ static int ICACHE_FLASH_ATTR auxgetinfo (lua_State *L, const char *what, lua_Deb ...@@ -229,7 +229,7 @@ static int ICACHE_FLASH_ATTR auxgetinfo (lua_State *L, const char *what, lua_Deb
} }
LUA_API int ICACHE_FLASH_ATTR lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
int status; int status;
Closure *f = NULL; Closure *f = NULL;
CallInfo *ci = NULL; CallInfo *ci = NULL;
...@@ -284,7 +284,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_getinfo (lua_State *L, const char *what, lua_D ...@@ -284,7 +284,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_getinfo (lua_State *L, const char *what, lua_D
static int ICACHE_FLASH_ATTR precheck (const Proto *pt) { static int precheck (const Proto *pt) {
check(pt->maxstacksize <= MAXSTACK); check(pt->maxstacksize <= MAXSTACK);
check(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize); check(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize);
check(!(pt->is_vararg & VARARG_NEEDSARG) || check(!(pt->is_vararg & VARARG_NEEDSARG) ||
...@@ -298,7 +298,7 @@ static int ICACHE_FLASH_ATTR precheck (const Proto *pt) { ...@@ -298,7 +298,7 @@ static int ICACHE_FLASH_ATTR precheck (const Proto *pt) {
#define checkopenop(pt,pc) luaG_checkopenop((pt)->code[(pc)+1]) #define checkopenop(pt,pc) luaG_checkopenop((pt)->code[(pc)+1])
int ICACHE_FLASH_ATTR luaG_checkopenop (Instruction i) { int luaG_checkopenop (Instruction i) {
switch (GET_OPCODE(i)) { switch (GET_OPCODE(i)) {
case OP_CALL: case OP_CALL:
case OP_TAILCALL: case OP_TAILCALL:
...@@ -312,7 +312,7 @@ int ICACHE_FLASH_ATTR luaG_checkopenop (Instruction i) { ...@@ -312,7 +312,7 @@ int ICACHE_FLASH_ATTR luaG_checkopenop (Instruction i) {
} }
static int ICACHE_FLASH_ATTR checkArgMode (const Proto *pt, int r, enum OpArgMask mode) { static int checkArgMode (const Proto *pt, int r, enum OpArgMask mode) {
switch (mode) { switch (mode) {
case OpArgN: check(r == 0); break; case OpArgN: check(r == 0); break;
case OpArgU: break; case OpArgU: break;
...@@ -325,7 +325,7 @@ static int ICACHE_FLASH_ATTR checkArgMode (const Proto *pt, int r, enum OpArgMas ...@@ -325,7 +325,7 @@ static int ICACHE_FLASH_ATTR checkArgMode (const Proto *pt, int r, enum OpArgMas
} }
static Instruction ICACHE_FLASH_ATTR symbexec (const Proto *pt, int lastpc, int reg) { static Instruction symbexec (const Proto *pt, int lastpc, int reg) {
int pc; int pc;
int last; /* stores position of last instruction that changed `reg' */ int last; /* stores position of last instruction that changed `reg' */
last = pt->sizecode-1; /* points to final return (a `neutral' instruction) */ last = pt->sizecode-1; /* points to final return (a `neutral' instruction) */
...@@ -492,12 +492,12 @@ static Instruction ICACHE_FLASH_ATTR symbexec (const Proto *pt, int lastpc, int ...@@ -492,12 +492,12 @@ static Instruction ICACHE_FLASH_ATTR symbexec (const Proto *pt, int lastpc, int
/* }====================================================== */ /* }====================================================== */
int ICACHE_FLASH_ATTR luaG_checkcode (const Proto *pt) { int luaG_checkcode (const Proto *pt) {
return (symbexec(pt, pt->sizecode, NO_REG) != 0); return (symbexec(pt, pt->sizecode, NO_REG) != 0);
} }
static const char *ICACHE_FLASH_ATTR kname (Proto *p, int c) { static const char *kname (Proto *p, int c) {
if (ISK(c) && ttisstring(&p->k[INDEXK(c)])) if (ISK(c) && ttisstring(&p->k[INDEXK(c)]))
return svalue(&p->k[INDEXK(c)]); return svalue(&p->k[INDEXK(c)]);
else else
...@@ -505,7 +505,7 @@ static const char *ICACHE_FLASH_ATTR kname (Proto *p, int c) { ...@@ -505,7 +505,7 @@ static const char *ICACHE_FLASH_ATTR kname (Proto *p, int c) {
} }
static const char *ICACHE_FLASH_ATTR getobjname (lua_State *L, CallInfo *ci, int stackpos, static const char *getobjname (lua_State *L, CallInfo *ci, int stackpos,
const char **name) { const char **name) {
if (isLua(ci)) { /* a Lua function? */ if (isLua(ci)) { /* a Lua function? */
Proto *p = ci_func(ci)->l.p; Proto *p = ci_func(ci)->l.p;
...@@ -552,7 +552,7 @@ static const char *ICACHE_FLASH_ATTR getobjname (lua_State *L, CallInfo *ci, int ...@@ -552,7 +552,7 @@ static const char *ICACHE_FLASH_ATTR getobjname (lua_State *L, CallInfo *ci, int
} }
static const char *ICACHE_FLASH_ATTR getfuncname (lua_State *L, CallInfo *ci, const char **name) { static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) {
Instruction i; Instruction i;
if ((isLua(ci) && ci->tailcalls > 0) || !isLua(ci - 1)) if ((isLua(ci) && ci->tailcalls > 0) || !isLua(ci - 1))
return NULL; /* calling function is not Lua (or is unknown) */ return NULL; /* calling function is not Lua (or is unknown) */
...@@ -567,7 +567,7 @@ static const char *ICACHE_FLASH_ATTR getfuncname (lua_State *L, CallInfo *ci, co ...@@ -567,7 +567,7 @@ static const char *ICACHE_FLASH_ATTR getfuncname (lua_State *L, CallInfo *ci, co
/* only ANSI way to check whether a pointer points to an array */ /* only ANSI way to check whether a pointer points to an array */
static int ICACHE_FLASH_ATTR isinstack (CallInfo *ci, const TValue *o) { static int isinstack (CallInfo *ci, const TValue *o) {
StkId p; StkId p;
for (p = ci->base; p < ci->top; p++) for (p = ci->base; p < ci->top; p++)
if (o == p) return 1; if (o == p) return 1;
...@@ -575,7 +575,7 @@ static int ICACHE_FLASH_ATTR isinstack (CallInfo *ci, const TValue *o) { ...@@ -575,7 +575,7 @@ static int ICACHE_FLASH_ATTR isinstack (CallInfo *ci, const TValue *o) {
} }
void ICACHE_FLASH_ATTR luaG_typeerror (lua_State *L, const TValue *o, const char *op) { void luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
const char *name = NULL; const char *name = NULL;
const char *t = luaT_typenames[ttype(o)]; const char *t = luaT_typenames[ttype(o)];
const char *kind = (isinstack(L->ci, o)) ? const char *kind = (isinstack(L->ci, o)) ?
...@@ -589,14 +589,14 @@ void ICACHE_FLASH_ATTR luaG_typeerror (lua_State *L, const TValue *o, const char ...@@ -589,14 +589,14 @@ void ICACHE_FLASH_ATTR luaG_typeerror (lua_State *L, const TValue *o, const char
} }
void ICACHE_FLASH_ATTR luaG_concaterror (lua_State *L, StkId p1, StkId p2) { void luaG_concaterror (lua_State *L, StkId p1, StkId p2) {
if (ttisstring(p1) || ttisnumber(p1)) p1 = p2; if (ttisstring(p1) || ttisnumber(p1)) p1 = p2;
lua_assert(!ttisstring(p1) && !ttisnumber(p1)); lua_assert(!ttisstring(p1) && !ttisnumber(p1));
luaG_typeerror(L, p1, "concatenate"); luaG_typeerror(L, p1, "concatenate");
} }
void ICACHE_FLASH_ATTR luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) { void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) {
TValue temp; TValue temp;
if (luaV_tonumber(p1, &temp) == NULL) if (luaV_tonumber(p1, &temp) == NULL)
p2 = p1; /* first operand is wrong */ p2 = p1; /* first operand is wrong */
...@@ -604,7 +604,7 @@ void ICACHE_FLASH_ATTR luaG_aritherror (lua_State *L, const TValue *p1, const TV ...@@ -604,7 +604,7 @@ void ICACHE_FLASH_ATTR luaG_aritherror (lua_State *L, const TValue *p1, const TV
} }
int ICACHE_FLASH_ATTR luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) { int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
const char *t1 = luaT_typenames[ttype(p1)]; const char *t1 = luaT_typenames[ttype(p1)];
const char *t2 = luaT_typenames[ttype(p2)]; const char *t2 = luaT_typenames[ttype(p2)];
if (t1[2] == t2[2]) if (t1[2] == t2[2])
...@@ -615,7 +615,7 @@ int ICACHE_FLASH_ATTR luaG_ordererror (lua_State *L, const TValue *p1, const TVa ...@@ -615,7 +615,7 @@ int ICACHE_FLASH_ATTR luaG_ordererror (lua_State *L, const TValue *p1, const TVa
} }
static void ICACHE_FLASH_ATTR addinfo (lua_State *L, const char *msg) { static void addinfo (lua_State *L, const char *msg) {
CallInfo *ci = L->ci; CallInfo *ci = L->ci;
if (isLua(ci)) { /* is Lua code? */ if (isLua(ci)) { /* is Lua code? */
char buff[LUA_IDSIZE]; /* add file:line information */ char buff[LUA_IDSIZE]; /* add file:line information */
...@@ -626,7 +626,7 @@ static void ICACHE_FLASH_ATTR addinfo (lua_State *L, const char *msg) { ...@@ -626,7 +626,7 @@ static void ICACHE_FLASH_ATTR addinfo (lua_State *L, const char *msg) {
} }
void ICACHE_FLASH_ATTR luaG_errormsg (lua_State *L) { void luaG_errormsg (lua_State *L) {
if (L->errfunc != 0) { /* is there an error handling function? */ if (L->errfunc != 0) { /* is there an error handling function? */
StkId errfunc = restorestack(L, L->errfunc); StkId errfunc = restorestack(L, L->errfunc);
if (!ttisfunction(errfunc) && !ttislightfunction(errfunc)) luaD_throw(L, LUA_ERRERR); if (!ttisfunction(errfunc) && !ttislightfunction(errfunc)) luaD_throw(L, LUA_ERRERR);
...@@ -639,7 +639,7 @@ void ICACHE_FLASH_ATTR luaG_errormsg (lua_State *L) { ...@@ -639,7 +639,7 @@ void ICACHE_FLASH_ATTR luaG_errormsg (lua_State *L) {
} }
void ICACHE_FLASH_ATTR luaG_runerror (lua_State *L, const char *fmt, ...) { void luaG_runerror (lua_State *L, const char *fmt, ...) {
va_list argp; va_list argp;
va_start(argp, fmt); va_start(argp, fmt);
addinfo(L, luaO_pushvfstring(L, fmt, argp)); addinfo(L, luaO_pushvfstring(L, fmt, argp));
......
...@@ -48,7 +48,7 @@ struct lua_longjmp { ...@@ -48,7 +48,7 @@ struct lua_longjmp {
}; };
void ICACHE_FLASH_ATTR luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) { void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) {
switch (errcode) { switch (errcode) {
case LUA_ERRMEM: { case LUA_ERRMEM: {
ptrdiff_t oldtopr = savestack(L, oldtop); ptrdiff_t oldtopr = savestack(L, oldtop);
...@@ -70,7 +70,7 @@ void ICACHE_FLASH_ATTR luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop ...@@ -70,7 +70,7 @@ void ICACHE_FLASH_ATTR luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop
} }
static void ICACHE_FLASH_ATTR restore_stack_limit (lua_State *L) { static void restore_stack_limit (lua_State *L) {
lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1); lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1);
if (L->size_ci > LUAI_MAXCALLS) { /* there was an overflow? */ if (L->size_ci > LUAI_MAXCALLS) { /* there was an overflow? */
int inuse = cast_int(L->ci - L->base_ci); int inuse = cast_int(L->ci - L->base_ci);
...@@ -80,7 +80,7 @@ static void ICACHE_FLASH_ATTR restore_stack_limit (lua_State *L) { ...@@ -80,7 +80,7 @@ static void ICACHE_FLASH_ATTR restore_stack_limit (lua_State *L) {
} }
static void ICACHE_FLASH_ATTR resetstack (lua_State *L, int status) { static void resetstack (lua_State *L, int status) {
L->ci = L->base_ci; L->ci = L->base_ci;
L->base = L->ci->base; L->base = L->ci->base;
luaF_close(L, L->base); /* close eventual pending closures */ luaF_close(L, L->base); /* close eventual pending closures */
...@@ -93,7 +93,7 @@ static void ICACHE_FLASH_ATTR resetstack (lua_State *L, int status) { ...@@ -93,7 +93,7 @@ static void ICACHE_FLASH_ATTR resetstack (lua_State *L, int status) {
} }
void ICACHE_FLASH_ATTR luaD_throw (lua_State *L, int errcode) { void luaD_throw (lua_State *L, int errcode) {
unfixedstack(L); /* make sure the fixedstack & block_gc flags get reset. */ unfixedstack(L); /* make sure the fixedstack & block_gc flags get reset. */
unset_block_gc(L); unset_block_gc(L);
if (L->errorJmp) { if (L->errorJmp) {
...@@ -112,7 +112,7 @@ void ICACHE_FLASH_ATTR luaD_throw (lua_State *L, int errcode) { ...@@ -112,7 +112,7 @@ void ICACHE_FLASH_ATTR luaD_throw (lua_State *L, int errcode) {
} }
int ICACHE_FLASH_ATTR luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) {
struct lua_longjmp lj; struct lua_longjmp lj;
lj.status = 0; lj.status = 0;
lj.previous = L->errorJmp; /* chain new error handler */ lj.previous = L->errorJmp; /* chain new error handler */
...@@ -127,7 +127,7 @@ int ICACHE_FLASH_ATTR luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) { ...@@ -127,7 +127,7 @@ int ICACHE_FLASH_ATTR luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) {
/* }====================================================== */ /* }====================================================== */
static void ICACHE_FLASH_ATTR correctstack (lua_State *L, TValue *oldstack) { static void correctstack (lua_State *L, TValue *oldstack) {
CallInfo *ci; CallInfo *ci;
GCObject *up; GCObject *up;
L->top = (L->top - oldstack) + L->stack; L->top = (L->top - oldstack) + L->stack;
...@@ -142,7 +142,7 @@ static void ICACHE_FLASH_ATTR correctstack (lua_State *L, TValue *oldstack) { ...@@ -142,7 +142,7 @@ static void ICACHE_FLASH_ATTR correctstack (lua_State *L, TValue *oldstack) {
} }
void ICACHE_FLASH_ATTR luaD_reallocstack (lua_State *L, int newsize) { void luaD_reallocstack (lua_State *L, int newsize) {
TValue *oldstack = L->stack; TValue *oldstack = L->stack;
int realsize = newsize + 1 + EXTRA_STACK; int realsize = newsize + 1 + EXTRA_STACK;
lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1); lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1);
...@@ -153,7 +153,7 @@ void ICACHE_FLASH_ATTR luaD_reallocstack (lua_State *L, int newsize) { ...@@ -153,7 +153,7 @@ void ICACHE_FLASH_ATTR luaD_reallocstack (lua_State *L, int newsize) {
} }
void ICACHE_FLASH_ATTR luaD_reallocCI (lua_State *L, int newsize) { void luaD_reallocCI (lua_State *L, int newsize) {
CallInfo *oldci = L->base_ci; CallInfo *oldci = L->base_ci;
luaM_reallocvector(L, L->base_ci, L->size_ci, newsize, CallInfo); luaM_reallocvector(L, L->base_ci, L->size_ci, newsize, CallInfo);
L->size_ci = newsize; L->size_ci = newsize;
...@@ -162,7 +162,7 @@ void ICACHE_FLASH_ATTR luaD_reallocCI (lua_State *L, int newsize) { ...@@ -162,7 +162,7 @@ void ICACHE_FLASH_ATTR luaD_reallocCI (lua_State *L, int newsize) {
} }
void ICACHE_FLASH_ATTR luaD_growstack (lua_State *L, int n) { void luaD_growstack (lua_State *L, int n) {
if (n <= L->stacksize) /* double size is enough? */ if (n <= L->stacksize) /* double size is enough? */
luaD_reallocstack(L, 2*L->stacksize); luaD_reallocstack(L, 2*L->stacksize);
else else
...@@ -170,7 +170,7 @@ void ICACHE_FLASH_ATTR luaD_growstack (lua_State *L, int n) { ...@@ -170,7 +170,7 @@ void ICACHE_FLASH_ATTR luaD_growstack (lua_State *L, int n) {
} }
static CallInfo *ICACHE_FLASH_ATTR growCI (lua_State *L) { static CallInfo *growCI (lua_State *L) {
if (L->size_ci > LUAI_MAXCALLS) /* overflow while handling overflow? */ if (L->size_ci > LUAI_MAXCALLS) /* overflow while handling overflow? */
luaD_throw(L, LUA_ERRERR); luaD_throw(L, LUA_ERRERR);
else { else {
...@@ -182,7 +182,7 @@ static CallInfo *ICACHE_FLASH_ATTR growCI (lua_State *L) { ...@@ -182,7 +182,7 @@ static CallInfo *ICACHE_FLASH_ATTR growCI (lua_State *L) {
} }
void ICACHE_FLASH_ATTR luaD_callhook (lua_State *L, int event, int line) { void luaD_callhook (lua_State *L, int event, int line) {
lua_Hook hook = L->hook; lua_Hook hook = L->hook;
if (hook && L->allowhook) { if (hook && L->allowhook) {
ptrdiff_t top = savestack(L, L->top); ptrdiff_t top = savestack(L, L->top);
...@@ -209,7 +209,7 @@ void ICACHE_FLASH_ATTR luaD_callhook (lua_State *L, int event, int line) { ...@@ -209,7 +209,7 @@ void ICACHE_FLASH_ATTR luaD_callhook (lua_State *L, int event, int line) {
} }
static StkId ICACHE_FLASH_ATTR adjust_varargs (lua_State *L, Proto *p, int actual) { static StkId adjust_varargs (lua_State *L, Proto *p, int actual) {
int i; int i;
int nfixargs = p->numparams; int nfixargs = p->numparams;
#if defined(LUA_COMPAT_VARARG) #if defined(LUA_COMPAT_VARARG)
...@@ -253,7 +253,7 @@ static StkId ICACHE_FLASH_ATTR adjust_varargs (lua_State *L, Proto *p, int actua ...@@ -253,7 +253,7 @@ static StkId ICACHE_FLASH_ATTR adjust_varargs (lua_State *L, Proto *p, int actua
} }
static StkId ICACHE_FLASH_ATTR tryfuncTM (lua_State *L, StkId func) { static StkId tryfuncTM (lua_State *L, StkId func) {
const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL); const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL);
StkId p; StkId p;
ptrdiff_t funcr = savestack(L, func); ptrdiff_t funcr = savestack(L, func);
...@@ -274,7 +274,7 @@ static StkId ICACHE_FLASH_ATTR tryfuncTM (lua_State *L, StkId func) { ...@@ -274,7 +274,7 @@ static StkId ICACHE_FLASH_ATTR tryfuncTM (lua_State *L, StkId func) {
(condhardstacktests(luaD_reallocCI(L, L->size_ci)), ++L->ci)) (condhardstacktests(luaD_reallocCI(L, L->size_ci)), ++L->ci))
int ICACHE_FLASH_ATTR luaD_precall (lua_State *L, StkId func, int nresults) { int luaD_precall (lua_State *L, StkId func, int nresults) {
ptrdiff_t funcr; ptrdiff_t funcr;
LClosure *cl = NULL; LClosure *cl = NULL;
if (!ttisfunction(func) && !ttislightfunction(func)) /* `func' is not a function? */ if (!ttisfunction(func) && !ttislightfunction(func)) /* `func' is not a function? */
...@@ -345,7 +345,7 @@ int ICACHE_FLASH_ATTR luaD_precall (lua_State *L, StkId func, int nresults) { ...@@ -345,7 +345,7 @@ int ICACHE_FLASH_ATTR luaD_precall (lua_State *L, StkId func, int nresults) {
} }
static StkId ICACHE_FLASH_ATTR callrethooks (lua_State *L, StkId firstResult) { static StkId callrethooks (lua_State *L, StkId firstResult) {
ptrdiff_t fr = savestack(L, firstResult); /* next call may change stack */ ptrdiff_t fr = savestack(L, firstResult); /* next call may change stack */
luaD_callhook(L, LUA_HOOKRET, -1); luaD_callhook(L, LUA_HOOKRET, -1);
if (f_isLua(L->ci)) { /* Lua function? */ if (f_isLua(L->ci)) { /* Lua function? */
...@@ -356,7 +356,7 @@ static StkId ICACHE_FLASH_ATTR callrethooks (lua_State *L, StkId firstResult) { ...@@ -356,7 +356,7 @@ static StkId ICACHE_FLASH_ATTR callrethooks (lua_State *L, StkId firstResult) {
} }
int ICACHE_FLASH_ATTR luaD_poscall (lua_State *L, StkId firstResult) { int luaD_poscall (lua_State *L, StkId firstResult) {
StkId res; StkId res;
int wanted, i; int wanted, i;
CallInfo *ci; CallInfo *ci;
...@@ -383,7 +383,7 @@ int ICACHE_FLASH_ATTR luaD_poscall (lua_State *L, StkId firstResult) { ...@@ -383,7 +383,7 @@ int ICACHE_FLASH_ATTR luaD_poscall (lua_State *L, StkId firstResult) {
** When returns, all the results are on the stack, starting at the original ** When returns, all the results are on the stack, starting at the original
** function position. ** function position.
*/ */
void ICACHE_FLASH_ATTR luaD_call (lua_State *L, StkId func, int nResults) { void luaD_call (lua_State *L, StkId func, int nResults) {
if (++L->nCcalls >= LUAI_MAXCCALLS) { if (++L->nCcalls >= LUAI_MAXCCALLS) {
if (L->nCcalls == LUAI_MAXCCALLS) if (L->nCcalls == LUAI_MAXCCALLS)
luaG_runerror(L, "C stack overflow"); luaG_runerror(L, "C stack overflow");
...@@ -397,7 +397,7 @@ void ICACHE_FLASH_ATTR luaD_call (lua_State *L, StkId func, int nResults) { ...@@ -397,7 +397,7 @@ void ICACHE_FLASH_ATTR luaD_call (lua_State *L, StkId func, int nResults) {
} }
static void ICACHE_FLASH_ATTR resume (lua_State *L, void *ud) { static void resume (lua_State *L, void *ud) {
StkId firstArg = cast(StkId, ud); StkId firstArg = cast(StkId, ud);
CallInfo *ci = L->ci; CallInfo *ci = L->ci;
if (L->status == 0) { /* start coroutine? */ if (L->status == 0) { /* start coroutine? */
...@@ -422,7 +422,7 @@ static void ICACHE_FLASH_ATTR resume (lua_State *L, void *ud) { ...@@ -422,7 +422,7 @@ static void ICACHE_FLASH_ATTR resume (lua_State *L, void *ud) {
} }
static int ICACHE_FLASH_ATTR resume_error (lua_State *L, const char *msg) { static int resume_error (lua_State *L, const char *msg) {
L->top = L->ci->base; L->top = L->ci->base;
setsvalue2s(L, L->top, luaS_new(L, msg)); setsvalue2s(L, L->top, luaS_new(L, msg));
incr_top(L); incr_top(L);
...@@ -431,7 +431,7 @@ static int ICACHE_FLASH_ATTR resume_error (lua_State *L, const char *msg) { ...@@ -431,7 +431,7 @@ static int ICACHE_FLASH_ATTR resume_error (lua_State *L, const char *msg) {
} }
LUA_API int ICACHE_FLASH_ATTR lua_resume (lua_State *L, int nargs) { LUA_API int lua_resume (lua_State *L, int nargs) {
int status; int status;
lua_lock(L); lua_lock(L);
if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci)) if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci))
...@@ -457,7 +457,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_resume (lua_State *L, int nargs) { ...@@ -457,7 +457,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_resume (lua_State *L, int nargs) {
} }
LUA_API int ICACHE_FLASH_ATTR lua_yield (lua_State *L, int nresults) { LUA_API int lua_yield (lua_State *L, int nresults) {
luai_userstateyield(L, nresults); luai_userstateyield(L, nresults);
lua_lock(L); lua_lock(L);
if (L->nCcalls > L->baseCcalls) if (L->nCcalls > L->baseCcalls)
...@@ -469,7 +469,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_yield (lua_State *L, int nresults) { ...@@ -469,7 +469,7 @@ LUA_API int ICACHE_FLASH_ATTR lua_yield (lua_State *L, int nresults) {
} }
int ICACHE_FLASH_ATTR luaD_pcall (lua_State *L, Pfunc func, void *u, int luaD_pcall (lua_State *L, Pfunc func, void *u,
ptrdiff_t old_top, ptrdiff_t ef) { ptrdiff_t old_top, ptrdiff_t ef) {
int status; int status;
unsigned short oldnCcalls = L->nCcalls; unsigned short oldnCcalls = L->nCcalls;
...@@ -504,7 +504,7 @@ struct SParser { /* data to `f_parser' */ ...@@ -504,7 +504,7 @@ struct SParser { /* data to `f_parser' */
const char *name; const char *name;
}; };
static void ICACHE_FLASH_ATTR f_parser (lua_State *L, void *ud) { static void f_parser (lua_State *L, void *ud) {
int i; int i;
Proto *tf; Proto *tf;
Closure *cl; Closure *cl;
...@@ -524,7 +524,7 @@ static void ICACHE_FLASH_ATTR f_parser (lua_State *L, void *ud) { ...@@ -524,7 +524,7 @@ static void ICACHE_FLASH_ATTR f_parser (lua_State *L, void *ud) {
} }
int ICACHE_FLASH_ATTR luaD_protectedparser (lua_State *L, ZIO *z, const char *name) { int luaD_protectedparser (lua_State *L, ZIO *z, const char *name) {
struct SParser p; struct SParser p;
int status; int status;
p.z = z; p.name = name; p.z = z; p.name = name;
......
...@@ -29,7 +29,7 @@ typedef struct { ...@@ -29,7 +29,7 @@ typedef struct {
#define DumpMem(b,n,size,D) DumpBlock(b,(n)*(size),D) #define DumpMem(b,n,size,D) DumpBlock(b,(n)*(size),D)
#define DumpVar(x,D) DumpMem(&x,1,sizeof(x),D) #define DumpVar(x,D) DumpMem(&x,1,sizeof(x),D)
static void ICACHE_FLASH_ATTR DumpBlock(const void* b, size_t size, DumpState* D) static void DumpBlock(const void* b, size_t size, DumpState* D)
{ {
if (D->status==0) if (D->status==0)
{ {
...@@ -40,19 +40,19 @@ static void ICACHE_FLASH_ATTR DumpBlock(const void* b, size_t size, DumpState* D ...@@ -40,19 +40,19 @@ static void ICACHE_FLASH_ATTR DumpBlock(const void* b, size_t size, DumpState* D
} }
} }
static void ICACHE_FLASH_ATTR DumpChar(int y, DumpState* D) static void DumpChar(int y, DumpState* D)
{ {
char x=(char)y; char x=(char)y;
DumpVar(x,D); DumpVar(x,D);
} }
static void ICACHE_FLASH_ATTR Align4(DumpState *D) static void Align4(DumpState *D)
{ {
while(D->wrote&3) while(D->wrote&3)
DumpChar(0,D); DumpChar(0,D);
} }
static void ICACHE_FLASH_ATTR MaybeByteSwap(char *number, size_t numbersize, DumpState *D) static void MaybeByteSwap(char *number, size_t numbersize, DumpState *D)
{ {
int x=1; int x=1;
int platform_little_endian = *(char*)&x; int platform_little_endian = *(char*)&x;
...@@ -68,7 +68,7 @@ static void ICACHE_FLASH_ATTR MaybeByteSwap(char *number, size_t numbersize, Dum ...@@ -68,7 +68,7 @@ static void ICACHE_FLASH_ATTR MaybeByteSwap(char *number, size_t numbersize, Dum
} }
} }
static void ICACHE_FLASH_ATTR DumpIntWithSize(int x, int sizeof_int, DumpState* D) static void DumpIntWithSize(int x, int sizeof_int, DumpState* D)
{ {
/* dump signed integer */ /* dump signed integer */
switch(sizeof_int) { switch(sizeof_int) {
...@@ -93,12 +93,12 @@ static void ICACHE_FLASH_ATTR DumpIntWithSize(int x, int sizeof_int, DumpState* ...@@ -93,12 +93,12 @@ static void ICACHE_FLASH_ATTR DumpIntWithSize(int x, int sizeof_int, DumpState*
} }
} }
static void ICACHE_FLASH_ATTR DumpInt(int x, DumpState* D) static void DumpInt(int x, DumpState* D)
{ {
DumpIntWithSize(x,D->target.sizeof_int,D); DumpIntWithSize(x,D->target.sizeof_int,D);
} }
static void ICACHE_FLASH_ATTR DumpSize(uint32_t x, DumpState* D) static void DumpSize(uint32_t x, DumpState* D)
{ {
/* dump unsigned integer */ /* dump unsigned integer */
switch(D->target.sizeof_strsize_t) { switch(D->target.sizeof_strsize_t) {
...@@ -123,7 +123,7 @@ static void ICACHE_FLASH_ATTR DumpSize(uint32_t x, DumpState* D) ...@@ -123,7 +123,7 @@ static void ICACHE_FLASH_ATTR DumpSize(uint32_t x, DumpState* D)
} }
} }
static void ICACHE_FLASH_ATTR DumpNumber(lua_Number x, DumpState* D) static void DumpNumber(lua_Number x, DumpState* D)
{ {
#if defined( LUA_NUMBER_INTEGRAL ) && !defined( LUA_CROSS_COMPILER ) #if defined( LUA_NUMBER_INTEGRAL ) && !defined( LUA_CROSS_COMPILER )
DumpIntWithSize(x,D->target.sizeof_lua_Number,D); DumpIntWithSize(x,D->target.sizeof_lua_Number,D);
...@@ -164,7 +164,7 @@ static void ICACHE_FLASH_ATTR DumpNumber(lua_Number x, DumpState* D) ...@@ -164,7 +164,7 @@ static void ICACHE_FLASH_ATTR DumpNumber(lua_Number x, DumpState* D)
#endif // #if defined( LUA_NUMBER_INTEGRAL ) && !defined( LUA_CROSS_COMPILER ) #endif // #if defined( LUA_NUMBER_INTEGRAL ) && !defined( LUA_CROSS_COMPILER )
} }
static void ICACHE_FLASH_ATTR DumpCode(const Proto *f, DumpState* D) static void DumpCode(const Proto *f, DumpState* D)
{ {
DumpInt(f->sizecode,D); DumpInt(f->sizecode,D);
char buf[10]; char buf[10];
...@@ -178,7 +178,7 @@ static void ICACHE_FLASH_ATTR DumpCode(const Proto *f, DumpState* D) ...@@ -178,7 +178,7 @@ static void ICACHE_FLASH_ATTR DumpCode(const Proto *f, DumpState* D)
} }
} }
static void ICACHE_FLASH_ATTR DumpString(const TString* s, DumpState* D) static void DumpString(const TString* s, DumpState* D)
{ {
if (s==NULL || getstr(s)==NULL) if (s==NULL || getstr(s)==NULL)
{ {
...@@ -195,7 +195,7 @@ static void ICACHE_FLASH_ATTR DumpString(const TString* s, DumpState* D) ...@@ -195,7 +195,7 @@ static void ICACHE_FLASH_ATTR DumpString(const TString* s, DumpState* D)
static void DumpFunction(const Proto* f, const TString* p, DumpState* D); static void DumpFunction(const Proto* f, const TString* p, DumpState* D);
static void ICACHE_FLASH_ATTR DumpConstants(const Proto* f, DumpState* D) static void DumpConstants(const Proto* f, DumpState* D)
{ {
int i,n=f->sizek; int i,n=f->sizek;
DumpInt(n,D); DumpInt(n,D);
...@@ -226,7 +226,7 @@ static void ICACHE_FLASH_ATTR DumpConstants(const Proto* f, DumpState* D) ...@@ -226,7 +226,7 @@ static void ICACHE_FLASH_ATTR DumpConstants(const Proto* f, DumpState* D)
for (i=0; i<n; i++) DumpFunction(f->p[i],f->source,D); for (i=0; i<n; i++) DumpFunction(f->p[i],f->source,D);
} }
static void ICACHE_FLASH_ATTR DumpDebug(const Proto* f, DumpState* D) static void DumpDebug(const Proto* f, DumpState* D)
{ {
int i,n; int i,n;
n= (D->strip) ? 0 : f->sizelineinfo; n= (D->strip) ? 0 : f->sizelineinfo;
...@@ -251,7 +251,7 @@ static void ICACHE_FLASH_ATTR DumpDebug(const Proto* f, DumpState* D) ...@@ -251,7 +251,7 @@ static void ICACHE_FLASH_ATTR DumpDebug(const Proto* f, DumpState* D)
for (i=0; i<n; i++) DumpString(f->upvalues[i],D); for (i=0; i<n; i++) DumpString(f->upvalues[i],D);
} }
static void ICACHE_FLASH_ATTR DumpFunction(const Proto* f, const TString* p, DumpState* D) static void DumpFunction(const Proto* f, const TString* p, DumpState* D)
{ {
DumpString((f->source==p || D->strip) ? NULL : f->source,D); DumpString((f->source==p || D->strip) ? NULL : f->source,D);
DumpInt(f->linedefined,D); DumpInt(f->linedefined,D);
...@@ -265,7 +265,7 @@ static void ICACHE_FLASH_ATTR DumpFunction(const Proto* f, const TString* p, Dum ...@@ -265,7 +265,7 @@ static void ICACHE_FLASH_ATTR DumpFunction(const Proto* f, const TString* p, Dum
DumpDebug(f,D); DumpDebug(f,D);
} }
static void ICACHE_FLASH_ATTR DumpHeader(DumpState* D) static void DumpHeader(DumpState* D)
{ {
char buf[LUAC_HEADERSIZE]; char buf[LUAC_HEADERSIZE];
char *h=buf; char *h=buf;
...@@ -288,7 +288,7 @@ static void ICACHE_FLASH_ATTR DumpHeader(DumpState* D) ...@@ -288,7 +288,7 @@ static void ICACHE_FLASH_ATTR DumpHeader(DumpState* D)
/* /*
** dump Lua function as precompiled chunk with specified target ** dump Lua function as precompiled chunk with specified target
*/ */
int ICACHE_FLASH_ATTR luaU_dump_crosscompile (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip, DumpTargetInfo target) int luaU_dump_crosscompile (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip, DumpTargetInfo target)
{ {
DumpState D; DumpState D;
D.L=L; D.L=L;
...@@ -306,7 +306,7 @@ int ICACHE_FLASH_ATTR luaU_dump_crosscompile (lua_State* L, const Proto* f, lua_ ...@@ -306,7 +306,7 @@ int ICACHE_FLASH_ATTR luaU_dump_crosscompile (lua_State* L, const Proto* f, lua_
/* /*
** dump Lua function as precompiled chunk with local machine as target ** dump Lua function as precompiled chunk with local machine as target
*/ */
int ICACHE_FLASH_ATTR luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip) int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip)
{ {
DumpTargetInfo target; DumpTargetInfo target;
int test=1; int test=1;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "lstate.h" #include "lstate.h"
#include "c_types.h" #include "c_types.h"
void ICACHE_FLASH_ATTR legc_set_mode(lua_State *L, int mode, unsigned limit) { void legc_set_mode(lua_State *L, int mode, unsigned limit) {
global_State *g = G(L); global_State *g = G(L);
g->egcmode = mode; g->egcmode = mode;
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
Closure *ICACHE_FLASH_ATTR luaF_newCclosure (lua_State *L, int nelems, Table *e) { Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e) {
Closure *c = cast(Closure *, luaM_malloc(L, sizeCclosure(nelems))); Closure *c = cast(Closure *, luaM_malloc(L, sizeCclosure(nelems)));
luaC_link(L, obj2gco(c), LUA_TFUNCTION); luaC_link(L, obj2gco(c), LUA_TFUNCTION);
c->c.isC = 1; c->c.isC = 1;
...@@ -30,7 +30,7 @@ Closure *ICACHE_FLASH_ATTR luaF_newCclosure (lua_State *L, int nelems, Table *e) ...@@ -30,7 +30,7 @@ Closure *ICACHE_FLASH_ATTR luaF_newCclosure (lua_State *L, int nelems, Table *e)
} }
Closure *ICACHE_FLASH_ATTR luaF_newLclosure (lua_State *L, int nelems, Table *e) { Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e) {
Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems))); Closure *c = cast(Closure *, luaM_malloc(L, sizeLclosure(nelems)));
luaC_link(L, obj2gco(c), LUA_TFUNCTION); luaC_link(L, obj2gco(c), LUA_TFUNCTION);
c->l.isC = 0; c->l.isC = 0;
...@@ -41,7 +41,7 @@ Closure *ICACHE_FLASH_ATTR luaF_newLclosure (lua_State *L, int nelems, Table *e) ...@@ -41,7 +41,7 @@ Closure *ICACHE_FLASH_ATTR luaF_newLclosure (lua_State *L, int nelems, Table *e)
} }
UpVal *ICACHE_FLASH_ATTR luaF_newupval (lua_State *L) { UpVal *luaF_newupval (lua_State *L) {
UpVal *uv = luaM_new(L, UpVal); UpVal *uv = luaM_new(L, UpVal);
luaC_link(L, obj2gco(uv), LUA_TUPVAL); luaC_link(L, obj2gco(uv), LUA_TUPVAL);
uv->v = &uv->u.value; uv->v = &uv->u.value;
...@@ -50,7 +50,7 @@ UpVal *ICACHE_FLASH_ATTR luaF_newupval (lua_State *L) { ...@@ -50,7 +50,7 @@ UpVal *ICACHE_FLASH_ATTR luaF_newupval (lua_State *L) {
} }
UpVal *ICACHE_FLASH_ATTR luaF_findupval (lua_State *L, StkId level) { UpVal *luaF_findupval (lua_State *L, StkId level) {
global_State *g = G(L); global_State *g = G(L);
GCObject **pp = &L->openupval; GCObject **pp = &L->openupval;
UpVal *p; UpVal *p;
...@@ -79,21 +79,21 @@ UpVal *ICACHE_FLASH_ATTR luaF_findupval (lua_State *L, StkId level) { ...@@ -79,21 +79,21 @@ UpVal *ICACHE_FLASH_ATTR luaF_findupval (lua_State *L, StkId level) {
} }
static void ICACHE_FLASH_ATTR unlinkupval (UpVal *uv) { static void unlinkupval (UpVal *uv) {
lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
uv->u.l.next->u.l.prev = uv->u.l.prev; /* remove from `uvhead' list */ uv->u.l.next->u.l.prev = uv->u.l.prev; /* remove from `uvhead' list */
uv->u.l.prev->u.l.next = uv->u.l.next; uv->u.l.prev->u.l.next = uv->u.l.next;
} }
void ICACHE_FLASH_ATTR luaF_freeupval (lua_State *L, UpVal *uv) { void luaF_freeupval (lua_State *L, UpVal *uv) {
if (uv->v != &uv->u.value) /* is it open? */ if (uv->v != &uv->u.value) /* is it open? */
unlinkupval(uv); /* remove from open list */ unlinkupval(uv); /* remove from open list */
luaM_free(L, uv); /* free upvalue */ luaM_free(L, uv); /* free upvalue */
} }
void ICACHE_FLASH_ATTR luaF_close (lua_State *L, StkId level) { void luaF_close (lua_State *L, StkId level) {
UpVal *uv; UpVal *uv;
global_State *g = G(L); global_State *g = G(L);
while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) { while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) {
...@@ -112,7 +112,7 @@ void ICACHE_FLASH_ATTR luaF_close (lua_State *L, StkId level) { ...@@ -112,7 +112,7 @@ void ICACHE_FLASH_ATTR luaF_close (lua_State *L, StkId level) {
} }
Proto *ICACHE_FLASH_ATTR luaF_newproto (lua_State *L) { Proto *luaF_newproto (lua_State *L) {
Proto *f = luaM_new(L, Proto); Proto *f = luaM_new(L, Proto);
luaC_link(L, obj2gco(f), LUA_TPROTO); luaC_link(L, obj2gco(f), LUA_TPROTO);
f->k = NULL; f->k = NULL;
...@@ -138,7 +138,7 @@ Proto *ICACHE_FLASH_ATTR luaF_newproto (lua_State *L) { ...@@ -138,7 +138,7 @@ Proto *ICACHE_FLASH_ATTR luaF_newproto (lua_State *L) {
} }
void ICACHE_FLASH_ATTR luaF_freeproto (lua_State *L, Proto *f) { void luaF_freeproto (lua_State *L, Proto *f) {
luaM_freearray(L, f->p, f->sizep, Proto *); luaM_freearray(L, f->p, f->sizep, Proto *);
luaM_freearray(L, f->k, f->sizek, TValue); luaM_freearray(L, f->k, f->sizek, TValue);
luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar); luaM_freearray(L, f->locvars, f->sizelocvars, struct LocVar);
...@@ -151,7 +151,7 @@ void ICACHE_FLASH_ATTR luaF_freeproto (lua_State *L, Proto *f) { ...@@ -151,7 +151,7 @@ void ICACHE_FLASH_ATTR luaF_freeproto (lua_State *L, Proto *f) {
} }
void ICACHE_FLASH_ATTR luaF_freeclosure (lua_State *L, Closure *c) { void luaF_freeclosure (lua_State *L, Closure *c) {
int size = (c->c.isC) ? sizeCclosure(c->c.nupvalues) : int size = (c->c.isC) ? sizeCclosure(c->c.nupvalues) :
sizeLclosure(c->l.nupvalues); sizeLclosure(c->l.nupvalues);
luaM_freemem(L, c, size); luaM_freemem(L, c, size);
...@@ -162,7 +162,7 @@ void ICACHE_FLASH_ATTR luaF_freeclosure (lua_State *L, Closure *c) { ...@@ -162,7 +162,7 @@ void ICACHE_FLASH_ATTR luaF_freeclosure (lua_State *L, Closure *c) {
** Look for n-th local variable at line `line' in function `func'. ** Look for n-th local variable at line `line' in function `func'.
** Returns NULL if not found. ** Returns NULL if not found.
*/ */
const char *ICACHE_FLASH_ATTR luaF_getlocalname (const Proto *f, int local_number, int pc) { const char *luaF_getlocalname (const Proto *f, int local_number, int pc) {
int i; int i;
for (i = 0; i<f->sizelocvars && f->locvars[i].startpc <= pc; i++) { for (i = 0; i<f->sizelocvars && f->locvars[i].startpc <= pc; i++) {
if (pc < f->locvars[i].endpc) { /* is variable active? */ if (pc < f->locvars[i].endpc) { /* is variable active? */
......
...@@ -59,14 +59,14 @@ ...@@ -59,14 +59,14 @@
#define setthreshold(g) (g->GCthreshold = (g->estimate/100) * g->gcpause) #define setthreshold(g) (g->GCthreshold = (g->estimate/100) * g->gcpause)
static void ICACHE_FLASH_ATTR removeentry (Node *n) { static void removeentry (Node *n) {
lua_assert(ttisnil(gval(n))); lua_assert(ttisnil(gval(n)));
if (iscollectable(gkey(n))) if (iscollectable(gkey(n)))
setttype(gkey(n), LUA_TDEADKEY); /* dead key; remove it */ setttype(gkey(n), LUA_TDEADKEY); /* dead key; remove it */
} }
static void ICACHE_FLASH_ATTR reallymarkobject (global_State *g, GCObject *o) { static void reallymarkobject (global_State *g, GCObject *o) {
lua_assert(iswhite(o) && !isdead(g, o)); lua_assert(iswhite(o) && !isdead(g, o));
white2gray(o); white2gray(o);
switch (o->gch.tt) { switch (o->gch.tt) {
...@@ -112,7 +112,7 @@ static void ICACHE_FLASH_ATTR reallymarkobject (global_State *g, GCObject *o) { ...@@ -112,7 +112,7 @@ static void ICACHE_FLASH_ATTR reallymarkobject (global_State *g, GCObject *o) {
} }
static void ICACHE_FLASH_ATTR marktmu (global_State *g) { static void marktmu (global_State *g) {
GCObject *u = g->tmudata; GCObject *u = g->tmudata;
if (u) { if (u) {
do { do {
...@@ -125,7 +125,7 @@ static void ICACHE_FLASH_ATTR marktmu (global_State *g) { ...@@ -125,7 +125,7 @@ static void ICACHE_FLASH_ATTR marktmu (global_State *g) {
/* move `dead' udata that need finalization to list `tmudata' */ /* move `dead' udata that need finalization to list `tmudata' */
size_t ICACHE_FLASH_ATTR luaC_separateudata (lua_State *L, int all) { size_t luaC_separateudata (lua_State *L, int all) {
global_State *g = G(L); global_State *g = G(L);
size_t deadmem = 0; size_t deadmem = 0;
GCObject **p = &g->mainthread->next; GCObject **p = &g->mainthread->next;
...@@ -155,7 +155,7 @@ size_t ICACHE_FLASH_ATTR luaC_separateudata (lua_State *L, int all) { ...@@ -155,7 +155,7 @@ size_t ICACHE_FLASH_ATTR luaC_separateudata (lua_State *L, int all) {
} }
static int ICACHE_FLASH_ATTR traversetable (global_State *g, Table *h) { static int traversetable (global_State *g, Table *h) {
int i; int i;
int weakkey = 0; int weakkey = 0;
int weakvalue = 0; int weakvalue = 0;
...@@ -200,7 +200,7 @@ static int ICACHE_FLASH_ATTR traversetable (global_State *g, Table *h) { ...@@ -200,7 +200,7 @@ static int ICACHE_FLASH_ATTR traversetable (global_State *g, Table *h) {
** All marks are conditional because a GC may happen while the ** All marks are conditional because a GC may happen while the
** prototype is still being created ** prototype is still being created
*/ */
static void ICACHE_FLASH_ATTR traverseproto (global_State *g, Proto *f) { static void traverseproto (global_State *g, Proto *f) {
int i; int i;
if (f->source) stringmark(f->source); if (f->source) stringmark(f->source);
for (i=0; i<f->sizek; i++) /* mark literals */ for (i=0; i<f->sizek; i++) /* mark literals */
...@@ -221,7 +221,7 @@ static void ICACHE_FLASH_ATTR traverseproto (global_State *g, Proto *f) { ...@@ -221,7 +221,7 @@ static void ICACHE_FLASH_ATTR traverseproto (global_State *g, Proto *f) {
static void ICACHE_FLASH_ATTR traverseclosure (global_State *g, Closure *cl) { static void traverseclosure (global_State *g, Closure *cl) {
markobject(g, cl->c.env); markobject(g, cl->c.env);
if (cl->c.isC) { if (cl->c.isC) {
int i; int i;
...@@ -240,7 +240,7 @@ static void ICACHE_FLASH_ATTR traverseclosure (global_State *g, Closure *cl) { ...@@ -240,7 +240,7 @@ static void ICACHE_FLASH_ATTR traverseclosure (global_State *g, Closure *cl) {
} }
static void ICACHE_FLASH_ATTR checkstacksizes (lua_State *L, StkId max) { static void checkstacksizes (lua_State *L, StkId max) {
int ci_used = cast_int(L->ci - L->base_ci); /* number of `ci' in use */ int ci_used = cast_int(L->ci - L->base_ci); /* number of `ci' in use */
int s_used = cast_int(max - L->stack); /* part of stack in use */ int s_used = cast_int(max - L->stack); /* part of stack in use */
if (L->size_ci > LUAI_MAXCALLS) /* handling overflow? */ if (L->size_ci > LUAI_MAXCALLS) /* handling overflow? */
...@@ -255,7 +255,7 @@ static void ICACHE_FLASH_ATTR checkstacksizes (lua_State *L, StkId max) { ...@@ -255,7 +255,7 @@ static void ICACHE_FLASH_ATTR checkstacksizes (lua_State *L, StkId max) {
} }
static void ICACHE_FLASH_ATTR traversestack (global_State *g, lua_State *l) { static void traversestack (global_State *g, lua_State *l) {
StkId o, lim; StkId o, lim;
CallInfo *ci; CallInfo *ci;
markvalue(g, gt(l)); markvalue(g, gt(l));
...@@ -278,7 +278,7 @@ static void ICACHE_FLASH_ATTR traversestack (global_State *g, lua_State *l) { ...@@ -278,7 +278,7 @@ static void ICACHE_FLASH_ATTR traversestack (global_State *g, lua_State *l) {
** traverse one gray object, turning it to black. ** traverse one gray object, turning it to black.
** Returns `quantity' traversed. ** Returns `quantity' traversed.
*/ */
static l_mem ICACHE_FLASH_ATTR propagatemark (global_State *g) { static l_mem propagatemark (global_State *g) {
GCObject *o = g->gray; GCObject *o = g->gray;
lua_assert(isgray(o)); lua_assert(isgray(o));
gray2black(o); gray2black(o);
...@@ -324,7 +324,7 @@ static l_mem ICACHE_FLASH_ATTR propagatemark (global_State *g) { ...@@ -324,7 +324,7 @@ static l_mem ICACHE_FLASH_ATTR propagatemark (global_State *g) {
} }
static size_t ICACHE_FLASH_ATTR propagateall (global_State *g) { static size_t propagateall (global_State *g) {
size_t m = 0; size_t m = 0;
while (g->gray) m += propagatemark(g); while (g->gray) m += propagatemark(g);
return m; return m;
...@@ -338,7 +338,7 @@ static size_t ICACHE_FLASH_ATTR propagateall (global_State *g) { ...@@ -338,7 +338,7 @@ static size_t ICACHE_FLASH_ATTR propagateall (global_State *g) {
** other objects: if really collected, cannot keep them; for userdata ** other objects: if really collected, cannot keep them; for userdata
** being finalized, keep them in keys, but not in values ** being finalized, keep them in keys, but not in values
*/ */
static int ICACHE_FLASH_ATTR iscleared (const TValue *o, int iskey) { static int iscleared (const TValue *o, int iskey) {
if (!iscollectable(o)) return 0; if (!iscollectable(o)) return 0;
if (ttisstring(o)) { if (ttisstring(o)) {
stringmark(rawtsvalue(o)); /* strings are `values', so are never weak */ stringmark(rawtsvalue(o)); /* strings are `values', so are never weak */
...@@ -352,7 +352,7 @@ static int ICACHE_FLASH_ATTR iscleared (const TValue *o, int iskey) { ...@@ -352,7 +352,7 @@ static int ICACHE_FLASH_ATTR iscleared (const TValue *o, int iskey) {
/* /*
** clear collected entries from weaktables ** clear collected entries from weaktables
*/ */
static void ICACHE_FLASH_ATTR cleartable (GCObject *l) { static void cleartable (GCObject *l) {
while (l) { while (l) {
Table *h = gco2h(l); Table *h = gco2h(l);
int i = h->sizearray; int i = h->sizearray;
...@@ -379,7 +379,7 @@ static void ICACHE_FLASH_ATTR cleartable (GCObject *l) { ...@@ -379,7 +379,7 @@ static void ICACHE_FLASH_ATTR cleartable (GCObject *l) {
} }
static void ICACHE_FLASH_ATTR freeobj (lua_State *L, GCObject *o) { static void freeobj (lua_State *L, GCObject *o) {
switch (o->gch.tt) { switch (o->gch.tt) {
case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break; case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break;
case LUA_TFUNCTION: luaF_freeclosure(L, gco2cl(o)); break; case LUA_TFUNCTION: luaF_freeclosure(L, gco2cl(o)); break;
...@@ -408,7 +408,7 @@ static void ICACHE_FLASH_ATTR freeobj (lua_State *L, GCObject *o) { ...@@ -408,7 +408,7 @@ static void ICACHE_FLASH_ATTR freeobj (lua_State *L, GCObject *o) {
#define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM) #define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM)
static GCObject **ICACHE_FLASH_ATTR sweeplist (lua_State *L, GCObject **p, lu_mem count) { static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) {
GCObject *curr; GCObject *curr;
global_State *g = G(L); global_State *g = G(L);
int deadmask = otherwhite(g); int deadmask = otherwhite(g);
...@@ -430,7 +430,7 @@ static GCObject **ICACHE_FLASH_ATTR sweeplist (lua_State *L, GCObject **p, lu_me ...@@ -430,7 +430,7 @@ static GCObject **ICACHE_FLASH_ATTR sweeplist (lua_State *L, GCObject **p, lu_me
} }
static void ICACHE_FLASH_ATTR checkSizes (lua_State *L) { static void checkSizes (lua_State *L) {
global_State *g = G(L); global_State *g = G(L);
/* check size of string hash */ /* check size of string hash */
if (g->strt.nuse < cast(lu_int32, g->strt.size/4) && if (g->strt.nuse < cast(lu_int32, g->strt.size/4) &&
...@@ -446,7 +446,7 @@ static void ICACHE_FLASH_ATTR checkSizes (lua_State *L) { ...@@ -446,7 +446,7 @@ static void ICACHE_FLASH_ATTR checkSizes (lua_State *L) {
} }
static void ICACHE_FLASH_ATTR GCTM (lua_State *L) { static void GCTM (lua_State *L) {
global_State *g = G(L); global_State *g = G(L);
GCObject *o = g->tmudata->gch.next; /* get first element */ GCObject *o = g->tmudata->gch.next; /* get first element */
Udata *udata = rawgco2u(o); Udata *udata = rawgco2u(o);
...@@ -478,13 +478,13 @@ static void ICACHE_FLASH_ATTR GCTM (lua_State *L) { ...@@ -478,13 +478,13 @@ static void ICACHE_FLASH_ATTR GCTM (lua_State *L) {
/* /*
** Call all GC tag methods ** Call all GC tag methods
*/ */
void ICACHE_FLASH_ATTR luaC_callGCTM (lua_State *L) { void luaC_callGCTM (lua_State *L) {
while (G(L)->tmudata) while (G(L)->tmudata)
GCTM(L); GCTM(L);
} }
void ICACHE_FLASH_ATTR luaC_freeall (lua_State *L) { void luaC_freeall (lua_State *L) {
global_State *g = G(L); global_State *g = G(L);
int i; int i;
g->currentwhite = WHITEBITS | bitmask(SFIXEDBIT); /* mask to collect all elements */ g->currentwhite = WHITEBITS | bitmask(SFIXEDBIT); /* mask to collect all elements */
...@@ -494,7 +494,7 @@ void ICACHE_FLASH_ATTR luaC_freeall (lua_State *L) { ...@@ -494,7 +494,7 @@ void ICACHE_FLASH_ATTR luaC_freeall (lua_State *L) {
} }
static void ICACHE_FLASH_ATTR markmt (global_State *g) { static void markmt (global_State *g) {
int i; int i;
for (i=0; i<NUM_TAGS; i++) for (i=0; i<NUM_TAGS; i++)
if (g->mt[i] && !luaR_isrotable(g->mt[i])) markobject(g, g->mt[i]); if (g->mt[i] && !luaR_isrotable(g->mt[i])) markobject(g, g->mt[i]);
...@@ -502,7 +502,7 @@ static void ICACHE_FLASH_ATTR markmt (global_State *g) { ...@@ -502,7 +502,7 @@ static void ICACHE_FLASH_ATTR markmt (global_State *g) {
/* mark root set */ /* mark root set */
static void ICACHE_FLASH_ATTR markroot (lua_State *L) { static void markroot (lua_State *L) {
global_State *g = G(L); global_State *g = G(L);
g->gray = NULL; g->gray = NULL;
g->grayagain = NULL; g->grayagain = NULL;
...@@ -516,7 +516,7 @@ static void ICACHE_FLASH_ATTR markroot (lua_State *L) { ...@@ -516,7 +516,7 @@ static void ICACHE_FLASH_ATTR markroot (lua_State *L) {
} }
static void ICACHE_FLASH_ATTR remarkupvals (global_State *g) { static void remarkupvals (global_State *g) {
UpVal *uv; UpVal *uv;
for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) { for (uv = g->uvhead.u.l.next; uv != &g->uvhead; uv = uv->u.l.next) {
lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
...@@ -526,7 +526,7 @@ static void ICACHE_FLASH_ATTR remarkupvals (global_State *g) { ...@@ -526,7 +526,7 @@ static void ICACHE_FLASH_ATTR remarkupvals (global_State *g) {
} }
static void ICACHE_FLASH_ATTR atomic (lua_State *L) { static void atomic (lua_State *L) {
global_State *g = G(L); global_State *g = G(L);
size_t udsize; /* total size of userdata to be finalized */ size_t udsize; /* total size of userdata to be finalized */
/* remark occasional upvalues of (maybe) dead threads */ /* remark occasional upvalues of (maybe) dead threads */
...@@ -556,7 +556,7 @@ static void ICACHE_FLASH_ATTR atomic (lua_State *L) { ...@@ -556,7 +556,7 @@ static void ICACHE_FLASH_ATTR atomic (lua_State *L) {
g->estimate = g->totalbytes - udsize; /* first estimate */ g->estimate = g->totalbytes - udsize; /* first estimate */
} }
static void ICACHE_FLASH_ATTR sweepstrstep (global_State *g, lua_State *L) { static void sweepstrstep (global_State *g, lua_State *L) {
lu_mem old = g->totalbytes; lu_mem old = g->totalbytes;
sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]); sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]);
if (g->sweepstrgc >= g->strt.size) /* nothing more to sweep? */ if (g->sweepstrgc >= g->strt.size) /* nothing more to sweep? */
...@@ -566,7 +566,7 @@ static void ICACHE_FLASH_ATTR sweepstrstep (global_State *g, lua_State *L) { ...@@ -566,7 +566,7 @@ static void ICACHE_FLASH_ATTR sweepstrstep (global_State *g, lua_State *L) {
} }
static l_mem ICACHE_FLASH_ATTR singlestep (lua_State *L) { static l_mem singlestep (lua_State *L) {
global_State *g = G(L); global_State *g = G(L);
/*lua_checkmemory(L);*/ /*lua_checkmemory(L);*/
switch (g->gcstate) { switch (g->gcstate) {
...@@ -615,7 +615,7 @@ static l_mem ICACHE_FLASH_ATTR singlestep (lua_State *L) { ...@@ -615,7 +615,7 @@ static l_mem ICACHE_FLASH_ATTR singlestep (lua_State *L) {
} }
void ICACHE_FLASH_ATTR luaC_step (lua_State *L) { void luaC_step (lua_State *L) {
global_State *g = G(L); global_State *g = G(L);
if(is_block_gc(L)) return; if(is_block_gc(L)) return;
set_block_gc(L); set_block_gc(L);
...@@ -645,7 +645,7 @@ void ICACHE_FLASH_ATTR luaC_step (lua_State *L) { ...@@ -645,7 +645,7 @@ void ICACHE_FLASH_ATTR luaC_step (lua_State *L) {
unset_block_gc(L); unset_block_gc(L);
} }
int ICACHE_FLASH_ATTR luaC_sweepstrgc (lua_State *L) { int luaC_sweepstrgc (lua_State *L) {
global_State *g = G(L); global_State *g = G(L);
if (g->gcstate == GCSsweepstring) { if (g->gcstate == GCSsweepstring) {
sweepstrstep(g, L); sweepstrstep(g, L);
...@@ -654,7 +654,7 @@ int ICACHE_FLASH_ATTR luaC_sweepstrgc (lua_State *L) { ...@@ -654,7 +654,7 @@ int ICACHE_FLASH_ATTR luaC_sweepstrgc (lua_State *L) {
return 0; return 0;
} }
void ICACHE_FLASH_ATTR luaC_fullgc (lua_State *L) { void luaC_fullgc (lua_State *L) {
global_State *g = G(L); global_State *g = G(L);
if(is_block_gc(L)) return; if(is_block_gc(L)) return;
set_block_gc(L); set_block_gc(L);
...@@ -683,7 +683,7 @@ void ICACHE_FLASH_ATTR luaC_fullgc (lua_State *L) { ...@@ -683,7 +683,7 @@ void ICACHE_FLASH_ATTR luaC_fullgc (lua_State *L) {
} }
void ICACHE_FLASH_ATTR luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) { void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) {
global_State *g = G(L); global_State *g = G(L);
lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o)); lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o));
lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause); lua_assert(g->gcstate != GCSfinalize && g->gcstate != GCSpause);
...@@ -696,7 +696,7 @@ void ICACHE_FLASH_ATTR luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) { ...@@ -696,7 +696,7 @@ void ICACHE_FLASH_ATTR luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) {
} }
void ICACHE_FLASH_ATTR luaC_barrierback (lua_State *L, Table *t) { void luaC_barrierback (lua_State *L, Table *t) {
global_State *g = G(L); global_State *g = G(L);
GCObject *o = obj2gco(t); GCObject *o = obj2gco(t);
lua_assert(isblack(o) && !isdead(g, o)); lua_assert(isblack(o) && !isdead(g, o));
...@@ -707,7 +707,7 @@ void ICACHE_FLASH_ATTR luaC_barrierback (lua_State *L, Table *t) { ...@@ -707,7 +707,7 @@ void ICACHE_FLASH_ATTR luaC_barrierback (lua_State *L, Table *t) {
} }
void ICACHE_FLASH_ATTR luaC_marknew (lua_State *L, GCObject *o) { void luaC_marknew (lua_State *L, GCObject *o) {
global_State *g = G(L); global_State *g = G(L);
o->gch.marked = luaC_white(g); o->gch.marked = luaC_white(g);
if (g->gcstate == GCSpropagate) if (g->gcstate == GCSpropagate)
...@@ -715,7 +715,7 @@ void ICACHE_FLASH_ATTR luaC_marknew (lua_State *L, GCObject *o) { ...@@ -715,7 +715,7 @@ void ICACHE_FLASH_ATTR luaC_marknew (lua_State *L, GCObject *o) {
} }
void ICACHE_FLASH_ATTR luaC_link (lua_State *L, GCObject *o, lu_byte tt) { void luaC_link (lua_State *L, GCObject *o, lu_byte tt) {
global_State *g = G(L); global_State *g = G(L);
o->gch.next = g->rootgc; o->gch.next = g->rootgc;
g->rootgc = o; g->rootgc = o;
...@@ -724,7 +724,7 @@ void ICACHE_FLASH_ATTR luaC_link (lua_State *L, GCObject *o, lu_byte tt) { ...@@ -724,7 +724,7 @@ void ICACHE_FLASH_ATTR luaC_link (lua_State *L, GCObject *o, lu_byte tt) {
} }
void ICACHE_FLASH_ATTR luaC_linkupval (lua_State *L, UpVal *uv) { void luaC_linkupval (lua_State *L, UpVal *uv) {
global_State *g = G(L); global_State *g = G(L);
GCObject *o = obj2gco(uv); GCObject *o = obj2gco(uv);
o->gch.next = g->rootgc; /* link upvalue into `rootgc' list */ o->gch.next = g->rootgc; /* link upvalue into `rootgc' list */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment