Commit Graph

97 Commits

Author SHA1 Message Date
Roberto Ierusalimschy
d9d2904f09 Details
Names in the parser and other details that do not change actual code.
2020-12-02 15:13:13 -03:00
Roberto Ierusalimschy
94cbe46511 Details
- small corrections in the manual
- ldo.c: 'docall' -> 'ccall' ('docall' already used in 'lua.c')
- comments
2020-10-30 10:18:54 -03:00
Roberto Ierusalimschy
63295f1f7f Fixed two bugs in to-be-closed variables x constants
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.
2020-06-01 15:07:58 -03:00
Roberto Ierusalimschy
5f83fb6582 Details 2019-11-18 14:54:06 -03:00
Roberto Ierusalimschy
d6af81084d New kind of expression VKSTR
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-17 14:26:56 -03:00
Roberto Ierusalimschy
f6aab3ec1f First implementation of constant propagation
Local constant variables initialized with compile-time constants
are optimized away from the code.
2019-07-12 11:38:42 -03:00
Roberto Ierusalimschy
3d296304ef Towards constant propagation
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-10 14:00:22 -03:00
Roberto Ierusalimschy
54f7b46c1e New implementation for constants
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-09 10:43:17 -03:00
Roberto Ierusalimschy
8eca21c2e8 First take on constant propagation 2019-07-01 12:42:31 -03:00
Roberto Ierusalimschy
e4b02ca8e4 Structure 'Vardesc' does not need a 'name' field
Removed the field 'name' from the structure 'Vardesc', as the name
of the local variable is already available in the prototype of the
function, through the index 'idx'.
2019-06-21 10:16:57 -03:00
Roberto Ierusalimschy
d9f40e3f6f First implementation for 'const' variables
A variable can be declared const, which means it cannot be assigned to,
with the syntax 'local <const> name = exp'.
2019-05-17 11:11:44 -03:00
Roberto Ierusalimschy
35296e1fde Details
comments and other janitorial work.
2018-11-22 13:56:04 -02:00
Roberto Ierusalimschy
a006514ea1 Big revamp in the implmentation of labels/gotos
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.
2018-10-29 14:26:48 -03:00
Roberto Ierusalimschy
4cd1f4aac0 Towards "to closed" local variables
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.
2018-10-08 10:42:07 -03:00
Roberto Ierusalimschy
f99509581e Removed extra information from RCS keyword strings
Version numbers and dates (mostly wrong) from RCS keyword strings
removed from all source files; only the file name are kept.
2018-08-23 14:26:12 -03:00
Roberto Ierusalimschy
03c6a05ec8 no more nil-in-table 2018-04-04 11:23:41 -03:00
Roberto Ierusalimschy
4a1612ff9b new experimental syntax using reserved word 'undef' 2018-03-07 12:55:38 -03:00
Roberto Ierusalimschy
e001d5aea6 'VRELOCABLE' -> 'VRELOC' 2017-12-14 12:24:02 -02:00
Roberto Ierusalimschy
10b8c99bbb small peephole optimizations 2017-11-30 11:29:18 -02:00
Roberto Ierusalimschy
b42430fd3a 'lineinfo' in prototypes saved as differences instead of absolute
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.)
2017-06-27 08:35:31 -03:00
Roberto Ierusalimschy
502a1d1108 new opcodes for table access with constant keys (strings and integers) 2017-04-28 17:57:45 -03:00
Roberto Ierusalimschy
07cf8415e3 more comments + reordeing of union inside 'expdesc' to allow
static initialization of a VKINT value
2015-12-30 16:16:13 -02:00
Roberto Ierusalimschy
19770b03a9 comments. (More explanation about kinds of expressions.) 2015-12-17 13:44:50 -02:00
Roberto Ierusalimschy
bdf566a8a3 `name' in comments changed to 'name' 2014-10-25 09:50:46 -02:00
Roberto Ierusalimschy
89b56e7d84 more precision between closure types ('LClosure' x 'CClosure') 2014-06-19 15:27:20 -03:00
Roberto Ierusalimschy
8ef9e8460e bug (GC can collect long identifier during parser) + change (using
a single constant table for all functions in a chunk)
2013-08-30 13:01:37 -03:00
Roberto Ierusalimschy
1294b09d8e first implementation of literal integers (no constant folding yet) 2013-04-16 15:46:28 -03:00
Roberto Ierusalimschy
3cadc37f47 no more 'Proto' objects on the stack. Protos are anchored on outer
Protos or on a Closure, which must be created before the Proto.
2012-05-08 10:53:33 -03:00
Roberto Ierusalimschy
59bcd137ae reducing even more use of C stack by the parser: struct 'FuncState'
does not need field 'L' + number of labels/gotos in a chunk may be
limited to SHRT_MAX. (Also removed some non-needed 'unsigned's.)
2011-07-27 15:09:01 -03:00
Roberto Ierusalimschy
7482e8f914 no need of lookahead in Zio 2011-02-23 10:13:10 -03:00
Roberto Ierusalimschy
f079749287 some reorganization of dynamic data structures used by the parser 2011-02-07 15:14:50 -02:00
Roberto Ierusalimschy
7cc0e63d8a first implementation of 'goto' 2011-02-04 15:34:43 -02:00
Roberto Ierusalimschy
81dd13f4c6 new way to distinguish between indexing tables in registers and
tables in upvalues (+ fixed small bug when checking conflicts in
multiple assignments)
2010-07-07 13:27:29 -03:00
Roberto Ierusalimschy
6a02bbe1e2 better organization for fields in struct 'expdesc' 2010-07-02 17:42:40 -03:00
Roberto Ierusalimschy
25c557ec63 first version of _ENV; no more global variables 2010-03-12 16:14:06 -03:00
Roberto Ierusalimschy
0fe2576a39 new instructions to optimize indexing on upvalues 2010-02-26 17:40:29 -03:00
Roberto Ierusalimschy
916587508c parser keeps list of active local variables in a single dynamic array,
therefore saving C stack space
2009-10-11 17:02:19 -03:00
Roberto Ierusalimschy
0ac3d07ea6 first implementation of lexical environments 2009-09-30 12:38:37 -03:00
Roberto Ierusalimschy
5938212748 information about upvalues (where they come from) kept in Proto structure,
instead of sequence of pseudo-opcodes after OP_CLOSURE
2009-09-28 13:32:50 -03:00
Roberto Ierusalimschy
198be23f36 added structure for local-variable information to allow extra
checkings if needed
2008-05-08 12:44:51 -03:00
Roberto Ierusalimschy
3d61c31e5a 'lparser.h' should not include 'ltable.h' 2006-03-09 15:15:48 -03:00
Roberto Ierusalimschy
6dd0c6ccbc numeral expressions keep their values in struct 'expdesc' 2005-10-03 11:02:40 -03:00
Roberto Ierusalimschy
8718fda9b2 added LUAI_FUNC to functions not in the API 2005-04-25 16:24:10 -03:00
Roberto Ierusalimschy
370d31a559 luac´ -> luai' (to avoid confusion with other luac stuff) 2005-03-09 13:28:07 -03:00
Roberto Ierusalimschy
f8df21bd20 `luaconf.h´ exports all its definitions always (so all of them
must have a lua/LUA prefix).
2005-03-08 17:10:05 -03:00
Roberto Ierusalimschy
b6a7983b65 USHRT_MAX may not fit in a (16-bit) int 2005-03-07 13:58:27 -03:00
Roberto Ierusalimschy
616438fe9a new way to use vararg' parameters (with ...') 2004-05-31 15:51:50 -03:00
Roberto Ierusalimschy
9fcc485176 zio does not keep "source" name (nobody uses it) 2003-08-25 16:51:54 -03:00
Roberto Ierusalimschy
265530478b more changes to reduce stack usage by the parser 2003-07-09 17:11:30 -03:00
Roberto Ierusalimschy
00180bb133 small changes to reduce stack usage by the parser 2003-07-09 12:36:38 -03:00