From cde179b36979c58d9380d3c4dd29b61412d13b51 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 4 Nov 1999 15:23:12 -0200 Subject: new implementation for global variable values (separated from strings) --- lparser.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'lparser.c') diff --git a/lparser.c b/lparser.c index 06f21e81..740ab03a 100644 --- a/lparser.c +++ b/lparser.c @@ -1,5 +1,5 @@ /* -** $Id: lparser.c,v 1.40 1999/09/02 13:13:22 roberto Exp roberto $ +** $Id: lparser.c,v 1.41 1999/09/20 14:15:18 roberto Exp roberto $ ** LL(1) Parser and code generator for Lua ** See Copyright Notice in lua.h */ @@ -232,6 +232,13 @@ static void code_constant (LexState *ls, int c) { } +static void assertglobal (LexState *ls, int index) { + TObject *o = &ls->fs->f->consts[index]; + LUA_ASSERT(ttype(o) == LUA_T_STRING, "global name is not a string"); + luaS_assertglobal(tsvalue(o)); +} + + static int next_constant (FuncState *fs) { TProtoFunc *f = fs->f; luaM_growvector(f->consts, f->nconsts, 1, TObject, constantEM, MAX_ARG); @@ -478,6 +485,7 @@ static void lua_pushvar (LexState *ls, vardesc *var) { break; case VGLOBAL: code_oparg(ls, GETGLOBAL, var->info, 1); + assertglobal(ls, var->info); /* make sure that there is a global */ break; case VDOT: code_oparg(ls, GETDOTTED, var->info, 0); @@ -501,6 +509,7 @@ static void storevar (LexState *ls, const vardesc *var) { break; case VGLOBAL: code_oparg(ls, SETGLOBAL, var->info, -1); + assertglobal(ls, var->info); /* make sure that there is a global */ break; case VINDEXED: code_opcode(ls, SETTABLEPOP, -3); -- cgit v1.2.3-55-g6feb