summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/luat-cod.lmt
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2020-11-23 19:48:34 +0100
committerContext Git Mirror Bot <phg@phi-gamma.net>2020-11-23 19:48:34 +0100
commit18499e46a49b8ccf4346686d1cf626ada33935b8 (patch)
treebd0ae7b601b323e20954c10c07598637d9403e00 /tex/context/base/mkiv/luat-cod.lmt
parent4b089e589d39346a66a27d04f9857fe16e4b7b41 (diff)
downloadcontext-18499e46a49b8ccf4346686d1cf626ada33935b8.tar.gz
2020-11-23 18:39:00
Diffstat (limited to 'tex/context/base/mkiv/luat-cod.lmt')
-rw-r--r--tex/context/base/mkiv/luat-cod.lmt304
1 files changed, 0 insertions, 304 deletions
diff --git a/tex/context/base/mkiv/luat-cod.lmt b/tex/context/base/mkiv/luat-cod.lmt
deleted file mode 100644
index e4432345e..000000000
--- a/tex/context/base/mkiv/luat-cod.lmt
+++ /dev/null
@@ -1,304 +0,0 @@
-if not modules then modules = { } end modules ['luat-cod'] = {
- version = 1.001,
- comment = "companion to luat-cod.mkiv",
- author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
- copyright = "PRAGMA ADE / ConTeXt Development Team",
- license = "see context related readme files"
-}
-
-local type, loadfile, tonumber = type, loadfile, tonumber
-local match, gsub, find, format, gmatch = string.match, string.gsub, string.find, string.format, string.gmatch
-
-local texconfig, lua = texconfig, lua
-
--- maybe pick up from commandline:
---
--- texconfig.interaction: 0=batchmode 1=nonstopmode 2=scrollmode 3=errornonstopmode 4=normal
-
--- some basic housekeeping
-
-texconfig.kpse_init = false -- not needed in lmtx
-texconfig.shell_escape = 't' -- not needed in lmtx
-
-texconfig.max_in_open = 2000
-texconfig.nest_size = 10000
-texconfig.param_size = 100000
-texconfig.save_size = 500000
-texconfig.stack_size = 100000
-texconfig.buffer_size = 10000000
-texconfig.token_size = 10000000
-texconfig.node_size = 50000000
-
-texconfig.max_print_line = 100000
-texconfig.max_strings = 500000
-texconfig.max_pool = 10000000
-
-texconfig.hash_extra = 200000
-
-texconfig.expand_depth = 10000
-texconfig.function_size = 32768
-texconfig.properties_size = 10000
-texconfig.error_line = 250
-texconfig.half_error_line = 125
-
--- registering bytecode chunks
-
-local bytedata = lua.bytedata or { }
-local bytedone = lua.bytedone or { }
-
----.bytecode = bytecode
-lua.bytedata = bytedata
-lua.bytedone = bytedone
-
-local setbytecode = lua.setbytecode
------ getbytecode = lua.getbytecode
-
-lua.firstbytecode = 501
-lua.lastbytecode = lua.lastbytecode or (lua.firstbytecode - 1) -- as we load ourselves again ... maybe return earlier
-
-function lua.registeredcodes()
- return lua.lastbytecode - lua.firstbytecode + 1
-end
-
--- no file.* and utilities.parsers.* functions yet
-
-local strip = false if arg then for i=-1,#arg do if arg[i] == "--c:strip" then strip = true break end end end
-
-function lua.registercode(filename,options)
- local barename = gsub(filename,"%.[%a%d]+$","")
- local basename = match(barename,"^.+[/\\](.-)$") or barename
- if not bytedone[basename] then
- local opts = { }
- if type(options) == "string" and options ~= "" then
- for s in gmatch(options,"([a-z]+)") do
- opts[s] = true
- end
- end
- if barename == filename then
- filename = filename .. (opts.autosuffix and CONTEXTLMTXMODE > 0 and ".lmt" or ".lua")
- end
- local code = environment.luafilechunk(filename,false,opts.optimize)
- if code then
- bytedone[basename] = true
- if environment.initex and not opts.initexonly then
- local n = lua.lastbytecode + 1
- bytedata[n] = { name = barename, options = opts }
- if strip or opts.strip then
- setbytecode(n,code,true)
- else
- setbytecode(n,code)
- end
- lua.lastbytecode = n
- end
- elseif environment.initex then
- texio.write_nl(format("\nerror loading file: %s (aborting)",filename))
- os.exit()
- end
- 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 { }
-local environment = environment
-
--- no string.unquoted yet
-
-local sourcefile = gsub(arg and arg[1] or "","^\"(.*)\"$","%1")
-local sourcepath = find(sourcefile,"/",1,true) and gsub(sourcefile,"/[^/]+$","") or ""
-local targetpath = "."
-
--- delayed (via metatable):
---
--- environment.jobname = tex.jobname
--- environment.version = tostring(tex.toks.contextversiontoks)
-
--- traditionally the revision has been a one character string and only
--- pdftex went beyond "9" but anyway we test for it
-
-if LUATEXENGINE == nil then
- LUATEXENGINE = status.luatex_engine and string.lower(status.luatex_engine)
- or (find(status.banner,"LuajitTeX",1,true) and "luajittex" or "luatex")
-end
-
-if LUATEXVERSION == nil then
- LUATEXVERSION = status.luatex_version/100
- + tonumber(status.luatex_revision)/10000
-end
-
-if CONTEXTLMTXMODE == nil then
- CONTEXTLMTXMODE = LUATEXENGINE == "luametatex" and 1 or 0
-end
-
-if LUATEXFUNCTIONALITY == nil then
- LUATEXFUNCTIONALITY = status.development_id or 6346
-end
-
-if LUATEXFORMATID == nil then
- LUATEXFORMATID = status.format_id or 0
-end
-
-if JITSUPPORTED == nil then
- JITSUPPORTED = LUATEXENGINE == "luajittex" or jit -- "or jit" can go
-end
-
-if INITEXMODE == nil then
- INITEXMODE = status.ini_version
-end
-
-environment.luatexengine = LUATEXENGINE
-environment.luatexversion = LUATEXVERSION
-environment.luatexfunctionality = LUATEXFUNCTIONALITY
-environment.jitsupported = JITSUPPORTED
-environment.initex = INITEXMODE
-environment.initexmode = INITEXMODE
-
--- 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)
--- lua.setbytecode(1024,nil)
--- -- but we don't want to lie about the amount either so ...
--- end
-
-if not environment.luafilechunk then
-
- function environment.luafilechunk(filename)
- local fullname = filename
- if sourcepath ~= "" then
- fullname = sourcepath .. "/" .. filename
- end
- local data = loadfile(fullname)
- texio.write("terminal_and_logfile","<",data and "+ " or "- ",fullname,">")
- if data then
--- package.loaded[gsub(filename,"%..-$"] =
- data()
- end
- return data
- end
-
-end
-
-if not environment.engineflags then -- raw flags
-
- local engineflags = { }
-
- for i=-10,#arg do
- local a = arg[i]
- if a then
- local flag, content = match(a,"^%-%-([^=]+)=?(.-)$")
- if flag then
- engineflags[flag] = content or ""
- end
- end
- end
-
- environment.engineflags = engineflags
-
-end
-
--- We need a few premature callbacks in the format generator. We
--- also do this when the format is loaded as otherwise we get
--- a kpse error when disabled. This is an engine issue that will
--- be sorted out in due time.
-
--- print("!!!!!!!!!!!!!!!!!!!!!!",lfs.isfile) os.exit()
-
-if not lfs.isfile then
-
- local attributes = lfs.attributes
-
- function lfs.isdir(name)
- return attributes(name,"mode") == "directory"
- end
-
- function lfs.isfile(name)
- local a = attributes(name,"mode")
- return a == "file" or a == "link" or nil
- end
-
-end
-
-local isfile = lfs.isfile
-
-local function source_file(name)
- local fullname = sourcepath .. "/" .. name
- if isfile(fullname) then
- return fullname
- end
- fullname = fullname .. ".tex"
- if isfile(fullname) then
- return fullname
- end
- if isfile(name) then
- return name
- end
- name = name .. ".tex"
- if isfile(name) then
- return name
- end
- return nil
-end
-
-local function target_file(name)
- return targetpath .. "/" .. name
-end
-
-local function find_log_file(name)
- return target_file(name)
-end
-
-local function find_data_file(name)
- return source_file(name)
-end
-
-local function open_data_file(name)
- local fullname = source_file(name)
- if fullname then
- local f = io.open(fullname,'rb')
- return {
- reader = function()
- return f:read("*line")
- end
- }
- else
- return false
- end
-end
-
-callback.register('find_log_file', find_log_file)
-callback.register('find_data_file' , find_data_file )
-callback.register('open_data_file' , open_data_file )
-
-callback.register("trace_memory", function(what,success)
- success = success and "succeeded" or "failed"
- if logs then
- logs.report("tex memory","bumping category %a %s, details: %s",
- what,success,table.sequenced(status["get"..what.."state"]()))
- elseif texio then
- texio.write_nl(format("bumping tex '%s' memory %s",
- what,success))
- end
- -- os.exit()
-end)