Commit Graph

59 Commits

Author SHA1 Message Date
Roberto Ierusalimschy
ab6a949522 Merge branch 'master' into nextversion 2023-06-22 11:41:48 -03:00
Roberto Ierusalimschy
ab859fe59b Bug: Loading a corrupted binary file can segfault
The size of the list of upvalue names are stored separated from the
size of the list of upvalues, but they share the same array.
2023-03-17 15:52:09 -03:00
Roberto Ierusalimschy
7d6a97e42b Dump doesn't need to reuse 'source'
All strings are being reused now, including 'source'.
2022-12-20 11:14:52 -03:00
Roberto Ierusalimschy
d70a0c91ad Dump/undump reuse strings
A repeated string in a dump is represented as an index to its first
occurence, instead of another copy of the string.
2022-12-15 16:44:22 -03:00
Roberto Ierusalimschy
61a4e64a66 Back to old encoding of versions in binary files
(Undoing part of commit f53eabeed8.)  It is better to keep this encoding
stable, so that all Lua versions can read at least the version of a
binary file.
2020-05-06 14:19:08 -03:00
Roberto Ierusalimschy
e8a52281d9 Code style in 'ldump'/'lundump'.
- function names start with lower case;
- state is always the first parameter.
2020-02-27 15:17:44 -03:00
Roberto Ierusalimschy
46c3587a6f Clearer distinction between types and tags
LUA_T* represents only types; tags (types + Variants) are represented
by LUA_V* constants.
2020-01-31 11:09:53 -03:00
Roberto Ierusalimschy
5ff408d218 Changed internal representation of booleans
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.)
2020-01-06 11:38:31 -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
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
f53eabeed8 Small changes in the header of binary files
- LUAC_VERSION is equal to LUA_VERSION_NUM, and it is stored
as an int.

- 'sizeof(int)' and 'sizeof(size_t)' removed from the header, as
the binary format does not depend on these sizes. (It uses its
own serialization for unsigned integer values.)
2019-03-19 15:31:08 -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
ef8263f81f better names for macros for tags and types.
rttype -> rawtt; ttyperaw -> withvariant; ttype -> ttypetag;
tnov -> ttype
2018-02-26 11:16:05 -03:00
Roberto Ierusalimschy
dfd188ba12 detail (identation of switch) 2017-11-28 09:19:07 -02:00
Roberto Ierusalimschy
124bfd2081 dumping ints and size_ts compacted 2017-06-27 11:21:12 -03: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
0c78de0d6d avoid calling write function with empty block 2015-10-08 12:53:49 -03:00
Roberto Ierusalimschy
fcc6e1220e avoid expression with side effect (in debug mode) inside 'sizeof' 2015-03-30 12:43:51 -03:00
Roberto Ierusalimschy
7e2015a46d size of short strings stored in a single byte, to reduce the size
of struct 'TString'
2015-01-16 14:54:37 -02:00
Roberto Ierusalimschy
28fdbcf393 added include for 'lprefix.h', for stuff that must be added before
any other header file
2014-11-02 17:19:04 -02:00
Roberto Ierusalimschy
ca41b43f53 type 'TString' refers directly to the structure inside the union
(union used only for size purposes)
2014-07-18 10:36:14 -03:00
Roberto Ierusalimschy
7021cc9bc8 allows different 'source' for each prototype, but inherits it from
parent when they are equal (only possible case for chunks created
by the parser)
2014-06-18 15:35:43 -03:00
Roberto Ierusalimschy
04da0a40c0 added assertion about sources being the same for all protos in a chunk 2014-06-18 10:54:31 -03:00
Roberto Ierusalimschy
94266dfdbd source for all prototypes must be equal in a chunk; no need to store
each one separated
2014-06-18 10:21:12 -03:00
Roberto Ierusalimschy
607be77ec8 some details to avoid warnings 2014-04-01 11:39:55 -03:00
Roberto Ierusalimschy
420cc62fac missplelling in comments/function names (endianess -> endianness) 2014-03-27 12:58:05 -03:00
Roberto Ierusalimschy
80fe8504f5 make all dumps/loads go trhough Load/DumpVector (so it is easier
to adapt the code to correct endianess, if needed)
2014-03-11 15:56:27 -03:00
Roberto Ierusalimschy
e976384213 keep chunk's headers compatible at least up to LUAC_VERSION (to be
able to detect correctly version mismatches)
2014-03-11 15:05:46 -03:00
Roberto Ierusalimschy
197e249433 "indent -kr -i2 -br -brf -nut" plus a few manual formating 2014-03-10 14:56:32 -03:00
Roberto Ierusalimschy
f69e0ade19 no need to store a full 'size_t' fo the size of (frequent) small strings 2014-03-01 12:18:44 -03:00
Roberto Ierusalimschy
99a1c06ea3 more regularity with vectors + sizeof computed by the macros themselves 2014-02-28 13:13:01 -03:00
Roberto Ierusalimschy
93e28031de all chars used in binary dumps are unsigned ('lu_byte') 2014-02-28 09:25:12 -03:00
Roberto Ierusalimschy
de84b3fecb store number of upvalues of main function in front of the dump,
so that undump can create initial closure before reading its prototype
2014-02-27 15:56:15 -03:00
Roberto Ierusalimschy
054179c2ff more explicit handling of headers for binary chunks 2014-02-27 13:56:20 -03:00
Roberto Ierusalimschy
eee51492e2 dumping and undumping integers 2013-04-26 15:48:35 -03:00
Roberto Ierusalimschy
8f8665fffa 'ttypenv' -> 'ttnov' 2013-04-12 16:07:09 -03:00
Roberto Ierusalimschy
f88806a1fb "default: lua_assert(0)" in switches helps debugging + uses
non-variant types in binary files
2012-01-23 21:02:10 -02:00
Roberto Ierusalimschy
6e899850b9 details 2011-11-24 11:25:41 -02:00
Roberto Ierusalimschy
6c8a32217a changes by lhf (better control of chars x bytes) 2011-05-17 09:42:43 -03:00
Roberto Ierusalimschy
1475cb59bf version from lhf 2010-10-25 12:33:38 -02:00
Roberto Ierusalimschy
25c557ec63 first version of _ENV; no more global variables 2010-03-12 16:14:06 -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
1ceec74370 useless test removed (pointed by lint) 2008-07-03 11:25:05 -03:00
Roberto Ierusalimschy
a7c9e45c64 avoid trailing white spaces 2006-09-11 11:07:24 -03:00
Roberto Ierusalimschy
69ea087dff small change to strip file names when stripping debug information 2006-02-17 13:51:03 -02:00
Roberto Ierusalimschy
2753134a38 new versions by lhf 2005-11-16 09:55:07 -02:00
Roberto Ierusalimschy
67578ec51f several small details 2005-05-17 16:49:15 -03:00
Roberto Ierusalimschy
1ab2b93462 debug information for last line of a function definition 2005-05-05 17:47:02 -03:00
Roberto Ierusalimschy
5d834bdf57 function constants may include boolean values 2004-10-04 16:01:12 -03:00