aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-01-22 09:55:38 +1000
committerDavid Walter Seikel2012-01-22 09:55:38 +1000
commit5270f91252ad63384930b69153638ff74a24b97e (patch)
treec94cdebe7afc51525b6638d9024b001a4418763d /LuaSL
parentMove the test script into the directory where the other tests are, so it's no... (diff)
downloadSledjHamr-5270f91252ad63384930b69153638ff74a24b97e.zip
SledjHamr-5270f91252ad63384930b69153638ff74a24b97e.tar.gz
SledjHamr-5270f91252ad63384930b69153638ff74a24b97e.tar.bz2
SledjHamr-5270f91252ad63384930b69153638ff74a24b97e.tar.xz
Consider a script as properly compiled if it passes the diff test.
Diffstat (limited to 'LuaSL')
-rw-r--r--LuaSL/src/LuaSL.h4
-rw-r--r--LuaSL/src/LuaSL_LSL_tree.h2
-rw-r--r--LuaSL/src/LuaSL_compile.c28
3 files changed, 21 insertions, 13 deletions
diff --git a/LuaSL/src/LuaSL.h b/LuaSL/src/LuaSL.h
index 59a3fbd..26547ee 100644
--- a/LuaSL/src/LuaSL.h
+++ b/LuaSL/src/LuaSL.h
@@ -56,8 +56,8 @@ typedef struct
56} gameGlobals; 56} gameGlobals;
57 57
58 58
59Eina_Bool compilerSetup(gameGlobals *game); 59boolean compilerSetup(gameGlobals *game);
60Eina_Bool compileLSL(gameGlobals *game, char *script, boolean doConstants); 60boolean compileLSL(gameGlobals *game, char *script, boolean doConstants);
61 61
62void loggingStartup(gameGlobals *game); 62void loggingStartup(gameGlobals *game);
63char *getDateTime(struct tm **nowOut, char *dateOut, time_t *tiemOut); 63char *getDateTime(struct tm **nowOut, char *dateOut, time_t *tiemOut);
diff --git a/LuaSL/src/LuaSL_LSL_tree.h b/LuaSL/src/LuaSL_LSL_tree.h
index c0930b3..76af195 100644
--- a/LuaSL/src/LuaSL_LSL_tree.h
+++ b/LuaSL/src/LuaSL_LSL_tree.h
@@ -3,7 +3,7 @@
3#define __LUASL_TREE_H__ 3#define __LUASL_TREE_H__
4 4
5//#define LUASL_DEBUG 5//#define LUASL_DEBUG
6//#define LUASL_DIFF_CHECK 6#define LUASL_DIFF_CHECK
7 7
8 8
9#include <stddef.h> // So we can have NULL defined. 9#include <stddef.h> // So we can have NULL defined.
diff --git a/LuaSL/src/LuaSL_compile.c b/LuaSL/src/LuaSL_compile.c
index 5f3b646..52db12a 100644
--- a/LuaSL/src/LuaSL_compile.c
+++ b/LuaSL/src/LuaSL_compile.c
@@ -1176,15 +1176,17 @@ static void outputStatementToken(FILE *file, outputMode mode, LSL_Leaf *content)
1176 } 1176 }
1177} 1177}
1178 1178
1179static void doneParsing(LuaSL_compiler *compiler) 1179static boolean doneParsing(LuaSL_compiler *compiler)
1180{ 1180{
1181 gameGlobals *game = compiler->game; 1181 gameGlobals *game = compiler->game;
1182 boolean result = FALSE;
1182 1183
1183 if (compiler->ast) 1184 if (compiler->ast)
1184 { 1185 {
1185 FILE *out; 1186 FILE *out;
1186 char buffer[PATH_MAX]; 1187 char buffer[PATH_MAX];
1187 char outName[PATH_MAX]; 1188 char outName[PATH_MAX];
1189 char diffName[PATH_MAX];
1188 char luaName[PATH_MAX]; 1190 char luaName[PATH_MAX];
1189 1191
1190// outputLeaf(stdout, OM_LSL, compiler->ast); 1192// outputLeaf(stdout, OM_LSL, compiler->ast);
@@ -1194,6 +1196,8 @@ static void doneParsing(LuaSL_compiler *compiler)
1194 1196
1195 strcpy(outName, compiler->fileName); 1197 strcpy(outName, compiler->fileName);
1196 strcat(outName, "2"); 1198 strcat(outName, "2");
1199 strcpy(diffName, compiler->fileName);
1200 strcat(diffName, ".diff");
1197 strcpy(luaName, compiler->fileName); 1201 strcpy(luaName, compiler->fileName);
1198 strcat(luaName, ".lua"); 1202 strcat(luaName, ".lua");
1199 out = fopen(outName, "w"); 1203 out = fopen(outName, "w");
@@ -1204,12 +1208,13 @@ static void doneParsing(LuaSL_compiler *compiler)
1204#endif 1208#endif
1205 outputLeaf(out, OM_LSL, compiler->ast); 1209 outputLeaf(out, OM_LSL, compiler->ast);
1206 fclose(out); 1210 fclose(out);
1207 sprintf(buffer, "diff %s %s", compiler->fileName, outName); 1211 sprintf(buffer, "diff \"%s\" \"%s\" > \"%s\"", compiler->fileName, outName, diffName);
1208#ifdef LUASL_DIFF_CHECK 1212#ifdef LUASL_DIFF_CHECK
1209 count = system(buffer); 1213 count = system(buffer);
1210 PI("Return value of %s is %d", buffer, count);
1211 if (0 != count) 1214 if (0 != count)
1212 PE("%s says they are different!", buffer); 1215 PE("LSL output file is different - %s!", outName);
1216 else
1217 result = TRUE;
1213#endif 1218#endif
1214 } 1219 }
1215 else 1220 else
@@ -1223,9 +1228,11 @@ static void doneParsing(LuaSL_compiler *compiler)
1223 else 1228 else
1224 PC("Unable to open file %s for writing!", luaName); 1229 PC("Unable to open file %s for writing!", luaName);
1225 } 1230 }
1231
1232 return result;
1226} 1233}
1227 1234
1228Eina_Bool compilerSetup(gameGlobals *game) 1235boolean compilerSetup(gameGlobals *game)
1229{ 1236{
1230 int i; 1237 int i;
1231 1238
@@ -1252,17 +1259,17 @@ Eina_Bool compilerSetup(gameGlobals *game)
1252 snprintf(buf, sizeof(buf), "%s/src/constants.lsl", PACKAGE_DATA_DIR); 1259 snprintf(buf, sizeof(buf), "%s/src/constants.lsl", PACKAGE_DATA_DIR);
1253 compileLSL(game, buf, TRUE); 1260 compileLSL(game, buf, TRUE);
1254 1261
1255 return EINA_TRUE; 1262 return TRUE;
1256 } 1263 }
1257 else 1264 else
1258 PC("No memory for tokens!"); 1265 PC("No memory for tokens!");
1259 1266
1260 return EINA_FALSE; 1267 return FALSE;
1261} 1268}
1262 1269
1263Eina_Bool compileLSL(gameGlobals *game, char *script, boolean doConstants) 1270boolean compileLSL(gameGlobals *game, char *script, boolean doConstants)
1264{ 1271{
1265 Eina_Bool result = EINA_FALSE; 1272 boolean result = FALSE;
1266 LuaSL_compiler compiler; 1273 LuaSL_compiler compiler;
1267 void *pParser = ParseAlloc(malloc); 1274 void *pParser = ParseAlloc(malloc);
1268 int yv; 1275 int yv;
@@ -1345,10 +1352,11 @@ Eina_Bool compileLSL(gameGlobals *game, char *script, boolean doConstants)
1345 if (doConstants) 1352 if (doConstants)
1346 { 1353 {
1347 memcpy(&constants, &(compiler.script), sizeof(LSL_Script)); 1354 memcpy(&constants, &(compiler.script), sizeof(LSL_Script));
1355 result = TRUE;
1348 } 1356 }
1349 else 1357 else
1350 { 1358 {
1351 doneParsing(&compiler); 1359 result = doneParsing(&compiler);
1352 1360
1353// Take the result of the parse, and convert it into Lua source. 1361// Take the result of the parse, and convert it into Lua source.
1354// Each LSL script becomes a Lua state. 1362// Each LSL script becomes a Lua state.