REMOVE ME: Use variables in place of object for generated class yields
This was a waste of time; it actually reduces performance slightly and increased GC, unintuitively enough. Leaving commit here and reverting to keep it for reference.master
parent
9784ef9326
commit
ec196146e2
|
@ -552,8 +552,10 @@
|
|||
<sequence select="$compiler:nl" />
|
||||
|
||||
<!-- simply alias the @yields -->
|
||||
<sequence select="concat( 'A[''', @yields, '''] = ',
|
||||
'A[''', $src, ''']; ')" />
|
||||
<sequence select="concat( compiler:class-yields-var(., false()), '=',
|
||||
compiler:sym-class-yields-var(
|
||||
$symtable-map( $src-sym/@parent ) ),
|
||||
'; ')" />
|
||||
|
||||
<variable name="class-sym" as="element( preproc:sym )"
|
||||
select="$symtable-map( $src-sym/@parent )" />
|
||||
|
@ -596,7 +598,8 @@
|
|||
<sequence select="concat( compiler:class-var(.), '=!!', $val, ';' )" />
|
||||
|
||||
<if test="@yields">
|
||||
<sequence select="concat( compiler:class-yields-var(.), '=', $val, ';' )" />
|
||||
<sequence select="concat( compiler:class-yields-var(., true()), '=',
|
||||
$val, ';' )" />
|
||||
</if>
|
||||
</template>
|
||||
|
||||
|
@ -622,8 +625,27 @@
|
|||
-->
|
||||
<function name="compiler:class-yields-var" as="xs:string">
|
||||
<param name="class" as="element( lv:classify )" />
|
||||
<param name="define" as="xs:boolean" />
|
||||
|
||||
<sequence select="concat( 'A[''', $class/@yields, ''']' )" />
|
||||
<variable name="prefix" as="xs:string"
|
||||
select="if ( $define ) then 'var ' else ''" />
|
||||
|
||||
<sequence select="if ( $class/@preproc:generated='true' ) then
|
||||
concat( $prefix, '_cgen', $class/@yields )
|
||||
else
|
||||
concat( 'A[''', $class/@yields, ''']' )" />
|
||||
</function>
|
||||
|
||||
<function name="compiler:sym-class-yields-var" as="xs:string">
|
||||
<param name="sym" as="element( preproc:sym )" />
|
||||
|
||||
<variable name="yields" as="xs:string"
|
||||
select="$sym/@yields" />
|
||||
|
||||
<sequence select="if ( $sym/@preproc:generated = 'true' ) then
|
||||
concat( '_cgen', $yields )
|
||||
else
|
||||
concat( 'A[''', $yields, ''']' )" />
|
||||
</function>
|
||||
|
||||
|
||||
|
@ -644,7 +666,7 @@
|
|||
<value-of select="$compiler:nl" />
|
||||
|
||||
<variable name="dest" as="xs:string"
|
||||
select="compiler:class-yields-var(.)" />
|
||||
select="compiler:class-yields-var(., true())" />
|
||||
|
||||
<sequence select="concat( $dest, '=[];', $compiler:nl )" />
|
||||
|
||||
|
@ -699,9 +721,11 @@
|
|||
the node is not preprocessed -->
|
||||
<!-- TODO: this can be simplified, since @yields is always provided -->
|
||||
<if test="@yields and ( $sym/@dim='0' )">
|
||||
<value-of select="$dest" />
|
||||
<variable name="dest-ref" as="xs:string"
|
||||
select="compiler:class-yields-var(., false())" />
|
||||
<value-of select="$dest-ref" />
|
||||
<text>=</text>
|
||||
<value-of select="$dest" />
|
||||
<value-of select="$dest-ref" />
|
||||
<text>[0];</text>
|
||||
|
||||
<value-of select="$compiler:nl" />
|
||||
|
@ -734,25 +758,31 @@
|
|||
<variable name="input-raw">
|
||||
<choose>
|
||||
<when test="$sym-on/@type = 'const'">
|
||||
<text>C</text>
|
||||
<text>C['</text>
|
||||
<value-of select="translate( @on, "'", '' )" />
|
||||
<text>']</text>
|
||||
</when>
|
||||
|
||||
<!-- lv:match generates these and so is the only thing capable of
|
||||
referencing them -->
|
||||
<when test="$sym-on/@type = 'cgen'">
|
||||
<value-of select="compiler:sym-class-yields-var(
|
||||
$symtable-map( $sym-on/@parent ) )" />
|
||||
</when>
|
||||
|
||||
<otherwise>
|
||||
<text>A</text>
|
||||
<text>A['</text>
|
||||
<value-of select="translate( @on, "'", '' )" />
|
||||
<text>']</text>
|
||||
</otherwise>
|
||||
</choose>
|
||||
|
||||
<text>['</text>
|
||||
<value-of select="translate( @on, "'", '' )" />
|
||||
<text>']</text>
|
||||
</variable>
|
||||
|
||||
<!-- yields (if not set, generate one so that cmatches still works properly)
|
||||
-->
|
||||
<variable name="yieldto">
|
||||
<call-template name="compiler:gen-match-yieldto">
|
||||
<with-param name="yields" select="$yields" />
|
||||
</call-template>
|
||||
</variable>
|
||||
<variable name="yieldto" as="xs:string"
|
||||
select="compiler:class-yields-var(
|
||||
parent::lv:classify,
|
||||
false() )" />
|
||||
|
||||
<!-- the input value -->
|
||||
<variable name="input">
|
||||
|
@ -893,24 +923,6 @@
|
|||
<text>']=[])).push(tmp);/*!-*/ </text>
|
||||
</template>
|
||||
|
||||
<template name="compiler:gen-match-yieldto">
|
||||
<param name="yields" />
|
||||
|
||||
<text>A['</text>
|
||||
<choose>
|
||||
<when test="$yields">
|
||||
<value-of select="$yields" />
|
||||
</when>
|
||||
|
||||
<otherwise>
|
||||
<call-template name="compiler:gen-default-yield">
|
||||
<with-param name="name" select="ancestor::lv:classify/@as" />
|
||||
</call-template>
|
||||
</otherwise>
|
||||
</choose>
|
||||
<text>']</text>
|
||||
</template>
|
||||
|
||||
<!--
|
||||
Handles the special "float" domain
|
||||
|
||||
|
@ -1261,13 +1273,11 @@
|
|||
<text>, </text>
|
||||
</if>
|
||||
|
||||
<text>A['</text>
|
||||
<call-template name="compiler:get-class-yield">
|
||||
<with-param name="symtable-map" select="$symtable-map" />
|
||||
<with-param name="name" select="@ref" />
|
||||
<with-param name="search" select="$root" />
|
||||
</call-template>
|
||||
<text>']</text>
|
||||
</for-each>
|
||||
<text>], [</text>
|
||||
<for-each select="lv:class[ @no='true' ]">
|
||||
|
@ -1275,13 +1285,11 @@
|
|||
<text>, </text>
|
||||
</if>
|
||||
|
||||
<text>A['</text>
|
||||
<call-template name="compiler:get-class-yield">
|
||||
<with-param name="symtable-map" select="$symtable-map" />
|
||||
<with-param name="name" select="@ref" />
|
||||
<with-param name="search" select="$root" />
|
||||
</call-template>
|
||||
<text>']</text>
|
||||
</for-each>
|
||||
<text>]);</text>
|
||||
</template>
|
||||
|
@ -1292,31 +1300,8 @@
|
|||
<param name="name" />
|
||||
<param name="search" />
|
||||
|
||||
<variable name="yields"
|
||||
select="$symtable-map(
|
||||
concat( ':class:', $name ) )/@yields" />
|
||||
|
||||
<choose>
|
||||
<when test="$yields != ''">
|
||||
<value-of select="$yields" />
|
||||
</when>
|
||||
|
||||
<otherwise>
|
||||
<call-template name="compiler:gen-default-yield">
|
||||
<with-param name="name" select="$name" />
|
||||
</call-template>
|
||||
</otherwise>
|
||||
</choose>
|
||||
</template>
|
||||
|
||||
|
||||
<template name="compiler:gen-default-yield">
|
||||
<param name="name" />
|
||||
|
||||
<!-- a random name that would be invalid to reference from the XML -->
|
||||
<text>___$$</text>
|
||||
<value-of select="$name" />
|
||||
<text>$$</text>
|
||||
<sequence select="compiler:sym-class-yields-var(
|
||||
$symtable-map( concat( ':class:', $name ) ) )" />
|
||||
</template>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue