diff options
Diffstat (limited to 'LuaSL/src/LuaSL_compile.c')
-rw-r--r-- | LuaSL/src/LuaSL_compile.c | 61 |
1 files changed, 60 insertions, 1 deletions
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c index 0183599..c61f900 100644 --- a/LuaSL/src/LuaSL_compile.c +++ b/LuaSL/src/LuaSL_compile.c | |||
@@ -742,6 +742,23 @@ LSL_Leaf *addIfElse(LuaSL_compiler *compiler, LSL_Leaf *ifBlock, LSL_Leaf *elseB | |||
742 | return ifBlock; | 742 | return ifBlock; |
743 | } | 743 | } |
744 | 744 | ||
745 | LSL_Leaf *addFor(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Leaf *flow, LSL_Leaf *left, LSL_Leaf *expr0, LSL_Leaf *stat0, LSL_Leaf *expr1, LSL_Leaf *stat1, LSL_Leaf *expr2, LSL_Leaf *right, LSL_Leaf *block) | ||
746 | { | ||
747 | LSL_Leaf **exprs = calloc(5, sizeof(LSL_Leaf *)); | ||
748 | |||
749 | if (exprs) | ||
750 | { | ||
751 | lval = addStatement(compiler, lval, flow, left, expr0, right, block, NULL); | ||
752 | exprs[0] = expr0; | ||
753 | exprs[1] = stat0; | ||
754 | exprs[2] = expr1; | ||
755 | exprs[3] = stat1; | ||
756 | exprs[4] = expr2; | ||
757 | lval->value.statementValue->expressions = (LSL_Leaf *) exprs; | ||
758 | } | ||
759 | return lval; | ||
760 | } | ||
761 | |||
745 | LSL_Leaf *addStatement(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Leaf *flow, LSL_Leaf *left, LSL_Leaf *expr, LSL_Leaf *right, LSL_Leaf *block, LSL_Leaf *identifier) | 762 | LSL_Leaf *addStatement(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Leaf *flow, LSL_Leaf *left, LSL_Leaf *expr, LSL_Leaf *right, LSL_Leaf *block, LSL_Leaf *identifier) |
746 | { | 763 | { |
747 | gameGlobals *game = compiler->game; | 764 | gameGlobals *game = compiler->game; |
@@ -784,6 +801,7 @@ LSL_Leaf *addStatement(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Leaf *flow, | |||
784 | } | 801 | } |
785 | case LSL_FOR : | 802 | case LSL_FOR : |
786 | { | 803 | { |
804 | justOne = TRUE; | ||
787 | break; | 805 | break; |
788 | } | 806 | } |
789 | case LSL_IF : | 807 | case LSL_IF : |
@@ -861,6 +879,21 @@ LSL_Leaf *addStatement(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Leaf *flow, | |||
861 | #endif | 879 | #endif |
862 | lval->value.statementValue = stat; | 880 | lval->value.statementValue = stat; |
863 | } | 881 | } |
882 | |||
883 | #if LUASL_DIFF_CHECK | ||
884 | if (left) | ||
885 | { | ||
886 | if (NULL == stat->ignorable) | ||
887 | stat->ignorable = calloc(3, sizeof(Eina_Strbuf *)); | ||
888 | else | ||
889 | stat->ignorable = realloc(stat->ignorable, 3 * sizeof(Eina_Strbuf *)); | ||
890 | if (stat->ignorable) | ||
891 | { | ||
892 | stat->ignorable[2] = left->ignorable; | ||
893 | left->ignorable = NULL; | ||
894 | } | ||
895 | } | ||
896 | #endif | ||
864 | } | 897 | } |
865 | 898 | ||
866 | return lval; | 899 | return lval; |
@@ -1427,6 +1460,10 @@ static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *state | |||
1427 | case LSL_FOR : | 1460 | case LSL_FOR : |
1428 | { | 1461 | { |
1429 | isBlock = TRUE; | 1462 | isBlock = TRUE; |
1463 | #if LUASL_DIFF_CHECK | ||
1464 | if ((statement->ignorable) && (statement->ignorable[1])) | ||
1465 | fwrite(eina_strbuf_string_get(statement->ignorable[1]), 1, eina_strbuf_length_get(statement->ignorable[1]), file); | ||
1466 | #endif | ||
1430 | fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen); | 1467 | fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen); |
1431 | break; | 1468 | break; |
1432 | } | 1469 | } |
@@ -1506,7 +1543,29 @@ static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *state | |||
1506 | } | 1543 | } |
1507 | } | 1544 | } |
1508 | 1545 | ||
1509 | if (statement->parenthesis) | 1546 | #if LUASL_DIFF_CHECK |
1547 | if ((statement->ignorable) && (statement->ignorable[2])) | ||
1548 | fwrite(eina_strbuf_string_get(statement->ignorable[2]), 1, eina_strbuf_length_get(statement->ignorable[2]), file); | ||
1549 | #endif | ||
1550 | if (LSL_FOR == statement->type) | ||
1551 | { | ||
1552 | LSL_Leaf **exprs = (LSL_Leaf **) statement->expressions; | ||
1553 | int i; | ||
1554 | |||
1555 | fprintf(file, "("); | ||
1556 | for (i = 0; i < 5; i++) | ||
1557 | { | ||
1558 | outputLeaf(file, mode, exprs[i]); | ||
1559 | if (i % 2) | ||
1560 | fprintf(file, ";"); | ||
1561 | } | ||
1562 | #if LUASL_DIFF_CHECK | ||
1563 | fprintf(file, "%s)", eina_strbuf_string_get(statement->parenthesis->rightIgnorable)); | ||
1564 | #else | ||
1565 | fprintf(file, ")"); | ||
1566 | #endif | ||
1567 | } | ||
1568 | else if (statement->parenthesis) | ||
1510 | outputRawParenthesisToken(file, mode, statement->parenthesis, ""); | 1569 | outputRawParenthesisToken(file, mode, statement->parenthesis, ""); |
1511 | else | 1570 | else |
1512 | outputLeaf(file, mode, statement->expressions); | 1571 | outputLeaf(file, mode, statement->expressions); |