diff options
| author | Li Jin <dragon-fly@qq.com> | 2021-08-17 23:09:27 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2021-08-17 23:09:27 +0800 |
| commit | 38908616d0e08b72e6b00d18490ed917fa643e4f (patch) | |
| tree | 4311b80a505f4c3819c8cb2c3c937296fef0356f /src/3rdParty/lua/lparser.c | |
| parent | 792e942f5269655ee03c48400999f3604b84396c (diff) | |
| download | yuescript-38908616d0e08b72e6b00d18490ed917fa643e4f.tar.gz yuescript-38908616d0e08b72e6b00d18490ed917fa643e4f.tar.bz2 yuescript-38908616d0e08b72e6b00d18490ed917fa643e4f.zip | |
reset Yuescript version since it's a minor version with new feature. update Lua lib.
Diffstat (limited to 'src/3rdParty/lua/lparser.c')
| -rw-r--r-- | src/3rdParty/lua/lparser.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/3rdParty/lua/lparser.c b/src/3rdParty/lua/lparser.c index 284ef1f..3abe3d7 100644 --- a/src/3rdParty/lua/lparser.c +++ b/src/3rdParty/lua/lparser.c | |||
| @@ -417,6 +417,17 @@ static void markupval (FuncState *fs, int level) { | |||
| 417 | 417 | ||
| 418 | 418 | ||
| 419 | /* | 419 | /* |
| 420 | ** Mark that current block has a to-be-closed variable. | ||
| 421 | */ | ||
| 422 | static void marktobeclosed (FuncState *fs) { | ||
| 423 | BlockCnt *bl = fs->bl; | ||
| 424 | bl->upval = 1; | ||
| 425 | bl->insidetbc = 1; | ||
| 426 | fs->needclose = 1; | ||
| 427 | } | ||
| 428 | |||
| 429 | |||
| 430 | /* | ||
| 420 | ** Find a variable with the given name 'n'. If it is an upvalue, add | 431 | ** Find a variable with the given name 'n'. If it is an upvalue, add |
| 421 | ** this upvalue into all intermediate functions. If it is a global, set | 432 | ** this upvalue into all intermediate functions. If it is a global, set |
| 422 | ** 'var' as 'void' as a flag. | 433 | ** 'var' as 'void' as a flag. |
| @@ -1599,7 +1610,7 @@ static void forlist (LexState *ls, TString *indexname) { | |||
| 1599 | line = ls->linenumber; | 1610 | line = ls->linenumber; |
| 1600 | adjust_assign(ls, 4, explist(ls, &e), &e); | 1611 | adjust_assign(ls, 4, explist(ls, &e), &e); |
| 1601 | adjustlocalvars(ls, 4); /* control variables */ | 1612 | adjustlocalvars(ls, 4); /* control variables */ |
| 1602 | markupval(fs, fs->nactvar); /* last control var. must be closed */ | 1613 | marktobeclosed(fs); /* last control var. must be closed */ |
| 1603 | luaK_checkstack(fs, 3); /* extra space to call generator */ | 1614 | luaK_checkstack(fs, 3); /* extra space to call generator */ |
| 1604 | forbody(ls, base, line, nvars - 4, 1); | 1615 | forbody(ls, base, line, nvars - 4, 1); |
| 1605 | } | 1616 | } |
| @@ -1703,11 +1714,9 @@ static int getlocalattribute (LexState *ls) { | |||
| 1703 | } | 1714 | } |
| 1704 | 1715 | ||
| 1705 | 1716 | ||
| 1706 | static void checktoclose (LexState *ls, int level) { | 1717 | static void checktoclose (FuncState *fs, int level) { |
| 1707 | if (level != -1) { /* is there a to-be-closed variable? */ | 1718 | if (level != -1) { /* is there a to-be-closed variable? */ |
| 1708 | FuncState *fs = ls->fs; | 1719 | marktobeclosed(fs); |
| 1709 | markupval(fs, level + 1); | ||
| 1710 | fs->bl->insidetbc = 1; /* in the scope of a to-be-closed variable */ | ||
| 1711 | luaK_codeABC(fs, OP_TBC, reglevel(fs, level), 0, 0); | 1720 | luaK_codeABC(fs, OP_TBC, reglevel(fs, level), 0, 0); |
| 1712 | } | 1721 | } |
| 1713 | } | 1722 | } |
| @@ -1751,7 +1760,7 @@ static void localstat (LexState *ls) { | |||
| 1751 | adjust_assign(ls, nvars, nexps, &e); | 1760 | adjust_assign(ls, nvars, nexps, &e); |
| 1752 | adjustlocalvars(ls, nvars); | 1761 | adjustlocalvars(ls, nvars); |
| 1753 | } | 1762 | } |
| 1754 | checktoclose(ls, toclose); | 1763 | checktoclose(fs, toclose); |
| 1755 | } | 1764 | } |
| 1756 | 1765 | ||
| 1757 | 1766 | ||
| @@ -1776,6 +1785,7 @@ static void funcstat (LexState *ls, int line) { | |||
| 1776 | luaX_next(ls); /* skip FUNCTION */ | 1785 | luaX_next(ls); /* skip FUNCTION */ |
| 1777 | ismethod = funcname(ls, &v); | 1786 | ismethod = funcname(ls, &v); |
| 1778 | body(ls, &b, ismethod, line); | 1787 | body(ls, &b, ismethod, line); |
| 1788 | check_readonly(ls, &v); | ||
| 1779 | luaK_storevar(ls->fs, &v, &b); | 1789 | luaK_storevar(ls->fs, &v, &b); |
| 1780 | luaK_fixline(ls->fs, line); /* definition "happens" in the first line */ | 1790 | luaK_fixline(ls->fs, line); /* definition "happens" in the first line */ |
| 1781 | } | 1791 | } |
