diff options
author | David Walter Seikel | 2012-01-17 13:15:15 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-17 13:15:15 +1000 |
commit | e235a097751de7ad97563997215f76761b3db609 (patch) | |
tree | 3dc1098de9770e8b165ed8dbc4128f5f2245afaa /LuaSL/src/LuaSL_compile.c | |
parent | Add a newline at the end of the file. lol (diff) | |
download | SledjHamr-e235a097751de7ad97563997215f76761b3db609.zip SledjHamr-e235a097751de7ad97563997215f76761b3db609.tar.gz SledjHamr-e235a097751de7ad97563997215f76761b3db609.tar.bz2 SledjHamr-e235a097751de7ad97563997215f76761b3db609.tar.xz |
Use EFL logging.
Diffstat (limited to '')
-rw-r--r-- | LuaSL/src/LuaSL_compile.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c index 01657bc..030f140 100644 --- a/LuaSL/src/LuaSL_compile.c +++ b/LuaSL/src/LuaSL_compile.c | |||
@@ -1,5 +1,4 @@ | |||
1 | #include "LuaSL.h" | 1 | #include "LuaSL.h" |
2 | #include "LuaSL_LSL_tree.h" | ||
3 | 2 | ||
4 | 3 | ||
5 | static LSL_Leaf *evaluateFloatToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right); | 4 | static LSL_Leaf *evaluateFloatToken(LSL_Leaf *content, LSL_Leaf *left, LSL_Leaf *right); |
@@ -210,8 +209,10 @@ void burnLeaf(LSL_Leaf *leaf) | |||
210 | } | 209 | } |
211 | } | 210 | } |
212 | 211 | ||
213 | LSL_Leaf *addOperation(LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right) | 212 | LSL_Leaf *addOperation(LuaSL_yyparseParam *param, LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right) |
214 | { | 213 | { |
214 | gameGlobals *game = param->game; | ||
215 | |||
215 | if (lval) | 216 | if (lval) |
216 | { | 217 | { |
217 | opType lType, rType; | 218 | opType lType, rType; |
@@ -283,7 +284,7 @@ LSL_Leaf *addOperation(LSL_Leaf *left, LSL_Leaf *lval, LSL_Leaf *right) | |||
283 | if (right) | 284 | if (right) |
284 | rightType = allowed[right->basicType].name; | 285 | rightType = allowed[right->basicType].name; |
285 | 286 | ||
286 | fprintf(stderr, "Invalid operation [%s %s %s] @ line %d column %d\n", leftType, lval->token->token, rightType, lval->line, lval->column); | 287 | PE("Invalid operation [%s %s %s] @ line %d column %d", leftType, lval->token->token, rightType, lval->line, lval->column); |
287 | } | 288 | } |
288 | } | 289 | } |
289 | 290 | ||
@@ -870,6 +871,8 @@ static void outputVariableToken(FILE *file, outputMode mode, LSL_Leaf *content) | |||
870 | 871 | ||
871 | static void doneParsing(LuaSL_yyparseParam *param) | 872 | static void doneParsing(LuaSL_yyparseParam *param) |
872 | { | 873 | { |
874 | gameGlobals *game = param->game; | ||
875 | |||
873 | if (param->ast) | 876 | if (param->ast) |
874 | { | 877 | { |
875 | FILE *out; | 878 | FILE *out; |
@@ -894,12 +897,12 @@ static void doneParsing(LuaSL_yyparseParam *param) | |||
894 | fclose(out); | 897 | fclose(out); |
895 | sprintf(buffer, "diff %s %s", param->fileName, outName); | 898 | sprintf(buffer, "diff %s %s", param->fileName, outName); |
896 | // count = system(buffer); | 899 | // count = system(buffer); |
897 | // printf("Return value of %s is %d\n", buffer, count); | 900 | // PI("Return value of %s is %d", buffer, count); |
898 | // if (0 != count) | 901 | // if (0 != count) |
899 | // fprintf(stderr, "%s says they are different!\n", buffer); | 902 | // PE("%s says they are different!", buffer); |
900 | } | 903 | } |
901 | else | 904 | else |
902 | fprintf(stderr, "Unable to open file %s for writing!\n", outName); | 905 | PC("Unable to open file %s for writing!", outName); |
903 | out = fopen(luaName, "w"); | 906 | out = fopen(luaName, "w"); |
904 | if (out) | 907 | if (out) |
905 | { | 908 | { |
@@ -907,11 +910,11 @@ static void doneParsing(LuaSL_yyparseParam *param) | |||
907 | fclose(out); | 910 | fclose(out); |
908 | } | 911 | } |
909 | else | 912 | else |
910 | fprintf(stderr, "Unable to open file %s for writing!\n", luaName); | 913 | PC("Unable to open file %s for writing!", luaName); |
911 | } | 914 | } |
912 | } | 915 | } |
913 | 916 | ||
914 | Eina_Bool compilerSetup() | 917 | Eina_Bool compilerSetup(gameGlobals *game) |
915 | { | 918 | { |
916 | int i; | 919 | int i; |
917 | 920 | ||
@@ -934,7 +937,7 @@ Eina_Bool compilerSetup() | |||
934 | return EINA_TRUE; | 937 | return EINA_TRUE; |
935 | } | 938 | } |
936 | else | 939 | else |
937 | fprintf(stderr, "No memory for tokens!"); | 940 | PC("No memory for tokens!"); |
938 | 941 | ||
939 | return EINA_FALSE; | 942 | return EINA_FALSE; |
940 | } | 943 | } |
@@ -950,15 +953,18 @@ Eina_Bool compileLSL(gameGlobals *game, char *script) | |||
950 | // Just pass all constants and function names through to Lua, assume they are globals there. | 953 | // Just pass all constants and function names through to Lua, assume they are globals there. |
951 | 954 | ||
952 | memset(¶m, 0, sizeof(LuaSL_yyparseParam)); | 955 | memset(¶m, 0, sizeof(LuaSL_yyparseParam)); |
956 | param.game = game; | ||
957 | |||
958 | |||
953 | strncpy(param.fileName, script, PATH_MAX - 1); | 959 | strncpy(param.fileName, script, PATH_MAX - 1); |
954 | param.fileName[PATH_MAX - 1] = '\0'; | 960 | param.fileName[PATH_MAX - 1] = '\0'; |
955 | param.file = fopen(param.fileName, "r"); | 961 | param.file = fopen(param.fileName, "r"); |
956 | if (NULL == param.file) | 962 | if (NULL == param.file) |
957 | { | 963 | { |
958 | fprintf(stderr, "Error opening file %s.\n", param.fileName); | 964 | PE("Error opening file %s.", param.fileName); |
959 | return FALSE; | 965 | return FALSE; |
960 | } | 966 | } |
961 | printf("Opened %s.\n", param.fileName); | 967 | PI("Opened %s.", param.fileName); |
962 | param.ast = NULL; | 968 | param.ast = NULL; |
963 | param.lval = calloc(1, sizeof(LSL_Leaf)); | 969 | param.lval = calloc(1, sizeof(LSL_Leaf)); |
964 | // Text editors usually start counting at 1, even programmers editors. | 970 | // Text editors usually start counting at 1, even programmers editors. |
@@ -1025,10 +1031,10 @@ static int nextFile(LuaSL_yyparseParam *param) | |||
1025 | param->file = fopen(param->fileName, "r"); | 1031 | param->file = fopen(param->fileName, "r"); |
1026 | if (NULL == param->file) | 1032 | if (NULL == param->file) |
1027 | { | 1033 | { |
1028 | fprintf(stderr, "Error opening file %s.\n", param->fileName); | 1034 | PE(stderr, "Error opening file %s.", param->fileName); |
1029 | return FALSE; | 1035 | return FALSE; |
1030 | } | 1036 | } |
1031 | printf("Opened %s.\n", param->fileName); | 1037 | PE("Opened %s.", param->fileName); |
1032 | burnLeaf(param->ast); | 1038 | burnLeaf(param->ast); |
1033 | param->ast = NULL; | 1039 | param->ast = NULL; |
1034 | param->lval = calloc(1, sizeof(LSL_Leaf)); | 1040 | param->lval = calloc(1, sizeof(LSL_Leaf)); |