Linux GNU 11.4.0 Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 70.8% 315 / 0 / 445
Functions: -% 0 / 1 / 1
Branches: 72.2% 26 / 0 / 36

build_cmake/OMCompiler/Compiler/generated-mo/Template/CodegenUtilSimulation.mo
Line Branch Exec Source
1 encapsulated package CodegenUtilSimulation
2 "
3 file: CodegenUtilSimulation.mo
4 package: CodegenUtilSimulation
5 description: Generated by Susan.
6 "
7
8 public import Tpl;
9
10 public import SimCodeVar;
11 public import HashTableCrefSimVar;
12 public import SimCode;
13 public import SimCodeFunction;
14 public import SimCodeCodegenUtil;
15 public import SimCodeFunctionUtil;
16 public import BackendDAE;
17 public import System;
18 public import Autoconf;
19 protected import Absyn;
20 protected import AbsynUtil;
21 public import MMath;
22 public import DAE;
23 public import ClassInf;
24 public import ClassInfUtil;
25 protected import SCode;
26 protected import SCodeDump;
27 public import StringUtil;
28 public import Util;
29 public import List;
30 public import ComponentReferenceBasics;
31 public import ComponentReference;
32 public import Expression;
33 protected import ExpressionDump;
34 public import ExpressionBasics;
35 public import Config;
36 public import Testsuite;
37 public import Flags;
38 public import FlagsUtil;
39 public import Settings;
40 public import Patternm;
41 public import Error;
42 public import Values;
43 public import ValuesUtil;
44 public import DAEDump;
45 public import Algorithm;
46 protected import ElementSource;
47 public import DAEUtil;
48 public import TypesDump;
49 public import Types;
50 public import HashTableCrIListArray;
51 public import ExpressionDumpTpl;
52 public import CodegenUtil;
53
54 public function modelNamePrefix
55 input Tpl.Text in_txt;
56 input SimCode.SimCode in_a_simCode;
57
58 output Tpl.Text out_txt;
59 algorithm
60 out_txt :=
61 match(in_txt, in_a_simCode)
62 local
63 Tpl.Text txt;
64 String i_fileNamePrefix;
65 String ret_0;
66
67 case ( txt,
68 SimCode.SIMCODE(fileNamePrefix = i_fileNamePrefix) )
69 algorithm
70 42131 ret_0 := System.makeC89Identifier(i_fileNamePrefix);
71 42131 txt := Tpl.writeStr(txt, ret_0);
72 then txt;
73
74 case ( txt,
75 _ )
76 then txt;
77 end match;
78 end modelNamePrefix;
79
80 public function fileNamePrefix
81 input Tpl.Text in_txt;
82 input SimCode.SimCode in_a_simCode;
83
84 output Tpl.Text out_txt;
85 algorithm
86 out_txt :=
87 match(in_txt, in_a_simCode)
88 local
89 Tpl.Text txt;
90 String i_fileNamePrefix;
91
92 case ( txt,
93 SimCode.SIMCODE(fileNamePrefix = i_fileNamePrefix) )
94 algorithm
95 2400 txt := Tpl.writeStr(txt, i_fileNamePrefix);
96 then txt;
97
98 case ( txt,
99 _ )
100 then txt;
101 end match;
102 end fileNamePrefix;
103
104 public function fullPathPrefix
105 input Tpl.Text in_txt;
106 input SimCode.SimCode in_a_simCode;
107
108 output Tpl.Text out_txt;
109 algorithm
110 out_txt :=
111 match(in_txt, in_a_simCode)
112 local
113 Tpl.Text txt;
114 String i_fullPathPrefix;
115
116 case ( txt,
117 SimCode.SIMCODE(fullPathPrefix = i_fullPathPrefix) )
118 algorithm
119 ✗ txt := Tpl.writeStr(txt, i_fullPathPrefix);
120 then txt;
121
122 case ( txt,
123 _ )
124 then txt;
125 end match;
126 end fullPathPrefix;
127
128 public function equationIndex
129 input Tpl.Text in_txt;
130 input SimCode.SimEqSystem in_a_eq;
131
132 output Tpl.Text out_txt;
133 algorithm
134 out_txt :=
135 match(in_txt, in_a_eq)
136 local
137 Tpl.Text txt;
138 Integer i_aliasOf;
139 Integer i_nls_index;
140 Integer i_ls_index;
141 Integer i_index;
142
143 case ( txt,
144 SimCode.SES_RESIDUAL(index = i_index) )
145 algorithm
146 10340 txt := Tpl.writeStr(txt, intString(i_index));
147 then txt;
148
149 case ( txt,
150 SimCode.SES_FOR_RESIDUAL(index = i_index) )
151 algorithm
152 42 txt := Tpl.writeStr(txt, intString(i_index));
153 then txt;
154
155 case ( txt,
156 SimCode.SES_GENERIC_RESIDUAL(index = i_index) )
157 algorithm
158 ✗ txt := Tpl.writeStr(txt, intString(i_index));
159 then txt;
160
161 case ( txt,
162 SimCode.SES_SIMPLE_ASSIGN(index = i_index) )
163 algorithm
164 806289 txt := Tpl.writeStr(txt, intString(i_index));
165 then txt;
166
167 case ( txt,
168 SimCode.SES_SIMPLE_ASSIGN_CONSTRAINTS(index = i_index) )
169 algorithm
170 24 txt := Tpl.writeStr(txt, intString(i_index));
171 then txt;
172
173 case ( txt,
174 SimCode.SES_ARRAY_CALL_ASSIGN(index = i_index) )
175 algorithm
176 4137 txt := Tpl.writeStr(txt, intString(i_index));
177 then txt;
178
179 case ( txt,
180 SimCode.SES_RESIZABLE_ASSIGN(index = i_index) )
181 algorithm
182 1438 txt := Tpl.writeStr(txt, intString(i_index));
183 then txt;
184
185 case ( txt,
186 SimCode.SES_GENERIC_ASSIGN(index = i_index) )
187 algorithm
188 110 txt := Tpl.writeStr(txt, intString(i_index));
189 then txt;
190
191 case ( txt,
192 SimCode.SES_ENTWINED_ASSIGN(index = i_index) )
193 algorithm
194 9 txt := Tpl.writeStr(txt, intString(i_index));
195 then txt;
196
197 case ( txt,
198 SimCode.SES_IFEQUATION(index = i_index) )
199 algorithm
200 40 txt := Tpl.writeStr(txt, intString(i_index));
201 then txt;
202
203 case ( txt,
204 SimCode.SES_ALGORITHM(index = i_index) )
205 algorithm
206 117628 txt := Tpl.writeStr(txt, intString(i_index));
207 then txt;
208
209 case ( txt,
210 SimCode.SES_INVERSE_ALGORITHM(index = i_index) )
211 algorithm
212 18 txt := Tpl.writeStr(txt, intString(i_index));
213 then txt;
214
215 case ( txt,
216 SimCode.SES_LINEAR(lSystem = SimCode.LINEARSYSTEM(index = i_ls_index)) )
217 algorithm
218 5761 txt := Tpl.writeStr(txt, intString(i_ls_index));
219 then txt;
220
221 case ( txt,
222 SimCode.SES_NONLINEAR(nlSystem = SimCode.NONLINEARSYSTEM(index = i_nls_index)) )
223 algorithm
224 5673 txt := Tpl.writeStr(txt, intString(i_nls_index));
225 then txt;
226
227 case ( txt,
228 SimCode.SES_MIXED(index = i_index) )
229 algorithm
230 ✗ txt := Tpl.writeStr(txt, intString(i_index));
231 then txt;
232
233 case ( txt,
234 SimCode.SES_WHEN(index = i_index) )
235 algorithm
236 2014 txt := Tpl.writeStr(txt, intString(i_index));
237 then txt;
238
239 case ( txt,
240 SimCode.SES_FOR_LOOP(index = i_index) )
241 algorithm
242 62 txt := Tpl.writeStr(txt, intString(i_index));
243 then txt;
244
245 case ( txt,
246 SimCode.SES_FOR_EQUATION(index = i_index) )
247 algorithm
248 9 txt := Tpl.writeStr(txt, intString(i_index));
249 then txt;
250
251 case ( txt,
252 SimCode.SES_ALIAS(aliasOf = i_aliasOf) )
253 algorithm
254 78505 txt := Tpl.writeStr(txt, intString(i_aliasOf));
255 then txt;
256
257 case ( txt,
258 _ )
259 algorithm
260 ✗ txt := CodegenUtil.error(txt, Tpl.sourceInfo("CodegenUtilSimulation.tpl", 136, 14), "equationIndex failed");
261 then txt;
262 end match;
263 end equationIndex;
264
265 public function equationIndexAlternativeTearing
266 input Tpl.Text in_txt;
267 input SimCode.SimEqSystem in_a_eq;
268
269 output Tpl.Text out_txt;
270 algorithm
271 out_txt :=
272 match(in_txt, in_a_eq)
273 local
274 Tpl.Text txt;
275 Integer i_at_index;
276
277 case ( txt,
278 SimCode.SES_LINEAR(alternativeTearing = SOME(SimCode.LINEARSYSTEM(index = i_at_index))) )
279 algorithm
280 ✗ txt := Tpl.writeStr(txt, intString(i_at_index));
281 then txt;
282
283 case ( txt,
284 SimCode.SES_NONLINEAR(alternativeTearing = SOME(SimCode.NONLINEARSYSTEM(index = i_at_index))) )
285 algorithm
286 18 txt := Tpl.writeStr(txt, intString(i_at_index));
287 then txt;
288
289 case ( txt,
290 _ )
291 then txt;
292 end match;
293 end equationIndexAlternativeTearing;
294
295 public function equationIndexGeneral
296 input Tpl.Text in_txt;
297 input SimCode.SimEqSystem in_a_eq;
298
299 output Tpl.Text out_txt;
300 algorithm
301 out_txt :=
302 match(in_txt, in_a_eq)
303 local
304 Tpl.Text txt;
305 SimCode.SimEqSystem i_eq;
306
307 case ( txt,
308 (i_eq as SimCode.SES_LINEAR(alternativeTearing = SOME(_))) )
309 algorithm
310 ✗ txt := equationIndexAlternativeTearing(txt, i_eq);
311 then txt;
312
313 case ( txt,
314 (i_eq as SimCode.SES_NONLINEAR(alternativeTearing = SOME(_))) )
315 algorithm
316 12 txt := equationIndexAlternativeTearing(txt, i_eq);
317 then txt;
318
319 case ( txt,
320 i_eq )
321 algorithm
322 481467 txt := equationIndex(txt, i_eq);
323 then txt;
324 end match;
325 end equationIndexGeneral;
326
327 protected function fun_51
328 input Tpl.Text in_txt;
329 input String in_mArg;
330 input list<SimCode.SimEqSystem> in_a_eqs;
331
332 output Tpl.Text out_txt;
333 algorithm
334 out_txt :=
335 match(in_txt, in_mArg, in_a_eqs)
336 local
337 Tpl.Text txt;
338 list<SimCode.SimEqSystem> a_eqs;
339
340 case ( txt,
341 "none",
342 a_eqs )
343 algorithm
344 229993 txt := dumpEqsWork(txt, a_eqs);
345 then txt;
346
347 case ( txt,
348 _,
349 _ )
350 then txt;
351 end match;
352 end fun_51;
353
354 public function dumpEqs
355 input Tpl.Text txt;
356 input list<SimCode.SimEqSystem> a_eqs;
357
358 output Tpl.Text out_txt;
359 protected
360 String ret_0;
361 algorithm
362 229993 ret_0 := Flags.getConfigString(Flags.OBFUSCATE);
363 229993 out_txt := fun_51(txt, ret_0, a_eqs);
364 end dumpEqs;
365
366 protected function lm_53
367 input output Tpl.Text txt;
368 input list<DAE.Statement> items;
369 algorithm
370
2/2
✓ Branch 0 taken 38920 times.
✓ Branch 1 taken 35364 times.
74284 for lstElt_53 in items loop
371 txt := match lstElt_53
372 local
373 DAE.Statement i_stmt;
374 String ret_0;
375
376 case i_stmt
377 algorithm
378 38920 ret_0 := DAEDump.ppStmtStr(i_stmt, 2);
379 38920 txt := CodegenUtil.escapeCComments(txt, ret_0);
380 then txt;
381 end match;
382 end for;
383 end lm_53;
384
385 protected function lm_54
386 input output Tpl.Text txt;
387 input list<DAE.Statement> items;
388 algorithm
389
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3 times.
11 for lstElt_54 in items loop
390 txt := match lstElt_54
391 local
392 DAE.Statement i_stmt;
393 String ret_0;
394
395 case i_stmt
396 algorithm
397 8 ret_0 := DAEDump.ppStmtStr(i_stmt, 2);
398 8 txt := CodegenUtil.escapeCComments(txt, ret_0);
399 then txt;
400 end match;
401 end for;
402 end lm_54;
403
404 protected function lm_55
405 input output Tpl.Text txt;
406 input list<SimCodeVar.SimVar> items;
407 algorithm
408
2/2
✓ Branch 0 taken 7561 times.
✓ Branch 1 taken 1124 times.
8685 for lstElt_55 in items loop
409 txt := match lstElt_55
410 local
411 DAE.ComponentRef i_cr;
412 Tpl.Text txt_0;
413
414 case SimCodeVar.SIMVAR(name = i_cr)
415 algorithm
416 7561 txt := Tpl.writeTok(txt, Tpl.ST_STRING("<var>"));
417 7561 txt_0 := ExpressionDumpTpl.dumpCref(Tpl.emptyTxt, i_cr);
418 7561 txt := CodegenUtil.escapeCComments(txt, Tpl.textString(txt_0));
419 7561 txt := Tpl.writeTok(txt, Tpl.ST_STRING("</var>"));
420 7561 txt := Tpl.nextIter(txt);
421 then txt;
422
423 case _
424 then txt;
425 end match;
426 end for;
427 end lm_55;
428
429 protected function lm_56
430 input output Tpl.Text txt;
431 input list<DAE.Exp> items;
432 algorithm
433
2/2
✓ Branch 0 taken 3115 times.
✓ Branch 1 taken 1124 times.
4239 for lstElt_56 in items loop
434 txt := match lstElt_56
435 local
436 DAE.Exp i_exp;
437 Tpl.Text txt_0;
438
439 case i_exp
440 algorithm
441 3115 txt := Tpl.writeTok(txt, Tpl.ST_STRING("<cell>"));
442 3115 txt_0 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_exp, "\"");
443 3115 txt := CodegenUtil.escapeCComments(txt, Tpl.textString(txt_0));
444 3115 txt := Tpl.writeTok(txt, Tpl.ST_STRING("</cell>"));
445 3115 txt := Tpl.nextIter(txt);
446 then txt;
447 end match;
448 end for;
449 end lm_56;
450
451 protected function fun_57
452 input Tpl.Text in_txt;
453 input SimCode.SimEqSystem in_a_eq;
454
455 output Tpl.Text out_txt;
456 algorithm
457 out_txt :=
458 match(in_txt, in_a_eq)
459 local
460 Tpl.Text txt;
461 DAE.Exp i_e_exp;
462 Tpl.Text txt_2;
463 Tpl.Text txt_1;
464 Tpl.Text txt_0;
465
466 case ( txt,
467 SimCode.SES_RESIDUAL(exp = i_e_exp) )
468 algorithm
469 11090 txt := Tpl.writeTok(txt, Tpl.ST_STRING("<residual>"));
470 11090 txt_0 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_e_exp, "\"");
471 11090 txt := CodegenUtil.escapeCComments(txt, Tpl.textString(txt_0));
472 11090 txt := Tpl.writeTok(txt, Tpl.ST_STRING("</residual>"));
473 then txt;
474
475 case ( txt,
476 SimCode.SES_FOR_RESIDUAL(exp = i_e_exp) )
477 algorithm
478 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<residual>"));
479 ✗ txt_1 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_e_exp, "\"");
480 ✗ txt := CodegenUtil.escapeCComments(txt, Tpl.textString(txt_1));
481 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("</residual>"));
482 then txt;
483
484 case ( txt,
485 SimCode.SES_GENERIC_RESIDUAL(exp = i_e_exp) )
486 algorithm
487 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<residual>"));
488 ✗ txt_2 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_e_exp, "\"");
489 ✗ txt := CodegenUtil.escapeCComments(txt, Tpl.textString(txt_2));
490 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("</residual>"));
491 then txt;
492
493 case ( txt,
494 _ )
495 then txt;
496 end match;
497 end fun_57;
498
499 protected function lm_58
500 input output Tpl.Text txt;
501 input list<tuple<Integer, Integer, SimCode.SimEqSystem>> items;
502 algorithm
503
2/2
✓ Branch 0 taken 11090 times.
✓ Branch 1 taken 1124 times.
12214 for lstElt_58 in items loop
504 txt := match lstElt_58
505 local
506 SimCode.SimEqSystem i_eq;
507 Integer i_i2;
508 Integer i_i1;
509
510 case (i_i1, i_i2, i_eq)
511 algorithm
512 11090 txt := Tpl.writeTok(txt, Tpl.ST_STRING("<cell row=\""));
513 11090 txt := Tpl.writeStr(txt, intString(i_i1));
514 11090 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\" col=\""));
515 11090 txt := Tpl.writeStr(txt, intString(i_i2));
516 11090 txt := Tpl.writeTok(txt, Tpl.ST_LINE("\">\n"));
517 11090 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
518 11090 txt := fun_57(txt, i_eq);
519 11090 txt := Tpl.softNewLine(txt);
520 11090 txt := Tpl.popBlock(txt);
521 11090 txt := Tpl.writeTok(txt, Tpl.ST_STRING("</cell>"));
522 then txt;
523 end match;
524 end for;
525 end lm_58;
526
527 protected function lm_59
528 input output Tpl.Text txt;
529 input list<DAE.ComponentRef> items;
530 algorithm
531
2/2
✓ Branch 0 taken 3697 times.
✓ Branch 1 taken 1150 times.
4847 for lstElt_59 in items loop
532 txt := match lstElt_59
533 local
534 DAE.ComponentRef i_cr;
535 Tpl.Text txt_0;
536
537 case i_cr
538 algorithm
539 3697 txt_0 := ExpressionDumpTpl.dumpCref(Tpl.emptyTxt, i_cr);
540 3697 txt := CodegenUtil.escapeCComments(txt, Tpl.textString(txt_0));
541 3697 txt := Tpl.nextIter(txt);
542 then txt;
543 end match;
544 end for;
545 end lm_59;
546
547 protected function lm_60
548 input output Tpl.Text txt;
549 input list<SimCode.SimEqSystem> items;
550 algorithm
551
2/2
✓ Branch 0 taken 21842 times.
✓ Branch 1 taken 1150 times.
22992 for lstElt_60 in items loop
552 txt := match lstElt_60
553 local
554 SimCode.SimEqSystem i_eq;
555
556 case i_eq
557 algorithm
558 21842 txt := equationIndex(txt, i_eq);
559 21842 txt := Tpl.nextIter(txt);
560 then txt;
561 end match;
562 end for;
563 end lm_60;
564
565 protected function lm_61
566 input output Tpl.Text txt;
567 input list<SimCodeVar.SimVar> items;
568 algorithm
569 ✗ for lstElt_61 in items loop
570 txt := match lstElt_61
571 local
572 DAE.ComponentRef i_cr;
573 Tpl.Text txt_0;
574
575 case SimCodeVar.SIMVAR(name = i_cr)
576 algorithm
577 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<var>"));
578 ✗ txt_0 := ExpressionDumpTpl.dumpCref(Tpl.emptyTxt, i_cr);
579 ✗ txt := CodegenUtil.escapeCComments(txt, Tpl.textString(txt_0));
580 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("</var>"));
581 ✗ txt := Tpl.nextIter(txt);
582 then txt;
583
584 case _
585 then txt;
586 end match;
587 end for;
588 end lm_61;
589
590 protected function lm_62
591 input output Tpl.Text txt;
592 input list<SimCode.SimEqSystem> items;
593 algorithm
594 ✗ for lstElt_62 in items loop
595 txt := match lstElt_62
596 local
597 SimCode.SimEqSystem i_eq;
598
599 case i_eq
600 algorithm
601 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<discrete index=\""));
602 ✗ txt := equationIndex(txt, i_eq);
603 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\" />"));
604 then txt;
605 end match;
606 end for;
607 end lm_62;
608
609 protected function lm_63
610 input output Tpl.Text txt;
611 input list<DAE.ComponentRef> items;
612 algorithm
613
2/2
✓ Branch 0 taken 648 times.
✓ Branch 1 taken 568 times.
1216 for lstElt_63 in items loop
614 txt := match lstElt_63
615 local
616 DAE.ComponentRef i_cond;
617 Tpl.Text txt_0;
618
619 case i_cond
620 algorithm
621 648 txt_0 := ExpressionDumpTpl.dumpCref(Tpl.emptyTxt, i_cond);
622 648 txt := CodegenUtil.escapeCComments(txt, Tpl.textString(txt_0));
623 648 txt := Tpl.nextIter(txt);
624 then txt;
625 end match;
626 end for;
627 end lm_63;
628
629 protected function lm_64
630 input output Tpl.Text txt;
631 input list<tuple<DAE.Exp, list<SimCode.SimEqSystem>>> items;
632 algorithm
633
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
16 for lstElt_64 in items loop
634 txt := match lstElt_64
635 local
636 list<SimCode.SimEqSystem> i_eqs;
637
638 case (_, i_eqs)
639 algorithm
640 8 txt := dumpEqs(txt, i_eqs);
641 then txt;
642 end match;
643 end for;
644 end lm_64;
645
646 protected function fun_65
647 input Tpl.Text in_txt;
648 input SimCode.SimEqSystem in_a_eq;
649
650 output Tpl.Text out_txt;
651 algorithm
652 out_txt :=
653 match(in_txt, in_a_eq)
654 local
655 Tpl.Text txt;
656 list<SimCode.SimEqSystem> i_e_single__calls;
657 Integer i_e_aliasOf;
658 list<SimCode.SimEqSystem> i_e_body;
659 DAE.Exp i_e_endIt;
660 DAE.Exp i_e_startIt;
661 DAE.Exp i_e_iter;
662 list<SimCode.SimEqSystem> i_elsebranch;
663 list<tuple<DAE.Exp, list<SimCode.SimEqSystem>>> i_ifbranches;
664 list<DAE.ComponentRef> i_conditions;
665 list<BackendDAE.WhenOperator> i_whenStmtLst;
666 list<SimCodeVar.SimVar> i_e_discVars;
667 list<SimCode.SimEqSystem> i_e_discEqs;
668 SimCode.SimEqSystem i_e_cont;
669 list<SimCode.SimEqSystem> i_nls_eqs;
670 list<DAE.ComponentRef> i_nls_crefs;
671 Integer i_nls_indexNonLinearSystem;
672 list<tuple<Integer, Integer, SimCode.SimEqSystem>> i_ls_simJac;
673 list<DAE.Exp> i_ls_beqs;
674 list<SimCodeVar.SimVar> i_ls_vars;
675 list<DAE.Statement> i_e_statements;
676 Integer i_e_call__index;
677 DAE.ComponentRef i_lhs_componentRef;
678 BackendDAE.Constraints i_e_cons;
679 DAE.ComponentRef i_e_cref;
680 DAE.Exp i_e_exp;
681 SimCode.SimEqSystem i_e;
682 Tpl.Text txt_22;
683 Tpl.Text txt_21;
684 Tpl.Text txt_20;
685 Tpl.Text txt_19;
686 Tpl.Text txt_18;
687 Tpl.Text txt_17;
688 Tpl.Text txt_16;
689 Tpl.Text txt_15;
690 Tpl.Text l_forstatement;
691 Tpl.Text l_elsebr;
692 Tpl.Text l_branches;
693 Tpl.Text l_body;
694 list<SimCode.SimEqSystem> ret_10;
695 Tpl.Text txt_9;
696 Tpl.Text txt_8;
697 Tpl.Text txt_7;
698 Tpl.Text txt_6;
699 Tpl.Text txt_5;
700 Tpl.Text txt_4;
701 Tpl.Text txt_3;
702 Tpl.Text txt_2;
703 Tpl.Text txt_1;
704 Tpl.Text txt_0;
705
706 case ( txt,
707 (i_e as SimCode.SES_RESIDUAL(exp = i_e_exp)) )
708 algorithm
709 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("equation index: "));
710 ✗ txt := equationIndex(txt, i_e);
711 ✗ txt := Tpl.softNewLine(txt);
712 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("type: RESIDUAL\n"));
713 ✗ txt_0 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_e_exp, "\"");
714 ✗ txt := CodegenUtil.escapeCComments(txt, Tpl.textString(txt_0));
715 then txt;
716
717 case ( txt,
718 (i_e as SimCode.SES_FOR_RESIDUAL(exp = i_e_exp)) )
719 algorithm
720 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("equation index: "));
721 ✗ txt := equationIndex(txt, i_e);
722 ✗ txt := Tpl.softNewLine(txt);
723 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("type: FOR_RESIDUAL\n"));
724 ✗ txt_1 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_e_exp, "\"");
725 ✗ txt := CodegenUtil.escapeCComments(txt, Tpl.textString(txt_1));
726 then txt;
727
728 case ( txt,
729 (i_e as SimCode.SES_GENERIC_RESIDUAL(exp = i_e_exp)) )
730 algorithm
731 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("equation index: "));
732 ✗ txt := equationIndex(txt, i_e);
733 ✗ txt := Tpl.softNewLine(txt);
734 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("type: GENERIC_RESIDUAL\n"));
735 ✗ txt_2 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_e_exp, "\"");
736 ✗ txt := CodegenUtil.escapeCComments(txt, Tpl.textString(txt_2));
737 then txt;
738
739 case ( txt,
740 (i_e as SimCode.SES_SIMPLE_ASSIGN(cref = i_e_cref, exp = i_e_exp)) )
741 algorithm
742 190309 txt := Tpl.writeTok(txt, Tpl.ST_STRING("equation index: "));
743 190309 txt := equationIndex(txt, i_e);
744 190309 txt := Tpl.softNewLine(txt);
745 190309 txt := Tpl.writeTok(txt, Tpl.ST_LINE("type: SIMPLE_ASSIGN\n"));
746 190309 txt_3 := ExpressionDumpTpl.dumpCref(Tpl.emptyTxt, i_e_cref);
747 190309 txt := CodegenUtil.escapeCComments(txt, Tpl.textString(txt_3));
748 190309 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = "));
749 190309 txt_4 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_e_exp, "\"");
750 190309 txt := CodegenUtil.escapeCComments(txt, Tpl.textString(txt_4));
751 then txt;
752
753 case ( txt,
754 (i_e as SimCode.SES_SIMPLE_ASSIGN_CONSTRAINTS(cref = i_e_cref, exp = i_e_exp, cons = i_e_cons)) )
755 algorithm
756 4 txt := Tpl.writeTok(txt, Tpl.ST_STRING("equation index: "));
757 4 txt := equationIndex(txt, i_e);
758 4 txt := Tpl.softNewLine(txt);
759 4 txt := Tpl.writeTok(txt, Tpl.ST_LINE("type: SIMPLE_ASSIGN_CONSTRAINTS\n"));
760 4 txt_5 := ExpressionDumpTpl.dumpCref(Tpl.emptyTxt, i_e_cref);
761 4 txt := CodegenUtil.escapeCComments(txt, Tpl.textString(txt_5));
762 4 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = "));
763 4 txt_6 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_e_exp, "\"");
764 4 txt := CodegenUtil.escapeCComments(txt, Tpl.textString(txt_6));
765 4 txt := Tpl.softNewLine(txt);
766 4 txt := Tpl.writeTok(txt, Tpl.ST_STRING("constraints: "));
767 4 txt_7 := ExpressionDumpTpl.dumpConstraints(Tpl.emptyTxt, i_e_cons);
768 4 txt := CodegenUtil.escapeCComments(txt, Tpl.textString(txt_7));
769 then txt;
770
771 case ( txt,
772 (i_e as SimCode.SES_ARRAY_CALL_ASSIGN(lhs = DAE.CREF(componentRef = i_lhs_componentRef), exp = i_e_exp)) )
773 algorithm
774 1036 txt := Tpl.writeTok(txt, Tpl.ST_STRING("equation index: "));
775 1036 txt := equationIndex(txt, i_e);
776 1036 txt := Tpl.softNewLine(txt);
777 1036 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
778 "type: ARRAY_CALL_ASSIGN\n",
779 "\n"
780 }, true));
781 1036 txt_8 := ExpressionDumpTpl.dumpCref(Tpl.emptyTxt, i_lhs_componentRef);
782 1036 txt := CodegenUtil.escapeCComments(txt, Tpl.textString(txt_8));
783 1036 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = "));
784 1036 txt_9 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_e_exp, "\"");
785 1036 txt := CodegenUtil.escapeCComments(txt, Tpl.textString(txt_9));
786 then txt;
787
788 case ( txt,
789 (i_e as SimCode.SES_RESIZABLE_ASSIGN(call_index = i_e_call__index)) )
790 algorithm
791 386 txt := Tpl.writeTok(txt, Tpl.ST_STRING("equation index: "));
792 386 txt := equationIndex(txt, i_e);
793 386 txt := Tpl.softNewLine(txt);
794 386 txt := Tpl.writeTok(txt, Tpl.ST_STRING("type: SES_RESIZABLE_ASSIGN call index: "));
795 386 txt := Tpl.writeStr(txt, intString(i_e_call__index));
796 then txt;
797
798 case ( txt,
799 (i_e as SimCode.SES_GENERIC_ASSIGN(call_index = i_e_call__index)) )
800 algorithm
801 29 txt := Tpl.writeTok(txt, Tpl.ST_STRING("equation index: "));
802 29 txt := equationIndex(txt, i_e);
803 29 txt := Tpl.softNewLine(txt);
804 29 txt := Tpl.writeTok(txt, Tpl.ST_STRING("type: SES_GENERIC_ASSIGN call index: "));
805 29 txt := Tpl.writeStr(txt, intString(i_e_call__index));
806 then txt;
807
808 case ( txt,
809 SimCode.SES_ALGORITHM(statements = {}) )
810 algorithm
811 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("empty algorithm"));
812 then txt;
813
814 case ( txt,
815 (i_e as SimCode.SES_ALGORITHM(statements = (i_e_statements as _ :: _))) )
816 algorithm
817 35364 txt := Tpl.writeTok(txt, Tpl.ST_STRING("equation index: "));
818 35364 txt := equationIndex(txt, i_e);
819 35364 txt := Tpl.softNewLine(txt);
820 35364 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
821 "type: ALGORITHM\n",
822 "\n"
823 }, true));
824 35364 txt := lm_53(txt, i_e_statements);
825 then txt;
826
827 case ( txt,
828 (i_e as SimCode.SES_INVERSE_ALGORITHM(statements = (i_e_statements as _ :: _))) )
829 algorithm
830 3 txt := Tpl.writeTok(txt, Tpl.ST_STRING("equation index: "));
831 3 txt := equationIndex(txt, i_e);
832 3 txt := Tpl.softNewLine(txt);
833 3 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
834 "type: INVERSE ALGORITHM\n",
835 "\n"
836 }, true));
837 3 txt := lm_54(txt, i_e_statements);
838 then txt;
839
840 case ( txt,
841 (i_e as SimCode.SES_LINEAR(lSystem = SimCode.LINEARSYSTEM(vars = i_ls_vars, beqs = i_ls_beqs, simJac = i_ls_simJac))) )
842 algorithm
843 1124 txt := Tpl.writeTok(txt, Tpl.ST_STRING("equation index: "));
844 1124 txt := equationIndex(txt, i_e);
845 1124 txt := Tpl.softNewLine(txt);
846 1124 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
847 "type: LINEAR\n",
848 "\n"
849 }, true));
850 1124 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
851 1124 txt := lm_55(txt, i_ls_vars);
852 1124 txt := Tpl.popIter(txt);
853 1124 txt := Tpl.softNewLine(txt);
854 1124 txt := Tpl.writeTok(txt, Tpl.ST_LINE("<row>\n"));
855 1124 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
856 1124 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
857 1124 txt := lm_56(txt, i_ls_beqs);
858 1124 txt := Tpl.popIter(txt);
859 1124 txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
860 1124 txt := Tpl.popBlock(txt);
861 1124 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
862 "</row>\n",
863 "<matrix>\n"
864 }, true));
865 1124 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
866 1124 txt := lm_58(txt, i_ls_simJac);
867 1124 txt := Tpl.softNewLine(txt);
868 1124 txt := Tpl.popBlock(txt);
869 1124 txt := Tpl.writeTok(txt, Tpl.ST_STRING("</matrix>"));
870 then txt;
871
872 case ( txt,
873 (i_e as SimCode.SES_NONLINEAR(nlSystem = SimCode.NONLINEARSYSTEM(indexNonLinearSystem = i_nls_indexNonLinearSystem, crefs = i_nls_crefs, eqs = i_nls_eqs))) )
874 algorithm
875 1150 txt := Tpl.writeTok(txt, Tpl.ST_STRING("equation index: "));
876 1150 txt := equationIndex(txt, i_e);
877 1150 txt := Tpl.softNewLine(txt);
878 1150 txt := Tpl.writeTok(txt, Tpl.ST_STRING("indexNonlinear: "));
879 1150 txt := Tpl.writeStr(txt, intString(i_nls_indexNonLinearSystem));
880 1150 txt := Tpl.softNewLine(txt);
881 1150 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
882 "type: NONLINEAR\n",
883 "\n",
884 "vars: {"
885 }, false));
886 1150 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
887 1150 txt := lm_59(txt, i_nls_crefs);
888 1150 txt := Tpl.popIter(txt);
889 1150 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
890 "}\n",
891 "eqns: {"
892 }, false));
893 1150 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
894 1150 txt := lm_60(txt, i_nls_eqs);
895 1150 txt := Tpl.popIter(txt);
896 1150 txt := Tpl.writeTok(txt, Tpl.ST_STRING("}"));
897 then txt;
898
899 case ( txt,
900 (i_e as SimCode.SES_MIXED(cont = i_e_cont, discEqs = i_e_discEqs, discVars = i_e_discVars)) )
901 algorithm
902 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("equation index: "));
903 ✗ txt := equationIndex(txt, i_e);
904 ✗ txt := Tpl.softNewLine(txt);
905 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
906 "type: MIXED\n",
907 "\n"
908 }, true));
909 ✗ ret_10 := List.fill(i_e_cont, 1);
910 ✗ txt := dumpEqs(txt, ret_10);
911 ✗ txt := Tpl.softNewLine(txt);
912 ✗ txt := dumpEqs(txt, i_e_discEqs);
913 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
914 "\n",
915 "\n",
916 "<mixed>\n"
917 }, true));
918 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
919 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<continuous index=\""));
920 ✗ txt := equationIndex(txt, i_e_cont);
921 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("\" />\n"));
922 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(",")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
923 ✗ txt := lm_61(txt, i_e_discVars);
924 ✗ txt := Tpl.popIter(txt);
925 ✗ txt := Tpl.softNewLine(txt);
926 ✗ txt := lm_62(txt, i_e_discEqs);
927 ✗ txt := Tpl.softNewLine(txt);
928 ✗ txt := Tpl.popBlock(txt);
929 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("</mixed>"));
930 then txt;
931
932 case ( txt,
933 (i_e as SimCode.SES_WHEN(whenStmtLst = i_whenStmtLst, conditions = i_conditions)) )
934 algorithm
935 568 l_body := dumpWhenOps(Tpl.emptyTxt, i_whenStmtLst);
936 568 txt := Tpl.writeTok(txt, Tpl.ST_STRING("equation index: "));
937 568 txt := equationIndex(txt, i_e);
938 568 txt := Tpl.softNewLine(txt);
939 568 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
940 "type: WHEN\n",
941 "\n",
942 "when {"
943 }, false));
944 568 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
945 568 txt := lm_63(txt, i_conditions);
946 568 txt := Tpl.popIter(txt);
947 568 txt := Tpl.writeTok(txt, Tpl.ST_LINE("} then\n"));
948 568 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
949 568 txt := Tpl.writeText(txt, l_body);
950 568 txt := Tpl.softNewLine(txt);
951 568 txt := Tpl.popBlock(txt);
952 568 txt := Tpl.writeTok(txt, Tpl.ST_STRING("end when;"));
953 then txt;
954
955 case ( txt,
956 (i_e as SimCode.SES_IFEQUATION(ifbranches = i_ifbranches, elsebranch = i_elsebranch)) )
957 algorithm
958 8 l_branches := lm_64(Tpl.emptyTxt, i_ifbranches);
959 8 l_elsebr := dumpEqs(Tpl.emptyTxt, i_elsebranch);
960 8 txt := Tpl.writeTok(txt, Tpl.ST_STRING("equation index: "));
961 8 txt := equationIndex(txt, i_e);
962 8 txt := Tpl.softNewLine(txt);
963 8 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
964 "type: IFEQUATION\n",
965 "\n"
966 }, true));
967 8 txt := Tpl.writeText(txt, l_branches);
968 8 txt := Tpl.softNewLine(txt);
969 8 txt := Tpl.writeText(txt, l_elsebr);
970 then txt;
971
972 case ( txt,
973 (i_e as SimCode.SES_FOR_LOOP(iter = i_e_iter, startIt = i_e_startIt, endIt = i_e_endIt, cref = i_e_cref, exp = i_e_exp)) )
974 algorithm
975 l_forstatement := Tpl.emptyTxt;
976 12 l_forstatement := Tpl.writeTok(l_forstatement, Tpl.ST_STRING("for "));
977 12 txt_15 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_e_iter, "\"");
978 12 l_forstatement := CodegenUtil.escapeCComments(l_forstatement, Tpl.textString(txt_15));
979 12 l_forstatement := Tpl.writeTok(l_forstatement, Tpl.ST_STRING(" in "));
980 12 txt_16 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_e_startIt, "\"");
981 12 l_forstatement := CodegenUtil.escapeCComments(l_forstatement, Tpl.textString(txt_16));
982 12 l_forstatement := Tpl.writeTok(l_forstatement, Tpl.ST_STRING(" : "));
983 12 txt_17 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_e_endIt, "\"");
984 12 l_forstatement := CodegenUtil.escapeCComments(l_forstatement, Tpl.textString(txt_17));
985 12 l_forstatement := Tpl.pushBlock(l_forstatement, Tpl.BT_INDENT(1));
986 12 l_forstatement := Tpl.writeTok(l_forstatement, Tpl.ST_STRING("loop"));
987 12 l_forstatement := Tpl.writeTok(l_forstatement, Tpl.ST_NEW_LINE());
988 12 l_forstatement := Tpl.popBlock(l_forstatement);
989 12 l_forstatement := Tpl.pushBlock(l_forstatement, Tpl.BT_INDENT(2));
990 12 txt_18 := ExpressionDumpTpl.dumpCref(Tpl.emptyTxt, i_e_cref);
991 12 l_forstatement := CodegenUtil.escapeCComments(l_forstatement, Tpl.textString(txt_18));
992 12 l_forstatement := Tpl.writeTok(l_forstatement, Tpl.ST_STRING(" = "));
993 12 txt_19 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_e_exp, "\"");
994 12 l_forstatement := CodegenUtil.escapeCComments(l_forstatement, Tpl.textString(txt_19));
995 12 l_forstatement := Tpl.writeTok(l_forstatement, Tpl.ST_STRING("; "));
996 12 l_forstatement := Tpl.popBlock(l_forstatement);
997 12 l_forstatement := Tpl.writeTok(l_forstatement, Tpl.ST_STRING("end for"));
998 12 txt := Tpl.writeTok(txt, Tpl.ST_STRING("equation index: "));
999 12 txt := equationIndex(txt, i_e);
1000 12 txt := Tpl.softNewLine(txt);
1001 12 txt := Tpl.writeTok(txt, Tpl.ST_LINE("type: FOR_LOOP\n"));
1002 12 txt := Tpl.writeText(txt, l_forstatement);
1003 then txt;
1004
1005 case ( txt,
1006 (i_e as SimCode.SES_FOR_EQUATION(iter = i_e_iter, startIt = i_e_startIt, endIt = i_e_endIt, body = i_e_body)) )
1007 algorithm
1008 l_forstatement := Tpl.emptyTxt;
1009 2 l_forstatement := Tpl.writeTok(l_forstatement, Tpl.ST_STRING("for "));
1010 2 txt_20 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_e_iter, "\"");
1011 2 l_forstatement := CodegenUtil.escapeCComments(l_forstatement, Tpl.textString(txt_20));
1012 2 l_forstatement := Tpl.writeTok(l_forstatement, Tpl.ST_STRING(" in "));
1013 2 txt_21 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_e_startIt, "\"");
1014 2 l_forstatement := CodegenUtil.escapeCComments(l_forstatement, Tpl.textString(txt_21));
1015 2 l_forstatement := Tpl.writeTok(l_forstatement, Tpl.ST_STRING(" : "));
1016 2 txt_22 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_e_endIt, "\"");
1017 2 l_forstatement := CodegenUtil.escapeCComments(l_forstatement, Tpl.textString(txt_22));
1018 2 l_forstatement := Tpl.pushBlock(l_forstatement, Tpl.BT_INDENT(1));
1019 2 l_forstatement := Tpl.writeTok(l_forstatement, Tpl.ST_STRING("loop"));
1020 2 l_forstatement := Tpl.writeTok(l_forstatement, Tpl.ST_NEW_LINE());
1021 2 l_forstatement := Tpl.popBlock(l_forstatement);
1022 2 l_forstatement := Tpl.pushBlock(l_forstatement, Tpl.BT_INDENT(2));
1023 2 l_forstatement := dumpEqs(l_forstatement, i_e_body);
1024 2 l_forstatement := Tpl.writeTok(l_forstatement, Tpl.ST_STRING(";"));
1025 2 l_forstatement := Tpl.popBlock(l_forstatement);
1026 2 l_forstatement := Tpl.writeTok(l_forstatement, Tpl.ST_STRING("end for"));
1027 2 txt := Tpl.writeTok(txt, Tpl.ST_STRING("equation index: "));
1028 2 txt := equationIndex(txt, i_e);
1029 2 txt := Tpl.softNewLine(txt);
1030 2 txt := Tpl.writeTok(txt, Tpl.ST_LINE("type: FOR_EQUATION\n"));
1031 2 txt := Tpl.writeText(txt, l_forstatement);
1032 then txt;
1033
1034 case ( txt,
1035 (i_e as SimCode.SES_ALIAS(aliasOf = i_e_aliasOf)) )
1036 algorithm
1037 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("equation index: "));
1038 ✗ txt := equationIndex(txt, i_e);
1039 ✗ txt := Tpl.softNewLine(txt);
1040 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("type: ALIAS\n"));
1041 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
1042 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("alias of "));
1043 ✗ txt := Tpl.writeStr(txt, intString(i_e_aliasOf));
1044 ✗ txt := Tpl.popBlock(txt);
1045 then txt;
1046
1047 case ( txt,
1048 (i_e as SimCode.SES_ENTWINED_ASSIGN(single_calls = i_e_single__calls)) )
1049 algorithm
1050 2 txt := Tpl.writeTok(txt, Tpl.ST_STRING("equation index: "));
1051 2 txt := equationIndex(txt, i_e);
1052 2 txt := Tpl.softNewLine(txt);
1053 2 txt := Tpl.writeTok(txt, Tpl.ST_LINE("type: ENTWINED_ASSIGN\n"));
1054 2 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
1055 2 txt := dumpEqs(txt, i_e_single__calls);
1056 2 txt := Tpl.popBlock(txt);
1057 then txt;
1058
1059 case ( txt,
1060 _ )
1061 algorithm
1062 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("unknown equation"));
1063 then txt;
1064 end match;
1065 end fun_65;
1066
1067 protected function lm_66
1068 input output Tpl.Text txt;
1069 input list<SimCode.SimEqSystem> items;
1070 algorithm
1071
2/2
✓ Branch 0 taken 229997 times.
✓ Branch 1 taken 229993 times.
459990 for lstElt_66 in items loop
1072 txt := match lstElt_66
1073 local
1074 SimCode.SimEqSystem i_eq;
1075
1076 case i_eq
1077 algorithm
1078 229997 txt := fun_65(txt, i_eq);
1079 then txt;
1080 end match;
1081 end for;
1082 end lm_66;
1083
1084 public function dumpEqsWork
1085 input Tpl.Text txt;
1086 input list<SimCode.SimEqSystem> a_eqs;
1087
1088 output Tpl.Text out_txt;
1089 algorithm
1090 229993 out_txt := lm_66(txt, a_eqs);
1091 end dumpEqsWork;
1092
1093 public function dumpWhenOps
1094 input Tpl.Text in_txt;
1095 input list<BackendDAE.WhenOperator> in_a_whenOps;
1096
1097 output Tpl.Text out_txt;
1098 algorithm
1099 out_txt :=
1100 match(in_txt, in_a_whenOps)
1101 local
1102 Tpl.Text txt;
1103 DAE.Exp i_e_exp;
1104 DAE.Exp i_e_level;
1105 DAE.Exp i_e_message;
1106 DAE.Exp i_e_condition;
1107 DAE.Exp i_e_value;
1108 DAE.ComponentRef i_e_stateVar;
1109 DAE.Exp i_e_left;
1110 DAE.Exp i_e_right;
1111 DAE.ComponentRef i_left_componentRef;
1112 list<BackendDAE.WhenOperator> i_rest;
1113 Tpl.Text txt_8;
1114 Tpl.Text txt_7;
1115 Tpl.Text txt_6;
1116 Tpl.Text txt_5;
1117 Tpl.Text txt_4;
1118 Tpl.Text txt_3;
1119 Tpl.Text txt_2;
1120 Tpl.Text txt_1;
1121 Tpl.Text l_restbody;
1122
1123 case ( txt,
1124 {} )
1125 then txt;
1126
1127 case ( txt,
1128 BackendDAE.ASSIGN(left = DAE.CREF(componentRef = i_left_componentRef), right = i_e_right) :: i_rest )
1129 algorithm
1130 477 l_restbody := dumpWhenOps(Tpl.emptyTxt, i_rest);
1131 477 txt := ExpressionDumpTpl.dumpCref(txt, i_left_componentRef);
1132 477 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = "));
1133 477 txt_1 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_e_right, "\"");
1134 477 txt := CodegenUtil.escapeCComments(txt, Tpl.textString(txt_1));
1135 477 txt := Tpl.writeTok(txt, Tpl.ST_LINE(";\n"));
1136 477 txt := Tpl.writeText(txt, l_restbody);
1137 then txt;
1138
1139 case ( txt,
1140 BackendDAE.ASSIGN(left = i_e_left, right = i_e_right) :: i_rest )
1141 algorithm
1142 6 l_restbody := dumpWhenOps(Tpl.emptyTxt, i_rest);
1143 6 txt := ExpressionDumpTpl.dumpExp(txt, i_e_left, "\"");
1144 6 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = "));
1145 6 txt_2 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_e_right, "\"");
1146 6 txt := CodegenUtil.escapeCComments(txt, Tpl.textString(txt_2));
1147 6 txt := Tpl.writeTok(txt, Tpl.ST_LINE(";\n"));
1148 6 txt := Tpl.writeText(txt, l_restbody);
1149 then txt;
1150
1151 case ( txt,
1152 BackendDAE.REINIT(stateVar = i_e_stateVar, value = i_e_value) :: i_rest )
1153 algorithm
1154 35 l_restbody := dumpWhenOps(Tpl.emptyTxt, i_rest);
1155 35 txt := Tpl.writeTok(txt, Tpl.ST_STRING("reinit("));
1156 35 txt := ExpressionDumpTpl.dumpCref(txt, i_e_stateVar);
1157 35 txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
1158 35 txt_3 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_e_value, "\"");
1159 35 txt := CodegenUtil.escapeCComments(txt, Tpl.textString(txt_3));
1160 35 txt := Tpl.writeTok(txt, Tpl.ST_LINE(");\n"));
1161 35 txt := Tpl.writeText(txt, l_restbody);
1162 then txt;
1163
1164 case ( txt,
1165 BackendDAE.ASSERT(condition = i_e_condition, message = i_e_message, level = i_e_level) :: i_rest )
1166 algorithm
1167 12 l_restbody := dumpWhenOps(Tpl.emptyTxt, i_rest);
1168 12 txt := Tpl.writeTok(txt, Tpl.ST_STRING("assert("));
1169 12 txt_4 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_e_condition, "\"");
1170 12 txt := CodegenUtil.escapeCComments(txt, Tpl.textString(txt_4));
1171 12 txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
1172 12 txt_5 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_e_message, "\"");
1173 12 txt := CodegenUtil.escapeCComments(txt, Tpl.textString(txt_5));
1174 12 txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
1175 12 txt_6 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_e_level, "\"");
1176 12 txt := CodegenUtil.escapeCComments(txt, Tpl.textString(txt_6));
1177 12 txt := Tpl.writeTok(txt, Tpl.ST_LINE(");\n"));
1178 12 txt := Tpl.writeText(txt, l_restbody);
1179 then txt;
1180
1181 case ( txt,
1182 BackendDAE.TERMINATE(message = i_e_message) :: i_rest )
1183 algorithm
1184 8 l_restbody := dumpWhenOps(Tpl.emptyTxt, i_rest);
1185 8 txt := Tpl.writeTok(txt, Tpl.ST_STRING("terminate("));
1186 8 txt_7 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_e_message, "\"");
1187 8 txt := CodegenUtil.escapeCComments(txt, Tpl.textString(txt_7));
1188 8 txt := Tpl.writeTok(txt, Tpl.ST_LINE(")%>);\n"));
1189 8 txt := Tpl.writeText(txt, l_restbody);
1190 then txt;
1191
1192 case ( txt,
1193 BackendDAE.NORETCALL(exp = i_e_exp) :: i_rest )
1194 algorithm
1195 30 l_restbody := dumpWhenOps(Tpl.emptyTxt, i_rest);
1196 30 txt := Tpl.writeTok(txt, Tpl.ST_STRING("noReturnCall("));
1197 30 txt_8 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_e_exp, "\"");
1198 30 txt := CodegenUtil.escapeCComments(txt, Tpl.textString(txt_8));
1199 30 txt := Tpl.writeTok(txt, Tpl.ST_LINE(")%>);\n"));
1200 30 txt := Tpl.writeText(txt, l_restbody);
1201 then txt;
1202
1203 case ( txt,
1204 _ )
1205 algorithm
1206 ✗ txt := CodegenUtil.error(txt, Tpl.sourceInfo("CodegenUtilSimulation.tpl", 390, 14), "dumpEqs: Unknown equation");
1207 then txt;
1208 end match;
1209 end dumpWhenOps;
1210
1211 protected function fun_69
1212 input Tpl.Text in_txt;
1213 input String in_mArg;
1214 input list<SimCode.SimEqSystem> in_a_eqs;
1215
1216 output Tpl.Text out_txt;
1217 algorithm
1218 out_txt :=
1219 match(in_txt, in_mArg, in_a_eqs)
1220 local
1221 Tpl.Text txt;
1222 list<SimCode.SimEqSystem> a_eqs;
1223
1224 case ( txt,
1225 "none",
1226 a_eqs )
1227 algorithm
1228 3 txt := dumpEqsAlternativeTearingWork(txt, a_eqs);
1229 then txt;
1230
1231 case ( txt,
1232 _,
1233 _ )
1234 then txt;
1235 end match;
1236 end fun_69;
1237
1238 public function dumpEqsAlternativeTearing
1239 input Tpl.Text txt;
1240 input list<SimCode.SimEqSystem> a_eqs;
1241
1242 output Tpl.Text out_txt;
1243 protected
1244 String ret_0;
1245 algorithm
1246 3 ret_0 := Flags.getConfigString(Flags.OBFUSCATE);
1247 3 out_txt := fun_69(txt, ret_0, a_eqs);
1248 end dumpEqsAlternativeTearing;
1249
1250 protected function lm_71
1251 input output Tpl.Text txt;
1252 input list<SimCodeVar.SimVar> items;
1253 algorithm
1254 ✗ for lstElt_71 in items loop
1255 txt := match lstElt_71
1256 local
1257 DAE.ComponentRef i_cr;
1258
1259 case SimCodeVar.SIMVAR(name = i_cr)
1260 algorithm
1261 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<var>"));
1262 ✗ txt := ExpressionDumpTpl.dumpCref(txt, i_cr);
1263 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("</var>"));
1264 ✗ txt := Tpl.nextIter(txt);
1265 then txt;
1266
1267 case _
1268 then txt;
1269 end match;
1270 end for;
1271 end lm_71;
1272
1273 protected function lm_72
1274 input output Tpl.Text txt;
1275 input list<DAE.Exp> items;
1276 algorithm
1277 ✗ for lstElt_72 in items loop
1278 txt := match lstElt_72
1279 local
1280 DAE.Exp i_exp;
1281 Tpl.Text txt_0;
1282
1283 case i_exp
1284 algorithm
1285 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<cell>"));
1286 ✗ txt_0 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_exp, "\"");
1287 ✗ txt := CodegenUtil.escapeCComments(txt, Tpl.textString(txt_0));
1288 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("</cell>"));
1289 ✗ txt := Tpl.nextIter(txt);
1290 then txt;
1291 end match;
1292 end for;
1293 end lm_72;
1294
1295 protected function fun_73
1296 input Tpl.Text in_txt;
1297 input SimCode.SimEqSystem in_a_eq;
1298
1299 output Tpl.Text out_txt;
1300 algorithm
1301 out_txt :=
1302 match(in_txt, in_a_eq)
1303 local
1304 Tpl.Text txt;
1305 DAE.Exp i_e_exp;
1306 Tpl.Text txt_2;
1307 Tpl.Text txt_1;
1308 Tpl.Text txt_0;
1309
1310 case ( txt,
1311 SimCode.SES_RESIDUAL(exp = i_e_exp) )
1312 algorithm
1313 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<residual>"));
1314 ✗ txt_0 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_e_exp, "\"");
1315 ✗ txt := CodegenUtil.escapeCComments(txt, Tpl.textString(txt_0));
1316 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("</residual>"));
1317 then txt;
1318
1319 case ( txt,
1320 SimCode.SES_FOR_RESIDUAL(exp = i_e_exp) )
1321 algorithm
1322 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<residual>"));
1323 ✗ txt_1 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_e_exp, "\"");
1324 ✗ txt := CodegenUtil.escapeCComments(txt, Tpl.textString(txt_1));
1325 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("</residual>"));
1326 then txt;
1327
1328 case ( txt,
1329 SimCode.SES_GENERIC_RESIDUAL(exp = i_e_exp) )
1330 algorithm
1331 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<residual>"));
1332 ✗ txt_2 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_e_exp, "\"");
1333 ✗ txt := CodegenUtil.escapeCComments(txt, Tpl.textString(txt_2));
1334 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("</residual>"));
1335 then txt;
1336
1337 case ( txt,
1338 _ )
1339 then txt;
1340 end match;
1341 end fun_73;
1342
1343 protected function lm_74
1344 input output Tpl.Text txt;
1345 input list<tuple<Integer, Integer, SimCode.SimEqSystem>> items;
1346 algorithm
1347 ✗ for lstElt_74 in items loop
1348 txt := match lstElt_74
1349 local
1350 SimCode.SimEqSystem i_eq;
1351 Integer i_i2;
1352 Integer i_i1;
1353
1354 case (i_i1, i_i2, i_eq)
1355 algorithm
1356 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<cell row=\""));
1357 ✗ txt := Tpl.writeStr(txt, intString(i_i1));
1358 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\" col=\""));
1359 ✗ txt := Tpl.writeStr(txt, intString(i_i2));
1360 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("\">\n"));
1361 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
1362 ✗ txt := fun_73(txt, i_eq);
1363 ✗ txt := Tpl.softNewLine(txt);
1364 ✗ txt := Tpl.popBlock(txt);
1365 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("</cell>"));
1366 then txt;
1367 end match;
1368 end for;
1369 end lm_74;
1370
1371 protected function lm_75
1372 input output Tpl.Text txt;
1373 input list<DAE.ComponentRef> items;
1374 algorithm
1375
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 for lstElt_75 in items loop
1376 txt := match lstElt_75
1377 local
1378 DAE.ComponentRef i_cr;
1379
1380 case i_cr
1381 algorithm
1382 3 txt := ExpressionDumpTpl.dumpCref(txt, i_cr);
1383 3 txt := Tpl.nextIter(txt);
1384 then txt;
1385 end match;
1386 end for;
1387 end lm_75;
1388
1389 protected function lm_76
1390 input output Tpl.Text txt;
1391 input list<SimCode.SimEqSystem> items;
1392 algorithm
1393
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 3 times.
12 for lstElt_76 in items loop
1394 txt := match lstElt_76
1395 local
1396 SimCode.SimEqSystem i_eq;
1397
1398 case i_eq
1399 algorithm
1400 9 txt := equationIndex(txt, i_eq);
1401 9 txt := Tpl.nextIter(txt);
1402 then txt;
1403 end match;
1404 end for;
1405 end lm_76;
1406
1407 protected function fun_77
1408 input Tpl.Text in_txt;
1409 input SimCode.SimEqSystem in_a_eq;
1410
1411 output Tpl.Text out_txt;
1412 algorithm
1413 out_txt :=
1414 match(in_txt, in_a_eq)
1415 local
1416 Tpl.Text txt;
1417 list<SimCode.SimEqSystem> i_at_eqs;
1418 list<DAE.ComponentRef> i_at_crefs;
1419 Integer i_at_indexNonLinearSystem;
1420 list<tuple<Integer, Integer, SimCode.SimEqSystem>> i_at_simJac;
1421 list<DAE.Exp> i_at_beqs;
1422 list<SimCodeVar.SimVar> i_at_vars;
1423 SimCode.SimEqSystem i_e;
1424
1425 case ( txt,
1426 (i_e as SimCode.SES_LINEAR(alternativeTearing = SOME(SimCode.LINEARSYSTEM(vars = i_at_vars, beqs = i_at_beqs, simJac = i_at_simJac)))) )
1427 algorithm
1428 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("equation index: "));
1429 ✗ txt := equationIndexAlternativeTearing(txt, i_e);
1430 ✗ txt := Tpl.softNewLine(txt);
1431 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1432 "type: LINEAR\n",
1433 "\n"
1434 }, true));
1435 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1436 ✗ txt := lm_71(txt, i_at_vars);
1437 ✗ txt := Tpl.popIter(txt);
1438 ✗ txt := Tpl.softNewLine(txt);
1439 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("<row>\n"));
1440 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
1441 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1442 ✗ txt := lm_72(txt, i_at_beqs);
1443 ✗ txt := Tpl.popIter(txt);
1444 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
1445 ✗ txt := Tpl.popBlock(txt);
1446 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1447 "</row>\n",
1448 "<matrix>\n"
1449 }, true));
1450 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
1451 ✗ txt := lm_74(txt, i_at_simJac);
1452 ✗ txt := Tpl.softNewLine(txt);
1453 ✗ txt := Tpl.popBlock(txt);
1454 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1455 "</matrix>\n",
1456 "\n",
1457 "This is the alternative tearing set with casual solvability rules.\n",
1458 "If it fails, this function will call the strict tearing set."
1459 }, false));
1460 then txt;
1461
1462 case ( txt,
1463 (i_e as SimCode.SES_NONLINEAR(alternativeTearing = SOME(SimCode.NONLINEARSYSTEM(indexNonLinearSystem = i_at_indexNonLinearSystem, crefs = i_at_crefs, eqs = i_at_eqs)))) )
1464 algorithm
1465 3 txt := Tpl.writeTok(txt, Tpl.ST_STRING("equation index: "));
1466 3 txt := equationIndexAlternativeTearing(txt, i_e);
1467 3 txt := Tpl.softNewLine(txt);
1468 3 txt := Tpl.writeTok(txt, Tpl.ST_STRING("indexNonlinear: "));
1469 3 txt := Tpl.writeStr(txt, intString(i_at_indexNonLinearSystem));
1470 3 txt := Tpl.softNewLine(txt);
1471 3 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1472 "type: NONLINEAR\n",
1473 "\n",
1474 "vars: {"
1475 }, false));
1476 3 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1477 3 txt := lm_75(txt, i_at_crefs);
1478 3 txt := Tpl.popIter(txt);
1479 3 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1480 "}\n",
1481 "eqns: {"
1482 }, false));
1483 3 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1484 3 txt := lm_76(txt, i_at_eqs);
1485 3 txt := Tpl.popIter(txt);
1486 3 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1487 "}\n",
1488 "\n",
1489 "This is the alternative tearing set with casual solvability rules.\n",
1490 "If it fails, this function will call the strict tearing set."
1491 }, false));
1492 then txt;
1493
1494 case ( txt,
1495 _ )
1496 algorithm
1497 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("unknown equation"));
1498 then txt;
1499 end match;
1500 end fun_77;
1501
1502 protected function lm_78
1503 input output Tpl.Text txt;
1504 input list<SimCode.SimEqSystem> items;
1505 algorithm
1506
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 for lstElt_78 in items loop
1507 txt := match lstElt_78
1508 local
1509 SimCode.SimEqSystem i_eq;
1510
1511 case i_eq
1512 algorithm
1513 3 txt := fun_77(txt, i_eq);
1514 then txt;
1515 end match;
1516 end for;
1517 end lm_78;
1518
1519 public function dumpEqsAlternativeTearingWork
1520 input Tpl.Text txt;
1521 input list<SimCode.SimEqSystem> a_eqs;
1522
1523 output Tpl.Text out_txt;
1524 algorithm
1525 3 out_txt := lm_78(txt, a_eqs);
1526 end dumpEqsAlternativeTearingWork;
1527
1528 annotation(__OpenModelica_Interface="codegen");
1529 end CodegenUtilSimulation;
1530