diff options
Diffstat (limited to 'LuaSL/src/LuaSL_compile.c')
-rw-r--r-- | LuaSL/src/LuaSL_compile.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c index f997d62..7fa7cd7 100644 --- a/LuaSL/src/LuaSL_compile.c +++ b/LuaSL/src/LuaSL_compile.c | |||
@@ -1931,7 +1931,7 @@ static void outputRawStatement(FILE *file, outputMode mode, LSL_Statement *state | |||
1931 | } | 1931 | } |
1932 | else if (OM_LUA == mode) | 1932 | else if (OM_LUA == mode) |
1933 | { | 1933 | { |
1934 | fprintf(file, "stateChange(_"); | 1934 | fprintf(file, "_LSL.stateChange(_"); |
1935 | if (statement->identifier.text) | 1935 | if (statement->identifier.text) |
1936 | outputText(file, &(statement->identifier), TRUE); | 1936 | outputText(file, &(statement->identifier), TRUE); |
1937 | fprintf(file, "State)"); | 1937 | fprintf(file, "State)"); |
@@ -2121,10 +2121,10 @@ static void outputCrementsToken(FILE *file, outputMode mode, LSL_Leaf *content) | |||
2121 | { | 2121 | { |
2122 | switch (content->toKen->type) | 2122 | switch (content->toKen->type) |
2123 | { | 2123 | { |
2124 | case LSL_DECREMENT_PRE : fprintf(file, " _preDecrement"); break; | 2124 | case LSL_DECREMENT_PRE : fprintf(file, " _LSL.preDecrement"); break; |
2125 | case LSL_INCREMENT_PRE : fprintf(file, " _preIncrement"); break; | 2125 | case LSL_INCREMENT_PRE : fprintf(file, " _LSL.preIncrement"); break; |
2126 | case LSL_DECREMENT_POST : fprintf(file, " _postDecrement"); break; | 2126 | case LSL_DECREMENT_POST : fprintf(file, " _LSL.postDecrement"); break; |
2127 | case LSL_INCREMENT_POST : fprintf(file, " _postIncrement"); break; | 2127 | case LSL_INCREMENT_POST : fprintf(file, " _LSL.postIncrement"); break; |
2128 | default : | 2128 | default : |
2129 | break; | 2129 | break; |
2130 | } | 2130 | } |
@@ -2423,17 +2423,11 @@ static boolean doneParsing(LuaSL_compiler *compiler) | |||
2423 | out = fopen(luaName, "w"); | 2423 | out = fopen(luaName, "w"); |
2424 | if (out) | 2424 | if (out) |
2425 | { | 2425 | { |
2426 | fprintf(out, "--// Pre declared helper stuff.\n"); | ||
2427 | fprintf(out, "local _bit = require(\"bit\")\n"); | ||
2428 | fprintf(out, "_currentState = {}\n"); | ||
2429 | fprintf(out, "function _preDecrement(name) _G[name] = _G[name] - 1; return _G[name]; end;\n"); | ||
2430 | fprintf(out, "function _preIncrement(name) _G[name] = _G[name] + 1; return _G[name]; end;\n"); | ||
2431 | fprintf(out, "function _postDecrement(name) local temp = _G[name]; _G[name] = _G[name] - 1; return temp; end;\n"); | ||
2432 | fprintf(out, "function _postIncrement(name) local temp = _G[name]; _G[name] = _G[name] + 1; return temp; end;\n"); | ||
2433 | fprintf(out, "function _stateChange(x) if nil ~= _currentState.state_exit then _currentState.state_exit(); end _currentState = x; if nil ~= _currentState.state_entry then _currentState.state_entry(); end end;\n"); | ||
2434 | fprintf(out, "--// Generated code goes here.\n\n"); | 2426 | fprintf(out, "--// Generated code goes here.\n\n"); |
2427 | fprintf(out, "local _bit = require(\"bit\")\n"); | ||
2428 | fprintf(out, "local _LSL = require(\"LSL\")\n\n"); | ||
2435 | outputLeaf(out, OM_LUA, compiler->ast); | 2429 | outputLeaf(out, OM_LUA, compiler->ast); |
2436 | fprintf(out, "\n\n--_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. | 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. |
2437 | fprintf(out, "\n--// End of generated code.\n\n"); | 2431 | fprintf(out, "\n--// End of generated code.\n\n"); |
2438 | fclose(out); | 2432 | fclose(out); |
2439 | sprintf(buffer, "../../libraries/luajit-2.0/src/luajit \"%s\"", luaName); | 2433 | sprintf(buffer, "../../libraries/luajit-2.0/src/luajit \"%s\"", luaName); |