aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--LuaSL/src/LuaSL_compile.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c
index a410152..5a3a68b 100644
--- a/LuaSL/src/LuaSL_compile.c
+++ b/LuaSL/src/LuaSL_compile.c
@@ -338,6 +338,7 @@ LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval,
338 lType = left->basicType; 338 lType = left->basicType;
339 if (OT_undeclared == lType) 339 if (OT_undeclared == lType)
340 { 340 {
341 PW("Undeclared identifier issue, deferring this until the second pass. @ line %d, column %d.", lval->line, lval->column);
341 lval->basicType = OT_undeclared; 342 lval->basicType = OT_undeclared;
342 return lval; 343 return lval;
343 } 344 }
@@ -359,6 +360,7 @@ LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval,
359 rType = right->basicType; 360 rType = right->basicType;
360 if (OT_undeclared == rType) 361 if (OT_undeclared == rType)
361 { 362 {
363 PW("Undeclared identifier issue, deferring this until the second pass. @ line %d, column %d.", lval->line, lval->column);
362 lval->basicType = OT_undeclared; 364 lval->basicType = OT_undeclared;
363 return lval; 365 return lval;
364 } 366 }
@@ -707,6 +709,17 @@ void endBlock(LuaSL_compiler *compiler, LSL_Leaf *block)
707 compiler->currentBlock = compiler->currentBlock->outerBlock; 709 compiler->currentBlock = compiler->currentBlock->outerBlock;
708} 710}
709 711
712static void secondPass(LuaSL_compiler *compiler, LSL_Leaf *leaf)
713{
714 if (leaf)
715 {
716 secondPass(compiler, leaf->left);
717 if (OT_undeclared == leaf->basicType)
718 leaf = addOperation(compiler, leaf->left, leaf, leaf->right);
719 secondPass(compiler, leaf->right);
720 }
721}
722
710static LSL_Leaf *evaluateLeaf(LSL_Leaf *leaf, LSL_Leaf *left, LSL_Leaf *right) 723static LSL_Leaf *evaluateLeaf(LSL_Leaf *leaf, LSL_Leaf *left, LSL_Leaf *right)
711{ 724{
712 LSL_Leaf *result = NULL; 725 LSL_Leaf *result = NULL;
@@ -1291,7 +1304,7 @@ Eina_Bool compileLSL(gameGlobals *game, char *script, boolean doConstants)
1291 1304
1292 if (compiler.undeclared) 1305 if (compiler.undeclared)
1293 { 1306 {
1294 PI("A second pass will be needed to check if functions where declared after they where used. To avoid this second pass, don't do that."); 1307 PW("A second pass is needed to check if functions where used before they where declared. To avoid this second pass, don't do that.");
1295 if (eina_clist_count(&(compiler.danglingCalls))) 1308 if (eina_clist_count(&(compiler.danglingCalls)))
1296 { 1309 {
1297 LSL_FunctionCall *call = NULL; 1310 LSL_FunctionCall *call = NULL;
@@ -1311,7 +1324,7 @@ Eina_Bool compileLSL(gameGlobals *game, char *script, boolean doConstants)
1311 PE("Undeclared function %s called @ line %d, column %d!", call->call->value.stringValue, call->call->line, call->call->column); 1324 PE("Undeclared function %s called @ line %d, column %d!", call->call->value.stringValue, call->call->line, call->call->column);
1312 } 1325 }
1313 } 1326 }
1314// TODO - Run through the expressions, cleaning up the function calls. 1327 secondPass(&compiler, compiler.ast);
1315 PI("Second pass completed."); 1328 PI("Second pass completed.");
1316 } 1329 }
1317 1330