diff options
author | David Walter Seikel | 2012-01-17 15:46:13 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-17 15:46:13 +1000 |
commit | eecc05cbd3def5e01d6165ee983d26285608e95b (patch) | |
tree | e0cafd69439d9a7515f2f6d932006cae10aace9e | |
parent | Use eina hash for functions, states, and variables. (diff) | |
download | SledjHamr-eecc05cbd3def5e01d6165ee983d26285608e95b.zip SledjHamr-eecc05cbd3def5e01d6165ee983d26285608e95b.tar.gz SledjHamr-eecc05cbd3def5e01d6165ee983d26285608e95b.tar.bz2 SledjHamr-eecc05cbd3def5e01d6165ee983d26285608e95b.tar.xz |
Add a variable lookup function.
-rw-r--r-- | LuaSL/src/LuaSL_compile.c | 21 |
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 | |||
213 | static 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 | |||
212 | LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right) | 233 | LSL_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; |