From ab6b1318f3dd335ef49aa46146c43a51037675b7 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Thu, 14 Aug 2014 14:11:58 +1000 Subject: Clean up the compiler output. Threaded compiling is much faster when it's not outputting to the console. --- src/LuaSL/LuaSL_LSL_tree.h | 3 ++- src/LuaSL/LuaSL_compile.c | 13 ++++++++----- src/LuaSL/LuaSL_lemon_yaccer.y | 12 ++++++------ src/LuaSL/LuaSL_lexer.l | 2 +- src/LuaSL/LuaSL_main.c | 2 ++ src/libraries/Runnr.c | 8 +++++++- 6 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/LuaSL/LuaSL_LSL_tree.h b/src/LuaSL/LuaSL_LSL_tree.h index 4192310..98e8e22 100644 --- a/src/LuaSL/LuaSL_LSL_tree.h +++ b/src/LuaSL/LuaSL_LSL_tree.h @@ -3,7 +3,8 @@ #define __LUASL_TREE_H__ #define LUASL_DEBUG 0 -#define COMPILE_THREADED 0 +#define COMPILE_THREADED 1 +#define COMPILE_OUTPUT 0 #define LUASL_DIFF_CHECK 0 #define LUASL_BAD_CHECK 1 diff --git a/src/LuaSL/LuaSL_compile.c b/src/LuaSL/LuaSL_compile.c index 4764855..a2b2bca 100644 --- a/src/LuaSL/LuaSL_compile.c +++ b/src/LuaSL/LuaSL_compile.c @@ -501,7 +501,7 @@ LSL_Leaf *addOperation(LuaSL_compiler *compiler, LSL_Leaf *left, LSL_Leaf *lval, // someList = someList + notAList -> someList = _LSL.listAddList( someList, notAList) else if ((OT_list == lType) || (OT_list == rType)) { - +#if COMPILE_OUTPUT if ((left) && (right)) printf("LA LINE %d - %s %s %s\n", lval->line, left->toKen->toKen, lval->toKen->toKen, right->toKen->toKen); else if (left) @@ -510,7 +510,7 @@ else if (right) printf("LA LINE %d - NOLEFT %s %s\n", lval->line, lval->toKen->toKen, right->toKen->toKen); else printf("LA LINE %d - NOLEFT %s NORIGHT\n", lval->line, lval->toKen->toKen); - +#endif lval->basicType = OT_list; lval->toKen = tokens[LSL_LIST_ADD_LIST - lowestToken]; } @@ -575,6 +575,7 @@ else { if (left->flags & MF_ASSIGNEXP) { +#if COMPILE_OUTPUT if ((left) && (right)) printf("%s %s %s\n", left->toKen->toKen, lval->toKen->toKen, right->toKen->toKen); else if (left) @@ -584,6 +585,7 @@ else if (right) else printf("NOLEFT %s NORIGHT\n", lval->toKen->toKen); printf("############################################################################## left\n"); +#endif left->flags |= MF_WRAPFUNC; if (LSL_PARENTHESIS_OPEN == left->toKen->type) left->value.parenthesis->flags |= MF_WRAPFUNC; @@ -609,6 +611,7 @@ else { if (right->flags & MF_ASSIGNEXP) { +#if COMPILE_OUTPUT if ((left) && (right)) printf("%s %s %s\n", left->toKen->toKen, lval->toKen->toKen, right->toKen->toKen); else if (left) @@ -618,6 +621,7 @@ else if (right) else printf("NOLEFT %s NORIGHT\n", lval->toKen->toKen); printf("############################################################################## right\n"); +#endif right->flags |= MF_WRAPFUNC; } } @@ -643,8 +647,6 @@ else rightType = allowed[right->basicType].name; } -// compiler->compiler->bugCount++; -// 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); finishMessage(compiler->compiler, addMessage(&(compiler->compiler->messages), sizeof(compileMessage), "Invalid operation [%s(%s) %s %s(%s)]", leftType, leftToken, lval->toKen->toKen, rightType, rightToken), 1, lval->column, lval->line); @@ -1429,6 +1431,7 @@ static void outputLeaf(FILE *file, outputMode mode, LSL_Leaf *leaf) if (MF_WRAPFUNC & leaf->flags) { // TODO - Leaving this here in case we trip over one. +#if COMPILE_OUTPUT if ((leaf->left) && (leaf->right)) printf("%s %s %s\n", leaf->left->toKen->toKen, leaf->toKen->toKen, leaf->right->toKen->toKen); else if (leaf->left) @@ -1437,6 +1440,7 @@ else if (leaf->right) printf("NOLEFT %s %s\n", leaf->toKen->toKen, leaf->right->toKen->toKen); else printf("NOLEFT %s NORIGHT\n", leaf->toKen->toKen); +#endif } if ((LSL_ASSIGNMENT & leaf->toKen->flags) && (LSL_ASSIGNMENT_PLAIN != leaf->toKen->type)) { @@ -2315,7 +2319,6 @@ void compileLSL(LuaCompiler *compiler) } else { -// 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); finishMessage(lcompiler->compiler, addMessage(&(lcompiler->compiler->messages), sizeof(compileMessage), "NOT FOUND function %s called", call->call->value.stringValue), 1, call->call->column, call->call->line); diff --git a/src/LuaSL/LuaSL_lemon_yaccer.y b/src/LuaSL/LuaSL_lemon_yaccer.y index 08fdccc..5ddf45a 100644 --- a/src/LuaSL/LuaSL_lemon_yaccer.y +++ b/src/LuaSL/LuaSL_lemon_yaccer.y @@ -229,20 +229,20 @@ expr(A) ::= LSL_STRING(B). { B->basicType = OT_string; A = B; } %parse_failure { - compiler->compiler->bugCount++; - PE("Giving up. Parser is hopelessly lost!"); + finishMessage(compiler->compiler, addMessage(&(compiler->compiler->messages), sizeof(compileMessage), + "Giving up. Parser is hopelessly lost!"), + 1, -1, -1); } %stack_overflow { - compiler->compiler->bugCount++; - PE("Giving up. Parser stack overflow @ line %d, column %d!", yypMinor->yy0->line, yypMinor->yy0->column); // Gotta love consistancy, if it ever happens. + finishMessage(compiler->compiler, addMessage(&(compiler->compiler->messages), sizeof(compileMessage), + "Giving up. Parser stack overflow"), // Gotta love consistancy, if it ever happens. + 1, yypMinor->yy0->column, yypMinor->yy0->line); } %syntax_error { -// compiler->compiler->bugCount++; -// PE("Syntax error @ line %d, column %d!", yyminor.yy0->line, yyminor.yy0->column); finishMessage(compiler->compiler, addMessage(&(compiler->compiler->messages), sizeof(compileMessage), "Syntax error."), 1, yyminor.yy0->column, yyminor.yy0->line); diff --git a/src/LuaSL/LuaSL_lexer.l b/src/LuaSL/LuaSL_lexer.l index 85b2821..9d58899 100644 --- a/src/LuaSL/LuaSL_lexer.l +++ b/src/LuaSL/LuaSL_lexer.l @@ -113,7 +113,7 @@ STRING \"(\\.|[^\\"\n])*\" <> { return common(yylval, yytext, yyleng, yyextra, TRUE, LSL_SCRIPT); } /* Everything else */ -. %{ printf(" unexpected character.\n"); yylval->value.stringValue = eina_stringshare_add_length(yytext, yyleng); common(yylval, yytext, yyleng, yyextra, TRUE, LSL_UNKNOWN); %} +. %{ if (COMPILE_OUTPUT) printf(" unexpected character '%s'.\n", yytext); yylval->value.stringValue = eina_stringshare_add_length(yytext, yyleng); common(yylval, yytext, yyleng, yyextra, TRUE, LSL_UNKNOWN); %} %% diff --git a/src/LuaSL/LuaSL_main.c b/src/LuaSL/LuaSL_main.c index 1eaa43a..0ffc679 100644 --- a/src/LuaSL/LuaSL_main.c +++ b/src/LuaSL/LuaSL_main.c @@ -186,10 +186,12 @@ static void _compileCb(LuaCompiler *compiler) EINA_CLIST_FOR_EACH_ENTRY_SAFE(message, safe, &(compiler->messages), compileMessage, node) { +#if COMPILE_OUTPUT if (message->type) sendBack(compiler->client, compiler->SID, "compilerError(%d,%d,%s)", message->line, message->column, message->message); else sendBack(compiler->client, compiler->SID, "compilerWarning(%d,%d,%s)", message->line, message->column, message->message); +#endif eina_clist_remove(&(message->node)); free(message); } diff --git a/src/libraries/Runnr.c b/src/libraries/Runnr.c index 5fecfdf..fbd4289 100644 --- a/src/libraries/Runnr.c +++ b/src/libraries/Runnr.c @@ -442,12 +442,14 @@ static void _compileThread(void *data, Ecore_Thread *thread) if (err) { compiler->bugCount++; +#if COMPILE_OUTPUT if (LUA_ERRSYNTAX == err) printf("Lua syntax error in %s: %s\n", name, lua_tostring(L, -1)); else if (LUA_ERRFILE == err) printf("Lua compile file error in %s: %s\n", name, lua_tostring(L, -1)); else if (LUA_ERRMEM == err) printf("Lua compile memory allocation error in %s: %s\n", name, lua_tostring(L, -1)); +#endif } else { @@ -480,11 +482,15 @@ static void _compileThread(void *data, Ecore_Thread *thread) else { compiler->bugCount++; +#if COMPILE_OUTPUT printf("Nothing for Lua to compile!\n"); +#endif } } -// TODO - Threaded version is consistantly about half the speed. WTF? +// Speed tests scripts per second - Threaded Unthreaded +// 900 - 1400 750 - 800 +// But with outputting to the console - 450 - 700 750 - 800 void compileScript(LuaCompiler *compiler, int threadIt) { if (threadIt) -- cgit v1.1