summaryrefslogtreecommitdiff
path: root/plugins/MirLua/src/lua/lcode.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/MirLua/src/lua/lcode.c')
-rw-r--r--plugins/MirLua/src/lua/lcode.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/plugins/MirLua/src/lua/lcode.c b/plugins/MirLua/src/lua/lcode.c
index 5e34624bf4..d6f0fcd847 100644
--- a/plugins/MirLua/src/lua/lcode.c
+++ b/plugins/MirLua/src/lua/lcode.c
@@ -1,5 +1,5 @@
/*
-** $Id: lcode.c,v 2.99 2014/12/29 16:49:25 roberto Exp $
+** $Id: lcode.c,v 2.101 2015/04/29 18:24:11 roberto Exp $
** Code generator for Lua
** See Copyright Notice in lua.h
*/
@@ -29,8 +29,8 @@
#include "lvm.h"
-/* Maximum number of registers in a Lua function */
-#define MAXREGS 250
+/* Maximum number of registers in a Lua function (must fit in 8 bits) */
+#define MAXREGS 255
#define hasjumps(e) ((e)->t != (e)->f)
@@ -279,7 +279,8 @@ void luaK_checkstack (FuncState *fs, int n) {
int newstack = fs->freereg + n;
if (newstack > fs->f->maxstacksize) {
if (newstack >= MAXREGS)
- luaX_syntaxerror(fs->ls, "function or expression too complex");
+ luaX_syntaxerror(fs->ls,
+ "function or expression needs too many registers");
fs->f->maxstacksize = cast_byte(newstack);
}
}
@@ -573,8 +574,8 @@ int luaK_exp2RK (FuncState *fs, expdesc *e) {
case VKFLT: {
e->u.info = luaK_numberK(fs, e->u.nval);
e->k = VK;
- /* go through */
}
+ /* FALLTHROUGH */
case VK: {
vk:
if (e->u.info <= MAXINDEXRK) /* constant fits in 'argC'? */
@@ -793,7 +794,7 @@ static int constfolding (FuncState *fs, int op, expdesc *e1, expdesc *e2) {
static void codeexpval (FuncState *fs, OpCode op,
expdesc *e1, expdesc *e2, int line) {
lua_assert(op >= OP_ADD);
- if (op <= OP_BNOT && constfolding(fs, op - OP_ADD + LUA_OPADD, e1, e2))
+ if (op <= OP_BNOT && constfolding(fs, (op - OP_ADD) + LUA_OPADD, e1, e2))
return; /* result has been folded */
else {
int o1, o2;
@@ -920,11 +921,11 @@ void luaK_posfix (FuncState *fs, BinOpr op,
break;
}
case OPR_EQ: case OPR_LT: case OPR_LE: {
- codecomp(fs, cast(OpCode, op - OPR_EQ + OP_EQ), 1, e1, e2);
+ codecomp(fs, cast(OpCode, (op - OPR_EQ) + OP_EQ), 1, e1, e2);
break;
}
case OPR_NE: case OPR_GT: case OPR_GE: {
- codecomp(fs, cast(OpCode, op - OPR_NE + OP_EQ), 0, e1, e2);
+ codecomp(fs, cast(OpCode, (op - OPR_NE) + OP_EQ), 0, e1, e2);
break;
}
default: lua_assert(0);