aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/LuaSL
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-08-10 04:18:04 +1000
committerDavid Walter Seikel2014-08-10 04:18:04 +1000
commitbda78b998894dbf00447014c95e34e125f33c9c7 (patch)
tree12dffbed3378766f44603886cf348a35fb0d29b7 /src/LuaSL
parentGot most of the LSL constants now, except the OS ones. (diff)
downloadSledjHamr-bda78b998894dbf00447014c95e34e125f33c9c7.zip
SledjHamr-bda78b998894dbf00447014c95e34e125f33c9c7.tar.gz
SledjHamr-bda78b998894dbf00447014c95e34e125f33c9c7.tar.bz2
SledjHamr-bda78b998894dbf00447014c95e34e125f33c9c7.tar.xz
Quick and dirty crashing compiler catcher.
Diffstat (limited to 'src/LuaSL')
-rw-r--r--src/LuaSL/LuaSL_LSL_tree.h1
-rw-r--r--src/LuaSL/LuaSL_compile.c13
2 files changed, 13 insertions, 1 deletions
diff --git a/src/LuaSL/LuaSL_LSL_tree.h b/src/LuaSL/LuaSL_LSL_tree.h
index b95b82e..30a12f5 100644
--- a/src/LuaSL/LuaSL_LSL_tree.h
+++ b/src/LuaSL/LuaSL_LSL_tree.h
@@ -4,6 +4,7 @@
4 4
5#define LUASL_DEBUG 0 5#define LUASL_DEBUG 0
6#define LUASL_DIFF_CHECK 0 6#define LUASL_DIFF_CHECK 0
7#define LUASL_BAD_CHECK 0
7 8
8 9
9#include <stddef.h> // So we can have NULL defined. 10#include <stddef.h> // So we can have NULL defined.
diff --git a/src/LuaSL/LuaSL_compile.c b/src/LuaSL/LuaSL_compile.c
index 94d7f9b..5da2724 100644
--- a/src/LuaSL/LuaSL_compile.c
+++ b/src/LuaSL/LuaSL_compile.c
@@ -2224,6 +2224,9 @@ boolean compilerSetup(gameGlobals *ourGlobals)
2224boolean compileLSL(LuaSL_compiler *compiler) 2224boolean compileLSL(LuaSL_compiler *compiler)
2225{ 2225{
2226 void *pParser = ParseAlloc(malloc); 2226 void *pParser = ParseAlloc(malloc);
2227#if LUASL_BAD_CHECK
2228 char tempName[PATH_MAX];
2229#endif
2227 int yv; 2230 int yv;
2228 2231
2229// Parse the LSL script, validating it and reporting errors. 2232// Parse the LSL script, validating it and reporting errors.
@@ -2246,6 +2249,12 @@ boolean compileLSL(LuaSL_compiler *compiler)
2246 PE("Error opening file %s.", compiler->compiler.file); 2249 PE("Error opening file %s.", compiler->compiler.file);
2247 return FALSE; 2250 return FALSE;
2248 } 2251 }
2252#if LUASL_BAD_CHECK
2253 // Mark the file as bad, in case we crash while compiling it.
2254 // NOTE - wont work so well when we are threaded.
2255 sprintf(tempName, "%s.BAD", compiler->compiler.file);
2256 ecore_file_mv(compiler->compiler.file, tempName);
2257#endif
2249 compiler->ast = NULL; 2258 compiler->ast = NULL;
2250 compiler->lval = newLeaf(LSL_UNKNOWN, NULL, NULL); 2259 compiler->lval = newLeaf(LSL_UNKNOWN, NULL, NULL);
2251 // Text editors usually start counting at 1, even programmers editors. mcedit is an exception, but you can deal with that yourself. 2260 // Text editors usually start counting at 1, even programmers editors. mcedit is an exception, but you can deal with that yourself.
@@ -2382,7 +2391,9 @@ boolean compileLSL(LuaSL_compiler *compiler)
2382 2391
2383 if (!compiler->doConstants) 2392 if (!compiler->doConstants)
2384 burnLeaf(compiler->ast); 2393 burnLeaf(compiler->ast);
2385// end compile thread here
2386 2394
2395#if LUASL_BAD_CHECK
2396 ecore_file_mv(tempName, compiler->compiler.file);
2397#endif
2387 return compiler->result; 2398 return compiler->result;
2388} 2399}