diff options
Diffstat (limited to 'LuaSL/src')
-rw-r--r-- | LuaSL/src/LuaSL_compile.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c index 7fa7cd7..d73b145 100644 --- a/LuaSL/src/LuaSL_compile.c +++ b/LuaSL/src/LuaSL_compile.c | |||
@@ -303,13 +303,15 @@ static LSL_Leaf *findVariable(LuaSL_compiler *compiler, const char *name) | |||
303 | } | 303 | } |
304 | 304 | ||
305 | if (NULL == var) | 305 | if (NULL == var) |
306 | var = eina_hash_find(constants.variables, name); | ||
307 | if (NULL != var) | ||
308 | { | 306 | { |
309 | var->flags |= MF_LSLCONST; | 307 | var = eina_hash_find(constants.variables, name); |
310 | var->value.identifierValue->flags |= MF_LSLCONST; | 308 | if (var) |
309 | { | ||
310 | var->flags |= MF_LSLCONST; | ||
311 | var->value.identifierValue->flags |= MF_LSLCONST; | ||
312 | } | ||
311 | } | 313 | } |
312 | else | 314 | if (NULL == var) |
313 | var = eina_hash_find(compiler->script.variables, name); | 315 | var = eina_hash_find(compiler->script.variables, name); |
314 | } | 316 | } |
315 | 317 | ||
@@ -2119,12 +2121,16 @@ static void outputCrementsToken(FILE *file, outputMode mode, LSL_Leaf *content) | |||
2119 | } | 2121 | } |
2120 | else if (OM_LUA == mode) | 2122 | else if (OM_LUA == mode) |
2121 | { | 2123 | { |
2124 | if (MF_LOCAL & content->value.identifierValue->flags) | ||
2125 | fprintf(file, " _"); | ||
2126 | else | ||
2127 | fprintf(file, " _LSL."); | ||
2122 | switch (content->toKen->type) | 2128 | switch (content->toKen->type) |
2123 | { | 2129 | { |
2124 | case LSL_DECREMENT_PRE : fprintf(file, " _LSL.preDecrement"); break; | 2130 | case LSL_DECREMENT_PRE : fprintf(file, "preDecrement"); break; |
2125 | case LSL_INCREMENT_PRE : fprintf(file, " _LSL.preIncrement"); break; | 2131 | case LSL_INCREMENT_PRE : fprintf(file, "preIncrement"); break; |
2126 | case LSL_DECREMENT_POST : fprintf(file, " _LSL.postDecrement"); break; | 2132 | case LSL_DECREMENT_POST : fprintf(file, "postDecrement"); break; |
2127 | case LSL_INCREMENT_POST : fprintf(file, " _LSL.postIncrement"); break; | 2133 | case LSL_INCREMENT_POST : fprintf(file, "postIncrement"); break; |
2128 | default : | 2134 | default : |
2129 | break; | 2135 | break; |
2130 | } | 2136 | } |
@@ -2217,6 +2223,8 @@ static void outputFunctionCallToken(FILE *file, outputMode mode, LSL_Leaf *conte | |||
2217 | boolean first = TRUE; | 2223 | boolean first = TRUE; |
2218 | 2224 | ||
2219 | // TODO - should output it's own ignorable here. | 2225 | // TODO - should output it's own ignorable here. |
2226 | if ((OM_LUA == mode) && (MF_LSLCONST & call->function->flags)) | ||
2227 | fprintf(file, "_LSL."); | ||
2220 | outputText(file, &(call->function->name), FALSE); // Don't output the function definitions ignorable. | 2228 | outputText(file, &(call->function->name), FALSE); // Don't output the function definitions ignorable. |
2221 | fprintf(file, "("); | 2229 | fprintf(file, "("); |
2222 | EINA_INARRAY_FOREACH((&(call->params)), param) | 2230 | EINA_INARRAY_FOREACH((&(call->params)), param) |
@@ -2242,6 +2250,8 @@ static void outputIdentifierToken(FILE *file, outputMode mode, LSL_Leaf *content | |||
2242 | { | 2250 | { |
2243 | if (LSL_IDENTIFIER == content->toKen->type) | 2251 | if (LSL_IDENTIFIER == content->toKen->type) |
2244 | { | 2252 | { |
2253 | if ((OM_LUA == mode) && (MF_LSLCONST & content->value.identifierValue->flags)) | ||
2254 | fprintf(file, "_LSL."); | ||
2245 | outputText(file, &(content->value.identifierValue->name), FALSE); | 2255 | outputText(file, &(content->value.identifierValue->name), FALSE); |
2246 | if (content->value.identifierValue->sub) | 2256 | if (content->value.identifierValue->sub) |
2247 | fprintf(file, ".%s", content->value.identifierValue->sub); | 2257 | fprintf(file, ".%s", content->value.identifierValue->sub); |
@@ -2427,7 +2437,7 @@ static boolean doneParsing(LuaSL_compiler *compiler) | |||
2427 | fprintf(out, "local _bit = require(\"bit\")\n"); | 2437 | fprintf(out, "local _bit = require(\"bit\")\n"); |
2428 | fprintf(out, "local _LSL = require(\"LSL\")\n\n"); | 2438 | fprintf(out, "local _LSL = require(\"LSL\")\n\n"); |
2429 | outputLeaf(out, OM_LUA, compiler->ast); | 2439 | outputLeaf(out, OM_LUA, compiler->ast); |
2430 | fprintf(out, "\n\n--_LSL.stateChange(_defaultState)\n"); // This actually starts the script running. Not ready for that yet, gotta implement some ll*() functions first. So commented it out in Lua. | 2440 | fprintf(out, "\n\n_LSL.stateChange(_defaultState)\n"); // This actually starts the script running. Not ready for that yet, gotta implement some ll*() functions first. So commented it out in Lua. |
2431 | fprintf(out, "\n--// End of generated code.\n\n"); | 2441 | fprintf(out, "\n--// End of generated code.\n\n"); |
2432 | fclose(out); | 2442 | fclose(out); |
2433 | sprintf(buffer, "../../libraries/luajit-2.0/src/luajit \"%s\"", luaName); | 2443 | sprintf(buffer, "../../libraries/luajit-2.0/src/luajit \"%s\"", luaName); |