Linux GNU 11.4.0 Code Coverage Report


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

OMCompiler/Compiler/Template/NFInstDumpTpl.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 package NFInstDumpTpl
37
38 import interface NFInstDumpTV;
39 import AbsynDumpTpl;
40 import ExpressionDumpTpl;
41
42 ✗ template dumpModel(String name, Class cls)
43 ::=
44 <<
45 class <%name%>
46 <%dumpClass(cls)%>
47 end <%name%>
48 >>
49 end dumpModel;
50
51 ✗ template dumpComponent(Component component)
52 ::=
53 match component
54 case UNTYPED_COMPONENT(__) then
55 let name_str = AbsynDumpTpl.dumpPath(name)
56 let bind_str = dumpBinding(binding)
57 let ty_str = ExpressionDumpTpl.dumpType(baseType)
58 let dims_str = NFInstDump.dumpUntypedComponentDims(component)
59 '{<%ty_str%><%dims_str%>} <%name_str%><%bind_str%>;'
60 case TYPED_COMPONENT(__) then
61 let name_str = AbsynDumpTpl.dumpPath(name)
62 let bind_str = dumpBinding(binding)
63 let ty_str = ExpressionDumpTpl.dumpType(ty)
64 '<%ty_str%> <%name_str%><%bind_str%>;'
65 case CONDITIONAL_COMPONENT(__) then
66 let name_str = AbsynDumpTpl.dumpPath(name)
67 'conditional <%name_str%>;'
68 case DELETED_COMPONENT(__) then
69 let name_str = AbsynDumpTpl.dumpPath(name)
70 'deleted <%name_str%>;'
71 case OUTER_COMPONENT(innerName = SOME(in)) then
72 let outer_str = AbsynDumpTpl.dumpPath(name)
73 let inner_str = AbsynDumpTpl.dumpPath(in)
74 'outer <%outer_str%> -> <%inner_str%>;'
75 case OUTER_COMPONENT(__) then
76 let outer_str = AbsynDumpTpl.dumpPath(name)
77 'outer <%outer_str%>;'
78 end dumpComponent;
79
80 ✗ template dumpElement(Element element)
81 ::=
82 match element
83 case ELEMENT(__) then
84 let comp_str = dumpComponent(component)
85 let cls_str = dumpClass(cls)
86 let sep_str = if cls_str then "\n"
87 '<%comp_str%><%sep_str%><%cls_str%>'
88 case CONDITIONAL_ELEMENT(__) then
89 let comp_str = dumpComponent(component)
90 '<%comp_str%>'
91 case EXTENDED_ELEMENTS(__) then
92 let cls_str = dumpClass(cls)
93 '<%cls_str%>'
94 end dumpElement;
95
96 ✗ template dumpClass(Class cls)
97 ::=
98 match cls
99 case COMPLEX_CLASS(__) then
100 let comp_str = (components |> comp => dumpElement(comp) ;separator="\n")
101 let ieq_str = (initialEquations |> ieq => dumpEquation(ieq) ;separator="\n")
102 let eq_str = (equations |> eq => dumpEquation(eq) ;separator="\n")
103 let comp_seq_str = if comp_str then
104 <<
105 <%comp_str%>
106 >>
107 let ieq_seq_str = if ieq_str then
108 <<
109
110 initial equation
111 <%ieq_str%>
112 <%if eq_str then '' else 'end equation;'%>
113 >>
114 let eq_seq_str = if eq_str then
115 <<
116
117 equation
118 <%eq_str%>
119 end equation;
120 >>
121 '<%comp_seq_str%><%ieq_seq_str%><%eq_seq_str%>'
122 end dumpClass;
123
124 ✗ template dumpExp(DAE.Exp exp)
125 ::= ExpressionDumpTpl.dumpExp(exp, "\"")
126 end dumpExp;
127
128 ✗ template dumpEquation(Equation equation)
129 ::=
130 match equation
131 case EQUALITY_EQUATION(__) then
132 let lhs_str = dumpExp(lhs)
133 let rhs_str = dumpExp(rhs)
134 let lhs_ty_str = ExpressionDumpTpl.dumpType(Expression.typeof(lhs))
135 let rhs_ty_str = ExpressionDumpTpl.dumpType(Expression.typeof(rhs))
136 '<%lhs_str%> {<%lhs_ty_str%>} = {<%rhs_ty_str%>} <%rhs_str%>;'
137 //case CONNECT_EQUATION(__) then
138 // let lhs_str = ExpressionDumpTpl.dumpCref(lhs)
139 // let rhs_str = ExpressionDumpTpl.dumpCref(rhs)
140 // let lhs_face_str = dumpFace(lhsFace)
141 // let rhs_face_str = dumpFace(rhsFace)
142 // 'connect(<%lhs_str%> <<%lhs_face_str%>>, <%rhs_str%> <<%rhs_face_str%>>);'
143 case FOR_EQUATION(__) then
144 let ty_str = ExpressionDumpTpl.dumpType(indexType)
145 let range_str = match range case SOME(range_exp) then
146 ' in <%dumpExp(range_exp)%>'
147 let eql_str = (body |> eq => dumpEquation(eq) ;separator="\n")
148 <<
149 for {<%ty_str%>} <%name%> /* index <%index%> */<%range_str%> loop
150 <%eql_str%>
151 end for;
152 >>
153 case IF_EQUATION(__) then
154 'if equation;'
155 case ASSERT_EQUATION(__) then
156 let cond_str = dumpExp(condition)
157 let msg_str = dumpExp(message)
158 'assert(<%cond_str%>, <%msg_str%>);'
159 case TERMINATE_EQUATION(__) then
160 let msg_str = dumpExp(message)
161 'terminate(<%msg_str%>);'
162 case REINIT_EQUATION(__) then
163 let cref_str = ExpressionDumpTpl.dumpCref(cref)
164 let exp_str = dumpExp(reinitExp)
165 'reinit(<%cref_str%>, <%exp_str%>)'
166 case NORETCALL_EQUATION(__) then dumpExp(exp)
167 else 'dumpEquation: IMPLEMENT ME'
168 end dumpEquation;
169
170 ✗ template dumpBinding(Binding binding)
171 ::=
172 match binding
173 case RAW_BINDING(bindingExp = aexp) then
174 let exp_str = AbsynDumpTpl.dumpExp(aexp)
175 ' = <RAW> <%exp_str%>'
176 case UNTYPED_BINDING(__) then
177 let exp_str = dumpExp(bindingExp)
178 ' = <%exp_str%>'
179 case TYPED_BINDING(__) then
180 let exp_str = dumpExp(bindingExp)
181 let ty_str = ExpressionDumpTpl.dumpType(bindingType)
182 ' = (<%ty_str%>) <%exp_str%>'
183 end dumpBinding;
184
185 ✗ template dumpPrefix(Prefix prefix)
186 ::=
187 match prefix
188 case PREFIX(__) then
189 let dims_str = if dims then '[<%ExpressionDumpTpl.dumpDimensions(dims)%>]'
190 let rest_str = dumpPrefix(restPrefix)
191 let pre_str = if rest_str then '<%rest_str%>.'
192 '<%pre_str%><%name%><%dims_str%>'
193 end dumpPrefix;
194
195 //template dumpConnections(Connections conn)
196 //::=
197 //match conn
198 // case CONNECTIONS(__) then
199 // let conn_str = (connections |> c => dumpConnection(c) ;separator="\n")
200 // '<%conn_str%>'
201 //end dumpConnections;
202 //
203 //template dumpConnection(Connection connection)
204 //::=
205 //match connection
206 // case CONNECTION(__) then
207 // let lhs_str = dumpConnector(lhs)
208 // let rhs_str = dumpConnector(rhs)
209 // 'connect(<%lhs_str%>, <%rhs_str%>)'
210 //end dumpConnection;
211 //
212 //template dumpConnector(Connector connector)
213 //::=
214 //match connector
215 // case CONNECTOR(__) then
216 // let name_str = ExpressionDumpTpl.dumpCref(name)
217 // let face_str = dumpFace(face)
218 // '<%name_str%> <<%face_str%>>'
219 //end dumpConnector;
220 //
221 //template dumpFace(Face face)
222 //::=
223 //match face
224 // case INSIDE() then 'inside'
225 // case OUTSIDE() then 'outside'
226 // case NO_FACE() then 'no_face'
227 //end dumpFace;
228
229 ✗ template dumpDimension(NFInstTypes.Dimension dim)
230 ::=
231 match dim
232 case UNTYPED_DIMENSION(__) then ExpressionDumpTpl.dumpDimension(dimension)
233 case TYPED_DIMENSION(__) then ExpressionDumpTpl.dumpDimension(dimension)
234 end dumpDimension;
235
236 ✗ template errorMsg(String errMessage)
237 ::=
238 let() = Tpl.addTemplateError(errMessage)
239 <<
240 <%errMessage%>
241 >>
242 end errorMsg;
243
244 annotation(__OpenModelica_Interface="frontend");
245 end NFInstDumpTpl;
246 // vim: filetype=susan sw=2 sts=2
247