From 56ef10c8934f9b2757e4c8da46588386f57d33fa Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sun, 13 Jan 2013 16:40:07 +0000 Subject: [PATCH] Lunatic translator: handle -mx. git-svn-id: https://svn.eduke32.com/eduke32@3388 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/lunatic/defs.ilua | 15 ++++++++++++++- polymer/eduke32/source/lunatic/dynsymlist | 3 +++ polymer/eduke32/source/lunatic/lunacon.lua | 19 ++++++++++++------- .../source/lunatic/test/nlcf_return.con | 6 +++--- 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/polymer/eduke32/source/lunatic/defs.ilua b/polymer/eduke32/source/lunatic/defs.ilua index a51e7ab31..bdc5db486 100644 --- a/polymer/eduke32/source/lunatic/defs.ilua +++ b/polymer/eduke32/source/lunatic/defs.ilua @@ -494,6 +494,9 @@ int32_t kfilelength(int32_t handle); void kclose(int32_t handle); int32_t kread(int32_t handle, void *buffer, int32_t leng); +char **g_scriptModules; +int32_t g_scriptModulesNum; + const char *G_ConFile(void); void G_DoGameStartup(const int32_t *params); int32_t C_DefineSound(int32_t sndidx, const char *fn, int32_t args[5]); @@ -1139,7 +1142,17 @@ do read_into_string = readintostr -- for lunacon local lunacon = require("lunacon") - local confn = ffi.string(ffiC.G_ConFile()) + local confn = { ffi.string(ffiC.G_ConFile()) } + + local nummods = ffiC.g_scriptModulesNum + if (nummods > 0) then + assert(ffiC.g_scriptModules ~= nil) + + for i=1,nummods do + confn[i+1] = ffi.string(ffiC.g_scriptModules[i-1]) + end + end + concode = lunacon.compile(confn) end diff --git a/polymer/eduke32/source/lunatic/dynsymlist b/polymer/eduke32/source/lunatic/dynsymlist index 8adf48a63..3c75a152b 100644 --- a/polymer/eduke32/source/lunatic/dynsymlist +++ b/polymer/eduke32/source/lunatic/dynsymlist @@ -63,6 +63,9 @@ kfilelength; kclose; kread; +g_scriptModules; +g_scriptModulesNum; + G_ConFile; G_DoGameStartup; C_DefineSound; diff --git a/polymer/eduke32/source/lunatic/lunacon.lua b/polymer/eduke32/source/lunatic/lunacon.lua index aa86f3c3b..ccbbcacc0 100644 --- a/polymer/eduke32/source/lunatic/lunacon.lua +++ b/polymer/eduke32/source/lunatic/lunacon.lua @@ -13,6 +13,7 @@ local table = require("table") local arg = arg local assert = assert +local ipairs = ipairs local pairs = pairs local pcall = pcall local print = print @@ -1930,15 +1931,19 @@ if (string.dump) then end else -- running from EDuke32 - function compile(filename) + function compile(filenames) -- TODO: pathsearchmode=1 set in G_CompileScripts + reset_all() - local ok, msg = pcall(do_include_file, "", filename) - if (not ok) then - print_on_failure(msg) - return nil - else - return get_code_string(g_curcode) + + for _, fname in ipairs(filenames) do + local ok, msg = pcall(do_include_file, "", fname) + if (not ok) then + print_on_failure(msg) + return nil + end end + + return get_code_string(g_curcode) end end diff --git a/polymer/eduke32/source/lunatic/test/nlcf_return.con b/polymer/eduke32/source/lunatic/test/nlcf_return.con index 3b55be4fa..84923bbae 100644 --- a/polymer/eduke32/source/lunatic/test/nlcf_return.con +++ b/polymer/eduke32/source/lunatic/test/nlcf_return.con @@ -4,19 +4,19 @@ definequote 127 RAN TEST STATE state teststate1 return - userquote 127 + quote 127 ends onevent EVENT_EGS ifactor HEAVYHBOMB { state teststate1 // after teststate1's return, return from EVENT_EGS! - userquote 126 + quote 126 } endevent onevent EVENT_FIRE // the concrete actor is irrelevant, only placeholder spawn HEAVYHBOMB // --> EVENT_EGS - userquote 125 + quote 125 endevent