From 45214c885b16a1d14ad8c468158e41a7be4a8050 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Mon, 23 Jan 2012 18:30:21 +1000 Subject: Fix variable reference being replaced by it's definition. --- LuaSL/src/LuaSL_compile.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'LuaSL/src/LuaSL_compile.c') diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c index 42b0798..f84b1e1 100644 --- a/LuaSL/src/LuaSL_compile.c +++ b/LuaSL/src/LuaSL_compile.c @@ -295,14 +295,23 @@ static LSL_Leaf *findVariable(LuaSL_compiler *compiler, const char *name) LSL_Leaf *checkVariable(LuaSL_compiler *compiler, LSL_Leaf *identifier) { gameGlobals *game = compiler->game; - LSL_Leaf *var = findVariable(compiler, identifier->value.stringValue); - if (NULL == var) - PE("NOT found %s @ line %d, column %d!", identifier->value.stringValue, identifier->line, identifier->column); - else if (LUASL_DEBUG) - PI("Found %s!", identifier->value.stringValue); + if (identifier) + { + LSL_Leaf *var = findVariable(compiler, identifier->value.stringValue); - return var; + if (var) + { + if (LUASL_DEBUG) + PI("Found %s!", identifier->value.stringValue); + identifier->value.identifierValue = var->value.identifierValue; + identifier->basicType = var->basicType; + } + else + PE("NOT found %s @ line %d, column %d!", identifier->value.stringValue, identifier->line, identifier->column); + } + + return identifier; } LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right) -- cgit v1.1