Linux GNU 11.4.0 Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 83.3% 5 / 0 / 6
Functions: -% 0 / 0 / 0
Branches: -% 0 / 0 / 0

OMCompiler/Compiler/Template/VisualXMLTpl.tpl
Line Branch Exec Source
1 /*
2 * This file is part of OpenModelica.
3 *
4 * Copyright (c) 1998-2026, Open Source Modelica Consortium (OSMC),
5 * c/o Linköpings universitet, Department of Computer and Information Science,
6 * SE-58183 Linköping, Sweden.
7 *
8 * All rights reserved.
9 *
10 * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF AGPL VERSION 3 LICENSE OR
11 * THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.8.
12 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
13 * RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GNU AGPL
14 * VERSION 3, ACCORDING TO RECIPIENTS CHOICE.
15 *
16 * The OpenModelica software and the OSMC (Open Source Modelica Consortium)
17 * Public License (OSMC-PL) are obtained from OSMC, either from the above
18 * address, from the URLs:
19 * http://www.openmodelica.org or
20 * https://github.com/OpenModelica/ or
21 * http://www.ida.liu.se/projects/OpenModelica,
22 * and in the OpenModelica distribution.
23 *
24 * GNU AGPL version 3 is obtained from:
25 * https://www.gnu.org/licenses/licenses.html#GPL
26 *
27 * This program is distributed WITHOUT ANY WARRANTY; without
28 * even the implied warranty of MERCHANTABILITY or FITNESS
29 * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
30 * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
31 *
32 * See the full OSMC Public License conditions for more details.
33 *
34 */
35
36 // This file defines template-extensions for transforming Modelica code into parallel hpcom-code.
37 //
38 // There are one root template intended to be called from the code generator:
39 // translateModel. These template do not return any
40 // result but instead write the result to files. All other templates return
41 // text and are used by the root templates (most of them indirectly).
42
43 package VisualXMLTpl
44
45 import interface VisualXMLTplTV;
46
47 //------------------------------------
48 // Section for Visualization XML Dump
49 //------------------------------------
50
51 3 template dumpVisXML(array<VisualXML.Visualization> vis, String fileName)
52 ::=
53 let()= textFile(dumpVisXML1(vis), fileName)
54 ""
55 end dumpVisXML;
56
57 3 template dumpVisXML1(array<VisualXML.Visualization> visArr)
58 ::=
59 let visDump = arrayList(visArr) |> vis => dumpVisualization(vis) ; separator="\n"
60 <<
61 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
62 <visualization>
63 <%visDump%>
64 </visualization>
65 >>
66 end dumpVisXML1;
67
68 32 template dumpVisualization(VisualXML.Visualization vis)
69 ::=
70 match vis
71 case vis as SHAPE(shapeType = sT as DAE.SCONST(string = svalue)) then
72 let TDump = arrayList(T) |> T0 => <<
73 <%dumpVecExp(T0)%>
74 >> ; separator="\n"
75 let rDump = dumpVecExp(arrayList(r))
76 let r_shapeDump = dumpVecExp(arrayList(r_shape))
77 let lDirDump = dumpVecExp(arrayList(lengthDir))
78 let wDirDump = dumpVecExp(arrayList(widthDir))
79 let colorDump = dumpVecExp(arrayList(color))
80 <<
81 <shape>
82 <ident><%ComponentReferenceBasics.printComponentRefStr(ident)%></ident>
83 <type><%svalue%></type>
84 <T>
85 <%TDump%>
86 </T>
87 <r>
88 <%rDump%>
89 </r>
90 <r_shape>
91 <%r_shapeDump%>
92 </r_shape>
93 <lengthDir>
94 <%lDirDump%>
95 </lengthDir>
96 <widthDir>
97 <%wDirDump%>
98 </widthDir>
99 <length><%dumpExp(length)%></length>
100 <width><%dumpExp(width)%></width>
101 <height><%dumpExp(height)%></height>
102 <extra><%dumpExp(extra)%></extra>
103 <color>
104 <%colorDump%>
105 </color>
106 <specCoeff><%dumpExp(specularCoeff)%></specCoeff>
107 </shape>
108 >>
109
110 case vis as VECTOR() then
111 let TDump = arrayList(T) |> T0 => <<
112 <%dumpVecExp(T0)%>
113 >> ; separator="\n"
114 let rDump = dumpVecExp(arrayList(r))
115 let coordDump = dumpVecExp(arrayList(coordinates))
116 let colorDump = dumpVecExp(arrayList(color))
117 <<
118 <vector>
119 <ident><%ComponentReferenceBasics.printComponentRefStr(ident)%></ident>
120 <T>
121 <%TDump%>
122 </T>
123 <r>
124 <%rDump%>
125 </r>
126 <coordinates>
127 <%coordDump%>
128 </coordinates>
129 <color>
130 <%colorDump%>
131 </color>
132 <specCoeff><%dumpExp(specularCoeff)%></specCoeff>
133 <quantity><%dumpExp(quantity)%></quantity>
134 <headAtOrigin><%dumpExp(headAtOrigin)%></headAtOrigin>
135 <twoHeadedArrow><%dumpExp(twoHeadedArrow)%></twoHeadedArrow>
136 </vector>
137 >>
138
139 case vis as SURFACE() then
140 let TDump = arrayList(T) |> T0 => <<
141 <%dumpVecExp(T0)%>
142 >> ; separator="\n"
143 let r_0Dump = dumpVecExp(arrayList(r_0))
144 let colorDump = dumpVecExp(arrayList(color))
145 <<
146 <surface>
147 <ident><%ComponentReferenceBasics.printComponentRefStr(ident)%></ident>
148 <T>
149 <%TDump%>
150 </T>
151 <r>
152 <%r_0Dump%>
153 </r>
154 <nu><%dumpExp(nu)%></nu>
155 <nv><%dumpExp(nv)%></nv>
156 <wireframe><%dumpExp(wireframe)%></wireframe>
157 <multiColored><%dumpExp(multiColored)%></multiColored>
158 <color>
159 <%colorDump%>
160 </color>
161 <specCoeff><%dumpExp(specularCoeff)%></specCoeff>
162 <transparency><%dumpExp(transparency)%></transparency>
163 </surface>
164 >>
165 end match
166 end dumpVisualization;
167
168 281 template dumpVecExp (list<DAE.Exp> vector)
169 ::=
170 let vecDump = vector |> vec => <<<%dumpExp(vec)%>>> ; separator="\n"
171 <<
172 <%vecDump%>>>
173 end dumpVecExp;
174
175 801 template dumpExp (DAE.Exp expIn)
176 ::=
177 match expIn
178 case expIn as ENUM_LITERAL(__) then
179 <<
180 <enum><%intString(index)%></enum>
181 >>
182 case expIn as BCONST(__) then
183 <<
184 <bconst><%ExpressionBasics.printExpStr(expIn)%></bconst>
185 >>
186 case expIn as CREF(__) then
187 <<
188 <cref><%ExpressionBasics.printExpStr(expIn)%></cref>
189 >>
190 case expIn as BINARY(__) then
191 <<<binary>
192 <%dumpExp(exp1)%>
193 <op><%dumpOperator(operator)%></op>
194 <%dumpExp(exp2)%>
195 </binary>
196 >>
197 case expIn as UNARY(__) then
198 <<<unary>
199 <op><%dumpOperator(operator)%></op>
200 <%dumpExp(exp)%>
201 </unary>
202 >>
203 case expIn as LBINARY(__) then
204 <<<lbinary>
205 <%dumpExp(exp1)%>
206 <op><%dumpOperator(operator)%></op>
207 <%dumpExp(exp2)%>
208 </lbinary>
209 >>
210 case expIn as LUNARY(__) then
211 <<<lunary>
212 <op><%dumpOperator(operator)%></op>
213 <%dumpExp(exp)%>
214 </lunary>
215 >>
216 case expIn as RELATION(__) then
217 <<<relation>
218 <exp1><%dumpExp(exp1)%></exp1>
219 <op><%dumpOperator(operator)%></op>
220 <exp2><%dumpExp(exp2)%></exp2>
221 </relation>
222 >>
223 case expIn as IFEXP(__) then
224 <<<ifexp>
225 <cond><%dumpExp(expCond)%></cond>
226 <then><%dumpExp(expThen)%></then>
227 <else><%dumpExp(expElse)%></else>
228 </ifexp>
229 >>
230 case expIn as CALL(__) then
231 let elist = expLst |> e => <<<%dumpExp(e)%>>> ; separator="\n"
232 <<<call>
233 <path><%AbsynUtil.pathString(path, ".", true, false)%></path>
234 <expLst><%elist%></expLst>
235 </call>
236 >>
237 else
238 <<
239 <exp><%ExpressionBasics.printExpStr(expIn)%></exp>
240 >>
241 end match
242 end dumpExp;
243
244 ✗ template dumpOperator (DAE.Operator op)
245 ::=
246 match op
247 case op as ADD() then
248 <<add>>
249 case op as SUB() then
250 <<sub>>
251 case op as MUL() then
252 <<mul>>
253 case op as DIV() then
254 <<div>>
255 case op as POW() then
256 <<pow>>
257 case op as UMINUS() then
258 <<uminus>>
259 case op as UMINUS_ARR() then
260 <<uminus_arr>>
261 case op as ADD_ARR() then
262 <<add_arr>>
263 case op as SUB_ARR() then
264 <<sub_arr>>
265 case op as MUL_ARR() then
266 <<mul_arr>>
267 case op as DIV_ARR() then
268 <<siv_arr>>
269 case op as MUL_ARRAY_SCALAR() then
270 <<mul_array_scalar>>
271 case op as ADD_ARRAY_SCALAR() then
272 <<add_array_scalar>>
273 case op as SUB_SCALAR_ARRAY() then
274 <<sub_scalar_array>>
275 case op as MUL_SCALAR_PRODUCT() then
276 <<mul_scalar_product>>
277 case op as MUL_MATRIX_PRODUCT() then
278 <<mul_matrix_product>>
279 case op as DIV_ARRAY_SCALAR() then
280 <<div_array_scalar>>
281 case op as DIV_SCALAR_ARRAY() then
282 <<siv_scalar_array>>
283 case op as POW_ARRAY_SCALAR() then
284 <<pow_array_scalar>>
285 case op as POW_SCALAR_ARRAY() then
286 <<pow_scalar_array>>
287 case op as POW_ARR() then
288 <<pow_arr>>
289 case op as POW_ARR2() then
290 <<por_arr2>>
291 case op as AND() then
292 <<and>>
293 case op as OR() then
294 <<or>>
295 case op as NOT() then
296 <<not>>
297 case op as LESS() then
298 <<less>>
299 case op as LESSEQ() then
300 <<lesseq>>
301 case op as GREATER() then
302 <<greater>>
303 case op as GREATEREQ() then
304 <<greatereq>>
305 case op as EQUAL() then
306 <<equal>>
307 case op as NEQUAL() then
308 <<nequal>>
309 case op as USERDEFINED() then
310 <<userdefined>>
311 else
312 <<-unknown operator->>
313 end match
314 end dumpOperator;
315
316 annotation(__OpenModelica_Interface="backend");
317 end VisualXMLTpl;
318