Produce consts as part of rater object
parent
7f26db41b2
commit
0c020b736d
|
@ -128,7 +128,11 @@
|
||||||
<xsl:variable name="pkg" as="element( lv:package )"
|
<xsl:variable name="pkg" as="element( lv:package )"
|
||||||
select="root(.)" />
|
select="root(.)" />
|
||||||
|
|
||||||
<xsl:apply-templates select="$pkg/lv:const[ @name=$name ]" mode="compile" />
|
<xsl:apply-templates mode="compile"
|
||||||
|
select="$pkg/lv:const[ @name=$name ],
|
||||||
|
$pkg/lv:typedef//lv:item[ @name=$name ]">
|
||||||
|
<xsl:with-param name="as-const" select="true()" />
|
||||||
|
</xsl:apply-templates>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
<xsl:template match="preproc:sym[ @type='tpl' ]" mode="preproc:compile-fragments" priority="5">
|
<xsl:template match="preproc:sym[ @type='tpl' ]" mode="preproc:compile-fragments" priority="5">
|
||||||
|
|
|
@ -65,18 +65,11 @@
|
||||||
<!-- to store debug information for equations (we have to put this out here
|
<!-- to store debug information for equations (we have to put this out here
|
||||||
so that functions also have access to it...yes, it's stateful, yes it's
|
so that functions also have access to it...yes, it's stateful, yes it's
|
||||||
bullshit, but oh well) -->
|
bullshit, but oh well) -->
|
||||||
<text>var debug = {};</text>
|
|
||||||
<text>var consts = {};</text>
|
<text>var consts = {};</text>
|
||||||
|
<text>var debug = {};</text>
|
||||||
<text>var params = {};</text>
|
<text>var params = {};</text>
|
||||||
<text>var types = {};</text>
|
<text>var types = {};</text>
|
||||||
<text>var meta = {};</text>
|
<text>var meta = {};</text>
|
||||||
<!--
|
|
||||||
<value-of select="$compiler:nl" />
|
|
||||||
<apply-templates
|
|
||||||
select="root(.)//lv:const[ .//lv:item or preproc:iou ]"
|
|
||||||
mode="compile" />
|
|
||||||
-->
|
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
@ -162,7 +155,6 @@
|
||||||
<text>premium: ( Math.round( args.___yield * 100 ) / 100 ), </text>
|
<text>premium: ( Math.round( args.___yield * 100 ) / 100 ), </text>
|
||||||
<text>classes: classes, </text>
|
<text>classes: classes, </text>
|
||||||
<text>vars: args, </text>
|
<text>vars: args, </text>
|
||||||
<text>consts: consts, </text>
|
|
||||||
<text>reqParams: req_params, </text>
|
<text>reqParams: req_params, </text>
|
||||||
<text>debug: debug </text>
|
<text>debug: debug </text>
|
||||||
<text>}; </text>
|
<text>}; </text>
|
||||||
|
@ -174,6 +166,7 @@
|
||||||
<text>'; </text>
|
<text>'; </text>
|
||||||
|
|
||||||
<text>rater.meta = meta;</text>
|
<text>rater.meta = meta;</text>
|
||||||
|
<text>rater.consts = consts;</text>
|
||||||
|
|
||||||
<!-- provide classification -> yields mapping -->
|
<!-- provide classification -> yields mapping -->
|
||||||
<value-of select="$compiler:nl" />
|
<value-of select="$compiler:nl" />
|
||||||
|
@ -383,6 +376,9 @@
|
||||||
@return property representing a specific value
|
@return property representing a specific value
|
||||||
-->
|
-->
|
||||||
<template match="lv:enum/lv:item" mode="compile">
|
<template match="lv:enum/lv:item" mode="compile">
|
||||||
|
<param name="as-const" as="xs:boolean"
|
||||||
|
select="false()" />
|
||||||
|
|
||||||
<!-- determine enumerated value -->
|
<!-- determine enumerated value -->
|
||||||
<variable name="value">
|
<variable name="value">
|
||||||
<choose>
|
<choose>
|
||||||
|
@ -398,9 +394,10 @@
|
||||||
</variable>
|
</variable>
|
||||||
|
|
||||||
<!-- we are only interest in its value; its constant is an internal value -->
|
<!-- we are only interest in its value; its constant is an internal value -->
|
||||||
<text>'</text>
|
<sequence select="if ( $as-const ) then
|
||||||
<value-of select="$value" />
|
concat( 'consts[''', @name, '''] = ', $value, ';' )
|
||||||
<text>': true</text>
|
else
|
||||||
|
concat( '''', $value, ''': true' )" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
@ -412,7 +409,7 @@
|
||||||
|
|
||||||
@return JS object assignment for constant set values
|
@return JS object assignment for constant set values
|
||||||
-->
|
-->
|
||||||
<template mode="compile" priority="1"
|
<template mode="compile" priority="2"
|
||||||
match="lv:const[ element() or @values ]">
|
match="lv:const[ element() or @values ]">
|
||||||
<text>consts['</text>
|
<text>consts['</text>
|
||||||
<value-of select="@name" />
|
<value-of select="@name" />
|
||||||
|
@ -448,6 +445,19 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Falls back to scalar constants
|
||||||
|
-->
|
||||||
|
<template mode="compile" priority="1"
|
||||||
|
match="lv:const">
|
||||||
|
<text>consts['</text>
|
||||||
|
<value-of select="@name" />
|
||||||
|
<text>'] = </text>
|
||||||
|
<value-of select="@value" />
|
||||||
|
<text>;</text>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Produce sequence of sets
|
Produce sequence of sets
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue