Skip to content

Commit 3dc7950

Browse files
committed
Propagate dependencies into AF output args
Per issue Qucs#67, the e:dependency template in adms.implicit.xml will propagate probe and variable dependencies from analog function arguments into the top-level expression in which the function is called (generally the RHS of an assignment), but does NOT do the same thing for any output arguments that might exist in the analog function. Some new CMC standard models (e.g. the MVSG-HV model) use analog functions in this manner, and it would be good to fix it. This commit augments the e:dependency template so that it completely propagates all dependencies from function arguments into any output variables that might exist. It is a no-op if there are no such function output arguments. This commit also obsoletes pull request Qucs#68. Unlike that PR, this one makes sure to perform dependency checking on the input arguments before copying their probe dependencies, and unlike that PR, it also copies their variable dependencies. Also unlike that code, it will correctly handle output arguments that are not at the beginning of the argument list, because it selects all arguments in the function definition in order and uses their position in the global list rather than selecting only the output arguments and using their position in the truncated list. Issue Qucs#67 PR Qucs#68
1 parent 05c979a commit 3dc7950

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

admsXml/adms.implicit.xml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
<admst:variable name="globalopdependent" string="no"/>
3737
<admst:variable name="globalpartitionning"/>
3838
<admst:variable name="globaltreenode"/>
39+
<admst:variable name="globalhandleafoutputs" string="no"/>
40+
<admst:variable name="globalaf"/>
3941

4042
<admst:template match="e:dependency">
4143
<admst:choose>
@@ -71,6 +73,9 @@
7173
<admst:when test="[datatypename='probe']">
7274
<admst:value-to select="dependency" string="linear"/>
7375
<admst:push into="$globalexpression/probe" select="." onduplicate="ignore"/>
76+
<admst:if test="[$globalhandleafoutputs='yes']">
77+
<admst:push into="$globalaf/@probe" select="." onduplicate="ignore"/>
78+
</admst:if>
7479
</admst:when>
7580
<admst:when test="[datatypename='array']">
7681
<admst:apply-templates select="variable" match="e:dependency"/>
@@ -81,6 +86,12 @@
8186
<admst:push into="$globalexpression/variable" select="." onduplicate="ignore"/>
8287
<admst:push into="$globaltreenode/@variable" select="." onduplicate="ignore"/>
8388
<admst:value-to select="dependency" path="prototype/dependency"/>
89+
90+
<admst:if test="[$globalhandleafoutputs='yes']">
91+
<admst:push into="$globalaf/@probe" select="probe" onduplicate="ignore"/>
92+
<admst:push into="$globalaf/@variable" select="." onduplicate="ignore"/>
93+
</admst:if>
94+
8495
</admst:when>
8596
<admst:when test="[datatypename='mapply_unary']">
8697
<admst:apply-templates select="arg1" match="e:dependency"/>
@@ -160,7 +171,32 @@
160171
<admst:value-to select="dependency" string="constant"/>
161172
</admst:when>
162173
<admst:otherwise>
174+
<!-- track dependencies of analog function output arguments -->
175+
<admst:if test="[definition/datatypename='analogfunction']">
176+
<admst:variable name="function" select="%(.)"/>
177+
<admst:if test="[exists(definition/variable[(output='yes') and (name!=$function/name)])]">
178+
<admst:variable name="globalhandleafoutputs" string="yes"/>
179+
<admst:variable name="globalaf" path="."/>
180+
</admst:if>
181+
</admst:if>
182+
<!-- process arguments normally -->
163183
<admst:apply-templates select="arguments" match="e:dependency"/>
184+
<!-- propagate dependencies into output arguments -->
185+
<admst:if test="[$globalhandleafoutputs='yes']">
186+
<admst:variable name="globalhandleafoutputs" string="no"/>
187+
<admst:variable name="globalaf"/>
188+
<admst:for-each select="definition/variable">
189+
<admst:if test="[(output='yes') and (name!=$function/name)]">
190+
<admst:variable name="position" select="%(position(.)-1)"/>
191+
<admst:fatal test="[$function/arguments[position(.)=$position]/datatypename!='variable']"
192+
format="%(function/name) output arg $position is %(.), must be a variable\n"/>
193+
<admst:push into="$function/arguments[position(.)=$position]/probe" select="$function/@probe" onduplicate="ignore"/>
194+
<admst:push into="$function/arguments[position(.)=$position]/variable" select="$function/@variable" onduplicate="ignore"/>
195+
</admst:if>
196+
</admst:for-each>
197+
<admst:value-to select="$function/@probe"/>
198+
<admst:value-to select="$function/@variable"/>
199+
</admst:if>
164200
<admst:choose>
165201
<admst:when test="[(name='ddt' or name='\$ddt')or(name='idt' or name='\$idt')]">
166202
<admst:value-to select="dependency" string="nonlinear"/>

0 commit comments

Comments
 (0)