mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 22:02:27 +00:00
This reverts commit 55a15c204e
.
This commit is contained in:
parent
6bbb44c165
commit
2bc0901ce3
16 changed files with 20 additions and 557 deletions
37
third_party/lua/lparser.c
vendored
37
third_party/lua/lparser.c
vendored
|
@ -905,14 +905,9 @@ static void field (LexState *ls, ConsControl *cc) {
|
|||
}
|
||||
|
||||
|
||||
static void constructor (LexState *ls, expdesc *t, int array) {
|
||||
static void constructor (LexState *ls, expdesc *t) {
|
||||
/* constructor -> '{' [ field { sep field } [sep] ] '}'
|
||||
sep -> ',' | ';' */
|
||||
|
||||
/* special case for arrays (when 'array' is true):
|
||||
constructor -> '[' [ listfield { sep listfield } [sep] ] ']'
|
||||
sep -> ',' | ';' */
|
||||
|
||||
FuncState *fs = ls->fs;
|
||||
int line = ls->linenumber;
|
||||
int pc = luaK_codeABC(fs, OP_NEWTABLE, 0, 0, 0);
|
||||
|
@ -923,32 +918,18 @@ static void constructor (LexState *ls, expdesc *t, int array) {
|
|||
init_exp(t, VNONRELOC, fs->freereg); /* table will be at stack top */
|
||||
luaK_reserveregs(fs, 1);
|
||||
init_exp(&cc.v, VVOID, 0); /* no value (yet) */
|
||||
luaK_exp2nextreg(ls->fs, t); /* fix it at stack top */
|
||||
checknext(ls, (array ? '[' : '{'));
|
||||
checknext(ls, '{');
|
||||
do {
|
||||
lua_assert(cc.v.k == VVOID || cc.tostore > 0);
|
||||
if (ls->t.token == (array ? ']' : '}')) break;
|
||||
if (ls->t.token == '}') break;
|
||||
closelistfield(fs, &cc);
|
||||
if (array)
|
||||
listfield(ls, &cc);
|
||||
else
|
||||
field(ls, &cc);
|
||||
field(ls, &cc);
|
||||
} while (testnext(ls, ',') || testnext(ls, ';'));
|
||||
check_match(ls, array ? ']' : '}', array ? '[' : '{', line);
|
||||
check_match(ls, '}', '{', line);
|
||||
lastlistfield(fs, &cc);
|
||||
luaK_settablesize(fs, pc, t->u.info, cc.na, cc.nh);
|
||||
/* encode arrayness by setting B to max value (255) */
|
||||
if (array) {
|
||||
/* make sure B is not already 255 */
|
||||
/* I don't this can happen in practice (max size is luaO_fb2int(255) = 3221225472), but let's be sure... */
|
||||
unsigned int b = GETARG_B(fs->f->code[pc]);
|
||||
if (b == 255)
|
||||
luaX_syntaxerror(fs->ls, "table too large");
|
||||
SETARG_B(fs->f->code[pc], 255);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* }====================================================================== */
|
||||
|
||||
|
||||
|
@ -1042,7 +1023,7 @@ static void funcargs (LexState *ls, expdesc *f, int line) {
|
|||
break;
|
||||
}
|
||||
case '{': { /* funcargs -> constructor */
|
||||
constructor(ls, &args, 0);
|
||||
constructor(ls, &args);
|
||||
break;
|
||||
}
|
||||
case TK_STRING: { /* funcargs -> STRING */
|
||||
|
@ -1177,11 +1158,7 @@ static void simpleexp (LexState *ls, expdesc *v) {
|
|||
break;
|
||||
}
|
||||
case '{': { /* constructor */
|
||||
constructor(ls, v, 0);
|
||||
return;
|
||||
}
|
||||
case '[': { /* array constructor */
|
||||
constructor(ls, v, 1);
|
||||
constructor(ls, v);
|
||||
return;
|
||||
}
|
||||
case TK_FUNCTION: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue