summaryrefslogtreecommitdiff
path: root/lparser.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* DetailsRoberto Ierusalimschy2019-05-281-1/+1
| | | | | | | - 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'
* First implementation for 'const' variablesRoberto Ierusalimschy2019-05-171-20/+89
| | | | | A variable can be declared const, which means it cannot be assigned to, with the syntax 'local <const> name = exp'.
* Flag for to-be-closed variables changed to '<toclose>'Roberto Ierusalimschy2019-05-091-1/+2
| | | | | | | 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.
* Keep correct type for immediate operands in comparisonsRoberto Ierusalimschy2019-03-221-1/+1
| | | | | | | | | | | | When calling metamethods for things like 'a < 3.0', which generates the opcode OP_LTI, the C register tells that the operand was converted to an integer, so that it can be corrected to float when calling a metamethod. This commit also includes some other stuff: - file 'onelua.c' added to the project - opcode OP_PREPVARARG renamed to OP_VARARGPREP - comparison opcodes rewritten through macros
* New semantics for the integer 'for' loopRoberto Ierusalimschy2019-03-191-26/+16
| | | | | | | | | | | The numerical 'for' loop over integers now uses a precomputed counter to control its number of iteractions. This change eliminates several weird cases caused by overflows (wrap-around) in the control variable. (It also ensures that every integer loop halts.) Also, the special opcodes for the usual case of step==1 were removed. (The new code is already somewhat complex for the usual case, but efficient.)
* Changes in the control of C-stack overflowRoberto Ierusalimschy2018-12-271-3/+5
| | | | | | | | | | * 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.)
* Calls cannot be tail in the scope of a to-be-closed variableRoberto Ierusalimschy2018-12-041-1/+4
| | | | | | 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.
* DetailsRoberto Ierusalimschy2018-11-221-33/+85
| | | | comments and other janitorial work.
* To-be-closed variable in 'for' loop separated from the stateRoberto Ierusalimschy2018-11-071-11/+14
| | | | | | | | | The variable to be closed in a generic 'for' loop now is the 4th value produced in the loop initialization, instead of being the loop state (the 2nd value produced). That allows a loop to use a state with a '__toclose' metamethod but do not close it. (As an example, 'f:lines()' might use the file 'f' as a state for the loop, but it should not close the file when the loop ends.)
* New syntax for to-be-closed variablesRoberto Ierusalimschy2018-11-071-12/+13
| | | | | | | 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').
* State in generic 'for' acts as a to-be-closed variableRoberto Ierusalimschy2018-10-311-0/+1
| | | | | | | | | | | The implicit variable 'state' in a generic 'for' is marked as a to-be-closed variable, so that the state will be closed as soon as the loop ends, no matter how. Taking advantage of this new facility, the call 'io.lines(filename)' now returns the open file as a second result. Therefore, an iteraction like 'for l in io.lines(name)...' will close the file even when the loop ends with a break or an error.
* Back with optimization for 'if cond then goto'Roberto Ierusalimschy2018-10-301-19/+65
| | | | | | | | | | | | Statements like 'if cond then goto label' generate code so that the jump in the 'if' goes directly to the given label. This optimization cannot be done when the jump is backwards leaving the scope of some variable, as it cannot add the needed 'close' instruction. (The jumps were already generated by the 'if'.) This commit also added 'likely'/'unlikely' for tests for errors in the parser, and it changed the way breaks outside loops are detected. (Now they are detected like other goto's with undefined labels.)
* Big revamp in the implmentation of labels/gotosRoberto Ierusalimschy2018-10-291-124/+117
| | | | | | | | Added restriction that, when a label is created, there cannot be another label with the same name visible. That allows backward goto's to be resolved when they are read. Backward goto's get a close if they jump out of the scope of some variable; labels get a close only if previous goto to it jumps out of the scope of some upvalue.
* More uniformity in code generation for 'for' loopsRoberto Ierusalimschy2018-10-261-10/+6
| | | | | | | Added new instruction 'OP_TFORPREP' to prepare a generic for loop. Currently it is equivalent to a jump (but with a format 'iABx', similar to other for-loop preparing instructions), but soon it will be the place to create upvalues for closing loop states.
* Closing methods should not interfere with returning valuesRoberto Ierusalimschy2018-10-251-8/+7
| | | | | | | | | | | | A closing method cannot be called in its own stack slot, as there may be returning values in the stack after that slot, and the call would corrupt those values. Instead, the closing method must be copied to the top of the stack to be called. Moreover, even when a function returns no value, its return istruction still has to have its position (which will set the stack top) after the local variables, otherwise a closing method might corrupt another not-yet-called closing method.
* First "complete" implementation of to-be-closed variablesRoberto Ierusalimschy2018-10-171-1/+1
| | | | | | | Still missing: - handling of memory errors when creating upvalue (must run closing method all the same) - interaction with coroutines
* Towards "to closed" local variablesRoberto Ierusalimschy2018-10-081-4/+30
| | | | | | | | | | | | Start of the implementation of "scoped variables" or "to be closed" variables, local variables whose '__close' (or themselves) are called when they go out of scope. This commit implements the syntax, the opcode, and the creation of the corresponding upvalue, but it still does not call the finalizations when the variable goes out of scope (the most important part). Currently, the syntax is 'local scoped name = exp', but that will probably change.
* Details (comments)Roberto Ierusalimschy2018-09-111-2/+2
|
* 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.
* in generational mode, an emergency collection can turn any object blackRoberto Ierusalimschy2018-06-181-2/+2
| | | | during any memory allocation.
* no more nil-in-tableRoberto Ierusalimschy2018-04-041-15/+1
|
* new experimental syntax using reserved word 'undef'Roberto Ierusalimschy2018-03-071-11/+18
|
* correct way to check stack space for vararg functionsRoberto Ierusalimschy2018-02-171-3/+1
|
* vararg back to '...' (but with another implementation)Roberto Ierusalimschy2018-02-091-16/+6
| | | | new implementation should have zero overhead for non-vararg functions
* new opcode 'PREPVARARG'Roberto Ierusalimschy2018-02-071-6/+16
| | | | (avoids test for vararg function in all function calls)
* new macros 'isOT'/'isIT'Roberto Ierusalimschy2017-12-221-2/+2
| | | | | (plus exchanged parameters of OP_VARARG to make it similar to other 'isOT' instructions)
* new opcodes 'FORLOOP1'/'FORPREP1' for "basic for" (integer variableRoberto Ierusalimschy2017-12-181-15/+36
| | | | with increment of 1)
* details (cleaning uses of 'exp1')Roberto Ierusalimschy2017-12-181-8/+5
|
* 'Proto->numparams' does not include vararg parameterRoberto Ierusalimschy2017-12-151-5/+4
| | | | (one less subtraction when calling functions...)
* 'VRELOCABLE' -> 'VRELOC'Roberto Ierusalimschy2017-12-141-3/+3
|
* avoid using one function for different tasks (malloc, free, etc.)Roberto Ierusalimschy2017-12-061-16/+9
|
* small peephole optimizationsRoberto Ierusalimschy2017-11-301-2/+2
|
* no more 'stackless' implementation; 'luaV_execute' calls itselfRoberto Ierusalimschy2017-11-231-8/+4
| | | | | recursively to execute function calls. 'unroll' continues all executions suspended by an yield (through a long jump)
* detailRoberto Ierusalimschy2017-10-041-2/+3
|
* no more 'getBMode'-'getCMode' (imprecise + we will need more spaceRoberto Ierusalimschy2017-09-281-2/+2
| | | | for op mode) + better control of op modes
* jumps do not close upvalues (to be faster and simpler);Roberto Ierusalimschy2017-09-131-46/+81
| | | | | | explicit instruction to close upvalues; command 'break' not handled like a 'goto' (to optimize removal of uneeded 'close' instructions)
* jumps in 'for' loops don't need to be signedRoberto Ierusalimschy2017-08-141-6/+24
|
* commentRoberto Ierusalimschy2017-08-121-2/+2
|
* 'OP_VARARG' has the vararg parameter as an operandRoberto Ierusalimschy2017-06-291-2/+3
|
* new type 'StackValue' for stack elementsRoberto Ierusalimschy2017-06-291-3/+3
| | | | (we may want to put extra info there in the future)
* 'lineinfo' in prototypes saved as differences instead of absoluteRoberto Ierusalimschy2017-06-271-4/+9
| | | | | | values, so that the array can use bytes instead of ints, reducing its size. (A new array 'abslineinfo' is used when line differences do not fit in a byte.)
* back to old-style vararg system (with vararg table collecting extraRoberto Ierusalimschy2017-05-131-1/+10
| | | | arguments)
* bug: cannot "skip" labels after if-goto before the jump over theRoberto Ierusalimschy2017-04-291-2/+2
| | | | 'then' part
* new opcodes for table access with constant keys (strings and integers)Roberto Ierusalimschy2017-04-281-16/+24
|
* new opcode LOADI (for loading immediate integers)Roberto Ierusalimschy2017-04-201-2/+2
|
* do not eliminate varargs from functions that do not use varargsRoberto Ierusalimschy2016-08-011-4/+3
| | | | (confuses the debug lib and gains very little in performance)
* bug: expression list with four or more expressions inRoberto Ierusalimschy2016-06-221-5/+4
| | | | | a 'for' loop can crash the interpreter. ('adjust_assign' must remove extra expresssions from its registers.)
* 'singlevaraux' returns result only in 'var->k'Roberto Ierusalimschy2016-05-131-10/+10
|
* bug: label between local definitions can mix-up their initializationsRoberto Ierusalimschy2016-03-071-2/+2
|
* 'getcode' -> 'getinstruction'Roberto Ierusalimschy2016-01-051-4/+4
|