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:
parent
704f20e1c4
commit
224a90dca3
7
parse.c
7
parse.c
|
@ -43,16 +43,11 @@ void VariableDefine(struct LexState *Lexer, const Str *Ident, struct Value *Init
|
||||||
/* get the value of a variable. must be defined */
|
/* get the value of a variable. must be defined */
|
||||||
void VariableGet(struct LexState *Lexer, Str *Ident, struct Value *Val, struct Value **LVal)
|
void VariableGet(struct LexState *Lexer, Str *Ident, struct Value *Val, struct Value **LVal)
|
||||||
{
|
{
|
||||||
int Frame;
|
if (TableGet(&Stack[StackUsed-1].LocalTable, Ident, LVal))
|
||||||
|
|
||||||
for (Frame = StackUsed-1; Frame >= 0; Frame--)
|
|
||||||
{
|
|
||||||
if (TableGet(&Stack[Frame].LocalTable, Ident, LVal))
|
|
||||||
{
|
{
|
||||||
*Val = **LVal;
|
*Val = **LVal;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!TableGet(&GlobalTable, Ident, LVal))
|
if (!TableGet(&GlobalTable, Ident, LVal))
|
||||||
ProgramFail(Lexer, "'%S' is undefined", Ident);
|
ProgramFail(Lexer, "'%S' is undefined", Ident);
|
||||||
|
|
Loading…
Reference in a new issue