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