diff options
author | David Walter Seikel | 2014-08-14 08:32:50 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-08-14 08:32:50 +1000 |
commit | 9e8f8dbd9c52d1da132d618573d87650e0a0f7f9 (patch) | |
tree | c9d76f4a95b3ed6b0d8174be2d981ec04cc570a9 | |
parent | Considerable cleanup of the top level compiling code. (diff) | |
download | SledjHamr-9e8f8dbd9c52d1da132d618573d87650e0a0f7f9.zip SledjHamr-9e8f8dbd9c52d1da132d618573d87650e0a0f7f9.tar.gz SledjHamr-9e8f8dbd9c52d1da132d618573d87650e0a0f7f9.tar.bz2 SledjHamr-9e8f8dbd9c52d1da132d618573d87650e0a0f7f9.tar.xz |
Only collect the errors and warnings during a compile, output them in a batch at the end.
-rw-r--r-- | src/LuaSL/LuaSL_compile.c | 32 | ||||
-rw-r--r-- | src/LuaSL/LuaSL_main.c | 14 | ||||
-rw-r--r-- | src/libraries/Runnr.c | 4 | ||||
-rw-r--r-- | src/libraries/Runnr.h | 8 | ||||
-rw-r--r-- | src/libraries/SledjHamr.c | 25 | ||||
-rw-r--r-- | src/libraries/SledjHamr.h | 1 |
6 files changed, 75 insertions, 9 deletions
diff --git a/src/LuaSL/LuaSL_compile.c b/src/LuaSL/LuaSL_compile.c index d1ef48b..b2ae841 100644 --- a/src/LuaSL/LuaSL_compile.c +++ b/src/LuaSL/LuaSL_compile.c | |||
@@ -223,6 +223,15 @@ LSL_Script constants; | |||
223 | int lowestToken = 999999; | 223 | int lowestToken = 999999; |
224 | 224 | ||
225 | 225 | ||
226 | static void finishMessage(LuaCompile *compiler, compileMessage *message, int type, int column, int line) | ||
227 | { | ||
228 | message->type = type; | ||
229 | message->column = column; | ||
230 | message->line = line; | ||
231 | if (type) | ||
232 | compiler->bugCount++; | ||
233 | } | ||
234 | |||
226 | static LSL_Leaf *newLeaf(LSL_Type type, LSL_Leaf *left, LSL_Leaf *right) | 235 | static LSL_Leaf *newLeaf(LSL_Type type, LSL_Leaf *left, LSL_Leaf *right) |
227 | { | 236 | { |
228 | LSL_Leaf *leaf = calloc(1, sizeof(LSL_Leaf)); | 237 | LSL_Leaf *leaf = calloc(1, sizeof(LSL_Leaf)); |
@@ -361,8 +370,11 @@ LSL_Leaf *checkVariable(LuaSL_compiler *compiler, LSL_Leaf *identifier, LSL_Leaf | |||
361 | } | 370 | } |
362 | else | 371 | else |
363 | { | 372 | { |
364 | compiler->compiler->bugCount++; | 373 | // compiler->compiler->bugCount++; |
365 | sendBack(compiler->compiler->client, compiler->compiler->SID, "compilerError(%d,%d,NOT FOUND variable %s)", identifier->line, identifier->column, identifier->value.stringValue); | 374 | // sendBack(compiler->compiler->client, compiler->compiler->SID, "compilerError(%d,%d,NOT FOUND variable %s)", identifier->line, identifier->column, identifier->value.stringValue); |
375 | finishMessage(compiler->compiler, addMessage(&(compiler->compiler->messages), sizeof(compileMessage), | ||
376 | "NOT FOUND variable %s", identifier->value.stringValue), | ||
377 | 1, identifier->column, identifier->line); | ||
366 | } | 378 | } |
367 | } | 379 | } |
368 | 380 | ||
@@ -632,8 +644,11 @@ else | |||
632 | rightType = allowed[right->basicType].name; | 644 | rightType = allowed[right->basicType].name; |
633 | } | 645 | } |
634 | 646 | ||
635 | compiler->compiler->bugCount++; | 647 | // compiler->compiler->bugCount++; |
636 | sendBack(compiler->compiler->client, compiler->compiler->SID, "compilerError(%d,%d,Invalid operation [%s(%s) %s %s(%s)])", lval->line, lval->column, leftType, leftToken, lval->toKen->toKen, rightType, rightToken); | 648 | // sendBack(compiler->compiler->client, compiler->compiler->SID, "compilerError(%d,%d,Invalid operation [%s(%s) %s %s(%s)])", lval->line, lval->column, leftType, leftToken, lval->toKen->toKen, rightType, rightToken); |
649 | finishMessage(compiler->compiler, addMessage(&(compiler->compiler->messages), sizeof(compileMessage), | ||
650 | "Invalid operation [%s(%s) %s %s(%s)]", leftType, leftToken, lval->toKen->toKen, rightType, rightToken), | ||
651 | 1, lval->column, lval->line); | ||
637 | } | 652 | } |
638 | } | 653 | } |
639 | 654 | ||
@@ -2234,7 +2249,7 @@ void compileLSL(LuaCompiler *compiler) | |||
2234 | lcompiler->ignorable = eina_strbuf_new(); | 2249 | lcompiler->ignorable = eina_strbuf_new(); |
2235 | #endif | 2250 | #endif |
2236 | 2251 | ||
2237 | PI("Compiling %s.", lcompiler->compiler->file); | 2252 | // PI("Compiling %s.", lcompiler->compiler->file); |
2238 | 2253 | ||
2239 | in = fopen(lcompiler->compiler->file, "r"); | 2254 | in = fopen(lcompiler->compiler->file, "r"); |
2240 | if (NULL == in) | 2255 | if (NULL == in) |
@@ -2300,7 +2315,12 @@ void compileLSL(LuaCompiler *compiler) | |||
2300 | call->call->basicType = func->basicType; | 2315 | call->call->basicType = func->basicType; |
2301 | } | 2316 | } |
2302 | else | 2317 | else |
2303 | sendBack(lcompiler->compiler->client, lcompiler->compiler->SID, "compilerError(%d,%d,NOT FOUND function %s called)", call->call->line, call->call->column, call->call->value.stringValue); | 2318 | { |
2319 | // sendBack(lcompiler->compiler->client, lcompiler->compiler->SID, "compilerError(%d,%d,NOT FOUND function %s called)", call->call->line, call->call->column, call->call->value.stringValue); | ||
2320 | finishMessage(lcompiler->compiler, addMessage(&(lcompiler->compiler->messages), sizeof(compileMessage), | ||
2321 | "NOT FOUND function %s called)", call->call->value.stringValue), | ||
2322 | 1, call->call->column, call->call->line); | ||
2323 | } | ||
2304 | } | 2324 | } |
2305 | } | 2325 | } |
2306 | secondPass(lcompiler, lcompiler->ast); | 2326 | secondPass(lcompiler, lcompiler->ast); |
diff --git a/src/LuaSL/LuaSL_main.c b/src/LuaSL/LuaSL_main.c index f316fdb..1eaa43a 100644 --- a/src/LuaSL/LuaSL_main.c +++ b/src/LuaSL/LuaSL_main.c | |||
@@ -182,6 +182,18 @@ static Eina_Bool _add(void *data, int type __UNUSED__, Ecore_Con_Event_Client_Ad | |||
182 | 182 | ||
183 | static void _compileCb(LuaCompiler *compiler) | 183 | static void _compileCb(LuaCompiler *compiler) |
184 | { | 184 | { |
185 | compileMessage *message = NULL, *safe = NULL; | ||
186 | |||
187 | EINA_CLIST_FOR_EACH_ENTRY_SAFE(message, safe, &(compiler->messages), compileMessage, node) | ||
188 | { | ||
189 | if (message->type) | ||
190 | sendBack(compiler->client, compiler->SID, "compilerError(%d,%d,%s)", message->line, message->column, message->message); | ||
191 | else | ||
192 | sendBack(compiler->client, compiler->SID, "compilerWarning(%d,%d,%s)", message->line, message->column, message->message); | ||
193 | eina_clist_remove(&(message->node)); | ||
194 | free(message); | ||
195 | } | ||
196 | |||
185 | if (0 == compiler->bugCount) | 197 | if (0 == compiler->bugCount) |
186 | sendBack(compiler->client, compiler->SID, "compiled(true)"); | 198 | sendBack(compiler->client, compiler->SID, "compiled(true)"); |
187 | else | 199 | else |
@@ -223,6 +235,7 @@ static Eina_Bool _data(void *data, int type __UNUSED__, Ecore_Con_Event_Client_D | |||
223 | temp++; | 235 | temp++; |
224 | temp[0] = '\0'; | 236 | temp[0] = '\0'; |
225 | 237 | ||
238 | eina_clist_init(&(compiler->messages)); | ||
226 | compiler->file = strdup(file); | 239 | compiler->file = strdup(file); |
227 | compiler->SID = strdup(SID); | 240 | compiler->SID = strdup(SID); |
228 | compiler->client = ev->client; | 241 | compiler->client = ev->client; |
@@ -304,6 +317,7 @@ int main(int argc, char **argv) | |||
304 | ourGlobals.names = eina_hash_string_superfast_new(NULL); | 317 | ourGlobals.names = eina_hash_string_superfast_new(NULL); |
305 | if (ecore_init()) | 318 | if (ecore_init()) |
306 | { | 319 | { |
320 | // ecore_thread_max_set(4); | ||
307 | if (ecore_con_init()) | 321 | if (ecore_con_init()) |
308 | { | 322 | { |
309 | if ((ourGlobals.server = ecore_con_server_add(ECORE_CON_REMOTE_TCP, ourGlobals.address, ourGlobals.port, &ourGlobals))) | 323 | if ((ourGlobals.server = ecore_con_server_add(ECORE_CON_REMOTE_TCP, ourGlobals.address, ourGlobals.port, &ourGlobals))) |
diff --git a/src/libraries/Runnr.c b/src/libraries/Runnr.c index 1f10d33..5fecfdf 100644 --- a/src/libraries/Runnr.c +++ b/src/libraries/Runnr.c | |||
@@ -421,9 +421,6 @@ static void _compileEnd(void *data, Ecore_Thread *thread) | |||
421 | free(compiler->SID); | 421 | free(compiler->SID); |
422 | } | 422 | } |
423 | 423 | ||
424 | // TODO - Should pass error messages back through a linked list. | ||
425 | // To eventually get passed back to the calling app via compiler->errors and compiler->warnings. | ||
426 | // Will need ageneric "add this formatted string to a linked list" function, in SledjHamr.c | ||
427 | static void _compileThread(void *data, Ecore_Thread *thread) | 424 | static void _compileThread(void *data, Ecore_Thread *thread) |
428 | { | 425 | { |
429 | LuaCompiler *compiler = data; | 426 | LuaCompiler *compiler = data; |
@@ -487,6 +484,7 @@ static void _compileThread(void *data, Ecore_Thread *thread) | |||
487 | } | 484 | } |
488 | } | 485 | } |
489 | 486 | ||
487 | // TODO - Threaded version is consistantly about half the speed. WTF? | ||
490 | void compileScript(LuaCompiler *compiler, int threadIt) | 488 | void compileScript(LuaCompiler *compiler, int threadIt) |
491 | { | 489 | { |
492 | if (threadIt) | 490 | if (threadIt) |
diff --git a/src/libraries/Runnr.h b/src/libraries/Runnr.h index 63e0afc..a2098d9 100644 --- a/src/libraries/Runnr.h +++ b/src/libraries/Runnr.h | |||
@@ -30,6 +30,13 @@ typedef enum | |||
30 | typedef struct _LuaCompile LuaCompile; | 30 | typedef struct _LuaCompile LuaCompile; |
31 | typedef void (* compileCb)(LuaCompile *compiler); | 31 | typedef void (* compileCb)(LuaCompile *compiler); |
32 | 32 | ||
33 | typedef struct _compileMessage | ||
34 | { | ||
35 | Eina_Clist node; | ||
36 | char *message; | ||
37 | int type, column, line; | ||
38 | } compileMessage; | ||
39 | |||
33 | typedef struct _LuaCompile | 40 | typedef struct _LuaCompile |
34 | { | 41 | { |
35 | char *file, *SID, *luaName; | 42 | char *file, *SID, *luaName; |
@@ -38,6 +45,7 @@ typedef struct _LuaCompile | |||
38 | compileCb parser; | 45 | compileCb parser; |
39 | compileCb cb; | 46 | compileCb cb; |
40 | boolean doConstants; | 47 | boolean doConstants; |
48 | Eina_Clist messages; // HEAD for error and warning messages. | ||
41 | } LuaCompiler; | 49 | } LuaCompiler; |
42 | 50 | ||
43 | typedef struct _script script; | 51 | typedef struct _script script; |
diff --git a/src/libraries/SledjHamr.c b/src/libraries/SledjHamr.c index 5e1d387..5b1cfd5 100644 --- a/src/libraries/SledjHamr.c +++ b/src/libraries/SledjHamr.c | |||
@@ -13,6 +13,12 @@ struct _conct | |||
13 | Ecore_Event_Handler *add, *data, *del; | 13 | Ecore_Event_Handler *add, *data, *del; |
14 | }; | 14 | }; |
15 | 15 | ||
16 | struct _message | ||
17 | { | ||
18 | Eina_Clist node; | ||
19 | char *message; | ||
20 | }; | ||
21 | |||
16 | 22 | ||
17 | static Eina_Bool _add(void *data, int type, Ecore_Con_Event_Server_Del *ev) | 23 | static Eina_Bool _add(void *data, int type, Ecore_Con_Event_Server_Del *ev) |
18 | { | 24 | { |
@@ -85,6 +91,25 @@ Ecore_Con_Server *reachOut(char *address, int port, void *data, Ecore_Event_Hand | |||
85 | return server; | 91 | return server; |
86 | } | 92 | } |
87 | 93 | ||
94 | void *addMessage(Eina_Clist *list, size_t size, const char *message, ...) | ||
95 | { | ||
96 | va_list args; | ||
97 | char buf[PATH_MAX]; | ||
98 | int length = 0; | ||
99 | struct _message *result; | ||
100 | |||
101 | va_start(args, message); | ||
102 | length += vsprintf(&buf[length], message, args); | ||
103 | va_end(args); | ||
104 | result = calloc(1, size + length + 1); | ||
105 | eina_clist_element_init(&(result->node)); | ||
106 | eina_clist_add_tail(list, &(result->node)); | ||
107 | result->message = ((char *) result) + size; | ||
108 | strcpy(result->message, buf); | ||
109 | |||
110 | return result; | ||
111 | } | ||
112 | |||
88 | void sendBack(Ecore_Con_Client *client, const char *SID, const char *message, ...) | 113 | void sendBack(Ecore_Con_Client *client, const char *SID, const char *message, ...) |
89 | { | 114 | { |
90 | va_list args; | 115 | va_list args; |
diff --git a/src/libraries/SledjHamr.h b/src/libraries/SledjHamr.h index 7ce32b9..07018a1 100644 --- a/src/libraries/SledjHamr.h +++ b/src/libraries/SledjHamr.h | |||
@@ -9,6 +9,7 @@ | |||
9 | 9 | ||
10 | 10 | ||
11 | Ecore_Con_Server *reachOut(char *address, int port, void *data, Ecore_Event_Handler_Cb _add, Ecore_Event_Handler_Cb _data, Ecore_Event_Handler_Cb _del); | 11 | Ecore_Con_Server *reachOut(char *address, int port, void *data, Ecore_Event_Handler_Cb _add, Ecore_Event_Handler_Cb _data, Ecore_Event_Handler_Cb _del); |
12 | void *addMessage(Eina_Clist *list, size_t size, const char *message, ...); | ||
12 | void sendBack(Ecore_Con_Client *client, const char *SID, const char *message, ...); | 13 | void sendBack(Ecore_Con_Client *client, const char *SID, const char *message, ...); |
13 | void sendForth(Ecore_Con_Server *server, const char *SID, const char *message, ...); | 14 | void sendForth(Ecore_Con_Server *server, const char *SID, const char *message, ...); |
14 | 15 | ||