diff options
Diffstat (limited to 'tex/context/base/mkiv/core-env.lua')
-rw-r--r-- | tex/context/base/mkiv/core-env.lua | 84 |
1 files changed, 29 insertions, 55 deletions
diff --git a/tex/context/base/mkiv/core-env.lua b/tex/context/base/mkiv/core-env.lua index da10c26f5..1c5165ac8 100644 --- a/tex/context/base/mkiv/core-env.lua +++ b/tex/context/base/mkiv/core-env.lua @@ -47,13 +47,12 @@ local cache = tokens.cache local iftrue = cache["iftrue"].mode -local dimencode = cache["scratchdimen"] .command -- tokens.commands.assign_dimen -local countcode = cache["scratchcounter"] .command -- tokens.commands.assign_int -local tokencode = cache["scratchtoken"] .command -- tokens.commands.assign_toks -local skipcode = cache["scratchskip"] .command -- tokens.commands.assign_glue -local muskipcode = cache["scratchmuskip"] .command -- tokens.commands.assign_mu_glue ------ attributecode = cache["scratchattribute"].command -- tokens.commands.assign_attr -local conditioncode = cache["iftrue"] .command -- tokens.commands.if_test +local dimencode = cache["scratchdimen"] .command -- tokens.commands.register_dimen +local countcode = cache["scratchcounter"].command -- tokens.commands.register_int +local tokencode = cache["scratchtoks"] .command -- tokens.commands.register_toks +local skipcode = cache["scratchskip"] .command -- tokens.commands.register_glue +local muskipcode = cache["scratchmuskip"] .command -- tokens.commands.register_mu_glue +local conditioncode = cache["iftrue"] .command -- tokens.commands.if_test local types = { [dimencode] = "dimen", @@ -82,10 +81,6 @@ setmetatableindex(texmodes, function(t,k) end end) -setmetatablenewindex(texmodes, function(t,k) - report_mode("you cannot set the %s named %a this way","mode",k) -end) - setmetatableindex(texsystemmodes, function(t,k) local m = systemmodes[k] if m then @@ -101,59 +96,38 @@ setmetatableindex(texsystemmodes, function(t,k) end end) -setmetatablenewindex(texsystemmodes, function(t,k) - report_mode("you cannot set the %s named %a this way","systemmode",k) -end) - -setmetatablenewindex(texconstants, function(t,k) - report_mode("you cannot set the %s named %a this way","constant",k) -end) - -setmetatablenewindex(texconditionals, function(t,k) - report_mode("you cannot set the %s named %a this way","conditional",k) -end) - -setmetatablenewindex(texifs, function(t,k) - -- just ignore -end) +do -- we could do the same as in lmtx (use the mode) -if CONTEXTLMTXMODE > 0 then + local trialtypesettingstate = createtoken("trialtypesettingstate").index + local texgetcount = tex.getcount - iftrue = cache["iftrue"].index - - -- if we really need performance we can have a dedicated cache for each - -- kind of variable - - setmetatableindex(texconstants, function(t,k) - return cache[k].command == countcode and texgetcount(k) or 0 + context.settrialtypesettingmethod(function() + return texgetcount(trialtypesettingstate) ~= 0 end) - setmetatableindex(texconditionals, function(t,k) -- 0 == true - return cache[k].command == countcode and texgetcount(k) == 0 - end) - - setmetatableindex(texifs, function(t,k) - local c = cache[k] - print(k) - inspect(c) - return c.command == conditioncode and c.index == iftrue - end) +end -else +setmetatablenewindex(texmodes, function(t,k) report_mode("you cannot set the %s named %a this way","mode", k) end) +setmetatablenewindex(texsystemmodes, function(t,k) report_mode("you cannot set the %s named %a this way","systemmode", k) end) +setmetatablenewindex(texconstants, function(t,k) report_mode("you cannot set the %s named %a this way","constant", k) end) +setmetatablenewindex(texconditionals, function(t,k) report_mode("you cannot set the %s named %a this way","conditional",k) end) +setmetatablenewindex(texifs, function(t,k) end) - setmetatableindex(texconstants, function(t,k) - return cache[k].mode ~= 0 and texgetcount(k) or 0 - end) +setmetatablenewindex(texifs, function(t,k) + -- just ignore +end) - setmetatableindex(texconditionals, function(t,k) -- 0 == true - return cache[k].mode ~= 0 and texgetcount(k) == 0 - end) +setmetatableindex(texconstants, function(t,k) + return cache[k].mode ~= 0 and texgetcount(k) or 0 +end) - setmetatableindex(texifs, function(t,k) - return cache[k].mode == iftrue - end) +setmetatableindex(texconditionals, function(t,k) -- 0 == true + return cache[k].mode ~= 0 and texgetcount(k) == 0 +end) -end +setmetatableindex(texifs, function(t,k) + return cache[k].mode == iftrue +end) tex.isdefined = isdefined |