Expand array slots in template tables with mixed const/var initializers.
This commit is contained in:
parent
eacecc90e1
commit
89f8c920c6
@ -1530,7 +1530,7 @@ static void expr_table(LexState *ls, ExpDesc *e)
|
|||||||
BCLine line = ls->linenumber;
|
BCLine line = ls->linenumber;
|
||||||
GCtab *t = NULL;
|
GCtab *t = NULL;
|
||||||
int vcall = 0, needarr = 0, fixt = 0;
|
int vcall = 0, needarr = 0, fixt = 0;
|
||||||
int32_t narr = 1; /* First array index. */
|
uint32_t narr = 1; /* First array index. */
|
||||||
uint32_t nhash = 0; /* Number of hash entries. */
|
uint32_t nhash = 0; /* Number of hash entries. */
|
||||||
BCReg freg = fs->freereg;
|
BCReg freg = fs->freereg;
|
||||||
BCPos pc = bcemit_AD(fs, BC_TNEW, freg, 0);
|
BCPos pc = bcemit_AD(fs, BC_TNEW, freg, 0);
|
||||||
@ -1552,7 +1552,7 @@ static void expr_table(LexState *ls, ExpDesc *e)
|
|||||||
nhash++;
|
nhash++;
|
||||||
} else {
|
} else {
|
||||||
expr_init(&key, VKNUM, 0);
|
expr_init(&key, VKNUM, 0);
|
||||||
setintV(&key.u.nval, narr);
|
setintV(&key.u.nval, (int)narr);
|
||||||
narr++;
|
narr++;
|
||||||
needarr = vcall = 1;
|
needarr = vcall = 1;
|
||||||
}
|
}
|
||||||
@ -1562,7 +1562,7 @@ static void expr_table(LexState *ls, ExpDesc *e)
|
|||||||
TValue k, *v;
|
TValue k, *v;
|
||||||
if (!t) { /* Create template table on demand. */
|
if (!t) { /* Create template table on demand. */
|
||||||
BCReg kidx;
|
BCReg kidx;
|
||||||
t = lj_tab_new(fs->L, 0, 0);
|
t = lj_tab_new(fs->L, narr, hsize2hbits(nhash));
|
||||||
kidx = const_gc(fs, obj2gco(t), LJ_TTAB);
|
kidx = const_gc(fs, obj2gco(t), LJ_TTAB);
|
||||||
fs->bcbase[pc].ins = BCINS_AD(BC_TDUP, freg-1, kidx);
|
fs->bcbase[pc].ins = BCINS_AD(BC_TDUP, freg-1, kidx);
|
||||||
}
|
}
|
||||||
@ -1611,15 +1611,19 @@ static void expr_table(LexState *ls, ExpDesc *e)
|
|||||||
if (!needarr) narr = 0;
|
if (!needarr) narr = 0;
|
||||||
else if (narr < 3) narr = 3;
|
else if (narr < 3) narr = 3;
|
||||||
else if (narr > 0x7ff) narr = 0x7ff;
|
else if (narr > 0x7ff) narr = 0x7ff;
|
||||||
setbc_d(ip, (uint32_t)narr|(hsize2hbits(nhash)<<11));
|
setbc_d(ip, narr|(hsize2hbits(nhash)<<11));
|
||||||
} else if (fixt) { /* Fix value for dummy keys in template table. */
|
} else {
|
||||||
Node *node = noderef(t->node);
|
if (needarr && t->asize < narr)
|
||||||
uint32_t i, hmask = t->hmask;
|
lj_tab_reasize(fs->L, t, narr-1);
|
||||||
for (i = 0; i <= hmask; i++) {
|
if (fixt) { /* Fix value for dummy keys in template table. */
|
||||||
Node *n = &node[i];
|
Node *node = noderef(t->node);
|
||||||
if (tvistab(&n->val)) {
|
uint32_t i, hmask = t->hmask;
|
||||||
lua_assert(tabV(&n->val) == t);
|
for (i = 0; i <= hmask; i++) {
|
||||||
setnilV(&n->val); /* Turn value into nil. */
|
Node *n = &node[i];
|
||||||
|
if (tvistab(&n->val)) {
|
||||||
|
lua_assert(tabV(&n->val) == t);
|
||||||
|
setnilV(&n->val); /* Turn value into nil. */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user