diff options
Diffstat (limited to '')
-rw-r--r-- | LuaSL/src/LuaSL_LSL_tree.h | 12 | ||||
-rw-r--r-- | LuaSL/src/LuaSL_compile.c | 47 |
2 files changed, 37 insertions, 22 deletions
diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h index 4858d99..2a66bd7 100644 --- a/LuaSL/src/LuaSL_LSL_tree.h +++ b/LuaSL/src/LuaSL_LSL_tree.h | |||
@@ -236,11 +236,12 @@ struct _LSL_Parenthesis | |||
236 | 236 | ||
237 | struct _LSL_Identifier // For variables and function parameters. | 237 | struct _LSL_Identifier // For variables and function parameters. |
238 | { | 238 | { |
239 | LSL_Text name; | 239 | LSL_Text name; |
240 | Eina_Strbuf *ignorable; | 240 | LSL_Statement *definition; |
241 | const char *sub; | 241 | Eina_Strbuf *ignorable; |
242 | LSL_Leaf value; | 242 | const char *sub; |
243 | miscFlags flags; | 243 | LSL_Leaf value; |
244 | miscFlags flags; | ||
244 | }; | 245 | }; |
245 | 246 | ||
246 | struct _LSL_Statement | 247 | struct _LSL_Statement |
@@ -256,6 +257,7 @@ struct _LSL_Statement | |||
256 | #if LUASL_DIFF_CHECK | 257 | #if LUASL_DIFF_CHECK |
257 | Eina_Strbuf **ignorable; // Can be up to five of these I think. | 258 | Eina_Strbuf **ignorable; // Can be up to five of these I think. |
258 | #endif | 259 | #endif |
260 | miscFlags flags; | ||
259 | /* | 261 | /* |
260 | LSL_Leaf *addStatement(LSL_Leaf *lval, LSL_Type type, LSL_Leaf *left, LSL_Leaf *expr, LSL_Leaf *right, LSL_Leaf *block); | 262 | LSL_Leaf *addStatement(LSL_Leaf *lval, LSL_Type type, LSL_Leaf *left, LSL_Leaf *expr, LSL_Leaf *right, LSL_Leaf *block); |
261 | 263 | ||
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c index c251eee..a72cab3 100644 --- a/LuaSL/src/LuaSL_compile.c +++ b/LuaSL/src/LuaSL_compile.c | |||
@@ -532,6 +532,7 @@ LSL_Leaf *addCrement(LuaSL_compiler *compiler, LSL_Leaf *variable, LSL_Leaf *cre | |||
532 | case LSL_DECREMENT_POST : variable->value.identifierValue->flags |= MF_POSTDEC; break; | 532 | case LSL_DECREMENT_POST : variable->value.identifierValue->flags |= MF_POSTDEC; break; |
533 | case LSL_INCREMENT_POST : variable->value.identifierValue->flags |= MF_POSTINC; break; | 533 | case LSL_INCREMENT_POST : variable->value.identifierValue->flags |= MF_POSTINC; break; |
534 | } | 534 | } |
535 | variable->value.identifierValue->definition->flags = variable->value.identifierValue->flags; | ||
535 | } | 536 | } |
536 | 537 | ||
537 | return crement; | 538 | return crement; |
@@ -986,6 +987,12 @@ LSL_Leaf *addStatement(LuaSL_compiler *compiler, LSL_Leaf *lval, LSL_Leaf *flow, | |||
986 | } | 987 | } |
987 | case LSL_VARIABLE : | 988 | case LSL_VARIABLE : |
988 | { | 989 | { |
990 | if (identifier) | ||
991 | { | ||
992 | stat->identifier.text = identifier->value.identifierValue->name.text; | ||
993 | identifier->value.identifierValue->definition = stat; | ||
994 | stat->flags = identifier->value.identifierValue->flags; | ||
995 | } | ||
989 | break; | 996 | break; |
990 | } | 997 | } |
991 | default : | 998 | default : |
@@ -1751,8 +1758,17 @@ static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *state | |||
1751 | case LSL_JUMP : | 1758 | case LSL_JUMP : |
1752 | { | 1759 | { |
1753 | #if LUASL_DIFF_CHECK | 1760 | #if LUASL_DIFF_CHECK |
1754 | if ((statement->ignorable) && (statement->ignorable[1])) | 1761 | if ((statement->ignorable) && (statement->ignorable[1])) |
1755 | fwrite(eina_strbuf_string_get(statement->ignorable[1]), 1, eina_strbuf_length_get(statement->ignorable[1]), file); | 1762 | fwrite(eina_strbuf_string_get(statement->ignorable[1]), 1, eina_strbuf_length_get(statement->ignorable[1]), file); |
1763 | #endif | ||
1764 | fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen); | ||
1765 | break; | ||
1766 | } | ||
1767 | case LSL_LABEL : | ||
1768 | { | ||
1769 | #if LUASL_DIFF_CHECK | ||
1770 | if ((statement->ignorable) && (statement->ignorable[1])) | ||
1771 | fwrite(eina_strbuf_string_get(statement->ignorable[1]), 1, eina_strbuf_length_get(statement->ignorable[1]), file); | ||
1756 | #endif | 1772 | #endif |
1757 | fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen); | 1773 | fprintf(file, "%s", tokens[statement->type - lowestToken]->toKen); |
1758 | break; | 1774 | break; |
@@ -1878,6 +1894,18 @@ static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *state | |||
1878 | fprintf(file, "\n"); | 1894 | fprintf(file, "\n"); |
1879 | } | 1895 | } |
1880 | 1896 | ||
1897 | if ((LSL_VARIABLE == statement->type) && (OM_LUA == mode) && (MF_LOCAL & statement->flags)) | ||
1898 | { | ||
1899 | const char *name = statement->identifier.text; | ||
1900 | |||
1901 | // if ((MF_PREDEC | MF_PREINC | MF_POSTDEC | MF_POSTINC) & statement->flags) | ||
1902 | // fprintf(file, "\n"); | ||
1903 | if (MF_PREDEC & statement->flags) fprintf(file, "local function preDecrement_%s() %s = %s - 1; return %s; end\n", name, name, name, name); | ||
1904 | if (MF_PREINC & statement->flags) fprintf(file, "local function preIncrement_%s() %s = %s + 1; return %s; end\n", name, name, name, name); | ||
1905 | if (MF_POSTDEC & statement->flags) fprintf(file, "local function postDecrement_%s() local temp = %s; %s = %s - 1; return temp; end\n", name, name, name, name); | ||
1906 | if (MF_POSTINC & statement->flags) fprintf(file, "local function postDecrement_%s() local temp = %s; %s = %s + 1; return temp; end\n", name, name, name, name); | ||
1907 | } | ||
1908 | |||
1881 | if (statement->elseBlock) | 1909 | if (statement->elseBlock) |
1882 | outputRawStatement(file, mode, statement->elseBlock); | 1910 | outputRawStatement(file, mode, statement->elseBlock); |
1883 | } | 1911 | } |
@@ -2090,21 +2118,6 @@ static void outputIdentifierToken(FILE *file, outputMode mode, LSL_Leaf *content | |||
2090 | } | 2118 | } |
2091 | else | 2119 | else |
2092 | outputText(file, &(content->value.identifierValue->name), !(LSL_NOIGNORE & content->toKen->flags)); | 2120 | outputText(file, &(content->value.identifierValue->name), !(LSL_NOIGNORE & content->toKen->flags)); |
2093 | |||
2094 | if (OM_LUA == mode) | ||
2095 | { | ||
2096 | if ((LSL_VARIABLE == content->toKen->type) && (MF_LOCAL & content->flags)) | ||
2097 | { | ||
2098 | const char *name = content->value.identifierValue->name.text; | ||
2099 | |||
2100 | if ((MF_PREDEC | MF_PREINC | MF_POSTDEC | MF_POSTINC) & content->value.identifierValue->flags) | ||
2101 | fprintf(file, "\n"); | ||
2102 | if (MF_PREDEC & content->value.identifierValue->flags) fprintf(file, "local function preDecrement_%s() %s = %s - 1; return %s; end\n", name, name, name, name); | ||
2103 | if (MF_PREINC & content->value.identifierValue->flags) fprintf(file, "local function preIncrement_%s() %s = %s + 1; return %s; end\n", name, name, name, name); | ||
2104 | if (MF_POSTDEC & content->value.identifierValue->flags) fprintf(file, "local function postDecrement_%s() local temp = %s; %s = %s - 1; return temp; end\n", name, name, name, name); | ||
2105 | if (MF_POSTDEC & content->value.identifierValue->flags) fprintf(file, "local function postDecrement_%s() local temp = %s; %s = %s + 1; return temp; end\n", name, name, name, name); | ||
2106 | } | ||
2107 | } | ||
2108 | } | 2121 | } |
2109 | } | 2122 | } |
2110 | 2123 | ||