Clearer code for controlling maximum registers
Plus, added a test to check that limit.
This commit is contained in:
6
lcode.c
6
lcode.c
@@ -31,10 +31,6 @@
|
||||
#include "lvm.h"
|
||||
|
||||
|
||||
/* Maximum number of registers in a Lua function (must fit in 8 bits) */
|
||||
#define MAXREGS 255
|
||||
|
||||
|
||||
#define hasjumps(e) ((e)->t != (e)->f)
|
||||
|
||||
|
||||
@@ -466,7 +462,7 @@ static int luaK_codek (FuncState *fs, int reg, int k) {
|
||||
void luaK_checkstack (FuncState *fs, int n) {
|
||||
int newstack = fs->freereg + n;
|
||||
if (newstack > fs->f->maxstacksize) {
|
||||
if (newstack >= MAXREGS)
|
||||
if (newstack > MAX_FSTACK)
|
||||
luaX_syntaxerror(fs->ls,
|
||||
"function or expression needs too many registers");
|
||||
fs->f->maxstacksize = cast_byte(newstack);
|
||||
|
||||
Reference in New Issue
Block a user