aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-01-17 15:46:13 +1000
committerDavid Walter Seikel2012-01-17 15:46:13 +1000
commiteecc05cbd3def5e01d6165ee983d26285608e95b (patch)
treee0cafd69439d9a7515f2f6d932006cae10aace9e /LuaSL
parentUse eina hash for functions, states, and variables. (diff)
downloadSledjHamr-eecc05cbd3def5e01d6165ee983d26285608e95b.zip
SledjHamr-eecc05cbd3def5e01d6165ee983d26285608e95b.tar.gz
SledjHamr-eecc05cbd3def5e01d6165ee983d26285608e95b.tar.bz2
SledjHamr-eecc05cbd3def5e01d6165ee983d26285608e95b.tar.xz
Add a variable lookup function.
Diffstat (limited to 'LuaSL')
-rw-r--r--LuaSL/src/LuaSL_compile.c21
1 files changed, 21 insertions, 0 deletions
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)
209 } 209 }
210} 210}
211 211
212
213static LSL_Leaf *findVariable(LuaSL_compiler *compiler, const char *name)
214{
215 LSL_Block *block = compiler->currentBlock;
216 LSL_Leaf *var = NULL;
217
218 if (name)
219 {
220 while ((block) && (NULL == var))
221 {
222 if (block->variables)
223 var = eina_hash_find(block->variables, name);
224 block = block->outerBlock;
225 }
226 if (NULL == var)
227 var = eina_hash_find(compiler->script.variables, name);
228 }
229
230 return var;
231}
232
212LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right) 233LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right)
213{ 234{
214 gameGlobals *game = compiler->game; 235 gameGlobals *game = compiler->game;