diff options
Diffstat (limited to '')
| -rw-r--r-- | lcode.c | 14 | ||||
| -rw-r--r-- | ldo.c | 16 | ||||
| -rw-r--r-- | lparser.h | 5 | ||||
| -rw-r--r-- | manual/manual.of | 13 |
4 files changed, 30 insertions, 18 deletions
| @@ -753,7 +753,7 @@ void luaK_setoneret (FuncState *fs, expdesc *e) { | |||
| 753 | 753 | ||
| 754 | 754 | ||
| 755 | /* | 755 | /* |
| 756 | ** Ensure that expression 'e' is not a variable (nor a constant). | 756 | ** Ensure that expression 'e' is not a variable (nor a <const>). |
| 757 | ** (Expression still may have jump lists.) | 757 | ** (Expression still may have jump lists.) |
| 758 | */ | 758 | */ |
| 759 | void luaK_dischargevars (FuncState *fs, expdesc *e) { | 759 | void luaK_dischargevars (FuncState *fs, expdesc *e) { |
| @@ -805,8 +805,8 @@ void luaK_dischargevars (FuncState *fs, expdesc *e) { | |||
| 805 | 805 | ||
| 806 | 806 | ||
| 807 | /* | 807 | /* |
| 808 | ** Ensures expression value is in register 'reg' (and therefore | 808 | ** Ensure expression value is in register 'reg', making 'e' a |
| 809 | ** 'e' will become a non-relocatable expression). | 809 | ** non-relocatable expression. |
| 810 | ** (Expression still may have jump lists.) | 810 | ** (Expression still may have jump lists.) |
| 811 | */ | 811 | */ |
| 812 | static void discharge2reg (FuncState *fs, expdesc *e, int reg) { | 812 | static void discharge2reg (FuncState *fs, expdesc *e, int reg) { |
| @@ -860,7 +860,8 @@ static void discharge2reg (FuncState *fs, expdesc *e, int reg) { | |||
| 860 | 860 | ||
| 861 | 861 | ||
| 862 | /* | 862 | /* |
| 863 | ** Ensures expression value is in any register. | 863 | ** Ensure expression value is in a register, making 'e' a |
| 864 | ** non-relocatable expression. | ||
| 864 | ** (Expression still may have jump lists.) | 865 | ** (Expression still may have jump lists.) |
| 865 | */ | 866 | */ |
| 866 | static void discharge2anyreg (FuncState *fs, expdesc *e) { | 867 | static void discharge2anyreg (FuncState *fs, expdesc *e) { |
| @@ -946,8 +947,11 @@ int luaK_exp2anyreg (FuncState *fs, expdesc *e) { | |||
| 946 | exp2reg(fs, e, e->u.info); /* put final result in it */ | 947 | exp2reg(fs, e, e->u.info); /* put final result in it */ |
| 947 | return e->u.info; | 948 | return e->u.info; |
| 948 | } | 949 | } |
| 950 | /* else expression has jumps and cannot change its register | ||
| 951 | to hold the jump values, because it is a local variable. | ||
| 952 | Go through to the default case. */ | ||
| 949 | } | 953 | } |
| 950 | luaK_exp2nextreg(fs, e); /* otherwise, use next available register */ | 954 | luaK_exp2nextreg(fs, e); /* default: use next available register */ |
| 951 | return e->u.info; | 955 | return e->u.info; |
| 952 | } | 956 | } |
| 953 | 957 | ||
| @@ -534,11 +534,11 @@ CallInfo *luaD_precall (lua_State *L, StkId func, int nresults) { | |||
| 534 | 534 | ||
| 535 | 535 | ||
| 536 | /* | 536 | /* |
| 537 | ** Call a function (C or Lua). 'inc' can be 1 (increment number | 537 | ** Call a function (C or Lua) through C. 'inc' can be 1 (increment |
| 538 | ** of recursive invocations in the C stack) or nyci (the same plus | 538 | ** number of recursive invocations in the C stack) or nyci (the same |
| 539 | ** increment number of non-yieldable calls). | 539 | ** plus increment number of non-yieldable calls). |
| 540 | */ | 540 | */ |
| 541 | static void docall (lua_State *L, StkId func, int nResults, int inc) { | 541 | static void ccall (lua_State *L, StkId func, int nResults, int inc) { |
| 542 | CallInfo *ci; | 542 | CallInfo *ci; |
| 543 | L->nCcalls += inc; | 543 | L->nCcalls += inc; |
| 544 | if (unlikely(getCcalls(L) >= LUAI_MAXCCALLS)) | 544 | if (unlikely(getCcalls(L) >= LUAI_MAXCCALLS)) |
| @@ -552,10 +552,10 @@ static void docall (lua_State *L, StkId func, int nResults, int inc) { | |||
| 552 | 552 | ||
| 553 | 553 | ||
| 554 | /* | 554 | /* |
| 555 | ** External interface for 'docall' | 555 | ** External interface for 'ccall' |
| 556 | */ | 556 | */ |
| 557 | void luaD_call (lua_State *L, StkId func, int nResults) { | 557 | void luaD_call (lua_State *L, StkId func, int nResults) { |
| 558 | return docall(L, func, nResults, 1); | 558 | ccall(L, func, nResults, 1); |
| 559 | } | 559 | } |
| 560 | 560 | ||
| 561 | 561 | ||
| @@ -563,7 +563,7 @@ void luaD_call (lua_State *L, StkId func, int nResults) { | |||
| 563 | ** Similar to 'luaD_call', but does not allow yields during the call. | 563 | ** Similar to 'luaD_call', but does not allow yields during the call. |
| 564 | */ | 564 | */ |
| 565 | void luaD_callnoyield (lua_State *L, StkId func, int nResults) { | 565 | void luaD_callnoyield (lua_State *L, StkId func, int nResults) { |
| 566 | return docall(L, func, nResults, nyci); | 566 | ccall(L, func, nResults, nyci); |
| 567 | } | 567 | } |
| 568 | 568 | ||
| 569 | 569 | ||
| @@ -678,7 +678,7 @@ static void resume (lua_State *L, void *ud) { | |||
| 678 | StkId firstArg = L->top - n; /* first argument */ | 678 | StkId firstArg = L->top - n; /* first argument */ |
| 679 | CallInfo *ci = L->ci; | 679 | CallInfo *ci = L->ci; |
| 680 | if (L->status == LUA_OK) /* starting a coroutine? */ | 680 | if (L->status == LUA_OK) /* starting a coroutine? */ |
| 681 | docall(L, firstArg - 1, LUA_MULTRET, 1); /* just call its body */ | 681 | ccall(L, firstArg - 1, LUA_MULTRET, 1); /* just call its body */ |
| 682 | else { /* resuming from previous yield */ | 682 | else { /* resuming from previous yield */ |
| 683 | lua_assert(L->status == LUA_YIELD); | 683 | lua_assert(L->status == LUA_YIELD); |
| 684 | L->status = LUA_OK; /* mark that it is running (again) */ | 684 | L->status = LUA_OK; /* mark that it is running (again) */ |
| @@ -23,7 +23,7 @@ | |||
| 23 | 23 | ||
| 24 | /* kinds of variables/expressions */ | 24 | /* kinds of variables/expressions */ |
| 25 | typedef enum { | 25 | typedef enum { |
| 26 | VVOID, /* when 'expdesc' describes the last expression a list, | 26 | VVOID, /* when 'expdesc' describes the last expression of a list, |
| 27 | this kind means an empty list (so, no expression) */ | 27 | this kind means an empty list (so, no expression) */ |
| 28 | VNIL, /* constant nil */ | 28 | VNIL, /* constant nil */ |
| 29 | VTRUE, /* constant true */ | 29 | VTRUE, /* constant true */ |
| @@ -38,7 +38,8 @@ typedef enum { | |||
| 38 | VLOCAL, /* local variable; var.sidx = stack index (local register); | 38 | VLOCAL, /* local variable; var.sidx = stack index (local register); |
| 39 | var.vidx = relative index in 'actvar.arr' */ | 39 | var.vidx = relative index in 'actvar.arr' */ |
| 40 | VUPVAL, /* upvalue variable; info = index of upvalue in 'upvalues' */ | 40 | VUPVAL, /* upvalue variable; info = index of upvalue in 'upvalues' */ |
| 41 | VCONST, /* compile-time constant; info = absolute index in 'actvar.arr' */ | 41 | VCONST, /* compile-time <const> variable; |
| 42 | info = absolute index in 'actvar.arr' */ | ||
| 42 | VINDEXED, /* indexed variable; | 43 | VINDEXED, /* indexed variable; |
| 43 | ind.t = table register; | 44 | ind.t = table register; |
| 44 | ind.idx = key's R index */ | 45 | ind.idx = key's R index */ |
diff --git a/manual/manual.of b/manual/manual.of index 86631bbc..606771f4 100644 --- a/manual/manual.of +++ b/manual/manual.of | |||
| @@ -2516,7 +2516,8 @@ Lua's garbage collection can free or move internal memory | |||
| 2516 | and then invalidate pointers to internal strings. | 2516 | and then invalidate pointers to internal strings. |
| 2517 | To allow a safe use of these pointers, | 2517 | To allow a safe use of these pointers, |
| 2518 | The API guarantees that any pointer to a string in a stack index | 2518 | The API guarantees that any pointer to a string in a stack index |
| 2519 | is valid while the value at that index is neither modified nor popped. | 2519 | is valid while the string value at that index is not removed from the stack. |
| 2520 | (It can be moved to another index, though.) | ||
| 2520 | When the index is a pseudo-index (referring to an upvalue), | 2521 | When the index is a pseudo-index (referring to an upvalue), |
| 2521 | the pointer is valid while the corresponding call is active and | 2522 | the pointer is valid while the corresponding call is active and |
| 2522 | the corresponding upvalue is not modified. | 2523 | the corresponding upvalue is not modified. |
| @@ -3744,10 +3745,13 @@ except that it allows the called function to yield @see{continuations}. | |||
| 3744 | } | 3745 | } |
| 3745 | 3746 | ||
| 3746 | @APIEntry{void lua_pop (lua_State *L, int n);| | 3747 | @APIEntry{void lua_pop (lua_State *L, int n);| |
| 3747 | @apii{n,0,-} | 3748 | @apii{n,0,e} |
| 3748 | 3749 | ||
| 3749 | Pops @id{n} elements from the stack. | 3750 | Pops @id{n} elements from the stack. |
| 3750 | 3751 | ||
| 3752 | This function can run arbitrary code when removing an index | ||
| 3753 | marked as to-be-closed from the stack. | ||
| 3754 | |||
| 3751 | } | 3755 | } |
| 3752 | 3756 | ||
| 3753 | @APIEntry{void lua_pushboolean (lua_State *L, int b);| | 3757 | @APIEntry{void lua_pushboolean (lua_State *L, int b);| |
| @@ -4227,7 +4231,7 @@ for the @Q{newindex} event @see{metatable}. | |||
| 4227 | } | 4231 | } |
| 4228 | 4232 | ||
| 4229 | @APIEntry{void lua_settop (lua_State *L, int index);| | 4233 | @APIEntry{void lua_settop (lua_State *L, int index);| |
| 4230 | @apii{?,?,-} | 4234 | @apii{?,?,e} |
| 4231 | 4235 | ||
| 4232 | Accepts any index, @N{or 0}, | 4236 | Accepts any index, @N{or 0}, |
| 4233 | and sets the stack top to this index. | 4237 | and sets the stack top to this index. |
| @@ -4235,6 +4239,9 @@ If the new top is greater than the old one, | |||
| 4235 | then the new elements are filled with @nil. | 4239 | then the new elements are filled with @nil. |
| 4236 | If @id{index} @N{is 0}, then all stack elements are removed. | 4240 | If @id{index} @N{is 0}, then all stack elements are removed. |
| 4237 | 4241 | ||
| 4242 | This function can run arbitrary code when removing an index | ||
| 4243 | marked as to-be-closed from the stack. | ||
| 4244 | |||
| 4238 | } | 4245 | } |
| 4239 | 4246 | ||
| 4240 | @APIEntry{void lua_setwarnf (lua_State *L, lua_WarnFunction f, void *ud);| | 4247 | @APIEntry{void lua_setwarnf (lua_State *L, lua_WarnFunction f, void *ud);| |
