diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/expl3/l3alloc.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/expl3/l3alloc.dtx | 146 |
1 files changed, 72 insertions, 74 deletions
diff --git a/Master/texmf-dist/source/latex/expl3/l3alloc.dtx b/Master/texmf-dist/source/latex/expl3/l3alloc.dtx index 76f141a25b0..a2031c45493 100644 --- a/Master/texmf-dist/source/latex/expl3/l3alloc.dtx +++ b/Master/texmf-dist/source/latex/expl3/l3alloc.dtx @@ -1,5 +1,5 @@ % \iffalse -%% File: l3alloc.dtx Copyright (C) 1990-2006 LaTeX3 project +%% File: l3alloc.dtx Copyright (C) 1990-2006,2009 LaTeX3 project %% %% It may be distributed and/or modified under the conditions of the %% LaTeX Project Public License (LPPL), either version 1.3c of this @@ -17,7 +17,7 @@ %% %% The development version of the bundle can be found at %% -%% http://www.latex-project.org/cgi-bin/cvsweb.cgi/ +%% http://www.latex-project.org/svnroot/experimental/trunk/ %% %% for those people who are interested. %% @@ -36,7 +36,7 @@ \RequirePackage{l3names} %</driver|package> %\fi -\GetIdInfo$Id: l3alloc.dtx 621 2007-09-01 20:14:19Z morten $ +\GetIdInfo$Id: l3alloc.dtx 1362 2009-05-28 20:19:21Z joseph $ {L3 Experimental register allocation}% %\iffalse %<*driver> @@ -44,7 +44,7 @@ \ProvidesFile{\filename.\filenameext} [\filedate\space v\fileversion\space\filedescription] %\iffalse -\documentclass{l3doc} +\documentclass[full]{l3doc} \begin{document} \DocInput{\filename.\filenameext} \end{document} @@ -60,6 +60,8 @@ % \date{\filedate} % \maketitle % +% \begin{documentation} +% % \section{Allocating registers and the like} % % This module provides the basic mechanism for allocating \TeX's @@ -77,9 +79,9 @@ % \item The other registers (|\tex_count:D|, |\tex_dimen:D|, % |\tex_skip:D|, |\tex_muskip:D|, |\tex_box:D|, and |\tex_toks:D| % range from 0 to 32768, but registers numbered above 255 are -% accessed somewhat less efficient. +% accessed somewhat less efficiently. % \item Registers could be allocated both globally and locally; the -% use of regsiters could also be globaly or locally. Here we +% use of registers could also be globaly or locally. Here we % provide support for globally allocated registers for both % gloabl and local use and for locally allocated registers for % local use only. @@ -88,60 +90,67 @@ % register was allocated last and which registers can not be % allocated by the standard mechanisms. % -% \subsection{Functions} +% \section{Functions} % % \begin{function}{\alloc_setup_type:nnn} % \begin{syntax} -% "\alloc_setup_type:nnn" <type> <g_start_num> <l_start_num> +% "\alloc_setup_type:nnn" \Arg{type} \Arg{g_start_num} \Arg{l_start_num} % \end{syntax} % Sets up the storage needed for the administration of registers of % type <type>.\\ % <type> should be a token list in braces, it can be one of % "int", "dimen", "skip", "muskip", "box", "toks", "ior", "iow", % "pattern", or "ins".\\ -% <g_start_num> is the number of the first not allocated global +% <g_start_num> is the number of the first non-allocated global % register, it will be incremented by 1 when the allocation is done. -% <l_start_num> is the number of the first not allocated local +% <l_start_num> is the number of the first non-allocated local % register, it will be decremented by 1 when the allocation is done. % \end{function} % % \begin{function}{\alloc_reg:NnNN} % \begin{syntax} -% "\alloc_reg:NnNN" <g-l> <type> <alloc_cmd> <cs> +% "\alloc_reg:NnNN" "g"$\big/$"l" <type> <alloc_cmd> <cs> % \end{syntax} -% Performs the allocation of a register of type <type> to copntrol +% Performs the allocation of a register of type <type> to control % sequence <cs>, using the command <alloc_cmd>. The "g" or "l" -% indicaties whether the allocation should be global or local. +% indicates whether the allocation should be global or local. % This macro is the basic building block for the definition of the % "\"<type>"_new:N" commands % \end{function} % -% \StopEventually{} +% \end{documentation} % -% \subsection{The Implementation} +% \begin{implementation} % -% We start by ensuring that the required packages are loaded when -% this file is loaded as a package on top of \LaTeXe. +% \section{\pkg{l3alloc} implementation} % -% \begin{macrocode} -%<package>\ProvidesExplPackage -%<package> {\filename}{\filedate}{\fileversion}{\filedescription} -%<package>\RequirePackage{l3expan} -%<package>\RequirePackage{l3num} -%<package>\RequirePackage{l3seq}\par -% \end{macrocode} +% \subsection{Internal functions} % +% \begin{function}{ \alloc_next_g:n | +% \alloc_next_l:n } +% \begin{syntax} +% "\alloc_next_g:n" \Arg{type} +% \end{syntax} +% These functions find the next free register for the specified type. +% \end{function} +% +% \subsection{Module code} % % \begin{macrocode} +%<*package> +\ProvidesExplPackage + {\filename}{\filedate}{\fileversion}{\filedescription} +\package_check_loaded_expl: +%</package> %<*initex|package> % \end{macrocode} % % \begin{macro}{\alloc_setup_type:nnn} % For each type of register we need to `counters' that hold the % last allocated global or local register. We also need a sequence -% to store the `excpetions'. +% to store the `exceptions'. % \begin{macrocode} -\def_new:Npn \alloc_setup_type:nnn #1 #2 #3{ +\cs_new_nopar:Npn \alloc_setup_type:nnn #1 #2 #3{ \num_new:c {g_ #1 _allocation_num} \num_new:c {l_ #1 _allocation_num} \seq_new:c {g_ #1 _allocation_seq} @@ -156,27 +165,28 @@ % These routines find the next free register. For globally allocated % registers we first increment the counter that keeps track of them. % \begin{macrocode} -\def_new:Npn \alloc_next_g:n #1 { +\cs_new_nopar:Npn \alloc_next_g:n #1 { \num_gincr:c {g_ #1 _allocation_num} % \end{macrocode} % Then we need to check whether we have run out of registers. % \begin{macrocode} - \num_compare:cNcTF {g_ #1 _allocation_num} = {l_ #1 _allocation_num} - {\io_put_term:x{We~ ran~ out~ of~ registers~ of~ type~ g_#1!}} - { + \intexpr_compare:nTF { + \num_use:c{g_ #1 _allocation_num} = \num_use:c{l_ #1 _allocation_num} + } + {\iow_term:x{We~ ran~ out~ of~ registers~ of~ type~ g_#1!}} + { % \end{macrocode} -% We also need to check wether the value of the counter already +% We also need to check whether the value of the counter already % occurs in the list of already allocated registers. % \begin{macrocode} - \seq_if_in:cxTF {g_ #1 _allocation_seq} - {\num_use:c{g_ #1 _allocation_num}} - {\io_put_term:x{\num_use:c{g_ #1 _allocation_num}~Already~ allocated!} + \seq_if_in:cxT {g_ #1 _allocation_seq} + {\num_use:c{g_ #1 _allocation_num}} % \end{macrocode} % If it does, we find the next value. % \begin{macrocode} + { \iow_term:x{\num_use:c{g_ #1 _allocation_num}~already~allocated!} \alloc_next_g:n {#1} } - {\use_noop:} - } + } % \end{macrocode} % By now the |.._allocation_num| counter will contain the number of % the register we will assign a control seuence for. @@ -185,42 +195,47 @@ % \end{macrocode} % For the locally allocated registers we have a similar function. % \begin{macrocode} -\def_new:Npn \alloc_next_l:n #1 { +\cs_new_nopar:Npn \alloc_next_l:n #1 { \num_gdecr:c {l_ #1 _allocation_num} - \num_compare:cNcTF {g_ #1 _allocation_num} = {l_ #1 _allocation_num} - {\io_put_term:x{We~ ran~ out~ of~ registers~ of~ type~ l_#1!}} +% \end{macrocode} +% (Will: should that be "\num_decr" (no "g") ?!) +% \begin{macrocode} + \intexpr_compare:nTF { + \num_use:c{g_ #1 _allocation_num} = \num_use:c{l_ #1 _allocation_num} + } + {\iow_term:x{We~ ran~ out~ of~ registers~ of~ type~ l_#1!}} { \seq_if_in:cxTF {g_ #1 _allocation_seq} {\num_use:c{l_ #1 _allocation_num}} - {\io_put_term:x{\num_use:c{l_ #1 _allocation_num}~Already~ allocated!} + { \iow_term:x{\num_use:c{l_ #1 _allocation_num}~already~allocated!} \alloc_next_l:n {#1} } - {\io_put_term:x{\num_use:c{l_ #1 _allocation_num}~Free!}} - } + { \iow_term:x{\num_use:c{l_ #1 _allocation_num}~free!} } + } } % \end{macrocode} % \end{macro} % \end{macro} % % \begin{macro}{\alloc_reg:NnNN} -% This internal macro performs the actual allocation. It's first +% This internal macro performs the actual allocation. Its first % argument is either 'g' for a globally allocated register or `l' % for a locally allocated register. The second argument is the % type of register to allocate, the third argument is the command % to use and the fourth argument is the control sequence that is to % be defined to point to the register. % \begin{macrocode} -\def_new:Npn \alloc_reg:NnNN #1 #2 #3 #4{ +\cs_new_nopar:Npn \alloc_reg:NnNN #1 #2 #3 #4{ % \end{macrocode} % It first checks that the control sequence that is to denote the % register does not already exist. % \begin{macrocode} - \chk_new_cs:N #4 + \chk_if_free_cs:N #4 % \end{macrocode} % Next, it decides whether a prefix is needed for the allocation % command; % \begin{macrocode} - \if:w#1g - \exp_after:NN \pref_global:D + \if:w #1 g + \exp_after:wN \pref_global:D \fi: % \end{macrocode} % And finally the actual allocation takes place. @@ -230,45 +245,28 @@ % \end{macrocode} % All that's left to do is write a message in the log file. % \begin{macrocode} - \io_put_log:x{ - \token_to_string:N#4=#2~register~\num_use:c{#1_ #2 _allocation_num}} + \iow_log:x{ + \token_to_str:N#4=#2~register~\num_use:c{#1_ #2 _allocation_num}} % \end{macrocode} -% Finally, it calls |\alloc_next_<g/l>| to find the next free register +% Finally, it calls |\alloc_next_|\meta{\texttt{\textup g}/\texttt{\textup l}} to find the next free register % number. % \begin{macrocode} - \cs_use:c{alloc_next_#1:n} {#2} + \use:c{alloc_next_#1:n} {#2} } % \end{macrocode} % \end{macro} % +% \begin{macrocode} +%</initex|package> +% \end{macrocode} % % \begin{macrocode} %<*showmemory> \showMemUsage %</showmemory> -%</initex|package> % \end{macrocode} % -% \endinput -% -% $Log$ -% Revision 1.6 2006/03/20 18:26:32 braams -% Updated the copyright notice (2006) and demoted all implementation -% sections to subsections and so on to clean up the toc for source3.tex -% -% Revision 1.5 2006/01/15 14:02:58 braams -% Added a \SopEventually{} command -% -% Revision 1.4 2005/12/27 16:02:18 morten -% Changed RCS information retrieval -% -% Revision 1.3 2005/04/06 22:32:38 braams -% Removed the functins that belong in other modules; -% Fixed the naming conventions -% -% Revision 1.2 2005/04/05 22:12:44 braams -% First, working, version of the regsiter allocation support -% -% Revision 1.1 2005/03/16 22:50:02 braams -% Initial register allocation module +% \end{implementation} +% \PrintIndex % +% \endinput |