aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--LuaSL/src/LuaSL_LSL_tree.h1
-rw-r--r--LuaSL/src/LuaSL_compile.c57
-rw-r--r--LuaSL/src/LuaSL_lemon_yaccer.y6
3 files changed, 56 insertions, 8 deletions
diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h
index d62c0b6..d877f22 100644
--- a/LuaSL/src/LuaSL_LSL_tree.h
+++ b/LuaSL/src/LuaSL_LSL_tree.h
@@ -405,6 +405,7 @@ LSL_Leaf *addVariable(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *identi
405 405
406LSL_Leaf *beginBlock(LuaSL_compiler *compiler, LSL_Leaf *block); 406LSL_Leaf *beginBlock(LuaSL_compiler *compiler, LSL_Leaf *block);
407LSL_Leaf *checkVariable(LuaSL_compiler *compiler, LSL_Leaf *identifier); 407LSL_Leaf *checkVariable(LuaSL_compiler *compiler, LSL_Leaf *identifier);
408LSL_Leaf *collectArguments(LuaSL_compiler *compiler, LSL_Leaf *list, LSL_Leaf *comma, LSL_Leaf *arg);
408LSL_Leaf *collectParameters(LuaSL_compiler *compiler, LSL_Leaf *list, LSL_Leaf *comma, LSL_Leaf *newParam); 409LSL_Leaf *collectParameters(LuaSL_compiler *compiler, LSL_Leaf *list, LSL_Leaf *comma, LSL_Leaf *newParam);
409LSL_Leaf *collectStatements(LuaSL_compiler *compiler, LSL_Leaf *list, LSL_Leaf *newStatement); 410LSL_Leaf *collectStatements(LuaSL_compiler *compiler, LSL_Leaf *list, LSL_Leaf *newStatement);
410 411
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c
index f8310a6..d9ac1c3 100644
--- a/LuaSL/src/LuaSL_compile.c
+++ b/LuaSL/src/LuaSL_compile.c
@@ -580,7 +580,7 @@ LSL_Leaf *addFunction(LuaSL_compiler *compiler, LSL_Leaf *type, LSL_Leaf *identi
580 580
581LSL_Leaf *addFunctionBody(LuaSL_compiler *compiler, LSL_Leaf *function, LSL_Leaf *block) 581LSL_Leaf *addFunctionBody(LuaSL_compiler *compiler, LSL_Leaf *function, LSL_Leaf *block)
582{ 582{
583 LSL_Leaf *statement = NULL; 583 LSL_Leaf *statement = NULL;
584 584
585 if (function) 585 if (function)
586 { 586 {
@@ -591,10 +591,55 @@ LSL_Leaf *addFunctionBody(LuaSL_compiler *compiler, LSL_Leaf *function, LSL_Leaf
591 return statement; 591 return statement;
592} 592}
593 593
594LSL_Leaf *collectArguments(LuaSL_compiler *compiler, LSL_Leaf *list, LSL_Leaf *comma, LSL_Leaf *arg)
595{
596 LSL_FunctionCall *call = NULL;
597
598 if (NULL == list)
599 list = newLeaf(LSL_FUNCTION_CALL, NULL, NULL);
600
601 if (list)
602 {
603 call = list->value.functionCallValue;
604 if (NULL == call)
605 {
606 call = calloc(1, sizeof(LSL_FunctionCall));
607 if (call)
608 {
609 list->value.functionCallValue = call;
610 eina_inarray_setup(&(call->params), sizeof(LSL_Leaf), 3);
611 }
612 }
613
614 if (call)
615 {
616 if (arg)
617 {
618 if (LUASL_DIFF_CHECK)
619 {
620 // Stash the comma for diff later.
621 if (comma)
622 eina_inarray_append(&(call->params), comma);
623 }
624 eina_inarray_append(&(call->params), arg);
625 // At this point, pointers to arg are not pointing to the one in call->params, AND arg is no longer needed.
626 }
627 }
628 }
629 return list;
630}
631
594LSL_Leaf *addFunctionCall(LuaSL_compiler *compiler, LSL_Leaf *identifier, LSL_Leaf *open, LSL_Leaf *params, LSL_Leaf *close) 632LSL_Leaf *addFunctionCall(LuaSL_compiler *compiler, LSL_Leaf *identifier, LSL_Leaf *open, LSL_Leaf *params, LSL_Leaf *close)
595{ 633{
596 LSL_Leaf *func = findFunction(compiler, identifier->value.stringValue); 634 LSL_Leaf *func = findFunction(compiler, identifier->value.stringValue);
597 LSL_FunctionCall *call = calloc(1, sizeof(LSL_FunctionCall)); 635 LSL_FunctionCall *call = NULL;
636
637 if (params)
638 {
639 call = params->value.functionCallValue;
640 }
641 else
642 call = calloc(1, sizeof(LSL_FunctionCall));
598 643
599 if (func) 644 if (func)
600 { 645 {
@@ -604,8 +649,6 @@ LSL_Leaf *addFunctionCall(LuaSL_compiler *compiler, LSL_Leaf *identifier, LSL_Le
604 eina_clist_element_init(&(call->dangler)); 649 eina_clist_element_init(&(call->dangler));
605 } 650 }
606 identifier->value.functionCallValue = call; 651 identifier->value.functionCallValue = call;
607 // TODO - Put the params in call.
608// eina_inarray_setup(&(cal->vars), sizeof(LSL_Text), 3);
609 identifier->toKen = tokens[LSL_FUNCTION_CALL - lowestToken]; 652 identifier->toKen = tokens[LSL_FUNCTION_CALL - lowestToken];
610 identifier->basicType = func->basicType; 653 identifier->basicType = func->basicType;
611 } 654 }
@@ -1507,11 +1550,15 @@ static void outputFunctionCallToken(FILE *file, outputMode mode, LSL_Leaf *conte
1507 if (content) 1550 if (content)
1508 { 1551 {
1509 LSL_FunctionCall *call = content->value.functionCallValue; 1552 LSL_FunctionCall *call = content->value.functionCallValue;
1553 LSL_Leaf *param = NULL;
1510 1554
1511 // TODO - should output it's own ignorable here. 1555 // TODO - should output it's own ignorable here.
1512 outputText(file, &(call->function->name), FALSE); // Don't output the function definitions ignorable. 1556 outputText(file, &(call->function->name), FALSE); // Don't output the function definitions ignorable.
1513 fprintf(file, "("); 1557 fprintf(file, "(");
1514 // TODO - print params here. 1558 EINA_INARRAY_FOREACH((&(call->params)), param)
1559 {
1560 outputLeaf(file, mode, param);
1561 }
1515 fprintf(file, ")"); 1562 fprintf(file, ")");
1516 } 1563 }
1517} 1564}
diff --git a/LuaSL/src/LuaSL_lemon_yaccer.y b/LuaSL/src/LuaSL_lemon_yaccer.y
index bbc4939..0aa6c5b 100644
--- a/LuaSL/src/LuaSL_lemon_yaccer.y
+++ b/LuaSL/src/LuaSL_lemon_yaccer.y
@@ -96,9 +96,9 @@ statement(A) ::= expr(E) LSL_STATEMENT(S). { A = addStatement(compi
96// Various forms of expression. 96// Various forms of expression.
97 97
98// Used for function call params, and list contents. 98// Used for function call params, and list contents.
99exprList ::= exprList LSL_COMMA expr. 99exprList(A) ::= exprList(B) LSL_COMMA(C) expr(D). { A = collectArguments(compiler, B, C, D); }
100exprList ::= expr. 100exprList(A) ::= expr(D). { A = collectArguments(compiler, NULL, NULL, D); }
101exprList ::= . 101exprList(A) ::= . { A = collectArguments(compiler, NULL, NULL, NULL); }
102 102
103%right LSL_BOOL_AND. 103%right LSL_BOOL_AND.
104expr(A) ::= expr(B) LSL_BOOL_AND(C) expr(D). { A = addOperation(compiler, B, C, D); } 104expr(A) ::= expr(B) LSL_BOOL_AND(C) expr(D). { A = addOperation(compiler, B, C, D); }