aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-01-17 16:38:32 +1000
committerDavid Walter Seikel2012-01-17 16:38:32 +1000
commitfa5db92c5ee7be17a1dbfc04c4a978c2725138ff (patch)
tree08e9ca2dd888ca2ba4ac1979a3ab8bfef351cbb7
parentDisable leaf burning for now, it's crashing. (diff)
downloadSledjHamr-fa5db92c5ee7be17a1dbfc04c4a978c2725138ff.zip
SledjHamr-fa5db92c5ee7be17a1dbfc04c4a978c2725138ff.tar.gz
SledjHamr-fa5db92c5ee7be17a1dbfc04c4a978c2725138ff.tar.bz2
SledjHamr-fa5db92c5ee7be17a1dbfc04c4a978c2725138ff.tar.xz
Check variables, though not looking up function parameters yet.
-rw-r--r--LuaSL/src/LuaSL_LSL_tree.h1
-rw-r--r--LuaSL/src/LuaSL_compile.c11
-rw-r--r--LuaSL/src/LuaSL_lemon_yaccer.y2
3 files changed, 13 insertions, 1 deletions
diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h
index dee6263..2c2bfa6 100644
--- a/LuaSL/src/LuaSL_LSL_tree.h
+++ b/LuaSL/src/LuaSL_LSL_tree.h
@@ -286,6 +286,7 @@ LSL_Leaf *addTypecast(LSL_Leaf *lval, LSL_Leaf *type, LSL_Leaf *rval, LSL_Leaf *
286LSL_Leaf *addVariable(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *identifier, LSL_Leaf *assignment, LSL_Leaf *expr); 286LSL_Leaf *addVariable(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *identifier, LSL_Leaf *assignment, LSL_Leaf *expr);
287 287
288void beginBlock(LuaSL_compiler *compiler, LSL_Leaf *block); 288void beginBlock(LuaSL_compiler *compiler, LSL_Leaf *block);
289LSL_Leaf *checkVariable(LuaSL_compiler *compiler, LSL_Leaf *identifier);
289LSL_Leaf *collectParameters(LSL_Leaf *list, LSL_Leaf *comma, LSL_Leaf *newParam); 290LSL_Leaf *collectParameters(LSL_Leaf *list, LSL_Leaf *comma, LSL_Leaf *newParam);
290void endBlock(LuaSL_compiler *compiler, LSL_Leaf *block); 291void endBlock(LuaSL_compiler *compiler, LSL_Leaf *block);
291 292
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c
index 65a8089..6d82fb6 100644
--- a/LuaSL/src/LuaSL_compile.c
+++ b/LuaSL/src/LuaSL_compile.c
@@ -230,6 +230,17 @@ static LSL_Leaf *findVariable(LuaSL_compiler *compiler, const char *name)
230 return var; 230 return var;
231} 231}
232 232
233LSL_Leaf *checkVariable(LuaSL_compiler *compiler, LSL_Leaf *identifier)
234{
235 gameGlobals *game = compiler->game;
236 LSL_Leaf *var = findVariable(compiler, identifier->value.stringValue);
237
238 if (NULL == var)
239 PE("NOT Found %s!", identifier->value.stringValue);
240
241 return var;
242}
243
233LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right) 244LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right)
234{ 245{
235 gameGlobals *game = compiler->game; 246 gameGlobals *game = compiler->game;
diff --git a/LuaSL/src/LuaSL_lemon_yaccer.y b/LuaSL/src/LuaSL_lemon_yaccer.y
index 560c6ab..d5a6751 100644
--- a/LuaSL/src/LuaSL_lemon_yaccer.y
+++ b/LuaSL/src/LuaSL_lemon_yaccer.y
@@ -167,7 +167,7 @@ statement(A) ::= type(B) LSL_IDENTIFIER(C) LSL_STATEMENT(F). { A = addStatem
167 167
168%right LSL_DOT LSL_IDENTIFIER. 168%right LSL_DOT LSL_IDENTIFIER.
169identifier ::= identifier LSL_DOT LSL_IDENTIFIER. 169identifier ::= identifier LSL_DOT LSL_IDENTIFIER.
170identifier(A) ::= LSL_IDENTIFIER(B). { A = B; } 170identifier(A) ::= LSL_IDENTIFIER(B). { A = checkVariable(compiler, B); }
171 171
172%right LSL_DECREMENT_PRE LSL_INCREMENT_PRE LSL_DECREMENT_POST LSL_INCREMENT_POST. 172%right LSL_DECREMENT_PRE LSL_INCREMENT_PRE LSL_DECREMENT_POST LSL_INCREMENT_POST.
173expr ::= identifier LSL_DECREMENT_PRE. 173expr ::= identifier LSL_DECREMENT_PRE.