| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
| |
The syntax 'function foo (a, b, ...arg)' is already used by JavaScript
for this same semantics, so it seems natural to use the same notation in
Lua.
|
| |
|
|
|
|
|
| |
A vararg table can be virtual. If the vararg table is used only as
a base in indexing expressions, the code does not need to create an
actual table for it. Instead, it compiles the indexing expressions
into direct accesses to the internal vararg data.
|
| |
|
|
|
| |
In this format, the attribute applies to all names in the list;
e.g. "global<const> print, require, math".
|
| | |
|
| | |
|
| | |
|
| |
|
|
| |
All test files refer to the main copyright notice in 'lua.h'.
|
| |
|
|
|
| |
Instead of receiving nil as a second argument, __close metamethods are
called with just one argument when there are no errors.
|
| |
|
|
|
| |
The buffer system from the auxiliary library reuses its buffer
as external memory when closing long strings.
|
| |
|
|
|
| |
Test files are more polite regarding the use of globals when locals
would do, and when globals are necessary deleting them after use.
|
| |
|
|
|
|
|
| |
Function 'leaveblock' was generating "break" label before removing
variables from the closing block. If 'createlabel' created a 'close'
instruction (which it did when matching a goto/break that exited
the scope of an upvalue), that instruction would use the wrong level.
|
| | |
|
| | |
|
| |
|
|
|
| |
Yielding in a __close metamethod called when returning vararg results
changes the top and so messes up the number of returned values.
|
| | |
|
| |
|
|
| |
New module easies the inclusion of GC tracing in individual test files.
|
| |
|
|
|
|
|
| |
When, inside a coroutine, a C function with to-be-closed slots return,
the corresponding metamethods can yield. ('__close' metamethods called
through 'lua_closeslot' still cannot yield, as there is no continuation
to go when resuming.)
|
| |
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
| |
The return hook should be called only after closing variables (which
are still part of the function). C functions were calling the hook
before the metamethods.
|
| |
|
|
|
|
| |
New field 'lua_State.ptbc' keeps to-be-closed variable until its
upvalue is created, so that it can be closed in case of a
memory-allocation error.
|
| |
|
|
|
|
| |
Completes commit b07fc10e91a. '__close' metamethods can yield even
when they are being called due to an error. '__close' metamethods from
C functions are still not allowed to yield.
|
| |
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
| |
When available, use the calling code to find a suitable name for what
was being called; this is particularly useful for errors of non-callable
metamethods. This commit also improved the debug information for
order metamethods.
|
| |
|
|
|
|
|
|
| |
A to-be-closed variable is constant and it must have a close metamethod
when it is created. A program has to go out of its way (e.g., by
changing the variable's metamethod) to invalidate that check. So,
it is not worth to test that again. If the program tampers with the
metamethod, Lua will raise a regular error when attempting to call it.
|
| |
|
|
|
| |
When there are multiple errors around closing methods, report the
last error instead of the original.
|
| |
|
|
|
|
|
| |
Undo commit c220b0a5d0: '__close' is not called again in case of
errors. (Upvalue is removed from the list before the call.) The
common error that justified that change was C stack overflows, which
are much rarer with the stackless implementation.
|
| |
|
|
|
|
| |
Besides errors in closing methods, 'coroutine.close' and
'lua_resetthread' also consider the original error that stopped the
thread, if any.
|
| |
|
|
|
|
|
| |
- After converting a generic GCObject to a specific type ('gco2*'),
avoid using the original GCObject (to reduce aliasing).
- Small corrections in comments in 'lopcodes.h'
- Added tests about who calls __close metamethods
|
| |
|
|
|
|
|
| |
To allow their use in memory tests, some functions in 'ltests.c'
should never allocate memory. To avoid this allocation, the
library registers the strings used for status codes, and keeps
the variable '_WARN' always defined (with false instead of nil).
|
| |
|
|
|
|
|
|
|
|
| |
The parser were mixing compiler indices of variables with stack indices,
so that when a to-be-closed variable was used inside the scope of
compile-time constants (which may be optimized away), it might be closed
in the wrong place. (See new tests for examples.)
Besides fixing the bugs, this commit also changed comments and variable
names to avoid that kind of confusion and added tests.
|
| | |
|
| | |
|
| |
|
|
|
| |
Warnings are mostly a tool to help developers (e.g., by showing hidden
error messages); regular users usually don't need to see them.
|
| |
|
|
|
|
| |
When using warn-mode '@store', from the test library, the tests ensure
not only that the expected warnings were issued, but also that there was
no extra warnings.
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
| |
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.)
|
| |
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
| |
Local constant variables initialized with compile-time constants
are optimized away from the code.
|
| |
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
| |
- Added a test for calling 'debug.traceback' after yields inside
hooks. (Lua 5.3 seems to have a bug there.)
- Removed test "repeat test with '__open' metamethod instead of a
function", as the previous test already uses the '__open' metamethod.
(It changed when functions were removed as possible to-be-closed
variables).
|
| |
|
|
|
|
|
|
| |
When there are multiple errors when closing objects, the error
reported by the protected call is the first one, for two reasons:
First, other errors may be caused by this one;
second, the first error is handled in the original execution context,
and therefore has the full traceback.
|
| |
|
|
|
|
| |
Closing methods must be run before correcting 'ci->func' when exiting
a vararg function, to get correct debug information (e.g., in case of
errors).
|
| |
|
|
|
|
|
| |
- new error message for "attempt to assign to const variable"
- note in the manual about compatibility options
- comments
- small changes in 'read_line' and 'pushstr'
|
| |
|
|
|
|
|
| |
The flag for to-be-closed variables was changed from '*toclose'
to '<toclose>'. Several people found confusing the old syntax and
the new one has a clear terminator, making it more flexible for
future changes.
|
| |
|
|
|
|
|
|
|
|
|
| |
Back to how it was, a coroutine does not unwind its stack in case of
errors (and therefore do not close its to-be-closed variables). This
allows the stack to be examined after the error. The program can
use 'coroutine.kill' to close the variables.
The function created by 'coroutine.wrap', however, closes the
coroutine's variables in case of errors, as it is impossible to examine
the stack any way.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
To-be-closed variables must contain objects with '__toclose'
metamethods (or nil). Functions were removed for several reasons:
* Functions interact badly with sandboxes. If a sandbox raises
an error to interrupt a script, a to-be-closed function still
can hijack control and continue running arbitrary sandboxed code.
* Functions interact badly with coroutines. If a coroutine yields
and is never resumed again, its to-be-closed functions will never
run. To-be-closed objects, on the other hand, will still be closed,
provided they have appropriate finalizers.
* If you really need a function, it is easy to create a dummy
object to run that function in its '__toclose' metamethod.
This comit also adds closing of variables in case of panic.
|
| |
|
|
|
|
| |
A to-be-closed variable must be closed when a block ends, so even
a 'return foo()' cannot directly returns the results of 'foo'; the
function must close the scope before returning.
|