summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkiv/node-tsk.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/node-tsk.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/mkiv/node-tsk.lua609
1 files changed, 133 insertions, 476 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-tsk.lua b/Master/texmf-dist/tex/context/base/mkiv/node-tsk.lua
index 0378c14c62a..1ce7ab1dc85 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/node-tsk.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/node-tsk.lua
@@ -52,21 +52,19 @@ end
function tasks.new(specification) -- was: name,arguments,list
local name = specification.name
+ local arguments = specification.arguments or 0
local sequence = specification.sequence
if name and sequence then
local tasklist = newsequencer {
- name = name
-- we can move more to the sequencer now .. todo
}
tasksdata[name] = {
- name = name,
list = tasklist,
runner = false,
+ arguments = arguments,
+ -- sequence = sequence,
frozen = { },
- processor = specification.processor or nodeprocessor,
- -- could be metatable but best freeze it
- arguments = specification.arguments or 0,
- templates = specification.templates,
+ processor = specification.processor or nodeprocessor
}
for l=1,#sequence do
appendgroup(tasklist,sequence[l])
@@ -172,26 +170,18 @@ function tasks.disablegroup(name,group)
end
end
-function tasks.appendaction(name,group,action,where,kind,state)
+function tasks.appendaction(name,group,action,where,kind)
local data = validgroup(name,"append action")
if data then
- local list = data.list
- appendaction(list,group,action,where,kind)
- if state == "disabled" or (state == "production" and environment.initex) then
- disableaction(list,action)
- end
+ appendaction(data.list,group,action,where,kind)
data.runner = false
end
end
-function tasks.prependaction(name,group,action,where,kind,state)
+function tasks.prependaction(name,group,action,where,kind)
local data = validgroup(name,"prepend action")
if data then
- local list = data.list
- prependaction(list,group,action,where,kind)
- if state == "disabled" or (state == "production" and environment.initex) then
- disableaction(list,action)
- end
+ prependaction(data.list,group,action,where,kind)
data.runner = false
end
end
@@ -226,29 +216,112 @@ statistics.register("node list callback tasks", function()
end
end)
-local function create(data,t)
- created = created + 1
- local runner = compile(data.list,data.processor,t)
- if trace_tasks then
- report_tasks("creating runner %a, %i actions enabled",t.name,data.list.steps or 0)
- end
- data.runner = runner
- return runner
-end
-
-function tasks.actions(name)
+function tasks.actions(name) -- we optimize for the number or arguments (no ...)
local data = tasksdata[name]
if data then
- local t = data.templates
- if t then
- t.name = data.name
- return function(...)
- total = total + 1
- return (data.runner or create(data,t))(...)
+ local n = data.arguments or 0
+ if n == 0 then
+ return function(head)
+ total = total + 1 -- will go away
+ local runner = data.runner
+ if not runner then
+ created = created + 1
+ if trace_tasks then
+ report_tasks("creating runner %a",name)
+ end
+ runner = compile(data.list,data.processor,0)
+ data.runner = runner
+ end
+ return runner(head)
+ end
+ elseif n == 1 then
+ return function(head,one)
+ total = total + 1 -- will go away
+ local runner = data.runner
+ if not runner then
+ created = created + 1
+ if trace_tasks then
+ report_tasks("creating runner %a with %s extra arguments",name,1)
+ end
+ runner = compile(data.list,data.processor,1)
+ data.runner = runner
+ end
+ return runner(head,one)
+ end
+ elseif n == 2 then
+ return function(head,one,two)
+ total = total + 1 -- will go away
+ local runner = data.runner
+ if not runner then
+ created = created + 1
+ if trace_tasks then
+ report_tasks("creating runner %a with %s extra arguments",name,2)
+ end
+ runner = compile(data.list,data.processor,2)
+ data.runner = runner
+ end
+ return runner(head,one,two)
+ end
+ elseif n == 3 then
+ return function(head,one,two,three)
+ total = total + 1 -- will go away
+ local runner = data.runner
+ if not runner then
+ created = created + 1
+ if trace_tasks then
+ report_tasks("creating runner %a with %s extra arguments",name,3)
+ end
+ runner = compile(data.list,data.processor,3)
+ data.runner = runner
+ end
+ return runner(head,one,two,three)
+ end
+ elseif n == 4 then
+ return function(head,one,two,three,four)
+ total = total + 1 -- will go away
+ local runner = data.runner
+ if not runner then
+ created = created + 1
+ if trace_tasks then
+ report_tasks("creating runner %a with %s extra arguments",name,4)
+ end
+ runner = compile(data.list,data.processor,4)
+ data.runner = runner
+ end
+ return runner(head,one,two,three,four)
+ end
+ elseif n == 5 then
+ return function(head,one,two,three,four,five)
+ total = total + 1 -- will go away
+ local runner = data.runner
+ if not runner then
+ created = created + 1
+ if trace_tasks then
+ report_tasks("creating runner %a with %s extra arguments",name,5)
+ end
+ runner = compile(data.list,data.processor,5)
+ data.runner = runner
+ end
+ return runner(head,one,two,three,four,five)
+ end
+ else
+ return function(head,...)
+ total = total + 1 -- will go away
+ local runner = data.runner
+ if not runner then
+ created = created + 1
+ if trace_tasks then
+ report_tasks("creating runner %a with %s extra arguments",name,n)
+ end
+ runner = compile(data.list,data.processor,"n")
+ data.runner = runner
+ end
+ return runner(head,...)
end
end
+ else
+ return nil
end
- return nil
end
function tasks.table(name) --maybe move this to task-deb.lua
@@ -278,132 +351,12 @@ function tasks.table(name) --maybe move this to task-deb.lua
end
end
--- -- shipouts everypar -- --
-
--- the shipout handlers acts on boxes so we don't need to return something
--- and also don't need to keep the state (done)
-
-local templates = {
-
-default = [[
-return function(head)
- return head
-end
-]],
-
-process = [[
-local tonut = nodes.tonut
-local tonode = nodes.nuts.tonode
-
-%localize%
-
-return function(head)
- local nuthead = tonut(head)
-
-%actions%
- return tonode(nuthead)
-end
-]],
-
-step = [[
- nuthead = tonut((%action%(tonode(nuthead))))
-]],
-
-nut = [[
- nuthead = %action%(nuthead)
-]],
-
-nohead = [[
- %action%(tonode(nuthead))
-]],
-
-nonut = [[
- %action%(nuthead)
-]],
-
-}
-
-tasks.new {
- name = "shipouts",
- processor = nodeprocessor,
- sequence = {
- "before", -- users
- "normalizers", -- system
- "finishers", -- system
- "after", -- users
- "wrapup", -- system
- },
- templates = templates
-}
-
-tasks.new {
- name = "everypar",
- processor = nodeprocessor,
- sequence = {
- "before", -- users
- "normalizers", -- system
- "after", -- users
- },
- templates = templates,
-}
-
--- -- finalizers -- --
-
-tasks.new {
- name = "finalizers",
- sequence = {
- "before", -- for users
- "normalizers",
- "fonts",
- "lists",
- "after", -- for users
- },
- processor = nodeprocessor,
- templates = {
-
-default = [[
-return function(head)
- return head
-end
-]],
-
-process = [[
-local tonut = nodes.tonut
-local tonode = nodes.nuts.tonode
-
-%localize%
-
-return function(head,groupcode)
- local nuthead = tonut(head)
-
-%actions%
- return tonode(nuthead)
-end
-]],
-
-step = [[
- nuthead = tonut((%action%(tonode(nuthead),groupcode)))
-]],
-
-nut = [[
- nuthead = %action%(nuthead,groupcode)
-]],
-
-nohead = [[
- %action%(tonode(nuthead),groupcode)
-]],
-
-nonut = [[
- %action%(nuthead,groupcode)
-]],
-
- }
-}
-
--- -- processors -- --
+-- this will move
tasks.new {
name = "processors",
+ arguments = 5, -- often only the first is used, and the last three are only passed in hpack filter
+-- arguments = 2,
processor = nodeprocessor,
sequence = {
"before", -- for users
@@ -413,297 +366,56 @@ tasks.new {
"fonts",
"lists",
"after", -- for users
- },
- templates = {
-
-default = [[
-return function(head)
- return head
-end
-]],
-
-process = [[
-local tonut = nodes.tonut
-local tonode = nodes.nuts.tonode
-
-%localize%
-
-return function(head,groupcode,size,packtype,direction,attributes)
- local nuthead = tonut(head)
-
-%actions%
- return tonode(nuthead)
-end
-]],
-
-step = [[
- nuthead = tonut((%action%(tonode(nuthead),groupcode,size,packtype,direction,attributes)))
-]],
-
-nut = [[
- nuthead = %action%(nuthead,groupcode,size,packtype,direction,attributes)
-]],
-
-nohead = [[
- %action%(tonode(nuthead),groupcode,size,packtype,direction,attributes)
-]],
-
-nonut = [[
- %action%(nuthead,groupcode,size,packtype,direction,attributes)
-]],
-
}
}
tasks.new {
name = "finalizers",
+ arguments = 1,
processor = nodeprocessor,
sequence = {
"before", -- for users
"normalizers",
+-- "characters",
+-- "finishers",
"fonts",
"lists",
"after", -- for users
- },
- templates = {
-
-default = [[
-return function(head)
- return head
-end
-]],
-
-process = [[
-local tonut = nodes.tonut
-local tonode = nodes.nuts.tonode
-
-%localize%
-
-return function(head)
- local nuthead = tonut(head)
-
-%actions%
- return tonode(nuthead)
-end
-]],
-
-step = [[
- nuthead = tonut((%action%(tonode(nuthead))))
-]],
-
-nut = [[
- nuthead = %action%(nuthead)
-]],
-
-nohead = [[
- %action%(tonode(nuthead))
-]],
-
-nonut = [[
- %action%(nuthead)
-]],
-
}
}
tasks.new {
- name = "mvlbuilders",
+ name = "shipouts",
+ arguments = 1,
+ -- nostate = true, -- maybe but only for main ones so little gain
processor = nodeprocessor,
sequence = {
"before", -- for users
"normalizers",
+ "finishers",
"after", -- for users
- },
- templates = {
-
-default = [[
-return function(head)
- return head
-end
-]],
-
-process = [[
-local tonut = nodes.tonut
-local tonode = nodes.nuts.tonode
-
-%localize%
-
-return function(head,groupcode)
- local nuthead = tonut(head)
-
-%actions%
- return tonode(nuthead)
-end
-]],
-
-step = [[
- nuthead = tonut((%action%(tonode(nuthead),groupcode)))
-]],
-
-nut = [[
- nuthead = %action%(nuthead,groupcode)
-]],
-
-nohead = [[
- %action%(tonode(nuthead),groupcode)
-]],
-
-nonut = [[
- %action%(nuthead,groupcode)
-]],
-
}
}
tasks.new {
- name = "vboxbuilders",
+ name = "mvlbuilders",
+ arguments = 1,
processor = nodeprocessor,
sequence = {
"before", -- for users
"normalizers",
"after", -- for users
- },
- templates = {
-
-default = [[
-return function(head)
- return head
-end
-]],
-
-process = [[
-local tonut = nodes.tonut
-local tonode = nodes.nuts.tonode
-
-%localize%
-
-return function(head,groupcode,size,packtype,maxdepth,direction)
- local nuthead = tonut(head)
-
-%actions%
- return tonode(nuthead)
-end
-]],
-
-step = [[
- nuthead = tonut((%action%(tonode(nuthead),groupcode,size,packtype,maxdepth,direction)))
-]],
-
-nut = [[
- nuthead = %action%(nuthead,groupcode,size,packtype,maxdepth,direction)
-]],
-
-nohead = [[
- %action%(tonode(nuthead),groupcode,size,packtype,maxdepth,direction)
-]],
-
-nonut = [[
- %action%(nuthead,groupcode,size,packtype,maxdepth,direction)
-]],
-
}
-
}
tasks.new {
- name = "contributers",
+ name = "vboxbuilders",
+ arguments = 5,
processor = nodeprocessor,
sequence = {
"before", -- for users
"normalizers",
"after", -- for users
- },
- templates = {
-
-default = [[
-return function(head)
- return head
-end
-]],
-
-process = [[
-local tonut = nodes.tonut
-local tonode = nodes.nuts.tonode
-
-%localize%
-
-return function(head,groupcode,line)
- local nuthead = tonut(head)
- local nutline = tonut(line)
-
-%actions%
- return tonode(nuthead)
-end
-]],
-
-step = [[
- nuthead = tonut((%action%(tonode(nuthead),groupcode,line)))
-]],
-
-nut = [[
- nuthead = %action%(nuthead,groupcode,nutline)
-]],
-
-nohead = [[
- %action%(tonode(nuthead),groupcode,line)
-]],
-
-nonut = [[
- %action%(nuthead,groupcode,nutline)
-]],
-
- }
-}
-
--- -- math -- --
-
-tasks.new {
- name = "math",
- processor = nodeprocessor,
- sequence = {
- "before",
- "normalizers",
- "builders",
- "after",
- },
- templates = {
-
-default = [[
-return function(head)
- return head
-end
-]],
-
-process = [[
-local tonut = nodes.tonut
-local tonode = nodes.nuts.tonode
-
-%localize%
-
-return function(head,style,penalties)
- local nuthead = tonut(head)
-
-%actions%
- return tonode(nuthead)
-end
-]],
-
-step = [[
- nuthead = tonut((%action%(tonode(nuthead),style,penalties)))
-]],
-
-nut = [[
- nuthead = %action%(nuthead,style,penalties)
-]],
-
-nohead = [[
- %action%(tonode(nuthead),style,penalties)
-]],
-
-nonut = [[
- %action%(nuthead,style,penalties)
-]],
-
}
}
@@ -729,69 +441,14 @@ nonut = [[
-- }
-- }
--- for now quite useless (too fuzzy)
---
--- tasks.new {
--- name = "listbuilders",
--- processor = nodeprocessor,
--- sequence = {
--- "before", -- for users
--- "normalizers",
--- "after", -- for users
--- },
--- templates = {
--- -- we don't need a default
--- default = [[
--- return function(box,location,prevdepth)
--- return box, prevdepth
--- end
--- ]],
--- process = [[
--- %localize%
--- return function(box,location,prevdepth,mirrored)
--- %actions%
--- return box, prevdepth
--- end
--- ]],
--- step = [[
--- box, prevdepth = %action%(box,location,prevdepth,mirrored)
--- ]],
--- },
--- }
-
--- -- math -- --
-
--- not really a node processor
+tasks.new {
+ name = "contributers",
+ arguments = 2, -- [head] where parent
+ processor = nodeprocessor,
+ sequence = {
+ "before", -- for users
+ "normalizers",
+ "after", -- for users
+ }
+}
--- tasks.new {
--- name = "newpar",
--- processor = nodeprocessor,
--- sequence = {
--- "before",
--- "normalizers",
--- "after",
--- },
--- templates = {
---
--- default = [[
--- return function(mode,indent)
--- return indent
--- end
--- ]],
---
--- process = [[
--- %localize%
---
--- return function(mode,indent)
---
--- %actions%
--- return indent
--- end
--- ]],
---
--- step = [[
--- indent = %action%(mode,indent)
--- ]],
---
--- }
--- }