From eecc05cbd3def5e01d6165ee983d26285608e95b Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Tue, 17 Jan 2012 15:46:13 +1000 Subject: Add a variable lookup function. --- LuaSL/src/LuaSL_compile.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'LuaSL') diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c index 445014e..9abe55d 100644 --- a/LuaSL/src/LuaSL_compile.c +++ b/LuaSL/src/LuaSL_compile.c @@ -209,6 +209,27 @@ void burnLeaf(void *data) } } + +static LSL_Leaf *findVariable(LuaSL_compiler *compiler, const char *name) +{ + LSL_Block *block = compiler->currentBlock; + LSL_Leaf *var = NULL; + + if (name) + { + while ((block) && (NULL == var)) + { + if (block->variables) + var = eina_hash_find(block->variables, name); + block = block->outerBlock; + } + if (NULL == var) + var = eina_hash_find(compiler->script.variables, name); + } + + return var; +} + LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right) { gameGlobals *game = compiler->game; -- cgit v1.1