diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-11-04 15:23:12 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-11-04 15:23:12 -0200 |
commit | cde179b36979c58d9380d3c4dd29b61412d13b51 (patch) | |
tree | 804c457691024d797a7479eddf711e103966b513 /lparser.c | |
parent | 80b39d83c3512e1dd627842e64c69841638d9088 (diff) | |
download | lua-cde179b36979c58d9380d3c4dd29b61412d13b51.tar.gz lua-cde179b36979c58d9380d3c4dd29b61412d13b51.tar.bz2 lua-cde179b36979c58d9380d3c4dd29b61412d13b51.zip |
new implementation for global variable values (separated from strings)
Diffstat (limited to 'lparser.c')
-rw-r--r-- | lparser.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.c,v 1.40 1999/09/02 13:13:22 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 1.41 1999/09/20 14:15:18 roberto Exp roberto $ |
3 | ** LL(1) Parser and code generator for Lua | 3 | ** LL(1) Parser and code generator for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -232,6 +232,13 @@ static void code_constant (LexState *ls, int c) { | |||
232 | } | 232 | } |
233 | 233 | ||
234 | 234 | ||
235 | static void assertglobal (LexState *ls, int index) { | ||
236 | TObject *o = &ls->fs->f->consts[index]; | ||
237 | LUA_ASSERT(ttype(o) == LUA_T_STRING, "global name is not a string"); | ||
238 | luaS_assertglobal(tsvalue(o)); | ||
239 | } | ||
240 | |||
241 | |||
235 | static int next_constant (FuncState *fs) { | 242 | static int next_constant (FuncState *fs) { |
236 | TProtoFunc *f = fs->f; | 243 | TProtoFunc *f = fs->f; |
237 | luaM_growvector(f->consts, f->nconsts, 1, TObject, constantEM, MAX_ARG); | 244 | luaM_growvector(f->consts, f->nconsts, 1, TObject, constantEM, MAX_ARG); |
@@ -478,6 +485,7 @@ static void lua_pushvar (LexState *ls, vardesc *var) { | |||
478 | break; | 485 | break; |
479 | case VGLOBAL: | 486 | case VGLOBAL: |
480 | code_oparg(ls, GETGLOBAL, var->info, 1); | 487 | code_oparg(ls, GETGLOBAL, var->info, 1); |
488 | assertglobal(ls, var->info); /* make sure that there is a global */ | ||
481 | break; | 489 | break; |
482 | case VDOT: | 490 | case VDOT: |
483 | code_oparg(ls, GETDOTTED, var->info, 0); | 491 | code_oparg(ls, GETDOTTED, var->info, 0); |
@@ -501,6 +509,7 @@ static void storevar (LexState *ls, const vardesc *var) { | |||
501 | break; | 509 | break; |
502 | case VGLOBAL: | 510 | case VGLOBAL: |
503 | code_oparg(ls, SETGLOBAL, var->info, -1); | 511 | code_oparg(ls, SETGLOBAL, var->info, -1); |
512 | assertglobal(ls, var->info); /* make sure that there is a global */ | ||
504 | break; | 513 | break; |
505 | case VINDEXED: | 514 | case VINDEXED: |
506 | code_opcode(ls, SETTABLEPOP, -3); | 515 | code_opcode(ls, SETTABLEPOP, -3); |