Implement/fix TGETS and TSETS.

Allows string keys in tables, for example:

t = {}
t["hello"] = 1
print(t["hello"]) -- prints 1
This commit is contained in:
Michael Munday 2016-12-22 14:40:31 -05:00
parent cab03375f1
commit c0c155e45e

View File

@ -2070,7 +2070,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
| lghi TMPR1, -1 | lghi TMPR1, -1
| xgr RC, TMPR1 | xgr RC, TMPR1
| sllg RC, RC, 3(r0) | sllg RC, RC, 3(r0)
| lg STR:RC, 0(RC, BASE) | lg STR:RC, 0(RC, KBASE)
| checktab TAB:RB, ->vmeta_tgets | checktab TAB:RB, ->vmeta_tgets
|->BC_TGETS_Z: // RB = GCtab *, RC = GCstr * |->BC_TGETS_Z: // RB = GCtab *, RC = GCstr *
| l TMPR1, TAB:RB->hmask | l TMPR1, TAB:RB->hmask
@ -2186,8 +2186,14 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
| j <2 | j <2
break; break;
case BC_TSETS: case BC_TSETS:
| stg r0, 0(r0) | ins_ABC // RA = src, RB = table, RC = str const (~)
| | sllg RB, RB, 3(r0)
| lg TAB:RB, 0(RB, BASE)
| lghi TMPR2, -1
| xgr RC, TMPR2 // ~RC
| sllg RC, RC, 3(r0)
| lg STR:RC, 0(RC, KBASE)
| checktab TAB:RB, ->vmeta_tsets
|->BC_TSETS_Z: // RB = GCtab *, RC = GCstr * |->BC_TSETS_Z: // RB = GCtab *, RC = GCstr *
| l TMPR1, TAB:RB->hmask | l TMPR1, TAB:RB->hmask
| n TMPR1, STR:RC->hash | n TMPR1, STR:RC->hash