- small corrections in the manual
- ldo.c: 'docall' -> 'ccall' ('docall' already used in 'lua.c')
- comments
This commit is contained in:
Roberto Ierusalimschy 2020-10-30 10:18:54 -03:00
parent 69b71a6919
commit 94cbe46511
4 changed files with 30 additions and 18 deletions

14
lcode.c
View File

@ -753,7 +753,7 @@ void luaK_setoneret (FuncState *fs, expdesc *e) {
/* /*
** Ensure that expression 'e' is not a variable (nor a constant). ** Ensure that expression 'e' is not a variable (nor a <const>).
** (Expression still may have jump lists.) ** (Expression still may have jump lists.)
*/ */
void luaK_dischargevars (FuncState *fs, expdesc *e) { void luaK_dischargevars (FuncState *fs, expdesc *e) {
@ -805,8 +805,8 @@ void luaK_dischargevars (FuncState *fs, expdesc *e) {
/* /*
** Ensures expression value is in register 'reg' (and therefore ** Ensure expression value is in register 'reg', making 'e' a
** 'e' will become a non-relocatable expression). ** non-relocatable expression.
** (Expression still may have jump lists.) ** (Expression still may have jump lists.)
*/ */
static void discharge2reg (FuncState *fs, expdesc *e, int reg) { static void discharge2reg (FuncState *fs, expdesc *e, int reg) {
@ -860,7 +860,8 @@ static void discharge2reg (FuncState *fs, expdesc *e, int reg) {
/* /*
** Ensures expression value is in any register. ** Ensure expression value is in a register, making 'e' a
** non-relocatable expression.
** (Expression still may have jump lists.) ** (Expression still may have jump lists.)
*/ */
static void discharge2anyreg (FuncState *fs, expdesc *e) { static void discharge2anyreg (FuncState *fs, expdesc *e) {
@ -946,8 +947,11 @@ int luaK_exp2anyreg (FuncState *fs, expdesc *e) {
exp2reg(fs, e, e->u.info); /* put final result in it */ exp2reg(fs, e, e->u.info); /* put final result in it */
return e->u.info; return e->u.info;
} }
/* else expression has jumps and cannot change its register
to hold the jump values, because it is a local variable.
Go through to the default case. */
} }
luaK_exp2nextreg(fs, e); /* otherwise, use next available register */ luaK_exp2nextreg(fs, e); /* default: use next available register */
return e->u.info; return e->u.info;
} }

16
ldo.c
View File

@ -534,11 +534,11 @@ CallInfo *luaD_precall (lua_State *L, StkId func, int nresults) {
/* /*
** Call a function (C or Lua). 'inc' can be 1 (increment number ** Call a function (C or Lua) through C. 'inc' can be 1 (increment
** of recursive invocations in the C stack) or nyci (the same plus ** number of recursive invocations in the C stack) or nyci (the same
** increment number of non-yieldable calls). ** plus increment number of non-yieldable calls).
*/ */
static void docall (lua_State *L, StkId func, int nResults, int inc) { static void ccall (lua_State *L, StkId func, int nResults, int inc) {
CallInfo *ci; CallInfo *ci;
L->nCcalls += inc; L->nCcalls += inc;
if (unlikely(getCcalls(L) >= LUAI_MAXCCALLS)) if (unlikely(getCcalls(L) >= LUAI_MAXCCALLS))
@ -552,10 +552,10 @@ static void docall (lua_State *L, StkId func, int nResults, int inc) {
/* /*
** External interface for 'docall' ** External interface for 'ccall'
*/ */
void luaD_call (lua_State *L, StkId func, int nResults) { void luaD_call (lua_State *L, StkId func, int nResults) {
return docall(L, func, nResults, 1); ccall(L, func, nResults, 1);
} }
@ -563,7 +563,7 @@ void luaD_call (lua_State *L, StkId func, int nResults) {
** Similar to 'luaD_call', but does not allow yields during the call. ** Similar to 'luaD_call', but does not allow yields during the call.
*/ */
void luaD_callnoyield (lua_State *L, StkId func, int nResults) { void luaD_callnoyield (lua_State *L, StkId func, int nResults) {
return docall(L, func, nResults, nyci); ccall(L, func, nResults, nyci);
} }
@ -678,7 +678,7 @@ static void resume (lua_State *L, void *ud) {
StkId firstArg = L->top - n; /* first argument */ StkId firstArg = L->top - n; /* first argument */
CallInfo *ci = L->ci; CallInfo *ci = L->ci;
if (L->status == LUA_OK) /* starting a coroutine? */ if (L->status == LUA_OK) /* starting a coroutine? */
docall(L, firstArg - 1, LUA_MULTRET, 1); /* just call its body */ ccall(L, firstArg - 1, LUA_MULTRET, 1); /* just call its body */
else { /* resuming from previous yield */ else { /* resuming from previous yield */
lua_assert(L->status == LUA_YIELD); lua_assert(L->status == LUA_YIELD);
L->status = LUA_OK; /* mark that it is running (again) */ L->status = LUA_OK; /* mark that it is running (again) */

View File

@ -23,7 +23,7 @@
/* kinds of variables/expressions */ /* kinds of variables/expressions */
typedef enum { typedef enum {
VVOID, /* when 'expdesc' describes the last expression a list, VVOID, /* when 'expdesc' describes the last expression of a list,
this kind means an empty list (so, no expression) */ this kind means an empty list (so, no expression) */
VNIL, /* constant nil */ VNIL, /* constant nil */
VTRUE, /* constant true */ VTRUE, /* constant true */
@ -38,7 +38,8 @@ typedef enum {
VLOCAL, /* local variable; var.sidx = stack index (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 <const> variable;
info = absolute index in 'actvar.arr' */
VINDEXED, /* indexed variable; VINDEXED, /* indexed variable;
ind.t = table register; ind.t = table register;
ind.idx = key's R index */ ind.idx = key's R index */

View File

@ -2516,7 +2516,8 @@ Lua's garbage collection can free or move internal memory
and then invalidate pointers to internal strings. and then invalidate pointers to internal strings.
To allow a safe use of these pointers, To allow a safe use of these pointers,
The API guarantees that any pointer to a string in a stack index The API guarantees that any pointer to a string in a stack index
is valid while the value at that index is neither modified nor popped. is valid while the string value at that index is not removed from the stack.
(It can be moved to another index, though.)
When the index is a pseudo-index (referring to an upvalue), When the index is a pseudo-index (referring to an upvalue),
the pointer is valid while the corresponding call is active and the pointer is valid while the corresponding call is active and
the corresponding upvalue is not modified. the corresponding upvalue is not modified.
@ -3744,10 +3745,13 @@ except that it allows the called function to yield @see{continuations}.
} }
@APIEntry{void lua_pop (lua_State *L, int n);| @APIEntry{void lua_pop (lua_State *L, int n);|
@apii{n,0,-} @apii{n,0,e}
Pops @id{n} elements from the stack. Pops @id{n} elements from the stack.
This function can run arbitrary code when removing an index
marked as to-be-closed from the stack.
} }
@APIEntry{void lua_pushboolean (lua_State *L, int b);| @APIEntry{void lua_pushboolean (lua_State *L, int b);|
@ -4227,7 +4231,7 @@ for the @Q{newindex} event @see{metatable}.
} }
@APIEntry{void lua_settop (lua_State *L, int index);| @APIEntry{void lua_settop (lua_State *L, int index);|
@apii{?,?,-} @apii{?,?,e}
Accepts any index, @N{or 0}, Accepts any index, @N{or 0},
and sets the stack top to this index. and sets the stack top to this index.
@ -4235,6 +4239,9 @@ If the new top is greater than the old one,
then the new elements are filled with @nil. then the new elements are filled with @nil.
If @id{index} @N{is 0}, then all stack elements are removed. If @id{index} @N{is 0}, then all stack elements are removed.
This function can run arbitrary code when removing an index
marked as to-be-closed from the stack.
} }
@APIEntry{void lua_setwarnf (lua_State *L, lua_WarnFunction f, void *ud);| @APIEntry{void lua_setwarnf (lua_State *L, lua_WarnFunction f, void *ud);|