From 5f83fb658206d195e54d3574b989ce5285a5b18f Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 18 Nov 2019 14:54:06 -0300 Subject: [PATCH] Details --- lfunc.c | 14 +++++++------- lfunc.h | 4 ++-- lopcodes.h | 4 ++-- lparser.h | 2 +- lvm.c | 2 +- manual/manual.of | 5 +++-- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/lfunc.c b/lfunc.c index 1e61f03f..0ef73284 100644 --- a/lfunc.c +++ b/lfunc.c @@ -24,20 +24,20 @@ -CClosure *luaF_newCclosure (lua_State *L, int n) { - GCObject *o = luaC_newobj(L, LUA_TCCL, sizeCclosure(n)); +CClosure *luaF_newCclosure (lua_State *L, int nupvals) { + GCObject *o = luaC_newobj(L, LUA_TCCL, sizeCclosure(nupvals)); CClosure *c = gco2ccl(o); - c->nupvalues = cast_byte(n); + c->nupvalues = cast_byte(nupvals); return c; } -LClosure *luaF_newLclosure (lua_State *L, int n) { - GCObject *o = luaC_newobj(L, LUA_TLCL, sizeLclosure(n)); +LClosure *luaF_newLclosure (lua_State *L, int nupvals) { + GCObject *o = luaC_newobj(L, LUA_TLCL, sizeLclosure(nupvals)); LClosure *c = gco2lcl(o); c->p = NULL; - c->nupvalues = cast_byte(n); - while (n--) c->upvals[n] = NULL; + c->nupvalues = cast_byte(nupvals); + while (nupvals--) c->upvals[nupvals] = NULL; return c; } diff --git a/lfunc.h b/lfunc.h index 0ed79c48..8d6f965c 100644 --- a/lfunc.h +++ b/lfunc.h @@ -54,8 +54,8 @@ LUAI_FUNC Proto *luaF_newproto (lua_State *L); -LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nelems); -LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nelems); +LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nupvals); +LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nupvals); LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl); LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); LUAI_FUNC void luaF_newtbcupval (lua_State *L, StkId level); diff --git a/lopcodes.h b/lopcodes.h index dbef6a65..382dec05 100644 --- a/lopcodes.h +++ b/lopcodes.h @@ -19,7 +19,7 @@ 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 iABC C(8) | B(8) |k| A(8) | Op(7) | iABx Bx(17) | A(8) | Op(7) | -iAsB sBx (signed)(17) | A(8) | Op(7) | +iAsBx sBx (signed)(17) | A(8) | Op(7) | iAx Ax(25) | Op(7) | isJ sJ(25) | Op(7) | @@ -133,7 +133,7 @@ enum OpMode {iABC, iABx, iAsBx, iAx, isJ}; /* basic instruction formats */ #define GETARG_sC(i) sC2int(GETARG_C(i)) #define SETARG_C(i,v) setarg(i, v, POS_C, SIZE_C) -#define TESTARG_k(i) (cast_int(((i) & (1u << POS_k)))) +#define TESTARG_k(i) check_exp(checkopm(i, iABC), (cast_int(((i) & (1u << POS_k))))) #define GETARG_k(i) check_exp(checkopm(i, iABC), getarg(i, POS_k, 1)) #define SETARG_k(i,v) setarg(i, v, POS_k, 1) diff --git a/lparser.h b/lparser.h index f528f013..f544492e 100644 --- a/lparser.h +++ b/lparser.h @@ -35,7 +35,7 @@ typedef enum { (string is fixed by the lexer) */ VNONRELOC, /* expression has its value in a fixed register; info = result register */ - VLOCAL, /* local variable; var.ridx = local register; + VLOCAL, /* local variable; var.sidx = stack index (local register); var.vidx = relative index in 'actvar.arr' */ VUPVAL, /* upvalue variable; info = index of upvalue in 'upvalues' */ VCONST, /* compile-time constant; info = absolute index in 'actvar.arr' */ diff --git a/lvm.c b/lvm.c index 2c96c58d..93cb8bc8 100644 --- a/lvm.c +++ b/lvm.c @@ -1082,7 +1082,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { lua_assert(base == ci->func + 1); lua_assert(base <= L->top && L->top < L->stack + L->stacksize); /* invalidate top for instructions not expecting it */ - lua_assert(isIT(i) || (L->top = base)); + lua_assert(isIT(i) || (cast_void(L->top = base), 1)); vmdispatch (GET_OPCODE(i)) { vmcase(OP_MOVE) { setobjs2s(L, ra, RB(i)); diff --git a/manual/manual.of b/manual/manual.of index 7b5b9385..61d4afac 100644 --- a/manual/manual.of +++ b/manual/manual.of @@ -8237,7 +8237,8 @@ This library is implemented through table @defid{os}. @LibEntry{os.clock ()| Returns an approximation of the amount in seconds of CPU time -used by the program. +used by the program, +as returned by the underlying @ANSI{clock}. } @@ -8336,7 +8337,7 @@ closes the Lua state before exiting. @LibEntry{os.getenv (varname)| -Returns the value of the process environment variable @id{varname}, +Returns the value of the process environment variable @id{varname} or @fail if the variable is not defined. }