summaryrefslogtreecommitdiff
path: root/lapi.c
Commit message (Collapse)AuthorAgeFilesLines
* Bug: 'lua_settop' may use an invalid pointer to stackRoberto Ierusalimschy2022-05-251-3/+2
|
* 'lua_checkstack' doesn't need to check stack overflowRoberto Ierusalimschy2022-05-231-7/+2
| | | | | | 'luaD_growstack' already checks that. This commit also fixes an internal bug in 'luaD_growstack': a large 'n' could cause an arithmetic overflow when computing 'needed'.
* DetailsRoberto Ierusalimschy2021-12-211-1/+1
| | | | correction in macro for hard tests + type in comment
* Bug: GC is not reentrantRoberto Ierusalimschy2021-12-131-8/+9
| | | | As the GC is not reentrant, finalizers should not be able to invoke it.
* Using 'inline' in some functionsRoberto Ierusalimschy2021-09-151-5/+7
| | | | | According to ISO C, "making a function an inline function suggests that calls to the function be as fast as possible." (Not available in C89.)
* 'index2value' more robustRoberto Ierusalimschy2021-05-241-5/+13
| | | | | 'index2value' accepts pseudo-indices also when called from a Lua function, through a hook.
* lua_settop/lua_pop closes to-be-closed variablesRoberto Ierusalimschy2021-03-091-7/+8
| | | | | | The existence of 'lua_closeslot' is no reason for lua_pop not to close to-be-closed variables too. It is too error-prone for lua_pop not to close tbc variables being popped from the stack.
* New implementation for to-be-closed variablesRoberto Ierusalimschy2021-02-091-6/+3
| | | | | | | | To-be-closed variables are linked in their own list, embedded into the stack elements. (Due to alignment, this information does not change the size of the stack elements in most architectures.) This new list does not produce garbage and avoids memory errors when creating tbc variables.
* New macro 'completestate'Roberto Ierusalimschy2021-02-051-1/+1
|
* Fixed some bugs around stack reallocationRoberto Ierusalimschy2021-02-051-0/+1
| | | | Long time without using HARDSTACKTESTS...
* Janitorial workRoberto Ierusalimschy2021-01-251-1/+2
| | | | Comments, code details, identation.
* Allow yields inside '__close' metamethodsRoberto Ierusalimschy2021-01-131-2/+2
| | | | | | | Initial implementation to allow yields inside '__close' metamethods. This current version still does not allow a '__close' metamethod to yield when called due to an error. '__close' metamethods from C functions also are not allowed to yield.
* New API function 'lua_closeslot'Roberto Ierusalimschy2021-01-111-1/+18
| | | | | | Closing a to-be-closed variable with 'lua_settop' is too restrictive, as it erases all slots above the variable. Moreover, it adds side effects to 'lua_settop', which should be a fairly basic function.
* Cleaner handling of errors in '__close' metamethodsRoberto Ierusalimschy2020-12-281-1/+1
| | | | | Instead of protecting each individual metamethod call, protect the entire call to 'luaF_close'.
* Changes in the API of 'luaH_set' and related functionsRoberto Ierusalimschy2020-12-041-3/+1
| | | | | Functions to set values in a table (luaH_set, luaH_newkey, etc.) receive the new value, instead of returning a slot where to put the value.
* Changed access to global table in the registryRoberto Ierusalimschy2020-11-261-8/+17
| | | | | The global table is always in the array part of the registry; we can use this fact to make its access slightly more efficient.
* 'lua_upvalueid' returns NULL on invalid upvalue indexRoberto Ierusalimschy2020-10-121-6/+13
|
* Avoid any code before locks in the APIRoberto Ierusalimschy2020-07-061-9/+17
| | | | | For consistency in the C API, avoid any initializations before callling lua_lock.
* Keep memory errors as memory errorsRoberto Ierusalimschy2020-07-061-1/+7
| | | | | | | Allow memory errors to be raised through the API (throwing the error with the memory error message); error in external allocations raises a memory error; memory errors in coroutines are re-raised as memory errors.
* 'luaV_concat' can "concat" one single valueRoberto Ierusalimschy2020-07-031-5/+3
| | | | | Several of its callers needed that case and had to do the check themselves.
* Fixed detail in 'loadUpvalues'Roberto Ierusalimschy2020-06-301-0/+1
| | | | | | | | | In 'lundump.c', when loading the upvalues of a function, there can be a read error if the chunk is truncated. In that case, the creation of the error message can trigger an emergency collection while the prototype is still anchored. So, the prototype must be GC consistent before loading the upvales, which implies that it the 'name' fields must be filled with NULL before the reading.
* Clearer distinction between types and tagsRoberto Ierusalimschy2020-01-311-11/+11
| | | | | LUA_T* represents only types; tags (types + Variants) are represented by LUA_V* constants.
* Changed internal representation of booleansRoberto Ierusalimschy2020-01-061-1/+4
| | | | | | | Instead of an explicit value (field 'b'), true and false use different tag variants. This avoids reading an extra field and results in more direct code. (Most code that uses booleans needs to distinguish between true and false anyway.)
* Fixed bug in 'aux_rawset'Roberto Ierusalimschy2019-12-301-1/+1
| | | | | In 'aux_rawset', top must be decremented after the barrier, which refers to top-1. (Bug introduced in commit c646e57fd.)
* Joined common code in 'lua_rawset' and 'lua_rawsetp'Roberto Ierusalimschy2019-12-171-17/+14
|
* Small correction in assertionRoberto Ierusalimschy2019-12-131-1/+1
|
* Removed some wrong commentsRoberto Ierusalimschy2019-11-281-8/+6
| | | | | Both 'tonumber' and 'tointeger' cannot change the out parameter when the conversion fails.
* Undo change in the handling of 'L->top' (commit b80077b8f3)Roberto Ierusalimschy2019-08-291-2/+0
| | | | | | With MMBIN instructions, there are fewer opcodes that need to update 'L->top', so that change does not seem to pay for the increased complexity.
* Change in the handling of 'L->top' when calling metamethodsRoberto Ierusalimschy2019-07-261-0/+2
| | | | | | | Instead of updating 'L->top' in every place that may call a metamethod, the metamethod functions themselves (luaT_trybinTM and luaT_callorderTM) correct the top. (When calling metamethods from the C API, however, the callers must preserve 'L->top'.)
* Calls 'luaF_close' in 'lua_settop' only when neededRoberto Ierusalimschy2019-07-171-5/+7
| | | | | In 'lua_settop', avoid calling 'luaF_close' when increasing the stack or when the function has no to-be-closed variables.
* Avoid setting the stack top below upvalues to be closedRoberto Ierusalimschy2019-07-161-7/+8
| | | | | | When leaving a scope, the new stack top should be set only after closing any upvalue, to avoid manipulating values in an "invalid" part of the stack.
* Small optimizations in range checksRoberto Ierusalimschy2019-03-271-4/+6
| | | | | | | | Checks of the form '1 <= x && x <= M' were rewritten in the form '(unsigned)x - 1 < (unsigned)M', which is usually more efficient. (Other similar checks have similar translations.) Although some compilers do these optimizations, that does not happen for all compilers or all cases.
* Changes in the warning systemRoberto Ierusalimschy2019-03-141-2/+2
| | | | | | | | - The warning functions get an extra parameter that tells whether message is to be continued (instead of using end-of-lines as a signal). - The user data for the warning function is a regular value, instead of a writable slot inside the Lua state.
* DetailsRoberto Ierusalimschy2019-03-131-9/+22
| | | | | | | | | | Several small improvements (code style, warnings, comments, more tests), in particular: - 'lua_topointer' extended to handle strings - raises an error in 'string.format("%10q")' ('%q' with modifiers) - in the manual for 'string.format', the term "option" replaced by "conversion specifier" (the term used by the C standard)
* After a "bad collections", avoid switching back back to generationalRoberto Ierusalimschy2019-01-301-4/+2
| | | | | | | After a major bad collection (one that collects too few objects), next collection will be major again. In that case, avoid switching back to generational mode (as it will have to switch again to incremental to do next major collection).
* No more LUA_ERRGCMM errorsRoberto Ierusalimschy2019-01-011-3/+1
| | | | | Errors in finalizers (__gc metamethods) are never propagated. Instead, they generate a warning.
* Added a warning system to LuaRoberto Ierusalimschy2018-12-281-0/+18
| | | | | The warning system is just a way for Lua to emit warnings, messages to the programmer that do not interfere with the running program.
* Changes in the control of C-stack overflowRoberto Ierusalimschy2018-12-271-2/+2
| | | | | | | | | | * unification of the 'nny' and 'nCcalls' counters; * external C functions ('lua_CFunction') count more "slots" in the C stack (to allow for their possible use of buffers) * added a new test script specific for C-stack overflows. (Most of those tests were already present, but concentrating them in a single script easies the task of checking whether 'LUAI_MAXCCALLS' is adequate in a system.)
* A to-be-closed variable must have a closable value (or be nil)Roberto Ierusalimschy2018-11-291-1/+1
| | | | | | | It is an error for a to-be-closed variable to have a non-closable non-nil value when it is being closed. This situation does not seem to be useful and often hints to an error. (Particularly in the C API, it is easy to change a to-be-closed index by mistake.)
* Auxiliary buffer cannot close box with 'lua_remove'Roberto Ierusalimschy2018-11-261-2/+2
| | | | | | | To remove a to-be-closed variable from the stack in the C API a function must use 'lua_settop' or 'lua_pop'. Previous implementation of 'luaL_pushresult' was not closing the box. (This commit also added tests to check that box is being closed "as soon as possible".)
* 'lua_toclose' gets the index to be closed as an argumentRoberto Ierusalimschy2018-11-121-3/+10
| | | | | | Sometimes it is useful to mark to-be-closed an index that is not at the top of the stack (e.g., if the value to be closed came from a function call returning multiple values).
* New syntax for to-be-closed variablesRoberto Ierusalimschy2018-11-071-1/+1
| | | | | | | The new syntax is <local *toclose x = f()>. The mark '*' allows other attributes to be added later without the need of new keywords; it also allows better error messages. The API function was also renamed ('lua_tobeclosed' -> 'lua_toclose').
* To-be-closed variables in the C APIRoberto Ierusalimschy2018-10-251-2/+13
|
* Details (comments)Roberto Ierusalimschy2018-09-111-1/+5
|
* Removed extra information from RCS keyword stringsRoberto Ierusalimschy2018-08-231-1/+1
| | | | | Version numbers and dates (mostly wrong) from RCS keyword strings removed from all source files; only the file name are kept.
* no need to check whether libraries and host use the same kernel;Roberto Ierusalimschy2018-06-181-5/+4
| | | | Lua should work correctly with several copies of the kernel
* new field 'nilvalue' in struct 'global_State' to avoid the use ofRoberto Ierusalimschy2018-06-151-13/+10
| | | | addresses of static variables
* removed unused macros 'isstackindex'/'api_checkstackindex' +Roberto Ierusalimschy2018-06-151-10/+2
| | | | macro 'api_checkvalidindex' (used only once) expanded and removed
* no more 'luaO_nilobject' to avoid comparison of global variable addressesRoberto Ierusalimschy2018-06-011-3/+5
| | | | (now uses static variables)
* no more nil-in-tableRoberto Ierusalimschy2018-04-041-22/+1
|