diff options
Diffstat (limited to 'tex/context/base/mkxl/luat-cod.lmt')
-rw-r--r-- | tex/context/base/mkxl/luat-cod.lmt | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/tex/context/base/mkxl/luat-cod.lmt b/tex/context/base/mkxl/luat-cod.lmt index 7047726b5..2e5fa8062 100644 --- a/tex/context/base/mkxl/luat-cod.lmt +++ b/tex/context/base/mkxl/luat-cod.lmt @@ -99,28 +99,6 @@ function lua.registercode(filename,options) end end -local finalizers = { } - -function lua.registerfinalizer(f,comment) - comment = comment or "unknown" - if type(f) == "function" then - finalizers[#finalizers+1] = { action = f, comment = comment } - else - print(format("\nfatal error: invalid finalizer, action: %s\n",comment)) - os.exit() - end -end - -function lua.finalize(logger) - for i=1,#finalizers do - local finalizer = finalizers[i] - finalizer.action() - if logger then - logger("finalize action: %s",finalizer.comment) - end - end -end - -- A first start with environments. This will be overloaded later. environment = environment or { } @@ -175,6 +153,37 @@ environment.jitsupported = JITSUPPORTED environment.initex = INITEXMODE environment.initexmode = INITEXMODE +if INITEXMODE then + + local finalizers = { } + + function lua.registerinitexfinalizer(f,comment) + comment = comment or "unknown" + if type(f) == "function" then + finalizers[#finalizers+1] = { action = f, comment = comment } + else + print(format("\nfatal error: invalid finalizer, action: %s\n",comment)) + os.exit() + end + end + + function lua.finalizeinitex(logger) + for i=1,#finalizers do + local finalizer = finalizers[i] + finalizer.action() + if logger then + logger("finalize action: %s",finalizer.comment) + end + end + end + +else + + function lua.registerinitexfinalizer() end + function lua.finalizeinitex () end + +end + -- if INITEXMODE then -- -- we have about that amount so we preallocate then which gives less -- -- reallocations (we're talking tiny record so no real gain) |