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 / 90
Functions: -% 0 / 1 / 1
Branches: 0.0% 0 / 0 / 8

build_cmake/OMCompiler/Compiler/generated-mo/Template/CodegenFMUCppHpcom.mo
Line Branch Exec Source
1 encapsulated package CodegenFMUCppHpcom
2 "
3 file: CodegenFMUCppHpcom.mo
4 package: CodegenFMUCppHpcom
5 description: Generated by Susan.
6 "
7
8 public import Tpl;
9
10 public import BackendVariable;
11 public import HpcOmSimCode;
12 public import HpcOmCodegenUtil;
13 public import FMI;
14 public import SimCodeVar;
15 public import HashTableCrefSimVar;
16 public import SimCode;
17 public import SimCodeFunction;
18 public import SimCodeCodegenUtil;
19 public import SimCodeFunctionUtil;
20 public import BackendDAE;
21 public import System;
22 public import Autoconf;
23 protected import Absyn;
24 protected import AbsynUtil;
25 public import MMath;
26 public import DAE;
27 public import ClassInf;
28 public import ClassInfUtil;
29 protected import SCode;
30 protected import SCodeDump;
31 public import StringUtil;
32 public import Util;
33 public import List;
34 public import ComponentReferenceBasics;
35 public import ComponentReference;
36 public import Expression;
37 protected import ExpressionDump;
38 public import ExpressionBasics;
39 public import Config;
40 public import Testsuite;
41 public import Flags;
42 public import FlagsUtil;
43 public import Settings;
44 public import Patternm;
45 public import Error;
46 public import Values;
47 public import ValuesUtil;
48 public import DAEDump;
49 public import Algorithm;
50 protected import ElementSource;
51 public import DAEUtil;
52 public import TypesDump;
53 public import Types;
54 public import HashTableCrIListArray;
55 public import CodegenFMUCpp;
56 public import CodegenCppHpcom;
57 protected import CodegenUtil;
58 protected import CodegenCpp;
59 protected import CodegenCppInit;
60
61 public function translateModel
62 input Tpl.Text in_txt;
63 input SimCode.SimCode in_a_simCode;
64 input String in_a_FMUVersion;
65 input String in_a_FMUType;
66
67 output Tpl.Text out_txt;
68 algorithm
69 out_txt :=
70 match(in_txt, in_a_simCode, in_a_FMUVersion, in_a_FMUType)
71 local
72 Tpl.Text txt;
73 String a_FMUVersion;
74 String a_FMUType;
75 HashTableCrIListArray.HashTable i_varToArrayIndexMapping;
76 Option<tuple<HpcOmSimCode.Schedule, HpcOmSimCode.Schedule, HpcOmSimCode.Schedule>> i_hpcomData_schedules;
77 list<SimCode.SimEqSystem> i_allEquations;
78 String i_fileNamePrefix;
79 SimCode.SimCode i_simCode;
80 Option<HpcOmSimCode.MemoryMap> i_hpcomData_hpcOmMemory;
81 SimCode.ModelInfo i_modelInfo;
82 Absyn.Path i_modelInfo_name;
83 Tpl.Text txt_46;
84 Tpl.Text txt_45;
85 Tpl.Text txt_44;
86 Boolean ret_43;
87 Tpl.Text txt_42;
88 Tpl.Text txt_41;
89 Tpl.Text txt_40;
90 Tpl.Text txt_39;
91 Tpl.Text txt_38;
92 Tpl.Text txt_37;
93 Tpl.Text txt_36;
94 Tpl.Text txt_35;
95 Tpl.Text txt_34;
96 Tpl.Text txt_33;
97 Tpl.Text txt_32;
98 Tpl.Text txt_31;
99 Tpl.Text txt_30;
100 Tpl.Text txt_29;
101 Tpl.Text txt_28;
102 Tpl.Text txt_27;
103 Tpl.Text txt_26;
104 Tpl.Text txt_25;
105 Tpl.Text txt_24;
106 Tpl.Text txt_23;
107 Tpl.Text txt_22;
108 Tpl.Text txt_21;
109 Tpl.Text txt_20;
110 Tpl.Text txt_19;
111 Tpl.Text txt_18;
112 Tpl.Text txt_17;
113 Tpl.Text txt_16;
114 Tpl.Text l_cpp;
115 Tpl.Text txt_14;
116 Tpl.Text l_numPreVars;
117 Tpl.Text l_numStringVars;
118 Tpl.Text l_numBoolVars;
119 Tpl.Text l_numIntVars;
120 Tpl.Text l_numRealVars;
121 Tpl.Text l_className;
122 Tpl.Text l_complexStartExpressions;
123 Tpl.Text l_extraFuncsDecl;
124 Tpl.Text l_extraFuncs;
125 Tpl.Text l_stateDerVectorName;
126 String ret_3;
127 Tpl.Text l_target;
128 String ret_1;
129 Tpl.Text l_guid;
130
131 case ( txt,
132 (i_simCode as SimCode.SIMCODE(modelInfo = (i_modelInfo as SimCode.MODELINFO(name = i_modelInfo_name)), makefileParams = SimCodeFunction.MAKEFILE_PARAMS(ccompiler = _), hpcomData = HpcOmSimCode.HPCOMDATA(hpcOmMemory = i_hpcomData_hpcOmMemory, schedules = i_hpcomData_schedules), fileNamePrefix = i_fileNamePrefix, allEquations = i_allEquations, varToArrayIndexMapping = i_varToArrayIndexMapping)),
133 a_FMUVersion,
134 a_FMUType )
135 algorithm
136 ✗ ret_1 := System.getUUIDStr();
137 ✗ l_guid := Tpl.writeStr(Tpl.emptyTxt, ret_1);
138 ✗ ret_3 := Config.simulationCodeTarget();
139 ✗ l_target := Tpl.writeStr(Tpl.emptyTxt, ret_3);
140 ✗ l_stateDerVectorName := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("__zDot"));
141 ✗ l_extraFuncs := Tpl.emptyTxt;
142 ✗ l_extraFuncsDecl := Tpl.emptyTxt;
143 ✗ l_complexStartExpressions := Tpl.emptyTxt;
144 ✗ l_className := CodegenCpp.lastIdentOfPath(Tpl.emptyTxt, i_modelInfo_name);
145 ✗ l_numRealVars := CodegenCppHpcom.numRealvarsHpcom(Tpl.emptyTxt, i_modelInfo, i_hpcomData_hpcOmMemory);
146 ✗ l_numIntVars := CodegenCppHpcom.numIntvarsHpcom(Tpl.emptyTxt, i_modelInfo, i_hpcomData_hpcOmMemory);
147 ✗ l_numBoolVars := CodegenCppHpcom.numBoolvarsHpcom(Tpl.emptyTxt, i_modelInfo, i_hpcomData_hpcOmMemory);
148 ✗ l_numStringVars := CodegenCppHpcom.numStringvarsHpcom(Tpl.emptyTxt, i_modelInfo, i_hpcomData_hpcOmMemory);
149 ✗ l_numPreVars := CodegenCppHpcom.numPreVarsHpcom(Tpl.emptyTxt, i_modelInfo, i_hpcomData_hpcOmMemory);
150 ✗ (txt_14, l_complexStartExpressions, l_stateDerVectorName) := CodegenCppInit.modelInitXMLFile(Tpl.emptyTxt, i_simCode, Tpl.textString(l_numRealVars), Tpl.textString(l_numIntVars), Tpl.textString(l_numBoolVars), Tpl.textString(l_numStringVars), a_FMUVersion, a_FMUType, Tpl.textString(l_guid), true, "hpcom cpp-runtime", l_complexStartExpressions, l_stateDerVectorName);
151 ✗ Tpl.textFile(txt_14, "modelDescription.xml");
152 ✗ l_cpp := CodegenCpp.translateModel(Tpl.emptyTxt, i_simCode);
153 ✗ (txt_16, l_extraFuncs, l_extraFuncsDecl, _) := CodegenFMUCpp.fmuWriteOutputHeaderFile(Tpl.emptyTxt, i_simCode, l_extraFuncs, l_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")));
154 ✗ txt_17 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp"));
155 ✗ txt_17 := Tpl.writeStr(txt_17, i_fileNamePrefix);
156 ✗ txt_17 := Tpl.writeTok(txt_17, Tpl.ST_STRING("WriteOutput.h"));
157 ✗ Tpl.textFile(txt_16, Tpl.textString(txt_17));
158 ✗ (txt_18, l_extraFuncs, l_extraFuncsDecl, _) := CodegenFMUCpp.fmuModelHeaderFile(Tpl.emptyTxt, i_simCode, l_extraFuncs, l_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")), Tpl.textString(l_guid), a_FMUVersion);
159 ✗ txt_19 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp"));
160 ✗ txt_19 := Tpl.writeStr(txt_19, i_fileNamePrefix);
161 ✗ txt_19 := Tpl.writeTok(txt_19, Tpl.ST_STRING("FMU.h"));
162 ✗ Tpl.textFile(txt_18, Tpl.textString(txt_19));
163 ✗ (txt_20, l_extraFuncs, l_extraFuncsDecl, _) := CodegenFMUCpp.fmuModelCppFile(Tpl.emptyTxt, i_simCode, l_extraFuncs, l_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")), Tpl.textString(l_guid), a_FMUVersion);
164 ✗ txt_21 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp"));
165 ✗ txt_21 := Tpl.writeStr(txt_21, i_fileNamePrefix);
166 ✗ txt_21 := Tpl.writeTok(txt_21, Tpl.ST_STRING("FMU.cpp"));
167 ✗ Tpl.textFile(txt_20, Tpl.textString(txt_21));
168 ✗ (txt_22, l_extraFuncs, l_extraFuncsDecl, _) := fmuMakefile(Tpl.emptyTxt, Tpl.textString(l_target), i_simCode, l_extraFuncs, l_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")), a_FMUVersion);
169 ✗ txt_23 := Tpl.writeStr(Tpl.emptyTxt, i_fileNamePrefix);
170 ✗ txt_23 := Tpl.writeTok(txt_23, Tpl.ST_STRING("_FMU.makefile"));
171 ✗ Tpl.textFile(txt_22, Tpl.textString(txt_23));
172 ✗ txt_24 := CodegenFMUCpp.fmuCalcHelperMainfile(Tpl.emptyTxt, i_simCode);
173 ✗ txt_25 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp"));
174 ✗ txt_25 := Tpl.writeStr(txt_25, i_fileNamePrefix);
175 ✗ txt_25 := Tpl.writeTok(txt_25, Tpl.ST_STRING("CalcHelperMain.cpp"));
176 ✗ Tpl.textFile(txt_24, Tpl.textString(txt_25));
177 ✗ (txt_26, l_extraFuncs, l_extraFuncsDecl, _, l_stateDerVectorName) := CodegenCppHpcom.updateHpcom(Tpl.emptyTxt, i_allEquations, i_simCode, l_extraFuncs, l_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")), SimCodeFunction.contextOther, l_stateDerVectorName, false);
178 ✗ txt_27 := Tpl.writeText(Tpl.emptyTxt, l_numRealVars);
179 ✗ txt_27 := Tpl.writeTok(txt_27, Tpl.ST_STRING("-1"));
180 ✗ txt_28 := Tpl.writeText(Tpl.emptyTxt, l_numIntVars);
181 ✗ txt_28 := Tpl.writeTok(txt_28, Tpl.ST_STRING("-1"));
182 ✗ txt_29 := Tpl.writeText(Tpl.emptyTxt, l_numBoolVars);
183 ✗ txt_29 := Tpl.writeTok(txt_29, Tpl.ST_STRING("-1"));
184 ✗ txt_30 := Tpl.writeText(Tpl.emptyTxt, l_numStringVars);
185 ✗ txt_30 := Tpl.writeTok(txt_30, Tpl.ST_STRING("-1"));
186 ✗ txt_31 := CodegenCppHpcom.additionalHpcomConstructorDefinitions(Tpl.emptyTxt, i_hpcomData_schedules);
187 ✗ txt_32 := CodegenUtil.dotPath(Tpl.emptyTxt, i_modelInfo_name);
188 ✗ txt_33 := CodegenCppHpcom.additionalHpcomConstructorBodyStatements(Tpl.emptyTxt, i_hpcomData_schedules, Tpl.textString(l_className), Tpl.textString(txt_32));
189 ✗ txt_34 := CodegenCppHpcom.additionalHpcomDestructorBodyStatements(Tpl.emptyTxt, i_hpcomData_schedules);
190 ✗ (txt_35, txt_26, txt_27, txt_28, txt_29, txt_30, l_extraFuncs, l_extraFuncsDecl, l_className, txt_31, txt_33, txt_34, l_stateDerVectorName) := CodegenCpp.simulationCppFile(Tpl.emptyTxt, i_simCode, SimCodeFunction.contextOther, txt_26, txt_27, txt_28, txt_29, txt_30, l_extraFuncs, l_extraFuncsDecl, l_className, txt_31, txt_33, txt_34, l_stateDerVectorName, false);
191 ✗ txt_36 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp"));
192 ✗ txt_36 := Tpl.writeStr(txt_36, i_fileNamePrefix);
193 ✗ txt_36 := Tpl.writeTok(txt_36, Tpl.ST_STRING(".cpp"));
194 ✗ Tpl.textFile(txt_35, Tpl.textString(txt_36));
195 ✗ (txt_37, l_extraFuncs, l_extraFuncsDecl, l_className) := CodegenCppHpcom.additionalHpcomIncludes(Tpl.emptyTxt, i_simCode, l_extraFuncs, l_extraFuncsDecl, l_className, false);
196 ✗ (txt_38, l_extraFuncs, l_extraFuncsDecl, _) := CodegenCppHpcom.additionalHpcomProtectedMemberDeclaration(Tpl.emptyTxt, i_simCode, l_extraFuncs, l_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")), false);
197 ✗ txt_39 := Tpl.writeText(Tpl.emptyTxt, l_numRealVars);
198 ✗ txt_39 := Tpl.writeTok(txt_39, Tpl.ST_STRING("-1"));
199 ✗ txt_40 := Tpl.writeText(Tpl.emptyTxt, l_numIntVars);
200 ✗ txt_40 := Tpl.writeTok(txt_40, Tpl.ST_STRING("-1"));
201 ✗ txt_41 := Tpl.writeText(Tpl.emptyTxt, l_numBoolVars);
202 ✗ txt_41 := Tpl.writeTok(txt_41, Tpl.ST_STRING("-1"));
203 ✗ txt_42 := Tpl.writeText(Tpl.emptyTxt, l_numStringVars);
204 ✗ txt_42 := Tpl.writeTok(txt_42, Tpl.ST_STRING("-1"));
205 ✗ ret_43 := Flags.isSet(Flags.GEN_DEBUG_SYMBOLS);
206 ✗ (txt_44, txt_39, txt_40, txt_41, txt_42) := CodegenCpp.memberVariableDefine(Tpl.emptyTxt, i_modelInfo, i_varToArrayIndexMapping, txt_39, txt_40, txt_41, txt_42, ret_43, false);
207 ✗ (txt_45, l_extraFuncs, l_extraFuncsDecl, _) := CodegenCpp.simulationHeaderFile(Tpl.emptyTxt, i_simCode, SimCodeFunction.contextOther, l_extraFuncs, l_extraFuncsDecl, Tpl.strTokText(Tpl.ST_STRING("")), Tpl.textString(txt_37), "", Tpl.textString(txt_38), Tpl.textString(txt_44), false);
208 ✗ txt_46 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OMCpp"));
209 ✗ txt_46 := Tpl.writeStr(txt_46, i_fileNamePrefix);
210 ✗ txt_46 := Tpl.writeTok(txt_46, Tpl.ST_STRING(".h"));
211 ✗ Tpl.textFile(txt_45, Tpl.textString(txt_46));
212 then txt;
213
214 case ( txt,
215 _,
216 _,
217 _ )
218 then txt;
219 end match;
220 end translateModel;
221
222 protected function fun_53
223 input Tpl.Text in_txt;
224 input Boolean in_mArg;
225
226 output Tpl.Text out_txt;
227 algorithm
228 out_txt :=
229 match(in_txt, in_mArg)
230 local
231 Tpl.Text txt;
232
233 case ( txt,
234 false )
235 then txt;
236
237 case ( txt,
238 _ )
239 algorithm
240 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" -lpthread"));
241 then txt;
242 end match;
243 end fun_53;
244
245 public function fmuMakefile
246 input Tpl.Text txt;
247 input String a_target;
248 input SimCode.SimCode a_simCode;
249 input Tpl.Text a_extraFuncs;
250 input Tpl.Text a_extraFuncsDecl;
251 input Tpl.Text a_extraFuncsNamespace;
252 input String a_FMUVersion;
253
254 output Tpl.Text out_txt;
255 output Tpl.Text out_a_extraFuncs;
256 output Tpl.Text out_a_extraFuncsDecl;
257 output Tpl.Text out_a_extraFuncsNamespace;
258 protected
259 Boolean ret_8;
260 Boolean ret_7;
261 Boolean ret_6;
262 Tpl.Text l_additionalLinkerFlags__MSVC;
263 Tpl.Text l_additionalLinkerFlags__GCC;
264 Tpl.Text l_additionalCFlags__MSVC;
265 Tpl.Text l_additionalCFlags__GCC;
266 String ret_1;
267 Tpl.Text l_type;
268 algorithm
269 ✗ ret_1 := Flags.getConfigString(Flags.HPCOM_CODE);
270 ✗ l_type := Tpl.writeStr(Tpl.emptyTxt, ret_1);
271 ✗ l_additionalCFlags__GCC := Tpl.emptyTxt;
272 ✗ l_additionalCFlags__MSVC := Tpl.emptyTxt;
273 ✗ l_additionalLinkerFlags__GCC := Tpl.emptyTxt;
274 ✗ l_additionalLinkerFlags__MSVC := Tpl.emptyTxt;
275 ✗ ret_6 := stringEq(Tpl.textString(l_type), "pthreads");
276 ✗ ret_7 := stringEq(Tpl.textString(l_type), "pthreads_spin");
277 ✗ ret_8 := boolOr(ret_6, ret_7);
278 ✗ l_additionalLinkerFlags__GCC := fun_53(l_additionalLinkerFlags__GCC, ret_8);
279 ✗ (out_txt, l_additionalCFlags__GCC, l_additionalCFlags__MSVC, l_additionalLinkerFlags__GCC, l_additionalLinkerFlags__MSVC) := CodegenCppHpcom.getAdditionalMakefileFlags(txt, l_additionalCFlags__GCC, l_additionalCFlags__MSVC, l_additionalLinkerFlags__GCC, l_additionalLinkerFlags__MSVC);
280 ✗ out_txt := Tpl.softNewLine(out_txt);
281 ✗ (out_txt, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace) := CodegenFMUCpp.fmuMakefile(out_txt, a_target, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_FMUVersion, Tpl.textString(l_additionalLinkerFlags__GCC), Tpl.textString(l_additionalLinkerFlags__MSVC), Tpl.textString(l_additionalCFlags__GCC), Tpl.textString(l_additionalCFlags__MSVC), "");
282 end fmuMakefile;
283
284 annotation(__OpenModelica_Interface="codegen_cpp_ext");
285 end CodegenFMUCppHpcom;
286