Commit Graph

163 Commits

Author SHA1 Message Date
Roberto Ierusalimschy
6f5bd5072d Macro LUAI_ASSERT eases turning assertions on 2020-07-08 15:51:55 -03:00
Roberto Ierusalimschy
3747487320 Small correction in assertion 2019-12-13 14:02:42 -03:00
Roberto Ierusalimschy
279c3a6961 A few changes in tests about number of bits in integers
- The preprocessor must work with at least 'long', and therefore must
do shifts of up to 31 bits correctly.
- Whenever possible, use unsigned types in shifts.
2019-05-13 16:17:21 -03:00
Roberto Ierusalimschy
49c42f3615 Some improvements in 'luaconf.h'
Added '#if !defined' in some definitions to allow external definitions;
more comments; other small changes.
2019-05-13 14:24:10 -03:00
Roberto Ierusalimschy
b14609032c Avoid the creation of too many strings in 'package'
Both when setting a path and searching for a file ('searchpath'),
this commit reduces the number of intermediate strings created
in Lua.
(For setting a path the change is not relevant, because this is
done only twice when loading the module. Anyway, it is a nice example
of how to use auxlib buffers to manipulate strings in the C API.)
2019-05-03 10:14:25 -03:00
Roberto Ierusalimschy
5ca1075b71 Added field 'srclen' to structure 'lua_Debug'
This new field gets the length of 'source' in the same structure.
Unlike the other strings in that structure, 'source' can be
relatively large, and Lua already has its length readily available.
2019-04-04 11:45:26 -03:00
Roberto Ierusalimschy
0443ad9e28 LUAI_MAXCCALLS renamed LUAI_MAXCSTACK
The limit LUAI_MAXCCALLS was renamed LUAI_MAXCSTACK, which better
represents its meaning. Moreover, its definition was moved to
'luaconf.h', given its importance now that Lua does not use
a "stackless" implementation.
2019-03-25 14:12:06 -03:00
Roberto Ierusalimschy
23e6bac8a0 Keep correct type for immediate operands in comparisons
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
2019-03-22 13:37:17 -03:00
Roberto Ierusalimschy
ba7da13ec5 Changes in the control of C-stack overflow
* 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.)
2018-12-27 14:32:29 -02:00
Roberto Ierusalimschy
9cbf17b0f1 Details (comments) 2018-09-11 08:39:12 -03:00
Roberto Ierusalimschy
5382a22e0e Corrections in the implementation of '%' for floats.
The multiplication (m*b) used to test whether 'm' is non-zero and
'm' and 'b' have different signs can underflow for very small numbers,
giving a wrong result. The use of explicit comparisons solves this
problem. This commit also adds several new tests for '%' (both for
floats and for integers) to exercise more corner cases, such as
very large and very small values.
2018-08-28 12:36:58 -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
06127927ff new macro 'ispow2' 2018-06-15 11:13:45 -03:00
Roberto Ierusalimschy
34aa0c5bd7 new macros 'likely'/'unlikely' with hints for jump predictions
(used only in errors for now)
2018-05-30 11:25:52 -03:00
Roberto Ierusalimschy
e2b15aa21d janitor work on casts 2018-01-28 13:13:26 -02:00
Roberto Ierusalimschy
f99f3c42ff comment 2017-12-28 09:51:00 -02:00
Roberto Ierusalimschy
7ad20af2cf more freedom in handling memory-allocation errors (not all allocations
automatically raise an error), which allows fixing a bug when resizing
a table.
2017-12-11 16:53:53 -02:00
Roberto Ierusalimschy
d0356d5f15 another value for LUAI_MAXCCALLS (must think more about that) 2017-12-01 13:08:14 -02:00
Roberto Ierusalimschy
196c87c9ce no more 'stackless' implementation; 'luaV_execute' calls itself
recursively to execute function calls. 'unroll' continues all
executions suspended by an yield (through a long jump)
2017-11-23 14:41:16 -02:00
Roberto Ierusalimschy
60a7492d24 new type 'ls_byte' for signed bytes 2017-06-27 08:35:01 -03:00
Roberto Ierusalimschy
4bc33d64de avoid overflows in computation of step size 2017-06-01 16:16:34 -03:00
Roberto Ierusalimschy
2caecf1b3e type 'L_Umaxalign' replaced by macro 'LUAI_MAXALIGN', which is also added
to the auxlib buffer
2017-04-24 15:06:12 -03:00
Roberto Ierusalimschy
d103312661 details (typos in comments) 2015-11-19 17:16:22 -02:00
Roberto Ierusalimschy
5bdee4f810 small changes to allow 'precall' to spend time preserving 'func'
only when needed (that is, when stack actually changes)
2015-10-21 16:40:47 -02:00
Roberto Ierusalimschy
9294466234 detail (string cache a bit smaller by default) 2015-10-06 11:29:49 -03:00
Roberto Ierusalimschy
9fae7b6d3f code for string cache generalized for "associative sets" (compiler
will optimize away or inline the extra loops)
2015-09-22 11:18:24 -03:00
Roberto Ierusalimschy
1198d82530 'lua_longassert' defined as an expression (instead of a command) 2015-09-08 13:53:56 -03:00
Roberto Ierusalimschy
b9db9bd0ef 'lua_Number' added to 'L_Umaxalign' union 2015-07-15 12:57:13 -03:00
Roberto Ierusalimschy
16e8bb360b comment 2015-06-09 11:21:00 -03:00
Roberto Ierusalimschy
a30c66f0fc macro 'luai_apicheck'/'api_check' back with a 'lua_State' parameter
(some people use it)
2015-03-06 16:49:50 -03:00
Roberto Ierusalimschy
a80cada914 new cache for interning strings 2015-03-04 10:31:21 -03:00
Roberto Ierusalimschy
a00013c8d0 'point2int' -> 'point2uint' (to reflect its actual result type) 2015-03-03 16:53:13 -03:00
Roberto Ierusalimschy
4ccc4578b3 detail (use 'l_floor' instead of 'l_mathop(floor)') 2015-02-09 13:41:56 -02:00
Roberto Ierusalimschy
c8d6cb0136 macros 'luai_num*' (for float arithmetic operations) moved to
llimits.h.
2015-02-05 15:15:33 -02:00
Roberto Ierusalimschy
438a9fcc78 LUAI_MAXSHORTLEN moved from 'luaconf.h' to 'llimits.h' (does not
affect the API and is seldom modified)
2015-01-16 15:15:52 -02:00
Roberto Ierusalimschy
5b01cb39b5 larger MINSTRTABSIZE (standard Lua starts with ~230 strings, after
oppening the standard libraries)
2015-01-16 13:41:03 -02:00
Roberto Ierusalimschy
a0503305bd comments 2015-01-16 11:26:55 -02:00
Roberto Ierusalimschy
cdd26700e8 definition for 'MAXUPVAL' moved for a more "private" place and its
value and comment corrected to reflect current implementation
2015-01-13 13:49:11 -02:00
Roberto Ierusalimschy
1465edf341 old Visual Studio versions did not support 'noreturn' attribute 2014-12-19 11:30:23 -02:00
Roberto Ierusalimschy
e75c0148c3 comments (references to "ANSI C" changed to "ISO C", which is the
international name
2014-11-02 17:33:33 -02:00
Roberto Ierusalimschy
ff6c034330 configurations for types 'lu_mem'/'l_mem'/'Instruction' moved to here
(from 'luaconf.h'), as they are not needed by the API and probably
will not be changed
2014-10-29 15:07:45 -02:00
Roberto Ierusalimschy
491103708e 'MAXSTACK' -> 'MAXREGS' and moved to 'lcode.c' (there is no reason
to change that constant...)
2014-10-27 14:29:58 -02:00
Roberto Ierusalimschy
bdf566a8a3 `name' in comments changed to 'name' 2014-10-25 09:50:46 -02:00
Roberto Ierusalimschy
325e44d87e no more "-2" for limits. (Limits should be precise; safety is in
the code that handles these limits.)
2014-07-18 15:29:12 -03:00
Roberto Ierusalimschy
54ac253343 detail (no need to define LUAI_USER_ALIGNMENT_T when it is not
defined; simpler to define 'L_Umaxalign' directly)
2014-07-18 15:18:45 -03:00
Roberto Ierusalimschy
5bbb4a06a6 removed unused parameter Ä'L' in macro 'api_check' and company 2014-07-15 18:26:50 -03:00
Roberto Ierusalimschy
c94f11d783 'IntPoint' -> 'point2int' + ensure that casted value fits in
destination type
2014-06-26 13:17:35 -03:00
Roberto Ierusalimschy
037a70dfea cast_u2s/cast_s2u renamed l_castS2U/l_castU2S to be configurable from
outside (mostly for testing)
2014-04-15 13:32:49 -03:00
Roberto Ierusalimschy
8f961da3db macros cast_integer/cast_unsigned replaced by cast_u2s/cast_s2u, that
should be used only between lua_Integer and lua_Unsigned
2014-04-15 11:29:30 -03:00
Roberto Ierusalimschy
ef789d4161 new global macro 'LUA_MAXUNSIGNED' 2014-04-12 11:45:10 -03:00