History

Lua 5.3.0-rc3

Lua Team committed 11 years ago

Commit 48416b81 parent f4a972718 files · +220 −181Browse files

Unified · Split

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