Unified · Split
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | |
| 2 | −This is Lua 5.3.0, released on 22 Dec 2014. | |
| 2 | +This is Lua 5.3.0, released on 02 Jan 2015. | |
| 3 | 3 | |
| 4 | 4 | For installation instructions, license details, and |
| 5 | 5 | further information about Lua, see doc/readme.html. |
| @@ -33,7 +33,7 @@ For a complete introduction to Lua programming, see the book · 32 unmodified lines | ||
| 33 | 33 | <A HREF="#index">index</A> |
| 34 | 34 | <HR> |
| 35 | 35 | <SMALL> |
| 36 | −Copyright © 2014 Lua.org, PUC-Rio. | |
| 36 | +Copyright © 2015 Lua.org, PUC-Rio. | |
| 37 | 37 | Freely available under the terms of the |
| 38 | 38 | <A HREF="http://www.lua.org/license.html">Lua license</A>. |
| 39 | 39 | </SMALL> |
| @@ -19,7 +19,7 @@ Lua 5.3 Reference Manual · 18 unmodified lines | ||
| 19 | 19 | by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes |
| 20 | 20 | <p> |
| 21 | 21 | <small> |
| 22 | −Copyright © 2014 Lua.org, PUC-Rio. | |
| 22 | +Copyright © 2015 Lua.org, PUC-Rio. | |
| 23 | 23 | Freely available under the terms of the |
| 24 | 24 | <a href="http://www.lua.org/license.html">Lua license</a>. |
| 25 | 25 | </small> |
| @@ -33,7 +33,7 @@ Freely available under the terms of the · 7 unmodified lines | ||
| 33 | 33 | <!-- ====================================================================== --> |
| 34 | 34 | <p> |
| 35 | 35 | |
| 36 | −<!-- $Id: manual.of,v 1.142 2014/12/22 13:31:36 roberto Exp $ --> | |
| 36 | +<!-- $Id: manual.of,v 1.143 2015/01/02 13:07:38 roberto Exp $ --> | |
| 37 | 37 | |
| 38 | 38 | |
| 39 | 39 | |
| @@ -1855,7 +1855,7 @@ Lua supports the following arithmetic operators: · 1815 unmodified lines | ||
| 1855 | 1855 | </ul> |
| 1856 | 1856 | |
| 1857 | 1857 | <p> |
| 1858 | −With the exception of float division and exponentiation, | |
| 1858 | +With the exception of exponentiation and float division, | |
| 1859 | 1859 | the arithmetic operators work as follows: |
| 1860 | 1860 | If both operands are integers, |
| 1861 | 1861 | the operation is performed over integers and the result is an integer. |
| @@ -1870,7 +1870,7 @@ and the result is a float. · 8 unmodified lines | ||
| 1870 | 1870 | |
| 1871 | 1871 | |
| 1872 | 1872 | <p> |
| 1873 | −Float division (<code>/</code>) and exponentiation | |
| 1873 | +Exponentiation and float division (<code>/</code>) | |
| 1874 | 1874 | always convert their operands to floats |
| 1875 | 1875 | and the result is always a float. |
| 1876 | 1876 | Exponentiation uses the ISO C function <code>pow</code>, |
| @@ -1932,7 +1932,7 @@ result in zero (as all bits are shifted out). · 55 unmodified lines | ||
| 1932 | 1932 | Lua provides some automatic conversions between some |
| 1933 | 1933 | types and representations at run time. |
| 1934 | 1934 | Bitwise operators always convert float operands to integers. |
| 1935 | −Float division and exponentiation | |
| 1935 | +Exponentiation and float division | |
| 1936 | 1936 | always convert integer operands to floats. |
| 1937 | 1937 | All other arithmetic operations applied to mixed numbers |
| 1938 | 1938 | (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 · 954 unmodified lines | ||
| 2893 | 2893 | </pre><p> |
| 2894 | 2894 | Note the external, explicit call to the continuation: |
| 2895 | 2895 | Lua will call the continuation only if needed, that is, |
| 2896 | −in case of errors or resuming after an yield. | |
| 2896 | +in case of errors or resuming after a yield. | |
| 2897 | 2897 | If the called function returns normally without ever yielding, |
| 2898 | 2898 | <a href="#lua_pcallk"><code>lua_pcallk</code></a> (and <a href="#lua_callk"><code>lua_callk</code></a>) will also return normally. |
| 2899 | 2899 | (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 · 10 unmodified lines | ||
| 2910 | 2910 | continuation function.) |
| 2911 | 2911 | For <a href="#lua_pcallk"><code>lua_pcallk</code></a>, |
| 2912 | 2912 | the status is the same value that would be returned by <a href="#lua_pcallk"><code>lua_pcallk</code></a>, |
| 2913 | −except that it is <a href="#pdf-LUA_YIELD"><code>LUA_YIELD</code></a> when being executed after an yield | |
| 2913 | +except that it is <a href="#pdf-LUA_YIELD"><code>LUA_YIELD</code></a> when being executed after a yield | |
| 2914 | 2914 | (instead of <a href="#pdf-LUA_OK"><code>LUA_OK</code></a>). |
| 2915 | 2915 | For <a href="#lua_yieldk"><code>lua_yieldk</code></a> and <a href="#lua_callk"><code>lua_callk</code></a>, |
| 2916 | 2916 | 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. · 2868 unmodified lines | ||
| 5785 | 5785 | <pre>void *lua_upvalueid (lua_State *L, int funcindex, int n);</pre> |
| 5786 | 5786 | |
| 5787 | 5787 | <p> |
| 5788 | −Returns an unique identifier for the upvalue numbered <code>n</code> | |
| 5788 | +Returns a unique identifier for the upvalue numbered <code>n</code> | |
| 5789 | 5789 | from the closure at index <code>funcindex</code>. |
| 5790 | 5790 | Parameters <code>funcindex</code> and <code>n</code> are as in the <a href="#lua_getupvalue"><code>lua_getupvalue</code></a> |
| 5791 | 5791 | (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, · 784 unmodified lines | ||
| 6576 | 6576 | adds to this new table the pair <code>__name = tname</code>, |
| 6577 | 6577 | adds to the registry the pair <code>[tname] = new table</code>, |
| 6578 | 6578 | and returns 1. |
| 6579 | +(The entry <code>__name</code> is used by some error-reporting functions.) | |
| 6579 | 6580 | |
| 6580 | 6581 | |
| 6581 | 6582 | <p> |
| @@ -6782,7 +6783,7 @@ Type for arrays of functions to be registered by · 200 unmodified lines | ||
| 6782 | 6783 | <a href="#luaL_setfuncs"><code>luaL_setfuncs</code></a>. |
| 6783 | 6784 | <code>name</code> is the function name and <code>func</code> is a pointer to |
| 6784 | 6785 | the function. |
| 6785 | −Any array of <a href="#luaL_Reg"><code>luaL_Reg</code></a> must end with an sentinel entry | |
| 6786 | +Any array of <a href="#luaL_Reg"><code>luaL_Reg</code></a> must end with a sentinel entry | |
| 6786 | 6787 | in which both <code>name</code> and <code>func</code> are <code>NULL</code>. |
| 6787 | 6788 | |
| 6788 | 6789 | |
| @@ -8552,26 +8553,27 @@ which matches any single character in the class; · 1763 unmodified lines | ||
| 8552 | 8553 | |
| 8553 | 8554 | <li> |
| 8554 | 8555 | a single character class followed by '<code>*</code>', |
| 8555 | −which matches 0 or more repetitions of characters in the class. | |
| 8556 | +which matches zero or more repetitions of characters in the class. | |
| 8556 | 8557 | These repetition items will always match the longest possible sequence; |
| 8557 | 8558 | </li> |
| 8558 | 8559 | |
| 8559 | 8560 | <li> |
| 8560 | 8561 | a single character class followed by '<code>+</code>', |
| 8561 | −which matches 1 or more repetitions of characters in the class. | |
| 8562 | +which matches one or more repetitions of characters in the class. | |
| 8562 | 8563 | These repetition items will always match the longest possible sequence; |
| 8563 | 8564 | </li> |
| 8564 | 8565 | |
| 8565 | 8566 | <li> |
| 8566 | 8567 | a single character class followed by '<code>-</code>', |
| 8567 | −which also matches 0 or more repetitions of characters in the class. | |
| 8568 | +which also matches zero or more repetitions of characters in the class. | |
| 8568 | 8569 | Unlike '<code>*</code>', |
| 8569 | 8570 | these repetition items will always match the shortest possible sequence; |
| 8570 | 8571 | </li> |
| 8571 | 8572 | |
| 8572 | 8573 | <li> |
| 8573 | 8574 | a single character class followed by '<code>?</code>', |
| 8574 | −which matches 0 or 1 occurrence of a character in the class; | |
| 8575 | +which matches zero or one occurrence of a character in the class. | |
| 8576 | +It always matches one occurrence if possible; | |
| 8575 | 8577 | </li> |
| 8576 | 8578 | |
| 8577 | 8579 | <li> |
| @@ -10108,7 +10110,9 @@ but also parameters, temporaries, etc. · 1530 unmodified lines | ||
| 10108 | 10110 | |
| 10109 | 10111 | <p> |
| 10110 | 10112 | The first parameter or local variable has index 1, and so on, |
| 10111 | −until the last active variable. | |
| 10113 | +following the order that they are declared in the code, | |
| 10114 | +counting only the variables that are active | |
| 10115 | +in the current scope of the function. | |
| 10112 | 10116 | Negative indices refer to vararg parameters; |
| 10113 | 10117 | -1 is the first vararg parameter. |
| 10114 | 10118 | 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. · 4 unmodified lines | ||
| 10119 | 10123 | <p> |
| 10120 | 10124 | Variable names starting with '<code>(</code>' (open parenthesis) |
| 10121 | 10125 | represent variables with no known names |
| 10122 | −(internal variables like loop control variables, | |
| 10126 | +(internal variables such as loop control variables, | |
| 10123 | 10127 | and variables from chunks saved without debug information). |
| 10124 | 10128 | |
| 10125 | 10129 | |
| @@ -10310,7 +10314,7 @@ to start the traceback · 184 unmodified lines | ||
| 10310 | 10314 | |
| 10311 | 10315 | |
| 10312 | 10316 | <p> |
| 10313 | −Returns an unique identifier (as a light userdata) | |
| 10317 | +Returns a unique identifier (as a light userdata) | |
| 10314 | 10318 | for the upvalue numbered <code>n</code> |
| 10315 | 10319 | from the given function. |
| 10316 | 10320 | |
| @@ -10770,7 +10774,7 @@ and LiteralString, see <a href="#3.1">§3.1</a>.) · 453 unmodified lines | ||
| 10770 | 10774 | <HR> |
| 10771 | 10775 | <SMALL CLASS="footer"> |
| 10772 | 10776 | Last update: |
| 10773 | −Mon Dec 22 12:28:03 BRST 2014 | |
| 10777 | +Fri Jan 2 11:29:40 BRST 2015 | |
| 10774 | 10778 | </SMALL> |
| 10775 | 10779 | <!-- |
| 10776 | 10780 | Last change: revised for Lua 5.3.0 (final) |
| @@ -333,7 +333,7 @@ For details, see · 332 unmodified lines | ||
| 333 | 333 | <A HREF="http://www.lua.org/license.html">this</A>. |
| 334 | 334 | |
| 335 | 335 | <BLOCKQUOTE STYLE="padding-bottom: 0em"> |
| 336 | −Copyright © 1994–2014 Lua.org, PUC-Rio. | |
| 336 | +Copyright © 1994–2015 Lua.org, PUC-Rio. | |
| 337 | 337 | |
| 338 | 338 | <P> |
| 339 | 339 | Permission is hereby granted, free of charge, to any person obtaining a copy |
| @@ -6,7 +6,7 @@ · 5 unmodified lines | ||
| 6 | 6 | # Your platform. See PLATS for possible values. |
| 7 | 7 | PLAT= none |
| 8 | 8 | |
| 9 | −CC= gcc | |
| 9 | +CC= gcc -std=c99 | |
| 10 | 10 | CFLAGS= -O2 -Wall -Wextra -DLUA_COMPAT_5_2 $(SYSCFLAGS) $(MYCFLAGS) |
| 11 | 11 | LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS) |
| 12 | 12 | LIBS= -lm $(SYSLIBS) $(MYLIBS) |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 2 | −** $Id: lapi.c,v 2.243 2014/11/12 13:28:54 roberto Exp $ | |
| 2 | +** $Id: lapi.c,v 2.244 2014/12/26 14:43:45 roberto Exp $ | |
| 3 | 3 | ** Lua API |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -676,7 +676,7 @@ LUA_API void lua_createtable (lua_State *L, int narray, int nrec) { · 670 unmodified lines | ||
| 676 | 676 | |
| 677 | 677 | LUA_API int lua_getmetatable (lua_State *L, int objindex) { |
| 678 | 678 | const TValue *obj; |
| 679 | − Table *mt = NULL; | |
| 679 | + Table *mt; | |
| 680 | 680 | int res = 0; |
| 681 | 681 | lua_lock(L); |
| 682 | 682 | obj = index2addr(L, objindex); |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 2 | −** $Id: lcode.c,v 2.98 2014/12/19 13:36:32 roberto Exp $ | |
| 2 | +** $Id: lcode.c,v 2.99 2014/12/29 16:49:25 roberto Exp $ | |
| 3 | 3 | ** Code generator for Lua |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -33,14 +33,6 @@ · 27 unmodified lines | ||
| 33 | 33 | #define MAXREGS 250 |
| 34 | 34 | |
| 35 | 35 | |
| 36 | −/* test for x == -0 ('signbit' needs 'math.h') */ | |
| 37 | −#if defined(signbit) | |
| 38 | −#define isminuszero(x) ((x) == 0.0 && signbit(x)) | |
| 39 | −#else | |
| 40 | −#define isminuszero(x) ((x) == 0.0 && 1.0/(x) < 0.0) | |
| 41 | −#endif | |
| 42 | − | |
| 43 | − | |
| 44 | 36 | #define hasjumps(e) ((e)->t != (e)->f) |
| 45 | 37 | |
| 46 | 38 | |
| @@ -364,14 +356,8 @@ int luaK_intK (FuncState *fs, lua_Integer n) { · 317 unmodified lines | ||
| 364 | 356 | } |
| 365 | 357 | |
| 366 | 358 | |
| 367 | −/* | |
| 368 | −** Both NaN and -0.0 should not go to the constant table, as they have | |
| 369 | −** problems with the hashing. (NaN is not a valid key, -0.0 collides | |
| 370 | −** with +0.0.) | |
| 371 | −*/ | |
| 372 | 359 | static int luaK_numberK (FuncState *fs, lua_Number r) { |
| 373 | 360 | TValue o; |
| 374 | − lua_assert(!luai_numisnan(r) && !isminuszero(r)); | |
| 375 | 361 | setfltvalue(&o, r); |
| 376 | 362 | return addk(fs, &o, &o); |
| 377 | 363 | } |
| @@ -761,14 +747,14 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { · 383 unmodified lines | ||
| 761 | 747 | ** return false if folding can raise an error |
| 762 | 748 | */ |
| 763 | 749 | static int validop (int op, TValue *v1, TValue *v2) { |
| 764 | − lua_Integer i; | |
| 765 | − if (luai_numinvalidop(op, nvalue(v1), nvalue(v2))) return 0; | |
| 766 | 750 | switch (op) { |
| 767 | 751 | case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR: |
| 768 | − case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: /* conversion errors */ | |
| 752 | + case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: { /* conversion errors */ | |
| 753 | + lua_Integer i; | |
| 769 | 754 | return (tointeger(v1, &i) && tointeger(v2, &i)); |
| 770 | − case LUA_OPIDIV: case LUA_OPMOD: /* integer division by 0 */ | |
| 771 | − return !(ttisinteger(v1) && ttisinteger(v2) && ivalue(v2) == 0); | |
| 755 | + } | |
| 756 | + case LUA_OPDIV: case LUA_OPIDIV: case LUA_OPMOD: /* division by 0 */ | |
| 757 | + return (nvalue(v2) != 0); | |
| 772 | 758 | default: return 1; /* everything else is valid */ |
| 773 | 759 | } |
| 774 | 760 | } |
| @@ -781,15 +767,15 @@ static int constfolding (FuncState *fs, int op, expdesc *e1, expdesc *e2) { · 6 unmodified lines | ||
| 781 | 767 | TValue v1, v2, res; |
| 782 | 768 | if (!tonumeral(e1, &v1) || !tonumeral(e2, &v2) || !validop(op, &v1, &v2)) |
| 783 | 769 | return 0; /* non-numeric operands or not safe to fold */ |
| 784 | − luaO_arith(fs->ls->L, op, &v1, &v2, &res); | |
| 770 | + luaO_arith(fs->ls->L, op, &v1, &v2, &res); /* does operation */ | |
| 785 | 771 | if (ttisinteger(&res)) { |
| 786 | 772 | e1->k = VKINT; |
| 787 | 773 | e1->u.ival = ivalue(&res); |
| 788 | 774 | } |
| 789 | − else { | |
| 775 | + else { /* folds neither NaN nor 0.0 (to avoid collapsing with -0.0) */ | |
| 790 | 776 | lua_Number n = fltvalue(&res); |
| 791 | − if (luai_numisnan(n) || isminuszero(n)) | |
| 792 | − return 0; /* folds neither NaN nor -0 */ | |
| 777 | + if (luai_numisnan(n) || n == 0) | |
| 778 | + return 0; | |
| 793 | 779 | e1->k = VKFLT; |
| 794 | 780 | e1->u.nval = n; |
| 795 | 781 | } |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 2 | −** $Id: ldblib.c,v 1.147 2014/12/08 15:47:25 roberto Exp $ | |
| 2 | +** $Id: ldblib.c,v 1.148 2015/01/02 12:52:22 roberto Exp $ | |
| 3 | 3 | ** Interface from Lua to its debug API |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -207,15 +207,20 @@ static int db_getlocal (lua_State *L) { · 201 unmodified lines | ||
| 207 | 207 | |
| 208 | 208 | static int db_setlocal (lua_State *L) { |
| 209 | 209 | int arg; |
| 210 | + const char *name; | |
| 210 | 211 | lua_State *L1 = getthread(L, &arg); |
| 211 | 212 | lua_Debug ar; |
| 212 | 213 | int level = (int)luaL_checkinteger(L, arg + 1); |
| 214 | + int nvar = (int)luaL_checkinteger(L, arg + 2); | |
| 213 | 215 | if (!lua_getstack(L1, level, &ar)) /* out of range? */ |
| 214 | 216 | return luaL_argerror(L, arg+1, "level out of range"); |
| 215 | 217 | luaL_checkany(L, arg+3); |
| 216 | 218 | lua_settop(L, arg+3); |
| 217 | 219 | lua_xmove(L, L1, 1); |
| 218 | − lua_pushstring(L, lua_setlocal(L1, &ar, (int)luaL_checkinteger(L, arg+2))); | |
| 220 | + name = lua_setlocal(L1, &ar, nvar); | |
| 221 | + if (name == NULL) | |
| 222 | + lua_pop(L1, 1); /* pop value (if not popped by 'lua_setlocal') */ | |
| 223 | + lua_pushstring(L, name); | |
| 219 | 224 | return 1; |
| 220 | 225 | } |
| 221 | 226 | |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 2 | −** $Id: ldebug.c,v 2.109 2014/12/10 11:30:09 roberto Exp $ | |
| 2 | +** $Id: ldebug.c,v 2.110 2015/01/02 12:52:22 roberto Exp $ | |
| 3 | 3 | ** Debug Interface |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -167,9 +167,10 @@ LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { · 161 unmodified lines | ||
| 167 | 167 | StkId pos = 0; /* to avoid warnings */ |
| 168 | 168 | const char *name = findlocal(L, ar->i_ci, n, &pos); |
| 169 | 169 | lua_lock(L); |
| 170 | − if (name) | |
| 170 | + if (name) { | |
| 171 | 171 | setobjs2s(L, pos, L->top - 1); |
| 172 | − L->top--; /* pop value */ | |
| 172 | + L->top--; /* pop value */ | |
| 173 | + } | |
| 173 | 174 | lua_unlock(L); |
| 174 | 175 | return name; |
| 175 | 176 | } |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 2 | −** $Id: liolib.c,v 2.141 2014/11/21 12:17:33 roberto Exp $ | |
| 2 | +** $Id: liolib.c,v 2.142 2015/01/02 12:50:28 roberto Exp $ | |
| 3 | 3 | ** Standard I/O (and system) library |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -464,9 +464,9 @@ static int test_eof (lua_State *L, FILE *f) { · 458 unmodified lines | ||
| 464 | 464 | |
| 465 | 465 | static int read_line (lua_State *L, FILE *f, int chop) { |
| 466 | 466 | luaL_Buffer b; |
| 467 | − int c; | |
| 467 | + int c = '\0'; | |
| 468 | 468 | luaL_buffinit(L, &b); |
| 469 | − for (;;) { | |
| 469 | + while (c != EOF && c != '\n') { /* repeat until end of line */ | |
| 470 | 470 | char *buff = luaL_prepbuffer(&b); /* pre-allocate buffer */ |
| 471 | 471 | int i = 0; |
| 472 | 472 | 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) { · 1 unmodified line | ||
| 474 | 474 | buff[i++] = c; |
| 475 | 475 | l_unlockfile(f); |
| 476 | 476 | luaL_addsize(&b, i); |
| 477 | − if (i < LUAL_BUFFERSIZE) | |
| 478 | − break; | |
| 479 | 477 | } |
| 480 | 478 | if (!chop && c == '\n') /* want a newline and have one? */ |
| 481 | 479 | luaL_addchar(&b, c); /* add ending newline to result */ |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 2 | −** $Id: lmathlib.c,v 1.113 2014/11/07 11:31:58 roberto Exp $ | |
| 2 | +** $Id: lmathlib.c,v 1.114 2014/12/27 20:32:26 roberto Exp $ | |
| 3 | 3 | ** Standard mathematical library |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -27,9 +27,11 @@ · 21 unmodified lines | ||
| 27 | 27 | #if defined(LUA_USE_POSIX) |
| 28 | 28 | #define l_rand() random() |
| 29 | 29 | #define l_srand(x) srandom(x) |
| 30 | +#define L_RANDMAX 2147483647 /* (2^31 - 1), following POSIX */ | |
| 30 | 31 | #else |
| 31 | 32 | #define l_rand() rand() |
| 32 | 33 | #define l_srand(x) srand(x) |
| 34 | +#define L_RANDMAX RAND_MAX | |
| 33 | 35 | #endif |
| 34 | 36 | #endif /* } */ |
| 35 | 37 | |
| @@ -233,12 +235,12 @@ static int math_max (lua_State *L) { · 197 unmodified lines | ||
| 233 | 235 | |
| 234 | 236 | /* |
| 235 | 237 | ** This function uses 'double' (instead of 'lua_Number') to ensure that |
| 236 | −** all bits from 'l_rand' can be represented, and that 'RAND_MAX + 1.0' | |
| 238 | +** all bits from 'l_rand' can be represented, and that 'RANDMAX + 1.0' | |
| 237 | 239 | ** will keep full precision (ensuring that 'r' is always less than 1.0.) |
| 238 | 240 | */ |
| 239 | 241 | static int math_random (lua_State *L) { |
| 240 | 242 | lua_Integer low, up; |
| 241 | − double r = (double)l_rand() * (1.0 / ((double)RAND_MAX + 1.0)); | |
| 243 | + double r = (double)l_rand() * (1.0 / ((double)L_RANDMAX + 1.0)); | |
| 242 | 244 | switch (lua_gettop(L)) { /* check number of arguments */ |
| 243 | 245 | case 0: { /* no arguments */ |
| 244 | 246 | lua_pushnumber(L, (lua_Number)r); /* Number between 0 and 1 */ |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 2 | −** $Id: lobject.c,v 2.100 2014/11/21 12:15:57 roberto Exp $ | |
| 2 | +** $Id: lobject.c,v 2.101 2014/12/26 14:43:45 roberto Exp $ | |
| 3 | 3 | ** Some generic functions over Lua objects |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -189,7 +189,7 @@ static lua_Number lua_strx2number (const char *s, char **endptr) { · 183 unmodified lines | ||
| 189 | 189 | int sigdig = 0; /* number of significant digits */ |
| 190 | 190 | int nosigdig = 0; /* number of non-significant digits */ |
| 191 | 191 | int e = 0; /* exponent correction */ |
| 192 | − int neg = 0; /* 1 if number is negative */ | |
| 192 | + int neg; /* 1 if number is negative */ | |
| 193 | 193 | int dot = 0; /* true after seen a dot */ |
| 194 | 194 | *endptr = cast(char *, s); /* nothing is valid yet */ |
| 195 | 195 | while (lisspace(cast_uchar(*s))) s++; /* skip initial spaces */ |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 2 | −** $Id: loslib.c,v 1.53 2014/12/10 15:42:42 roberto Exp $ | |
| 2 | +** $Id: loslib.c,v 1.54 2014/12/26 14:46:07 roberto Exp $ | |
| 3 | 3 | ** Standard Operating System library |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -100,8 +100,8 @@ · 94 unmodified lines | ||
| 100 | 100 | #else /* }{ */ |
| 101 | 101 | |
| 102 | 102 | /* ISO C definitions */ |
| 103 | −#define l_gmtime(t,r) ((void)r, gmtime(t)) | |
| 104 | −#define l_localtime(t,r) ((void)r, localtime(t)) | |
| 103 | +#define l_gmtime(t,r) ((void)(r)->tm_sec, gmtime(t)) | |
| 104 | +#define l_localtime(t,r) ((void)(r)->tm_sec, localtime(t)) | |
| 105 | 105 | |
| 106 | 106 | #endif /* } */ |
| 107 | 107 | |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 2 | −** $Id: lparser.c,v 2.146 2014/11/27 18:41:43 roberto Exp $ | |
| 2 | +** $Id: lparser.c,v 2.147 2014/12/27 20:31:43 roberto Exp $ | |
| 3 | 3 | ** Lua Parser |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -47,8 +47,8 @@ · 41 unmodified lines | ||
| 47 | 47 | */ |
| 48 | 48 | typedef struct BlockCnt { |
| 49 | 49 | struct BlockCnt *previous; /* chain */ |
| 50 | − short firstlabel; /* index of first label in this block */ | |
| 51 | − short firstgoto; /* index of first pending goto in this block */ | |
| 50 | + int firstlabel; /* index of first label in this block */ | |
| 51 | + int firstgoto; /* index of first pending goto in this block */ | |
| 52 | 52 | lu_byte nactvar; /* # active locals outside the block */ |
| 53 | 53 | lu_byte upval; /* true if some variable in the block is an upvalue */ |
| 54 | 54 | lu_byte isloop; /* true if 'block' is a loop */ |
| @@ -386,7 +386,7 @@ static int newlabelentry (LexState *ls, Labellist *l, TString *name, · 331 unmodified lines | ||
| 386 | 386 | l->arr[n].line = line; |
| 387 | 387 | l->arr[n].nactvar = ls->fs->nactvar; |
| 388 | 388 | l->arr[n].pc = pc; |
| 389 | − l->n++; | |
| 389 | + l->n = n + 1; | |
| 390 | 390 | return n; |
| 391 | 391 | } |
| 392 | 392 | |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 2 | −** $Id: lprefix.h,v 1.1 2014/11/03 15:12:44 roberto Exp $ | |
| 2 | +** $Id: lprefix.h,v 1.2 2014/12/29 16:54:13 roberto Exp $ | |
| 3 | 3 | ** Definitions for Lua code that must come before any other header file |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -11,18 +11,24 @@ · 5 unmodified lines | ||
| 11 | 11 | /* |
| 12 | 12 | ** Allows POSIX/XSI stuff |
| 13 | 13 | */ |
| 14 | +#if !defined(LUA_USE_C89) /* { */ | |
| 15 | + | |
| 14 | 16 | #if !defined(_XOPEN_SOURCE) |
| 15 | 17 | #define _XOPEN_SOURCE 600 |
| 18 | +#elif _XOPEN_SOURCE == 0 | |
| 19 | +#undef _XOPEN_SOURCE /* use -D_XOPEN_SOURCE=0 to undefine it */ | |
| 16 | 20 | #endif |
| 17 | 21 | |
| 18 | 22 | /* |
| 19 | 23 | ** Allows manipulation of large files in gcc and some other compilers |
| 20 | 24 | */ |
| 21 | −#if !defined(_FILE_OFFSET_BITS) | |
| 25 | +#if !defined(LUA_32BITS) && !defined(_FILE_OFFSET_BITS) | |
| 22 | 26 | #define _LARGEFILE_SOURCE 1 |
| 23 | 27 | #define _FILE_OFFSET_BITS 64 |
| 24 | 28 | #endif |
| 25 | 29 | |
| 30 | +#endif /* } */ | |
| 31 | + | |
| 26 | 32 | |
| 27 | 33 | /* |
| 28 | 34 | ** Windows stuff |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 2 | −** $Id: lua.h,v 1.324 2014/12/08 15:12:07 roberto Exp $ | |
| 2 | +** $Id: lua.h,v 1.325 2014/12/26 17:24:27 roberto Exp $ | |
| 3 | 3 | ** Lua - A Scripting Language |
| 4 | 4 | ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) |
| 5 | 5 | ** See Copyright Notice at the end of this file |
| @@ -23,7 +23,7 @@ · 17 unmodified lines | ||
| 23 | 23 | |
| 24 | 24 | #define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR |
| 25 | 25 | #define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE |
| 26 | −#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2014 Lua.org, PUC-Rio" | |
| 26 | +#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2015 Lua.org, PUC-Rio" | |
| 27 | 27 | #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes" |
| 28 | 28 | |
| 29 | 29 | |
| @@ -459,7 +459,7 @@ struct lua_Debug { · 429 unmodified lines | ||
| 459 | 459 | |
| 460 | 460 | |
| 461 | 461 | /****************************************************************************** |
| 462 | −* Copyright (C) 1994-2014 Lua.org, PUC-Rio. | |
| 462 | +* Copyright (C) 1994-2015 Lua.org, PUC-Rio. | |
| 463 | 463 | * |
| 464 | 464 | * Permission is hereby granted, free of charge, to any person obtaining |
| 465 | 465 | * a copy of this software and associated documentation files (the |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 2 | −** $Id: luaconf.h,v 1.236 2014/12/19 13:31:12 roberto Exp $ | |
| 2 | +** $Id: luaconf.h,v 1.238 2014/12/29 13:27:55 roberto Exp $ | |
| 3 | 3 | ** Configuration file for Lua |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -476,7 +476,7 @@ · 470 unmodified lines | ||
| 476 | 476 | #include <math.h> |
| 477 | 477 | |
| 478 | 478 | /* floor division (defined as 'floor(a/b)') */ |
| 479 | −#define luai_numidiv(L,a,b) ((void)L, l_mathop(floor)((a)/(b))) | |
| 479 | +#define luai_numidiv(L,a,b) ((void)L, l_mathop(floor)(luai_numdiv(L,a,b))) | |
| 480 | 480 | |
| 481 | 481 | /* |
| 482 | 482 | ** module: defined as 'a - floor(a/b)*b'; the previous definition gives |
| @@ -507,14 +507,6 @@ · 24 unmodified lines | ||
| 507 | 507 | #endif |
| 508 | 508 | |
| 509 | 509 | |
| 510 | −/* | |
| 511 | −** The following macro checks whether an operation is not safe to be | |
| 512 | −** performed by the constant folder. It should result in zero only if | |
| 513 | −** the operation is safe. | |
| 514 | −*/ | |
| 515 | −#define luai_numinvalidop(op,a,b) 0 | |
| 516 | − | |
| 517 | − | |
| 518 | 510 | /* |
| 519 | 511 | @@ LUA_INTEGER is the integer type used by Lua. |
| 520 | 512 | ** |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 2 | −** $Id: lvm.c,v 2.231 2014/12/19 13:36:32 roberto Exp $ | |
| 2 | +** $Id: lvm.c,v 2.232 2014/12/27 20:30:38 roberto Exp $ | |
| 3 | 3 | ** Lua virtual machine |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -644,8 +644,8 @@ void luaV_finishOp (lua_State *L) { · 638 unmodified lines | ||
| 644 | 644 | |
| 645 | 645 | |
| 646 | 646 | #define vmdispatch(o) switch(o) |
| 647 | −#define vmcase(l,b) case l: {b} break; | |
| 648 | −#define vmcasenb(l,b) case l: {b} /* nb = no break */ | |
| 647 | +#define vmcase(l) case l: | |
| 648 | +#define vmbreak break | |
| 649 | 649 | |
| 650 | 650 | void luaV_execute (lua_State *L) { |
| 651 | 651 | CallInfo *ci = L->ci; |
| @@ -670,53 +670,64 @@ void luaV_execute (lua_State *L) { · 18 unmodified lines | ||
| 670 | 670 | lua_assert(base == ci->u.l.base); |
| 671 | 671 | lua_assert(base <= L->top && L->top < L->stack + L->stacksize); |
| 672 | 672 | vmdispatch (GET_OPCODE(i)) { |
| 673 | − vmcase(OP_MOVE, | |
| 673 | + vmcase(OP_MOVE) { | |
| 674 | 674 | setobjs2s(L, ra, RB(i)); |
| 675 | − ) | |
| 676 | − vmcase(OP_LOADK, | |
| 675 | + vmbreak; | |
| 676 | + } | |
| 677 | + vmcase(OP_LOADK) { | |
| 677 | 678 | TValue *rb = k + GETARG_Bx(i); |
| 678 | 679 | setobj2s(L, ra, rb); |
| 679 | − ) | |
| 680 | − vmcase(OP_LOADKX, | |
| 680 | + vmbreak; | |
| 681 | + } | |
| 682 | + vmcase(OP_LOADKX) { | |
| 681 | 683 | TValue *rb; |
| 682 | 684 | lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_EXTRAARG); |
| 683 | 685 | rb = k + GETARG_Ax(*ci->u.l.savedpc++); |
| 684 | 686 | setobj2s(L, ra, rb); |
| 685 | − ) | |
| 686 | − vmcase(OP_LOADBOOL, | |
| 687 | + vmbreak; | |
| 688 | + } | |
| 689 | + vmcase(OP_LOADBOOL) { | |
| 687 | 690 | setbvalue(ra, GETARG_B(i)); |
| 688 | 691 | if (GETARG_C(i)) ci->u.l.savedpc++; /* skip next instruction (if C) */ |
| 689 | − ) | |
| 690 | − vmcase(OP_LOADNIL, | |
| 692 | + vmbreak; | |
| 693 | + } | |
| 694 | + vmcase(OP_LOADNIL) { | |
| 691 | 695 | int b = GETARG_B(i); |
| 692 | 696 | do { |
| 693 | 697 | setnilvalue(ra++); |
| 694 | 698 | } while (b--); |
| 695 | − ) | |
| 696 | − vmcase(OP_GETUPVAL, | |
| 699 | + vmbreak; | |
| 700 | + } | |
| 701 | + vmcase(OP_GETUPVAL) { | |
| 697 | 702 | int b = GETARG_B(i); |
| 698 | 703 | setobj2s(L, ra, cl->upvals[b]->v); |
| 699 | − ) | |
| 700 | − vmcase(OP_GETTABUP, | |
| 704 | + vmbreak; | |
| 705 | + } | |
| 706 | + vmcase(OP_GETTABUP) { | |
| 701 | 707 | int b = GETARG_B(i); |
| 702 | 708 | Protect(luaV_gettable(L, cl->upvals[b]->v, RKC(i), ra)); |
| 703 | − ) | |
| 704 | − vmcase(OP_GETTABLE, | |
| 709 | + vmbreak; | |
| 710 | + } | |
| 711 | + vmcase(OP_GETTABLE) { | |
| 705 | 712 | Protect(luaV_gettable(L, RB(i), RKC(i), ra)); |
| 706 | − ) | |
| 707 | − vmcase(OP_SETTABUP, | |
| 713 | + vmbreak; | |
| 714 | + } | |
| 715 | + vmcase(OP_SETTABUP) { | |
| 708 | 716 | int a = GETARG_A(i); |
| 709 | 717 | Protect(luaV_settable(L, cl->upvals[a]->v, RKB(i), RKC(i))); |
| 710 | − ) | |
| 711 | − vmcase(OP_SETUPVAL, | |
| 718 | + vmbreak; | |
| 719 | + } | |
| 720 | + vmcase(OP_SETUPVAL) { | |
| 712 | 721 | UpVal *uv = cl->upvals[GETARG_B(i)]; |
| 713 | 722 | setobj(L, uv->v, ra); |
| 714 | 723 | luaC_upvalbarrier(L, uv); |
| 715 | − ) | |
| 716 | − vmcase(OP_SETTABLE, | |
| 724 | + vmbreak; | |
| 725 | + } | |
| 726 | + vmcase(OP_SETTABLE) { | |
| 717 | 727 | Protect(luaV_settable(L, ra, RKB(i), RKC(i))); |
| 718 | − ) | |
| 719 | − vmcase(OP_NEWTABLE, | |
| 728 | + vmbreak; | |
| 729 | + } | |
| 730 | + vmcase(OP_NEWTABLE) { | |
| 720 | 731 | int b = GETARG_B(i); |
| 721 | 732 | int c = GETARG_C(i); |
| 722 | 733 | Table *t = luaH_new(L); |
| @@ -724,13 +735,15 @@ void luaV_execute (lua_State *L) { · 1 unmodified line | ||
| 724 | 735 | if (b != 0 || c != 0) |
| 725 | 736 | luaH_resize(L, t, luaO_fb2int(b), luaO_fb2int(c)); |
| 726 | 737 | checkGC(L, ra + 1); |
| 727 | − ) | |
| 728 | − vmcase(OP_SELF, | |
| 738 | + vmbreak; | |
| 739 | + } | |
| 740 | + vmcase(OP_SELF) { | |
| 729 | 741 | StkId rb = RB(i); |
| 730 | 742 | setobjs2s(L, ra+1, rb); |
| 731 | 743 | Protect(luaV_gettable(L, rb, RKC(i), ra)); |
| 732 | − ) | |
| 733 | − vmcase(OP_ADD, | |
| 744 | + vmbreak; | |
| 745 | + } | |
| 746 | + vmcase(OP_ADD) { | |
| 734 | 747 | TValue *rb = RKB(i); |
| 735 | 748 | TValue *rc = RKC(i); |
| 736 | 749 | lua_Number nb; lua_Number nc; |
| @@ -742,8 +755,9 @@ void luaV_execute (lua_State *L) { · 5 unmodified lines | ||
| 742 | 755 | setfltvalue(ra, luai_numadd(L, nb, nc)); |
| 743 | 756 | } |
| 744 | 757 | else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_ADD)); } |
| 745 | − ) | |
| 746 | − vmcase(OP_SUB, | |
| 758 | + vmbreak; | |
| 759 | + } | |
| 760 | + vmcase(OP_SUB) { | |
| 747 | 761 | TValue *rb = RKB(i); |
| 748 | 762 | TValue *rc = RKC(i); |
| 749 | 763 | lua_Number nb; lua_Number nc; |
| @@ -755,8 +769,9 @@ void luaV_execute (lua_State *L) { · 5 unmodified lines | ||
| 755 | 769 | setfltvalue(ra, luai_numsub(L, nb, nc)); |
| 756 | 770 | } |
| 757 | 771 | else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_SUB)); } |
| 758 | − ) | |
| 759 | − vmcase(OP_MUL, | |
| 772 | + vmbreak; | |
| 773 | + } | |
| 774 | + vmcase(OP_MUL) { | |
| 760 | 775 | TValue *rb = RKB(i); |
| 761 | 776 | TValue *rc = RKC(i); |
| 762 | 777 | lua_Number nb; lua_Number nc; |
| @@ -768,8 +783,9 @@ void luaV_execute (lua_State *L) { · 5 unmodified lines | ||
| 768 | 783 | setfltvalue(ra, luai_nummul(L, nb, nc)); |
| 769 | 784 | } |
| 770 | 785 | else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_MUL)); } |
| 771 | − ) | |
| 772 | − vmcase(OP_DIV, /* float division (always with floats) */ | |
| 786 | + vmbreak; | |
| 787 | + } | |
| 788 | + vmcase(OP_DIV) { /* float division (always with floats) */ | |
| 773 | 789 | TValue *rb = RKB(i); |
| 774 | 790 | TValue *rc = RKC(i); |
| 775 | 791 | lua_Number nb; lua_Number nc; |
| @@ -777,8 +793,9 @@ void luaV_execute (lua_State *L) { · 1 unmodified line | ||
| 777 | 793 | setfltvalue(ra, luai_numdiv(L, nb, nc)); |
| 778 | 794 | } |
| 779 | 795 | else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_DIV)); } |
| 780 | − ) | |
| 781 | − vmcase(OP_BAND, | |
| 796 | + vmbreak; | |
| 797 | + } | |
| 798 | + vmcase(OP_BAND) { | |
| 782 | 799 | TValue *rb = RKB(i); |
| 783 | 800 | TValue *rc = RKC(i); |
| 784 | 801 | lua_Integer ib; lua_Integer ic; |
| @@ -786,8 +803,9 @@ void luaV_execute (lua_State *L) { · 1 unmodified line | ||
| 786 | 803 | setivalue(ra, intop(&, ib, ic)); |
| 787 | 804 | } |
| 788 | 805 | else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_BAND)); } |
| 789 | − ) | |
| 790 | − vmcase(OP_BOR, | |
| 806 | + vmbreak; | |
| 807 | + } | |
| 808 | + vmcase(OP_BOR) { | |
| 791 | 809 | TValue *rb = RKB(i); |
| 792 | 810 | TValue *rc = RKC(i); |
| 793 | 811 | lua_Integer ib; lua_Integer ic; |
| @@ -795,8 +813,9 @@ void luaV_execute (lua_State *L) { · 1 unmodified line | ||
| 795 | 813 | setivalue(ra, intop(|, ib, ic)); |
| 796 | 814 | } |
| 797 | 815 | else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_BOR)); } |
| 798 | − ) | |
| 799 | − vmcase(OP_BXOR, | |
| 816 | + vmbreak; | |
| 817 | + } | |
| 818 | + vmcase(OP_BXOR) { | |
| 800 | 819 | TValue *rb = RKB(i); |
| 801 | 820 | TValue *rc = RKC(i); |
| 802 | 821 | lua_Integer ib; lua_Integer ic; |
| @@ -804,8 +823,9 @@ void luaV_execute (lua_State *L) { · 1 unmodified line | ||
| 804 | 823 | setivalue(ra, intop(^, ib, ic)); |
| 805 | 824 | } |
| 806 | 825 | else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_BXOR)); } |
| 807 | − ) | |
| 808 | − vmcase(OP_SHL, | |
| 826 | + vmbreak; | |
| 827 | + } | |
| 828 | + vmcase(OP_SHL) { | |
| 809 | 829 | TValue *rb = RKB(i); |
| 810 | 830 | TValue *rc = RKC(i); |
| 811 | 831 | lua_Integer ib; lua_Integer ic; |
| @@ -813,8 +833,9 @@ void luaV_execute (lua_State *L) { · 1 unmodified line | ||
| 813 | 833 | setivalue(ra, luaV_shiftl(ib, ic)); |
| 814 | 834 | } |
| 815 | 835 | else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_SHL)); } |
| 816 | − ) | |
| 817 | − vmcase(OP_SHR, | |
| 836 | + vmbreak; | |
| 837 | + } | |
| 838 | + vmcase(OP_SHR) { | |
| 818 | 839 | TValue *rb = RKB(i); |
| 819 | 840 | TValue *rc = RKC(i); |
| 820 | 841 | lua_Integer ib; lua_Integer ic; |
| @@ -822,8 +843,9 @@ void luaV_execute (lua_State *L) { · 1 unmodified line | ||
| 822 | 843 | setivalue(ra, luaV_shiftl(ib, -ic)); |
| 823 | 844 | } |
| 824 | 845 | else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_SHR)); } |
| 825 | − ) | |
| 826 | − vmcase(OP_MOD, | |
| 846 | + vmbreak; | |
| 847 | + } | |
| 848 | + vmcase(OP_MOD) { | |
| 827 | 849 | TValue *rb = RKB(i); |
| 828 | 850 | TValue *rc = RKC(i); |
| 829 | 851 | lua_Number nb; lua_Number nc; |
| @@ -837,8 +859,9 @@ void luaV_execute (lua_State *L) { · 7 unmodified lines | ||
| 837 | 859 | setfltvalue(ra, m); |
| 838 | 860 | } |
| 839 | 861 | else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_MOD)); } |
| 840 | − ) | |
| 841 | − vmcase(OP_IDIV, /* floor division */ | |
| 862 | + vmbreak; | |
| 863 | + } | |
| 864 | + vmcase(OP_IDIV) { /* floor division */ | |
| 842 | 865 | TValue *rb = RKB(i); |
| 843 | 866 | TValue *rc = RKC(i); |
| 844 | 867 | lua_Number nb; lua_Number nc; |
| @@ -850,8 +873,9 @@ void luaV_execute (lua_State *L) { · 5 unmodified lines | ||
| 850 | 873 | setfltvalue(ra, luai_numidiv(L, nb, nc)); |
| 851 | 874 | } |
| 852 | 875 | else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_IDIV)); } |
| 853 | − ) | |
| 854 | − vmcase(OP_POW, | |
| 876 | + vmbreak; | |
| 877 | + } | |
| 878 | + vmcase(OP_POW) { | |
| 855 | 879 | TValue *rb = RKB(i); |
| 856 | 880 | TValue *rc = RKC(i); |
| 857 | 881 | lua_Number nb; lua_Number nc; |
| @@ -859,8 +883,9 @@ void luaV_execute (lua_State *L) { · 1 unmodified line | ||
| 859 | 883 | setfltvalue(ra, luai_numpow(L, nb, nc)); |
| 860 | 884 | } |
| 861 | 885 | else { Protect(luaT_trybinTM(L, rb, rc, ra, TM_POW)); } |
| 862 | − ) | |
| 863 | − vmcase(OP_UNM, | |
| 886 | + vmbreak; | |
| 887 | + } | |
| 888 | + vmcase(OP_UNM) { | |
| 864 | 889 | TValue *rb = RB(i); |
| 865 | 890 | lua_Number nb; |
| 866 | 891 | if (ttisinteger(rb)) { |
| @@ -873,8 +898,9 @@ void luaV_execute (lua_State *L) { · 6 unmodified lines | ||
| 873 | 898 | else { |
| 874 | 899 | Protect(luaT_trybinTM(L, rb, rb, ra, TM_UNM)); |
| 875 | 900 | } |
| 876 | − ) | |
| 877 | − vmcase(OP_BNOT, | |
| 901 | + vmbreak; | |
| 902 | + } | |
| 903 | + vmcase(OP_BNOT) { | |
| 878 | 904 | TValue *rb = RB(i); |
| 879 | 905 | lua_Integer ib; |
| 880 | 906 | if (tointeger(rb, &ib)) { |
| @@ -883,16 +909,19 @@ void luaV_execute (lua_State *L) { · 2 unmodified lines | ||
| 883 | 909 | else { |
| 884 | 910 | Protect(luaT_trybinTM(L, rb, rb, ra, TM_BNOT)); |
| 885 | 911 | } |
| 886 | − ) | |
| 887 | − vmcase(OP_NOT, | |
| 912 | + vmbreak; | |
| 913 | + } | |
| 914 | + vmcase(OP_NOT) { | |
| 888 | 915 | TValue *rb = RB(i); |
| 889 | 916 | int res = l_isfalse(rb); /* next assignment may change this value */ |
| 890 | 917 | setbvalue(ra, res); |
| 891 | − ) | |
| 892 | − vmcase(OP_LEN, | |
| 918 | + vmbreak; | |
| 919 | + } | |
| 920 | + vmcase(OP_LEN) { | |
| 893 | 921 | Protect(luaV_objlen(L, ra, RB(i))); |
| 894 | − ) | |
| 895 | − vmcase(OP_CONCAT, | |
| 922 | + vmbreak; | |
| 923 | + } | |
| 924 | + vmcase(OP_CONCAT) { | |
| 896 | 925 | int b = GETARG_B(i); |
| 897 | 926 | int c = GETARG_C(i); |
| 898 | 927 | StkId rb; |
| @@ -903,11 +932,13 @@ void luaV_execute (lua_State *L) { · 4 unmodified lines | ||
| 903 | 932 | setobjs2s(L, ra, rb); |
| 904 | 933 | checkGC(L, (ra >= rb ? ra + 1 : rb)); |
| 905 | 934 | L->top = ci->top; /* restore top */ |
| 906 | − ) | |
| 907 | − vmcase(OP_JMP, | |
| 935 | + vmbreak; | |
| 936 | + } | |
| 937 | + vmcase(OP_JMP) { | |
| 908 | 938 | dojump(ci, i, 0); |
| 909 | − ) | |
| 910 | − vmcase(OP_EQ, | |
| 939 | + vmbreak; | |
| 940 | + } | |
| 941 | + vmcase(OP_EQ) { | |
| 911 | 942 | TValue *rb = RKB(i); |
| 912 | 943 | TValue *rc = RKC(i); |
| 913 | 944 | Protect( |
| @@ -916,30 +947,34 @@ void luaV_execute (lua_State *L) { · 2 unmodified lines | ||
| 916 | 947 | else |
| 917 | 948 | donextjump(ci); |
| 918 | 949 | ) |
| 919 | − ) | |
| 920 | − vmcase(OP_LT, | |
| 950 | + vmbreak; | |
| 951 | + } | |
| 952 | + vmcase(OP_LT) { | |
| 921 | 953 | Protect( |
| 922 | 954 | if (luaV_lessthan(L, RKB(i), RKC(i)) != GETARG_A(i)) |
| 923 | 955 | ci->u.l.savedpc++; |
| 924 | 956 | else |
| 925 | 957 | donextjump(ci); |
| 926 | 958 | ) |
| 927 | − ) | |
| 928 | − vmcase(OP_LE, | |
| 959 | + vmbreak; | |
| 960 | + } | |
| 961 | + vmcase(OP_LE) { | |
| 929 | 962 | Protect( |
| 930 | 963 | if (luaV_lessequal(L, RKB(i), RKC(i)) != GETARG_A(i)) |
| 931 | 964 | ci->u.l.savedpc++; |
| 932 | 965 | else |
| 933 | 966 | donextjump(ci); |
| 934 | 967 | ) |
| 935 | − ) | |
| 936 | − vmcase(OP_TEST, | |
| 968 | + vmbreak; | |
| 969 | + } | |
| 970 | + vmcase(OP_TEST) { | |
| 937 | 971 | if (GETARG_C(i) ? l_isfalse(ra) : !l_isfalse(ra)) |
| 938 | 972 | ci->u.l.savedpc++; |
| 939 | 973 | else |
| 940 | 974 | donextjump(ci); |
| 941 | − ) | |
| 942 | − vmcase(OP_TESTSET, | |
| 975 | + vmbreak; | |
| 976 | + } | |
| 977 | + vmcase(OP_TESTSET) { | |
| 943 | 978 | TValue *rb = RB(i); |
| 944 | 979 | if (GETARG_C(i) ? l_isfalse(rb) : !l_isfalse(rb)) |
| 945 | 980 | ci->u.l.savedpc++; |
| @@ -947,8 +982,9 @@ void luaV_execute (lua_State *L) { · 1 unmodified line | ||
| 947 | 982 | setobjs2s(L, ra, rb); |
| 948 | 983 | donextjump(ci); |
| 949 | 984 | } |
| 950 | − ) | |
| 951 | − vmcase(OP_CALL, | |
| 985 | + vmbreak; | |
| 986 | + } | |
| 987 | + vmcase(OP_CALL) { | |
| 952 | 988 | int b = GETARG_B(i); |
| 953 | 989 | int nresults = GETARG_C(i) - 1; |
| 954 | 990 | if (b != 0) L->top = ra+b; /* else previous instruction set top */ |
| @@ -961,8 +997,9 @@ void luaV_execute (lua_State *L) { · 6 unmodified lines | ||
| 961 | 997 | ci->callstatus |= CIST_REENTRY; |
| 962 | 998 | goto newframe; /* restart luaV_execute over new Lua function */ |
| 963 | 999 | } |
| 964 | − ) | |
| 965 | − vmcase(OP_TAILCALL, | |
| 1000 | + vmbreak; | |
| 1001 | + } | |
| 1002 | + vmcase(OP_TAILCALL) { | |
| 966 | 1003 | int b = GETARG_B(i); |
| 967 | 1004 | if (b != 0) L->top = ra+b; /* else previous instruction set top */ |
| 968 | 1005 | lua_assert(GETARG_C(i) - 1 == LUA_MULTRET); |
| @@ -990,8 +1027,9 @@ void luaV_execute (lua_State *L) { · 21 unmodified lines | ||
| 990 | 1027 | lua_assert(L->top == oci->u.l.base + getproto(ofunc)->maxstacksize); |
| 991 | 1028 | goto newframe; /* restart luaV_execute over new Lua function */ |
| 992 | 1029 | } |
| 993 | − ) | |
| 994 | − vmcasenb(OP_RETURN, | |
| 1030 | + vmbreak; | |
| 1031 | + } | |
| 1032 | + vmcase(OP_RETURN) { | |
| 995 | 1033 | int b = GETARG_B(i); |
| 996 | 1034 | if (b != 0) L->top = ra+b-1; |
| 997 | 1035 | if (cl->p->sizep > 0) luaF_close(L, base); |
| @@ -1005,8 +1043,8 @@ void luaV_execute (lua_State *L) { · 7 unmodified lines | ||
| 1005 | 1043 | lua_assert(GET_OPCODE(*((ci)->u.l.savedpc - 1)) == OP_CALL); |
| 1006 | 1044 | goto newframe; /* restart luaV_execute over new Lua function */ |
| 1007 | 1045 | } |
| 1008 | − ) | |
| 1009 | − vmcase(OP_FORLOOP, | |
| 1046 | + } | |
| 1047 | + vmcase(OP_FORLOOP) { | |
| 1010 | 1048 | if (ttisinteger(ra)) { /* integer loop? */ |
| 1011 | 1049 | lua_Integer step = ivalue(ra + 2); |
| 1012 | 1050 | lua_Integer idx = ivalue(ra) + step; /* increment index */ |
| @@ -1028,8 +1066,9 @@ void luaV_execute (lua_State *L) { · 15 unmodified lines | ||
| 1028 | 1066 | setfltvalue(ra + 3, idx); /* ...and external index */ |
| 1029 | 1067 | } |
| 1030 | 1068 | } |
| 1031 | − ) | |
| 1032 | − vmcase(OP_FORPREP, | |
| 1069 | + vmbreak; | |
| 1070 | + } | |
| 1071 | + vmcase(OP_FORPREP) { | |
| 1033 | 1072 | TValue *init = ra; |
| 1034 | 1073 | TValue *plimit = ra + 1; |
| 1035 | 1074 | TValue *pstep = ra + 2; |
| @@ -1055,8 +1094,9 @@ void luaV_execute (lua_State *L) { · 19 unmodified lines | ||
| 1055 | 1094 | setfltvalue(init, luai_numsub(L, ninit, nstep)); |
| 1056 | 1095 | } |
| 1057 | 1096 | ci->u.l.savedpc += GETARG_sBx(i); |
| 1058 | − ) | |
| 1059 | − vmcasenb(OP_TFORCALL, | |
| 1097 | + vmbreak; | |
| 1098 | + } | |
| 1099 | + vmcase(OP_TFORCALL) { | |
| 1060 | 1100 | StkId cb = ra + 3; /* call base */ |
| 1061 | 1101 | setobjs2s(L, cb+2, ra+2); |
| 1062 | 1102 | setobjs2s(L, cb+1, ra+1); |
| @@ -1068,15 +1108,16 @@ void luaV_execute (lua_State *L) { · 5 unmodified lines | ||
| 1068 | 1108 | ra = RA(i); |
| 1069 | 1109 | lua_assert(GET_OPCODE(i) == OP_TFORLOOP); |
| 1070 | 1110 | goto l_tforloop; |
| 1071 | − ) | |
| 1072 | − vmcase(OP_TFORLOOP, | |
| 1111 | + } | |
| 1112 | + vmcase(OP_TFORLOOP) { | |
| 1073 | 1113 | l_tforloop: |
| 1074 | 1114 | if (!ttisnil(ra + 1)) { /* continue loop? */ |
| 1075 | 1115 | setobjs2s(L, ra, ra + 1); /* save control variable */ |
| 1076 | 1116 | ci->u.l.savedpc += GETARG_sBx(i); /* jump back */ |
| 1077 | 1117 | } |
| 1078 | − ) | |
| 1079 | − vmcase(OP_SETLIST, | |
| 1118 | + vmbreak; | |
| 1119 | + } | |
| 1120 | + vmcase(OP_SETLIST) { | |
| 1080 | 1121 | int n = GETARG_B(i); |
| 1081 | 1122 | int c = GETARG_C(i); |
| 1082 | 1123 | unsigned int last; |
| @@ -1097,8 +1138,9 @@ void luaV_execute (lua_State *L) { · 14 unmodified lines | ||
| 1097 | 1138 | luaC_barrierback(L, h, val); |
| 1098 | 1139 | } |
| 1099 | 1140 | L->top = ci->top; /* correct top (in case of previous open call) */ |
| 1100 | − ) | |
| 1101 | − vmcase(OP_CLOSURE, | |
| 1141 | + vmbreak; | |
| 1142 | + } | |
| 1143 | + vmcase(OP_CLOSURE) { | |
| 1102 | 1144 | Proto *p = cl->p->p[GETARG_Bx(i)]; |
| 1103 | 1145 | LClosure *ncl = getcached(p, cl->upvals, base); /* cached closure */ |
| 1104 | 1146 | if (ncl == NULL) /* no match? */ |
| @@ -1106,8 +1148,9 @@ void luaV_execute (lua_State *L) { · 1 unmodified line | ||
| 1106 | 1148 | else |
| 1107 | 1149 | setclLvalue(L, ra, ncl); /* push cashed closure */ |
| 1108 | 1150 | checkGC(L, ra + 1); |
| 1109 | − ) | |
| 1110 | − vmcase(OP_VARARG, | |
| 1151 | + vmbreak; | |
| 1152 | + } | |
| 1153 | + vmcase(OP_VARARG) { | |
| 1111 | 1154 | int b = GETARG_B(i) - 1; |
| 1112 | 1155 | int j; |
| 1113 | 1156 | int n = cast_int(base - ci->func) - cl->p->numparams - 1; |
| @@ -1125,10 +1168,12 @@ void luaV_execute (lua_State *L) { · 11 unmodified lines | ||
| 1125 | 1168 | setnilvalue(ra + j); |
| 1126 | 1169 | } |
| 1127 | 1170 | } |
| 1128 | − ) | |
| 1129 | − vmcase(OP_EXTRAARG, | |
| 1171 | + vmbreak; | |
| 1172 | + } | |
| 1173 | + vmcase(OP_EXTRAARG) { | |
| 1130 | 1174 | lua_assert(0); |
| 1131 | − ) | |
| 1175 | + vmbreak; | |
| 1176 | + } | |
| 1132 | 1177 | } |
| 1133 | 1178 | } |
| 1134 | 1179 | } |