diff options
author | Lua Team <team@lua.org> | 2015-01-02 12:00:00 +0000 |
---|---|---|
committer | repogen <> | 2015-01-02 12:00:00 +0000 |
commit | 6b0dd2d3885d020d3154e0da84de92e9ee8b2c82 (patch) | |
tree | a5513d60b8154b2855e8246087520fde146516e7 | |
parent | 65cb014c87f5ecfee995afc9babba930d6a9f0bc (diff) | |
download | lua-github-6b0dd2d3885d020d3154e0da84de92e9ee8b2c82.tar.gz |
Lua 5.3.0-rc35.3.0-rc3
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | doc/contents.html | 2 | ||||
-rw-r--r-- | doc/manual.html | 38 | ||||
-rw-r--r-- | doc/readme.html | 2 | ||||
-rw-r--r-- | src/Makefile | 2 | ||||
-rw-r--r-- | src/lapi.c | 4 | ||||
-rw-r--r-- | src/lcode.c | 34 | ||||
-rw-r--r-- | src/ldblib.c | 9 | ||||
-rw-r--r-- | src/ldebug.c | 7 | ||||
-rw-r--r-- | src/liolib.c | 8 | ||||
-rw-r--r-- | src/lmathlib.c | 8 | ||||
-rw-r--r-- | src/lobject.c | 4 | ||||
-rw-r--r-- | src/loslib.c | 6 | ||||
-rw-r--r-- | src/lparser.c | 8 | ||||
-rw-r--r-- | src/lprefix.h | 10 | ||||
-rw-r--r-- | src/lua.h | 6 | ||||
-rw-r--r-- | src/luaconf.h | 12 | ||||
-rw-r--r-- | src/lvm.c | 239 |
18 files changed, 220 insertions, 181 deletions
@@ -1,5 +1,5 @@ -This is Lua 5.3.0, released on 22 Dec 2014. +This is Lua 5.3.0, released on 02 Jan 2015. For installation instructions, license details, and further information about Lua, see doc/readme.html. diff --git a/doc/contents.html b/doc/contents.html index 61c97c6c..e59e4215 100644 --- a/doc/contents.html +++ b/doc/contents.html @@ -33,7 +33,7 @@ For a complete introduction to Lua programming, see the book <A HREF="#index">index</A> <HR> <SMALL> -Copyright © 2014 Lua.org, PUC-Rio. +Copyright © 2015 Lua.org, PUC-Rio. Freely available under the terms of the <A HREF="http://www.lua.org/license.html">Lua license</A>. </SMALL> diff --git a/doc/manual.html b/doc/manual.html index 1807c003..f082929e 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -19,7 +19,7 @@ Lua 5.3 Reference Manual by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes <p> <small> -Copyright © 2014 Lua.org, PUC-Rio. +Copyright © 2015 Lua.org, PUC-Rio. Freely available under the terms of the <a href="http://www.lua.org/license.html">Lua license</a>. </small> @@ -33,7 +33,7 @@ Freely available under the terms of the <!-- ====================================================================== --> <p> -<!-- $Id: manual.of,v 1.142 2014/12/22 13:31:36 roberto Exp $ --> +<!-- $Id: manual.of,v 1.143 2015/01/02 13:07:38 roberto Exp $ --> @@ -1855,7 +1855,7 @@ Lua supports the following arithmetic operators: </ul> <p> -With the exception of float division and exponentiation, +With the exception of exponentiation and float division, the arithmetic operators work as follows: If both operands are integers, the operation is performed over integers and the result is an integer. @@ -1870,7 +1870,7 @@ and the result is a float. <p> -Float division (<code>/</code>) and exponentiation +Exponentiation and float division (<code>/</code>) always convert their operands to floats and the result is always a float. Exponentiation uses the ISO C function <code>pow</code>, @@ -1932,7 +1932,7 @@ result in zero (as all bits are shifted out). Lua provides some automatic conversions between some types and representations at run time. Bitwise operators always convert float operands to integers. -Float division and exponentiation +Exponentiation and float division always convert integer operands to floats. All other arithmetic operations applied to mixed numbers (integers and floats) convert the integer operand to a float; @@ -2893,7 +2893,7 @@ replacing <a href="#lua_pcall"><code>lua_pcall</code></a> by <a href="#lua_pcall </pre><p> Note the external, explicit call to the continuation: Lua will call the continuation only if needed, that is, -in case of errors or resuming after an yield. +in case of errors or resuming after a yield. If the called function returns normally without ever yielding, <a href="#lua_pcallk"><code>lua_pcallk</code></a> (and <a href="#lua_callk"><code>lua_callk</code></a>) will also return normally. (Of course, instead of calling the continuation in that case, @@ -2910,7 +2910,7 @@ it only passes this value from the original function to the continuation function.) For <a href="#lua_pcallk"><code>lua_pcallk</code></a>, the status is the same value that would be returned by <a href="#lua_pcallk"><code>lua_pcallk</code></a>, -except that it is <a href="#pdf-LUA_YIELD"><code>LUA_YIELD</code></a> when being executed after an yield +except that it is <a href="#pdf-LUA_YIELD"><code>LUA_YIELD</code></a> when being executed after a yield (instead of <a href="#pdf-LUA_OK"><code>LUA_OK</code></a>). For <a href="#lua_yieldk"><code>lua_yieldk</code></a> and <a href="#lua_callk"><code>lua_callk</code></a>, the status is always <a href="#pdf-LUA_YIELD"><code>LUA_YIELD</code></a> when Lua calls the continuation. @@ -5785,7 +5785,7 @@ when the index is greater than the number of upvalues. <pre>void *lua_upvalueid (lua_State *L, int funcindex, int n);</pre> <p> -Returns an unique identifier for the upvalue numbered <code>n</code> +Returns a unique identifier for the upvalue numbered <code>n</code> from the closure at index <code>funcindex</code>. Parameters <code>funcindex</code> and <code>n</code> are as in the <a href="#lua_getupvalue"><code>lua_getupvalue</code></a> (see <a href="#lua_getupvalue"><code>lua_getupvalue</code></a>) @@ -6576,6 +6576,7 @@ creates a new table to be used as a metatable for userdata, adds to this new table the pair <code>__name = tname</code>, adds to the registry the pair <code>[tname] = new table</code>, and returns 1. +(The entry <code>__name</code> is used by some error-reporting functions.) <p> @@ -6782,7 +6783,7 @@ Type for arrays of functions to be registered by <a href="#luaL_setfuncs"><code>luaL_setfuncs</code></a>. <code>name</code> is the function name and <code>func</code> is a pointer to the function. -Any array of <a href="#luaL_Reg"><code>luaL_Reg</code></a> must end with an sentinel entry +Any array of <a href="#luaL_Reg"><code>luaL_Reg</code></a> must end with a sentinel entry in which both <code>name</code> and <code>func</code> are <code>NULL</code>. @@ -8552,26 +8553,27 @@ which matches any single character in the class; <li> a single character class followed by '<code>*</code>', -which matches 0 or more repetitions of characters in the class. +which matches zero or more repetitions of characters in the class. These repetition items will always match the longest possible sequence; </li> <li> a single character class followed by '<code>+</code>', -which matches 1 or more repetitions of characters in the class. +which matches one or more repetitions of characters in the class. These repetition items will always match the longest possible sequence; </li> <li> a single character class followed by '<code>-</code>', -which also matches 0 or more repetitions of characters in the class. +which also matches zero or more repetitions of characters in the class. Unlike '<code>*</code>', these repetition items will always match the shortest possible sequence; </li> <li> a single character class followed by '<code>?</code>', -which matches 0 or 1 occurrence of a character in the class; +which matches zero or one occurrence of a character in the class. +It always matches one occurrence if possible; </li> <li> @@ -10108,7 +10110,9 @@ but also parameters, temporaries, etc. <p> The first parameter or local variable has index 1, and so on, -until the last active variable. +following the order that they are declared in the code, +counting only the variables that are active +in the current scope of the function. Negative indices refer to vararg parameters; -1 is the first vararg parameter. The function returns <b>nil</b> if there is no variable with the given index, @@ -10119,7 +10123,7 @@ and raises an error when called with a level out of range. <p> Variable names starting with '<code>(</code>' (open parenthesis) represent variables with no known names -(internal variables like loop control variables, +(internal variables such as loop control variables, and variables from chunks saved without debug information). @@ -10310,7 +10314,7 @@ to start the traceback <p> -Returns an unique identifier (as a light userdata) +Returns a unique identifier (as a light userdata) for the upvalue numbered <code>n</code> from the given function. @@ -10770,7 +10774,7 @@ and LiteralString, see <a href="#3.1">§3.1</a>.) <HR> <SMALL CLASS="footer"> Last update: -Mon Dec 22 12:28:03 BRST 2014 +Fri Jan 2 11:29:40 BRST 2015 </SMALL> <!-- Last change: revised for Lua 5.3.0 (final) diff --git a/doc/readme.html b/doc/readme.html index 0ace9660..01657557 100644 --- a/doc/readme.html +++ b/doc/readme.html @@ -333,7 +333,7 @@ For details, see <A HREF="http://www.lua.org/license.html">this</A>. <BLOCKQUOTE STYLE="padding-bottom: 0em"> -Copyright © 1994–2014 Lua.org, PUC-Rio. +Copyright © 1994–2015 Lua.org, PUC-Rio. <P> Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/src/Makefile b/src/Makefile index 7d1b02c6..4be6dc13 100644 --- a/src/Makefile +++ b/src/Makefile @@ -6,7 +6,7 @@ # Your platform. See PLATS for possible values. PLAT= none -CC= gcc +CC= gcc -std=c99 CFLAGS= -O2 -Wall -Wextra -DLUA_COMPAT_5_2 $(SYSCFLAGS) $(MYCFLAGS) LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS) LIBS= -lm $(SYSLIBS) $(MYLIBS) @@ -1,5 +1,5 @@ /* -** $Id: lapi.c,v 2.243 2014/11/12 13:28:54 roberto Exp $ +** $Id: lapi.c,v 2.244 2014/12/26 14:43:45 roberto Exp $ ** Lua API ** See Copyright Notice in lua.h */ @@ -676,7 +676,7 @@ LUA_API void lua_createtable (lua_State *L, int narray, int nrec) { LUA_API int lua_getmetatable (lua_State *L, int objindex) { const TValue *obj; - Table *mt = NULL; + Table *mt; int res = 0; lua_lock(L); obj = index2addr(L, objindex); diff --git a/src/lcode.c b/src/lcode.c index ad0365a8..5e34624b 100644 --- a/src/lcode.c +++ b/src/lcode.c @@ -1,5 +1,5 @@ /* -** $Id: lcode.c,v 2.98 2014/12/19 13:36:32 roberto Exp $ +** $Id: lcode.c,v 2.99 2014/12/29 16:49:25 roberto Exp $ ** Code generator for Lua ** See Copyright Notice in lua.h */ @@ -33,14 +33,6 @@ #define MAXREGS 250 -/* test for x == -0 ('signbit' needs 'math.h') */ -#if defined(signbit) -#define isminuszero(x) ((x) == 0.0 && signbit(x)) -#else -#define isminuszero(x) ((x) == 0.0 && 1.0/(x) < 0.0) -#endif - - #define hasjumps(e) ((e)->t != (e)->f) @@ -364,14 +356,8 @@ int luaK_intK (FuncState *fs, lua_Integer n) { } -/* -** Both NaN and -0.0 should not go to the constant table, as they have -** problems with the hashing. (NaN is not a valid key, -0.0 collides -** with +0.0.) -*/ static int luaK_numberK (FuncState *fs, lua_Number r) { TValue o; - lua_assert(!luai_numisnan(r) && !isminuszero(r)); setfltvalue(&o, r); return addk(fs, &o, &o); } @@ -761,14 +747,14 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { ** return false if folding can raise an error */ static int validop (int op, TValue *v1, TValue *v2) { - lua_Integer i; - if (luai_numinvalidop(op, nvalue(v1), nvalue(v2))) return 0; switch (op) { case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR: - case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: /* conversion errors */ + case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: { /* conversion errors */ + lua_Integer i; return (tointeger(v1, &i) && tointeger(v2, &i)); - case LUA_OPIDIV: case LUA_OPMOD: /* integer division by 0 */ - return !(ttisinteger(v1) && ttisinteger(v2) && ivalue(v2) == 0); + } + case LUA_OPDIV: case LUA_OPIDIV: case LUA_OPMOD: /* division by 0 */ + return (nvalue(v2) != 0); default: return 1; /* everything else is valid */ } } @@ -781,15 +767,15 @@ static int constfolding (FuncState *fs, int op, expdesc *e1, expdesc *e2) { TValue v1, v2, res; if (!tonumeral(e1, &v1) || !tonumeral(e2, &v2) || !validop(op, &v1, &v2)) return 0; /* non-numeric operands or not safe to fold */ - luaO_arith(fs->ls->L, op, &v1, &v2, &res); + luaO_arith(fs->ls->L, op, &v1, &v2, &res); /* does operation */ if (ttisinteger(&res)) { e1->k = VKINT; e1->u.ival = ivalue(&res); } - else { + else { /* folds neither NaN nor 0.0 (to avoid collapsing with -0.0) */ lua_Number n = fltvalue(&res); - if (luai_numisnan(n) || isminuszero(n)) - return 0; /* folds neither NaN nor -0 */ + if (luai_numisnan(n) || n == 0) + return 0; e1->k = VKFLT; e1->u.nval = n; } diff --git a/src/ldblib.c b/src/ldblib.c index c7aa7bb6..24a11b53 100644 --- a/src/ldblib.c +++ b/src/ldblib.c @@ -1,5 +1,5 @@ /* -** $Id: ldblib.c,v 1.147 2014/12/08 15:47:25 roberto Exp $ +** $Id: ldblib.c,v 1.148 2015/01/02 12:52:22 roberto Exp $ ** Interface from Lua to its debug API ** See Copyright Notice in lua.h */ @@ -207,15 +207,20 @@ static int db_getlocal (lua_State *L) { static int db_setlocal (lua_State *L) { int arg; + const char *name; lua_State *L1 = getthread(L, &arg); lua_Debug ar; int level = (int)luaL_checkinteger(L, arg + 1); + int nvar = (int)luaL_checkinteger(L, arg + 2); if (!lua_getstack(L1, level, &ar)) /* out of range? */ return luaL_argerror(L, arg+1, "level out of range"); luaL_checkany(L, arg+3); lua_settop(L, arg+3); lua_xmove(L, L1, 1); - lua_pushstring(L, lua_setlocal(L1, &ar, (int)luaL_checkinteger(L, arg+2))); + name = lua_setlocal(L1, &ar, nvar); + if (name == NULL) + lua_pop(L1, 1); /* pop value (if not popped by 'lua_setlocal') */ + lua_pushstring(L, name); return 1; } diff --git a/src/ldebug.c b/src/ldebug.c index 5ca62ebf..6986bf0f 100644 --- a/src/ldebug.c +++ b/src/ldebug.c @@ -1,5 +1,5 @@ /* -** $Id: ldebug.c,v 2.109 2014/12/10 11:30:09 roberto Exp $ +** $Id: ldebug.c,v 2.110 2015/01/02 12:52:22 roberto Exp $ ** Debug Interface ** See Copyright Notice in lua.h */ @@ -167,9 +167,10 @@ LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { StkId pos = 0; /* to avoid warnings */ const char *name = findlocal(L, ar->i_ci, n, &pos); lua_lock(L); - if (name) + if (name) { setobjs2s(L, pos, L->top - 1); - L->top--; /* pop value */ + L->top--; /* pop value */ + } lua_unlock(L); return name; } diff --git a/src/liolib.c b/src/liolib.c index 245036bd..4dea3968 100644 --- a/src/liolib.c +++ b/src/liolib.c @@ -1,5 +1,5 @@ /* -** $Id: liolib.c,v 2.141 2014/11/21 12:17:33 roberto Exp $ +** $Id: liolib.c,v 2.142 2015/01/02 12:50:28 roberto Exp $ ** Standard I/O (and system) library ** See Copyright Notice in lua.h */ @@ -464,9 +464,9 @@ static int test_eof (lua_State *L, FILE *f) { static int read_line (lua_State *L, FILE *f, int chop) { luaL_Buffer b; - int c; + int c = '\0'; luaL_buffinit(L, &b); - for (;;) { + while (c != EOF && c != '\n') { /* repeat until end of line */ char *buff = luaL_prepbuffer(&b); /* pre-allocate buffer */ int i = 0; l_lockfile(f); /* no memory errors can happen inside the lock */ @@ -474,8 +474,6 @@ static int read_line (lua_State *L, FILE *f, int chop) { buff[i++] = c; l_unlockfile(f); luaL_addsize(&b, i); - if (i < LUAL_BUFFERSIZE) - break; } if (!chop && c == '\n') /* want a newline and have one? */ luaL_addchar(&b, c); /* add ending newline to result */ diff --git a/src/lmathlib.c b/src/lmathlib.c index 158f2337..002c508b 100644 --- a/src/lmathlib.c +++ b/src/lmathlib.c @@ -1,5 +1,5 @@ /* -** $Id: lmathlib.c,v 1.113 2014/11/07 11:31:58 roberto Exp $ +** $Id: lmathlib.c,v 1.114 2014/12/27 20:32:26 roberto Exp $ ** Standard mathematical library ** See Copyright Notice in lua.h */ @@ -27,9 +27,11 @@ #if defined(LUA_USE_POSIX) #define l_rand() random() #define l_srand(x) srandom(x) +#define L_RANDMAX 2147483647 /* (2^31 - 1), following POSIX */ #else #define l_rand() rand() #define l_srand(x) srand(x) +#define L_RANDMAX RAND_MAX #endif #endif /* } */ @@ -233,12 +235,12 @@ static int math_max (lua_State *L) { /* ** This function uses 'double' (instead of 'lua_Number') to ensure that -** all bits from 'l_rand' can be represented, and that 'RAND_MAX + 1.0' +** all bits from 'l_rand' can be represented, and that 'RANDMAX + 1.0' ** will keep full precision (ensuring that 'r' is always less than 1.0.) */ static int math_random (lua_State *L) { lua_Integer low, up; - double r = (double)l_rand() * (1.0 / ((double)RAND_MAX + 1.0)); + double r = (double)l_rand() * (1.0 / ((double)L_RANDMAX + 1.0)); switch (lua_gettop(L)) { /* check number of arguments */ case 0: { /* no arguments */ lua_pushnumber(L, (lua_Number)r); /* Number between 0 and 1 */ diff --git a/src/lobject.c b/src/lobject.c index ceb4b983..6a24aff9 100644 --- a/src/lobject.c +++ b/src/lobject.c @@ -1,5 +1,5 @@ /* -** $Id: lobject.c,v 2.100 2014/11/21 12:15:57 roberto Exp $ +** $Id: lobject.c,v 2.101 2014/12/26 14:43:45 roberto Exp $ ** Some generic functions over Lua objects ** See Copyright Notice in lua.h */ @@ -189,7 +189,7 @@ static lua_Number lua_strx2number (const char *s, char **endptr) { int sigdig = 0; /* number of significant digits */ int nosigdig = 0; /* number of non-significant digits */ int e = 0; /* exponent correction */ - int neg = 0; /* 1 if number is negative */ + int neg; /* 1 if number is negative */ int dot = 0; /* true after seen a dot */ *endptr = cast(char *, s); /* nothing is valid yet */ while (lisspace(cast_uchar(*s))) s++; /* skip initial spaces */ diff --git a/src/loslib.c b/src/loslib.c index b72ce961..20359b24 100644 --- a/src/loslib.c +++ b/src/loslib.c @@ -1,5 +1,5 @@ /* -** $Id: loslib.c,v 1.53 2014/12/10 15:42:42 roberto Exp $ +** $Id: loslib.c,v 1.54 2014/12/26 14:46:07 roberto Exp $ ** Standard Operating System library ** See Copyright Notice in lua.h */ @@ -100,8 +100,8 @@ #else /* }{ */ /* ISO C definitions */ -#define l_gmtime(t,r) ((void)r, gmtime(t)) -#define l_localtime(t,r) ((void)r, localtime(t)) +#define l_gmtime(t,r) ((void)(r)->tm_sec, gmtime(t)) +#define l_localtime(t,r) ((void)(r)->tm_sec, localtime(t)) #endif /* } */ diff --git a/src/lparser.c b/src/lparser.c index 98b92c22..9a54dfc9 100644 --- a/src/lparser.c +++ b/src/lparser.c @@ -1,5 +1,5 @@ /* -** $Id: lparser.c,v 2.146 2014/11/27 18:41:43 roberto Exp $ +** $Id: lparser.c,v 2.147 2014/12/27 20:31:43 roberto Exp $ ** Lua Parser ** See Copyright Notice in lua.h */ @@ -47,8 +47,8 @@ */ typedef struct BlockCnt { struct BlockCnt *previous; /* chain */ - short firstlabel; /* index of first label in this block */ - short firstgoto; /* index of first pending goto in this block */ + int firstlabel; /* index of first label in this block */ + int firstgoto; /* index of first pending goto in this block */ lu_byte nactvar; /* # active locals outside the block */ lu_byte upval; /* true if some variable in the block is an upvalue */ lu_byte isloop; /* true if 'block' is a loop */ @@ -386,7 +386,7 @@ static int newlabelentry (LexState *ls, Labellist *l, TString *name, l->arr[n].line = line; l->arr[n].nactvar = ls->fs->nactvar; l->arr[n].pc = pc; - l->n++; + l->n = n + 1; return n; } diff --git a/src/lprefix.h b/src/lprefix.h index c2a78cd7..02daa837 100644 --- a/src/lprefix.h +++ b/src/lprefix.h @@ -1,5 +1,5 @@ /* -** $Id: lprefix.h,v 1.1 2014/11/03 15:12:44 roberto Exp $ +** $Id: lprefix.h,v 1.2 2014/12/29 16:54:13 roberto Exp $ ** Definitions for Lua code that must come before any other header file ** See Copyright Notice in lua.h */ @@ -11,18 +11,24 @@ /* ** Allows POSIX/XSI stuff */ +#if !defined(LUA_USE_C89) /* { */ + #if !defined(_XOPEN_SOURCE) #define _XOPEN_SOURCE 600 +#elif _XOPEN_SOURCE == 0 +#undef _XOPEN_SOURCE /* use -D_XOPEN_SOURCE=0 to undefine it */ #endif /* ** Allows manipulation of large files in gcc and some other compilers */ -#if !defined(_FILE_OFFSET_BITS) +#if !defined(LUA_32BITS) && !defined(_FILE_OFFSET_BITS) #define _LARGEFILE_SOURCE 1 #define _FILE_OFFSET_BITS 64 #endif +#endif /* } */ + /* ** Windows stuff @@ -1,5 +1,5 @@ /* -** $Id: lua.h,v 1.324 2014/12/08 15:12:07 roberto Exp $ +** $Id: lua.h,v 1.325 2014/12/26 17:24:27 roberto Exp $ ** Lua - A Scripting Language ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) ** See Copyright Notice at the end of this file @@ -23,7 +23,7 @@ #define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR #define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE -#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2014 Lua.org, PUC-Rio" +#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2015 Lua.org, PUC-Rio" #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes" @@ -459,7 +459,7 @@ struct lua_Debug { /****************************************************************************** -* Copyright (C) 1994-2014 Lua.org, PUC-Rio. +* Copyright (C) 1994-2015 Lua.org, PUC-Rio. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the diff --git a/src/luaconf.h b/src/luaconf.h index 7e9cd9a7..fd28d21a 100644 --- a/src/luaconf.h +++ b/src/luaconf.h @@ -1,5 +1,5 @@ /* -** $Id: luaconf.h,v 1.236 2014/12/19 13:31:12 roberto Exp $ +** $Id: luaconf.h,v 1.238 2014/12/29 13:27:55 roberto Exp $ ** Configuration file for Lua ** See Copyright Notice in lua.h */ @@ -476,7 +476,7 @@ #include <math.h> /* floor division (defined as 'floor(a/b)') */ -#define luai_numidiv(L,a,b) ((void)L, l_mathop(floor)((a)/(b))) +#define luai_numidiv(L,a,b) ((void)L, l_mathop(floor)(luai_numdiv(L,a,b))) /* ** module: defined as 'a - floor(a/b)*b'; the previous definition gives @@ -508,14 +508,6 @@ /* -** The following macro checks whether an operation is not safe to be -** performed by the constant folder. It should result in zero only if -** the operation is safe. -*/ -#define luai_numinvalidop(op,a,b) 0 - - -/* @@ LUA_INTEGER is the integer type used by Lua. ** @@ LUA_UNSIGNED is the unsigned version of LUA_INTEGER. @@ -1,5 +1,5 @@ /* -** $Id: lvm.c,v 2.231 2014/12/19 13:36:32 roberto Exp $ +** $Id: lvm.c,v 2.232 2014/12/27 20:30:38 roberto Exp $ ** Lua virtual machine ** See Copyright Notice in lua.h */ @@ -644,8 +644,8 @@ void luaV_finishOp (lua_State *L) { #define vmdispatch(o) switch(o) -#define vmcase(l,b) case l: {b} break; -#define vmcasenb(l,b) case l: {b} /* nb = no break */ +#define vmcase(l) case l: +#define vmbreak break void luaV_execute (lua_State *L) { CallInfo *ci = L->ci; @@ -670,53 +670,64 @@ void luaV_execute (lua_State *L) { lua_assert(base == ci->u.l.base); lua_assert(base <= L->top && L->top < L->stack + L->stacksize); vmdispatch (GET_OPCODE(i)) { - vmcase(OP_MOVE, + vmcase(OP_MOVE) { setobjs2s(L, ra, RB(i)); - ) - vmcase(OP_LOADK, + vmbreak; + } + vmcase(OP_LOADK) { TValue *rb = k + GETARG_Bx(i); setobj2s(L, ra, rb); - ) - vmcase(OP_LOADKX, + vmbreak; + } + vmcase(OP_LOADKX) { TValue *rb; lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_EXTRAARG); rb = k + GETARG_Ax(*ci->u.l.savedpc++); setobj2s(L, ra, rb); - ) - vmcase(OP_LOADBOOL, + vmbreak; + } + vmcase(OP_LOADBOOL) { setbvalue(ra, GETARG_B(i)); if (GETARG_C(i)) ci->u.l.savedpc++; /* skip next instruction (if C) */ - ) - vmcase(OP_LOADNIL, + vmbreak; + } + vmcase(OP_LOADNIL) { int b = GETARG_B(i); do { setnilvalue(ra++); } while (b--); - ) - vmcase(OP_GETUPVAL, + vmbreak; + } + vmcase(OP_GETUPVAL) { int b = GETARG_B(i); setobj2s(L, ra, cl->upvals[b]->v); - ) - vmcase(OP_GETTABUP, + vmbreak; + } + vmcase(OP_GETTABUP) { int b = GETARG_B(i); Protect(luaV_gettable(L, cl->upvals[b]->v, RKC(i), ra)); - ) - vmcase(OP_GETTABLE, + vmbreak; + } + vmcase(OP_GETTABLE) { Protect(luaV_gettable(L, RB(i), RKC(i), ra)); - ) - vmcase(OP_SETTABUP, + vmbreak; + } + vmcase(OP_SETTABUP) { int a = GETARG_A(i); Protect(luaV_settable(L, cl->upvals[a]->v, RKB(i), RKC(i))); - ) - vmcase(OP_SETUPVAL, + vmbreak; + } + vmcase(OP_SETUPVAL) { UpVal *uv = cl->upvals[GETARG_B(i)]; setobj(L, uv->v, ra); luaC_upvalbarrier(L, uv); - ) - vmcase(OP_SETTABLE, + vmbreak; + } + vmcase(OP_SETTABLE) { Protect(luaV_settable(L, ra, RKB(i), RKC(i))); - ) - vmcase(OP_NEWTABLE, + vmbreak; + } + vmcase(OP_NEWTABLE) { int b = GETARG_B(i); int c = GETARG_C(i); Table *t = luaH_new(L); @@ -724,13 +735,15 @@ void luaV_execute (lua_State *L) { if (b != 0 || c != 0) luaH_resize(L, t, luaO_fb2int(b), luaO_fb2int(c)); checkGC(L, ra + 1); - ) - vmcase(OP_SELF, + vmbreak; + } + vmcase(OP_SELF) { StkId rb = RB(i); setobjs2s(L, ra+1, rb); Protect(luaV_gettable(L, rb, RKC(i), ra)); - ) - vmcase(OP_ADD, + vmbreak; + } + vmcase(OP_ADD) { TValue *rb = RKB(i); TValue *rc = RKC(i); lua_Number nb; lua_Number nc; @@ -742,8 +755,9 @@ void luaV_execute (lua_State *L) { setfltvalue(ra, luai_numadd(L, nb, nc)); } else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_ADD)); } - ) - vmcase(OP_SUB, + vmbreak; + } + vmcase(OP_SUB) { TValue *rb = RKB(i); TValue *rc = RKC(i); lua_Number nb; lua_Number nc; @@ -755,8 +769,9 @@ void luaV_execute (lua_State *L) { setfltvalue(ra, luai_numsub(L, nb, nc)); } else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_SUB)); } - ) - vmcase(OP_MUL, + vmbreak; + } + vmcase(OP_MUL) { TValue *rb = RKB(i); TValue *rc = RKC(i); lua_Number nb; lua_Number nc; @@ -768,8 +783,9 @@ void luaV_execute (lua_State *L) { setfltvalue(ra, luai_nummul(L, nb, nc)); } else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_MUL)); } - ) - vmcase(OP_DIV, /* float division (always with floats) */ + vmbreak; + } + vmcase(OP_DIV) { /* float division (always with floats) */ TValue *rb = RKB(i); TValue *rc = RKC(i); lua_Number nb; lua_Number nc; @@ -777,8 +793,9 @@ void luaV_execute (lua_State *L) { setfltvalue(ra, luai_numdiv(L, nb, nc)); } else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_DIV)); } - ) - vmcase(OP_BAND, + vmbreak; + } + vmcase(OP_BAND) { TValue *rb = RKB(i); TValue *rc = RKC(i); lua_Integer ib; lua_Integer ic; @@ -786,8 +803,9 @@ void luaV_execute (lua_State *L) { setivalue(ra, intop(&, ib, ic)); } else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_BAND)); } - ) - vmcase(OP_BOR, + vmbreak; + } + vmcase(OP_BOR) { TValue *rb = RKB(i); TValue *rc = RKC(i); lua_Integer ib; lua_Integer ic; @@ -795,8 +813,9 @@ void luaV_execute (lua_State *L) { setivalue(ra, intop(|, ib, ic)); } else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_BOR)); } - ) - vmcase(OP_BXOR, + vmbreak; + } + vmcase(OP_BXOR) { TValue *rb = RKB(i); TValue *rc = RKC(i); lua_Integer ib; lua_Integer ic; @@ -804,8 +823,9 @@ void luaV_execute (lua_State *L) { setivalue(ra, intop(^, ib, ic)); } else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_BXOR)); } - ) - vmcase(OP_SHL, + vmbreak; + } + vmcase(OP_SHL) { TValue *rb = RKB(i); TValue *rc = RKC(i); lua_Integer ib; lua_Integer ic; @@ -813,8 +833,9 @@ void luaV_execute (lua_State *L) { setivalue(ra, luaV_shiftl(ib, ic)); } else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_SHL)); } - ) - vmcase(OP_SHR, + vmbreak; + } + vmcase(OP_SHR) { TValue *rb = RKB(i); TValue *rc = RKC(i); lua_Integer ib; lua_Integer ic; @@ -822,8 +843,9 @@ void luaV_execute (lua_State *L) { setivalue(ra, luaV_shiftl(ib, -ic)); } else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_SHR)); } - ) - vmcase(OP_MOD, + vmbreak; + } + vmcase(OP_MOD) { TValue *rb = RKB(i); TValue *rc = RKC(i); lua_Number nb; lua_Number nc; @@ -837,8 +859,9 @@ void luaV_execute (lua_State *L) { setfltvalue(ra, m); } else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_MOD)); } - ) - vmcase(OP_IDIV, /* floor division */ + vmbreak; + } + vmcase(OP_IDIV) { /* floor division */ TValue *rb = RKB(i); TValue *rc = RKC(i); lua_Number nb; lua_Number nc; @@ -850,8 +873,9 @@ void luaV_execute (lua_State *L) { setfltvalue(ra, luai_numidiv(L, nb, nc)); } else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_IDIV)); } - ) - vmcase(OP_POW, + vmbreak; + } + vmcase(OP_POW) { TValue *rb = RKB(i); TValue *rc = RKC(i); lua_Number nb; lua_Number nc; @@ -859,8 +883,9 @@ void luaV_execute (lua_State *L) { setfltvalue(ra, luai_numpow(L, nb, nc)); } else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_POW)); } - ) - vmcase(OP_UNM, + vmbreak; + } + vmcase(OP_UNM) { TValue *rb = RB(i); lua_Number nb; if (ttisinteger(rb)) { @@ -873,8 +898,9 @@ void luaV_execute (lua_State *L) { else { Protect(luaT_trybinTM(L, rb, rb, ra, TM_UNM)); } - ) - vmcase(OP_BNOT, + vmbreak; + } + vmcase(OP_BNOT) { TValue *rb = RB(i); lua_Integer ib; if (tointeger(rb, &ib)) { @@ -883,16 +909,19 @@ void luaV_execute (lua_State *L) { else { Protect(luaT_trybinTM(L, rb, rb, ra, TM_BNOT)); } - ) - vmcase(OP_NOT, + vmbreak; + } + vmcase(OP_NOT) { TValue *rb = RB(i); int res = l_isfalse(rb); /* next assignment may change this value */ setbvalue(ra, res); - ) - vmcase(OP_LEN, + vmbreak; + } + vmcase(OP_LEN) { Protect(luaV_objlen(L, ra, RB(i))); - ) - vmcase(OP_CONCAT, + vmbreak; + } + vmcase(OP_CONCAT) { int b = GETARG_B(i); int c = GETARG_C(i); StkId rb; @@ -903,11 +932,13 @@ void luaV_execute (lua_State *L) { setobjs2s(L, ra, rb); checkGC(L, (ra >= rb ? ra + 1 : rb)); L->top = ci->top; /* restore top */ - ) - vmcase(OP_JMP, + vmbreak; + } + vmcase(OP_JMP) { dojump(ci, i, 0); - ) - vmcase(OP_EQ, + vmbreak; + } + vmcase(OP_EQ) { TValue *rb = RKB(i); TValue *rc = RKC(i); Protect( @@ -916,30 +947,34 @@ void luaV_execute (lua_State *L) { else donextjump(ci); ) - ) - vmcase(OP_LT, + vmbreak; + } + vmcase(OP_LT) { Protect( if (luaV_lessthan(L, RKB(i), RKC(i)) != GETARG_A(i)) ci->u.l.savedpc++; else donextjump(ci); ) - ) - vmcase(OP_LE, + vmbreak; + } + vmcase(OP_LE) { Protect( if (luaV_lessequal(L, RKB(i), RKC(i)) != GETARG_A(i)) ci->u.l.savedpc++; else donextjump(ci); ) - ) - vmcase(OP_TEST, + vmbreak; + } + vmcase(OP_TEST) { if (GETARG_C(i) ? l_isfalse(ra) : !l_isfalse(ra)) ci->u.l.savedpc++; else donextjump(ci); - ) - vmcase(OP_TESTSET, + vmbreak; + } + vmcase(OP_TESTSET) { TValue *rb = RB(i); if (GETARG_C(i) ? l_isfalse(rb) : !l_isfalse(rb)) ci->u.l.savedpc++; @@ -947,8 +982,9 @@ void luaV_execute (lua_State *L) { setobjs2s(L, ra, rb); donextjump(ci); } - ) - vmcase(OP_CALL, + vmbreak; + } + vmcase(OP_CALL) { int b = GETARG_B(i); int nresults = GETARG_C(i) - 1; if (b != 0) L->top = ra+b; /* else previous instruction set top */ @@ -961,8 +997,9 @@ void luaV_execute (lua_State *L) { ci->callstatus |= CIST_REENTRY; goto newframe; /* restart luaV_execute over new Lua function */ } - ) - vmcase(OP_TAILCALL, + vmbreak; + } + vmcase(OP_TAILCALL) { int b = GETARG_B(i); if (b != 0) L->top = ra+b; /* else previous instruction set top */ lua_assert(GETARG_C(i) - 1 == LUA_MULTRET); @@ -990,8 +1027,9 @@ void luaV_execute (lua_State *L) { lua_assert(L->top == oci->u.l.base + getproto(ofunc)->maxstacksize); goto newframe; /* restart luaV_execute over new Lua function */ } - ) - vmcasenb(OP_RETURN, + vmbreak; + } + vmcase(OP_RETURN) { int b = GETARG_B(i); if (b != 0) L->top = ra+b-1; if (cl->p->sizep > 0) luaF_close(L, base); @@ -1005,8 +1043,8 @@ void luaV_execute (lua_State *L) { lua_assert(GET_OPCODE(*((ci)->u.l.savedpc - 1)) == OP_CALL); goto newframe; /* restart luaV_execute over new Lua function */ } - ) - vmcase(OP_FORLOOP, + } + vmcase(OP_FORLOOP) { if (ttisinteger(ra)) { /* integer loop? */ lua_Integer step = ivalue(ra + 2); lua_Integer idx = ivalue(ra) + step; /* increment index */ @@ -1028,8 +1066,9 @@ void luaV_execute (lua_State *L) { setfltvalue(ra + 3, idx); /* ...and external index */ } } - ) - vmcase(OP_FORPREP, + vmbreak; + } + vmcase(OP_FORPREP) { TValue *init = ra; TValue *plimit = ra + 1; TValue *pstep = ra + 2; @@ -1055,8 +1094,9 @@ void luaV_execute (lua_State *L) { setfltvalue(init, luai_numsub(L, ninit, nstep)); } ci->u.l.savedpc += GETARG_sBx(i); - ) - vmcasenb(OP_TFORCALL, + vmbreak; + } + vmcase(OP_TFORCALL) { StkId cb = ra + 3; /* call base */ setobjs2s(L, cb+2, ra+2); setobjs2s(L, cb+1, ra+1); @@ -1068,15 +1108,16 @@ void luaV_execute (lua_State *L) { ra = RA(i); lua_assert(GET_OPCODE(i) == OP_TFORLOOP); goto l_tforloop; - ) - vmcase(OP_TFORLOOP, + } + vmcase(OP_TFORLOOP) { l_tforloop: if (!ttisnil(ra + 1)) { /* continue loop? */ setobjs2s(L, ra, ra + 1); /* save control variable */ ci->u.l.savedpc += GETARG_sBx(i); /* jump back */ } - ) - vmcase(OP_SETLIST, + vmbreak; + } + vmcase(OP_SETLIST) { int n = GETARG_B(i); int c = GETARG_C(i); unsigned int last; @@ -1097,8 +1138,9 @@ void luaV_execute (lua_State *L) { luaC_barrierback(L, h, val); } L->top = ci->top; /* correct top (in case of previous open call) */ - ) - vmcase(OP_CLOSURE, + vmbreak; + } + vmcase(OP_CLOSURE) { Proto *p = cl->p->p[GETARG_Bx(i)]; LClosure *ncl = getcached(p, cl->upvals, base); /* cached closure */ if (ncl == NULL) /* no match? */ @@ -1106,8 +1148,9 @@ void luaV_execute (lua_State *L) { else setclLvalue(L, ra, ncl); /* push cashed closure */ checkGC(L, ra + 1); - ) - vmcase(OP_VARARG, + vmbreak; + } + vmcase(OP_VARARG) { int b = GETARG_B(i) - 1; int j; int n = cast_int(base - ci->func) - cl->p->numparams - 1; @@ -1125,10 +1168,12 @@ void luaV_execute (lua_State *L) { setnilvalue(ra + j); } } - ) - vmcase(OP_EXTRAARG, + vmbreak; + } + vmcase(OP_EXTRAARG) { lua_assert(0); - ) + vmbreak; + } } } } |