aboutsummaryrefslogtreecommitdiff
path: root/lzio.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2019-08-12Detail in the manual (method 'file:setvbuf')Roberto Ierusalimschy1-16/+8
ANSI C is vague about 'setvbuf'; most details are implementation defined. So, the manual cannot give any guaranties, either.
2019-08-01DetailsRoberto Ierusalimschy2-8/+13
- removed rule about RCS from makefile - comments and nitpicking in 'llex.c'
2019-07-31Correction in the documentation of 'io.lines'Roberto Ierusalimschy2-7/+5
The loop does not end on end of file, but when the iterator function fails to read a value. (In particular, the format "a" never fails, so a loop with 'io.lines(fname, "a")' never ends.)
2019-07-31Tracebacks recognize metamethods '__close'Roberto Ierusalimschy2-4/+20
2019-07-31To-be-closed variables must be closed on initializationRoberto Ierusalimschy6-41/+70
When initializing a to-be-closed variable, check whether it has a '__close' metamethod (or is a false value) and raise an error if if it hasn't. This produces more accurate error messages. (The check before closing still need to be done: in the C API, the value is not constant; and the object may lose its '__close' metamethod during the block.)
2019-07-30Fixed test in 'main.lua'Roberto Ierusalimschy1-7/+10
The test "to-be-closed variables in main chunk" was broken, as it used the removed feature of functions as to-be-closed values. The error was not detected because its expected result had no lines to be checked (due to missing new lines).
2019-07-30Change in the syntax of attributesRoberto Ierusalimschy11-102/+103
Attributes changed to posfixed ('x <const>', instead of '<const> x'), and "toclose" renamed to "close". Posfixed attributes seem to make it clearer that it applies to only one variable when there are multiple variables.
2019-07-26Change in the handling of 'L->top' when calling metamethodsRoberto Ierusalimschy10-29/+75
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'.)
2019-07-26Bug: 'Vardesc' array can be reallocated in 'localstat'Roberto Ierusalimschy1-12/+15
A reference to a 'Vardesc*' (as done by 'localstat') can be invalidated by the creation of any new variable.
2019-07-25Small corrections when setting 'L->top'Roberto Ierusalimschy4-6/+17
- OP_NEWTABLE can use 'ra + 1' to set top (instead of ci->top); - OP_CLOSE doesn't need to set top ('Protect' already does that); - OP_TFORCALL must use 'ProtectNT', to preserve the top already set. (That was a small bug, because iterators could be called with extra parameters besides the state and the control variable.) - Comments and an extra test for the bug in previous item.
2019-07-24Some improvements in date/time functionsRoberto Ierusalimschy2-41/+100
- Range in date table extended to full 32 bits. - Easier support for times represented as floats. - Added more tests.
2019-07-23Fixed bug in 'string.format' with option '%f'Roberto Ierusalimschy2-8/+12
As an example, 'print(string.format("%.99f", 1e70))' may have a lot of garbage after the number. The old test to ensure that 'string.format("%.99f", n)' was not too large, 'fabs(n) < 1e100', assumes that the number will fit in the 99 bytes; but the 99 is not the space for the number, it is the added extra zeros. The option worked for smaller numbers because of the extra space added to MAX_ITEM.
2019-07-22Do not collect open upvaluesRoberto Ierusalimschy4-14/+11
Open upvalues are kept alive together with their corresponding stack. This change makes a simpler and safer fix to the issue in commit 440a5ee78c8, about upvalues in the list of open upvalues being collected while others are being created. (That previous fix may not be correct.)
2019-07-19'math.randomseed' always returns the two seed componentsRoberto Ierusalimschy3-11/+15
2019-07-19Avoid using addresses of static variables as unique keysRoberto Ierusalimschy3-16/+17
The addresses of static variables may be different for different instances of Lua, making these instances incompatible if they use these addresses as unique keys in the registry (or other tables).
2019-07-19Fixed bug for emergency collection in upvalue creationRoberto Ierusalimschy3-8/+10
When creating an upvalue, an emergency collection can collect the previous upvalue where the new one would be linked. The following code can trigger the bug, using valgrind on Lua compiled with the -DHARDMEMTESTS option: local x; local y (function () return y end)(); (function () return x end)()
2019-07-19Tag LUA_TUPVALTBC replaced by a flagRoberto Ierusalimschy5-18/+13
It is simpler to signal a to-be-closed upvalue with a boolean flag, instead of using a different tag.
2019-07-19Some details in 'lmem.c' and 'lgc.c'Roberto Ierusalimschy2-27/+42
- Several new comments in 'lmem.c'. - Both 'luaM_growaux_' and 'luaM_shrinkvector_' use 'luaM_saferealloc_' to check for errors. Moreover, the use of 'luaM_saferealloc_' makes 'luaM_shrinkvector_' try again if shrink fails (which can happen now). - In 'checkSizes', save old debt only when needed.
2019-07-18DetailsRoberto Ierusalimschy3-25/+17
- Macro 'checkliveness' (for debug) always uses 'L', to avoid warnings. - Some old 'while' changed to 'for' in 'testes/gc.lua'. - In 'testes/libs/makefile', do not make files depend on 'ltests.h', which may not even exist.
2019-07-18Reviving HARDMEMTESTSRoberto Ierusalimschy4-15/+35
This commit brings a new implementation for HARDMEMTESTS, which forces an emergency GC whenever possible. It also fixes some issues detected with this option: - A small bug in lvm.c: a closure could be collected by an emergency GC while being initialized. - Some tests: a memory address can be immediatly reused after a GC; for instance, two consecutive '{}' expressions can return exactly the same address, if the first one is not anchored.
2019-07-18Small bug with stack reallocationRoberto Ierusalimschy2-7/+9
OP_RETURN must update trap before updating stack. (Bug detected with -DHARDSTACKTESTS). Also, in 'luaF_close', do not create a variable with 'uplevel(uv)', as the stack may change and invalidate this value. (This is not a bug, but could become one if 'upl' was used again.)
2019-07-17'math.randomseed()' returns the seeds it usedRoberto Ierusalimschy4-7/+27
A call to 'math.randomseed()' returns the two components of the seed it set, so that they can be used to set that same seed again.
2019-07-17Calls 'luaF_close' in 'lua_settop' only when neededRoberto Ierusalimschy1-5/+7
In 'lua_settop', avoid calling 'luaF_close' when increasing the stack or when the function has no to-be-closed variables.
2019-07-17Fixed small issue with constant propagationRoberto Ierusalimschy2-7/+21
Constants directly assigned to other constants were not propagating: For instance, in local <const> k1 = 10 local <const> k2 = k1 'k2' were not treated as a compile-time constant.
2019-07-17New kind of expression VKSTRRoberto Ierusalimschy5-18/+54
String literal expressions have their own kind VKSTR, instead of the generic VK. This allows strings to "cross" functions without entering their constant tables (e.g., if they are used only by some nested function).
2019-07-16Micro optimization in OP_RETURN and OP_TAILCALLRoberto Ierusalimschy3-15/+13
Many functions are vararg but create no upvalues, so it is better to separate the tests for these two kinds of "extra work".
2019-07-16'__close' method may be called again in case of errorRoberto Ierusalimschy3-22/+32
An error in a closing method may be caused by a lack of resources, such as memory or stack space, and the error may free enough resources (by unwinding the stack) to allow the method to work if called again. If the closing method is already running after some error (including its own), it is not called again.
2019-07-16Avoid setting the stack top below upvalues to be closedRoberto Ierusalimschy3-9/+13
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.
2019-07-15Unification of size representation in OP_NEWTABLE and OP_SETLISTRoberto Ierusalimschy6-72/+80
Opcodes OP_NEWTABLE and OP_SETLIST use the same representation to store the size of the array part of a table. This new representation can go up to 2^33 (8 + 25 bits).
2019-07-12Reordering of instructions in the main loopRoberto Ierusalimschy1-44/+44
The instructions in the main interpreter loop were reordered to the same order of their enumeration in 'lopcodes.h'.
2019-07-12OP_NEWTABLE keeps exact size of arraysRoberto Ierusalimschy10-88/+67
OP_NEWTABLE is followed by an OP_EXTRAARG, so that it can keep the exact size of the array part of the table to be created. (Functions 'luaO_int2fb'/'luaO_fb2int' were removed.)
2019-07-12First implementation of constant propagationRoberto Ierusalimschy12-119/+249
Local constant variables initialized with compile-time constants are optimized away from the code.
2019-07-10DetailsRoberto Ierusalimschy3-13/+13
In the generic for loop, it is simpler for OP_TFORLOOP to use the same 'ra' as OP_TFORCALL. Moreover, the internal names of the loop temporaries "(for ...)" don't need to leak internal details (even because the numerical for loop doesn't have a fixed role for each of its temporaries).
2019-07-10Towards constant propagationRoberto Ierusalimschy3-42/+87
This commit detaches the number of active variables from the number of variables in the stack, during compilation. Soon, compile-time constants will be propagated and therefore will not exist during run time (in the stack).
2019-07-09New implementation for constantsRoberto Ierusalimschy8-131/+125
VLOCAL expressions keep a reference to their corresponding 'Vardesc', and 'Upvaldesc' (for upvalues) has a field 'ro' (read-only). So, it is easier to check whether a variable is read-only. The decoupling in VLOCAL between 'vidx' ('Vardesc' index) and 'sidx' (stack index) should also help the forthcoming implementation of compile-time constant propagation.
2019-07-05Details (typos in comments)Roberto Ierusalimschy9-19/+19
2019-07-03Local attributes can be used in list of local variablesRoberto Ierusalimschy3-81/+103
The syntax for local attributes ('const'/'toclose') was unified with the regular syntax for local variables, so that we can have variables with attributes in local definitions with multiple names; for instance: local <toclose> f, <const> err = io.open(fname) This new syntax does not implement constant propagation, yet. This commit also has some small improvements to the manual.
2019-07-01First take on constant propagationRoberto Ierusalimschy4-26/+73
2019-07-01Methods separated from metamethods in 'io'Roberto Ierusalimschy1-10/+20
In the 'io' library, changed the use of the metatable also as its own "method table", so that metamethods cannot be accessed as if they were methods. (For instance, 'io.stdin.__gc' does not result in the finalizer metamethod anymore.)
2019-06-26Small changes around C-stack limitRoberto Ierusalimschy4-10/+24
- Better documentation in 'testes/cstack.lua' about using 'debug.setCstacklimit' to find a good limit. - Constant LUAI_MAXCSTACK gets added CSTACKERR (extra stack for error handling), so that it is compatible with the argument to 'debug.setCstacklimit'.
2019-06-25'__call' metamethod can be any callable objectRoberto Ierusalimschy2-14/+31
Removed the restriction that a '__call' metamethod must be an actual function.
2019-06-25A few more tests for table access in the APIRoberto Ierusalimschy2-1/+63
Added tests where the table being accessed is also the index or value in the operation.