diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-08-27 18:01:44 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-08-27 18:01:44 -0300 |
| commit | 8332d5c8a5059b85da1adaa3f0197d0f57afae81 (patch) | |
| tree | 8a2f59ff0803da3afbc7e8a409911c920d624e94 /lcode.c | |
| parent | 885961be1d8e3f703b54d1d19e6c63617cd2ed24 (diff) | |
| download | lua-8332d5c8a5059b85da1adaa3f0197d0f57afae81.tar.gz lua-8332d5c8a5059b85da1adaa3f0197d0f57afae81.tar.bz2 lua-8332d5c8a5059b85da1adaa3f0197d0f57afae81.zip | |
parser fully reentrant(!)
Diffstat (limited to 'lcode.c')
| -rw-r--r-- | lcode.c | 12 |
1 files changed, 7 insertions, 5 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lcode.c,v 1.117 2003/04/03 13:35:34 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 1.119 2003/08/27 20:58:52 roberto Exp $ |
| 3 | ** Code generator for Lua | 3 | ** Code generator for Lua |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -207,17 +207,19 @@ static void freeexp (FuncState *fs, expdesc *e) { | |||
| 207 | 207 | ||
| 208 | 208 | ||
| 209 | static int addk (FuncState *fs, TObject *k, TObject *v) { | 209 | static int addk (FuncState *fs, TObject *k, TObject *v) { |
| 210 | const TObject *idx = luaH_get(fs->h, k); | 210 | TObject *idx = luaH_set(fs->L, fs->h, k); |
| 211 | Proto *f = fs->f; | ||
| 212 | int oldsize = f->sizek; | ||
| 211 | if (ttisnumber(idx)) { | 213 | if (ttisnumber(idx)) { |
| 212 | lua_assert(luaO_rawequalObj(&fs->f->k[cast(int, nvalue(idx))], v)); | 214 | lua_assert(luaO_rawequalObj(&fs->f->k[cast(int, nvalue(idx))], v)); |
| 213 | return cast(int, nvalue(idx)); | 215 | return cast(int, nvalue(idx)); |
| 214 | } | 216 | } |
| 215 | else { /* constant not found; create a new entry */ | 217 | else { /* constant not found; create a new entry */ |
| 216 | Proto *f = fs->f; | 218 | setnvalue(idx, cast(lua_Number, fs->nk)); |
| 217 | luaM_growvector(fs->L, f->k, fs->nk, f->sizek, TObject, | 219 | luaM_growvector(fs->L, f->k, fs->nk, f->sizek, TObject, |
| 218 | MAXARG_Bx, "constant table overflow"); | 220 | MAXARG_Bx, "constant table overflow"); |
| 219 | setobj2n(&f->k[fs->nk], v); | 221 | while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]); |
| 220 | setnvalue(luaH_set(fs->L, fs->h, k), cast(lua_Number, fs->nk)); | 222 | setobj(&f->k[fs->nk], v); /* write barrier */ |
| 221 | return fs->nk++; | 223 | return fs->nk++; |
| 222 | } | 224 | } |
| 223 | } | 225 | } |
