summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/luat-cnf.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/luat-cnf.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/luat-cnf.lua91
1 files changed, 56 insertions, 35 deletions
diff --git a/Master/texmf-dist/tex/context/base/luat-cnf.lua b/Master/texmf-dist/tex/context/base/luat-cnf.lua
index 609dc412bcf..3672c603ece 100644
--- a/Master/texmf-dist/tex/context/base/luat-cnf.lua
+++ b/Master/texmf-dist/tex/context/base/luat-cnf.lua
@@ -30,22 +30,22 @@ texconfig.param_size = 25000 -- 60
texconfig.save_size = 50000 -- 4000
texconfig.stack_size = 10000 -- 300
---~ local function initialize()
---~ local t, variable = allocate(), resolvers.variable
---~ for name, default in next, variablenames do
---~ local name = variablenames[i]
---~ local value = variable(name)
---~ value = tonumber(value)
---~ if not value or value == "" or value == 0 then
---~ value = default
---~ end
---~ texconfig[name], t[name] = value, value
---~ end
---~ initialize = nil
---~ return t
---~ end
-
---~ luatex.variables = initialize()
+-- local function initialize()
+-- local t, variable = allocate(), resolvers.variable
+-- for name, default in next, variablenames do
+-- local name = variablenames[i]
+-- local value = variable(name)
+-- value = tonumber(value)
+-- if not value or value == "" or value == 0 then
+-- value = default
+-- end
+-- texconfig[name], t[name] = value, value
+-- end
+-- initialize = nil
+-- return t
+-- end
+--
+-- luatex.variables = initialize()
local stub = [[
@@ -71,9 +71,9 @@ function texconfig.init()
local builtin, globals = { }, { }
- libraries = { -- we set it her as we want libraries also 'indexed'
+ libraries = { -- we set it here as we want libraries also 'indexed'
basiclua = {
- "string", "table", "coroutine", "debug", "file", "io", "lpeg", "math", "os", "package",
+ "string", "table", "coroutine", "debug", "file", "io", "lpeg", "math", "os", "package", "bit32",
},
basictex = { -- noad
"callback", "font", "img", "lang", "lua", "node", "pdf", "status", "tex", "texconfig", "texio", "token",
@@ -88,6 +88,14 @@ function texconfig.init()
"fontforge", -- can be filled by luat-log
"kpse",
},
+ functions = {
+ "assert", "pcall", "xpcall", "error", "collectgarbage",
+ "dofile", "load","loadfile", "require", "module",
+ "getmetatable", "setmetatable",
+ "ipairs", "pairs", "rawequal", "rawget", "rawset", "next",
+ "tonumber", "tostring",
+ "type", "unpack", "select", "print",
+ },
builtin = builtin, -- to be filled
globals = globals, -- to be filled
}
@@ -96,46 +104,60 @@ function texconfig.init()
globals[k] = tostring(v)
end
- local function collect(t)
+ local function collect(t,fnc)
local lib = { }
for k, v in next, t do
- local keys = { }
- local gv = _G[v]
- if type(gv) == "table" then
- for k, v in next, gv do
- keys[k] = tostring(v) -- true -- by tostring we cannot call overloades functions (security)
+ if fnc then
+ lib[v] = _G[v]
+ else
+ local keys = { }
+ local gv = _G[v]
+ local tv = type(gv)
+ if tv == "table" then
+ for k, v in next, gv do
+ keys[k] = tostring(v) -- true -- by tostring we cannot call overloades functions (security)
+ end
end
+ lib[v] = keys
+ builtin[v] = keys
end
- lib[v] = keys
- builtin[v] = keys
end
return lib
end
- libraries.basiclua = collect(libraries.basiclua)
- libraries.basictex = collect(libraries.basictex)
- libraries.extralua = collect(libraries.extralua)
- libraries.extratex = collect(libraries.extratex)
- libraries.obsolete = collect(libraries.obsolete)
+ libraries.basiclua = collect(libraries.basiclua)
+ libraries.basictex = collect(libraries.basictex)
+ libraries.extralua = collect(libraries.extralua)
+ libraries.extratex = collect(libraries.extratex)
+ libraries.functions = collect(libraries.functions,true)
+ libraries.obsolete = collect(libraries.obsolete)
-- shortcut and helper
local function init(start)
local b = lua.bytecode
local i = start
+ local t = os.clock()
while b[i] do
b[i]() ;
b[i] = nil ;
i = i + 1
-- collectgarbage('step')
end
- return i - start
+ return i - start, os.clock() - t
end
-- the stored tables and modules
- storage.noftables = init(0)
- storage.nofmodules = init(%s)
+ storage.noftables , storage.toftables = init(0)
+ storage.nofmodules, storage.tofmodules = init(%s)
+
+ if modules then
+ local loaded = package.loaded
+ for module, _ in next, modules do
+ loaded[module] = true
+ end
+ end
end
@@ -149,7 +171,6 @@ end)
-- done, from now on input and callbacks are internal
]]
-
local variablenames = {
"error_line", "half_error_line",
"expand_depth", "hash_extra", "nest_size",