Fixed bug in scoping accessing all stack frames, not just local and

global


git-svn-id: http://picoc.googlecode.com/svn/trunk@23 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
zik.saleeba 2008-12-27 02:28:29 +00:00
parent 704f20e1c4
commit 224a90dca3

11
parse.c
View file

@ -43,15 +43,10 @@ void VariableDefine(struct LexState *Lexer, const Str *Ident, struct Value *Init
/* get the value of a variable. must be defined */
void VariableGet(struct LexState *Lexer, Str *Ident, struct Value *Val, struct Value **LVal)
{
int Frame;
for (Frame = StackUsed-1; Frame >= 0; Frame--)
if (TableGet(&Stack[StackUsed-1].LocalTable, Ident, LVal))
{
if (TableGet(&Stack[Frame].LocalTable, Ident, LVal))
{
*Val = **LVal;
return;
}
*Val = **LVal;
return;
}
if (!TableGet(&GlobalTable, Ident, LVal))