depgen: Combine preproc:symtable sym-ref generation cases

This does not impact performance, but it makes it less confusing.  What a
mess this whole thing is.  I'll have to incrementally refactor it until it
makes sense enough to optimize.

For this who don't know, from XSLT 1.0 days: "rtf" means "result tree
fragment", before sequences were a thing, and you had to treat generated
trees specially.  Yeah, old code.

DEV-15114
main
Mike Gerwitz 2023-10-18 16:28:42 -04:00
parent e20076235e
commit b3f92e0678
1 changed files with 52 additions and 71 deletions

View File

@ -142,7 +142,7 @@
<!-- grab the original source symbol for these references and augment them <!-- grab the original source symbol for these references and augment them
with any additional dependency metadata --> with any additional dependency metadata -->
<variable name="syms-rtf"> <variable name="syms" as="element( preproc:sym )*">
<for-each select="$uniq"> <for-each select="$uniq">
<variable name="name" select="@name" /> <variable name="name" select="@name" />
<variable name="sym" as="element( preproc:sym )?" <variable name="sym" as="element( preproc:sym )?"
@ -178,8 +178,6 @@
</for-each> </for-each>
</variable> </variable>
<variable name="syms" select="$syms-rtf/preproc:sym" />
<!-- only applicable if the symbol is @lax and the symbol was not <!-- only applicable if the symbol is @lax and the symbol was not
found in the local symbol table --> found in the local symbol table -->
<variable name="lax" select=" <variable name="lax" select="
@ -202,24 +200,17 @@
</for-each> </for-each>
<!-- @tex provided an non-empty, or function --> <!-- @tex provided an non-empty, or function -->
<for-each select=" <for-each select="$syms">
$syms[ <preproc:sym-ref>
( @tex and not( @tex='' ) )
or @type='func'
]">
<choose> <choose>
<!-- even if function, @tex overrides symbol --> <!-- even if function, @tex overrides symbol -->
<when test="@tex and not( @tex='' )"> <when test="@tex and not( @tex='' )">
<preproc:sym-ref tex="{@tex}"> <attribute name="tex" select="@tex" />
<sequence select="@*" /> <sequence select="@*" />
<sequence select="preproc:meta/@*" /> <sequence select="preproc:meta/@*" />
</preproc:sym-ref>
</when> </when>
<!-- must be a function; use its name --> <when test="@type = 'func'">
<otherwise>
<preproc:sym-ref>
<sequence select="@*" /> <sequence select="@*" />
<sequence select="preproc:meta/@*" /> <sequence select="preproc:meta/@*" />
@ -228,22 +219,12 @@
<value-of select="@name" /> <value-of select="@name" />
<text>}</text> <text>}</text>
</attribute> </attribute>
</preproc:sym-ref> </when>
</otherwise>
</choose>
</for-each>
<!-- no @tex, @tex empty, no function -->
<for-each select="
$syms[
( not( @tex ) or @tex='' )
and not( @type='func' )
]">
<otherwise>
<variable name="name" select="@name" /> <variable name="name" select="@name" />
<variable name="sym" select="." /> <variable name="sym" select="." />
<preproc:sym-ref>
<!-- minimal attribute copy (avoid data duplication as much as <!-- minimal attribute copy (avoid data duplication as much as
possible to reduce modification headaches later on) --> possible to reduce modification headaches later on) -->
<sequence select="@name, @parent" /> <sequence select="@name, @parent" />
@ -253,9 +234,7 @@
<variable name="pos" select="position()" /> <variable name="pos" select="position()" />
<attribute name="tex"> <attribute name="tex">
<variable name="texsym" select=" <variable name="texsym" select="
$tex-defaults/preproc:syms/preproc:sym[ $tex-defaults/preproc:syms/preproc:sym[ $pos ]
position() = $pos
]
" /> " />
<choose> <choose>
@ -285,6 +264,8 @@
</otherwise> </otherwise>
</choose> </choose>
</attribute> </attribute>
</otherwise>
</choose>
</preproc:sym-ref> </preproc:sym-ref>
</for-each> </for-each>
</preproc:sym-dep> </preproc:sym-dep>