diff options
Diffstat (limited to '')
-rw-r--r-- | LuaSL/src/LuaSL_compile.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c index 8e9bd01..a4d54db 100644 --- a/LuaSL/src/LuaSL_compile.c +++ b/LuaSL/src/LuaSL_compile.c | |||
@@ -358,7 +358,7 @@ LSL_Leaf *checkVariable(LuaSL_compiler *compiler, LSL_Leaf *identifier, LSL_Leaf | |||
358 | else | 358 | else |
359 | { | 359 | { |
360 | compiler->script.bugCount++; | 360 | compiler->script.bugCount++; |
361 | sendBack(game, compiler->client, compiler->fileName, "compilerError(%d,%d,NOT found %s)", identifier->line, identifier->column, identifier->value.stringValue); | 361 | sendBack(game, compiler->client, compiler->SID, "compilerError(%d,%d,NOT found %s)", identifier->line, identifier->column, identifier->value.stringValue); |
362 | } | 362 | } |
363 | } | 363 | } |
364 | 364 | ||
@@ -402,7 +402,7 @@ LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, | |||
402 | if (OT_undeclared == lType) | 402 | if (OT_undeclared == lType) |
403 | { | 403 | { |
404 | compiler->script.warningCount++; | 404 | compiler->script.warningCount++; |
405 | sendBack(game, compiler->client, compiler->fileName, "compilerWarning(%d,%d,Undeclared identifier issue, deferring this until the second pass)", lval->line, lval->column); | 405 | sendBack(game, compiler->client, compiler->SID, "compilerWarning(%d,%d,Undeclared identifier issue, deferring this until the second pass)", lval->line, lval->column); |
406 | lval->basicType = OT_undeclared; | 406 | lval->basicType = OT_undeclared; |
407 | return lval; | 407 | return lval; |
408 | } | 408 | } |
@@ -430,7 +430,7 @@ LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, | |||
430 | if (OT_undeclared == rType) | 430 | if (OT_undeclared == rType) |
431 | { | 431 | { |
432 | compiler->script.warningCount++; | 432 | compiler->script.warningCount++; |
433 | sendBack(game, compiler->client, compiler->fileName, "compilerWarning(%d,%d,Undeclared identifier issue, deferring this until the second pass)", lval->line, lval->column); | 433 | sendBack(game, compiler->client, compiler->SID, "compilerWarning(%d,%d,Undeclared identifier issue, deferring this until the second pass)", lval->line, lval->column); |
434 | lval->basicType = OT_undeclared; | 434 | lval->basicType = OT_undeclared; |
435 | return lval; | 435 | return lval; |
436 | } | 436 | } |
@@ -587,7 +587,7 @@ else | |||
587 | } | 587 | } |
588 | 588 | ||
589 | compiler->script.bugCount++; | 589 | compiler->script.bugCount++; |
590 | sendBack(game, compiler->client, compiler->fileName, "compilerError(%d,%d,Invalid operation [%s(%s) %s %s(%s)])", lval->line, lval->column, leftType, leftToken, lval->toKen->toKen, rightType, rightToken); | 590 | sendBack(game, compiler->client, compiler->SID, "compilerError(%d,%d,Invalid operation [%s(%s) %s %s(%s)])", lval->line, lval->column, leftType, leftToken, lval->toKen->toKen, rightType, rightToken); |
591 | } | 591 | } |
592 | } | 592 | } |
593 | 593 | ||
@@ -2120,7 +2120,7 @@ boolean compilerSetup(gameGlobals *game) | |||
2120 | 2120 | ||
2121 | // Compile the constants. | 2121 | // Compile the constants. |
2122 | snprintf(buf, sizeof(buf), "%s/src/constants.lsl", PACKAGE_DATA_DIR); | 2122 | snprintf(buf, sizeof(buf), "%s/src/constants.lsl", PACKAGE_DATA_DIR); |
2123 | compileLSL(game, NULL, buf, TRUE); | 2123 | compileLSL(game, NULL, "FAKE_SID", buf, TRUE); |
2124 | 2124 | ||
2125 | return TRUE; | 2125 | return TRUE; |
2126 | } | 2126 | } |
@@ -2140,7 +2140,7 @@ static int luaWriter(lua_State *L, const void* p, size_t sz, void* ud) | |||
2140 | return result; | 2140 | return result; |
2141 | } | 2141 | } |
2142 | 2142 | ||
2143 | boolean compileLSL(gameGlobals *game, Ecore_Con_Client *client, char *script, boolean doConstants) | 2143 | boolean compileLSL(gameGlobals *game, Ecore_Con_Client *client, char *SID, char *script, boolean doConstants) |
2144 | { | 2144 | { |
2145 | boolean result = FALSE; | 2145 | boolean result = FALSE; |
2146 | LuaSL_compiler compiler; | 2146 | LuaSL_compiler compiler; |
@@ -2161,6 +2161,8 @@ boolean compileLSL(gameGlobals *game, Ecore_Con_Client *client, char *script, bo | |||
2161 | compiler.ignorable = eina_strbuf_new(); | 2161 | compiler.ignorable = eina_strbuf_new(); |
2162 | #endif | 2162 | #endif |
2163 | 2163 | ||
2164 | strncpy(compiler.SID, SID, 36); | ||
2165 | compiler.SID[36] = '\0'; | ||
2164 | strncpy(compiler.fileName, script, PATH_MAX - 1); | 2166 | strncpy(compiler.fileName, script, PATH_MAX - 1); |
2165 | compiler.fileName[PATH_MAX - 1] = '\0'; | 2167 | compiler.fileName[PATH_MAX - 1] = '\0'; |
2166 | compiler.file = fopen(compiler.fileName, "r"); | 2168 | compiler.file = fopen(compiler.fileName, "r"); |
@@ -2216,7 +2218,7 @@ boolean compileLSL(gameGlobals *game, Ecore_Con_Client *client, char *script, bo | |||
2216 | call->call->basicType = func->basicType; | 2218 | call->call->basicType = func->basicType; |
2217 | } | 2219 | } |
2218 | else | 2220 | else |
2219 | sendBack(game, compiler.client, compiler.fileName, "compilerError(%d,%d,Undeclared function %s called)", call->call->line, call->call->column, call->call->value.stringValue); | 2221 | sendBack(game, compiler.client, compiler.SID, "compilerError(%d,%d,Undeclared function %s called)", call->call->line, call->call->column, call->call->value.stringValue); |
2220 | } | 2222 | } |
2221 | } | 2223 | } |
2222 | secondPass(&compiler, compiler.ast); | 2224 | secondPass(&compiler, compiler.ast); |
@@ -2275,8 +2277,7 @@ boolean compileLSL(gameGlobals *game, Ecore_Con_Client *client, char *script, bo | |||
2275 | fprintf(out, "--// Generated code goes here.\n\n"); | 2277 | fprintf(out, "--// Generated code goes here.\n\n"); |
2276 | fprintf(out, "local _bit = require(\"bit\")\n"); | 2278 | fprintf(out, "local _bit = require(\"bit\")\n"); |
2277 | fprintf(out, "local _LSL = require(\"LSL\")\n\n"); | 2279 | fprintf(out, "local _LSL = require(\"LSL\")\n\n"); |
2278 | // TODO - Use the scripts UUID instead of the file name here, or something. | 2280 | fprintf(out, "local _SID = [=[%s]=]\n\n", compiler.SID); |
2279 | fprintf(out, "local _SID = [=[%s]=]\n\n", compiler.fileName); | ||
2280 | outputLeaf(out, OM_LUA, compiler.ast); | 2281 | outputLeaf(out, OM_LUA, compiler.ast); |
2281 | fprintf(out, "\n\n_LSL.mainLoop(_SID, _defaultState)\n"); // This actually starts the script running. | 2282 | fprintf(out, "\n\n_LSL.mainLoop(_SID, _defaultState)\n"); // This actually starts the script running. |
2282 | fprintf(out, "\n--// End of generated code.\n\n"); | 2283 | fprintf(out, "\n--// End of generated code.\n\n"); |