This commit is contained in:
Roberto Ierusalimschy 2019-11-18 14:54:06 -03:00
parent 679dc72c08
commit 5f83fb6582
6 changed files with 16 additions and 15 deletions

14
lfunc.c
View File

@ -24,20 +24,20 @@
CClosure *luaF_newCclosure (lua_State *L, int n) { CClosure *luaF_newCclosure (lua_State *L, int nupvals) {
GCObject *o = luaC_newobj(L, LUA_TCCL, sizeCclosure(n)); GCObject *o = luaC_newobj(L, LUA_TCCL, sizeCclosure(nupvals));
CClosure *c = gco2ccl(o); CClosure *c = gco2ccl(o);
c->nupvalues = cast_byte(n); c->nupvalues = cast_byte(nupvals);
return c; return c;
} }
LClosure *luaF_newLclosure (lua_State *L, int n) { LClosure *luaF_newLclosure (lua_State *L, int nupvals) {
GCObject *o = luaC_newobj(L, LUA_TLCL, sizeLclosure(n)); GCObject *o = luaC_newobj(L, LUA_TLCL, sizeLclosure(nupvals));
LClosure *c = gco2lcl(o); LClosure *c = gco2lcl(o);
c->p = NULL; c->p = NULL;
c->nupvalues = cast_byte(n); c->nupvalues = cast_byte(nupvals);
while (n--) c->upvals[n] = NULL; while (nupvals--) c->upvals[nupvals] = NULL;
return c; return c;
} }

View File

@ -54,8 +54,8 @@
LUAI_FUNC Proto *luaF_newproto (lua_State *L); LUAI_FUNC Proto *luaF_newproto (lua_State *L);
LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nelems); LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nupvals);
LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nelems); LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nupvals);
LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl); LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl);
LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level);
LUAI_FUNC void luaF_newtbcupval (lua_State *L, StkId level); LUAI_FUNC void luaF_newtbcupval (lua_State *L, StkId level);

View File

@ -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 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) | iABC C(8) | B(8) |k| A(8) | Op(7) |
iABx Bx(17) | 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) | iAx Ax(25) | Op(7) |
isJ sJ(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 GETARG_sC(i) sC2int(GETARG_C(i))
#define SETARG_C(i,v) setarg(i, v, POS_C, SIZE_C) #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 GETARG_k(i) check_exp(checkopm(i, iABC), getarg(i, POS_k, 1))
#define SETARG_k(i,v) setarg(i, v, POS_k, 1) #define SETARG_k(i,v) setarg(i, v, POS_k, 1)

View File

@ -35,7 +35,7 @@ typedef enum {
(string is fixed by the lexer) */ (string is fixed by the lexer) */
VNONRELOC, /* expression has its value in a fixed register; VNONRELOC, /* expression has its value in a fixed register;
info = result 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' */ var.vidx = relative index in 'actvar.arr' */
VUPVAL, /* upvalue variable; info = index of upvalue in 'upvalues' */ VUPVAL, /* upvalue variable; info = index of upvalue in 'upvalues' */
VCONST, /* compile-time constant; info = absolute index in 'actvar.arr' */ VCONST, /* compile-time constant; info = absolute index in 'actvar.arr' */

2
lvm.c
View File

@ -1082,7 +1082,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
lua_assert(base == ci->func + 1); lua_assert(base == ci->func + 1);
lua_assert(base <= L->top && L->top < L->stack + L->stacksize); lua_assert(base <= L->top && L->top < L->stack + L->stacksize);
/* invalidate top for instructions not expecting it */ /* 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)) { vmdispatch (GET_OPCODE(i)) {
vmcase(OP_MOVE) { vmcase(OP_MOVE) {
setobjs2s(L, ra, RB(i)); setobjs2s(L, ra, RB(i));

View File

@ -8237,7 +8237,8 @@ This library is implemented through table @defid{os}.
@LibEntry{os.clock ()| @LibEntry{os.clock ()|
Returns an approximation of the amount in seconds of CPU time 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)| @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. or @fail if the variable is not defined.
} }