diff options
Diffstat (limited to '')
-rw-r--r-- | LuaSL/src/LuaSL_compile.c | 57 |
1 files changed, 52 insertions, 5 deletions
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 | ||
581 | LSL_Leaf *addFunctionBody(LuaSL_compiler *compiler, LSL_Leaf *function, LSL_Leaf *block) | 581 | LSL_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 | ||
594 | LSL_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 | |||
594 | LSL_Leaf *addFunctionCall(LuaSL_compiler *compiler, LSL_Leaf *identifier, LSL_Leaf *open, LSL_Leaf *params, LSL_Leaf *close) | 632 | LSL_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 | } |