Linux GNU 11.4.0 Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 52.4% 2199 / 0 / 4196
Functions: -% 0 / 1 / 1
Branches: 67.3% 101 / 0 / 150

build_cmake/OMCompiler/Compiler/generated-mo/Template/CodegenCppCommon.mo
Line Branch Exec Source
1 encapsulated package CodegenCppCommon
2 "
3 file: CodegenCppCommon.mo
4 package: CodegenCppCommon
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 CodegenUtil;
52 protected import ExpressionDumpTpl;
53
54 public function cref
55 input Tpl.Text in_txt;
56 input DAE.ComponentRef in_a_cr;
57 input Boolean in_a_useFlatArrayNotation;
58
59 output Tpl.Text out_txt;
60 algorithm
61 out_txt :=
62 match(in_txt, in_a_cr, in_a_useFlatArrayNotation)
63 local
64 Tpl.Text txt;
65 Boolean a_useFlatArrayNotation;
66 DAE.ComponentRef i_cr;
67
68 case ( txt,
69 DAE.CREF_IDENT(ident = "time"),
70 _ )
71 algorithm
72 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_simTime"));
73 then txt;
74
75 case ( txt,
76 DAE.WILD(),
77 _ )
78 then txt;
79
80 case ( txt,
81 i_cr,
82 a_useFlatArrayNotation )
83 algorithm
84 401946 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
85 401946 txt := crefToCStr(txt, i_cr, a_useFlatArrayNotation);
86 then txt;
87 end match;
88 end cref;
89
90 public function localCref
91 input Tpl.Text in_txt;
92 input DAE.ComponentRef in_a_cr;
93 input Boolean in_a_useFlatArrayNotation;
94
95 output Tpl.Text out_txt;
96 algorithm
97 out_txt :=
98 match(in_txt, in_a_cr, in_a_useFlatArrayNotation)
99 local
100 Tpl.Text txt;
101 Boolean a_useFlatArrayNotation;
102 DAE.ComponentRef i_cr;
103
104 case ( txt,
105 DAE.CREF_IDENT(ident = "time"),
106 _ )
107 algorithm
108 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_simTime"));
109 then txt;
110
111 case ( txt,
112 DAE.CREF_IDENT(ident = "__HOM_LAMBDA"),
113 _ )
114 algorithm
115 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("1.0"));
116 then txt;
117
118 case ( txt,
119 DAE.WILD(),
120 _ )
121 then txt;
122
123 case ( txt,
124 i_cr,
125 a_useFlatArrayNotation )
126 algorithm
127 70 txt := crefToCStr(txt, i_cr, a_useFlatArrayNotation);
128 then txt;
129 end match;
130 end localCref;
131
132 protected function lm_47
133 input output Tpl.Text txt;
134 input list<DAE.Subscript> items;
135 algorithm
136
2/2
✓ Branch 0 taken 19256 times.
✓ Branch 1 taken 16809 times.
36065 for lstElt_47 in items loop
137 txt := match lstElt_47
138 local
139 DAE.Subscript i_s;
140
141 case i_s
142 algorithm
143 19256 txt := subscriptToCStr(txt, i_s);
144 19256 txt := Tpl.nextIter(txt);
145 then txt;
146 end match;
147 end for;
148 end lm_47;
149
150 protected function lm_48
151 input output Tpl.Text txt;
152 input list<DAE.Subscript> items;
153 algorithm
154 ✗ for lstElt_48 in items loop
155 txt := match lstElt_48
156 local
157 DAE.Subscript i_s;
158
159 case i_s
160 algorithm
161 ✗ txt := subscriptToCStr(txt, i_s);
162 ✗ txt := Tpl.nextIter(txt);
163 then txt;
164 end match;
165 end for;
166 end lm_48;
167
168 protected function fun_49
169 input Tpl.Text in_txt;
170 input Boolean in_a_useFlatArrayNotation;
171 input list<DAE.Subscript> in_a_subscripts;
172
173 output Tpl.Text out_txt;
174 algorithm
175 out_txt :=
176 match(in_txt, in_a_useFlatArrayNotation, in_a_subscripts)
177 local
178 Tpl.Text txt;
179 list<DAE.Subscript> a_subscripts;
180
181 case ( txt,
182 false,
183 a_subscripts )
184 algorithm
185 16809 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
186 16809 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(",")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
187 16809 txt := lm_47(txt, a_subscripts);
188 16809 txt := Tpl.popIter(txt);
189 16809 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
190 then txt;
191
192 case ( txt,
193 _,
194 a_subscripts )
195 algorithm
196 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
197 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING("_")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
198 ✗ txt := lm_48(txt, a_subscripts);
199 ✗ txt := Tpl.popIter(txt);
200 then txt;
201 end match;
202 end fun_49;
203
204 public function subscriptsToCStr
205 input Tpl.Text in_txt;
206 input list<DAE.Subscript> in_a_subscripts;
207 input Boolean in_a_useFlatArrayNotation;
208
209 output Tpl.Text out_txt;
210 algorithm
211 out_txt :=
212 match(in_txt, in_a_subscripts, in_a_useFlatArrayNotation)
213 local
214 Tpl.Text txt;
215 Boolean a_useFlatArrayNotation;
216 list<DAE.Subscript> i_subscripts;
217
218 case ( txt,
219 {},
220 _ )
221 then txt;
222
223 case ( txt,
224 i_subscripts,
225 a_useFlatArrayNotation )
226 algorithm
227 16809 txt := fun_49(txt, a_useFlatArrayNotation, i_subscripts);
228 then txt;
229 end match;
230 end subscriptsToCStr;
231
232 protected function fun_51
233 input Tpl.Text in_txt;
234 input DAE.Exp in_a_exp;
235
236 output Tpl.Text out_txt;
237 algorithm
238 out_txt :=
239 match(in_txt, in_a_exp)
240 local
241 Tpl.Text txt;
242 DAE.ComponentRef i_cr;
243 Integer i_i;
244
245 case ( txt,
246 DAE.ICONST(integer = i_i) )
247 algorithm
248 257276 txt := Tpl.writeStr(txt, intString(i_i));
249 then txt;
250
251 case ( txt,
252 DAE.ENUM_LITERAL(index = i_i) )
253 algorithm
254 ✗ txt := Tpl.writeStr(txt, intString(i_i));
255 then txt;
256
257 case ( txt,
258 DAE.CREF(componentRef = i_cr) )
259 algorithm
260 ✗ txt := crefToCStr(txt, i_cr, false);
261 then txt;
262
263 case ( txt,
264 _ )
265 then txt;
266 end match;
267 end fun_51;
268
269 public function subscriptToCStr
270 input Tpl.Text in_txt;
271 input DAE.Subscript in_a_subscript;
272
273 output Tpl.Text out_txt;
274 algorithm
275 out_txt :=
276 match(in_txt, in_a_subscript)
277 local
278 Tpl.Text txt;
279 DAE.Exp i_exp;
280 Integer i_i;
281
282 case ( txt,
283 DAE.SLICE(exp = DAE.ICONST(integer = i_i)) )
284 algorithm
285 ✗ txt := Tpl.writeStr(txt, intString(i_i));
286 then txt;
287
288 case ( txt,
289 DAE.WHOLEDIM() )
290 algorithm
291 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("WHOLEDIM"));
292 then txt;
293
294 case ( txt,
295 DAE.INDEX(exp = i_exp) )
296 algorithm
297 257276 txt := fun_51(txt, i_exp);
298 then txt;
299
300 case ( txt,
301 _ )
302 algorithm
303 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("UNKNOWN_SUBSCRIPT"));
304 then txt;
305 end match;
306 end subscriptToCStr;
307
308 protected function fun_53
309 input Tpl.Text in_txt;
310 input Boolean in_mArg;
311 input list<DAE.Subscript> in_a_subscriptLst;
312
313 output Tpl.Text out_txt;
314 algorithm
315 out_txt :=
316 match(in_txt, in_mArg, in_a_subscriptLst)
317 local
318 Tpl.Text txt;
319 list<DAE.Subscript> a_subscriptLst;
320
321 case ( txt,
322 false,
323 _ )
324 then txt;
325
326 case ( txt,
327 _,
328 a_subscriptLst )
329 algorithm
330 879856 txt := subscriptsToCStrForArray(txt, a_subscriptLst);
331 then txt;
332 end match;
333 end fun_53;
334
335 public function crefToCStrForArray
336 input Tpl.Text in_txt;
337 input DAE.ComponentRef in_a_cr;
338 input Tpl.Text in_a_dims;
339
340 output Tpl.Text out_txt;
341 output Tpl.Text out_a_dims;
342 algorithm
343 (out_txt, out_a_dims) :=
344 match(in_txt, in_a_cr, in_a_dims)
345 local
346 Tpl.Text txt;
347 Tpl.Text a_dims;
348 DAE.ComponentRef i_componentRef;
349 DAE.Ident i_ident;
350 list<DAE.Subscript> i_subscriptLst;
351 String ret_4;
352 Boolean ret_3;
353 Tpl.Text l_subs;
354 String ret_1;
355 Integer ret_0;
356
357 case ( txt,
358 DAE.CREF_IDENT(subscriptLst = i_subscriptLst, ident = i_ident),
359 a_dims )
360 algorithm
361 427992 ret_0 := listLength(i_subscriptLst);
362 427992 a_dims := Tpl.writeStr(a_dims, intString(ret_0));
363 427992 ret_1 := System.unquoteIdentifier(i_ident);
364 427992 txt := Tpl.writeStr(txt, ret_1);
365 427992 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
366 then (txt, a_dims);
367
368 case ( txt,
369 DAE.CREF_QUAL(subscriptLst = i_subscriptLst, ident = i_ident, componentRef = i_componentRef),
370 a_dims )
371 algorithm
372 879950 ret_3 := Flags.isSet(Flags.NF_SCALARIZE);
373 879950 l_subs := fun_53(Tpl.emptyTxt, ret_3, i_subscriptLst);
374 879950 ret_4 := System.unquoteIdentifier(i_ident);
375 879950 txt := Tpl.writeStr(txt, ret_4);
376 879950 txt := Tpl.writeText(txt, l_subs);
377 879950 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_P_"));
378 879950 (txt, a_dims) := crefToCStrForArray(txt, i_componentRef, a_dims);
379 then (txt, a_dims);
380
381 case ( txt,
382 DAE.WILD(),
383 a_dims )
384 algorithm
385 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
386 then (txt, a_dims);
387
388 case ( txt,
389 _,
390 a_dims )
391 algorithm
392 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("CREF_NOT_IDENT_OR_QUAL"));
393 then (txt, a_dims);
394 end match;
395 end crefToCStrForArray;
396
397 public function crefToCStr1
398 input Tpl.Text in_txt;
399 input DAE.ComponentRef in_a_cr;
400 input Boolean in_a_useFlatArrayNotation;
401
402 output Tpl.Text out_txt;
403 algorithm
404 out_txt :=
405 match(in_txt, in_a_cr, in_a_useFlatArrayNotation)
406 local
407 Tpl.Text txt;
408 Boolean a_useFlatArrayNotation;
409 DAE.ComponentRef i_componentRef;
410 list<DAE.Subscript> i_subscriptLst;
411 DAE.Ident i_ident;
412 String ret_1;
413 String ret_0;
414
415 case ( txt,
416 DAE.CREF_IDENT(ident = i_ident),
417 _ )
418 algorithm
419 108139 ret_0 := System.unquoteIdentifier(i_ident);
420 108139 txt := Tpl.writeStr(txt, ret_0);
421 108139 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
422 then txt;
423
424 case ( txt,
425 DAE.CREF_QUAL(ident = i_ident, subscriptLst = i_subscriptLst, componentRef = i_componentRef),
426 a_useFlatArrayNotation )
427 algorithm
428 215334 ret_1 := System.unquoteIdentifier(i_ident);
429 215334 txt := Tpl.writeStr(txt, ret_1);
430 215334 txt := subscriptsToCStrForArray(txt, i_subscriptLst);
431 215334 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_P_"));
432 215334 txt := crefToCStr1(txt, i_componentRef, a_useFlatArrayNotation);
433 then txt;
434
435 case ( txt,
436 DAE.WILD(),
437 _ )
438 algorithm
439 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
440 then txt;
441
442 case ( txt,
443 _,
444 _ )
445 algorithm
446 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("CREF_NOT_IDENT_OR_QUAL"));
447 then txt;
448 end match;
449 end crefToCStr1;
450
451 protected function lm_56
452 input output Tpl.Text txt;
453 input list<DAE.Subscript> items;
454 algorithm
455
2/2
✓ Branch 0 taken 238020 times.
✓ Branch 1 taken 238020 times.
476040 for lstElt_56 in items loop
456 txt := match lstElt_56
457 local
458 DAE.Subscript i_s;
459
460 case i_s
461 algorithm
462 238020 txt := subscriptToCStr(txt, i_s);
463 238020 txt := Tpl.nextIter(txt);
464 then txt;
465 end match;
466 end for;
467 end lm_56;
468
469 public function subscriptsToCStrForArray
470 input Tpl.Text in_txt;
471 input list<DAE.Subscript> in_a_subscripts;
472
473 output Tpl.Text out_txt;
474 algorithm
475 out_txt :=
476 match(in_txt, in_a_subscripts)
477 local
478 Tpl.Text txt;
479 list<DAE.Subscript> i_subscripts;
480
481 case ( txt,
482 {} )
483 then txt;
484
485 case ( txt,
486 i_subscripts )
487 algorithm
488 238020 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING("$c")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
489 238020 txt := lm_56(txt, i_subscripts);
490 238020 txt := Tpl.popIter(txt);
491 then txt;
492 end match;
493 end subscriptsToCStrForArray;
494
495 public function crefStrForWriteOutput
496 input Tpl.Text in_txt;
497 input DAE.ComponentRef in_a_cr;
498
499 output Tpl.Text out_txt;
500 algorithm
501 out_txt :=
502 match(in_txt, in_a_cr)
503 local
504 Tpl.Text txt;
505 DAE.ComponentRef i_componentRef;
506 DAE.Ident i_ident;
507 list<DAE.Subscript> i_subscriptLst;
508 String ret_1;
509 String ret_0;
510
511 case ( txt,
512 DAE.CREF_IDENT(ident = "xloc", subscriptLst = i_subscriptLst) )
513 algorithm
514 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("__xd"));
515 ✗ txt := subscriptsStrForWriteOutput(txt, i_subscriptLst);
516 then txt;
517
518 case ( txt,
519 DAE.CREF_IDENT(ident = "time") )
520 algorithm
521 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_simTime"));
522 then txt;
523
524 case ( txt,
525 DAE.CREF_IDENT(ident = i_ident, subscriptLst = i_subscriptLst) )
526 algorithm
527 381 ret_0 := System.unquoteIdentifier(i_ident);
528 381 txt := Tpl.writeStr(txt, ret_0);
529 381 txt := subscriptsStrForWriteOutput(txt, i_subscriptLst);
530 then txt;
531
532 case ( txt,
533 DAE.CREF_QUAL(ident = "$DER", componentRef = i_componentRef) )
534 algorithm
535 64 txt := Tpl.writeTok(txt, Tpl.ST_STRING("der("));
536 64 txt := crefStrForWriteOutput(txt, i_componentRef);
537 64 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
538 then txt;
539
540 case ( txt,
541 DAE.CREF_QUAL(ident = "$CLKPRE", componentRef = i_componentRef) )
542 algorithm
543 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("previous("));
544 ✗ txt := crefStrForWriteOutput(txt, i_componentRef);
545 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
546 then txt;
547
548 case ( txt,
549 DAE.CREF_QUAL(ident = i_ident, subscriptLst = i_subscriptLst, componentRef = i_componentRef) )
550 algorithm
551 715 ret_1 := System.unquoteIdentifier(i_ident);
552 715 txt := Tpl.writeStr(txt, ret_1);
553 715 txt := subscriptsStrForWriteOutput(txt, i_subscriptLst);
554 715 txt := Tpl.writeTok(txt, Tpl.ST_STRING("."));
555 715 txt := crefStrForWriteOutput(txt, i_componentRef);
556 then txt;
557
558 case ( txt,
559 _ )
560 algorithm
561 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("CREF_NOT_IDENT_OR_QUAL"));
562 then txt;
563 end match;
564 end crefStrForWriteOutput;
565
566 public function crefStrForSetVariables
567 input Tpl.Text in_txt;
568 input DAE.ComponentRef in_a_cr;
569 input Boolean in_a_useFlatArrayNotation;
570
571 output Tpl.Text out_txt;
572 algorithm
573 out_txt :=
574 match(in_txt, in_a_cr, in_a_useFlatArrayNotation)
575 local
576 Tpl.Text txt;
577 Boolean a_useFlatArrayNotation;
578 DAE.ComponentRef i_cr;
579
580 case ( txt,
581 DAE.CREF_QUAL(ident = "$DER"),
582 _ )
583 then txt;
584
585 case ( txt,
586 i_cr,
587 a_useFlatArrayNotation )
588 algorithm
589 ✗ txt := cref(txt, i_cr, a_useFlatArrayNotation);
590 then txt;
591 end match;
592 end crefStrForSetVariables;
593
594 protected function lm_60
595 input output Tpl.Text txt;
596 input list<DAE.Subscript> items;
597 algorithm
598
2/2
✓ Branch 0 taken 201 times.
✓ Branch 1 taken 201 times.
402 for lstElt_60 in items loop
599 txt := match lstElt_60
600 local
601 DAE.Subscript i_s;
602
603 case i_s
604 algorithm
605 201 txt := subscriptStr(txt, i_s);
606 201 txt := Tpl.nextIter(txt);
607 then txt;
608 end match;
609 end for;
610 end lm_60;
611
612 public function subscriptsStrForWriteOutput
613 input Tpl.Text in_txt;
614 input list<DAE.Subscript> in_a_subscripts;
615
616 output Tpl.Text out_txt;
617 algorithm
618 out_txt :=
619 match(in_txt, in_a_subscripts)
620 local
621 Tpl.Text txt;
622 list<DAE.Subscript> i_subscripts;
623
624 case ( txt,
625 {} )
626 then txt;
627
628 case ( txt,
629 i_subscripts )
630 algorithm
631 201 txt := Tpl.writeTok(txt, Tpl.ST_STRING("["));
632 201 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(",")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
633 201 txt := lm_60(txt, i_subscripts);
634 201 txt := Tpl.popIter(txt);
635 201 txt := Tpl.writeTok(txt, Tpl.ST_STRING("]"));
636 then txt;
637 end match;
638 end subscriptsStrForWriteOutput;
639
640 public function crefStr
641 input Tpl.Text in_txt;
642 input DAE.ComponentRef in_a_cr;
643
644 output Tpl.Text out_txt;
645 algorithm
646 out_txt :=
647 match(in_txt, in_a_cr)
648 local
649 Tpl.Text txt;
650 DAE.ComponentRef i_componentRef;
651 DAE.Ident i_ident;
652 list<DAE.Subscript> i_subscriptLst;
653 String ret_1;
654 String ret_0;
655
656 case ( txt,
657 DAE.CREF_IDENT(ident = "xloc", subscriptLst = i_subscriptLst) )
658 algorithm
659 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("__xd"));
660 ✗ txt := subscriptsStr(txt, i_subscriptLst);
661 then txt;
662
663 case ( txt,
664 DAE.CREF_IDENT(ident = "time") )
665 algorithm
666 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_simTime"));
667 then txt;
668
669 case ( txt,
670 DAE.CREF_IDENT(ident = i_ident, subscriptLst = i_subscriptLst) )
671 algorithm
672 40864 ret_0 := System.unquoteIdentifier(i_ident);
673 40864 txt := Tpl.writeStr(txt, ret_0);
674 40864 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
675 40864 txt := subscriptsStr(txt, i_subscriptLst);
676 then txt;
677
678 case ( txt,
679 DAE.CREF_QUAL(ident = i_ident, subscriptLst = i_subscriptLst, componentRef = i_componentRef) )
680 algorithm
681 8270 ret_1 := System.unquoteIdentifier(i_ident);
682 8270 txt := Tpl.writeStr(txt, ret_1);
683 8270 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
684 8270 txt := subscriptsStr(txt, i_subscriptLst);
685 8270 txt := Tpl.writeTok(txt, Tpl.ST_STRING("."));
686 8270 txt := crefStr(txt, i_componentRef);
687 then txt;
688
689 case ( txt,
690 _ )
691 algorithm
692 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("CREF_NOT_IDENT_OR_QUAL"));
693 then txt;
694 end match;
695 end crefStr;
696
697 protected function lm_63
698 input output Tpl.Text txt;
699 input list<DAE.Subscript> items;
700 algorithm
701 ✗ for lstElt_63 in items loop
702 txt := match lstElt_63
703 local
704 DAE.Subscript i_s;
705
706 case i_s
707 algorithm
708 ✗ txt := subscriptStr(txt, i_s);
709 ✗ txt := Tpl.nextIter(txt);
710 then txt;
711 end match;
712 end for;
713 end lm_63;
714
715 public function subscriptsStr
716 input Tpl.Text in_txt;
717 input list<DAE.Subscript> in_a_subscripts;
718
719 output Tpl.Text out_txt;
720 algorithm
721 out_txt :=
722 match(in_txt, in_a_subscripts)
723 local
724 Tpl.Text txt;
725 list<DAE.Subscript> i_subscripts;
726
727 case ( txt,
728 {} )
729 then txt;
730
731 case ( txt,
732 i_subscripts )
733 algorithm
734 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
735 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(",")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
736 ✗ txt := lm_63(txt, i_subscripts);
737 ✗ txt := Tpl.popIter(txt);
738 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
739 then txt;
740 end match;
741 end subscriptsStr;
742
743 protected function fun_65
744 input Tpl.Text in_txt;
745 input DAE.Exp in_a_exp;
746
747 output Tpl.Text out_txt;
748 algorithm
749 out_txt :=
750 match(in_txt, in_a_exp)
751 local
752 Tpl.Text txt;
753 DAE.ComponentRef i_cr;
754 Integer i_i;
755
756 case ( txt,
757 DAE.ICONST(integer = i_i) )
758 algorithm
759 201 txt := Tpl.writeStr(txt, intString(i_i));
760 then txt;
761
762 case ( txt,
763 DAE.ENUM_LITERAL(index = i_i) )
764 algorithm
765 ✗ txt := Tpl.writeStr(txt, intString(i_i));
766 then txt;
767
768 case ( txt,
769 DAE.CREF(componentRef = i_cr) )
770 algorithm
771 ✗ txt := crefStr(txt, i_cr);
772 then txt;
773
774 case ( txt,
775 _ )
776 then txt;
777 end match;
778 end fun_65;
779
780 public function subscriptStr
781 input Tpl.Text in_txt;
782 input DAE.Subscript in_a_subscript;
783
784 output Tpl.Text out_txt;
785 algorithm
786 out_txt :=
787 match(in_txt, in_a_subscript)
788 local
789 Tpl.Text txt;
790 DAE.Exp i_exp;
791 Integer i_i;
792
793 case ( txt,
794 DAE.SLICE(exp = DAE.ICONST(integer = i_i)) )
795 algorithm
796 ✗ txt := Tpl.writeStr(txt, intString(i_i));
797 then txt;
798
799 case ( txt,
800 DAE.WHOLEDIM() )
801 algorithm
802 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("WHOLEDIM"));
803 then txt;
804
805 case ( txt,
806 DAE.INDEX(exp = i_exp) )
807 algorithm
808 201 txt := fun_65(txt, i_exp);
809 then txt;
810
811 case ( txt,
812 _ )
813 algorithm
814 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("UNKNOWN_SUBSCRIPT"));
815 then txt;
816 end match;
817 end subscriptStr;
818
819 protected function fun_67
820 input Tpl.Text in_txt;
821 input SimCodeFunction.Context in_a_context;
822 input Boolean in_a_useFlatArrayNotation;
823 input Tpl.Text in_a_stateDerVectorName;
824 input Tpl.Text in_a_varDeclsCref;
825 input Tpl.Text in_a_extraFuncsNamespace;
826 input Tpl.Text in_a_extraFuncsDecl;
827 input Tpl.Text in_a_extraFuncs;
828 input SimCode.SimCode in_a_simCode;
829 input DAE.ComponentRef in_a_cr;
830
831 output Tpl.Text out_txt;
832 output Tpl.Text out_a_stateDerVectorName;
833 output Tpl.Text out_a_varDeclsCref;
834 output Tpl.Text out_a_extraFuncsNamespace;
835 output Tpl.Text out_a_extraFuncsDecl;
836 output Tpl.Text out_a_extraFuncs;
837 algorithm
838 (out_txt, out_a_stateDerVectorName, out_a_varDeclsCref, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs) :=
839 match(in_txt, in_a_context, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_varDeclsCref, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_cr)
840 local
841 Tpl.Text txt;
842 Boolean a_useFlatArrayNotation;
843 Tpl.Text a_stateDerVectorName;
844 Tpl.Text a_varDeclsCref;
845 Tpl.Text a_extraFuncsNamespace;
846 Tpl.Text a_extraFuncsDecl;
847 Tpl.Text a_extraFuncs;
848 SimCode.SimCode a_simCode;
849 DAE.ComponentRef a_cr;
850 SimCodeFunction.Context i_context;
851
852 case ( txt,
853 SimCodeFunction.FUNCTION_CONTEXT(cref_prefix = _),
854 _,
855 a_stateDerVectorName,
856 a_varDeclsCref,
857 a_extraFuncsNamespace,
858 a_extraFuncsDecl,
859 a_extraFuncs,
860 _,
861 a_cr )
862 algorithm
863 34721 txt := crefStr(txt, a_cr);
864 34721 then (txt, a_stateDerVectorName, a_varDeclsCref, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs);
865
866 case ( txt,
867 i_context,
868 a_useFlatArrayNotation,
869 a_stateDerVectorName,
870 a_varDeclsCref,
871 a_extraFuncsNamespace,
872 a_extraFuncsDecl,
873 a_extraFuncs,
874 a_simCode,
875 a_cr )
876 algorithm
877 26541 (txt, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_varDeclsCref, a_stateDerVectorName) := cref1(txt, a_cr, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, i_context, a_varDeclsCref, a_stateDerVectorName, a_useFlatArrayNotation);
878 26541 then (txt, a_stateDerVectorName, a_varDeclsCref, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs);
879 end match;
880 end fun_67;
881
882 public function contextCref
883 input Tpl.Text txt;
884 input DAE.ComponentRef a_cr;
885 input SimCodeFunction.Context a_context;
886 input SimCode.SimCode a_simCode;
887 input Tpl.Text a_extraFuncs;
888 input Tpl.Text a_extraFuncsDecl;
889 input Tpl.Text a_extraFuncsNamespace;
890 input Tpl.Text a_stateDerVectorName;
891 input Boolean a_useFlatArrayNotation;
892
893 output Tpl.Text out_txt;
894 output Tpl.Text out_a_extraFuncs;
895 output Tpl.Text out_a_extraFuncsDecl;
896 output Tpl.Text out_a_extraFuncsNamespace;
897 output Tpl.Text out_a_stateDerVectorName;
898 protected
899 Tpl.Text l_varDeclsCref;
900 algorithm
901 61262 l_varDeclsCref := Tpl.emptyTxt;
902 61262 (out_txt, out_a_stateDerVectorName, l_varDeclsCref, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs) := fun_67(txt, a_context, a_useFlatArrayNotation, a_stateDerVectorName, l_varDeclsCref, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_cr);
903 end contextCref;
904
905 protected function fun_69
906 input Tpl.Text in_txt;
907 input SimCodeFunction.Context in_a_context;
908 input DAE.ComponentRef in_a_cr;
909
910 output Tpl.Text out_txt;
911 algorithm
912 out_txt :=
913 match(in_txt, in_a_context, in_a_cr)
914 local
915 Tpl.Text txt;
916 DAE.ComponentRef a_cr;
917
918 case ( txt,
919 SimCodeFunction.FUNCTION_CONTEXT(cref_prefix = _),
920 a_cr )
921 algorithm
922 736 txt := crefStr(txt, a_cr);
923 then txt;
924
925 case ( txt,
926 _,
927 _ )
928 then txt;
929 end match;
930 end fun_69;
931
932 public function contextCref2
933 input Tpl.Text txt;
934 input DAE.ComponentRef a_cr;
935 input SimCodeFunction.Context a_context;
936
937 output Tpl.Text out_txt;
938 algorithm
939 736 out_txt := fun_69(txt, a_context, a_cr);
940 end contextCref2;
941
942 protected function fun_71
943 input Tpl.Text in_txt;
944 input SimCodeFunction.Context in_a_context;
945 input String in_a_funName;
946
947 output Tpl.Text out_txt;
948 algorithm
949 out_txt :=
950 match(in_txt, in_a_context, in_a_funName)
951 local
952 Tpl.Text txt;
953 String a_funName;
954
955 case ( txt,
956 SimCodeFunction.FUNCTION_CONTEXT(cref_prefix = _),
957 a_funName )
958 algorithm
959 476 txt := Tpl.writeStr(txt, a_funName);
960 then txt;
961
962 case ( txt,
963 _,
964 a_funName )
965 algorithm
966 2475 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_functions->"));
967 2475 txt := Tpl.writeStr(txt, a_funName);
968 then txt;
969 end match;
970 end fun_71;
971
972 public function contextFunName
973 input Tpl.Text txt;
974 input String a_funName;
975 input SimCodeFunction.Context a_context;
976
977 output Tpl.Text out_txt;
978 algorithm
979 2951 out_txt := fun_71(txt, a_context, a_funName);
980 end contextFunName;
981
982 public function contextIteratorName
983 input Tpl.Text txt;
984 input DAE.Ident a_name;
985 input SimCodeFunction.Context a_context;
986
987 output Tpl.Text out_txt;
988 protected
989 String ret_0;
990 algorithm
991 29 ret_0 := System.unquoteIdentifier(a_name);
992 29 out_txt := Tpl.writeStr(txt, ret_0);
993 29 out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("_"));
994 end contextIteratorName;
995
996 public function crefWithIndex
997 input Tpl.Text in_txt;
998 input DAE.ComponentRef in_a_cr;
999 input SimCodeFunction.Context in_a_context;
1000 input Tpl.Text in_a_varDecls;
1001 input SimCode.SimCode in_a_simCode;
1002 input Tpl.Text in_a_extraFuncs;
1003 input Tpl.Text in_a_extraFuncsDecl;
1004 input Tpl.Text in_a_extraFuncsNamespace;
1005 input Tpl.Text in_a_stateDerVectorName;
1006 input Boolean in_a_useFlatArrayNotation;
1007
1008 output Tpl.Text out_txt;
1009 output Tpl.Text out_a_varDecls;
1010 output Tpl.Text out_a_extraFuncs;
1011 output Tpl.Text out_a_extraFuncsDecl;
1012 output Tpl.Text out_a_extraFuncsNamespace;
1013 output Tpl.Text out_a_stateDerVectorName;
1014 algorithm
1015 (out_txt, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
1016 match(in_txt, in_a_cr, in_a_context, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
1017 local
1018 Tpl.Text txt;
1019 SimCodeFunction.Context a_context;
1020 Tpl.Text a_varDecls;
1021 SimCode.SimCode a_simCode;
1022 Tpl.Text a_extraFuncs;
1023 Tpl.Text a_extraFuncsDecl;
1024 Tpl.Text a_extraFuncsNamespace;
1025 Tpl.Text a_stateDerVectorName;
1026 Boolean a_useFlatArrayNotation;
1027 DAE.ComponentRef i_cr;
1028
1029 case ( txt,
1030 (i_cr as DAE.CREF_QUAL(ident = _)),
1031 a_context,
1032 a_varDecls,
1033 a_simCode,
1034 a_extraFuncs,
1035 a_extraFuncsDecl,
1036 a_extraFuncsNamespace,
1037 a_stateDerVectorName,
1038 a_useFlatArrayNotation )
1039 algorithm
1040 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
1041 ✗ (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := crefToCStrWithIndex(txt, i_cr, a_context, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
1042 then (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
1043
1044 case ( txt,
1045 _,
1046 _,
1047 a_varDecls,
1048 _,
1049 a_extraFuncs,
1050 a_extraFuncsDecl,
1051 a_extraFuncsNamespace,
1052 a_stateDerVectorName,
1053 _ )
1054 ✗ then (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
1055 end match;
1056 end crefWithIndex;
1057
1058 protected function fun_75
1059 input Tpl.Text in_txt;
1060 input DAE.Exp in_a_exp;
1061 input list<DAE.Subscript> in_a_subscriptLst;
1062 input Tpl.Text in_a_identTmp;
1063 input Boolean in_a_useFlatArrayNotation;
1064 input Tpl.Text in_a_stateDerVectorName;
1065 input Tpl.Text in_a_extraFuncsNamespace;
1066 input Tpl.Text in_a_extraFuncsDecl;
1067 input Tpl.Text in_a_extraFuncs;
1068 input SimCode.SimCode in_a_simCode;
1069 input Tpl.Text in_a_varDecls;
1070 input Tpl.Text in_a_preExp;
1071 input SimCodeFunction.Context in_a_context;
1072
1073 output Tpl.Text out_txt;
1074 output Tpl.Text out_a_stateDerVectorName;
1075 output Tpl.Text out_a_extraFuncsNamespace;
1076 output Tpl.Text out_a_extraFuncsDecl;
1077 output Tpl.Text out_a_extraFuncs;
1078 output Tpl.Text out_a_varDecls;
1079 output Tpl.Text out_a_preExp;
1080 algorithm
1081 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls, out_a_preExp) :=
1082 match(in_txt, in_a_exp, in_a_subscriptLst, in_a_identTmp, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_varDecls, in_a_preExp, in_a_context)
1083 local
1084 Tpl.Text txt;
1085 list<DAE.Subscript> a_subscriptLst;
1086 Tpl.Text a_identTmp;
1087 Boolean a_useFlatArrayNotation;
1088 Tpl.Text a_stateDerVectorName;
1089 Tpl.Text a_extraFuncsNamespace;
1090 Tpl.Text a_extraFuncsDecl;
1091 Tpl.Text a_extraFuncs;
1092 SimCode.SimCode a_simCode;
1093 Tpl.Text a_varDecls;
1094 Tpl.Text a_preExp;
1095 SimCodeFunction.Context a_context;
1096 DAE.ComponentRef i_componentRef;
1097 DAE.Exp i_e;
1098 Tpl.Text l_tmp;
1099
1100 case ( txt,
1101 (i_e as DAE.CREF(componentRef = i_componentRef)),
1102 a_subscriptLst,
1103 a_identTmp,
1104 a_useFlatArrayNotation,
1105 a_stateDerVectorName,
1106 a_extraFuncsNamespace,
1107 a_extraFuncsDecl,
1108 a_extraFuncs,
1109 a_simCode,
1110 a_varDecls,
1111 a_preExp,
1112 a_context )
1113 algorithm
1114 ✗ (l_tmp, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpCrefRhs(Tpl.emptyTxt, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
1115 ✗ txt := Tpl.writeText(txt, a_identTmp);
1116 ✗ txt := Tpl.writeText(txt, l_tmp);
1117 ✗ txt := subscriptsToCStrForArray(txt, a_subscriptLst);
1118 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_P_"));
1119 ✗ txt := crefToCStr(txt, i_componentRef, a_useFlatArrayNotation);
1120 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
1121
1122 case ( txt,
1123 _,
1124 _,
1125 _,
1126 _,
1127 a_stateDerVectorName,
1128 a_extraFuncsNamespace,
1129 a_extraFuncsDecl,
1130 a_extraFuncs,
1131 _,
1132 a_varDecls,
1133 a_preExp,
1134 _ )
1135 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
1136 end match;
1137 end fun_75;
1138
1139 protected function fun_76
1140 input Tpl.Text in_txt;
1141 input DAE.Subscript in_mArg;
1142 input list<DAE.Subscript> in_a_subscriptLst;
1143 input Tpl.Text in_a_identTmp;
1144 input Boolean in_a_useFlatArrayNotation;
1145 input Tpl.Text in_a_stateDerVectorName;
1146 input Tpl.Text in_a_extraFuncsNamespace;
1147 input Tpl.Text in_a_extraFuncsDecl;
1148 input Tpl.Text in_a_extraFuncs;
1149 input SimCode.SimCode in_a_simCode;
1150 input Tpl.Text in_a_varDecls;
1151 input Tpl.Text in_a_preExp;
1152 input SimCodeFunction.Context in_a_context;
1153
1154 output Tpl.Text out_txt;
1155 output Tpl.Text out_a_stateDerVectorName;
1156 output Tpl.Text out_a_extraFuncsNamespace;
1157 output Tpl.Text out_a_extraFuncsDecl;
1158 output Tpl.Text out_a_extraFuncs;
1159 output Tpl.Text out_a_varDecls;
1160 output Tpl.Text out_a_preExp;
1161 algorithm
1162 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls, out_a_preExp) :=
1163 match(in_txt, in_mArg, in_a_subscriptLst, in_a_identTmp, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_varDecls, in_a_preExp, in_a_context)
1164 local
1165 Tpl.Text txt;
1166 list<DAE.Subscript> a_subscriptLst;
1167 Tpl.Text a_identTmp;
1168 Boolean a_useFlatArrayNotation;
1169 Tpl.Text a_stateDerVectorName;
1170 Tpl.Text a_extraFuncsNamespace;
1171 Tpl.Text a_extraFuncsDecl;
1172 Tpl.Text a_extraFuncs;
1173 SimCode.SimCode a_simCode;
1174 Tpl.Text a_varDecls;
1175 Tpl.Text a_preExp;
1176 SimCodeFunction.Context a_context;
1177 DAE.Exp i_exp;
1178
1179 case ( txt,
1180 DAE.INDEX(exp = i_exp),
1181 a_subscriptLst,
1182 a_identTmp,
1183 a_useFlatArrayNotation,
1184 a_stateDerVectorName,
1185 a_extraFuncsNamespace,
1186 a_extraFuncsDecl,
1187 a_extraFuncs,
1188 a_simCode,
1189 a_varDecls,
1190 a_preExp,
1191 a_context )
1192 algorithm
1193 ✗ (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := fun_75(txt, i_exp, a_subscriptLst, a_identTmp, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
1194 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
1195
1196 case ( txt,
1197 _,
1198 _,
1199 _,
1200 _,
1201 a_stateDerVectorName,
1202 a_extraFuncsNamespace,
1203 a_extraFuncsDecl,
1204 a_extraFuncs,
1205 _,
1206 a_varDecls,
1207 a_preExp,
1208 _ )
1209 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
1210 end match;
1211 end fun_76;
1212
1213 protected function fun_77
1214 input Tpl.Text in_txt;
1215 input DAE.ComponentRef in_a_cr;
1216 input Boolean in_a_useFlatArrayNotation;
1217 input Tpl.Text in_a_stateDerVectorName;
1218 input Tpl.Text in_a_extraFuncsNamespace;
1219 input Tpl.Text in_a_extraFuncsDecl;
1220 input Tpl.Text in_a_extraFuncs;
1221 input SimCode.SimCode in_a_simCode;
1222 input Tpl.Text in_a_varDecls;
1223 input Tpl.Text in_a_preExp;
1224 input SimCodeFunction.Context in_a_context;
1225
1226 output Tpl.Text out_txt;
1227 output Tpl.Text out_a_stateDerVectorName;
1228 output Tpl.Text out_a_extraFuncsNamespace;
1229 output Tpl.Text out_a_extraFuncsDecl;
1230 output Tpl.Text out_a_extraFuncs;
1231 output Tpl.Text out_a_varDecls;
1232 output Tpl.Text out_a_preExp;
1233 algorithm
1234 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls, out_a_preExp) :=
1235 match(in_txt, in_a_cr, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_varDecls, in_a_preExp, in_a_context)
1236 local
1237 Tpl.Text txt;
1238 Boolean a_useFlatArrayNotation;
1239 Tpl.Text a_stateDerVectorName;
1240 Tpl.Text a_extraFuncsNamespace;
1241 Tpl.Text a_extraFuncsDecl;
1242 Tpl.Text a_extraFuncs;
1243 SimCode.SimCode a_simCode;
1244 Tpl.Text a_varDecls;
1245 Tpl.Text a_preExp;
1246 SimCodeFunction.Context a_context;
1247 list<DAE.Subscript> i_subscriptLst;
1248 DAE.Ident i_ident;
1249 DAE.Subscript ret_2;
1250 String ret_1;
1251 Tpl.Text l_identTmp;
1252
1253 case ( txt,
1254 DAE.CREF_QUAL(ident = i_ident, subscriptLst = i_subscriptLst),
1255 a_useFlatArrayNotation,
1256 a_stateDerVectorName,
1257 a_extraFuncsNamespace,
1258 a_extraFuncsDecl,
1259 a_extraFuncs,
1260 a_simCode,
1261 a_varDecls,
1262 a_preExp,
1263 a_context )
1264 algorithm
1265 ✗ ret_1 := System.unquoteIdentifier(i_ident);
1266 ✗ l_identTmp := Tpl.writeStr(Tpl.emptyTxt, ret_1);
1267 ✗ ret_2 := listHead(i_subscriptLst);
1268 ✗ (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := fun_76(txt, ret_2, i_subscriptLst, l_identTmp, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
1269 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
1270
1271 case ( txt,
1272 _,
1273 _,
1274 a_stateDerVectorName,
1275 a_extraFuncsNamespace,
1276 a_extraFuncsDecl,
1277 a_extraFuncs,
1278 _,
1279 a_varDecls,
1280 a_preExp,
1281 _ )
1282 algorithm
1283 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("CREF_NOT_IDENT_OR_QUAL"));
1284 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
1285 end match;
1286 end fun_77;
1287
1288 public function crefToCStrWithIndex
1289 input Tpl.Text txt;
1290 input DAE.ComponentRef a_cr;
1291 input SimCodeFunction.Context a_context;
1292 input Tpl.Text a_varDecls;
1293 input SimCode.SimCode a_simCode;
1294 input Tpl.Text a_extraFuncs;
1295 input Tpl.Text a_extraFuncsDecl;
1296 input Tpl.Text a_extraFuncsNamespace;
1297 input Tpl.Text a_stateDerVectorName;
1298 input Boolean a_useFlatArrayNotation;
1299
1300 output Tpl.Text out_txt;
1301 output Tpl.Text out_a_varDecls;
1302 output Tpl.Text out_a_extraFuncs;
1303 output Tpl.Text out_a_extraFuncsDecl;
1304 output Tpl.Text out_a_extraFuncsNamespace;
1305 output Tpl.Text out_a_stateDerVectorName;
1306 protected
1307 Tpl.Text l_tmp;
1308 Tpl.Text l_preExp;
1309 algorithm
1310 ✗ l_preExp := Tpl.emptyTxt;
1311 l_tmp := Tpl.emptyTxt;
1312 ✗ (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls, l_preExp) := fun_77(txt, a_cr, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, l_preExp, a_context);
1313 end crefToCStrWithIndex;
1314
1315 protected function fun_79
1316 input Tpl.Text in_txt;
1317 input SimCodeFunction.Context in_a_context;
1318
1319 output Tpl.Text out_txt;
1320 algorithm
1321 out_txt :=
1322 match(in_txt, in_a_context)
1323 local
1324 Tpl.Text txt;
1325
1326 case ( txt,
1327 SimCodeFunction.ALGLOOP_CONTEXT(genInitialisation = false) )
1328 algorithm
1329 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_system->_simTime"));
1330 then txt;
1331
1332 case ( txt,
1333 _ )
1334 algorithm
1335 519 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_simTime"));
1336 then txt;
1337 end match;
1338 end fun_79;
1339
1340 public function cref1
1341 input Tpl.Text in_txt;
1342 input DAE.ComponentRef in_a_cr;
1343 input SimCode.SimCode in_a_simCode;
1344 input Tpl.Text in_a_extraFuncs;
1345 input Tpl.Text in_a_extraFuncsDecl;
1346 input Tpl.Text in_a_extraFuncsNamespace;
1347 input SimCodeFunction.Context in_a_context;
1348 input Tpl.Text in_a_varDecls;
1349 input Tpl.Text in_a_stateDerVectorName;
1350 input Boolean in_a_useFlatArrayNotation;
1351
1352 output Tpl.Text out_txt;
1353 output Tpl.Text out_a_extraFuncs;
1354 output Tpl.Text out_a_extraFuncsDecl;
1355 output Tpl.Text out_a_extraFuncsNamespace;
1356 output Tpl.Text out_a_varDecls;
1357 output Tpl.Text out_a_stateDerVectorName;
1358 algorithm
1359 (out_txt, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_varDecls, out_a_stateDerVectorName) :=
1360 match(in_txt, in_a_cr, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_context, in_a_varDecls, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
1361 local
1362 Tpl.Text txt;
1363 SimCode.SimCode a_simCode;
1364 Tpl.Text a_extraFuncs;
1365 Tpl.Text a_extraFuncsDecl;
1366 Tpl.Text a_extraFuncsNamespace;
1367 SimCodeFunction.Context a_context;
1368 Tpl.Text a_varDecls;
1369 Tpl.Text a_stateDerVectorName;
1370 Boolean a_useFlatArrayNotation;
1371 DAE.ComponentRef i_cr;
1372 DAE.ComponentRef i_componentRef;
1373
1374 case ( txt,
1375 DAE.CREF_QUAL(ident = "$PRE", componentRef = i_componentRef),
1376 a_simCode,
1377 a_extraFuncs,
1378 a_extraFuncsDecl,
1379 a_extraFuncsNamespace,
1380 a_context,
1381 a_varDecls,
1382 a_stateDerVectorName,
1383 a_useFlatArrayNotation )
1384 algorithm
1385 340 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_discrete_events->pre("));
1386 340 (txt, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_varDecls, a_stateDerVectorName) := cref1(txt, i_componentRef, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_context, a_varDecls, a_stateDerVectorName, a_useFlatArrayNotation);
1387 340 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
1388 340 then (txt, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_varDecls, a_stateDerVectorName);
1389
1390 case ( txt,
1391 (i_cr as DAE.CREF_IDENT(ident = "xloc")),
1392 a_simCode,
1393 a_extraFuncs,
1394 a_extraFuncsDecl,
1395 a_extraFuncsNamespace,
1396 a_context,
1397 a_varDecls,
1398 a_stateDerVectorName,
1399 a_useFlatArrayNotation )
1400 algorithm
1401 ✗ (txt, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_varDecls, a_stateDerVectorName) := representationCref(txt, i_cr, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_context, a_varDecls, a_stateDerVectorName, a_useFlatArrayNotation);
1402 then (txt, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_varDecls, a_stateDerVectorName);
1403
1404 case ( txt,
1405 DAE.CREF_IDENT(ident = "time"),
1406 _,
1407 a_extraFuncs,
1408 a_extraFuncsDecl,
1409 a_extraFuncsNamespace,
1410 a_context,
1411 a_varDecls,
1412 a_stateDerVectorName,
1413 _ )
1414 algorithm
1415 519 txt := fun_79(txt, a_context);
1416 519 then (txt, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_varDecls, a_stateDerVectorName);
1417
1418 case ( txt,
1419 DAE.CREF_QUAL(ident = "$START", componentRef = i_componentRef),
1420 a_simCode,
1421 a_extraFuncs,
1422 a_extraFuncsDecl,
1423 a_extraFuncsNamespace,
1424 a_context,
1425 a_varDecls,
1426 a_stateDerVectorName,
1427 a_useFlatArrayNotation )
1428 algorithm
1429 187 (txt, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_varDecls, a_stateDerVectorName) := representationCref(txt, i_componentRef, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_context, a_varDecls, a_stateDerVectorName, a_useFlatArrayNotation);
1430 then (txt, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_varDecls, a_stateDerVectorName);
1431
1432 case ( txt,
1433 i_cr,
1434 a_simCode,
1435 a_extraFuncs,
1436 a_extraFuncsDecl,
1437 a_extraFuncsNamespace,
1438 a_context,
1439 a_varDecls,
1440 a_stateDerVectorName,
1441 a_useFlatArrayNotation )
1442 algorithm
1443 41065 (txt, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_varDecls, a_stateDerVectorName) := representationCref(txt, i_cr, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_context, a_varDecls, a_stateDerVectorName, a_useFlatArrayNotation);
1444 then (txt, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_varDecls, a_stateDerVectorName);
1445 end match;
1446 end cref1;
1447
1448 protected function fun_81
1449 input Tpl.Text in_txt;
1450 input SimCodeFunction.Context in_a_context;
1451 input Boolean in_a_useFlatArrayNotation;
1452 input DAE.ComponentRef in_a_inCref;
1453
1454 output Tpl.Text out_txt;
1455 algorithm
1456 out_txt :=
1457 match(in_txt, in_a_context, in_a_useFlatArrayNotation, in_a_inCref)
1458 local
1459 Tpl.Text txt;
1460 Boolean a_useFlatArrayNotation;
1461 DAE.ComponentRef a_inCref;
1462
1463 case ( txt,
1464 SimCodeFunction.ALGLOOP_CONTEXT(genInitialisation = false, genJacobian = false),
1465 a_useFlatArrayNotation,
1466 a_inCref )
1467 algorithm
1468 3746 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_system->"));
1469 3746 txt := cref(txt, a_inCref, a_useFlatArrayNotation);
1470 then txt;
1471
1472 case ( txt,
1473 SimCodeFunction.ALGLOOP_CONTEXT(genInitialisation = false, genJacobian = true),
1474 _,
1475 a_inCref )
1476 algorithm
1477 158 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_system->_"));
1478 158 txt := crefToCStr(txt, a_inCref, false);
1479 then txt;
1480
1481 case ( txt,
1482 SimCodeFunction.JACOBIAN_CONTEXT(name = _),
1483 _,
1484 a_inCref )
1485 algorithm
1486 320 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
1487 320 txt := crefToCStr(txt, a_inCref, false);
1488 then txt;
1489
1490 case ( txt,
1491 _,
1492 a_useFlatArrayNotation,
1493 a_inCref )
1494 algorithm
1495 9655 txt := cref(txt, a_inCref, a_useFlatArrayNotation);
1496 then txt;
1497 end match;
1498 end fun_81;
1499
1500 protected function fun_82
1501 input Tpl.Text in_txt;
1502 input SimCodeVar.SimVar in_a_var;
1503 input SimCodeFunction.Context in_a_context;
1504 input Boolean in_a_useFlatArrayNotation;
1505 input DAE.ComponentRef in_a_inCref;
1506
1507 output Tpl.Text out_txt;
1508 algorithm
1509 out_txt :=
1510 match(in_txt, in_a_var, in_a_context, in_a_useFlatArrayNotation, in_a_inCref)
1511 local
1512 Tpl.Text txt;
1513 SimCodeFunction.Context a_context;
1514 Boolean a_useFlatArrayNotation;
1515 DAE.ComponentRef a_inCref;
1516
1517 case ( txt,
1518 SimCodeVar.SIMVAR(index = -2),
1519 _,
1520 a_useFlatArrayNotation,
1521 a_inCref )
1522 algorithm
1523 69 txt := localCref(txt, a_inCref, a_useFlatArrayNotation);
1524 then txt;
1525
1526 case ( txt,
1527 _,
1528 a_context,
1529 a_useFlatArrayNotation,
1530 a_inCref )
1531 algorithm
1532 13879 txt := fun_81(txt, a_context, a_useFlatArrayNotation, a_inCref);
1533 then txt;
1534 end match;
1535 end fun_82;
1536
1537 protected function fun_83
1538 input Tpl.Text in_txt;
1539 input BackendDAE.VarKind in_a_varKind;
1540 input Boolean in_a_useFlatArrayNotation;
1541 input DAE.ComponentRef in_a_inCref;
1542 input SimCodeVar.SimVar in_a_var;
1543 input Option<String> in_a_matrixName;
1544 input SimCodeFunction.Context in_a_context;
1545 input Integer in_a_i;
1546
1547 output Tpl.Text out_txt;
1548 algorithm
1549 out_txt :=
1550 match(in_txt, in_a_varKind, in_a_useFlatArrayNotation, in_a_inCref, in_a_var, in_a_matrixName, in_a_context, in_a_i)
1551 local
1552 Tpl.Text txt;
1553 Boolean a_useFlatArrayNotation;
1554 DAE.ComponentRef a_inCref;
1555 SimCodeVar.SimVar a_var;
1556 Option<String> a_matrixName;
1557 SimCodeFunction.Context a_context;
1558 Integer a_i;
1559 String ret_2;
1560 String ret_1;
1561 String ret_0;
1562
1563 case ( txt,
1564 BackendDAE.DAE_RESIDUAL_VAR(),
1565 _,
1566 _,
1567 _,
1568 _,
1569 _,
1570 a_i )
1571 algorithm
1572 54 txt := Tpl.writeTok(txt, Tpl.ST_STRING("__daeResidual["));
1573 54 txt := Tpl.writeStr(txt, intString(a_i));
1574 54 txt := Tpl.writeTok(txt, Tpl.ST_STRING("]"));
1575 then txt;
1576
1577 case ( txt,
1578 BackendDAE.JAC_VAR(),
1579 _,
1580 _,
1581 _,
1582 a_matrixName,
1583 a_context,
1584 a_i )
1585 algorithm
1586 256 txt := contextSystem(txt, a_context);
1587 256 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
1588 256 ret_0 := Util.getOption(a_matrixName);
1589 256 txt := Tpl.writeStr(txt, ret_0);
1590 256 txt := Tpl.writeTok(txt, Tpl.ST_STRING("jac_y("));
1591 256 txt := Tpl.writeStr(txt, intString(a_i));
1592 256 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
1593 then txt;
1594
1595 case ( txt,
1596 BackendDAE.JAC_TMP_VAR(),
1597 _,
1598 _,
1599 _,
1600 a_matrixName,
1601 a_context,
1602 a_i )
1603 algorithm
1604 1470 txt := contextSystem(txt, a_context);
1605 1470 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
1606 1470 ret_1 := Util.getOption(a_matrixName);
1607 1470 txt := Tpl.writeStr(txt, ret_1);
1608 1470 txt := Tpl.writeTok(txt, Tpl.ST_STRING("jac_tmp("));
1609 1470 txt := Tpl.writeStr(txt, intString(a_i));
1610 1470 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
1611 then txt;
1612
1613 case ( txt,
1614 BackendDAE.SEED_VAR(),
1615 _,
1616 _,
1617 _,
1618 a_matrixName,
1619 a_context,
1620 a_i )
1621 algorithm
1622 573 txt := contextSystem(txt, a_context);
1623 573 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
1624 573 ret_2 := Util.getOption(a_matrixName);
1625 573 txt := Tpl.writeStr(txt, ret_2);
1626 573 txt := Tpl.writeTok(txt, Tpl.ST_STRING("jac_x("));
1627 573 txt := Tpl.writeStr(txt, intString(a_i));
1628 573 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
1629 then txt;
1630
1631 case ( txt,
1632 BackendDAE.VARIABLE(),
1633 a_useFlatArrayNotation,
1634 a_inCref,
1635 a_var,
1636 _,
1637 a_context,
1638 _ )
1639 algorithm
1640 13948 txt := fun_82(txt, a_var, a_context, a_useFlatArrayNotation, a_inCref);
1641 then txt;
1642
1643 case ( txt,
1644 _,
1645 a_useFlatArrayNotation,
1646 a_inCref,
1647 _,
1648 _,
1649 a_context,
1650 _ )
1651 algorithm
1652 26424 txt := contextSystem(txt, a_context);
1653 26424 txt := cref(txt, a_inCref, a_useFlatArrayNotation);
1654 then txt;
1655 end match;
1656 end fun_83;
1657
1658 protected function smf_84
1659 input Tpl.Text in_txt;
1660 input SimCodeVar.SimVar in_it;
1661 input Boolean in_a_useFlatArrayNotation;
1662 input DAE.ComponentRef in_a_inCref;
1663 input SimCodeFunction.Context in_a_context;
1664
1665 output Tpl.Text out_txt;
1666 algorithm
1667 out_txt :=
1668 match(in_txt, in_it, in_a_useFlatArrayNotation, in_a_inCref, in_a_context)
1669 local
1670 Tpl.Text txt;
1671 Boolean a_useFlatArrayNotation;
1672 DAE.ComponentRef a_inCref;
1673 SimCodeFunction.Context a_context;
1674 SimCodeVar.SimVar i_var;
1675 Option<String> i_matrixName;
1676 Integer i_i;
1677 BackendDAE.VarKind i_varKind;
1678
1679 case ( txt,
1680 (i_var as SimCodeVar.SIMVAR(varKind = i_varKind, index = i_i, matrixName = i_matrixName)),
1681 a_useFlatArrayNotation,
1682 a_inCref,
1683 a_context )
1684 algorithm
1685 42725 txt := fun_83(txt, i_varKind, a_useFlatArrayNotation, a_inCref, i_var, i_matrixName, a_context, i_i);
1686 then txt;
1687
1688 case ( txt,
1689 _,
1690 _,
1691 _,
1692 _ )
1693 then txt;
1694 end match;
1695 end smf_84;
1696
1697 protected function fun_85
1698 input Tpl.Text in_txt;
1699 input SimCodeFunction.Context in_a_context;
1700 input DAE.ComponentRef in_a_inCref;
1701 input SimCode.SimCode in_a_simCode;
1702 input Boolean in_a_useFlatArrayNotation;
1703
1704 output Tpl.Text out_txt;
1705 algorithm
1706 out_txt :=
1707 match(in_txt, in_a_context, in_a_inCref, in_a_simCode, in_a_useFlatArrayNotation)
1708 local
1709 Tpl.Text txt;
1710 DAE.ComponentRef a_inCref;
1711 SimCode.SimCode a_simCode;
1712 Boolean a_useFlatArrayNotation;
1713 SimCodeFunction.Context i_context;
1714 SimCodeVar.SimVar ret_1;
1715 Tpl.Text l_representation;
1716
1717 case ( txt,
1718 SimCodeFunction.FUNCTION_CONTEXT(cref_prefix = _),
1719 a_inCref,
1720 _,
1721 _ )
1722 algorithm
1723 ✗ txt := crefStr(txt, a_inCref);
1724 then txt;
1725
1726 case ( txt,
1727 i_context,
1728 a_inCref,
1729 a_simCode,
1730 a_useFlatArrayNotation )
1731 algorithm
1732 42725 ret_1 := SimCodeCodegenUtil.cref2simvar(a_inCref, a_simCode);
1733 42725 l_representation := smf_84(Tpl.emptyTxt, ret_1, a_useFlatArrayNotation, a_inCref, i_context);
1734 42725 txt := Tpl.writeText(txt, l_representation);
1735 then txt;
1736 end match;
1737 end fun_85;
1738
1739 public function representationCref
1740 input Tpl.Text txt;
1741 input DAE.ComponentRef a_inCref;
1742 input SimCode.SimCode a_simCode;
1743 input Tpl.Text a_extraFuncs;
1744 input Tpl.Text a_extraFuncsDecl;
1745 input Tpl.Text a_extraFuncsNamespace;
1746 input SimCodeFunction.Context a_context;
1747 input Tpl.Text a_varDecls;
1748 input Tpl.Text a_stateDerVectorName;
1749 input Boolean a_useFlatArrayNotation;
1750
1751 output Tpl.Text out_txt;
1752 output Tpl.Text out_a_extraFuncs;
1753 output Tpl.Text out_a_extraFuncsDecl;
1754 output Tpl.Text out_a_extraFuncsNamespace;
1755 output Tpl.Text out_a_varDecls;
1756 output Tpl.Text out_a_stateDerVectorName;
1757 algorithm
1758 42725 out_txt := fun_85(txt, a_context, a_inCref, a_simCode, a_useFlatArrayNotation);
1759 out_a_extraFuncs := a_extraFuncs;
1760 out_a_extraFuncsDecl := a_extraFuncsDecl;
1761 out_a_extraFuncsNamespace := a_extraFuncsNamespace;
1762 out_a_varDecls := a_varDecls;
1763 out_a_stateDerVectorName := a_stateDerVectorName;
1764 end representationCref;
1765
1766 public function arraycref
1767 input Tpl.Text in_txt;
1768 input DAE.ComponentRef in_a_cr;
1769 input Boolean in_a_useFlatArrayNotation;
1770
1771 output Tpl.Text out_txt;
1772 algorithm
1773 out_txt :=
1774 match(in_txt, in_a_cr, in_a_useFlatArrayNotation)
1775 local
1776 Tpl.Text txt;
1777 Boolean a_useFlatArrayNotation;
1778 DAE.ComponentRef i_cr;
1779
1780 case ( txt,
1781 (i_cr as DAE.CREF_IDENT(ident = "xloc")),
1782 _ )
1783 algorithm
1784 ✗ txt := crefStr(txt, i_cr);
1785 then txt;
1786
1787 case ( txt,
1788 DAE.CREF_IDENT(ident = "time"),
1789 _ )
1790 algorithm
1791 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_simTime"));
1792 then txt;
1793
1794 case ( txt,
1795 DAE.WILD(),
1796 _ )
1797 then txt;
1798
1799 case ( txt,
1800 i_cr,
1801 a_useFlatArrayNotation )
1802 algorithm
1803 108139 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
1804 108139 txt := crefToCStr1(txt, i_cr, a_useFlatArrayNotation);
1805 then txt;
1806 end match;
1807 end arraycref;
1808
1809 public function arraycref2
1810 input Tpl.Text in_txt;
1811 input DAE.ComponentRef in_a_cr;
1812 input Tpl.Text in_a_dims;
1813
1814 output Tpl.Text out_txt;
1815 output Tpl.Text out_a_dims;
1816 algorithm
1817 (out_txt, out_a_dims) :=
1818 match(in_txt, in_a_cr, in_a_dims)
1819 local
1820 Tpl.Text txt;
1821 Tpl.Text a_dims;
1822 DAE.ComponentRef i_cr;
1823
1824 case ( txt,
1825 (i_cr as DAE.CREF_IDENT(ident = "xloc")),
1826 a_dims )
1827 algorithm
1828 ✗ txt := crefStr(txt, i_cr);
1829 ✗ then (txt, a_dims);
1830
1831 case ( txt,
1832 DAE.CREF_IDENT(ident = "time"),
1833 a_dims )
1834 algorithm
1835 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_simTime"));
1836 ✗ then (txt, a_dims);
1837
1838 case ( txt,
1839 DAE.WILD(),
1840 a_dims )
1841 ✗ then (txt, a_dims);
1842
1843 case ( txt,
1844 i_cr,
1845 a_dims )
1846 algorithm
1847 427976 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
1848 427976 (txt, a_dims) := crefToCStrForArray(txt, i_cr, a_dims);
1849 then (txt, a_dims);
1850 end match;
1851 end arraycref2;
1852
1853 public function cref2
1854 input Tpl.Text in_txt;
1855 input DAE.ComponentRef in_a_cr;
1856 input Boolean in_a_useFlatArrayNotation;
1857
1858 output Tpl.Text out_txt;
1859 algorithm
1860 out_txt :=
1861 match(in_txt, in_a_cr, in_a_useFlatArrayNotation)
1862 local
1863 Tpl.Text txt;
1864 Boolean a_useFlatArrayNotation;
1865 DAE.ComponentRef i_cr;
1866
1867 case ( txt,
1868 (i_cr as DAE.CREF_IDENT(ident = "xloc")),
1869 _ )
1870 algorithm
1871 ✗ txt := crefStr(txt, i_cr);
1872 then txt;
1873
1874 case ( txt,
1875 DAE.CREF_IDENT(ident = "time"),
1876 _ )
1877 algorithm
1878 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_simTime"));
1879 then txt;
1880
1881 case ( txt,
1882 DAE.WILD(),
1883 _ )
1884 then txt;
1885
1886 case ( txt,
1887 i_cr,
1888 a_useFlatArrayNotation )
1889 algorithm
1890 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
1891 ✗ txt := crefToCStr(txt, i_cr, a_useFlatArrayNotation);
1892 then txt;
1893 end match;
1894 end cref2;
1895
1896 protected function fun_90
1897 input Tpl.Text in_txt;
1898 input Boolean in_mArg;
1899 input Boolean in_a_useFlatArrayNotation;
1900 input list<DAE.Subscript> in_a_subscriptLst;
1901
1902 output Tpl.Text out_txt;
1903 algorithm
1904 out_txt :=
1905 match(in_txt, in_mArg, in_a_useFlatArrayNotation, in_a_subscriptLst)
1906 local
1907 Tpl.Text txt;
1908 Boolean a_useFlatArrayNotation;
1909 list<DAE.Subscript> a_subscriptLst;
1910
1911 case ( txt,
1912 false,
1913 _,
1914 _ )
1915 then txt;
1916
1917 case ( txt,
1918 _,
1919 a_useFlatArrayNotation,
1920 a_subscriptLst )
1921 algorithm
1922 401973 txt := subscriptsToCStr(txt, a_subscriptLst, a_useFlatArrayNotation);
1923 then txt;
1924 end match;
1925 end fun_90;
1926
1927 protected function fun_91
1928 input Tpl.Text in_txt;
1929 input Boolean in_mArg;
1930 input list<DAE.Subscript> in_a_subscriptLst;
1931
1932 output Tpl.Text out_txt;
1933 algorithm
1934 out_txt :=
1935 match(in_txt, in_mArg, in_a_subscriptLst)
1936 local
1937 Tpl.Text txt;
1938 list<DAE.Subscript> a_subscriptLst;
1939
1940 case ( txt,
1941 false,
1942 _ )
1943 then txt;
1944
1945 case ( txt,
1946 _,
1947 a_subscriptLst )
1948 algorithm
1949 703245 txt := subscriptsToCStrForArray(txt, a_subscriptLst);
1950 then txt;
1951 end match;
1952 end fun_91;
1953
1954 public function crefToCStr
1955 input Tpl.Text in_txt;
1956 input DAE.ComponentRef in_a_cr;
1957 input Boolean in_a_useFlatArrayNotation;
1958
1959 output Tpl.Text out_txt;
1960 algorithm
1961 out_txt :=
1962 match(in_txt, in_a_cr, in_a_useFlatArrayNotation)
1963 local
1964 Tpl.Text txt;
1965 Boolean a_useFlatArrayNotation;
1966 DAE.ComponentRef i_componentRef;
1967 DAE.Ident i_ident;
1968 list<DAE.Subscript> i_subscriptLst;
1969 String ret_4;
1970 Boolean ret_3;
1971 String ret_2;
1972 Boolean ret_1;
1973 Tpl.Text l_subs;
1974
1975 case ( txt,
1976 DAE.CREF_IDENT(subscriptLst = i_subscriptLst, ident = i_ident),
1977 a_useFlatArrayNotation )
1978 algorithm
1979 402494 ret_1 := Flags.isSet(Flags.NF_SCALARIZE);
1980 402494 l_subs := fun_90(Tpl.emptyTxt, ret_1, a_useFlatArrayNotation, i_subscriptLst);
1981 402494 ret_2 := System.unquoteIdentifier(i_ident);
1982 402494 txt := Tpl.writeStr(txt, ret_2);
1983 402494 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
1984 402494 txt := Tpl.writeText(txt, l_subs);
1985 then txt;
1986
1987 case ( txt,
1988 DAE.CREF_QUAL(subscriptLst = i_subscriptLst, ident = i_ident, componentRef = i_componentRef),
1989 a_useFlatArrayNotation )
1990 algorithm
1991 703570 ret_3 := Flags.isSet(Flags.NF_SCALARIZE);
1992 703570 l_subs := fun_91(Tpl.emptyTxt, ret_3, i_subscriptLst);
1993 703570 ret_4 := System.unquoteIdentifier(i_ident);
1994 703570 txt := Tpl.writeStr(txt, ret_4);
1995 703570 txt := Tpl.writeText(txt, l_subs);
1996 703570 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_P_"));
1997 703570 txt := crefToCStr(txt, i_componentRef, a_useFlatArrayNotation);
1998 then txt;
1999
2000 case ( txt,
2001 DAE.WILD(),
2002 _ )
2003 then txt;
2004
2005 case ( txt,
2006 _,
2007 _ )
2008 algorithm
2009 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("CREF_NOT_IDENT_OR_QUAL"));
2010 then txt;
2011 end match;
2012 end crefToCStr;
2013
2014 public function contextSystem
2015 input Tpl.Text in_txt;
2016 input SimCodeFunction.Context in_a_context;
2017
2018 output Tpl.Text out_txt;
2019 algorithm
2020 out_txt :=
2021 match(in_txt, in_a_context)
2022 local
2023 Tpl.Text txt;
2024
2025 case ( txt,
2026 SimCodeFunction.ALGLOOP_CONTEXT(genInitialisation = false) )
2027 algorithm
2028 7065 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_system->"));
2029 then txt;
2030
2031 case ( txt,
2032 _ )
2033 then txt;
2034 end match;
2035 end contextSystem;
2036
2037 protected function fun_94
2038 input Tpl.Text in_txt;
2039 input SimCodeFunction.Context in_a_context;
2040 input DAE.ComponentRef in_a_cr;
2041 input DAE.Type in_a_t;
2042 input Boolean in_a_useFlatArrayNotation;
2043 input Tpl.Text in_a_stateDerVectorName;
2044 input Tpl.Text in_a_extraFuncsNamespace;
2045 input Tpl.Text in_a_extraFuncsDecl;
2046 input Tpl.Text in_a_extraFuncs;
2047 input SimCode.SimCode in_a_simCode;
2048 input Tpl.Text in_a_varDecls;
2049 input Tpl.Text in_a_preExp;
2050 input DAE.Exp in_a_exp;
2051
2052 output Tpl.Text out_txt;
2053 output Tpl.Text out_a_stateDerVectorName;
2054 output Tpl.Text out_a_extraFuncsNamespace;
2055 output Tpl.Text out_a_extraFuncsDecl;
2056 output Tpl.Text out_a_extraFuncs;
2057 output Tpl.Text out_a_varDecls;
2058 output Tpl.Text out_a_preExp;
2059 algorithm
2060 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls, out_a_preExp) :=
2061 match(in_txt, in_a_context, in_a_cr, in_a_t, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_varDecls, in_a_preExp, in_a_exp)
2062 local
2063 Tpl.Text txt;
2064 DAE.ComponentRef a_cr;
2065 DAE.Type a_t;
2066 Boolean a_useFlatArrayNotation;
2067 Tpl.Text a_stateDerVectorName;
2068 Tpl.Text a_extraFuncsNamespace;
2069 Tpl.Text a_extraFuncsDecl;
2070 Tpl.Text a_extraFuncs;
2071 SimCode.SimCode a_simCode;
2072 Tpl.Text a_varDecls;
2073 Tpl.Text a_preExp;
2074 DAE.Exp a_exp;
2075 SimCodeFunction.Context i_context;
2076
2077 case ( txt,
2078 (i_context as SimCodeFunction.FUNCTION_CONTEXT(cref_prefix = _)),
2079 _,
2080 _,
2081 a_useFlatArrayNotation,
2082 a_stateDerVectorName,
2083 a_extraFuncsNamespace,
2084 a_extraFuncsDecl,
2085 a_extraFuncs,
2086 a_simCode,
2087 a_varDecls,
2088 a_preExp,
2089 a_exp )
2090 algorithm
2091 38 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpCref(txt, false, a_exp, i_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
2092 38 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
2093
2094 case ( txt,
2095 i_context,
2096 a_cr,
2097 a_t,
2098 a_useFlatArrayNotation,
2099 a_stateDerVectorName,
2100 a_extraFuncsNamespace,
2101 a_extraFuncsDecl,
2102 a_extraFuncs,
2103 a_simCode,
2104 a_varDecls,
2105 a_preExp,
2106 _ )
2107 algorithm
2108 3 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpRecordCrefRhs(txt, a_t, a_cr, i_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
2109 3 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
2110 end match;
2111 end fun_94;
2112
2113 public function daeExpCrefRhs
2114 input Tpl.Text in_txt;
2115 input DAE.Exp in_a_exp;
2116 input SimCodeFunction.Context in_a_context;
2117 input Tpl.Text in_a_preExp;
2118 input Tpl.Text in_a_varDecls;
2119 input SimCode.SimCode in_a_simCode;
2120 input Tpl.Text in_a_extraFuncs;
2121 input Tpl.Text in_a_extraFuncsDecl;
2122 input Tpl.Text in_a_extraFuncsNamespace;
2123 input Tpl.Text in_a_stateDerVectorName;
2124 input Boolean in_a_useFlatArrayNotation;
2125
2126 output Tpl.Text out_txt;
2127 output Tpl.Text out_a_preExp;
2128 output Tpl.Text out_a_varDecls;
2129 output Tpl.Text out_a_extraFuncs;
2130 output Tpl.Text out_a_extraFuncsDecl;
2131 output Tpl.Text out_a_extraFuncsNamespace;
2132 output Tpl.Text out_a_stateDerVectorName;
2133 algorithm
2134 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
2135 match(in_txt, in_a_exp, in_a_context, in_a_preExp, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
2136 local
2137 Tpl.Text txt;
2138 SimCodeFunction.Context a_context;
2139 Tpl.Text a_preExp;
2140 Tpl.Text a_varDecls;
2141 SimCode.SimCode a_simCode;
2142 Tpl.Text a_extraFuncs;
2143 Tpl.Text a_extraFuncsDecl;
2144 Tpl.Text a_extraFuncsNamespace;
2145 Tpl.Text a_stateDerVectorName;
2146 Boolean a_useFlatArrayNotation;
2147 DAE.Ident i_ident;
2148 DAE.ComponentRef i_componentRef;
2149 DAE.ComponentRef i_cr;
2150 DAE.Type i_t;
2151 DAE.Exp i_exp;
2152 Tpl.Text txt_1;
2153 Absyn.Path ret_0;
2154
2155 case ( txt,
2156 (i_exp as DAE.CREF(componentRef = i_cr, ty = (i_t as DAE.T_COMPLEX(complexClassType = ClassInf.RECORD(path = _))))),
2157 a_context,
2158 a_preExp,
2159 a_varDecls,
2160 a_simCode,
2161 a_extraFuncs,
2162 a_extraFuncsDecl,
2163 a_extraFuncsNamespace,
2164 a_stateDerVectorName,
2165 a_useFlatArrayNotation )
2166 algorithm
2167 41 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := fun_94(txt, a_context, i_cr, i_t, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, i_exp);
2168 41 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
2169
2170 case ( txt,
2171 DAE.CREF(ty = DAE.T_FUNCTION_REFERENCE_FUNC(functionType = i_t), componentRef = i_componentRef),
2172 a_context,
2173 a_preExp,
2174 a_varDecls,
2175 _,
2176 a_extraFuncs,
2177 a_extraFuncsDecl,
2178 a_extraFuncsNamespace,
2179 a_stateDerVectorName,
2180 _ )
2181 algorithm
2182 ✗ ret_0 := ComponentReference.crefToPathIgnoreSubs(i_componentRef);
2183 ✗ txt_1 := CodegenUtil.underscorePath(Tpl.emptyTxt, ret_0);
2184 ✗ (txt, a_extraFuncsDecl) := functionClosure(txt, Tpl.textString(txt_1), "", i_t, i_t, a_context, a_extraFuncsDecl);
2185 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
2186
2187 case ( txt,
2188 DAE.CREF(componentRef = DAE.CREF_IDENT(ident = i_ident), ty = DAE.T_FUNCTION_REFERENCE_VAR(functionType = _)),
2189 a_context,
2190 a_preExp,
2191 a_varDecls,
2192 _,
2193 a_extraFuncs,
2194 a_extraFuncsDecl,
2195 a_extraFuncsNamespace,
2196 a_stateDerVectorName,
2197 _ )
2198 algorithm
2199 ✗ txt := contextFunName(txt, i_ident, a_context);
2200 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
2201
2202 case ( txt,
2203 i_exp,
2204 a_context,
2205 a_preExp,
2206 a_varDecls,
2207 a_simCode,
2208 a_extraFuncs,
2209 a_extraFuncsDecl,
2210 a_extraFuncsNamespace,
2211 a_stateDerVectorName,
2212 a_useFlatArrayNotation )
2213 algorithm
2214 54256 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpCref(txt, false, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
2215 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
2216 end match;
2217 end daeExpCrefRhs;
2218
2219 protected function fun_96
2220 input Tpl.Text in_txt;
2221 input Boolean in_a_isLhs;
2222
2223 output Tpl.Text out_txt;
2224 algorithm
2225 out_txt :=
2226 match(in_txt, in_a_isLhs)
2227 local
2228 Tpl.Text txt;
2229
2230 case ( txt,
2231 false )
2232 algorithm
2233 17 txt := Tpl.writeTok(txt, Tpl.ST_STRING("ArraySliceConst"));
2234 then txt;
2235
2236 case ( txt,
2237 _ )
2238 algorithm
2239 10 txt := Tpl.writeTok(txt, Tpl.ST_STRING("ArraySlice"));
2240 then txt;
2241 end match;
2242 end fun_96;
2243
2244 protected function lm_97
2245 input output Tpl.Text txt;
2246 input list<DAE.Subscript> items;
2247 input Boolean a_useFlatArrayNotation;
2248 input output Tpl.Text a_stateDerVectorName;
2249 input output Tpl.Text a_extraFuncsNamespace;
2250 input output Tpl.Text a_extraFuncsDecl;
2251 input output Tpl.Text a_extraFuncs;
2252 input SimCode.SimCode a_simCode;
2253 input output Tpl.Text a_varDecls;
2254 input output Tpl.Text a_preExp;
2255 input SimCodeFunction.Context a_context;
2256 algorithm
2257
2/2
✓ Branch 0 taken 13603 times.
✓ Branch 1 taken 13599 times.
27202 for lstElt_97 in items loop
2258 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_97
2259 local
2260 DAE.Exp i_exp;
2261
2262 case DAE.INDEX(exp = i_exp)
2263 algorithm
2264 13603 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
2265 13603 txt := Tpl.nextIter(txt);
2266 13603 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
2267
2268 case _
2269 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
2270 end match;
2271 end for;
2272 end lm_97;
2273
2274 protected function fun_98
2275 input Tpl.Text in_txt;
2276 input String in_mArg;
2277 input Tpl.Text in_a_dimsValuesStr;
2278 input Tpl.Text in_a_arrName;
2279
2280 output Tpl.Text out_txt;
2281 algorithm
2282 out_txt :=
2283 match(in_txt, in_mArg, in_a_dimsValuesStr, in_a_arrName)
2284 local
2285 Tpl.Text txt;
2286 Tpl.Text a_dimsValuesStr;
2287 Tpl.Text a_arrName;
2288
2289 case ( txt,
2290 "metatype_array",
2291 a_dimsValuesStr,
2292 a_arrName )
2293 algorithm
2294 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("arrayGet("));
2295 ✗ txt := Tpl.writeText(txt, a_arrName);
2296 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(","));
2297 ✗ txt := Tpl.writeText(txt, a_dimsValuesStr);
2298 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(") /* DAE.CREF */"));
2299 then txt;
2300
2301 case ( txt,
2302 _,
2303 a_dimsValuesStr,
2304 a_arrName )
2305 algorithm
2306 13599 txt := Tpl.writeText(txt, a_arrName);
2307 13599 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
2308 13599 txt := Tpl.writeText(txt, a_dimsValuesStr);
2309 13599 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
2310 then txt;
2311 end match;
2312 end fun_98;
2313
2314 protected function fun_99
2315 input Tpl.Text in_txt;
2316 input Boolean in_mArg;
2317 input Boolean in_a_useFlatArrayNotation;
2318 input Tpl.Text in_a_stateDerVectorName;
2319 input Tpl.Text in_a_extraFuncsNamespace;
2320 input Tpl.Text in_a_extraFuncsDecl;
2321 input Tpl.Text in_a_extraFuncs;
2322 input SimCode.SimCode in_a_simCode;
2323 input Tpl.Text in_a_varDecls;
2324 input Tpl.Text in_a_preExp;
2325 input DAE.Type in_a_ty;
2326 input Boolean in_a_isLhs;
2327 input SimCodeFunction.Context in_a_context;
2328 input DAE.ComponentRef in_a_cr;
2329
2330 output Tpl.Text out_txt;
2331 output Tpl.Text out_a_stateDerVectorName;
2332 output Tpl.Text out_a_extraFuncsNamespace;
2333 output Tpl.Text out_a_extraFuncsDecl;
2334 output Tpl.Text out_a_extraFuncs;
2335 output Tpl.Text out_a_varDecls;
2336 output Tpl.Text out_a_preExp;
2337 algorithm
2338 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls, out_a_preExp) :=
2339 match(in_txt, in_mArg, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_varDecls, in_a_preExp, in_a_ty, in_a_isLhs, in_a_context, in_a_cr)
2340 local
2341 Tpl.Text txt;
2342 Boolean a_useFlatArrayNotation;
2343 Tpl.Text a_stateDerVectorName;
2344 Tpl.Text a_extraFuncsNamespace;
2345 Tpl.Text a_extraFuncsDecl;
2346 Tpl.Text a_extraFuncs;
2347 SimCode.SimCode a_simCode;
2348 Tpl.Text a_varDecls;
2349 Tpl.Text a_preExp;
2350 DAE.Type a_ty;
2351 Boolean a_isLhs;
2352 SimCodeFunction.Context a_context;
2353 DAE.ComponentRef a_cr;
2354 String str_9;
2355 list<DAE.Subscript> ret_8;
2356 Tpl.Text l_dimsValuesStr;
2357 Tpl.Text l_arrayType;
2358 DAE.ComponentRef ret_5;
2359 list<DAE.Subscript> ret_4;
2360 Tpl.Text l_slice;
2361 Tpl.Text l_elTypeStr;
2362 Tpl.Text l_arrTypeStr;
2363 Tpl.Text l_arrName;
2364
2365 case ( txt,
2366 false,
2367 a_useFlatArrayNotation,
2368 a_stateDerVectorName,
2369 a_extraFuncsNamespace,
2370 a_extraFuncsDecl,
2371 a_extraFuncs,
2372 a_simCode,
2373 a_varDecls,
2374 a_preExp,
2375 a_ty,
2376 a_isLhs,
2377 a_context,
2378 a_cr )
2379 algorithm
2380 27 l_arrName := contextArrayCref(Tpl.emptyTxt, a_cr, a_context);
2381 27 l_arrTypeStr := fun_96(Tpl.emptyTxt, a_isLhs);
2382 27 l_elTypeStr := expTypeShort(Tpl.emptyTxt, a_ty);
2383 27 ret_4 := ComponentReferenceBasics.crefSubs(a_cr);
2384 27 (l_slice, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpCrefIndexSpec(Tpl.emptyTxt, ret_4, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
2385 27 a_preExp := Tpl.writeText(a_preExp, l_arrTypeStr);
2386 27 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("<"));
2387 27 a_preExp := Tpl.writeText(a_preExp, l_elTypeStr);
2388 27 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("> "));
2389 27 a_preExp := Tpl.writeText(a_preExp, l_slice);
2390 27 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("_as("));
2391 27 a_preExp := Tpl.writeText(a_preExp, l_arrName);
2392 27 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
2393 27 a_preExp := Tpl.writeText(a_preExp, l_slice);
2394 27 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
2395 27 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
2396 27 txt := Tpl.writeText(txt, l_slice);
2397 27 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_as"));
2398 27 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
2399
2400 case ( txt,
2401 _,
2402 a_useFlatArrayNotation,
2403 a_stateDerVectorName,
2404 a_extraFuncsNamespace,
2405 a_extraFuncsDecl,
2406 a_extraFuncs,
2407 a_simCode,
2408 a_varDecls,
2409 a_preExp,
2410 a_ty,
2411 _,
2412 a_context,
2413 a_cr )
2414 algorithm
2415 13599 ret_5 := ComponentReferenceBasics.crefStripLastSubs(a_cr);
2416 13599 (l_arrName, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := contextCref(Tpl.emptyTxt, ret_5, a_context, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
2417 13599 l_arrayType := expTypeShort(Tpl.emptyTxt, a_ty);
2418 13599 ret_8 := ComponentReferenceBasics.crefSubs(a_cr);
2419 13599 l_dimsValuesStr := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(",")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2420 13599 (l_dimsValuesStr, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_97(l_dimsValuesStr, ret_8, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
2421 13599 l_dimsValuesStr := Tpl.popIter(l_dimsValuesStr);
2422 13599 str_9 := Tpl.textString(l_arrayType);
2423 13599 txt := fun_98(txt, str_9, l_dimsValuesStr, l_arrName);
2424 13599 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
2425 end match;
2426 end fun_99;
2427
2428 protected function fun_100
2429 input Tpl.Text in_txt;
2430 input Boolean in_mArg;
2431 input Boolean in_a_useFlatArrayNotation;
2432 input Tpl.Text in_a_stateDerVectorName;
2433 input Tpl.Text in_a_extraFuncsNamespace;
2434 input Tpl.Text in_a_extraFuncsDecl;
2435 input Tpl.Text in_a_extraFuncs;
2436 input SimCode.SimCode in_a_simCode;
2437 input Tpl.Text in_a_varDecls;
2438 input Tpl.Text in_a_preExp;
2439 input DAE.Type in_a_ty;
2440 input Boolean in_a_isLhs;
2441 input SimCodeFunction.Context in_a_context;
2442 input DAE.ComponentRef in_a_cr;
2443
2444 output Tpl.Text out_txt;
2445 output Tpl.Text out_a_stateDerVectorName;
2446 output Tpl.Text out_a_extraFuncsNamespace;
2447 output Tpl.Text out_a_extraFuncsDecl;
2448 output Tpl.Text out_a_extraFuncs;
2449 output Tpl.Text out_a_varDecls;
2450 output Tpl.Text out_a_preExp;
2451 algorithm
2452 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls, out_a_preExp) :=
2453 match(in_txt, in_mArg, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_varDecls, in_a_preExp, in_a_ty, in_a_isLhs, in_a_context, in_a_cr)
2454 local
2455 Tpl.Text txt;
2456 Boolean a_useFlatArrayNotation;
2457 Tpl.Text a_stateDerVectorName;
2458 Tpl.Text a_extraFuncsNamespace;
2459 Tpl.Text a_extraFuncsDecl;
2460 Tpl.Text a_extraFuncs;
2461 SimCode.SimCode a_simCode;
2462 Tpl.Text a_varDecls;
2463 Tpl.Text a_preExp;
2464 DAE.Type a_ty;
2465 Boolean a_isLhs;
2466 SimCodeFunction.Context a_context;
2467 DAE.ComponentRef a_cr;
2468 Boolean ret_6;
2469 Boolean ret_5;
2470 Boolean ret_4;
2471 Integer ret_3;
2472 list<DAE.Dimension> ret_2;
2473 Integer ret_1;
2474 list<DAE.Subscript> ret_0;
2475
2476 case ( txt,
2477 false,
2478 a_useFlatArrayNotation,
2479 a_stateDerVectorName,
2480 a_extraFuncsNamespace,
2481 a_extraFuncsDecl,
2482 a_extraFuncs,
2483 a_simCode,
2484 a_varDecls,
2485 a_preExp,
2486 a_ty,
2487 a_isLhs,
2488 a_context,
2489 a_cr )
2490 algorithm
2491 13626 ret_0 := ComponentReferenceBasics.crefSubs(a_cr);
2492 13626 ret_1 := listLength(ret_0);
2493 13626 ret_2 := ComponentReferenceBasics.crefDims(a_cr);
2494 13626 ret_3 := listLength(ret_2);
2495 13626 ret_4 := intEq(ret_1, ret_3);
2496 13626 ret_5 := SimCodeFunctionUtil.crefSubIsScalar(a_cr);
2497 13626 ret_6 := boolAnd(ret_4, ret_5);
2498 13626 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := fun_99(txt, ret_6, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_ty, a_isLhs, a_context, a_cr);
2499 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
2500
2501 case ( txt,
2502 _,
2503 a_useFlatArrayNotation,
2504 a_stateDerVectorName,
2505 a_extraFuncsNamespace,
2506 a_extraFuncsDecl,
2507 a_extraFuncs,
2508 a_simCode,
2509 a_varDecls,
2510 a_preExp,
2511 _,
2512 _,
2513 a_context,
2514 a_cr )
2515 algorithm
2516 42790 (txt, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := contextCref(txt, a_cr, a_context, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
2517 42790 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
2518 end match;
2519 end fun_100;
2520
2521 protected function fun_101
2522 input Tpl.Text in_txt;
2523 input Boolean in_mArg;
2524 input Tpl.Text in_a_box;
2525 input Boolean in_a_useFlatArrayNotation;
2526 input Tpl.Text in_a_stateDerVectorName;
2527 input Tpl.Text in_a_extraFuncsNamespace;
2528 input Tpl.Text in_a_extraFuncsDecl;
2529 input Tpl.Text in_a_extraFuncs;
2530 input SimCode.SimCode in_a_simCode;
2531 input Tpl.Text in_a_varDecls;
2532 input Tpl.Text in_a_preExp;
2533 input DAE.Type in_a_ty;
2534 input Boolean in_a_isLhs;
2535 input SimCodeFunction.Context in_a_context;
2536 input DAE.ComponentRef in_a_cr;
2537
2538 output Tpl.Text out_txt;
2539 output Tpl.Text out_a_stateDerVectorName;
2540 output Tpl.Text out_a_extraFuncsNamespace;
2541 output Tpl.Text out_a_extraFuncsDecl;
2542 output Tpl.Text out_a_extraFuncs;
2543 output Tpl.Text out_a_varDecls;
2544 output Tpl.Text out_a_preExp;
2545 algorithm
2546 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls, out_a_preExp) :=
2547 match(in_txt, in_mArg, in_a_box, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_varDecls, in_a_preExp, in_a_ty, in_a_isLhs, in_a_context, in_a_cr)
2548 local
2549 Tpl.Text txt;
2550 Tpl.Text a_box;
2551 Boolean a_useFlatArrayNotation;
2552 Tpl.Text a_stateDerVectorName;
2553 Tpl.Text a_extraFuncsNamespace;
2554 Tpl.Text a_extraFuncsDecl;
2555 Tpl.Text a_extraFuncs;
2556 SimCode.SimCode a_simCode;
2557 Tpl.Text a_varDecls;
2558 Tpl.Text a_preExp;
2559 DAE.Type a_ty;
2560 Boolean a_isLhs;
2561 SimCodeFunction.Context a_context;
2562 DAE.ComponentRef a_cr;
2563 Boolean ret_0;
2564
2565 case ( txt,
2566 true,
2567 _,
2568 a_useFlatArrayNotation,
2569 a_stateDerVectorName,
2570 a_extraFuncsNamespace,
2571 a_extraFuncsDecl,
2572 a_extraFuncs,
2573 a_simCode,
2574 a_varDecls,
2575 a_preExp,
2576 a_ty,
2577 a_isLhs,
2578 a_context,
2579 a_cr )
2580 algorithm
2581 56416 ret_0 := SimCodeFunctionUtil.crefIsScalar(a_cr, a_context);
2582 56416 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := fun_100(txt, ret_0, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_ty, a_isLhs, a_context, a_cr);
2583 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
2584
2585 case ( txt,
2586 _,
2587 a_box,
2588 _,
2589 a_stateDerVectorName,
2590 a_extraFuncsNamespace,
2591 a_extraFuncsDecl,
2592 a_extraFuncs,
2593 _,
2594 a_varDecls,
2595 a_preExp,
2596 _,
2597 _,
2598 _,
2599 _ )
2600 algorithm
2601 1475 txt := Tpl.writeText(txt, a_box);
2602 1475 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
2603 end match;
2604 end fun_101;
2605
2606 protected function fun_102
2607 input Tpl.Text in_txt;
2608 input DAE.Exp in_a_ecr;
2609 input Boolean in_a_isLhs;
2610 input SimCodeFunction.Context in_a_context;
2611 input Tpl.Text in_a_preExp;
2612 input Tpl.Text in_a_varDecls;
2613 input SimCode.SimCode in_a_simCode;
2614 input Tpl.Text in_a_extraFuncs;
2615 input Tpl.Text in_a_extraFuncsDecl;
2616 input Tpl.Text in_a_extraFuncsNamespace;
2617 input Tpl.Text in_a_stateDerVectorName;
2618 input Boolean in_a_useFlatArrayNotation;
2619
2620 output Tpl.Text out_txt;
2621 output Tpl.Text out_a_preExp;
2622 output Tpl.Text out_a_varDecls;
2623 output Tpl.Text out_a_extraFuncs;
2624 output Tpl.Text out_a_extraFuncsDecl;
2625 output Tpl.Text out_a_extraFuncsNamespace;
2626 output Tpl.Text out_a_stateDerVectorName;
2627 algorithm
2628 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
2629 match(in_txt, in_a_ecr, in_a_isLhs, in_a_context, in_a_preExp, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
2630 local
2631 Tpl.Text txt;
2632 Boolean a_isLhs;
2633 SimCodeFunction.Context a_context;
2634 Tpl.Text a_preExp;
2635 Tpl.Text a_varDecls;
2636 SimCode.SimCode a_simCode;
2637 Tpl.Text a_extraFuncs;
2638 Tpl.Text a_extraFuncsDecl;
2639 Tpl.Text a_extraFuncsNamespace;
2640 Tpl.Text a_stateDerVectorName;
2641 Boolean a_useFlatArrayNotation;
2642 DAE.Type i_ty;
2643 DAE.ComponentRef i_cr;
2644 Absyn.Path i_name;
2645 Boolean ret_1;
2646 Tpl.Text l_box;
2647
2648 case ( txt,
2649 DAE.CREF(componentRef = _, ty = DAE.T_FUNCTION(path = i_name)),
2650 _,
2651 _,
2652 a_preExp,
2653 a_varDecls,
2654 _,
2655 a_extraFuncs,
2656 a_extraFuncsDecl,
2657 a_extraFuncsNamespace,
2658 a_stateDerVectorName,
2659 _ )
2660 algorithm
2661 ✗ txt := CodegenUtil.underscorePath(txt, i_name);
2662 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
2663
2664 case ( txt,
2665 DAE.CREF(componentRef = i_cr, ty = i_ty),
2666 a_isLhs,
2667 a_context,
2668 a_preExp,
2669 a_varDecls,
2670 a_simCode,
2671 a_extraFuncs,
2672 a_extraFuncsDecl,
2673 a_extraFuncsNamespace,
2674 a_stateDerVectorName,
2675 a_useFlatArrayNotation )
2676 algorithm
2677 57891 (l_box, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpCrefRhsArrayBox(Tpl.emptyTxt, i_cr, i_ty, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
2678 57891 ret_1 := Tpl.isEmpty(l_box);
2679 57891 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := fun_101(txt, ret_1, l_box, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, i_ty, a_isLhs, a_context, i_cr);
2680 57891 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
2681
2682 case ( txt,
2683 _,
2684 _,
2685 _,
2686 a_preExp,
2687 a_varDecls,
2688 _,
2689 a_extraFuncs,
2690 a_extraFuncsDecl,
2691 a_extraFuncsNamespace,
2692 a_stateDerVectorName,
2693 _ )
2694 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
2695 end match;
2696 end fun_102;
2697
2698 public function daeExpCref
2699 input Tpl.Text txt;
2700 input Boolean a_isLhs;
2701 input DAE.Exp a_ecr;
2702 input SimCodeFunction.Context a_context;
2703 input Tpl.Text a_preExp;
2704 input Tpl.Text a_varDecls;
2705 input SimCode.SimCode a_simCode;
2706 input Tpl.Text a_extraFuncs;
2707 input Tpl.Text a_extraFuncsDecl;
2708 input Tpl.Text a_extraFuncsNamespace;
2709 input Tpl.Text a_stateDerVectorName;
2710 input Boolean a_useFlatArrayNotation;
2711
2712 output Tpl.Text out_txt;
2713 output Tpl.Text out_a_preExp;
2714 output Tpl.Text out_a_varDecls;
2715 output Tpl.Text out_a_extraFuncs;
2716 output Tpl.Text out_a_extraFuncsDecl;
2717 output Tpl.Text out_a_extraFuncsNamespace;
2718 output Tpl.Text out_a_stateDerVectorName;
2719 algorithm
2720 57891 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) := fun_102(txt, a_ecr, a_isLhs, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
2721 end daeExpCref;
2722
2723 protected function fun_104
2724 input Tpl.Text in_txt;
2725 input Option<DAE.Exp> in_a_step;
2726 input Boolean in_a_useFlatArrayNotation;
2727 input Tpl.Text in_a_stateDerVectorName;
2728 input Tpl.Text in_a_extraFuncsNamespace;
2729 input Tpl.Text in_a_extraFuncsDecl;
2730 input Tpl.Text in_a_extraFuncs;
2731 input SimCode.SimCode in_a_simCode;
2732 input Tpl.Text in_a_varDecls;
2733 input Tpl.Text in_a_preExp;
2734 input SimCodeFunction.Context in_a_context;
2735
2736 output Tpl.Text out_txt;
2737 output Tpl.Text out_a_stateDerVectorName;
2738 output Tpl.Text out_a_extraFuncsNamespace;
2739 output Tpl.Text out_a_extraFuncsDecl;
2740 output Tpl.Text out_a_extraFuncs;
2741 output Tpl.Text out_a_varDecls;
2742 output Tpl.Text out_a_preExp;
2743 algorithm
2744 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls, out_a_preExp) :=
2745 match(in_txt, in_a_step, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_varDecls, in_a_preExp, in_a_context)
2746 local
2747 Tpl.Text txt;
2748 Boolean a_useFlatArrayNotation;
2749 Tpl.Text a_stateDerVectorName;
2750 Tpl.Text a_extraFuncsNamespace;
2751 Tpl.Text a_extraFuncsDecl;
2752 Tpl.Text a_extraFuncs;
2753 SimCode.SimCode a_simCode;
2754 Tpl.Text a_varDecls;
2755 Tpl.Text a_preExp;
2756 SimCodeFunction.Context a_context;
2757 DAE.Exp i_stepExp;
2758
2759 case ( txt,
2760 SOME(i_stepExp),
2761 a_useFlatArrayNotation,
2762 a_stateDerVectorName,
2763 a_extraFuncsNamespace,
2764 a_extraFuncsDecl,
2765 a_extraFuncs,
2766 a_simCode,
2767 a_varDecls,
2768 a_preExp,
2769 a_context )
2770 algorithm
2771 1 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_stepExp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
2772 1 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
2773
2774 case ( txt,
2775 _,
2776 _,
2777 a_stateDerVectorName,
2778 a_extraFuncsNamespace,
2779 a_extraFuncsDecl,
2780 a_extraFuncs,
2781 _,
2782 a_varDecls,
2783 a_preExp,
2784 _ )
2785 algorithm
2786 9 txt := Tpl.writeTok(txt, Tpl.ST_STRING("1"));
2787 9 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
2788 end match;
2789 end fun_104;
2790
2791 protected function fun_105
2792 input Tpl.Text in_txt;
2793 input DAE.Exp in_a_exp;
2794 input Tpl.Text in_a_tmp__slice;
2795 input Boolean in_a_useFlatArrayNotation;
2796 input Tpl.Text in_a_stateDerVectorName;
2797 input Tpl.Text in_a_extraFuncsNamespace;
2798 input Tpl.Text in_a_extraFuncsDecl;
2799 input Tpl.Text in_a_extraFuncs;
2800 input SimCode.SimCode in_a_simCode;
2801 input Tpl.Text in_a_varDecls;
2802 input Tpl.Text in_a_preExp;
2803 input SimCodeFunction.Context in_a_context;
2804
2805 output Tpl.Text out_txt;
2806 output Tpl.Text out_a_stateDerVectorName;
2807 output Tpl.Text out_a_extraFuncsNamespace;
2808 output Tpl.Text out_a_extraFuncsDecl;
2809 output Tpl.Text out_a_extraFuncs;
2810 output Tpl.Text out_a_varDecls;
2811 output Tpl.Text out_a_preExp;
2812 algorithm
2813 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls, out_a_preExp) :=
2814 match(in_txt, in_a_exp, in_a_tmp__slice, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_varDecls, in_a_preExp, in_a_context)
2815 local
2816 Tpl.Text txt;
2817 Tpl.Text a_tmp__slice;
2818 Boolean a_useFlatArrayNotation;
2819 Tpl.Text a_stateDerVectorName;
2820 Tpl.Text a_extraFuncsNamespace;
2821 Tpl.Text a_extraFuncsDecl;
2822 Tpl.Text a_extraFuncs;
2823 SimCode.SimCode a_simCode;
2824 Tpl.Text a_varDecls;
2825 Tpl.Text a_preExp;
2826 SimCodeFunction.Context a_context;
2827 DAE.Exp i_exp;
2828 Option<DAE.Exp> i_step;
2829 DAE.Exp i_stop;
2830 DAE.Exp i_start;
2831 Tpl.Text l_expPart;
2832 Tpl.Text l_step__exp;
2833 Tpl.Text l_stop__exp;
2834 Tpl.Text l_start__exp;
2835
2836 case ( txt,
2837 DAE.RANGE(start = i_start, stop = i_stop, step = i_step),
2838 a_tmp__slice,
2839 a_useFlatArrayNotation,
2840 a_stateDerVectorName,
2841 a_extraFuncsNamespace,
2842 a_extraFuncsDecl,
2843 a_extraFuncs,
2844 a_simCode,
2845 a_varDecls,
2846 a_preExp,
2847 a_context )
2848 algorithm
2849 10 (l_start__exp, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_start, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
2850 10 (l_stop__exp, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_stop, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
2851 10 (l_step__exp, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := fun_104(Tpl.emptyTxt, i_step, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
2852 10 a_preExp := Tpl.writeText(a_preExp, a_tmp__slice);
2853 10 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(".push_back(Slice("));
2854 10 a_preExp := Tpl.writeText(a_preExp, l_start__exp);
2855 10 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
2856 10 a_preExp := Tpl.writeText(a_preExp, l_step__exp);
2857 10 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
2858 10 a_preExp := Tpl.writeText(a_preExp, l_stop__exp);
2859 10 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("));"));
2860 10 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
2861 10 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
2862
2863 case ( txt,
2864 i_exp,
2865 a_tmp__slice,
2866 a_useFlatArrayNotation,
2867 a_stateDerVectorName,
2868 a_extraFuncsNamespace,
2869 a_extraFuncsDecl,
2870 a_extraFuncs,
2871 a_simCode,
2872 a_varDecls,
2873 a_preExp,
2874 a_context )
2875 algorithm
2876 1 (l_expPart, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
2877 1 a_preExp := Tpl.writeText(a_preExp, a_tmp__slice);
2878 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(".push_back(Slice("));
2879 1 a_preExp := Tpl.writeText(a_preExp, l_expPart);
2880 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("));"));
2881 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
2882 1 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
2883 end match;
2884 end fun_105;
2885
2886 protected function fun_106
2887 input Tpl.Text in_txt;
2888 input DAE.Subscript in_a_sub;
2889 input Tpl.Text in_a_tmp__slice;
2890 input Boolean in_a_useFlatArrayNotation;
2891 input Tpl.Text in_a_stateDerVectorName;
2892 input Tpl.Text in_a_extraFuncsNamespace;
2893 input Tpl.Text in_a_extraFuncsDecl;
2894 input Tpl.Text in_a_extraFuncs;
2895 input SimCode.SimCode in_a_simCode;
2896 input Tpl.Text in_a_varDecls;
2897 input Tpl.Text in_a_preExp;
2898 input SimCodeFunction.Context in_a_context;
2899
2900 output Tpl.Text out_txt;
2901 output Tpl.Text out_a_stateDerVectorName;
2902 output Tpl.Text out_a_extraFuncsNamespace;
2903 output Tpl.Text out_a_extraFuncsDecl;
2904 output Tpl.Text out_a_extraFuncs;
2905 output Tpl.Text out_a_varDecls;
2906 output Tpl.Text out_a_preExp;
2907 algorithm
2908 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls, out_a_preExp) :=
2909 match(in_txt, in_a_sub, in_a_tmp__slice, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_varDecls, in_a_preExp, in_a_context)
2910 local
2911 Tpl.Text txt;
2912 Tpl.Text a_tmp__slice;
2913 Boolean a_useFlatArrayNotation;
2914 Tpl.Text a_stateDerVectorName;
2915 Tpl.Text a_extraFuncsNamespace;
2916 Tpl.Text a_extraFuncsDecl;
2917 Tpl.Text a_extraFuncs;
2918 SimCode.SimCode a_simCode;
2919 Tpl.Text a_varDecls;
2920 Tpl.Text a_preExp;
2921 SimCodeFunction.Context a_context;
2922 DAE.Exp i_exp;
2923 Tpl.Text l_expPart;
2924
2925 case ( txt,
2926 DAE.INDEX(exp = i_exp),
2927 a_tmp__slice,
2928 a_useFlatArrayNotation,
2929 a_stateDerVectorName,
2930 a_extraFuncsNamespace,
2931 a_extraFuncsDecl,
2932 a_extraFuncs,
2933 a_simCode,
2934 a_varDecls,
2935 a_preExp,
2936 a_context )
2937 algorithm
2938 15 (l_expPart, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
2939 15 a_preExp := Tpl.writeText(a_preExp, a_tmp__slice);
2940 15 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(".push_back(Slice("));
2941 15 a_preExp := Tpl.writeText(a_preExp, l_expPart);
2942 15 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("));"));
2943 15 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
2944 15 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
2945
2946 case ( txt,
2947 DAE.WHOLEDIM(),
2948 a_tmp__slice,
2949 _,
2950 a_stateDerVectorName,
2951 a_extraFuncsNamespace,
2952 a_extraFuncsDecl,
2953 a_extraFuncs,
2954 _,
2955 a_varDecls,
2956 a_preExp,
2957 _ )
2958 algorithm
2959 7 a_preExp := Tpl.writeText(a_preExp, a_tmp__slice);
2960 7 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(".push_back(Slice());"));
2961 7 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
2962 7 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
2963
2964 case ( txt,
2965 DAE.SLICE(exp = i_exp),
2966 a_tmp__slice,
2967 a_useFlatArrayNotation,
2968 a_stateDerVectorName,
2969 a_extraFuncsNamespace,
2970 a_extraFuncsDecl,
2971 a_extraFuncs,
2972 a_simCode,
2973 a_varDecls,
2974 a_preExp,
2975 a_context )
2976 algorithm
2977 11 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := fun_105(txt, i_exp, a_tmp__slice, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
2978 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
2979
2980 case ( txt,
2981 _,
2982 _,
2983 _,
2984 a_stateDerVectorName,
2985 a_extraFuncsNamespace,
2986 a_extraFuncsDecl,
2987 a_extraFuncs,
2988 _,
2989 a_varDecls,
2990 a_preExp,
2991 _ )
2992 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
2993 end match;
2994 end fun_106;
2995
2996 protected function lm_107
2997 input output Tpl.Text txt;
2998 input list<DAE.Subscript> items;
2999 input Tpl.Text a_tmp__slice;
3000 input Boolean a_useFlatArrayNotation;
3001 input output Tpl.Text a_stateDerVectorName;
3002 input output Tpl.Text a_extraFuncsNamespace;
3003 input output Tpl.Text a_extraFuncsDecl;
3004 input output Tpl.Text a_extraFuncs;
3005 input SimCode.SimCode a_simCode;
3006 input output Tpl.Text a_varDecls;
3007 input output Tpl.Text a_preExp;
3008 input SimCodeFunction.Context a_context;
3009 algorithm
3010
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 27 times.
60 for lstElt_107 in items loop
3011 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_107
3012 local
3013 DAE.Subscript i_sub;
3014
3015 case i_sub
3016 algorithm
3017 33 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := fun_106(txt, i_sub, a_tmp__slice, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
3018 33 txt := Tpl.nextIter(txt);
3019 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
3020 end match;
3021 end for;
3022 end lm_107;
3023
3024 public function daeExpCrefIndexSpec
3025 input Tpl.Text txt;
3026 input list<DAE.Subscript> a_subs;
3027 input SimCodeFunction.Context a_context;
3028 input Tpl.Text a_preExp;
3029 input Tpl.Text a_varDecls;
3030 input SimCode.SimCode a_simCode;
3031 input Tpl.Text a_extraFuncs;
3032 input Tpl.Text a_extraFuncsDecl;
3033 input Tpl.Text a_extraFuncsNamespace;
3034 input Tpl.Text a_stateDerVectorName;
3035 input Boolean a_useFlatArrayNotation;
3036
3037 output Tpl.Text out_txt;
3038 output Tpl.Text out_a_preExp;
3039 output Tpl.Text out_a_varDecls;
3040 output Tpl.Text out_a_extraFuncs;
3041 output Tpl.Text out_a_extraFuncsDecl;
3042 output Tpl.Text out_a_extraFuncsNamespace;
3043 output Tpl.Text out_a_stateDerVectorName;
3044 protected
3045 Tpl.Text l_0__;
3046 Tpl.Text l_tmp__slice;
3047 algorithm
3048 27 (l_tmp__slice, out_a_varDecls) := tempDecl(Tpl.emptyTxt, "vector<Slice>", a_varDecls);
3049 27 out_a_preExp := Tpl.writeText(a_preExp, l_tmp__slice);
3050 27 out_a_preExp := Tpl.writeTok(out_a_preExp, Tpl.ST_STRING(".clear();"));
3051 27 out_a_preExp := Tpl.writeTok(out_a_preExp, Tpl.ST_NEW_LINE());
3052 27 l_0__ := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING_LIST({
3053 "\n",
3054 " "
3055 }, false)), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
3056 27 (l_0__, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls, out_a_preExp) := lm_107(l_0__, a_subs, l_tmp__slice, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, out_a_varDecls, out_a_preExp, a_context);
3057 27 l_0__ := Tpl.popIter(l_0__);
3058 27 out_txt := Tpl.writeText(txt, l_tmp__slice);
3059 end daeExpCrefIndexSpec;
3060
3061 protected function fun_109
3062 input Tpl.Text in_txt;
3063 input DAE.ComponentRef in_a_cr;
3064 input Tpl.Text in_a_preExp;
3065 input DAE.Type in_a_aty;
3066 input DAE.Dimensions in_a_dims;
3067 input SimCodeFunction.Context in_a_context;
3068
3069 output Tpl.Text out_txt;
3070 output Tpl.Text out_a_preExp;
3071 algorithm
3072 (out_txt, out_a_preExp) :=
3073 match(in_txt, in_a_cr, in_a_preExp, in_a_aty, in_a_dims, in_a_context)
3074 local
3075 Tpl.Text txt;
3076 Tpl.Text a_preExp;
3077 DAE.Type a_aty;
3078 DAE.Dimensions a_dims;
3079 SimCodeFunction.Context a_context;
3080 DAE.ComponentRef i_componentRef;
3081 Tpl.Text l_T;
3082 Tpl.Text l_dimstr;
3083 Integer ret_2;
3084 Tpl.Text l_ndims;
3085 Tpl.Text l_arr;
3086
3087 case ( txt,
3088 DAE.CREF_QUAL(ident = "$PRE", componentRef = i_componentRef),
3089 a_preExp,
3090 a_aty,
3091 a_dims,
3092 a_context )
3093 algorithm
3094 2 l_arr := arrayCrefCStr(Tpl.emptyTxt, i_componentRef, a_context);
3095 2 ret_2 := listLength(a_dims);
3096 2 l_ndims := Tpl.writeStr(Tpl.emptyTxt, intString(ret_2));
3097 2 l_dimstr := checkDimension(Tpl.emptyTxt, a_dims);
3098 2 l_T := expTypeShort(Tpl.emptyTxt, a_aty);
3099 2 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("StatArrayDim"));
3100 2 a_preExp := Tpl.writeText(a_preExp, l_ndims);
3101 2 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("<"));
3102 2 a_preExp := Tpl.writeText(a_preExp, l_T);
3103 2 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
3104 2 a_preExp := Tpl.writeText(a_preExp, l_dimstr);
3105 2 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("> "));
3106 2 a_preExp := Tpl.writeText(a_preExp, l_arr);
3107 2 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING_LIST({
3108 "_pre;\n",
3109 "std::transform("
3110 }, false));
3111 2 a_preExp := Tpl.writeText(a_preExp, l_arr);
3112 2 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_LINE(".getData(),\n"));
3113 2 a_preExp := Tpl.pushBlock(a_preExp, Tpl.BT_INDENT(15));
3114 2 a_preExp := Tpl.writeText(a_preExp, l_arr);
3115 2 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(".getData() + "));
3116 2 a_preExp := Tpl.writeText(a_preExp, l_arr);
3117 2 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_LINE(".getNumElems(),\n"));
3118 2 a_preExp := Tpl.writeText(a_preExp, l_arr);
3119 2 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING_LIST({
3120 "_pre.getData(),\n",
3121 "PreArray2CArray<"
3122 }, false));
3123 2 a_preExp := Tpl.writeText(a_preExp, l_T);
3124 2 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(">(_discrete_events));"));
3125 2 a_preExp := Tpl.popBlock(a_preExp);
3126 2 txt := Tpl.writeText(txt, l_arr);
3127 2 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_pre"));
3128 then (txt, a_preExp);
3129
3130 case ( txt,
3131 _,
3132 a_preExp,
3133 _,
3134 _,
3135 _ )
3136 then (txt, a_preExp);
3137 end match;
3138 end fun_109;
3139
3140 protected function fun_110
3141 input Tpl.Text in_txt;
3142 input DAE.Type in_a_ty;
3143 input Tpl.Text in_a_preExp;
3144 input SimCodeFunction.Context in_a_context;
3145 input DAE.ComponentRef in_a_cr;
3146
3147 output Tpl.Text out_txt;
3148 output Tpl.Text out_a_preExp;
3149 algorithm
3150 (out_txt, out_a_preExp) :=
3151 match(in_txt, in_a_ty, in_a_preExp, in_a_context, in_a_cr)
3152 local
3153 Tpl.Text txt;
3154 Tpl.Text a_preExp;
3155 SimCodeFunction.Context a_context;
3156 DAE.ComponentRef a_cr;
3157 DAE.Type i_aty;
3158 DAE.Dimensions i_dims;
3159
3160 case ( txt,
3161 DAE.T_ARRAY(ty = i_aty, dims = i_dims),
3162 a_preExp,
3163 a_context,
3164 a_cr )
3165 algorithm
3166 250 (txt, a_preExp) := fun_109(txt, a_cr, a_preExp, i_aty, i_dims, a_context);
3167 then (txt, a_preExp);
3168
3169 case ( txt,
3170 _,
3171 a_preExp,
3172 _,
3173 _ )
3174 25973 then (txt, a_preExp);
3175 end match;
3176 end fun_110;
3177
3178 protected function fun_111
3179 input Tpl.Text in_txt;
3180 input BackendDAE.VarKind in_a_varKind;
3181 input Tpl.Text in_a_preExp;
3182 input DAE.Type in_a_ty;
3183 input Boolean in_a_useFlatArrayNotation;
3184 input Tpl.Text in_a_stateDerVectorName;
3185 input Tpl.Text in_a_varDecls;
3186 input SimCodeFunction.Context in_a_context;
3187 input Tpl.Text in_a_extraFuncsNamespace;
3188 input Tpl.Text in_a_extraFuncsDecl;
3189 input Tpl.Text in_a_extraFuncs;
3190 input SimCode.SimCode in_a_simCode;
3191 input DAE.ComponentRef in_a_cr;
3192
3193 output Tpl.Text out_txt;
3194 output Tpl.Text out_a_preExp;
3195 output Tpl.Text out_a_stateDerVectorName;
3196 output Tpl.Text out_a_varDecls;
3197 output Tpl.Text out_a_extraFuncsNamespace;
3198 output Tpl.Text out_a_extraFuncsDecl;
3199 output Tpl.Text out_a_extraFuncs;
3200 algorithm
3201 (out_txt, out_a_preExp, out_a_stateDerVectorName, out_a_varDecls, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs) :=
3202 match(in_txt, in_a_varKind, in_a_preExp, in_a_ty, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_varDecls, in_a_context, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_cr)
3203 local
3204 Tpl.Text txt;
3205 Tpl.Text a_preExp;
3206 DAE.Type a_ty;
3207 Boolean a_useFlatArrayNotation;
3208 Tpl.Text a_stateDerVectorName;
3209 Tpl.Text a_varDecls;
3210 SimCodeFunction.Context a_context;
3211 Tpl.Text a_extraFuncsNamespace;
3212 Tpl.Text a_extraFuncsDecl;
3213 Tpl.Text a_extraFuncs;
3214 SimCode.SimCode a_simCode;
3215 DAE.ComponentRef a_cr;
3216 Tpl.Text l_arrdata;
3217
3218 case ( txt,
3219 BackendDAE.DAE_RESIDUAL_VAR(),
3220 a_preExp,
3221 a_ty,
3222 a_useFlatArrayNotation,
3223 a_stateDerVectorName,
3224 a_varDecls,
3225 a_context,
3226 a_extraFuncsNamespace,
3227 a_extraFuncsDecl,
3228 a_extraFuncs,
3229 a_simCode,
3230 a_cr )
3231 algorithm
3232 ✗ (l_arrdata, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_varDecls, a_stateDerVectorName) := representationCref(Tpl.emptyTxt, a_cr, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_context, a_varDecls, a_stateDerVectorName, a_useFlatArrayNotation);
3233 ✗ (txt, l_arrdata, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := daeExpCrefRhsArrayBox2(txt, l_arrdata, a_ty, false, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace);
3234 ✗ then (txt, a_preExp, a_stateDerVectorName, a_varDecls, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs);
3235
3236 case ( txt,
3237 BackendDAE.JAC_VAR(),
3238 a_preExp,
3239 a_ty,
3240 a_useFlatArrayNotation,
3241 a_stateDerVectorName,
3242 a_varDecls,
3243 a_context,
3244 a_extraFuncsNamespace,
3245 a_extraFuncsDecl,
3246 a_extraFuncs,
3247 a_simCode,
3248 a_cr )
3249 algorithm
3250 20 (l_arrdata, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_varDecls, a_stateDerVectorName) := representationCref(Tpl.emptyTxt, a_cr, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_context, a_varDecls, a_stateDerVectorName, a_useFlatArrayNotation);
3251 20 (txt, l_arrdata, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := daeExpCrefRhsArrayBox2(txt, l_arrdata, a_ty, true, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace);
3252 20 then (txt, a_preExp, a_stateDerVectorName, a_varDecls, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs);
3253
3254 case ( txt,
3255 BackendDAE.JAC_TMP_VAR(),
3256 a_preExp,
3257 a_ty,
3258 a_useFlatArrayNotation,
3259 a_stateDerVectorName,
3260 a_varDecls,
3261 a_context,
3262 a_extraFuncsNamespace,
3263 a_extraFuncsDecl,
3264 a_extraFuncs,
3265 a_simCode,
3266 a_cr )
3267 algorithm
3268 880 (l_arrdata, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_varDecls, a_stateDerVectorName) := representationCref(Tpl.emptyTxt, a_cr, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_context, a_varDecls, a_stateDerVectorName, a_useFlatArrayNotation);
3269 880 (txt, l_arrdata, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := daeExpCrefRhsArrayBox2(txt, l_arrdata, a_ty, true, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace);
3270 880 then (txt, a_preExp, a_stateDerVectorName, a_varDecls, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs);
3271
3272 case ( txt,
3273 BackendDAE.SEED_VAR(),
3274 a_preExp,
3275 a_ty,
3276 a_useFlatArrayNotation,
3277 a_stateDerVectorName,
3278 a_varDecls,
3279 a_context,
3280 a_extraFuncsNamespace,
3281 a_extraFuncsDecl,
3282 a_extraFuncs,
3283 a_simCode,
3284 a_cr )
3285 algorithm
3286 573 (l_arrdata, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_varDecls, a_stateDerVectorName) := representationCref(Tpl.emptyTxt, a_cr, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_context, a_varDecls, a_stateDerVectorName, a_useFlatArrayNotation);
3287 573 (txt, l_arrdata, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace) := daeExpCrefRhsArrayBox2(txt, l_arrdata, a_ty, true, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace);
3288 573 then (txt, a_preExp, a_stateDerVectorName, a_varDecls, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs);
3289
3290 case ( txt,
3291 _,
3292 a_preExp,
3293 a_ty,
3294 _,
3295 a_stateDerVectorName,
3296 a_varDecls,
3297 a_context,
3298 a_extraFuncsNamespace,
3299 a_extraFuncsDecl,
3300 a_extraFuncs,
3301 _,
3302 a_cr )
3303 algorithm
3304 26223 (txt, a_preExp) := fun_110(txt, a_ty, a_preExp, a_context, a_cr);
3305 26223 then (txt, a_preExp, a_stateDerVectorName, a_varDecls, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs);
3306 end match;
3307 end fun_111;
3308
3309 protected function smf_112
3310 input Tpl.Text in_txt;
3311 input SimCodeVar.SimVar in_it;
3312 input Tpl.Text in_a_preExp;
3313 input DAE.Type in_a_ty;
3314 input Boolean in_a_useFlatArrayNotation;
3315 input Tpl.Text in_a_stateDerVectorName;
3316 input Tpl.Text in_a_varDecls;
3317 input SimCodeFunction.Context in_a_context;
3318 input Tpl.Text in_a_extraFuncsNamespace;
3319 input Tpl.Text in_a_extraFuncsDecl;
3320 input Tpl.Text in_a_extraFuncs;
3321 input SimCode.SimCode in_a_simCode;
3322 input DAE.ComponentRef in_a_cr;
3323
3324 output Tpl.Text out_txt;
3325 output Tpl.Text out_a_preExp;
3326 output Tpl.Text out_a_stateDerVectorName;
3327 output Tpl.Text out_a_varDecls;
3328 output Tpl.Text out_a_extraFuncsNamespace;
3329 output Tpl.Text out_a_extraFuncsDecl;
3330 output Tpl.Text out_a_extraFuncs;
3331 algorithm
3332 (out_txt, out_a_preExp, out_a_stateDerVectorName, out_a_varDecls, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs) :=
3333 match(in_txt, in_it, in_a_preExp, in_a_ty, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_varDecls, in_a_context, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_cr)
3334 local
3335 Tpl.Text txt;
3336 Tpl.Text a_preExp;
3337 DAE.Type a_ty;
3338 Boolean a_useFlatArrayNotation;
3339 Tpl.Text a_stateDerVectorName;
3340 Tpl.Text a_varDecls;
3341 SimCodeFunction.Context a_context;
3342 Tpl.Text a_extraFuncsNamespace;
3343 Tpl.Text a_extraFuncsDecl;
3344 Tpl.Text a_extraFuncs;
3345 SimCode.SimCode a_simCode;
3346 DAE.ComponentRef a_cr;
3347 BackendDAE.VarKind i_varKind;
3348
3349 case ( txt,
3350 SimCodeVar.SIMVAR(index = _, matrixName = _, varKind = i_varKind),
3351 a_preExp,
3352 a_ty,
3353 a_useFlatArrayNotation,
3354 a_stateDerVectorName,
3355 a_varDecls,
3356 a_context,
3357 a_extraFuncsNamespace,
3358 a_extraFuncsDecl,
3359 a_extraFuncs,
3360 a_simCode,
3361 a_cr )
3362 algorithm
3363 27696 (txt, a_preExp, a_stateDerVectorName, a_varDecls, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs) := fun_111(txt, i_varKind, a_preExp, a_ty, a_useFlatArrayNotation, a_stateDerVectorName, a_varDecls, a_context, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_cr);
3364 then (txt, a_preExp, a_stateDerVectorName, a_varDecls, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs);
3365
3366 case ( txt,
3367 _,
3368 a_preExp,
3369 _,
3370 _,
3371 a_stateDerVectorName,
3372 a_varDecls,
3373 _,
3374 a_extraFuncsNamespace,
3375 a_extraFuncsDecl,
3376 a_extraFuncs,
3377 _,
3378 _ )
3379 ✗ then (txt, a_preExp, a_stateDerVectorName, a_varDecls, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs);
3380 end match;
3381 end smf_112;
3382
3383 protected function fun_113
3384 input Tpl.Text in_txt;
3385 input SimCodeFunction.Context in_a_context;
3386 input DAE.ComponentRef in_a_cr;
3387 input DAE.Type in_a_ty;
3388 input Tpl.Text in_a_preExp;
3389 input Tpl.Text in_a_varDecls;
3390 input SimCode.SimCode in_a_simCode;
3391 input Tpl.Text in_a_extraFuncs;
3392 input Tpl.Text in_a_extraFuncsDecl;
3393 input Tpl.Text in_a_extraFuncsNamespace;
3394 input Tpl.Text in_a_stateDerVectorName;
3395 input Boolean in_a_useFlatArrayNotation;
3396
3397 output Tpl.Text out_txt;
3398 output Tpl.Text out_a_preExp;
3399 output Tpl.Text out_a_varDecls;
3400 output Tpl.Text out_a_extraFuncs;
3401 output Tpl.Text out_a_extraFuncsDecl;
3402 output Tpl.Text out_a_extraFuncsNamespace;
3403 output Tpl.Text out_a_stateDerVectorName;
3404 algorithm
3405 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
3406 match(in_txt, in_a_context, in_a_cr, in_a_ty, in_a_preExp, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
3407 local
3408 Tpl.Text txt;
3409 DAE.ComponentRef a_cr;
3410 DAE.Type a_ty;
3411 Tpl.Text a_preExp;
3412 Tpl.Text a_varDecls;
3413 SimCode.SimCode a_simCode;
3414 Tpl.Text a_extraFuncs;
3415 Tpl.Text a_extraFuncsDecl;
3416 Tpl.Text a_extraFuncsNamespace;
3417 Tpl.Text a_stateDerVectorName;
3418 Boolean a_useFlatArrayNotation;
3419 SimCodeFunction.Context i_context;
3420 SimCodeVar.SimVar ret_1;
3421 Tpl.Text l_box;
3422
3423 case ( txt,
3424 SimCodeFunction.FUNCTION_CONTEXT(cref_prefix = _),
3425 _,
3426 _,
3427 a_preExp,
3428 a_varDecls,
3429 _,
3430 a_extraFuncs,
3431 a_extraFuncsDecl,
3432 a_extraFuncsNamespace,
3433 a_stateDerVectorName,
3434 _ )
3435 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
3436
3437 case ( txt,
3438 i_context,
3439 a_cr,
3440 a_ty,
3441 a_preExp,
3442 a_varDecls,
3443 a_simCode,
3444 a_extraFuncs,
3445 a_extraFuncsDecl,
3446 a_extraFuncsNamespace,
3447 a_stateDerVectorName,
3448 a_useFlatArrayNotation )
3449 algorithm
3450 27696 ret_1 := SimCodeCodegenUtil.cref2simvar(a_cr, a_simCode);
3451 27696 (l_box, a_preExp, a_stateDerVectorName, a_varDecls, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs) := smf_112(Tpl.emptyTxt, ret_1, a_preExp, a_ty, a_useFlatArrayNotation, a_stateDerVectorName, a_varDecls, i_context, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_cr);
3452 27696 txt := Tpl.writeText(txt, l_box);
3453 27696 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
3454 end match;
3455 end fun_113;
3456
3457 public function daeExpCrefRhsArrayBox
3458 input Tpl.Text txt;
3459 input DAE.ComponentRef a_cr;
3460 input DAE.Type a_ty;
3461 input SimCodeFunction.Context a_context;
3462 input Tpl.Text a_preExp;
3463 input Tpl.Text a_varDecls;
3464 input SimCode.SimCode a_simCode;
3465 input Tpl.Text a_extraFuncs;
3466 input Tpl.Text a_extraFuncsDecl;
3467 input Tpl.Text a_extraFuncsNamespace;
3468 input Tpl.Text a_stateDerVectorName;
3469 input Boolean a_useFlatArrayNotation;
3470
3471 output Tpl.Text out_txt;
3472 output Tpl.Text out_a_preExp;
3473 output Tpl.Text out_a_varDecls;
3474 output Tpl.Text out_a_extraFuncs;
3475 output Tpl.Text out_a_extraFuncsDecl;
3476 output Tpl.Text out_a_extraFuncsNamespace;
3477 output Tpl.Text out_a_stateDerVectorName;
3478 algorithm
3479 57891 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) := fun_113(txt, a_context, a_cr, a_ty, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
3480 end daeExpCrefRhsArrayBox;
3481
3482 protected function fun_115
3483 input Tpl.Text in_txt;
3484 input String in_mArg;
3485 input Tpl.Text in_a_dimstr;
3486 input DAE.Type in_a_ty;
3487 input DAE.Dimensions in_a_dims;
3488
3489 output Tpl.Text out_txt;
3490 algorithm
3491 out_txt :=
3492 match(in_txt, in_mArg, in_a_dimstr, in_a_ty, in_a_dims)
3493 local
3494 Tpl.Text txt;
3495 Tpl.Text a_dimstr;
3496 DAE.Type a_ty;
3497 DAE.Dimensions a_dims;
3498 Integer ret_1;
3499 Integer ret_0;
3500
3501 case ( txt,
3502 "",
3503 _,
3504 a_ty,
3505 a_dims )
3506 algorithm
3507 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("DynArrayDim"));
3508 ✗ ret_0 := listLength(a_dims);
3509 ✗ txt := Tpl.writeStr(txt, intString(ret_0));
3510 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<"));
3511 ✗ txt := expTypeShort(txt, a_ty);
3512 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(">"));
3513 then txt;
3514
3515 case ( txt,
3516 _,
3517 a_dimstr,
3518 a_ty,
3519 a_dims )
3520 algorithm
3521 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("StatArrayDim"));
3522 ✗ ret_1 := listLength(a_dims);
3523 ✗ txt := Tpl.writeStr(txt, intString(ret_1));
3524 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<"));
3525 ✗ txt := expTypeShort(txt, a_ty);
3526 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(","));
3527 ✗ txt := Tpl.writeText(txt, a_dimstr);
3528 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(">"));
3529 then txt;
3530 end match;
3531 end fun_115;
3532
3533 protected function fun_116
3534 input Tpl.Text in_txt;
3535 input Boolean in_a_isRowMajorData;
3536 input Tpl.Text in_a_arrayData;
3537 input Tpl.Text in_a_arrayVar;
3538
3539 output Tpl.Text out_txt;
3540 algorithm
3541 out_txt :=
3542 match(in_txt, in_a_isRowMajorData, in_a_arrayData, in_a_arrayVar)
3543 local
3544 Tpl.Text txt;
3545 Tpl.Text a_arrayData;
3546 Tpl.Text a_arrayVar;
3547
3548 case ( txt,
3549 false,
3550 a_arrayData,
3551 a_arrayVar )
3552 algorithm
3553 ✗ txt := Tpl.writeText(txt, a_arrayVar);
3554 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".assign(&"));
3555 ✗ txt := Tpl.writeText(txt, a_arrayData);
3556 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
3557 then txt;
3558
3559 case ( txt,
3560 _,
3561 a_arrayData,
3562 a_arrayVar )
3563 algorithm
3564 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("assignRowMajorData(&"));
3565 ✗ txt := Tpl.writeText(txt, a_arrayData);
3566 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
3567 ✗ txt := Tpl.writeText(txt, a_arrayVar);
3568 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
3569 then txt;
3570 end match;
3571 end fun_116;
3572
3573 protected function fun_117
3574 input Tpl.Text in_txt;
3575 input DAE.Type in_a_ty;
3576 input Tpl.Text in_a_arrayData;
3577 input Boolean in_a_isRowMajorData;
3578 input Tpl.Text in_a_preExp;
3579
3580 output Tpl.Text out_txt;
3581 output Tpl.Text out_a_preExp;
3582 algorithm
3583 (out_txt, out_a_preExp) :=
3584 match(in_txt, in_a_ty, in_a_arrayData, in_a_isRowMajorData, in_a_preExp)
3585 local
3586 Tpl.Text txt;
3587 Tpl.Text a_arrayData;
3588 Boolean a_isRowMajorData;
3589 Tpl.Text a_preExp;
3590 DAE.Type i_t;
3591 DAE.Dimensions i_dims;
3592 Tpl.Text l_arrayAssign;
3593 Tpl.Text l_arrayVar;
3594 Tpl.Text l_tmpdecl;
3595 String str_2;
3596 Tpl.Text l_arrayType;
3597 Tpl.Text l_dimstr;
3598
3599 case ( txt,
3600 (i_t as DAE.T_ARRAY(ty = _, dims = i_dims)),
3601 a_arrayData,
3602 a_isRowMajorData,
3603 a_preExp )
3604 algorithm
3605 ✗ l_dimstr := checkDimension(Tpl.emptyTxt, i_dims);
3606 ✗ str_2 := Tpl.textString(l_dimstr);
3607 ✗ l_arrayType := fun_115(Tpl.emptyTxt, str_2, l_dimstr, i_t, i_dims);
3608 ✗ l_tmpdecl := Tpl.emptyTxt;
3609 ✗ (l_arrayVar, l_tmpdecl) := tempDecl(Tpl.emptyTxt, Tpl.textString(l_arrayType), l_tmpdecl);
3610 ✗ l_arrayAssign := fun_116(Tpl.emptyTxt, a_isRowMajorData, a_arrayData, l_arrayVar);
3611 ✗ a_preExp := Tpl.writeText(a_preExp, l_arrayType);
3612 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(" "));
3613 ✗ a_preExp := Tpl.writeText(a_preExp, l_arrayVar);
3614 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_LINE(";\n"));
3615 ✗ a_preExp := Tpl.writeText(a_preExp, l_arrayAssign);
3616 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(";"));
3617 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
3618 ✗ txt := Tpl.writeText(txt, l_arrayVar);
3619 then (txt, a_preExp);
3620
3621 case ( txt,
3622 _,
3623 a_arrayData,
3624 _,
3625 a_preExp )
3626 algorithm
3627 1473 txt := Tpl.writeText(txt, a_arrayData);
3628 then (txt, a_preExp);
3629 end match;
3630 end fun_117;
3631
3632 public function daeExpCrefRhsArrayBox2
3633 input Tpl.Text txt;
3634 input Tpl.Text a_arrayData;
3635 input DAE.Type a_ty;
3636 input Boolean a_isRowMajorData;
3637 input SimCodeFunction.Context a_context;
3638 input Tpl.Text a_preExp;
3639 input Tpl.Text a_varDecls;
3640 input SimCode.SimCode a_simCode;
3641 input Tpl.Text a_extraFuncs;
3642 input Tpl.Text a_extraFuncsDecl;
3643 input Tpl.Text a_extraFuncsNamespace;
3644
3645 output Tpl.Text out_txt;
3646 output Tpl.Text out_a_arrayData;
3647 output Tpl.Text out_a_preExp;
3648 output Tpl.Text out_a_varDecls;
3649 output Tpl.Text out_a_extraFuncs;
3650 output Tpl.Text out_a_extraFuncsDecl;
3651 output Tpl.Text out_a_extraFuncsNamespace;
3652 algorithm
3653 1473 (out_txt, out_a_preExp) := fun_117(txt, a_ty, a_arrayData, a_isRowMajorData, a_preExp);
3654 out_a_arrayData := a_arrayData;
3655 out_a_varDecls := a_varDecls;
3656 out_a_extraFuncs := a_extraFuncs;
3657 out_a_extraFuncsDecl := a_extraFuncsDecl;
3658 out_a_extraFuncsNamespace := a_extraFuncsNamespace;
3659 end daeExpCrefRhsArrayBox2;
3660
3661 protected function lm_119
3662 input output Tpl.Text txt;
3663 input list<DAE.Var> items;
3664 input Boolean a_useFlatArrayNotation;
3665 input output Tpl.Text a_stateDerVectorName;
3666 input output Tpl.Text a_extraFuncsNamespace;
3667 input output Tpl.Text a_extraFuncsDecl;
3668 input output Tpl.Text a_extraFuncs;
3669 input SimCode.SimCode a_simCode;
3670 input output Tpl.Text a_varDecls;
3671 input output Tpl.Text a_preExp;
3672 input SimCodeFunction.Context a_context;
3673 input DAE.ComponentRef a_cr;
3674 algorithm
3675
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 3 times.
51 for lstElt_119 in items loop
3676 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_119
3677 local
3678 DAE.Var i_v;
3679 DAE.Exp ret_0;
3680
3681 case i_v
3682 algorithm
3683 48 ret_0 := SimCodeFunctionUtil.makeCrefRecordExp(a_cr, i_v);
3684 48 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, ret_0, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
3685 48 txt := Tpl.nextIter(txt);
3686 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
3687 end match;
3688 end for;
3689 end lm_119;
3690
3691 public function daeExpRecordCrefRhs
3692 input Tpl.Text in_txt;
3693 input DAE.Type in_a_ty;
3694 input DAE.ComponentRef in_a_cr;
3695 input SimCodeFunction.Context in_a_context;
3696 input Tpl.Text in_a_preExp;
3697 input Tpl.Text in_a_varDecls;
3698 input SimCode.SimCode in_a_simCode;
3699 input Tpl.Text in_a_extraFuncs;
3700 input Tpl.Text in_a_extraFuncsDecl;
3701 input Tpl.Text in_a_extraFuncsNamespace;
3702 input Tpl.Text in_a_stateDerVectorName;
3703 input Boolean in_a_useFlatArrayNotation;
3704
3705 output Tpl.Text out_txt;
3706 output Tpl.Text out_a_preExp;
3707 output Tpl.Text out_a_varDecls;
3708 output Tpl.Text out_a_extraFuncs;
3709 output Tpl.Text out_a_extraFuncsDecl;
3710 output Tpl.Text out_a_extraFuncsNamespace;
3711 output Tpl.Text out_a_stateDerVectorName;
3712 algorithm
3713 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
3714 match(in_txt, in_a_ty, in_a_cr, in_a_context, in_a_preExp, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
3715 local
3716 Tpl.Text txt;
3717 DAE.ComponentRef a_cr;
3718 SimCodeFunction.Context a_context;
3719 Tpl.Text a_preExp;
3720 Tpl.Text a_varDecls;
3721 SimCode.SimCode a_simCode;
3722 Tpl.Text a_extraFuncs;
3723 Tpl.Text a_extraFuncsDecl;
3724 Tpl.Text a_extraFuncsNamespace;
3725 Tpl.Text a_stateDerVectorName;
3726 Boolean a_useFlatArrayNotation;
3727 ClassInf.State i_record__state;
3728 list<DAE.Var> i_var__lst;
3729 Tpl.Text l_ret__var;
3730 Tpl.Text l_ret__type;
3731 Absyn.Path ret_2;
3732 Tpl.Text l_record__type__name;
3733 Tpl.Text l_vars;
3734
3735 case ( txt,
3736 DAE.T_COMPLEX(complexClassType = i_record__state, varLst = i_var__lst),
3737 a_cr,
3738 a_context,
3739 a_preExp,
3740 a_varDecls,
3741 a_simCode,
3742 a_extraFuncs,
3743 a_extraFuncsDecl,
3744 a_extraFuncsNamespace,
3745 a_stateDerVectorName,
3746 a_useFlatArrayNotation )
3747 algorithm
3748 3 l_vars := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
3749 3 (l_vars, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_119(l_vars, i_var__lst, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context, a_cr);
3750 3 l_vars := Tpl.popIter(l_vars);
3751 3 ret_2 := ClassInfUtil.getStateName(i_record__state);
3752 3 l_record__type__name := CodegenUtil.underscorePath(Tpl.emptyTxt, ret_2);
3753 3 l_ret__type := Tpl.writeText(Tpl.emptyTxt, l_record__type__name);
3754 3 l_ret__type := Tpl.writeTok(l_ret__type, Tpl.ST_STRING("RetType"));
3755 3 (l_ret__var, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(l_ret__type), a_varDecls);
3756 3 a_preExp := contextFunName(a_preExp, Tpl.textString(l_record__type__name), a_context);
3757 3 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("("));
3758 3 a_preExp := Tpl.writeText(a_preExp, l_vars);
3759 3 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(","));
3760 3 a_preExp := Tpl.writeText(a_preExp, l_ret__var);
3761 3 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
3762 3 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
3763 3 txt := Tpl.writeText(txt, l_ret__var);
3764 3 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
3765
3766 case ( txt,
3767 _,
3768 _,
3769 _,
3770 a_preExp,
3771 a_varDecls,
3772 _,
3773 a_extraFuncs,
3774 a_extraFuncsDecl,
3775 a_extraFuncsNamespace,
3776 a_stateDerVectorName,
3777 _ )
3778 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
3779 end match;
3780 end daeExpRecordCrefRhs;
3781
3782 public function crefST
3783 input Tpl.Text in_txt;
3784 input DAE.ComponentRef in_a_cr;
3785 input Boolean in_a_useFlatArrayNotation;
3786
3787 output Tpl.Text out_txt;
3788 algorithm
3789 out_txt :=
3790 match(in_txt, in_a_cr, in_a_useFlatArrayNotation)
3791 local
3792 Tpl.Text txt;
3793 Boolean a_useFlatArrayNotation;
3794 DAE.ComponentRef i_cr;
3795
3796 case ( txt,
3797 DAE.CREF_IDENT(ident = "time"),
3798 _ )
3799 algorithm
3800 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_simTime"));
3801 then txt;
3802
3803 case ( txt,
3804 DAE.WILD(),
3805 _ )
3806 then txt;
3807
3808 case ( txt,
3809 i_cr,
3810 a_useFlatArrayNotation )
3811 algorithm
3812 ✗ txt := crefToCStr(txt, i_cr, a_useFlatArrayNotation);
3813 then txt;
3814 end match;
3815 end crefST;
3816
3817 protected function fun_122
3818 input Tpl.Text in_txt;
3819 input SimCodeFunction.Context in_a_context;
3820 input DAE.ComponentRef in_a_cr;
3821
3822 output Tpl.Text out_txt;
3823 algorithm
3824 out_txt :=
3825 match(in_txt, in_a_context, in_a_cr)
3826 local
3827 Tpl.Text txt;
3828 DAE.ComponentRef a_cr;
3829 SimCodeFunction.Context i_context;
3830
3831 case ( txt,
3832 SimCodeFunction.FUNCTION_CONTEXT(cref_prefix = _),
3833 a_cr )
3834 algorithm
3835 14 txt := arrayCrefStr(txt, a_cr);
3836 then txt;
3837
3838 case ( txt,
3839 i_context,
3840 a_cr )
3841 algorithm
3842 14 txt := arrayCrefCStr(txt, a_cr, i_context);
3843 then txt;
3844 end match;
3845 end fun_122;
3846
3847 public function contextArrayCref
3848 input Tpl.Text in_txt;
3849 input DAE.ComponentRef in_a_cr;
3850 input SimCodeFunction.Context in_a_context;
3851
3852 output Tpl.Text out_txt;
3853 algorithm
3854 out_txt :=
3855 match(in_txt, in_a_cr, in_a_context)
3856 local
3857 Tpl.Text txt;
3858 SimCodeFunction.Context a_context;
3859 DAE.ComponentRef i_cr;
3860 DAE.ComponentRef i_componentRef;
3861
3862 case ( txt,
3863 DAE.CREF_QUAL(ident = "$START", componentRef = i_componentRef),
3864 a_context )
3865 algorithm
3866 ✗ txt := contextArrayCref(txt, i_componentRef, a_context);
3867 then txt;
3868
3869 case ( txt,
3870 i_cr,
3871 a_context )
3872 algorithm
3873 28 txt := fun_122(txt, a_context, i_cr);
3874 then txt;
3875 end match;
3876 end contextArrayCref;
3877
3878 public function arrayCrefStr
3879 input Tpl.Text in_txt;
3880 input DAE.ComponentRef in_a_cr;
3881
3882 output Tpl.Text out_txt;
3883 algorithm
3884 out_txt :=
3885 match(in_txt, in_a_cr)
3886 local
3887 Tpl.Text txt;
3888 DAE.ComponentRef i_componentRef;
3889 DAE.Ident i_ident;
3890 String ret_1;
3891 String ret_0;
3892
3893 case ( txt,
3894 DAE.CREF_IDENT(ident = "time") )
3895 algorithm
3896 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_simTime"));
3897 then txt;
3898
3899 case ( txt,
3900 DAE.CREF_IDENT(ident = i_ident) )
3901 algorithm
3902 14 ret_0 := System.unquoteIdentifier(i_ident);
3903 14 txt := Tpl.writeStr(txt, ret_0);
3904 14 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
3905 then txt;
3906
3907 case ( txt,
3908 DAE.CREF_QUAL(ident = i_ident, componentRef = i_componentRef) )
3909 algorithm
3910 1 ret_1 := System.unquoteIdentifier(i_ident);
3911 1 txt := Tpl.writeStr(txt, ret_1);
3912 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_."));
3913 1 txt := arrayCrefStr(txt, i_componentRef);
3914 then txt;
3915
3916 case ( txt,
3917 _ )
3918 algorithm
3919 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("CREF_NOT_IDENT_OR_QUAL"));
3920 then txt;
3921 end match;
3922 end arrayCrefStr;
3923
3924 protected function fun_125
3925 input Tpl.Text in_txt;
3926 input SimCodeFunction.Context in_a_context;
3927 input DAE.ComponentRef in_a_cr;
3928
3929 output Tpl.Text out_txt;
3930 algorithm
3931 out_txt :=
3932 match(in_txt, in_a_context, in_a_cr)
3933 local
3934 Tpl.Text txt;
3935 DAE.ComponentRef a_cr;
3936 Tpl.Text l_dims;
3937
3938 case ( txt,
3939 SimCodeFunction.ALGLOOP_CONTEXT(genInitialisation = false),
3940 a_cr )
3941 algorithm
3942 ✗ l_dims := Tpl.emptyTxt;
3943 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(1));
3944 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_system->_"));
3945 ✗ (txt, l_dims) := crefToCStrForArray(txt, a_cr, l_dims);
3946 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
3947 ✗ txt := Tpl.popBlock(txt);
3948 then txt;
3949
3950 case ( txt,
3951 _,
3952 a_cr )
3953 algorithm
3954 16 l_dims := Tpl.emptyTxt;
3955 16 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
3956 16 (txt, l_dims) := crefToCStrForArray(txt, a_cr, l_dims);
3957 then txt;
3958 end match;
3959 end fun_125;
3960
3961 public function arrayCrefCStr
3962 input Tpl.Text txt;
3963 input DAE.ComponentRef a_cr;
3964 input SimCodeFunction.Context a_context;
3965
3966 output Tpl.Text out_txt;
3967 algorithm
3968 16 out_txt := fun_125(txt, a_context, a_cr);
3969 end arrayCrefCStr;
3970
3971 public function arrayCrefCStr2
3972 input Tpl.Text in_txt;
3973 input DAE.ComponentRef in_a_cr;
3974
3975 output Tpl.Text out_txt;
3976 algorithm
3977 out_txt :=
3978 match(in_txt, in_a_cr)
3979 local
3980 Tpl.Text txt;
3981 DAE.ComponentRef i_componentRef;
3982 DAE.Ident i_ident;
3983 String ret_1;
3984 String ret_0;
3985
3986 case ( txt,
3987 DAE.CREF_IDENT(ident = i_ident) )
3988 algorithm
3989 ✗ ret_0 := System.unquoteIdentifier(i_ident);
3990 ✗ txt := Tpl.writeStr(txt, ret_0);
3991 then txt;
3992
3993 case ( txt,
3994 DAE.CREF_QUAL(ident = i_ident, componentRef = i_componentRef) )
3995 algorithm
3996 ✗ ret_1 := System.unquoteIdentifier(i_ident);
3997 ✗ txt := Tpl.writeStr(txt, ret_1);
3998 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_P_"));
3999 ✗ txt := arrayCrefCStr2(txt, i_componentRef);
4000 then txt;
4001
4002 case ( txt,
4003 _ )
4004 algorithm
4005 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("CREF_NOT_IDENT_OR_QUAL"));
4006 then txt;
4007 end match;
4008 end arrayCrefCStr2;
4009
4010 public function crefTypeST
4011 input Tpl.Text in_txt;
4012 input DAE.ComponentRef in_a_cr;
4013
4014 output Tpl.Text out_txt;
4015 algorithm
4016 out_txt :=
4017 match(in_txt, in_a_cr)
4018 local
4019 Tpl.Text txt;
4020 DAE.ComponentRef i_componentRef;
4021 DAE.Type i_identType;
4022
4023 case ( txt,
4024 DAE.CREF_IDENT(identType = i_identType) )
4025 algorithm
4026 ✗ txt := expTypeShortSPS(txt, i_identType);
4027 then txt;
4028
4029 case ( txt,
4030 DAE.CREF_QUAL(componentRef = i_componentRef) )
4031 algorithm
4032 ✗ txt := crefTypeST(txt, i_componentRef);
4033 then txt;
4034
4035 case ( txt,
4036 _ )
4037 algorithm
4038 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("crefType:ERROR"));
4039 then txt;
4040 end match;
4041 end crefTypeST;
4042
4043 public function crefTypeMLPI
4044 input Tpl.Text in_txt;
4045 input DAE.ComponentRef in_a_cr;
4046
4047 output Tpl.Text out_txt;
4048 algorithm
4049 out_txt :=
4050 match(in_txt, in_a_cr)
4051 local
4052 Tpl.Text txt;
4053 DAE.ComponentRef i_componentRef;
4054 DAE.Type i_identType;
4055
4056 case ( txt,
4057 DAE.CREF_IDENT(identType = i_identType) )
4058 algorithm
4059 ✗ txt := expTypeShortMLPI(txt, i_identType);
4060 then txt;
4061
4062 case ( txt,
4063 DAE.CREF_QUAL(componentRef = i_componentRef) )
4064 algorithm
4065 ✗ txt := crefTypeMLPI(txt, i_componentRef);
4066 then txt;
4067
4068 case ( txt,
4069 _ )
4070 algorithm
4071 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("crefType:ERROR"));
4072 then txt;
4073 end match;
4074 end crefTypeMLPI;
4075
4076 protected function fun_130
4077 input Tpl.Text in_txt;
4078 input Boolean in_mArg;
4079 input Tpl.Text in_a_typeShort;
4080
4081 output Tpl.Text out_txt;
4082 algorithm
4083 out_txt :=
4084 match(in_txt, in_mArg, in_a_typeShort)
4085 local
4086 Tpl.Text txt;
4087 Tpl.Text a_typeShort;
4088
4089 case ( txt,
4090 false,
4091 a_typeShort )
4092 algorithm
4093 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("ERROR:crefStartValueType "));
4094 ✗ txt := Tpl.writeText(txt, a_typeShort);
4095 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
4096 then txt;
4097
4098 case ( txt,
4099 _,
4100 _ )
4101 algorithm
4102 3 txt := Tpl.writeTok(txt, Tpl.ST_STRING("ExternalObject"));
4103 then txt;
4104 end match;
4105 end fun_130;
4106
4107 protected function fun_131
4108 input Tpl.Text in_txt;
4109 input Boolean in_mArg;
4110 input Tpl.Text in_a_typeShort;
4111
4112 output Tpl.Text out_txt;
4113 algorithm
4114 out_txt :=
4115 match(in_txt, in_mArg, in_a_typeShort)
4116 local
4117 Tpl.Text txt;
4118 Tpl.Text a_typeShort;
4119 Boolean ret_0;
4120
4121 case ( txt,
4122 false,
4123 a_typeShort )
4124 algorithm
4125
2/4
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
3 ret_0 := stringEq(Tpl.textString(a_typeShort), "void*");
4126 3 txt := fun_130(txt, ret_0, a_typeShort);
4127 then txt;
4128
4129 case ( txt,
4130 _,
4131 _ )
4132 algorithm
4133 43 txt := Tpl.writeTok(txt, Tpl.ST_STRING("String"));
4134 then txt;
4135 end match;
4136 end fun_131;
4137
4138 protected function fun_132
4139 input Tpl.Text in_txt;
4140 input Boolean in_mArg;
4141 input Tpl.Text in_a_typeShort;
4142
4143 output Tpl.Text out_txt;
4144 algorithm
4145 out_txt :=
4146 match(in_txt, in_mArg, in_a_typeShort)
4147 local
4148 Tpl.Text txt;
4149 Tpl.Text a_typeShort;
4150 Boolean ret_0;
4151
4152 case ( txt,
4153 false,
4154 a_typeShort )
4155 algorithm
4156
3/4
✓ Branch 1 taken 43 times.
✓ Branch 2 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 43 times.
46 ret_0 := stringEq(Tpl.textString(a_typeShort), "string");
4157 46 txt := fun_131(txt, ret_0, a_typeShort);
4158 then txt;
4159
4160 case ( txt,
4161 _,
4162 _ )
4163 algorithm
4164 868 txt := Tpl.writeTok(txt, Tpl.ST_STRING("Bool"));
4165 then txt;
4166 end match;
4167 end fun_132;
4168
4169 protected function fun_133
4170 input Tpl.Text in_txt;
4171 input Boolean in_mArg;
4172 input Tpl.Text in_a_typeShort;
4173
4174 output Tpl.Text out_txt;
4175 algorithm
4176 out_txt :=
4177 match(in_txt, in_mArg, in_a_typeShort)
4178 local
4179 Tpl.Text txt;
4180 Tpl.Text a_typeShort;
4181 Boolean ret_0;
4182
4183 case ( txt,
4184 false,
4185 a_typeShort )
4186 algorithm
4187
3/4
✓ Branch 1 taken 868 times.
✓ Branch 2 taken 46 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 868 times.
914 ret_0 := stringEq(Tpl.textString(a_typeShort), "bool");
4188 914 txt := fun_132(txt, ret_0, a_typeShort);
4189 then txt;
4190
4191 case ( txt,
4192 _,
4193 _ )
4194 algorithm
4195 778 txt := Tpl.writeTok(txt, Tpl.ST_STRING("Int"));
4196 then txt;
4197 end match;
4198 end fun_133;
4199
4200 protected function fun_134
4201 input Tpl.Text in_txt;
4202 input Boolean in_mArg;
4203 input Tpl.Text in_a_typeShort;
4204
4205 output Tpl.Text out_txt;
4206 algorithm
4207 out_txt :=
4208 match(in_txt, in_mArg, in_a_typeShort)
4209 local
4210 Tpl.Text txt;
4211 Tpl.Text a_typeShort;
4212 Boolean ret_0;
4213
4214 case ( txt,
4215 false,
4216 a_typeShort )
4217 algorithm
4218
3/4
✓ Branch 1 taken 778 times.
✓ Branch 2 taken 914 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 778 times.
1692 ret_0 := stringEq(Tpl.textString(a_typeShort), "int");
4219 1692 txt := fun_133(txt, ret_0, a_typeShort);
4220 then txt;
4221
4222 case ( txt,
4223 _,
4224 _ )
4225 algorithm
4226 9514 txt := Tpl.writeTok(txt, Tpl.ST_STRING("Real"));
4227 then txt;
4228 end match;
4229 end fun_134;
4230
4231 public function crefStartValueType
4232 input Tpl.Text in_txt;
4233 input DAE.ComponentRef in_a_cr;
4234
4235 output Tpl.Text out_txt;
4236 algorithm
4237 out_txt :=
4238 match(in_txt, in_a_cr)
4239 local
4240 Tpl.Text txt;
4241 DAE.ComponentRef i_componentRef;
4242 DAE.Type i_identType;
4243 Boolean ret_2;
4244 Tpl.Text l_typeString;
4245 Tpl.Text l_typeShort;
4246
4247 case ( txt,
4248 DAE.CREF_IDENT(identType = i_identType) )
4249 algorithm
4250 11206 l_typeShort := expTypeShort(Tpl.emptyTxt, i_identType);
4251
4/4
✓ Branch 1 taken 9557 times.
✓ Branch 2 taken 1649 times.
✓ Branch 5 taken 43 times.
✓ Branch 6 taken 9514 times.
11206 ret_2 := stringEq(Tpl.textString(l_typeShort), "double");
4252 11206 l_typeString := fun_134(Tpl.emptyTxt, ret_2, l_typeShort);
4253 11206 txt := Tpl.writeText(txt, l_typeString);
4254 then txt;
4255
4256 case ( txt,
4257 DAE.CREF_QUAL(componentRef = i_componentRef) )
4258 algorithm
4259 23088 txt := crefStartValueType(txt, i_componentRef);
4260 then txt;
4261
4262 case ( txt,
4263 _ )
4264 algorithm
4265 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("crefStartValueType:ERROR"));
4266 then txt;
4267 end match;
4268 end crefStartValueType;
4269
4270 public function dimension
4271 input Tpl.Text in_txt;
4272 input DAE.Dimension in_a_d;
4273 input SimCodeFunction.Context in_a_context;
4274
4275 output Tpl.Text out_txt;
4276 algorithm
4277 out_txt :=
4278 match(in_txt, in_a_d, in_a_context)
4279 local
4280 Tpl.Text txt;
4281 SimCodeFunction.Context a_context;
4282 DAE.Exp i_e;
4283 Integer i_size;
4284 Integer i_integer;
4285
4286 case ( txt,
4287 DAE.DIM_BOOLEAN(),
4288 _ )
4289 algorithm
4290 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("2"));
4291 then txt;
4292
4293 case ( txt,
4294 DAE.DIM_INTEGER(integer = i_integer),
4295 _ )
4296 algorithm
4297 246 txt := Tpl.writeStr(txt, intString(i_integer));
4298 then txt;
4299
4300 case ( txt,
4301 DAE.DIM_ENUM(size = i_size),
4302 _ )
4303 algorithm
4304 ✗ txt := Tpl.writeStr(txt, intString(i_size));
4305 then txt;
4306
4307 case ( txt,
4308 DAE.DIM_EXP(exp = i_e),
4309 a_context )
4310 algorithm
4311 ✗ txt := dimensionExp(txt, i_e, a_context, false);
4312 then txt;
4313
4314 case ( txt,
4315 DAE.DIM_UNKNOWN(),
4316 _ )
4317 algorithm
4318 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("-1"));
4319 then txt;
4320
4321 case ( txt,
4322 _,
4323 _ )
4324 algorithm
4325 ✗ txt := error(txt, Tpl.sourceInfo("CodegenCppCommon.tpl", 652, 14), "dimension: INVALID_DIMENSION");
4326 then txt;
4327 end match;
4328 end dimension;
4329
4330 protected function lm_137
4331 input output Tpl.Text txt;
4332 input list<Integer> items;
4333 algorithm
4334
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 1788 times.
2388 for lstElt_137 in items loop
4335 txt := match lstElt_137
4336 local
4337 Integer i_dim;
4338
4339 case i_dim
4340 algorithm
4341 600 txt := Tpl.writeStr(txt, intString(i_dim));
4342 600 txt := Tpl.nextIter(txt);
4343 then txt;
4344 end match;
4345 end for;
4346 end lm_137;
4347
4348 protected function fun_138
4349 input Tpl.Text in_txt;
4350 input Boolean in_mArg;
4351 input Tpl.Text in_a_dimstr;
4352
4353 output Tpl.Text out_txt;
4354 algorithm
4355 out_txt :=
4356 match(in_txt, in_mArg, in_a_dimstr)
4357 local
4358 Tpl.Text txt;
4359 Tpl.Text a_dimstr;
4360
4361 case ( txt,
4362 false,
4363 _ )
4364 then txt;
4365
4366 case ( txt,
4367 _,
4368 a_dimstr )
4369 algorithm
4370 1788 txt := Tpl.writeText(txt, a_dimstr);
4371 then txt;
4372 end match;
4373 end fun_138;
4374
4375 public function checkDimension
4376 input Tpl.Text txt;
4377 input DAE.Dimensions a_dims;
4378
4379 output Tpl.Text out_txt;
4380 protected
4381 Boolean ret_3;
4382 Integer ret_2;
4383 list<Integer> ret_1;
4384 Tpl.Text l_dimstr;
4385 algorithm
4386 1788 ret_1 := Expression.dimensionsList(a_dims);
4387 1788 l_dimstr := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(",")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
4388 1788 l_dimstr := lm_137(l_dimstr, ret_1);
4389 1788 l_dimstr := Tpl.popIter(l_dimstr);
4390 1788 ret_2 := System.stringFind(Tpl.textString(l_dimstr), "-");
4391 1788 ret_3 := intEq(-1, ret_2);
4392 1788 out_txt := fun_138(txt, ret_3, l_dimstr);
4393 end checkDimension;
4394
4395 protected function lm_140
4396 input output Tpl.Text txt;
4397 input list<Integer> items;
4398 algorithm
4399 ✗ for lstElt_140 in items loop
4400 txt := match lstElt_140
4401 local
4402 Integer i_dim;
4403
4404 case i_dim
4405 algorithm
4406 ✗ txt := Tpl.writeStr(txt, intString(i_dim));
4407 ✗ txt := Tpl.nextIter(txt);
4408 then txt;
4409 end match;
4410 end for;
4411 end lm_140;
4412
4413 public function checkExpDimension
4414 input Tpl.Text txt;
4415 input list<DAE.Exp> a_dims;
4416
4417 output Tpl.Text out_txt;
4418 protected
4419 list<Integer> ret_0;
4420 algorithm
4421 ✗ ret_0 := Expression.expDimensionsList(a_dims);
4422 ✗ out_txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(",")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
4423 ✗ out_txt := lm_140(out_txt, ret_0);
4424 ✗ out_txt := Tpl.popIter(out_txt);
4425 end checkExpDimension;
4426
4427 protected function fun_142
4428 input Tpl.Text in_txt;
4429 input String in_mArg;
4430 input Tpl.Text in_a_subdimstr;
4431 input Tpl.Text in_a_dimstr;
4432
4433 output Tpl.Text out_txt;
4434 algorithm
4435 out_txt :=
4436 match(in_txt, in_mArg, in_a_subdimstr, in_a_dimstr)
4437 local
4438 Tpl.Text txt;
4439 Tpl.Text a_subdimstr;
4440 Tpl.Text a_dimstr;
4441
4442 case ( txt,
4443 "",
4444 _,
4445 _ )
4446 then txt;
4447
4448 case ( txt,
4449 _,
4450 a_subdimstr,
4451 a_dimstr )
4452 algorithm
4453 ✗ txt := Tpl.writeText(txt, a_dimstr);
4454 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
4455 ✗ txt := Tpl.writeText(txt, a_subdimstr);
4456 then txt;
4457 end match;
4458 end fun_142;
4459
4460 protected function fun_143
4461 input Tpl.Text in_txt;
4462 input DAE.Type in_a_elty;
4463 input Tpl.Text in_a_dimstr;
4464
4465 output Tpl.Text out_txt;
4466 algorithm
4467 out_txt :=
4468 match(in_txt, in_a_elty, in_a_dimstr)
4469 local
4470 Tpl.Text txt;
4471 Tpl.Text a_dimstr;
4472 DAE.Type i_subty;
4473 DAE.Dimensions i_subdims;
4474 String str_1;
4475 Tpl.Text l_subdimstr;
4476
4477 case ( txt,
4478 DAE.T_ARRAY(dims = i_subdims, ty = i_subty),
4479 a_dimstr )
4480 algorithm
4481 ✗ l_subdimstr := listDimsFlat(Tpl.emptyTxt, i_subdims, i_subty);
4482 ✗ str_1 := Tpl.textString(l_subdimstr);
4483 ✗ txt := fun_142(txt, str_1, l_subdimstr, a_dimstr);
4484 then txt;
4485
4486 case ( txt,
4487 _,
4488 a_dimstr )
4489 algorithm
4490 430 txt := Tpl.writeText(txt, a_dimstr);
4491 then txt;
4492 end match;
4493 end fun_143;
4494
4495 protected function fun_144
4496 input Tpl.Text in_txt;
4497 input String in_mArg;
4498 input Tpl.Text in_a_dimstr;
4499 input DAE.Type in_a_elty;
4500
4501 output Tpl.Text out_txt;
4502 algorithm
4503 out_txt :=
4504 match(in_txt, in_mArg, in_a_dimstr, in_a_elty)
4505 local
4506 Tpl.Text txt;
4507 Tpl.Text a_dimstr;
4508 DAE.Type a_elty;
4509
4510 case ( txt,
4511 "",
4512 _,
4513 _ )
4514 then txt;
4515
4516 case ( txt,
4517 _,
4518 a_dimstr,
4519 a_elty )
4520 algorithm
4521 430 txt := fun_143(txt, a_elty, a_dimstr);
4522 then txt;
4523 end match;
4524 end fun_144;
4525
4526 public function listDimsFlat
4527 input Tpl.Text txt;
4528 input DAE.Dimensions a_dims;
4529 input DAE.Type a_elty;
4530
4531 output Tpl.Text out_txt;
4532 protected
4533 String str_1;
4534 Tpl.Text l_dimstr;
4535 algorithm
4536 454 l_dimstr := checkDimension(Tpl.emptyTxt, a_dims);
4537 454 str_1 := Tpl.textString(l_dimstr);
4538 454 out_txt := fun_144(txt, str_1, l_dimstr, a_elty);
4539 end listDimsFlat;
4540
4541 protected function fun_146
4542 input Tpl.Text in_txt;
4543 input DAE.Type in_a_elty;
4544 input DAE.Dimensions in_a_dims;
4545 input Integer in_a_offset;
4546
4547 output Tpl.Text out_txt;
4548 algorithm
4549 out_txt :=
4550 match(in_txt, in_a_elty, in_a_dims, in_a_offset)
4551 local
4552 Tpl.Text txt;
4553 DAE.Dimensions a_dims;
4554 Integer a_offset;
4555 DAE.Dimensions i_dims;
4556 DAE.Type i_subty;
4557 DAE.Dimensions i_subdims;
4558 Integer ret_3;
4559 Integer ret_2;
4560 Integer ret_1;
4561 Integer ret_0;
4562
4563 case ( txt,
4564 DAE.T_ARRAY(dims = (i_dims as i_subdims), ty = i_subty),
4565 _,
4566 a_offset )
4567 algorithm
4568 ✗ ret_0 := listLength(i_dims);
4569 ✗ ret_1 := intAdd(ret_0, a_offset);
4570 ✗ txt := nDimsFlat(txt, i_subdims, i_subty, ret_1);
4571 then txt;
4572
4573 case ( txt,
4574 _,
4575 a_dims,
4576 a_offset )
4577 algorithm
4578 454 ret_2 := listLength(a_dims);
4579 454 ret_3 := intAdd(ret_2, a_offset);
4580 454 txt := Tpl.writeStr(txt, intString(ret_3));
4581 then txt;
4582 end match;
4583 end fun_146;
4584
4585 public function nDimsFlat
4586 input Tpl.Text txt;
4587 input DAE.Dimensions a_dims;
4588 input DAE.Type a_elty;
4589 input Integer a_offset;
4590
4591 output Tpl.Text out_txt;
4592 algorithm
4593 454 out_txt := fun_146(txt, a_elty, a_dims, a_offset);
4594 end nDimsFlat;
4595
4596 protected function fun_148
4597 input Tpl.Text in_txt;
4598 input Boolean in_mArg;
4599
4600 output Tpl.Text out_txt;
4601 algorithm
4602 out_txt :=
4603 match(in_txt, in_mArg)
4604 local
4605 Tpl.Text txt;
4606
4607 case ( txt,
4608 false )
4609 algorithm
4610 408 txt := Tpl.writeTok(txt, Tpl.ST_STRING("string"));
4611 then txt;
4612
4613 case ( txt,
4614 _ )
4615 algorithm
4616 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("metatype"));
4617 then txt;
4618 end match;
4619 end fun_148;
4620
4621 public function expTypeShort
4622 input Tpl.Text in_txt;
4623 input DAE.Type in_a_type;
4624
4625 output Tpl.Text out_txt;
4626 algorithm
4627 out_txt :=
4628 match(in_txt, in_a_type)
4629 local
4630 Tpl.Text txt;
4631 DAE.Type i_type;
4632 ClassInf.State i_complexClassType;
4633 DAE.Type i_ty;
4634 DAE.Type i_complexType;
4635 String ret_2;
4636 Absyn.Path ret_1;
4637 Boolean ret_0;
4638
4639 case ( txt,
4640 DAE.T_INTEGER(varLst = _) )
4641 algorithm
4642 1260 txt := Tpl.writeTok(txt, Tpl.ST_STRING("int"));
4643 then txt;
4644
4645 case ( txt,
4646 DAE.T_REAL(varLst = _) )
4647 algorithm
4648 30717 txt := Tpl.writeTok(txt, Tpl.ST_STRING("double"));
4649 then txt;
4650
4651 case ( txt,
4652 DAE.T_STRING(varLst = _) )
4653 algorithm
4654 408 ret_0 := Config.acceptMetaModelicaGrammar();
4655 408 txt := fun_148(txt, ret_0);
4656 then txt;
4657
4658 case ( txt,
4659 DAE.T_BOOL(varLst = _) )
4660 algorithm
4661 1506 txt := Tpl.writeTok(txt, Tpl.ST_STRING("bool"));
4662 then txt;
4663
4664 case ( txt,
4665 DAE.T_ENUMERATION(index = _) )
4666 algorithm
4667 610 txt := Tpl.writeTok(txt, Tpl.ST_STRING("int"));
4668 then txt;
4669
4670 case ( txt,
4671 DAE.T_UNKNOWN() )
4672 algorithm
4673 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("double /*W1*/"));
4674 then txt;
4675
4676 case ( txt,
4677 DAE.T_ANYTYPE(anyClassType = _) )
4678 algorithm
4679 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("complex2"));
4680 then txt;
4681
4682 case ( txt,
4683 DAE.T_SUBTYPE_BASIC(complexType = i_complexType) )
4684 algorithm
4685 ✗ txt := expTypeShort(txt, i_complexType);
4686 then txt;
4687
4688 case ( txt,
4689 DAE.T_ARRAY(ty = i_ty) )
4690 algorithm
4691 6173 txt := expTypeShort(txt, i_ty);
4692 then txt;
4693
4694 case ( txt,
4695 DAE.T_COMPLEX(complexClassType = ClassInf.EXTERNAL_OBJ(path = _)) )
4696 algorithm
4697 55 txt := Tpl.writeTok(txt, Tpl.ST_STRING("void*"));
4698 then txt;
4699
4700 case ( txt,
4701 DAE.T_COMPLEX(complexClassType = i_complexClassType) )
4702 algorithm
4703 11 ret_1 := ClassInfUtil.getStateName(i_complexClassType);
4704 11 txt := CodegenUtil.underscorePath(txt, ret_1);
4705 11 txt := Tpl.writeTok(txt, Tpl.ST_STRING("Type"));
4706 then txt;
4707
4708 case ( txt,
4709 DAE.T_METATYPE(ty = _) )
4710 algorithm
4711 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("metatype"));
4712 then txt;
4713
4714 case ( txt,
4715 DAE.T_METABOXED(ty = _) )
4716 algorithm
4717 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("metatype"));
4718 then txt;
4719
4720 case ( txt,
4721 DAE.T_FUNCTION(funcArg = _) )
4722 algorithm
4723 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("fnptr"));
4724 then txt;
4725
4726 case ( txt,
4727 DAE.T_FUNCTION_REFERENCE_FUNC(builtin = _) )
4728 algorithm
4729 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("fnptr"));
4730 then txt;
4731
4732 case ( txt,
4733 DAE.T_FUNCTION_REFERENCE_VAR(functionType = _) )
4734 algorithm
4735 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("fnptr"));
4736 then txt;
4737
4738 case ( txt,
4739 i_type )
4740 algorithm
4741 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("expTypeShort:ERROR "));
4742 ✗ ret_2 := TypesDump.unparseType(i_type);
4743 ✗ txt := Tpl.writeStr(txt, ret_2);
4744 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
4745 then txt;
4746 end match;
4747 end expTypeShort;
4748
4749 protected function fun_150
4750 input Tpl.Text in_txt;
4751 input DAE.Type in_a_ty;
4752
4753 output Tpl.Text out_txt;
4754 algorithm
4755 out_txt :=
4756 match(in_txt, in_a_ty)
4757 local
4758 Tpl.Text txt;
4759 DAE.Type i_ty;
4760 ClassInf.State i_complexClassType;
4761 Absyn.Path ret_0;
4762
4763 case ( txt,
4764 DAE.T_COMPLEX(complexClassType = i_complexClassType) )
4765 algorithm
4766 ✗ ret_0 := ClassInfUtil.getStateName(i_complexClassType);
4767 ✗ txt := CodegenUtil.underscorePath(txt, ret_0);
4768 then txt;
4769
4770 case ( txt,
4771 i_ty )
4772 algorithm
4773 4271 txt := expTypeShort(txt, i_ty);
4774 then txt;
4775 end match;
4776 end fun_150;
4777
4778 protected function fun_151
4779 input Tpl.Text in_txt;
4780 input DAE.Type in_a_ty;
4781
4782 output Tpl.Text out_txt;
4783 algorithm
4784 out_txt :=
4785 match(in_txt, in_a_ty)
4786 local
4787 Tpl.Text txt;
4788 DAE.Type i_ty;
4789 Absyn.Path i_rname;
4790
4791 case ( txt,
4792 DAE.T_COMPLEX(complexClassType = ClassInf.RECORD(path = i_rname)) )
4793 algorithm
4794 199 txt := CodegenUtil.underscorePath(txt, i_rname);
4795 199 txt := Tpl.writeTok(txt, Tpl.ST_STRING("Type"));
4796 then txt;
4797
4798 case ( txt,
4799 i_ty )
4800 algorithm
4801 4271 txt := fun_150(txt, i_ty);
4802 then txt;
4803 end match;
4804 end fun_151;
4805
4806 protected function fun_152
4807 input Tpl.Text in_txt;
4808 input DAE.Type in_a_ty;
4809
4810 output Tpl.Text out_txt;
4811 algorithm
4812 out_txt :=
4813 match(in_txt, in_a_ty)
4814 local
4815 Tpl.Text txt;
4816 DAE.Type i_ty;
4817
4818 case ( txt,
4819 (i_ty as DAE.T_COMPLEX(complexClassType = ClassInf.EXTERNAL_OBJ(path = _))) )
4820 algorithm
4821 6 txt := expTypeShort(txt, i_ty);
4822 then txt;
4823
4824 case ( txt,
4825 i_ty )
4826 algorithm
4827 4470 txt := fun_151(txt, i_ty);
4828 then txt;
4829 end match;
4830 end fun_152;
4831
4832 protected function fun_153
4833 input Tpl.Text in_txt;
4834 input DAE.Type in_a_ty;
4835
4836 output Tpl.Text out_txt;
4837 algorithm
4838 out_txt :=
4839 match(in_txt, in_a_ty)
4840 local
4841 Tpl.Text txt;
4842 DAE.Dimensions i_dims;
4843 DAE.Type i_elty;
4844
4845 case ( txt,
4846 DAE.T_ARRAY(ty = i_elty, dims = i_dims) )
4847 algorithm
4848 ✗ txt := expTypeArrayDims(txt, i_elty, i_dims);
4849 then txt;
4850
4851 case ( txt,
4852 _ )
4853 algorithm
4854 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("ERROR:expTypeFlag3 no array"));
4855 then txt;
4856 end match;
4857 end fun_153;
4858
4859 protected function fun_154
4860 input Tpl.Text in_txt;
4861 input DAE.Type in_a_ty;
4862
4863 output Tpl.Text out_txt;
4864 algorithm
4865 out_txt :=
4866 match(in_txt, in_a_ty)
4867 local
4868 Tpl.Text txt;
4869 DAE.Type i_ty;
4870 DAE.Dimensions i_dims;
4871 DAE.Type i_elty;
4872
4873 case ( txt,
4874 DAE.T_ARRAY(ty = i_elty, dims = i_dims) )
4875 algorithm
4876 443 txt := expTypeArrayDims(txt, i_elty, i_dims);
4877 then txt;
4878
4879 case ( txt,
4880 i_ty )
4881 algorithm
4882 1662 txt := expTypeFlag(txt, i_ty, 2);
4883 then txt;
4884 end match;
4885 end fun_154;
4886
4887 protected function fun_155
4888 input Tpl.Text in_txt;
4889 input String in_mArg;
4890 input Tpl.Text in_a_dimstr;
4891 input DAE.Type in_a_ty;
4892 input DAE.Dimensions in_a_dims;
4893
4894 output Tpl.Text out_txt;
4895 algorithm
4896 out_txt :=
4897 match(in_txt, in_mArg, in_a_dimstr, in_a_ty, in_a_dims)
4898 local
4899 Tpl.Text txt;
4900 Tpl.Text a_dimstr;
4901 DAE.Type a_ty;
4902 DAE.Dimensions a_dims;
4903 Integer ret_1;
4904 Integer ret_0;
4905
4906 case ( txt,
4907 "",
4908 _,
4909 a_ty,
4910 a_dims )
4911 algorithm
4912 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("const DynArrayDim"));
4913 ✗ ret_0 := listLength(a_dims);
4914 ✗ txt := Tpl.writeStr(txt, intString(ret_0));
4915 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<"));
4916 ✗ txt := expTypeShort(txt, a_ty);
4917 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(">&"));
4918 then txt;
4919
4920 case ( txt,
4921 _,
4922 a_dimstr,
4923 a_ty,
4924 a_dims )
4925 algorithm
4926 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("const StatArrayDim"));
4927 ✗ ret_1 := listLength(a_dims);
4928 ✗ txt := Tpl.writeStr(txt, intString(ret_1));
4929 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<"));
4930 ✗ txt := expTypeShort(txt, a_ty);
4931 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(","));
4932 ✗ txt := Tpl.writeText(txt, a_dimstr);
4933 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(">&"));
4934 then txt;
4935 end match;
4936 end fun_155;
4937
4938 protected function fun_156
4939 input Tpl.Text in_txt;
4940 input DAE.Type in_a_ty;
4941
4942 output Tpl.Text out_txt;
4943 algorithm
4944 out_txt :=
4945 match(in_txt, in_a_ty)
4946 local
4947 Tpl.Text txt;
4948 DAE.Type i_ty;
4949 DAE.Dimensions i_dims;
4950 String str_1;
4951 Tpl.Text l_dimstr;
4952
4953 case ( txt,
4954 (i_ty as DAE.T_ARRAY(dims = i_dims)) )
4955 algorithm
4956 ✗ l_dimstr := checkDimension(Tpl.emptyTxt, i_dims);
4957 ✗ str_1 := Tpl.textString(l_dimstr);
4958 ✗ txt := fun_155(txt, str_1, l_dimstr, i_ty, i_dims);
4959 then txt;
4960
4961 case ( txt,
4962 i_ty )
4963 algorithm
4964 228 txt := expTypeFlag(txt, i_ty, 2);
4965 then txt;
4966 end match;
4967 end fun_156;
4968
4969 protected function fun_157
4970 input Tpl.Text in_txt;
4971 input DAE.Type in_a_ty;
4972
4973 output Tpl.Text out_txt;
4974 algorithm
4975 out_txt :=
4976 match(in_txt, in_a_ty)
4977 local
4978 Tpl.Text txt;
4979 DAE.Dimensions i_dims;
4980 DAE.Type i_ty;
4981 Integer ret_0;
4982
4983 case ( txt,
4984 DAE.T_ARRAY(dims = i_dims, ty = i_ty) )
4985 algorithm
4986 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("multi_array<"));
4987 ✗ txt := expTypeShort(txt, i_ty);
4988 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(","));
4989 ✗ ret_0 := listLength(i_dims);
4990 ✗ txt := Tpl.writeStr(txt, intString(ret_0));
4991 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(">"));
4992 then txt;
4993
4994 case ( txt,
4995 _ )
4996 then txt;
4997 end match;
4998 end fun_157;
4999
5000 protected function fun_158
5001 input Tpl.Text in_txt;
5002 input DAE.Type in_a_ty;
5003
5004 output Tpl.Text out_txt;
5005 algorithm
5006 out_txt :=
5007 match(in_txt, in_a_ty)
5008 local
5009 Tpl.Text txt;
5010 DAE.Type i_ty;
5011
5012 case ( txt,
5013 DAE.T_ARRAY(dims = _, ty = i_ty) )
5014 algorithm
5015 200 txt := Tpl.writeTok(txt, Tpl.ST_STRING("const BaseArray<"));
5016 200 txt := expTypeShort(txt, i_ty);
5017 200 txt := Tpl.writeTok(txt, Tpl.ST_STRING(">&"));
5018 then txt;
5019
5020 case ( txt,
5021 i_ty )
5022 algorithm
5023 3012 txt := expTypeFlag(txt, i_ty, 9);
5024 then txt;
5025 end match;
5026 end fun_158;
5027
5028 protected function fun_159
5029 input Tpl.Text in_txt;
5030 input DAE.Type in_a_ty;
5031
5032 output Tpl.Text out_txt;
5033 algorithm
5034 out_txt :=
5035 match(in_txt, in_a_ty)
5036 local
5037 Tpl.Text txt;
5038 DAE.Type i_ty;
5039 ClassInf.State i_complexClassType;
5040 Absyn.Path ret_0;
5041
5042 case ( txt,
5043 DAE.T_COMPLEX(complexClassType = i_complexClassType) )
5044 algorithm
5045 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("const "));
5046 ✗ ret_0 := ClassInfUtil.getStateName(i_complexClassType);
5047 ✗ txt := CodegenUtil.underscorePath(txt, ret_0);
5048 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("&"));
5049 then txt;
5050
5051 case ( txt,
5052 i_ty )
5053 algorithm
5054 2890 txt := expTypeShort(txt, i_ty);
5055 then txt;
5056 end match;
5057 end fun_159;
5058
5059 protected function fun_160
5060 input Tpl.Text in_txt;
5061 input DAE.Type in_a_ty;
5062
5063 output Tpl.Text out_txt;
5064 algorithm
5065 out_txt :=
5066 match(in_txt, in_a_ty)
5067 local
5068 Tpl.Text txt;
5069 DAE.Type i_ty;
5070 Absyn.Path i_rname;
5071
5072 case ( txt,
5073 DAE.T_COMPLEX(complexClassType = ClassInf.RECORD(path = i_rname)) )
5074 algorithm
5075 76 txt := Tpl.writeTok(txt, Tpl.ST_STRING("const "));
5076 76 txt := CodegenUtil.underscorePath(txt, i_rname);
5077 76 txt := Tpl.writeTok(txt, Tpl.ST_STRING("Type&"));
5078 then txt;
5079
5080 case ( txt,
5081 i_ty )
5082 algorithm
5083 2890 txt := fun_159(txt, i_ty);
5084 then txt;
5085 end match;
5086 end fun_160;
5087
5088 protected function fun_161
5089 input Tpl.Text in_txt;
5090 input DAE.Type in_a_ty;
5091
5092 output Tpl.Text out_txt;
5093 algorithm
5094 out_txt :=
5095 match(in_txt, in_a_ty)
5096 local
5097 Tpl.Text txt;
5098 DAE.Type i_ty;
5099
5100 case ( txt,
5101 (i_ty as DAE.T_COMPLEX(complexClassType = ClassInf.EXTERNAL_OBJ(path = _))) )
5102 algorithm
5103 46 txt := expTypeShort(txt, i_ty);
5104 then txt;
5105
5106 case ( txt,
5107 i_ty )
5108 algorithm
5109 2966 txt := fun_160(txt, i_ty);
5110 then txt;
5111 end match;
5112 end fun_161;
5113
5114 protected function fun_162
5115 input Tpl.Text in_txt;
5116 input Integer in_a_flag;
5117 input DAE.Type in_a_ty;
5118
5119 output Tpl.Text out_txt;
5120 algorithm
5121 out_txt :=
5122 match(in_txt, in_a_flag, in_a_ty)
5123 local
5124 Tpl.Text txt;
5125 DAE.Type a_ty;
5126
5127 case ( txt,
5128 1,
5129 a_ty )
5130 algorithm
5131 253 txt := expTypeShort(txt, a_ty);
5132 then txt;
5133
5134 case ( txt,
5135 2,
5136 a_ty )
5137 algorithm
5138 4476 txt := fun_152(txt, a_ty);
5139 then txt;
5140
5141 case ( txt,
5142 3,
5143 a_ty )
5144 algorithm
5145 ✗ txt := fun_153(txt, a_ty);
5146 then txt;
5147
5148 case ( txt,
5149 4,
5150 a_ty )
5151 algorithm
5152 2105 txt := fun_154(txt, a_ty);
5153 then txt;
5154
5155 case ( txt,
5156 5,
5157 a_ty )
5158 algorithm
5159 228 txt := fun_156(txt, a_ty);
5160 then txt;
5161
5162 case ( txt,
5163 6,
5164 a_ty )
5165 algorithm
5166 ✗ txt := expTypeFlag(txt, a_ty, 4);
5167 then txt;
5168
5169 case ( txt,
5170 7,
5171 a_ty )
5172 algorithm
5173 ✗ txt := fun_157(txt, a_ty);
5174 then txt;
5175
5176 case ( txt,
5177 8,
5178 a_ty )
5179 algorithm
5180 3212 txt := fun_158(txt, a_ty);
5181 then txt;
5182
5183 case ( txt,
5184 9,
5185 a_ty )
5186 algorithm
5187 3012 txt := fun_161(txt, a_ty);
5188 then txt;
5189
5190 case ( txt,
5191 _,
5192 _ )
5193 then txt;
5194 end match;
5195 end fun_162;
5196
5197 public function expTypeFlag
5198 input Tpl.Text txt;
5199 input DAE.Type a_ty;
5200 input Integer a_flag;
5201
5202 output Tpl.Text out_txt;
5203 algorithm
5204 13286 out_txt := fun_162(txt, a_flag, a_ty);
5205 end expTypeFlag;
5206
5207 public function crefType
5208 input Tpl.Text in_txt;
5209 input DAE.ComponentRef in_a_cr;
5210
5211 output Tpl.Text out_txt;
5212 algorithm
5213 out_txt :=
5214 match(in_txt, in_a_cr)
5215 local
5216 Tpl.Text txt;
5217 DAE.ComponentRef i_componentRef;
5218 DAE.Type i_identType;
5219
5220 case ( txt,
5221 DAE.CREF_IDENT(identType = i_identType) )
5222 algorithm
5223 ✗ txt := expTypeArrayIf(txt, i_identType);
5224 then txt;
5225
5226 case ( txt,
5227 DAE.CREF_QUAL(componentRef = i_componentRef) )
5228 algorithm
5229 ✗ txt := crefType(txt, i_componentRef);
5230 then txt;
5231
5232 case ( txt,
5233 _ )
5234 algorithm
5235 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("crefType:ERROR"));
5236 then txt;
5237 end match;
5238 end crefType;
5239
5240 public function expTypeFromExpShort
5241 input Tpl.Text txt;
5242 input DAE.Exp a_exp;
5243
5244 output Tpl.Text out_txt;
5245 algorithm
5246 258 out_txt := expTypeFromExpFlag(txt, a_exp, 1);
5247 end expTypeFromExpShort;
5248
5249 public function expTypeFromExpModelica
5250 input Tpl.Text txt;
5251 input DAE.Exp a_exp;
5252
5253 output Tpl.Text out_txt;
5254 algorithm
5255 1012 out_txt := expTypeFromExpFlag(txt, a_exp, 2);
5256 end expTypeFromExpModelica;
5257
5258 public function expTypeFromExpArray
5259 input Tpl.Text txt;
5260 input DAE.Exp a_exp;
5261
5262 output Tpl.Text out_txt;
5263 algorithm
5264 9 out_txt := expTypeFromExpFlag(txt, a_exp, 4);
5265 end expTypeFromExpArray;
5266
5267 protected function fun_168
5268 input Tpl.Text in_txt;
5269 input Boolean in_mArg;
5270
5271 output Tpl.Text out_txt;
5272 algorithm
5273 out_txt :=
5274 match(in_txt, in_mArg)
5275 local
5276 Tpl.Text txt;
5277
5278 case ( txt,
5279 false )
5280 algorithm
5281 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("string"));
5282 then txt;
5283
5284 case ( txt,
5285 _ )
5286 algorithm
5287 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("metatype"));
5288 then txt;
5289 end match;
5290 end fun_168;
5291
5292 public function expTypeShortSPS
5293 input Tpl.Text in_txt;
5294 input DAE.Type in_a_type;
5295
5296 output Tpl.Text out_txt;
5297 algorithm
5298 out_txt :=
5299 match(in_txt, in_a_type)
5300 local
5301 Tpl.Text txt;
5302 ClassInf.State i_complexClassType;
5303 DAE.Type i_ty;
5304 Absyn.Path ret_1;
5305 Boolean ret_0;
5306
5307 case ( txt,
5308 DAE.T_INTEGER(varLst = _) )
5309 algorithm
5310 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("INT"));
5311 then txt;
5312
5313 case ( txt,
5314 DAE.T_REAL(varLst = _) )
5315 algorithm
5316 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("LREAL"));
5317 then txt;
5318
5319 case ( txt,
5320 DAE.T_STRING(varLst = _) )
5321 algorithm
5322 ✗ ret_0 := Config.acceptMetaModelicaGrammar();
5323 ✗ txt := fun_168(txt, ret_0);
5324 then txt;
5325
5326 case ( txt,
5327 DAE.T_BOOL(varLst = _) )
5328 algorithm
5329 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("BOOL"));
5330 then txt;
5331
5332 case ( txt,
5333 DAE.T_ENUMERATION(index = _) )
5334 algorithm
5335 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("INT"));
5336 then txt;
5337
5338 case ( txt,
5339 DAE.T_UNKNOWN() )
5340 algorithm
5341 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("LREAL"));
5342 then txt;
5343
5344 case ( txt,
5345 DAE.T_ANYTYPE(anyClassType = _) )
5346 algorithm
5347 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("type not supported"));
5348 then txt;
5349
5350 case ( txt,
5351 DAE.T_ARRAY(ty = i_ty) )
5352 algorithm
5353 ✗ txt := expTypeShortSPS(txt, i_ty);
5354 then txt;
5355
5356 case ( txt,
5357 DAE.T_COMPLEX(complexClassType = ClassInf.EXTERNAL_OBJ(path = _)) )
5358 algorithm
5359 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("type not supported"));
5360 then txt;
5361
5362 case ( txt,
5363 DAE.T_COMPLEX(complexClassType = i_complexClassType) )
5364 algorithm
5365 ✗ ret_1 := ClassInfUtil.getStateName(i_complexClassType);
5366 ✗ txt := CodegenUtil.underscorePath(txt, ret_1);
5367 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("Type"));
5368 then txt;
5369
5370 case ( txt,
5371 DAE.T_METATYPE(ty = _) )
5372 algorithm
5373 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("type not supported"));
5374 then txt;
5375
5376 case ( txt,
5377 DAE.T_METABOXED(ty = _) )
5378 algorithm
5379 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("type not supported"));
5380 then txt;
5381
5382 case ( txt,
5383 DAE.T_FUNCTION(funcArg = _) )
5384 algorithm
5385 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("type not supported"));
5386 then txt;
5387
5388 case ( txt,
5389 DAE.T_FUNCTION_REFERENCE_FUNC(builtin = _) )
5390 algorithm
5391 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("type not supported"));
5392 then txt;
5393
5394 case ( txt,
5395 DAE.T_FUNCTION_REFERENCE_VAR(functionType = _) )
5396 algorithm
5397 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("type not supported"));
5398 then txt;
5399
5400 case ( txt,
5401 _ )
5402 algorithm
5403 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("expTypeShort:ERROR"));
5404 then txt;
5405 end match;
5406 end expTypeShortSPS;
5407
5408 protected function fun_170
5409 input Tpl.Text in_txt;
5410 input Boolean in_mArg;
5411
5412 output Tpl.Text out_txt;
5413 algorithm
5414 out_txt :=
5415 match(in_txt, in_mArg)
5416 local
5417 Tpl.Text txt;
5418
5419 case ( txt,
5420 false )
5421 algorithm
5422 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("string"));
5423 then txt;
5424
5425 case ( txt,
5426 _ )
5427 algorithm
5428 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("metatype"));
5429 then txt;
5430 end match;
5431 end fun_170;
5432
5433 public function expTypeShortMLPI
5434 input Tpl.Text in_txt;
5435 input DAE.Type in_a_type;
5436
5437 output Tpl.Text out_txt;
5438 algorithm
5439 out_txt :=
5440 match(in_txt, in_a_type)
5441 local
5442 Tpl.Text txt;
5443 ClassInf.State i_complexClassType;
5444 DAE.Type i_ty;
5445 Absyn.Path ret_1;
5446 Boolean ret_0;
5447
5448 case ( txt,
5449 DAE.T_INTEGER(varLst = _) )
5450 algorithm
5451 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("MLPI_IEC_INT"));
5452 then txt;
5453
5454 case ( txt,
5455 DAE.T_REAL(varLst = _) )
5456 algorithm
5457 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("MLPI_IEC_LREAL"));
5458 then txt;
5459
5460 case ( txt,
5461 DAE.T_STRING(varLst = _) )
5462 algorithm
5463 ✗ ret_0 := Config.acceptMetaModelicaGrammar();
5464 ✗ txt := fun_170(txt, ret_0);
5465 then txt;
5466
5467 case ( txt,
5468 DAE.T_BOOL(varLst = _) )
5469 algorithm
5470 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("MLPI_IEC_BOOL"));
5471 then txt;
5472
5473 case ( txt,
5474 DAE.T_ENUMERATION(index = _) )
5475 algorithm
5476 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("MLPI_IEC_INT"));
5477 then txt;
5478
5479 case ( txt,
5480 DAE.T_UNKNOWN() )
5481 algorithm
5482 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("MLPI_IEC_LREAL"));
5483 then txt;
5484
5485 case ( txt,
5486 DAE.T_ANYTYPE(anyClassType = _) )
5487 algorithm
5488 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("type not supported"));
5489 then txt;
5490
5491 case ( txt,
5492 DAE.T_ARRAY(ty = i_ty) )
5493 algorithm
5494 ✗ txt := expTypeShortSPS(txt, i_ty);
5495 then txt;
5496
5497 case ( txt,
5498 DAE.T_COMPLEX(complexClassType = ClassInf.EXTERNAL_OBJ(path = _)) )
5499 algorithm
5500 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("type not supported"));
5501 then txt;
5502
5503 case ( txt,
5504 DAE.T_COMPLEX(complexClassType = i_complexClassType) )
5505 algorithm
5506 ✗ ret_1 := ClassInfUtil.getStateName(i_complexClassType);
5507 ✗ txt := CodegenUtil.underscorePath(txt, ret_1);
5508 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("Type"));
5509 then txt;
5510
5511 case ( txt,
5512 DAE.T_METATYPE(ty = _) )
5513 algorithm
5514 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("type not supported"));
5515 then txt;
5516
5517 case ( txt,
5518 DAE.T_METABOXED(ty = _) )
5519 algorithm
5520 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("type not supported"));
5521 then txt;
5522
5523 case ( txt,
5524 DAE.T_FUNCTION(funcArg = _) )
5525 algorithm
5526 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("type not supported"));
5527 then txt;
5528
5529 case ( txt,
5530 DAE.T_FUNCTION_REFERENCE_FUNC(builtin = _) )
5531 algorithm
5532 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("type not supported"));
5533 then txt;
5534
5535 case ( txt,
5536 DAE.T_FUNCTION_REFERENCE_VAR(functionType = _) )
5537 algorithm
5538 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("type not supported"));
5539 then txt;
5540
5541 case ( txt,
5542 _ )
5543 algorithm
5544 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("expTypeShort:ERROR"));
5545 then txt;
5546 end match;
5547 end expTypeShortMLPI;
5548
5549 protected function fun_172
5550 input Tpl.Text in_txt;
5551 input Boolean in_a_isArray;
5552 input DAE.Type in_a_ty;
5553
5554 output Tpl.Text out_txt;
5555 algorithm
5556 out_txt :=
5557 match(in_txt, in_a_isArray, in_a_ty)
5558 local
5559 Tpl.Text txt;
5560 DAE.Type a_ty;
5561
5562 case ( txt,
5563 false,
5564 a_ty )
5565 algorithm
5566 20 txt := expTypeShort(txt, a_ty);
5567 then txt;
5568
5569 case ( txt,
5570 _,
5571 a_ty )
5572 algorithm
5573 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("expType_"));
5574 ✗ txt := expTypeArray1(txt, a_ty, 0);
5575 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_NOT_YET"));
5576 then txt;
5577 end match;
5578 end fun_172;
5579
5580 public function expType
5581 input Tpl.Text txt;
5582 input DAE.Type a_ty;
5583 input Boolean a_isArray;
5584
5585 output Tpl.Text out_txt;
5586 algorithm
5587 20 out_txt := fun_172(txt, a_isArray, a_ty);
5588 end expType;
5589
5590 public function expTypeModelica
5591 input Tpl.Text txt;
5592 input DAE.Type a_ty;
5593
5594 output Tpl.Text out_txt;
5595 algorithm
5596 ✗ out_txt := expTypeFlag(txt, a_ty, 2);
5597 end expTypeModelica;
5598
5599 public function expTypeArray
5600 input Tpl.Text txt;
5601 input DAE.Type a_ty;
5602
5603 output Tpl.Text out_txt;
5604 algorithm
5605 ✗ out_txt := expTypeFlag(txt, a_ty, 3);
5606 end expTypeArray;
5607
5608 public function expTypeArrayIf
5609 input Tpl.Text txt;
5610 input DAE.Type a_ty;
5611
5612 output Tpl.Text out_txt;
5613 algorithm
5614 2096 out_txt := expTypeFlag(txt, a_ty, 4);
5615 end expTypeArrayIf;
5616
5617 public function expTypeArray1
5618 input Tpl.Text txt;
5619 input DAE.Type a_ty;
5620 input Integer a_dims;
5621
5622 output Tpl.Text out_txt;
5623 algorithm
5624 ✗ out_txt := Tpl.writeTok(txt, Tpl.ST_STRING("SimArray"));
5625 ✗ out_txt := Tpl.writeStr(out_txt, intString(a_dims));
5626 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("<"));
5627 ✗ out_txt := expTypeShort(out_txt, a_ty);
5628 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING(">"));
5629 end expTypeArray1;
5630
5631 protected function fun_178
5632 input Tpl.Text in_txt;
5633 input String in_mArg;
5634 input Tpl.Text in_a_dimstr;
5635 input Tpl.Text in_a_typeShort;
5636 input DAE.Type in_a_elty;
5637 input DAE.Dimensions in_a_dims;
5638
5639 output Tpl.Text out_txt;
5640 algorithm
5641 out_txt :=
5642 match(in_txt, in_mArg, in_a_dimstr, in_a_typeShort, in_a_elty, in_a_dims)
5643 local
5644 Tpl.Text txt;
5645 Tpl.Text a_dimstr;
5646 Tpl.Text a_typeShort;
5647 DAE.Type a_elty;
5648 DAE.Dimensions a_dims;
5649
5650 case ( txt,
5651 "",
5652 _,
5653 a_typeShort,
5654 a_elty,
5655 a_dims )
5656 algorithm
5657 24 txt := Tpl.writeTok(txt, Tpl.ST_STRING("DynArrayDim"));
5658 24 txt := nDimsFlat(txt, a_dims, a_elty, 0);
5659 24 txt := Tpl.writeTok(txt, Tpl.ST_STRING("<"));
5660 24 txt := Tpl.writeText(txt, a_typeShort);
5661 24 txt := Tpl.writeTok(txt, Tpl.ST_STRING(">"));
5662 then txt;
5663
5664 case ( txt,
5665 _,
5666 a_dimstr,
5667 a_typeShort,
5668 a_elty,
5669 a_dims )
5670 algorithm
5671 430 txt := Tpl.writeTok(txt, Tpl.ST_STRING("StatArrayDim"));
5672 430 txt := nDimsFlat(txt, a_dims, a_elty, 0);
5673 430 txt := Tpl.writeTok(txt, Tpl.ST_STRING("<"));
5674 430 txt := Tpl.writeText(txt, a_typeShort);
5675 430 txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
5676 430 txt := Tpl.writeText(txt, a_dimstr);
5677 430 txt := Tpl.writeTok(txt, Tpl.ST_STRING(">"));
5678 then txt;
5679 end match;
5680 end fun_178;
5681
5682 public function expTypeArrayDims
5683 input Tpl.Text txt;
5684 input DAE.Type a_elty;
5685 input DAE.Dimensions a_dims;
5686
5687 output Tpl.Text out_txt;
5688 protected
5689 String str_2;
5690 Tpl.Text l_dimstr;
5691 Tpl.Text l_typeShort;
5692 algorithm
5693 454 l_typeShort := expTypeShort(Tpl.emptyTxt, a_elty);
5694 454 l_dimstr := listDimsFlat(Tpl.emptyTxt, a_dims, a_elty);
5695 454 str_2 := Tpl.textString(l_dimstr);
5696 454 out_txt := fun_178(txt, str_2, l_dimstr, l_typeShort, a_elty, a_dims);
5697 end expTypeArrayDims;
5698
5699 protected function lm_180
5700 input output Tpl.Text txt;
5701 input DAE.Dimensions items;
5702 input SimCodeFunction.Context a_context;
5703 algorithm
5704 ✗ for lstElt_180 in items loop
5705 txt := match lstElt_180
5706 local
5707 DAE.Dimension i_dim;
5708
5709 case i_dim
5710 algorithm
5711 ✗ txt := dimension(txt, i_dim, a_context);
5712 ✗ txt := Tpl.nextIter(txt);
5713 then txt;
5714 end match;
5715 end for;
5716 end lm_180;
5717
5718 public function allocateDimensions
5719 input Tpl.Text in_txt;
5720 input DAE.Type in_a_ty;
5721 input SimCodeFunction.Context in_a_context;
5722
5723 output Tpl.Text out_txt;
5724 algorithm
5725 out_txt :=
5726 match(in_txt, in_a_ty, in_a_context)
5727 local
5728 Tpl.Text txt;
5729 SimCodeFunction.Context a_context;
5730 DAE.Dimensions i_dims;
5731 Tpl.Text l_dimstr;
5732
5733 case ( txt,
5734 DAE.T_ARRAY(dims = i_dims),
5735 a_context )
5736 algorithm
5737 ✗ l_dimstr := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(",")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
5738 ✗ l_dimstr := lm_180(l_dimstr, i_dims, a_context);
5739 ✗ l_dimstr := Tpl.popIter(l_dimstr);
5740 ✗ txt := Tpl.writeText(txt, l_dimstr);
5741 then txt;
5742
5743 case ( txt,
5744 _,
5745 _ )
5746 then txt;
5747 end match;
5748 end allocateDimensions;
5749
5750 public function tempDecl
5751 input Tpl.Text txt;
5752 input String a_ty;
5753 input Tpl.Text a_varDecls;
5754
5755 output Tpl.Text out_txt;
5756 output Tpl.Text out_a_varDecls;
5757 protected
5758 Integer ret_1;
5759 Tpl.Text l_newVar;
5760 algorithm
5761 5268 l_newVar := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("tmp"));
5762 5268 ret_1 := System.tmpTick();
5763 5268 l_newVar := Tpl.writeStr(l_newVar, intString(ret_1));
5764 5268 out_a_varDecls := Tpl.writeStr(a_varDecls, a_ty);
5765 5268 out_a_varDecls := Tpl.writeTok(out_a_varDecls, Tpl.ST_STRING(" "));
5766 5268 out_a_varDecls := Tpl.writeText(out_a_varDecls, l_newVar);
5767 5268 out_a_varDecls := Tpl.writeTok(out_a_varDecls, Tpl.ST_STRING(";"));
5768 5268 out_a_varDecls := Tpl.writeTok(out_a_varDecls, Tpl.ST_NEW_LINE());
5769 5268 out_txt := Tpl.writeText(txt, l_newVar);
5770 end tempDecl;
5771
5772 public function tempDeclAssign
5773 input Tpl.Text txt;
5774 input String a_ty;
5775 input Tpl.Text a_varDecls;
5776 input String a_assign;
5777
5778 output Tpl.Text out_txt;
5779 output Tpl.Text out_a_varDecls;
5780 protected
5781 Integer ret_1;
5782 Tpl.Text l_newVar;
5783 algorithm
5784 ✗ l_newVar := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("tmp"));
5785 ✗ ret_1 := System.tmpTick();
5786 ✗ l_newVar := Tpl.writeStr(l_newVar, intString(ret_1));
5787 ✗ out_a_varDecls := Tpl.writeStr(a_varDecls, a_ty);
5788 ✗ out_a_varDecls := Tpl.writeTok(out_a_varDecls, Tpl.ST_STRING(" "));
5789 ✗ out_a_varDecls := Tpl.writeText(out_a_varDecls, l_newVar);
5790 ✗ out_a_varDecls := Tpl.writeTok(out_a_varDecls, Tpl.ST_STRING(" = "));
5791 ✗ out_a_varDecls := Tpl.writeStr(out_a_varDecls, a_assign);
5792 ✗ out_a_varDecls := Tpl.writeTok(out_a_varDecls, Tpl.ST_STRING(";"));
5793 ✗ out_a_varDecls := Tpl.writeTok(out_a_varDecls, Tpl.ST_NEW_LINE());
5794 ✗ out_txt := Tpl.writeText(txt, l_newVar);
5795 end tempDeclAssign;
5796
5797 public function tempDecl1
5798 input Tpl.Text txt;
5799 input String a_ty;
5800 input String a_exp;
5801 input Tpl.Text a_varDecls;
5802
5803 output Tpl.Text out_txt;
5804 output Tpl.Text out_a_varDecls;
5805 protected
5806 Tpl.Text l_newVar1;
5807 Integer ret_1;
5808 Tpl.Text l_newVar;
5809 algorithm
5810 ✗ l_newVar := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("tmp"));
5811 ✗ ret_1 := System.tmpTick();
5812 ✗ l_newVar := Tpl.writeStr(l_newVar, intString(ret_1));
5813 ✗ l_newVar1 := Tpl.writeText(Tpl.emptyTxt, l_newVar);
5814 ✗ l_newVar1 := Tpl.writeTok(l_newVar1, Tpl.ST_STRING("("));
5815 ✗ l_newVar1 := Tpl.writeStr(l_newVar1, a_exp);
5816 ✗ l_newVar1 := Tpl.writeTok(l_newVar1, Tpl.ST_STRING(")"));
5817 ✗ out_a_varDecls := Tpl.writeStr(a_varDecls, a_ty);
5818 ✗ out_a_varDecls := Tpl.writeTok(out_a_varDecls, Tpl.ST_STRING(" "));
5819 ✗ out_a_varDecls := Tpl.writeText(out_a_varDecls, l_newVar1);
5820 ✗ out_a_varDecls := Tpl.writeTok(out_a_varDecls, Tpl.ST_STRING(";"));
5821 ✗ out_a_varDecls := Tpl.writeTok(out_a_varDecls, Tpl.ST_NEW_LINE());
5822 ✗ out_txt := Tpl.writeText(txt, l_newVar);
5823 end tempDecl1;
5824
5825 protected function fun_185
5826 input Tpl.Text in_txt;
5827 input SimCodeFunction.Context in_a_context;
5828 input Boolean in_a_useFlatArrayNotation;
5829 input DAE.ComponentRef in_a_cr;
5830
5831 output Tpl.Text out_txt;
5832 algorithm
5833 out_txt :=
5834 match(in_txt, in_a_context, in_a_useFlatArrayNotation, in_a_cr)
5835 local
5836 Tpl.Text txt;
5837 Boolean a_useFlatArrayNotation;
5838 DAE.ComponentRef a_cr;
5839 String ret_1;
5840 Tpl.Text txt_0;
5841
5842 case ( txt,
5843 SimCodeFunction.FUNCTION_CONTEXT(cref_prefix = _),
5844 _,
5845 a_cr )
5846 algorithm
5847 ✗ txt_0 := crefStr(Tpl.emptyTxt, a_cr);
5848 ✗ ret_1 := System.unquoteIdentifier(Tpl.textString(txt_0));
5849 ✗ txt := Tpl.writeStr(txt, ret_1);
5850 then txt;
5851
5852 case ( txt,
5853 _,
5854 a_useFlatArrayNotation,
5855 a_cr )
5856 algorithm
5857 ✗ txt := cref(txt, a_cr, a_useFlatArrayNotation);
5858 then txt;
5859 end match;
5860 end fun_185;
5861
5862 public function dimensionExp
5863 input Tpl.Text in_txt;
5864 input DAE.Exp in_a_dimExp;
5865 input SimCodeFunction.Context in_a_context;
5866 input Boolean in_a_useFlatArrayNotation;
5867
5868 output Tpl.Text out_txt;
5869 algorithm
5870 out_txt :=
5871 match(in_txt, in_a_dimExp, in_a_context, in_a_useFlatArrayNotation)
5872 local
5873 Tpl.Text txt;
5874 SimCodeFunction.Context a_context;
5875 Boolean a_useFlatArrayNotation;
5876 DAE.Exp i_dimExp;
5877 DAE.ComponentRef i_cr;
5878
5879 case ( txt,
5880 DAE.CREF(componentRef = i_cr),
5881 a_context,
5882 a_useFlatArrayNotation )
5883 algorithm
5884 ✗ txt := fun_185(txt, a_context, a_useFlatArrayNotation, i_cr);
5885 then txt;
5886
5887 case ( txt,
5888 i_dimExp,
5889 _,
5890 _ )
5891 algorithm
5892 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("/* fehler dimensionExp: INVALID_DIMENSION "));
5893 ✗ txt := ExpressionDumpTpl.dumpExp(txt, i_dimExp, "\"");
5894 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("*/"));
5895 then txt;
5896 end match;
5897 end dimensionExp;
5898
5899 public function daeDimensionExp
5900 input Tpl.Text in_txt;
5901 input DAE.Exp in_a_exp;
5902
5903 output Tpl.Text out_txt;
5904 algorithm
5905 out_txt :=
5906 match(in_txt, in_a_exp)
5907 local
5908 Tpl.Text txt;
5909 Integer i_integer;
5910
5911 case ( txt,
5912 DAE.ICONST(integer = i_integer) )
5913 algorithm
5914 ✗ txt := Tpl.writeStr(txt, intString(i_integer));
5915 then txt;
5916
5917 case ( txt,
5918 _ )
5919 algorithm
5920 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("-1"));
5921 then txt;
5922 end match;
5923 end daeDimensionExp;
5924
5925 protected function fun_188
5926 input Tpl.Text in_txt;
5927 input Boolean in_a_bool;
5928
5929 output Tpl.Text out_txt;
5930 algorithm
5931 out_txt :=
5932 match(in_txt, in_a_bool)
5933 local
5934 Tpl.Text txt;
5935
5936 case ( txt,
5937 false )
5938 algorithm
5939 430 txt := Tpl.writeTok(txt, Tpl.ST_STRING("false"));
5940 then txt;
5941
5942 case ( txt,
5943 _ )
5944 algorithm
5945 559 txt := Tpl.writeTok(txt, Tpl.ST_STRING("true"));
5946 then txt;
5947 end match;
5948 end fun_188;
5949
5950 public function daeExp
5951 input Tpl.Text in_txt;
5952 input DAE.Exp in_a_exp;
5953 input SimCodeFunction.Context in_a_context;
5954 input Tpl.Text in_a_preExp;
5955 input Tpl.Text in_a_varDecls;
5956 input SimCode.SimCode in_a_simCode;
5957 input Tpl.Text in_a_extraFuncs;
5958 input Tpl.Text in_a_extraFuncsDecl;
5959 input Tpl.Text in_a_extraFuncsNamespace;
5960 input Tpl.Text in_a_stateDerVectorName;
5961 input Boolean in_a_useFlatArrayNotation;
5962
5963 output Tpl.Text out_txt;
5964 output Tpl.Text out_a_preExp;
5965 output Tpl.Text out_a_varDecls;
5966 output Tpl.Text out_a_extraFuncs;
5967 output Tpl.Text out_a_extraFuncsDecl;
5968 output Tpl.Text out_a_extraFuncsNamespace;
5969 output Tpl.Text out_a_stateDerVectorName;
5970 algorithm
5971 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
5972 match(in_txt, in_a_exp, in_a_context, in_a_preExp, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
5973 local
5974 Tpl.Text txt;
5975 SimCodeFunction.Context a_context;
5976 Tpl.Text a_preExp;
5977 Tpl.Text a_varDecls;
5978 SimCode.SimCode a_simCode;
5979 Tpl.Text a_extraFuncs;
5980 Tpl.Text a_extraFuncsDecl;
5981 Tpl.Text a_extraFuncsNamespace;
5982 Tpl.Text a_stateDerVectorName;
5983 Boolean a_useFlatArrayNotation;
5984 DAE.Exp i_exp;
5985 DAE.Exp i_expElse;
5986 DAE.Exp i_expThen;
5987 DAE.Exp i_expCond;
5988 DAE.Exp i_exp2;
5989 DAE.Exp i_exp1;
5990 DAE.Operator i_operator;
5991 Integer i_index;
5992 DAE.Exp i_e;
5993 String i_string;
5994 Boolean i_bool;
5995 Real i_real;
5996 Integer i_integer;
5997 Tpl.Text txt_6;
5998 Tpl.Text txt_5;
5999 Tpl.Text txt_4;
6000 Tpl.Text txt_3;
6001 Tpl.Text txt_2;
6002 Tpl.Text txt_1;
6003 Tpl.Text txt_0;
6004
6005 case ( txt,
6006 DAE.ICONST(integer = i_integer),
6007 _,
6008 a_preExp,
6009 a_varDecls,
6010 _,
6011 a_extraFuncs,
6012 a_extraFuncsDecl,
6013 a_extraFuncsNamespace,
6014 a_stateDerVectorName,
6015 _ )
6016 algorithm
6017 15579 txt := Tpl.writeStr(txt, intString(i_integer));
6018 15579 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6019
6020 case ( txt,
6021 DAE.RCONST(real = i_real),
6022 _,
6023 a_preExp,
6024 a_varDecls,
6025 _,
6026 a_extraFuncs,
6027 a_extraFuncsDecl,
6028 a_extraFuncsNamespace,
6029 a_stateDerVectorName,
6030 _ )
6031 algorithm
6032 25635 txt := Tpl.writeStr(txt, realString(i_real));
6033 25635 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6034
6035 case ( txt,
6036 DAE.BCONST(bool = i_bool),
6037 _,
6038 a_preExp,
6039 a_varDecls,
6040 _,
6041 a_extraFuncs,
6042 a_extraFuncsDecl,
6043 a_extraFuncsNamespace,
6044 a_stateDerVectorName,
6045 _ )
6046 algorithm
6047 989 txt := fun_188(txt, i_bool);
6048 989 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6049
6050 case ( txt,
6051 DAE.SCONST(string = i_string),
6052 a_context,
6053 a_preExp,
6054 a_varDecls,
6055 a_simCode,
6056 a_extraFuncs,
6057 a_extraFuncsDecl,
6058 a_extraFuncsNamespace,
6059 a_stateDerVectorName,
6060 a_useFlatArrayNotation )
6061 algorithm
6062 1028 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpSconst(txt, i_string, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
6063 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6064
6065 case ( txt,
6066 (i_e as DAE.CLKCONST(clk = _)),
6067 _,
6068 a_preExp,
6069 a_varDecls,
6070 _,
6071 a_extraFuncs,
6072 a_extraFuncsDecl,
6073 a_extraFuncsNamespace,
6074 a_stateDerVectorName,
6075 _ )
6076 algorithm
6077 ✗ txt_0 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("Unsupported CLKCONST exp:"));
6078 ✗ txt_0 := ExpressionDumpTpl.dumpExp(txt_0, i_e, "\"");
6079 ✗ txt := error(txt, Tpl.sourceInfo("CodegenCppCommon.tpl", 998, 44), Tpl.textString(txt_0));
6080 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6081
6082 case ( txt,
6083 DAE.ENUM_LITERAL(index = i_index),
6084 _,
6085 a_preExp,
6086 a_varDecls,
6087 _,
6088 a_extraFuncs,
6089 a_extraFuncsDecl,
6090 a_extraFuncsNamespace,
6091 a_stateDerVectorName,
6092 _ )
6093 algorithm
6094 449 txt := Tpl.writeStr(txt, intString(i_index));
6095 449 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6096
6097 case ( txt,
6098 (i_e as DAE.CREF(componentRef = _)),
6099 a_context,
6100 a_preExp,
6101 a_varDecls,
6102 a_simCode,
6103 a_extraFuncs,
6104 a_extraFuncsDecl,
6105 a_extraFuncsNamespace,
6106 a_stateDerVectorName,
6107 a_useFlatArrayNotation )
6108 algorithm
6109 54297 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpCrefRhs(txt, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
6110 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6111
6112 case ( txt,
6113 (i_e as DAE.CAST(ty = _)),
6114 a_context,
6115 a_preExp,
6116 a_varDecls,
6117 a_simCode,
6118 a_extraFuncs,
6119 a_extraFuncsDecl,
6120 a_extraFuncsNamespace,
6121 a_stateDerVectorName,
6122 a_useFlatArrayNotation )
6123 algorithm
6124 165 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpCast(txt, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
6125 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6126
6127 case ( txt,
6128 (i_e as DAE.CONS(car = _)),
6129 _,
6130 a_preExp,
6131 a_varDecls,
6132 _,
6133 a_extraFuncs,
6134 a_extraFuncsDecl,
6135 a_extraFuncsNamespace,
6136 a_stateDerVectorName,
6137 _ )
6138 algorithm
6139 ✗ txt_1 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("Unsupported CONS exp:"));
6140 ✗ txt_1 := ExpressionDumpTpl.dumpExp(txt_1, i_e, "\"");
6141 ✗ txt := error(txt, Tpl.sourceInfo("CodegenCppCommon.tpl", 1002, 44), Tpl.textString(txt_1));
6142 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6143
6144 case ( txt,
6145 (i_e as DAE.UNARY(operator = _)),
6146 a_context,
6147 a_preExp,
6148 a_varDecls,
6149 a_simCode,
6150 a_extraFuncs,
6151 a_extraFuncsDecl,
6152 a_extraFuncsNamespace,
6153 a_stateDerVectorName,
6154 a_useFlatArrayNotation )
6155 algorithm
6156 1314 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpUnary(txt, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
6157 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6158
6159 case ( txt,
6160 (i_e as DAE.LBINARY(exp1 = _)),
6161 a_context,
6162 a_preExp,
6163 a_varDecls,
6164 a_simCode,
6165 a_extraFuncs,
6166 a_extraFuncsDecl,
6167 a_extraFuncsNamespace,
6168 a_stateDerVectorName,
6169 a_useFlatArrayNotation )
6170 algorithm
6171 553 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpLbinary(txt, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
6172 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6173
6174 case ( txt,
6175 (i_e as DAE.LUNARY(operator = _)),
6176 a_context,
6177 a_preExp,
6178 a_varDecls,
6179 a_simCode,
6180 a_extraFuncs,
6181 a_extraFuncsDecl,
6182 a_extraFuncsNamespace,
6183 a_stateDerVectorName,
6184 a_useFlatArrayNotation )
6185 algorithm
6186 570 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpLunary(txt, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
6187 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6188
6189 case ( txt,
6190 DAE.BINARY(operator = i_operator, exp1 = i_exp1, exp2 = i_exp2),
6191 a_context,
6192 a_preExp,
6193 a_varDecls,
6194 a_simCode,
6195 a_extraFuncs,
6196 a_extraFuncsDecl,
6197 a_extraFuncsNamespace,
6198 a_stateDerVectorName,
6199 a_useFlatArrayNotation )
6200 algorithm
6201 52155 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpBinary(txt, i_operator, i_exp1, i_exp2, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
6202 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6203
6204 case ( txt,
6205 DAE.IFEXP(expCond = i_expCond, expThen = i_expThen, expElse = i_expElse),
6206 a_context,
6207 a_preExp,
6208 a_varDecls,
6209 a_simCode,
6210 a_extraFuncs,
6211 a_extraFuncsDecl,
6212 a_extraFuncsNamespace,
6213 a_stateDerVectorName,
6214 a_useFlatArrayNotation )
6215 algorithm
6216 1585 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpIf(txt, i_expCond, i_expThen, i_expElse, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
6217 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6218
6219 case ( txt,
6220 (i_e as DAE.RELATION(exp1 = _)),
6221 a_context,
6222 a_preExp,
6223 a_varDecls,
6224 a_simCode,
6225 a_extraFuncs,
6226 a_extraFuncsDecl,
6227 a_extraFuncsNamespace,
6228 a_stateDerVectorName,
6229 a_useFlatArrayNotation )
6230 algorithm
6231 2730 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpRelation(txt, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
6232 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6233
6234 case ( txt,
6235 (i_e as DAE.CALL(path = _)),
6236 a_context,
6237 a_preExp,
6238 a_varDecls,
6239 a_simCode,
6240 a_extraFuncs,
6241 a_extraFuncsDecl,
6242 a_extraFuncsNamespace,
6243 a_stateDerVectorName,
6244 a_useFlatArrayNotation )
6245 algorithm
6246 4901 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpCall(txt, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
6247 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6248
6249 case ( txt,
6250 (i_e as DAE.RECORD(path = _)),
6251 a_context,
6252 a_preExp,
6253 a_varDecls,
6254 a_simCode,
6255 a_extraFuncs,
6256 a_extraFuncsDecl,
6257 a_extraFuncsNamespace,
6258 a_stateDerVectorName,
6259 a_useFlatArrayNotation )
6260 algorithm
6261 260 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpRecord(txt, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
6262 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6263
6264 case ( txt,
6265 (i_e as DAE.TUPLE(PR = _)),
6266 _,
6267 a_preExp,
6268 a_varDecls,
6269 _,
6270 a_extraFuncs,
6271 a_extraFuncsDecl,
6272 a_extraFuncsNamespace,
6273 a_stateDerVectorName,
6274 _ )
6275 algorithm
6276 ✗ txt_2 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("Unsupported TUPLE exp:"));
6277 ✗ txt_2 := ExpressionDumpTpl.dumpExp(txt_2, i_e, "\"");
6278 ✗ txt := error(txt, Tpl.sourceInfo("CodegenCppCommon.tpl", 1011, 44), Tpl.textString(txt_2));
6279 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6280
6281 case ( txt,
6282 (i_e as DAE.ASUB(exp = _)),
6283 a_context,
6284 a_preExp,
6285 a_varDecls,
6286 a_simCode,
6287 a_extraFuncs,
6288 a_extraFuncsDecl,
6289 a_extraFuncsNamespace,
6290 a_stateDerVectorName,
6291 a_useFlatArrayNotation )
6292 algorithm
6293 140 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpAsub(txt, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
6294 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6295
6296 case ( txt,
6297 (i_e as DAE.MATRIX(ty = _)),
6298 a_context,
6299 a_preExp,
6300 a_varDecls,
6301 a_simCode,
6302 a_extraFuncs,
6303 a_extraFuncsDecl,
6304 a_extraFuncsNamespace,
6305 a_stateDerVectorName,
6306 a_useFlatArrayNotation )
6307 algorithm
6308 8 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpMatrix(txt, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
6309 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6310
6311 case ( txt,
6312 (i_e as DAE.RANGE(ty = _)),
6313 a_context,
6314 a_preExp,
6315 a_varDecls,
6316 a_simCode,
6317 a_extraFuncs,
6318 a_extraFuncsDecl,
6319 a_extraFuncsNamespace,
6320 a_stateDerVectorName,
6321 a_useFlatArrayNotation )
6322 algorithm
6323 19 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpRange(txt, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
6324 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6325
6326 case ( txt,
6327 (i_e as DAE.TSUB(exp = _)),
6328 a_context,
6329 a_preExp,
6330 a_varDecls,
6331 a_simCode,
6332 a_extraFuncs,
6333 a_extraFuncsDecl,
6334 a_extraFuncsNamespace,
6335 a_stateDerVectorName,
6336 a_useFlatArrayNotation )
6337 algorithm
6338 21 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpTsub(txt, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
6339 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6340
6341 case ( txt,
6342 (i_e as DAE.REDUCTION(reductionInfo = _)),
6343 a_context,
6344 a_preExp,
6345 a_varDecls,
6346 a_simCode,
6347 a_extraFuncs,
6348 a_extraFuncsDecl,
6349 a_extraFuncsNamespace,
6350 a_stateDerVectorName,
6351 a_useFlatArrayNotation )
6352 algorithm
6353 9 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpReduction(txt, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
6354 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6355
6356 case ( txt,
6357 (i_e as DAE.ARRAY(ty = _)),
6358 a_context,
6359 a_preExp,
6360 a_varDecls,
6361 a_simCode,
6362 a_extraFuncs,
6363 a_extraFuncsDecl,
6364 a_extraFuncsNamespace,
6365 a_stateDerVectorName,
6366 a_useFlatArrayNotation )
6367 algorithm
6368 409 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpArray(txt, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
6369 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6370
6371 case ( txt,
6372 (i_e as DAE.SIZE(exp = _)),
6373 a_context,
6374 a_preExp,
6375 a_varDecls,
6376 a_simCode,
6377 a_extraFuncs,
6378 a_extraFuncsDecl,
6379 a_extraFuncsNamespace,
6380 a_stateDerVectorName,
6381 a_useFlatArrayNotation )
6382 algorithm
6383 132 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpSize(txt, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
6384 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6385
6386 case ( txt,
6387 (i_e as DAE.SHARED_LITERAL(index = _)),
6388 a_context,
6389 a_preExp,
6390 a_varDecls,
6391 _,
6392 a_extraFuncs,
6393 a_extraFuncsDecl,
6394 a_extraFuncsNamespace,
6395 a_stateDerVectorName,
6396 a_useFlatArrayNotation )
6397 algorithm
6398 2092 (txt, a_preExp, a_varDecls) := daeExpSharedLiteral(txt, i_e, a_context, a_preExp, a_varDecls, a_useFlatArrayNotation);
6399 2092 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6400
6401 case ( txt,
6402 (i_e as DAE.PARTEVALFUNCTION(path = _)),
6403 a_context,
6404 a_preExp,
6405 a_varDecls,
6406 a_simCode,
6407 a_extraFuncs,
6408 a_extraFuncsDecl,
6409 a_extraFuncsNamespace,
6410 a_stateDerVectorName,
6411 a_useFlatArrayNotation )
6412 algorithm
6413 16 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpPartEvalFunction(txt, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
6414 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6415
6416 case ( txt,
6417 (i_e as DAE.BOX(exp = _)),
6418 a_context,
6419 a_preExp,
6420 a_varDecls,
6421 a_simCode,
6422 a_extraFuncs,
6423 a_extraFuncsDecl,
6424 a_extraFuncsNamespace,
6425 a_stateDerVectorName,
6426 a_useFlatArrayNotation )
6427 algorithm
6428 51 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpBox(txt, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
6429 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6430
6431 case ( txt,
6432 (i_e as DAE.UNBOX(exp = _)),
6433 a_context,
6434 a_preExp,
6435 a_varDecls,
6436 a_simCode,
6437 a_extraFuncs,
6438 a_extraFuncsDecl,
6439 a_extraFuncsNamespace,
6440 a_stateDerVectorName,
6441 a_useFlatArrayNotation )
6442 algorithm
6443 3 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpUnbox(txt, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
6444 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6445
6446 case ( txt,
6447 (i_e as DAE.RSUB(exp = _)),
6448 a_context,
6449 a_preExp,
6450 a_varDecls,
6451 a_simCode,
6452 a_extraFuncs,
6453 a_extraFuncsDecl,
6454 a_extraFuncsNamespace,
6455 a_stateDerVectorName,
6456 a_useFlatArrayNotation )
6457 algorithm
6458 79 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpRSub(txt, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
6459 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6460
6461 case ( txt,
6462 (i_e as DAE.METARECORDCALL(path = _)),
6463 a_context,
6464 a_preExp,
6465 a_varDecls,
6466 a_simCode,
6467 a_extraFuncs,
6468 a_extraFuncsDecl,
6469 a_extraFuncsNamespace,
6470 a_stateDerVectorName,
6471 a_useFlatArrayNotation )
6472 algorithm
6473 ✗ (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpRecordCall(txt, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
6474 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6475
6476 case ( txt,
6477 (i_e as DAE.META_TUPLE(listExp = _)),
6478 _,
6479 a_preExp,
6480 a_varDecls,
6481 _,
6482 a_extraFuncs,
6483 a_extraFuncsDecl,
6484 a_extraFuncsNamespace,
6485 a_stateDerVectorName,
6486 _ )
6487 algorithm
6488 ✗ txt_3 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("Unsupported META_TUPLE exp:"));
6489 ✗ txt_3 := ExpressionDumpTpl.dumpExp(txt_3, i_e, "\"");
6490 ✗ txt := error(txt, Tpl.sourceInfo("CodegenCppCommon.tpl", 1025, 44), Tpl.textString(txt_3));
6491 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6492
6493 case ( txt,
6494 (i_e as DAE.META_OPTION(exp = _)),
6495 _,
6496 a_preExp,
6497 a_varDecls,
6498 _,
6499 a_extraFuncs,
6500 a_extraFuncsDecl,
6501 a_extraFuncsNamespace,
6502 a_stateDerVectorName,
6503 _ )
6504 algorithm
6505 ✗ txt_4 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("Unsupported META_OPTION exp:"));
6506 ✗ txt_4 := ExpressionDumpTpl.dumpExp(txt_4, i_e, "\"");
6507 ✗ txt := error(txt, Tpl.sourceInfo("CodegenCppCommon.tpl", 1026, 44), Tpl.textString(txt_4));
6508 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6509
6510 case ( txt,
6511 (i_e as DAE.MATCHEXPRESSION(matchType = _)),
6512 _,
6513 a_preExp,
6514 a_varDecls,
6515 _,
6516 a_extraFuncs,
6517 a_extraFuncsDecl,
6518 a_extraFuncsNamespace,
6519 a_stateDerVectorName,
6520 _ )
6521 algorithm
6522 ✗ txt_5 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("Unsupported MATCHEXPRESSION exp:"));
6523 ✗ txt_5 := ExpressionDumpTpl.dumpExp(txt_5, i_e, "\"");
6524 ✗ txt := error(txt, Tpl.sourceInfo("CodegenCppCommon.tpl", 1027, 44), Tpl.textString(txt_5));
6525 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6526
6527 case ( txt,
6528 i_exp,
6529 _,
6530 a_preExp,
6531 a_varDecls,
6532 _,
6533 a_extraFuncs,
6534 a_extraFuncsDecl,
6535 a_extraFuncsNamespace,
6536 a_stateDerVectorName,
6537 _ )
6538 algorithm
6539 ✗ txt_6 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("Unknown exp:"));
6540 ✗ txt_6 := ExpressionDumpTpl.dumpExp(txt_6, i_exp, "\"");
6541 ✗ txt := error(txt, Tpl.sourceInfo("CodegenCppCommon.tpl", 1028, 14), Tpl.textString(txt_6));
6542 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6543 end match;
6544 end daeExp;
6545
6546 public function daeExpRSub
6547 input Tpl.Text in_txt;
6548 input DAE.Exp in_a_exp;
6549 input SimCodeFunction.Context in_a_context;
6550 input Tpl.Text in_a_preExp;
6551 input Tpl.Text in_a_varDecls;
6552 input SimCode.SimCode in_a_simCode;
6553 input Tpl.Text in_a_extraFuncs;
6554 input Tpl.Text in_a_extraFuncsDecl;
6555 input Tpl.Text in_a_extraFuncsNamespace;
6556 input Tpl.Text in_a_stateDerVectorName;
6557 input Boolean in_a_useFlatArrayNotation;
6558
6559 output Tpl.Text out_txt;
6560 output Tpl.Text out_a_preExp;
6561 output Tpl.Text out_a_varDecls;
6562 output Tpl.Text out_a_extraFuncs;
6563 output Tpl.Text out_a_extraFuncsDecl;
6564 output Tpl.Text out_a_extraFuncsNamespace;
6565 output Tpl.Text out_a_stateDerVectorName;
6566 algorithm
6567 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
6568 match(in_txt, in_a_exp, in_a_context, in_a_preExp, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
6569 local
6570 Tpl.Text txt;
6571 SimCodeFunction.Context a_context;
6572 Tpl.Text a_preExp;
6573 Tpl.Text a_varDecls;
6574 SimCode.SimCode a_simCode;
6575 Tpl.Text a_extraFuncs;
6576 Tpl.Text a_extraFuncsDecl;
6577 Tpl.Text a_extraFuncsNamespace;
6578 Tpl.Text a_stateDerVectorName;
6579 Boolean a_useFlatArrayNotation;
6580 String i_fieldName;
6581 DAE.Exp i_exp;
6582 Tpl.Text txt_1;
6583 Tpl.Text l_res;
6584
6585 case ( txt,
6586 DAE.RSUB(ix = -1, exp = i_exp, fieldName = i_fieldName),
6587 a_context,
6588 a_preExp,
6589 a_varDecls,
6590 a_simCode,
6591 a_extraFuncs,
6592 a_extraFuncsDecl,
6593 a_extraFuncsNamespace,
6594 a_stateDerVectorName,
6595 a_useFlatArrayNotation )
6596 algorithm
6597 79 (l_res, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
6598 79 txt := Tpl.writeText(txt, l_res);
6599 79 txt := Tpl.writeTok(txt, Tpl.ST_STRING("."));
6600 79 txt := Tpl.writeStr(txt, i_fieldName);
6601 79 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
6602 79 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6603
6604 case ( txt,
6605 DAE.RSUB(exp = i_exp),
6606 _,
6607 a_preExp,
6608 a_varDecls,
6609 _,
6610 a_extraFuncs,
6611 a_extraFuncsDecl,
6612 a_extraFuncsNamespace,
6613 a_stateDerVectorName,
6614 _ )
6615 algorithm
6616 ✗ txt_1 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_exp, "\"");
6617 ✗ txt_1 := Tpl.writeTok(txt_1, Tpl.ST_STRING(": failed"));
6618 ✗ txt := error(txt, Tpl.sourceInfo("CodegenCppCommon.tpl", 1040, 11), Tpl.textString(txt_1));
6619 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6620
6621 case ( txt,
6622 _,
6623 _,
6624 a_preExp,
6625 a_varDecls,
6626 _,
6627 a_extraFuncs,
6628 a_extraFuncsDecl,
6629 a_extraFuncsNamespace,
6630 a_stateDerVectorName,
6631 _ )
6632 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6633 end match;
6634 end daeExpRSub;
6635
6636 protected function fun_191
6637 input Tpl.Text in_txt;
6638 input Option<DAE.Exp> in_a_step;
6639 input Boolean in_a_useFlatArrayNotation;
6640 input Tpl.Text in_a_stateDerVectorName;
6641 input Tpl.Text in_a_extraFuncsNamespace;
6642 input Tpl.Text in_a_extraFuncsDecl;
6643 input Tpl.Text in_a_extraFuncs;
6644 input SimCode.SimCode in_a_simCode;
6645 input Tpl.Text in_a_varDecls;
6646 input Tpl.Text in_a_preExp;
6647 input SimCodeFunction.Context in_a_context;
6648
6649 output Tpl.Text out_txt;
6650 output Tpl.Text out_a_stateDerVectorName;
6651 output Tpl.Text out_a_extraFuncsNamespace;
6652 output Tpl.Text out_a_extraFuncsDecl;
6653 output Tpl.Text out_a_extraFuncs;
6654 output Tpl.Text out_a_varDecls;
6655 output Tpl.Text out_a_preExp;
6656 algorithm
6657 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls, out_a_preExp) :=
6658 match(in_txt, in_a_step, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_varDecls, in_a_preExp, in_a_context)
6659 local
6660 Tpl.Text txt;
6661 Boolean a_useFlatArrayNotation;
6662 Tpl.Text a_stateDerVectorName;
6663 Tpl.Text a_extraFuncsNamespace;
6664 Tpl.Text a_extraFuncsDecl;
6665 Tpl.Text a_extraFuncs;
6666 SimCode.SimCode a_simCode;
6667 Tpl.Text a_varDecls;
6668 Tpl.Text a_preExp;
6669 SimCodeFunction.Context a_context;
6670 DAE.Exp i_stepExp;
6671
6672 case ( txt,
6673 SOME(i_stepExp),
6674 a_useFlatArrayNotation,
6675 a_stateDerVectorName,
6676 a_extraFuncsNamespace,
6677 a_extraFuncsDecl,
6678 a_extraFuncs,
6679 a_simCode,
6680 a_varDecls,
6681 a_preExp,
6682 a_context )
6683 algorithm
6684 10 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_stepExp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
6685 10 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
6686
6687 case ( txt,
6688 _,
6689 _,
6690 a_stateDerVectorName,
6691 a_extraFuncsNamespace,
6692 a_extraFuncsDecl,
6693 a_extraFuncs,
6694 _,
6695 a_varDecls,
6696 a_preExp,
6697 _ )
6698 algorithm
6699 9 txt := Tpl.writeTok(txt, Tpl.ST_STRING("1"));
6700 9 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
6701 end match;
6702 end fun_191;
6703
6704 public function daeExpRange
6705 input Tpl.Text in_txt;
6706 input DAE.Exp in_a_exp;
6707 input SimCodeFunction.Context in_a_context;
6708 input Tpl.Text in_a_preExp;
6709 input Tpl.Text in_a_varDecls;
6710 input SimCode.SimCode in_a_simCode;
6711 input Tpl.Text in_a_extraFuncs;
6712 input Tpl.Text in_a_extraFuncsDecl;
6713 input Tpl.Text in_a_extraFuncsNamespace;
6714 input Tpl.Text in_a_stateDerVectorName;
6715 input Boolean in_a_useFlatArrayNotation;
6716
6717 output Tpl.Text out_txt;
6718 output Tpl.Text out_a_preExp;
6719 output Tpl.Text out_a_varDecls;
6720 output Tpl.Text out_a_extraFuncs;
6721 output Tpl.Text out_a_extraFuncsDecl;
6722 output Tpl.Text out_a_extraFuncsNamespace;
6723 output Tpl.Text out_a_stateDerVectorName;
6724 algorithm
6725 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
6726 match(in_txt, in_a_exp, in_a_context, in_a_preExp, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
6727 local
6728 Tpl.Text txt;
6729 SimCodeFunction.Context a_context;
6730 Tpl.Text a_preExp;
6731 Tpl.Text a_varDecls;
6732 SimCode.SimCode a_simCode;
6733 Tpl.Text a_extraFuncs;
6734 Tpl.Text a_extraFuncsDecl;
6735 Tpl.Text a_extraFuncsNamespace;
6736 Tpl.Text a_stateDerVectorName;
6737 Boolean a_useFlatArrayNotation;
6738 Option<DAE.Exp> i_step;
6739 DAE.Exp i_stop;
6740 DAE.Exp i_start;
6741 DAE.Type i_ty;
6742 Tpl.Text l_step__exp;
6743 Tpl.Text txt_4;
6744 Tpl.Text l_tmp;
6745 Tpl.Text l_stop__exp;
6746 Tpl.Text l_start__exp;
6747 Tpl.Text l_ty__str;
6748
6749 case ( txt,
6750 DAE.RANGE(ty = i_ty, start = i_start, stop = i_stop, step = i_step),
6751 a_context,
6752 a_preExp,
6753 a_varDecls,
6754 a_simCode,
6755 a_extraFuncs,
6756 a_extraFuncsDecl,
6757 a_extraFuncsNamespace,
6758 a_stateDerVectorName,
6759 a_useFlatArrayNotation )
6760 algorithm
6761 19 l_ty__str := expTypeShort(Tpl.emptyTxt, i_ty);
6762 19 (l_start__exp, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_start, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
6763 19 (l_stop__exp, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_stop, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
6764 19 txt_4 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("DynArrayDim1<"));
6765 19 txt_4 := Tpl.writeText(txt_4, l_ty__str);
6766 19 txt_4 := Tpl.writeTok(txt_4, Tpl.ST_STRING(">"));
6767 19 (l_tmp, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(txt_4), a_varDecls);
6768 19 (l_step__exp, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := fun_191(Tpl.emptyTxt, i_step, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
6769 19 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("int "));
6770 19 a_preExp := Tpl.writeText(a_preExp, l_tmp);
6771 19 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("_num_elems =("));
6772 19 a_preExp := Tpl.writeText(a_preExp, l_stop__exp);
6773 19 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("-"));
6774 19 a_preExp := Tpl.writeText(a_preExp, l_start__exp);
6775 19 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(")/"));
6776 19 a_preExp := Tpl.writeText(a_preExp, l_step__exp);
6777 19 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_LINE("+1;\n"));
6778 19 a_preExp := Tpl.writeText(a_preExp, l_tmp);
6779 19 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(".setDims("));
6780 19 a_preExp := Tpl.writeText(a_preExp, l_tmp);
6781 19 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING_LIST({
6782 "_num_elems) /*daeExpRange*/;\n",
6783 "for (int "
6784 }, false));
6785 19 a_preExp := Tpl.writeText(a_preExp, l_tmp);
6786 19 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("_i = 1; "));
6787 19 a_preExp := Tpl.writeText(a_preExp, l_tmp);
6788 19 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("_i <= "));
6789 19 a_preExp := Tpl.writeText(a_preExp, l_tmp);
6790 19 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("_num_elems; "));
6791 19 a_preExp := Tpl.writeText(a_preExp, l_tmp);
6792 19 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_LINE("_i++)\n"));
6793 19 a_preExp := Tpl.pushBlock(a_preExp, Tpl.BT_INDENT(2));
6794 19 a_preExp := Tpl.writeText(a_preExp, l_tmp);
6795 19 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("("));
6796 19 a_preExp := Tpl.writeText(a_preExp, l_tmp);
6797 19 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("_i) = "));
6798 19 a_preExp := Tpl.writeText(a_preExp, l_start__exp);
6799 19 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("+("));
6800 19 a_preExp := Tpl.writeText(a_preExp, l_tmp);
6801 19 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("_i-1)*"));
6802 19 a_preExp := Tpl.writeText(a_preExp, l_step__exp);
6803 19 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(";"));
6804 19 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
6805 19 a_preExp := Tpl.popBlock(a_preExp);
6806 19 txt := Tpl.writeText(txt, l_tmp);
6807 19 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6808
6809 case ( txt,
6810 _,
6811 _,
6812 a_preExp,
6813 a_varDecls,
6814 _,
6815 a_extraFuncs,
6816 a_extraFuncsDecl,
6817 a_extraFuncsNamespace,
6818 a_stateDerVectorName,
6819 _ )
6820 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
6821 end match;
6822 end daeExpRange;
6823
6824 protected function fun_193
6825 input Tpl.Text in_txt;
6826 input Absyn.Path in_a_ri_path;
6827 input Tpl.Text in_a_tmpVarDecls;
6828
6829 output Tpl.Text out_txt;
6830 output Tpl.Text out_a_tmpVarDecls;
6831 algorithm
6832 (out_txt, out_a_tmpVarDecls) :=
6833 match(in_txt, in_a_ri_path, in_a_tmpVarDecls)
6834 local
6835 Tpl.Text txt;
6836 Tpl.Text a_tmpVarDecls;
6837
6838 case ( txt,
6839 Absyn.IDENT(name = "array"),
6840 a_tmpVarDecls )
6841 algorithm
6842 ✗ (txt, a_tmpVarDecls) := tempDecl(txt, "int", a_tmpVarDecls);
6843 then (txt, a_tmpVarDecls);
6844
6845 case ( txt,
6846 _,
6847 a_tmpVarDecls )
6848 ✗ then (txt, a_tmpVarDecls);
6849 end match;
6850 end fun_193;
6851
6852 protected function fun_194
6853 input Tpl.Text in_txt;
6854 input Option<Values.Value> in_a_ri_defaultValue;
6855 input Tpl.Text in_a_tmpVarDecls;
6856
6857 output Tpl.Text out_txt;
6858 output Tpl.Text out_a_tmpVarDecls;
6859 algorithm
6860 (out_txt, out_a_tmpVarDecls) :=
6861 match(in_txt, in_a_ri_defaultValue, in_a_tmpVarDecls)
6862 local
6863 Tpl.Text txt;
6864 Tpl.Text a_tmpVarDecls;
6865
6866 case ( txt,
6867 NONE(),
6868 a_tmpVarDecls )
6869 algorithm
6870 ✗ (txt, a_tmpVarDecls) := tempDecl(txt, "int", a_tmpVarDecls);
6871 then (txt, a_tmpVarDecls);
6872
6873 case ( txt,
6874 _,
6875 a_tmpVarDecls )
6876 ✗ then (txt, a_tmpVarDecls);
6877 end match;
6878 end fun_194;
6879
6880 protected function fun_195
6881 input Tpl.Text in_txt;
6882 input Absyn.Path in_a_ri_path;
6883 input Tpl.Text in_a_tmpVarDecls;
6884 input Option<Values.Value> in_a_ri_defaultValue;
6885
6886 output Tpl.Text out_txt;
6887 output Tpl.Text out_a_tmpVarDecls;
6888 algorithm
6889 (out_txt, out_a_tmpVarDecls) :=
6890 match(in_txt, in_a_ri_path, in_a_tmpVarDecls, in_a_ri_defaultValue)
6891 local
6892 Tpl.Text txt;
6893 Tpl.Text a_tmpVarDecls;
6894 Option<Values.Value> a_ri_defaultValue;
6895
6896 case ( txt,
6897 Absyn.IDENT(name = "array"),
6898 a_tmpVarDecls,
6899 _ )
6900 ✗ then (txt, a_tmpVarDecls);
6901
6902 case ( txt,
6903 _,
6904 a_tmpVarDecls,
6905 a_ri_defaultValue )
6906 algorithm
6907 ✗ (txt, a_tmpVarDecls) := fun_194(txt, a_ri_defaultValue, a_tmpVarDecls);
6908 then (txt, a_tmpVarDecls);
6909 end match;
6910 end fun_195;
6911
6912 protected function fun_196
6913 input Tpl.Text in_txt;
6914 input Absyn.Path in_a_ri_path;
6915 input Tpl.Text in_a_tmpVarDecls;
6916
6917 output Tpl.Text out_txt;
6918 output Tpl.Text out_a_tmpVarDecls;
6919 algorithm
6920 (out_txt, out_a_tmpVarDecls) :=
6921 match(in_txt, in_a_ri_path, in_a_tmpVarDecls)
6922 local
6923 Tpl.Text txt;
6924 Tpl.Text a_tmpVarDecls;
6925
6926 case ( txt,
6927 Absyn.IDENT(name = "list"),
6928 a_tmpVarDecls )
6929 algorithm
6930 ✗ (txt, a_tmpVarDecls) := tempDecl(txt, "modelica_metatype*", a_tmpVarDecls);
6931 then (txt, a_tmpVarDecls);
6932
6933 case ( txt,
6934 _,
6935 a_tmpVarDecls )
6936 ✗ then (txt, a_tmpVarDecls);
6937 end match;
6938 end fun_196;
6939
6940 protected function fun_197
6941 input Tpl.Text in_txt;
6942 input Option<Values.Value> in_a_ri_defaultValue;
6943 input Boolean in_a_useFlatArrayNotation;
6944 input Tpl.Text in_a_stateDerVectorName;
6945 input Tpl.Text in_a_extraFuncsNamespace;
6946 input Tpl.Text in_a_extraFuncsDecl;
6947 input Tpl.Text in_a_extraFuncs;
6948 input SimCode.SimCode in_a_simCode;
6949 input Tpl.Text in_a_tmpVarDecls;
6950 input Tpl.Text in_a_preDefault;
6951 input SimCodeFunction.Context in_a_context;
6952
6953 output Tpl.Text out_txt;
6954 output Tpl.Text out_a_stateDerVectorName;
6955 output Tpl.Text out_a_extraFuncsNamespace;
6956 output Tpl.Text out_a_extraFuncsDecl;
6957 output Tpl.Text out_a_extraFuncs;
6958 output Tpl.Text out_a_tmpVarDecls;
6959 output Tpl.Text out_a_preDefault;
6960 algorithm
6961 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_tmpVarDecls, out_a_preDefault) :=
6962 match(in_txt, in_a_ri_defaultValue, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_tmpVarDecls, in_a_preDefault, in_a_context)
6963 local
6964 Tpl.Text txt;
6965 Boolean a_useFlatArrayNotation;
6966 Tpl.Text a_stateDerVectorName;
6967 Tpl.Text a_extraFuncsNamespace;
6968 Tpl.Text a_extraFuncsDecl;
6969 Tpl.Text a_extraFuncs;
6970 SimCode.SimCode a_simCode;
6971 Tpl.Text a_tmpVarDecls;
6972 Tpl.Text a_preDefault;
6973 SimCodeFunction.Context a_context;
6974 Values.Value i_v;
6975 DAE.Exp ret_0;
6976
6977 case ( txt,
6978 SOME(i_v),
6979 a_useFlatArrayNotation,
6980 a_stateDerVectorName,
6981 a_extraFuncsNamespace,
6982 a_extraFuncsDecl,
6983 a_extraFuncs,
6984 a_simCode,
6985 a_tmpVarDecls,
6986 a_preDefault,
6987 a_context )
6988 algorithm
6989 ✗ ret_0 := ValuesUtil.valueExpNoOriginal(i_v);
6990 ✗ (txt, a_preDefault, a_tmpVarDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, ret_0, a_context, a_preDefault, a_tmpVarDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
6991 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_preDefault);
6992
6993 case ( txt,
6994 _,
6995 _,
6996 a_stateDerVectorName,
6997 a_extraFuncsNamespace,
6998 a_extraFuncsDecl,
6999 a_extraFuncs,
7000 _,
7001 a_tmpVarDecls,
7002 a_preDefault,
7003 _ )
7004 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_preDefault);
7005 end match;
7006 end fun_197;
7007
7008 protected function fun_198
7009 input Tpl.Text in_txt;
7010 input Absyn.Path in_a_ri_path;
7011 input Boolean in_a_useFlatArrayNotation;
7012 input Tpl.Text in_a_stateDerVectorName;
7013 input Tpl.Text in_a_extraFuncsNamespace;
7014 input Tpl.Text in_a_extraFuncsDecl;
7015 input Tpl.Text in_a_extraFuncs;
7016 input SimCode.SimCode in_a_simCode;
7017 input Tpl.Text in_a_tmpVarDecls;
7018 input Tpl.Text in_a_preDefault;
7019 input SimCodeFunction.Context in_a_context;
7020 input Option<Values.Value> in_a_ri_defaultValue;
7021
7022 output Tpl.Text out_txt;
7023 output Tpl.Text out_a_stateDerVectorName;
7024 output Tpl.Text out_a_extraFuncsNamespace;
7025 output Tpl.Text out_a_extraFuncsDecl;
7026 output Tpl.Text out_a_extraFuncs;
7027 output Tpl.Text out_a_tmpVarDecls;
7028 output Tpl.Text out_a_preDefault;
7029 algorithm
7030 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_tmpVarDecls, out_a_preDefault) :=
7031 match(in_txt, in_a_ri_path, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_tmpVarDecls, in_a_preDefault, in_a_context, in_a_ri_defaultValue)
7032 local
7033 Tpl.Text txt;
7034 Boolean a_useFlatArrayNotation;
7035 Tpl.Text a_stateDerVectorName;
7036 Tpl.Text a_extraFuncsNamespace;
7037 Tpl.Text a_extraFuncsDecl;
7038 Tpl.Text a_extraFuncs;
7039 SimCode.SimCode a_simCode;
7040 Tpl.Text a_tmpVarDecls;
7041 Tpl.Text a_preDefault;
7042 SimCodeFunction.Context a_context;
7043 Option<Values.Value> a_ri_defaultValue;
7044
7045 case ( txt,
7046 Absyn.IDENT(name = "array"),
7047 _,
7048 a_stateDerVectorName,
7049 a_extraFuncsNamespace,
7050 a_extraFuncsDecl,
7051 a_extraFuncs,
7052 _,
7053 a_tmpVarDecls,
7054 a_preDefault,
7055 _,
7056 _ )
7057 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_preDefault);
7058
7059 case ( txt,
7060 _,
7061 a_useFlatArrayNotation,
7062 a_stateDerVectorName,
7063 a_extraFuncsNamespace,
7064 a_extraFuncsDecl,
7065 a_extraFuncs,
7066 a_simCode,
7067 a_tmpVarDecls,
7068 a_preDefault,
7069 a_context,
7070 a_ri_defaultValue )
7071 algorithm
7072 ✗ (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_preDefault) := fun_197(txt, a_ri_defaultValue, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_tmpVarDecls, a_preDefault, a_context);
7073 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_preDefault);
7074 end match;
7075 end fun_198;
7076
7077 protected function fun_199
7078 input Tpl.Text in_txt;
7079 input DAE.Type in_mArg;
7080 input Tpl.Text in_a_reductionBodyExpr;
7081 input Tpl.Text in_a_res;
7082 input Tpl.Text in_a_arrIndex;
7083 input Tpl.Text in_a_varDecls;
7084
7085 output Tpl.Text out_txt;
7086 output Tpl.Text out_a_varDecls;
7087 algorithm
7088 (out_txt, out_a_varDecls) :=
7089 match(in_txt, in_mArg, in_a_reductionBodyExpr, in_a_res, in_a_arrIndex, in_a_varDecls)
7090 local
7091 Tpl.Text txt;
7092 Tpl.Text a_reductionBodyExpr;
7093 Tpl.Text a_res;
7094 Tpl.Text a_arrIndex;
7095 Tpl.Text a_varDecls;
7096 DAE.Type i_ty;
7097 Tpl.Text l_tmp__slice;
7098
7099 case ( txt,
7100 DAE.T_ARRAY(ty = i_ty),
7101 a_reductionBodyExpr,
7102 a_res,
7103 a_arrIndex,
7104 a_varDecls )
7105 algorithm
7106 ✗ (l_tmp__slice, a_varDecls) := tempDecl(Tpl.emptyTxt, "vector<Slice>", a_varDecls);
7107 ✗ txt := Tpl.writeText(txt, l_tmp__slice);
7108 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(".clear();\n"));
7109 ✗ txt := Tpl.writeText(txt, l_tmp__slice);
7110 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".push_back(Slice("));
7111 ✗ txt := Tpl.writeText(txt, a_arrIndex);
7112 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
7113 "++));\n",
7114 "ArraySlice<"
7115 }, false));
7116 ✗ txt := expTypeShort(txt, i_ty);
7117 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(">("));
7118 ✗ txt := Tpl.writeText(txt, a_res);
7119 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
7120 ✗ txt := Tpl.writeText(txt, l_tmp__slice);
7121 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(").assign("));
7122 ✗ txt := Tpl.writeText(txt, a_reductionBodyExpr);
7123 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
7124 ✗ then (txt, a_varDecls);
7125
7126 case ( txt,
7127 _,
7128 a_reductionBodyExpr,
7129 a_res,
7130 a_arrIndex,
7131 a_varDecls )
7132 algorithm
7133 ✗ txt := Tpl.writeText(txt, a_res);
7134 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
7135 ✗ txt := Tpl.writeText(txt, a_arrIndex);
7136 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("++) = "));
7137 ✗ txt := Tpl.writeText(txt, a_reductionBodyExpr);
7138 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
7139 ✗ then (txt, a_varDecls);
7140 end match;
7141 end fun_199;
7142
7143 protected function fun_200
7144 input Tpl.Text in_txt;
7145 input Boolean in_mArg;
7146 input Tpl.Text in_a_reductionBodyExpr;
7147 input Tpl.Text in_a_foldExpPre;
7148 input Tpl.Text in_a_foundFirst;
7149 input Tpl.Text in_a_fExpStr;
7150 input Tpl.Text in_a_res;
7151
7152 output Tpl.Text out_txt;
7153 algorithm
7154 out_txt :=
7155 match(in_txt, in_mArg, in_a_reductionBodyExpr, in_a_foldExpPre, in_a_foundFirst, in_a_fExpStr, in_a_res)
7156 local
7157 Tpl.Text txt;
7158 Tpl.Text a_reductionBodyExpr;
7159 Tpl.Text a_foldExpPre;
7160 Tpl.Text a_foundFirst;
7161 Tpl.Text a_fExpStr;
7162 Tpl.Text a_res;
7163
7164 case ( txt,
7165 true,
7166 _,
7167 _,
7168 _,
7169 a_fExpStr,
7170 a_res )
7171 algorithm
7172 ✗ txt := Tpl.writeText(txt, a_res);
7173 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = "));
7174 ✗ txt := Tpl.writeText(txt, a_fExpStr);
7175 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
7176 then txt;
7177
7178 case ( txt,
7179 _,
7180 a_reductionBodyExpr,
7181 a_foldExpPre,
7182 a_foundFirst,
7183 a_fExpStr,
7184 a_res )
7185 algorithm
7186 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("if ("));
7187 ✗ txt := Tpl.writeText(txt, a_foundFirst);
7188 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
7189 ")\n",
7190 "{\n"
7191 }, true));
7192 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
7193 ✗ txt := Tpl.writeText(txt, a_foldExpPre);
7194 ✗ txt := Tpl.softNewLine(txt);
7195 ✗ txt := Tpl.writeText(txt, a_res);
7196 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = "));
7197 ✗ txt := Tpl.writeText(txt, a_fExpStr);
7198 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(";\n"));
7199 ✗ txt := Tpl.popBlock(txt);
7200 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
7201 "}\n",
7202 "else\n",
7203 "{\n"
7204 }, true));
7205 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
7206 ✗ txt := Tpl.writeText(txt, a_res);
7207 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = "));
7208 ✗ txt := Tpl.writeText(txt, a_reductionBodyExpr);
7209 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(";\n"));
7210 ✗ txt := Tpl.writeText(txt, a_foundFirst);
7211 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(" = 1;\n"));
7212 ✗ txt := Tpl.popBlock(txt);
7213 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("}"));
7214 then txt;
7215 end match;
7216 end fun_200;
7217
7218 protected function fun_201
7219 input Tpl.Text in_txt;
7220 input Option<DAE.Exp> in_a_ri_foldExp;
7221 input Tpl.Text in_a_reductionBodyExpr;
7222 input Tpl.Text in_a_res;
7223 input Tpl.Text in_a_foundFirst;
7224 input Boolean in_a_useFlatArrayNotation;
7225 input Tpl.Text in_a_stateDerVectorName;
7226 input Tpl.Text in_a_extraFuncsNamespace;
7227 input Tpl.Text in_a_extraFuncsDecl;
7228 input Tpl.Text in_a_extraFuncs;
7229 input SimCode.SimCode in_a_simCode;
7230 input Tpl.Text in_a_tmpVarDecls;
7231 input SimCodeFunction.Context in_a_context;
7232
7233 output Tpl.Text out_txt;
7234 output Tpl.Text out_a_stateDerVectorName;
7235 output Tpl.Text out_a_extraFuncsNamespace;
7236 output Tpl.Text out_a_extraFuncsDecl;
7237 output Tpl.Text out_a_extraFuncs;
7238 output Tpl.Text out_a_tmpVarDecls;
7239 algorithm
7240 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_tmpVarDecls) :=
7241 match(in_txt, in_a_ri_foldExp, in_a_reductionBodyExpr, in_a_res, in_a_foundFirst, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_tmpVarDecls, in_a_context)
7242 local
7243 Tpl.Text txt;
7244 Tpl.Text a_reductionBodyExpr;
7245 Tpl.Text a_res;
7246 Tpl.Text a_foundFirst;
7247 Boolean a_useFlatArrayNotation;
7248 Tpl.Text a_stateDerVectorName;
7249 Tpl.Text a_extraFuncsNamespace;
7250 Tpl.Text a_extraFuncsDecl;
7251 Tpl.Text a_extraFuncs;
7252 SimCode.SimCode a_simCode;
7253 Tpl.Text a_tmpVarDecls;
7254 SimCodeFunction.Context a_context;
7255 DAE.Exp i_fExp;
7256 Boolean ret_2;
7257 Tpl.Text l_fExpStr;
7258 Tpl.Text l_foldExpPre;
7259
7260 case ( txt,
7261 SOME(i_fExp),
7262 a_reductionBodyExpr,
7263 a_res,
7264 a_foundFirst,
7265 a_useFlatArrayNotation,
7266 a_stateDerVectorName,
7267 a_extraFuncsNamespace,
7268 a_extraFuncsDecl,
7269 a_extraFuncs,
7270 a_simCode,
7271 a_tmpVarDecls,
7272 a_context )
7273 algorithm
7274 ✗ l_foldExpPre := Tpl.emptyTxt;
7275 ✗ (l_fExpStr, l_foldExpPre, a_tmpVarDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_fExp, a_context, l_foldExpPre, a_tmpVarDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
7276 ✗ ret_2 := Tpl.isEmpty(a_foundFirst);
7277 ✗ txt := fun_200(txt, ret_2, a_reductionBodyExpr, l_foldExpPre, a_foundFirst, l_fExpStr, a_res);
7278 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls);
7279
7280 case ( txt,
7281 _,
7282 _,
7283 _,
7284 _,
7285 _,
7286 a_stateDerVectorName,
7287 a_extraFuncsNamespace,
7288 a_extraFuncsDecl,
7289 a_extraFuncs,
7290 _,
7291 a_tmpVarDecls,
7292 _ )
7293 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls);
7294 end match;
7295 end fun_201;
7296
7297 protected function fun_202
7298 input Tpl.Text in_txt;
7299 input Absyn.Path in_a_ri_path;
7300 input Tpl.Text in_a_foundFirst;
7301 input Boolean in_a_useFlatArrayNotation;
7302 input Tpl.Text in_a_stateDerVectorName;
7303 input Tpl.Text in_a_extraFuncsNamespace;
7304 input Tpl.Text in_a_extraFuncsDecl;
7305 input Tpl.Text in_a_extraFuncs;
7306 input SimCode.SimCode in_a_simCode;
7307 input Tpl.Text in_a_tmpVarDecls;
7308 input SimCodeFunction.Context in_a_context;
7309 input Option<DAE.Exp> in_a_ri_foldExp;
7310 input Tpl.Text in_a_arrIndex;
7311 input Tpl.Text in_a_varDecls;
7312 input DAE.Exp in_a_r_expr;
7313 input Tpl.Text in_a_res;
7314 input Tpl.Text in_a_reductionBodyExpr;
7315 input Tpl.Text in_a_resTail;
7316
7317 output Tpl.Text out_txt;
7318 output Tpl.Text out_a_stateDerVectorName;
7319 output Tpl.Text out_a_extraFuncsNamespace;
7320 output Tpl.Text out_a_extraFuncsDecl;
7321 output Tpl.Text out_a_extraFuncs;
7322 output Tpl.Text out_a_tmpVarDecls;
7323 output Tpl.Text out_a_varDecls;
7324 algorithm
7325 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_tmpVarDecls, out_a_varDecls) :=
7326 match(in_txt, in_a_ri_path, in_a_foundFirst, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_tmpVarDecls, in_a_context, in_a_ri_foldExp, in_a_arrIndex, in_a_varDecls, in_a_r_expr, in_a_res, in_a_reductionBodyExpr, in_a_resTail)
7327 local
7328 Tpl.Text txt;
7329 Tpl.Text a_foundFirst;
7330 Boolean a_useFlatArrayNotation;
7331 Tpl.Text a_stateDerVectorName;
7332 Tpl.Text a_extraFuncsNamespace;
7333 Tpl.Text a_extraFuncsDecl;
7334 Tpl.Text a_extraFuncs;
7335 SimCode.SimCode a_simCode;
7336 Tpl.Text a_tmpVarDecls;
7337 SimCodeFunction.Context a_context;
7338 Option<DAE.Exp> a_ri_foldExp;
7339 Tpl.Text a_arrIndex;
7340 Tpl.Text a_varDecls;
7341 DAE.Exp a_r_expr;
7342 Tpl.Text a_res;
7343 Tpl.Text a_reductionBodyExpr;
7344 Tpl.Text a_resTail;
7345 DAE.Type ret_0;
7346
7347 case ( txt,
7348 Absyn.IDENT(name = "list"),
7349 _,
7350 _,
7351 a_stateDerVectorName,
7352 a_extraFuncsNamespace,
7353 a_extraFuncsDecl,
7354 a_extraFuncs,
7355 _,
7356 a_tmpVarDecls,
7357 _,
7358 _,
7359 _,
7360 a_varDecls,
7361 _,
7362 _,
7363 a_reductionBodyExpr,
7364 a_resTail )
7365 algorithm
7366 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("*"));
7367 ✗ txt := Tpl.writeText(txt, a_resTail);
7368 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = mmc_mk_cons("));
7369 ✗ txt := Tpl.writeText(txt, a_reductionBodyExpr);
7370 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(",0);\n"));
7371 ✗ txt := Tpl.writeText(txt, a_resTail);
7372 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = &MMC_CDR(*"));
7373 ✗ txt := Tpl.writeText(txt, a_resTail);
7374 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
7375 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_varDecls);
7376
7377 case ( txt,
7378 Absyn.IDENT(name = "listReverse"),
7379 _,
7380 _,
7381 a_stateDerVectorName,
7382 a_extraFuncsNamespace,
7383 a_extraFuncsDecl,
7384 a_extraFuncs,
7385 _,
7386 a_tmpVarDecls,
7387 _,
7388 _,
7389 _,
7390 a_varDecls,
7391 _,
7392 a_res,
7393 a_reductionBodyExpr,
7394 _ )
7395 algorithm
7396 ✗ txt := Tpl.writeText(txt, a_res);
7397 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = mmc_mk_cons("));
7398 ✗ txt := Tpl.writeText(txt, a_reductionBodyExpr);
7399 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(","));
7400 ✗ txt := Tpl.writeText(txt, a_res);
7401 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
7402 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_varDecls);
7403
7404 case ( txt,
7405 Absyn.IDENT(name = "array"),
7406 _,
7407 _,
7408 a_stateDerVectorName,
7409 a_extraFuncsNamespace,
7410 a_extraFuncsDecl,
7411 a_extraFuncs,
7412 _,
7413 a_tmpVarDecls,
7414 _,
7415 _,
7416 a_arrIndex,
7417 a_varDecls,
7418 a_r_expr,
7419 a_res,
7420 a_reductionBodyExpr,
7421 _ )
7422 algorithm
7423 ✗ ret_0 := Expression.typeof(a_r_expr);
7424 ✗ (txt, a_varDecls) := fun_199(txt, ret_0, a_reductionBodyExpr, a_res, a_arrIndex, a_varDecls);
7425 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_varDecls);
7426
7427 case ( txt,
7428 _,
7429 a_foundFirst,
7430 a_useFlatArrayNotation,
7431 a_stateDerVectorName,
7432 a_extraFuncsNamespace,
7433 a_extraFuncsDecl,
7434 a_extraFuncs,
7435 a_simCode,
7436 a_tmpVarDecls,
7437 a_context,
7438 a_ri_foldExp,
7439 _,
7440 a_varDecls,
7441 _,
7442 a_res,
7443 a_reductionBodyExpr,
7444 _ )
7445 algorithm
7446 ✗ (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls) := fun_201(txt, a_ri_foldExp, a_reductionBodyExpr, a_res, a_foundFirst, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_tmpVarDecls, a_context);
7447 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_varDecls);
7448 end match;
7449 end fun_202;
7450
7451 protected function fun_203
7452 input Tpl.Text in_txt;
7453 input Boolean in_mArg;
7454 input Tpl.Text in_a_firstIndex;
7455
7456 output Tpl.Text out_txt;
7457 algorithm
7458 out_txt :=
7459 match(in_txt, in_mArg, in_a_firstIndex)
7460 local
7461 Tpl.Text txt;
7462 Tpl.Text a_firstIndex;
7463
7464 case ( txt,
7465 true,
7466 _ )
7467 then txt;
7468
7469 case ( txt,
7470 _,
7471 a_firstIndex )
7472 algorithm
7473 ✗ txt := Tpl.writeText(txt, a_firstIndex);
7474 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = 1;"));
7475 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
7476 then txt;
7477 end match;
7478 end fun_203;
7479
7480 protected function fun_204
7481 input Tpl.Text in_txt;
7482 input Option<DAE.Exp> in_a_iter_guardExp;
7483 input Boolean in_a_useFlatArrayNotation;
7484 input Tpl.Text in_a_stateDerVectorName;
7485 input Tpl.Text in_a_extraFuncsNamespace;
7486 input Tpl.Text in_a_extraFuncsDecl;
7487 input Tpl.Text in_a_extraFuncs;
7488 input SimCode.SimCode in_a_simCode;
7489 input Tpl.Text in_a_tmpVarDecls;
7490 input Tpl.Text in_a_guardExpPre;
7491 input SimCodeFunction.Context in_a_context;
7492
7493 output Tpl.Text out_txt;
7494 output Tpl.Text out_a_stateDerVectorName;
7495 output Tpl.Text out_a_extraFuncsNamespace;
7496 output Tpl.Text out_a_extraFuncsDecl;
7497 output Tpl.Text out_a_extraFuncs;
7498 output Tpl.Text out_a_tmpVarDecls;
7499 output Tpl.Text out_a_guardExpPre;
7500 algorithm
7501 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_tmpVarDecls, out_a_guardExpPre) :=
7502 match(in_txt, in_a_iter_guardExp, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_tmpVarDecls, in_a_guardExpPre, in_a_context)
7503 local
7504 Tpl.Text txt;
7505 Boolean a_useFlatArrayNotation;
7506 Tpl.Text a_stateDerVectorName;
7507 Tpl.Text a_extraFuncsNamespace;
7508 Tpl.Text a_extraFuncsDecl;
7509 Tpl.Text a_extraFuncs;
7510 SimCode.SimCode a_simCode;
7511 Tpl.Text a_tmpVarDecls;
7512 Tpl.Text a_guardExpPre;
7513 SimCodeFunction.Context a_context;
7514 DAE.Exp i_grd;
7515
7516 case ( txt,
7517 SOME(i_grd),
7518 a_useFlatArrayNotation,
7519 a_stateDerVectorName,
7520 a_extraFuncsNamespace,
7521 a_extraFuncsDecl,
7522 a_extraFuncs,
7523 a_simCode,
7524 a_tmpVarDecls,
7525 a_guardExpPre,
7526 a_context )
7527 algorithm
7528 ✗ (txt, a_guardExpPre, a_tmpVarDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_grd, a_context, a_guardExpPre, a_tmpVarDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
7529 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_guardExpPre);
7530
7531 case ( txt,
7532 _,
7533 _,
7534 a_stateDerVectorName,
7535 a_extraFuncsNamespace,
7536 a_extraFuncsDecl,
7537 a_extraFuncs,
7538 _,
7539 a_tmpVarDecls,
7540 a_guardExpPre,
7541 _ )
7542 algorithm
7543 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("1"));
7544 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_guardExpPre);
7545 end match;
7546 end fun_204;
7547
7548 protected function fun_205
7549 input Tpl.Text in_txt;
7550 input DAE.Type in_a_iter_ty;
7551 input Tpl.Text in_a_firstIndex;
7552 input Tpl.Text in_a_loopVar;
7553
7554 output Tpl.Text out_txt;
7555 algorithm
7556 out_txt :=
7557 match(in_txt, in_a_iter_ty, in_a_firstIndex, in_a_loopVar)
7558 local
7559 Tpl.Text txt;
7560 Tpl.Text a_firstIndex;
7561 Tpl.Text a_loopVar;
7562 ClassInf.State i_record__state;
7563 Absyn.Path ret_1;
7564 Tpl.Text l_rec__name;
7565
7566 case ( txt,
7567 DAE.T_ARRAY(ty = DAE.T_COMPLEX(complexClassType = i_record__state)),
7568 a_firstIndex,
7569 a_loopVar )
7570 algorithm
7571 ✗ ret_1 := ClassInfUtil.getStateName(i_record__state);
7572 ✗ l_rec__name := CodegenUtil.underscorePath(Tpl.emptyTxt, ret_1);
7573 ✗ txt := Tpl.writeText(txt, l_rec__name);
7574 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_array_get("));
7575 ✗ txt := Tpl.writeText(txt, a_loopVar);
7576 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(", 1, "));
7577 ✗ txt := Tpl.writeText(txt, a_firstIndex);
7578 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("++)"));
7579 then txt;
7580
7581 case ( txt,
7582 _,
7583 a_firstIndex,
7584 a_loopVar )
7585 algorithm
7586 ✗ txt := Tpl.writeText(txt, a_loopVar);
7587 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("( "));
7588 ✗ txt := Tpl.writeText(txt, a_firstIndex);
7589 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("++)"));
7590 then txt;
7591 end match;
7592 end fun_205;
7593
7594 protected function lm_206
7595 input output Tpl.Text txt;
7596 input DAE.ReductionIterators items;
7597 input Tpl.Text a_endLoop;
7598 input Boolean a_useFlatArrayNotation;
7599 input output Tpl.Text a_stateDerVectorName;
7600 input output Tpl.Text a_extraFuncsNamespace;
7601 input output Tpl.Text a_extraFuncsDecl;
7602 input output Tpl.Text a_extraFuncs;
7603 input SimCode.SimCode a_simCode;
7604 input output Tpl.Text a_rangeExpPre;
7605 input SimCodeFunction.Context a_context;
7606 input output Tpl.Text a_tmpVarDecls;
7607 algorithm
7608 ✗ for lstElt_206 in items loop
7609 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_rangeExpPre, a_tmpVarDecls) := match lstElt_206
7610 local
7611 DAE.Type i_iter_ty;
7612 Option<DAE.Exp> i_iter_guardExp;
7613 String i_iter_id;
7614 DAE.Type i_ty;
7615 DAE.Exp i_iter_exp;
7616 Tpl.Text l_addr;
7617 Tpl.Text l_guardExp;
7618 Tpl.Text l_iteratorName;
7619 Tpl.Text l_empty;
7620 Tpl.Text l_guardCond;
7621 Boolean ret_7;
7622 Tpl.Text l_rangeExp;
7623 Tpl.Text l_firstIndex;
7624 Tpl.Text l_guardExpPre;
7625 Tpl.Text l_loopVar;
7626 Tpl.Text l_arrayType;
7627 Tpl.Text l_ty__str;
7628 Tpl.Text l_identType;
7629
7630 case DAE.REDUCTIONITER(exp = i_iter_exp, ty = (i_iter_ty as i_ty), id = i_iter_id, guardExp = i_iter_guardExp)
7631 algorithm
7632 ✗ l_identType := expTypeFromExpModelica(Tpl.emptyTxt, i_iter_exp);
7633 ✗ l_ty__str := expTypeShort(Tpl.emptyTxt, i_ty);
7634 ✗ l_arrayType := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("DynArrayDim1<"));
7635 ✗ l_arrayType := Tpl.writeText(l_arrayType, l_identType);
7636 ✗ l_arrayType := Tpl.writeTok(l_arrayType, Tpl.ST_STRING(">"));
7637 ✗ l_loopVar := Tpl.writeStr(Tpl.emptyTxt, i_iter_id);
7638 ✗ l_loopVar := Tpl.writeTok(l_loopVar, Tpl.ST_STRING("_loopVar"));
7639 ✗ l_guardExpPre := Tpl.emptyTxt;
7640 ✗ a_tmpVarDecls := Tpl.writeText(a_tmpVarDecls, l_arrayType);
7641 ✗ a_tmpVarDecls := Tpl.writeTok(a_tmpVarDecls, Tpl.ST_STRING(" "));
7642 ✗ a_tmpVarDecls := Tpl.writeText(a_tmpVarDecls, l_loopVar);
7643 ✗ a_tmpVarDecls := Tpl.writeTok(a_tmpVarDecls, Tpl.ST_STRING(";/*testloopvar*/"));
7644 ✗ a_tmpVarDecls := Tpl.writeTok(a_tmpVarDecls, Tpl.ST_NEW_LINE());
7645 ✗ (l_firstIndex, a_tmpVarDecls) := tempDecl(Tpl.emptyTxt, "int", a_tmpVarDecls);
7646 ✗ (l_rangeExp, a_rangeExpPre, a_tmpVarDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_iter_exp, a_context, a_rangeExpPre, a_tmpVarDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
7647 ✗ a_rangeExpPre := Tpl.writeText(a_rangeExpPre, l_loopVar);
7648 ✗ a_rangeExpPre := Tpl.writeTok(a_rangeExpPre, Tpl.ST_STRING(" = "));
7649 ✗ a_rangeExpPre := Tpl.writeText(a_rangeExpPre, l_rangeExp);
7650 ✗ a_rangeExpPre := Tpl.writeTok(a_rangeExpPre, Tpl.ST_STRING("/*testloopvar2*/;"));
7651 ✗ a_rangeExpPre := Tpl.writeTok(a_rangeExpPre, Tpl.ST_NEW_LINE());
7652 ✗ ret_7 := Tpl.isEmpty(l_firstIndex);
7653 ✗ a_rangeExpPre := fun_203(a_rangeExpPre, ret_7, l_firstIndex);
7654 ✗ (l_guardCond, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, l_guardExpPre) := fun_204(Tpl.emptyTxt, i_iter_guardExp, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_tmpVarDecls, l_guardExpPre, a_context);
7655 ✗ l_empty := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("0 == ("));
7656 ✗ l_empty := Tpl.writeText(l_empty, l_loopVar);
7657 ✗ l_empty := Tpl.writeTok(l_empty, Tpl.ST_STRING(".getDim(2))"));
7658 ✗ l_iteratorName := contextIteratorName(Tpl.emptyTxt, i_iter_id, a_context);
7659 ✗ a_tmpVarDecls := Tpl.writeText(a_tmpVarDecls, l_identType);
7660 ✗ a_tmpVarDecls := Tpl.writeTok(a_tmpVarDecls, Tpl.ST_STRING(" "));
7661 ✗ a_tmpVarDecls := Tpl.writeText(a_tmpVarDecls, l_iteratorName);
7662 ✗ a_tmpVarDecls := Tpl.writeTok(a_tmpVarDecls, Tpl.ST_STRING(";"));
7663 ✗ a_tmpVarDecls := Tpl.writeTok(a_tmpVarDecls, Tpl.ST_NEW_LINE());
7664 ✗ l_guardExp := Tpl.writeText(Tpl.emptyTxt, l_guardExpPre);
7665 ✗ l_guardExp := Tpl.softNewLine(l_guardExp);
7666 ✗ l_guardExp := Tpl.writeTok(l_guardExp, Tpl.ST_STRING("if("));
7667 ✗ l_guardExp := Tpl.writeText(l_guardExp, l_guardCond);
7668 ✗ l_guardExp := Tpl.writeTok(l_guardExp, Tpl.ST_LINE(") { /* found non-guarded */\n"));
7669 ✗ l_guardExp := Tpl.pushBlock(l_guardExp, Tpl.BT_INDENT(2));
7670 ✗ l_guardExp := Tpl.writeText(l_guardExp, a_endLoop);
7671 ✗ l_guardExp := Tpl.writeTok(l_guardExp, Tpl.ST_STRING_LIST({
7672 "--;\n",
7673 "break;\n"
7674 }, true));
7675 ✗ l_guardExp := Tpl.popBlock(l_guardExp);
7676 ✗ l_guardExp := Tpl.writeTok(l_guardExp, Tpl.ST_STRING("}"));
7677 ✗ l_addr := fun_205(Tpl.emptyTxt, i_iter_ty, l_firstIndex, l_loopVar);
7678 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("while("));
7679 ✗ txt := Tpl.writeText(txt, l_firstIndex);
7680 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" <= "));
7681 ✗ txt := Tpl.writeText(txt, l_loopVar);
7682 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(".getDim(1)) {\n"));
7683 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
7684 ✗ txt := Tpl.writeText(txt, l_iteratorName);
7685 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = "));
7686 ✗ txt := Tpl.writeText(txt, l_addr);
7687 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(";\n"));
7688 ✗ txt := Tpl.writeText(txt, l_guardExp);
7689 ✗ txt := Tpl.softNewLine(txt);
7690 ✗ txt := Tpl.popBlock(txt);
7691 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("}"));
7692 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_rangeExpPre, a_tmpVarDecls);
7693
7694 case _
7695 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_rangeExpPre, a_tmpVarDecls);
7696 end match;
7697 end for;
7698 end lm_206;
7699
7700 protected function lm_207
7701 input output Tpl.Text txt;
7702 input DAE.ReductionIterators items;
7703 input Tpl.Text a_length;
7704 input output Tpl.Text a_rangeExpPre;
7705 algorithm
7706 ✗ for lstElt_207 in items loop
7707 (txt, a_rangeExpPre) := match lstElt_207
7708 local
7709 String i_iter_id;
7710 Tpl.Text l_loopVar;
7711
7712 case DAE.REDUCTIONITER(id = i_iter_id)
7713 algorithm
7714 ✗ l_loopVar := Tpl.writeStr(Tpl.emptyTxt, i_iter_id);
7715 ✗ l_loopVar := Tpl.writeTok(l_loopVar, Tpl.ST_STRING("_loopVar"));
7716 ✗ a_rangeExpPre := Tpl.writeText(a_rangeExpPre, a_length);
7717 ✗ a_rangeExpPre := Tpl.writeTok(a_rangeExpPre, Tpl.ST_STRING(" = max("));
7718 ✗ a_rangeExpPre := Tpl.writeText(a_rangeExpPre, a_length);
7719 ✗ a_rangeExpPre := Tpl.writeTok(a_rangeExpPre, Tpl.ST_STRING(", "));
7720 ✗ a_rangeExpPre := Tpl.writeText(a_rangeExpPre, l_loopVar);
7721 ✗ a_rangeExpPre := Tpl.writeTok(a_rangeExpPre, Tpl.ST_STRING(".getDim(1));"));
7722 ✗ a_rangeExpPre := Tpl.writeTok(a_rangeExpPre, Tpl.ST_NEW_LINE());
7723 then (txt, a_rangeExpPre);
7724
7725 case _
7726 then (txt, a_rangeExpPre);
7727 end match;
7728 end for;
7729 end lm_207;
7730
7731 protected function fun_208
7732 input Tpl.Text in_txt;
7733 input DAE.Dimension in_a_dim;
7734 input DAE.Exp in_a_r_expr;
7735 input Boolean in_a_useFlatArrayNotation;
7736 input Tpl.Text in_a_stateDerVectorName;
7737 input Tpl.Text in_a_extraFuncsNamespace;
7738 input Tpl.Text in_a_extraFuncsDecl;
7739 input Tpl.Text in_a_extraFuncs;
7740 input SimCode.SimCode in_a_simCode;
7741 input Tpl.Text in_a_tmpVarDecls;
7742 input Tpl.Text in_a_rangeExpPre;
7743 input SimCodeFunction.Context in_a_context;
7744 input Tpl.Text in_a_dim__vec;
7745
7746 output Tpl.Text out_txt;
7747 output Tpl.Text out_a_stateDerVectorName;
7748 output Tpl.Text out_a_extraFuncsNamespace;
7749 output Tpl.Text out_a_extraFuncsDecl;
7750 output Tpl.Text out_a_extraFuncs;
7751 output Tpl.Text out_a_tmpVarDecls;
7752 output Tpl.Text out_a_rangeExpPre;
7753 algorithm
7754 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_tmpVarDecls, out_a_rangeExpPre) :=
7755 match(in_txt, in_a_dim, in_a_r_expr, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_tmpVarDecls, in_a_rangeExpPre, in_a_context, in_a_dim__vec)
7756 local
7757 Tpl.Text txt;
7758 DAE.Exp a_r_expr;
7759 Boolean a_useFlatArrayNotation;
7760 Tpl.Text a_stateDerVectorName;
7761 Tpl.Text a_extraFuncsNamespace;
7762 Tpl.Text a_extraFuncsDecl;
7763 Tpl.Text a_extraFuncs;
7764 SimCode.SimCode a_simCode;
7765 Tpl.Text a_tmpVarDecls;
7766 Tpl.Text a_rangeExpPre;
7767 SimCodeFunction.Context a_context;
7768 Tpl.Text a_dim__vec;
7769 DAE.Exp i_exp;
7770 Integer i_size;
7771 Integer i_integer;
7772 Tpl.Text txt_1;
7773 String ret_2;
7774 DAE.Type ret_1;
7775 Tpl.Text l_val;
7776
7777 case ( txt,
7778 DAE.DIM_INTEGER(integer = i_integer),
7779 _,
7780 _,
7781 a_stateDerVectorName,
7782 a_extraFuncsNamespace,
7783 a_extraFuncsDecl,
7784 a_extraFuncs,
7785 _,
7786 a_tmpVarDecls,
7787 a_rangeExpPre,
7788 _,
7789 a_dim__vec )
7790 algorithm
7791 ✗ txt := Tpl.writeText(txt, a_dim__vec);
7792 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".push_back("));
7793 ✗ txt := Tpl.writeStr(txt, intString(i_integer));
7794 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
7795 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_rangeExpPre);
7796
7797 case ( txt,
7798 DAE.DIM_BOOLEAN(),
7799 _,
7800 _,
7801 a_stateDerVectorName,
7802 a_extraFuncsNamespace,
7803 a_extraFuncsDecl,
7804 a_extraFuncs,
7805 _,
7806 a_tmpVarDecls,
7807 a_rangeExpPre,
7808 _,
7809 a_dim__vec )
7810 algorithm
7811 ✗ txt := Tpl.writeText(txt, a_dim__vec);
7812 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".push_back(2)"));
7813 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_rangeExpPre);
7814
7815 case ( txt,
7816 DAE.DIM_ENUM(size = i_size),
7817 _,
7818 _,
7819 a_stateDerVectorName,
7820 a_extraFuncsNamespace,
7821 a_extraFuncsDecl,
7822 a_extraFuncs,
7823 _,
7824 a_tmpVarDecls,
7825 a_rangeExpPre,
7826 _,
7827 a_dim__vec )
7828 algorithm
7829 ✗ txt := Tpl.writeText(txt, a_dim__vec);
7830 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".push_back("));
7831 ✗ txt := Tpl.writeStr(txt, intString(i_size));
7832 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
7833 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_rangeExpPre);
7834
7835 case ( txt,
7836 DAE.DIM_EXP(exp = i_exp),
7837 _,
7838 a_useFlatArrayNotation,
7839 a_stateDerVectorName,
7840 a_extraFuncsNamespace,
7841 a_extraFuncsDecl,
7842 a_extraFuncs,
7843 a_simCode,
7844 a_tmpVarDecls,
7845 a_rangeExpPre,
7846 a_context,
7847 a_dim__vec )
7848 algorithm
7849 ✗ (l_val, a_rangeExpPre, a_tmpVarDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_exp, a_context, a_rangeExpPre, a_tmpVarDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
7850 ✗ txt := Tpl.writeText(txt, a_dim__vec);
7851 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".push_back("));
7852 ✗ txt := Tpl.writeText(txt, l_val);
7853 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
7854 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_rangeExpPre);
7855
7856 case ( txt,
7857 _,
7858 a_r_expr,
7859 _,
7860 a_stateDerVectorName,
7861 a_extraFuncsNamespace,
7862 a_extraFuncsDecl,
7863 a_extraFuncs,
7864 _,
7865 a_tmpVarDecls,
7866 a_rangeExpPre,
7867 _,
7868 _ )
7869 algorithm
7870 ✗ txt_1 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("array reduction unable to generate code for element of unknown dimension sizes; type "));
7871 ✗ ret_1 := Expression.typeof(a_r_expr);
7872 ✗ ret_2 := TypesDump.unparseType(ret_1);
7873 ✗ txt_1 := Tpl.writeStr(txt_1, ret_2);
7874 ✗ txt_1 := Tpl.writeTok(txt_1, Tpl.ST_STRING(": "));
7875 ✗ txt_1 := ExpressionDumpTpl.dumpExp(txt_1, a_r_expr, "\"");
7876 ✗ txt := error(txt, Tpl.sourceInfo("CodegenCppCommon.tpl", 1186, 24), Tpl.textString(txt_1));
7877 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_rangeExpPre);
7878 end match;
7879 end fun_208;
7880
7881 protected function lm_209
7882 input output Tpl.Text txt;
7883 input DAE.Dimensions items;
7884 input DAE.Exp a_r_expr;
7885 input Boolean a_useFlatArrayNotation;
7886 input output Tpl.Text a_stateDerVectorName;
7887 input output Tpl.Text a_extraFuncsNamespace;
7888 input output Tpl.Text a_extraFuncsDecl;
7889 input output Tpl.Text a_extraFuncs;
7890 input SimCode.SimCode a_simCode;
7891 input output Tpl.Text a_tmpVarDecls;
7892 input output Tpl.Text a_rangeExpPre;
7893 input SimCodeFunction.Context a_context;
7894 input Tpl.Text a_dim__vec;
7895 algorithm
7896 ✗ for lstElt_209 in items loop
7897 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_rangeExpPre) := match lstElt_209
7898 local
7899 DAE.Dimension i_dim;
7900
7901 case i_dim
7902 algorithm
7903 ✗ (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_rangeExpPre) := fun_208(txt, i_dim, a_r_expr, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_tmpVarDecls, a_rangeExpPre, a_context, a_dim__vec);
7904 ✗ txt := Tpl.nextIter(txt);
7905 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_rangeExpPre);
7906 end match;
7907 end for;
7908 end lm_209;
7909
7910 protected function fun_210
7911 input Tpl.Text in_txt;
7912 input DAE.Type in_mArg;
7913 input Tpl.Text in_a_res;
7914 input Tpl.Text in_a_length;
7915 input DAE.Exp in_a_r_expr;
7916 input Boolean in_a_useFlatArrayNotation;
7917 input Tpl.Text in_a_stateDerVectorName;
7918 input Tpl.Text in_a_extraFuncsNamespace;
7919 input Tpl.Text in_a_extraFuncsDecl;
7920 input Tpl.Text in_a_extraFuncs;
7921 input SimCode.SimCode in_a_simCode;
7922 input Tpl.Text in_a_rangeExpPre;
7923 input SimCodeFunction.Context in_a_context;
7924 input Tpl.Text in_a_tmpVarDecls;
7925
7926 output Tpl.Text out_txt;
7927 output Tpl.Text out_a_stateDerVectorName;
7928 output Tpl.Text out_a_extraFuncsNamespace;
7929 output Tpl.Text out_a_extraFuncsDecl;
7930 output Tpl.Text out_a_extraFuncs;
7931 output Tpl.Text out_a_rangeExpPre;
7932 output Tpl.Text out_a_tmpVarDecls;
7933 algorithm
7934 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_rangeExpPre, out_a_tmpVarDecls) :=
7935 match(in_txt, in_mArg, in_a_res, in_a_length, in_a_r_expr, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_rangeExpPre, in_a_context, in_a_tmpVarDecls)
7936 local
7937 Tpl.Text txt;
7938 Tpl.Text a_res;
7939 Tpl.Text a_length;
7940 DAE.Exp a_r_expr;
7941 Boolean a_useFlatArrayNotation;
7942 Tpl.Text a_stateDerVectorName;
7943 Tpl.Text a_extraFuncsNamespace;
7944 Tpl.Text a_extraFuncsDecl;
7945 Tpl.Text a_extraFuncs;
7946 SimCode.SimCode a_simCode;
7947 Tpl.Text a_rangeExpPre;
7948 SimCodeFunction.Context a_context;
7949 Tpl.Text a_tmpVarDecls;
7950 DAE.Dimensions i_dims;
7951 Tpl.Text l_dimSizes;
7952 Tpl.Text l_dim__vec;
7953
7954 case ( txt,
7955 DAE.T_ARRAY(dims = i_dims),
7956 a_res,
7957 a_length,
7958 a_r_expr,
7959 a_useFlatArrayNotation,
7960 a_stateDerVectorName,
7961 a_extraFuncsNamespace,
7962 a_extraFuncsDecl,
7963 a_extraFuncs,
7964 a_simCode,
7965 a_rangeExpPre,
7966 a_context,
7967 a_tmpVarDecls )
7968 algorithm
7969 ✗ (l_dim__vec, a_tmpVarDecls) := tempDecl(Tpl.emptyTxt, "std::vector<size_t>", a_tmpVarDecls);
7970 ✗ l_dimSizes := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING("; ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
7971 ✗ (l_dimSizes, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_rangeExpPre) := lm_209(l_dimSizes, i_dims, a_r_expr, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_tmpVarDecls, a_rangeExpPre, a_context, l_dim__vec);
7972 ✗ l_dimSizes := Tpl.popIter(l_dimSizes);
7973 ✗ txt := Tpl.writeText(txt, l_dim__vec);
7974 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".push_back("));
7975 ✗ txt := Tpl.writeText(txt, a_length);
7976 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(");\n"));
7977 ✗ txt := Tpl.writeText(txt, l_dimSizes);
7978 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(";\n"));
7979 ✗ txt := Tpl.writeText(txt, a_res);
7980 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".setDims("));
7981 ✗ txt := Tpl.writeText(txt, l_dim__vec);
7982 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
7983 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_rangeExpPre, a_tmpVarDecls);
7984
7985 case ( txt,
7986 _,
7987 a_res,
7988 a_length,
7989 _,
7990 _,
7991 a_stateDerVectorName,
7992 a_extraFuncsNamespace,
7993 a_extraFuncsDecl,
7994 a_extraFuncs,
7995 _,
7996 a_rangeExpPre,
7997 _,
7998 a_tmpVarDecls )
7999 algorithm
8000 ✗ txt := Tpl.writeText(txt, a_res);
8001 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".setDims("));
8002 ✗ txt := Tpl.writeText(txt, a_length);
8003 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
8004 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_rangeExpPre, a_tmpVarDecls);
8005 end match;
8006 end fun_210;
8007
8008 protected function fun_211
8009 input Tpl.Text in_txt;
8010 input Boolean in_mArg;
8011 input Absyn.Path in_a_ri_path;
8012 input Tpl.Text in_a_foundFirst;
8013 input Tpl.Text in_a_defaultValue;
8014 input Tpl.Text in_a_res;
8015 input Tpl.Text in_a_preDefault;
8016
8017 output Tpl.Text out_txt;
8018 algorithm
8019 out_txt :=
8020 match(in_txt, in_mArg, in_a_ri_path, in_a_foundFirst, in_a_defaultValue, in_a_res, in_a_preDefault)
8021 local
8022 Tpl.Text txt;
8023 Absyn.Path a_ri_path;
8024 Tpl.Text a_foundFirst;
8025 Tpl.Text a_defaultValue;
8026 Tpl.Text a_res;
8027 Tpl.Text a_preDefault;
8028
8029 case ( txt,
8030 true,
8031 _,
8032 _,
8033 a_defaultValue,
8034 a_res,
8035 a_preDefault )
8036 algorithm
8037 ✗ txt := Tpl.writeText(txt, a_preDefault);
8038 ✗ txt := Tpl.softNewLine(txt);
8039 ✗ txt := Tpl.writeText(txt, a_res);
8040 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = "));
8041 ✗ txt := Tpl.writeText(txt, a_defaultValue);
8042 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("; /* defaultValue */"));
8043 then txt;
8044
8045 case ( txt,
8046 _,
8047 a_ri_path,
8048 a_foundFirst,
8049 _,
8050 _,
8051 _ )
8052 algorithm
8053 ✗ txt := Tpl.writeText(txt, a_foundFirst);
8054 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = 0; /* "));
8055 ✗ txt := CodegenUtil.dotPath(txt, a_ri_path);
8056 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" lacks default-value */"));
8057 then txt;
8058 end match;
8059 end fun_211;
8060
8061 protected function fun_212
8062 input Tpl.Text in_txt;
8063 input Absyn.Path in_a_ri_path;
8064 input Tpl.Text in_a_defaultValue;
8065 input Tpl.Text in_a_preDefault;
8066 input Tpl.Text in_a_foundFirst;
8067 input Tpl.Text in_a_res;
8068 input Boolean in_a_useFlatArrayNotation;
8069 input Tpl.Text in_a_stateDerVectorName;
8070 input Tpl.Text in_a_extraFuncsNamespace;
8071 input Tpl.Text in_a_extraFuncsDecl;
8072 input Tpl.Text in_a_extraFuncs;
8073 input SimCode.SimCode in_a_simCode;
8074 input SimCodeFunction.Context in_a_context;
8075 input DAE.Exp in_a_r_expr;
8076 input Tpl.Text in_a_arrIndex;
8077 input DAE.ReductionIterators in_a_iterators;
8078 input Tpl.Text in_a_rangeExpPre;
8079 input Tpl.Text in_a_tmpVarDecls;
8080
8081 output Tpl.Text out_txt;
8082 output Tpl.Text out_a_stateDerVectorName;
8083 output Tpl.Text out_a_extraFuncsNamespace;
8084 output Tpl.Text out_a_extraFuncsDecl;
8085 output Tpl.Text out_a_extraFuncs;
8086 output Tpl.Text out_a_rangeExpPre;
8087 output Tpl.Text out_a_tmpVarDecls;
8088 algorithm
8089 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_rangeExpPre, out_a_tmpVarDecls) :=
8090 match(in_txt, in_a_ri_path, in_a_defaultValue, in_a_preDefault, in_a_foundFirst, in_a_res, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_context, in_a_r_expr, in_a_arrIndex, in_a_iterators, in_a_rangeExpPre, in_a_tmpVarDecls)
8091 local
8092 Tpl.Text txt;
8093 Tpl.Text a_defaultValue;
8094 Tpl.Text a_preDefault;
8095 Tpl.Text a_foundFirst;
8096 Tpl.Text a_res;
8097 Boolean a_useFlatArrayNotation;
8098 Tpl.Text a_stateDerVectorName;
8099 Tpl.Text a_extraFuncsNamespace;
8100 Tpl.Text a_extraFuncsDecl;
8101 Tpl.Text a_extraFuncs;
8102 SimCode.SimCode a_simCode;
8103 SimCodeFunction.Context a_context;
8104 DAE.Exp a_r_expr;
8105 Tpl.Text a_arrIndex;
8106 DAE.ReductionIterators a_iterators;
8107 Tpl.Text a_rangeExpPre;
8108 Tpl.Text a_tmpVarDecls;
8109 Absyn.Path i_ri_path;
8110 Boolean ret_3;
8111 DAE.Type ret_2;
8112 Tpl.Text l_0__;
8113 Tpl.Text l_length;
8114
8115 case ( txt,
8116 Absyn.IDENT(name = "array"),
8117 _,
8118 _,
8119 _,
8120 a_res,
8121 a_useFlatArrayNotation,
8122 a_stateDerVectorName,
8123 a_extraFuncsNamespace,
8124 a_extraFuncsDecl,
8125 a_extraFuncs,
8126 a_simCode,
8127 a_context,
8128 a_r_expr,
8129 a_arrIndex,
8130 a_iterators,
8131 a_rangeExpPre,
8132 a_tmpVarDecls )
8133 algorithm
8134 ✗ (l_length, a_tmpVarDecls) := tempDecl(Tpl.emptyTxt, "int", a_tmpVarDecls);
8135 ✗ a_rangeExpPre := Tpl.writeText(a_rangeExpPre, l_length);
8136 ✗ a_rangeExpPre := Tpl.writeTok(a_rangeExpPre, Tpl.ST_STRING(" = 0;"));
8137 ✗ a_rangeExpPre := Tpl.writeTok(a_rangeExpPre, Tpl.ST_NEW_LINE());
8138 ✗ (l_0__, a_rangeExpPre) := lm_207(Tpl.emptyTxt, a_iterators, l_length, a_rangeExpPre);
8139 ✗ txt := Tpl.writeText(txt, a_arrIndex);
8140 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(" = 1;\n"));
8141 ✗ ret_2 := Expression.typeof(a_r_expr);
8142 ✗ (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_rangeExpPre, a_tmpVarDecls) := fun_210(txt, ret_2, a_res, l_length, a_r_expr, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_rangeExpPre, a_context, a_tmpVarDecls);
8143 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_rangeExpPre, a_tmpVarDecls);
8144
8145 case ( txt,
8146 i_ri_path,
8147 a_defaultValue,
8148 a_preDefault,
8149 a_foundFirst,
8150 a_res,
8151 _,
8152 a_stateDerVectorName,
8153 a_extraFuncsNamespace,
8154 a_extraFuncsDecl,
8155 a_extraFuncs,
8156 _,
8157 _,
8158 _,
8159 _,
8160 _,
8161 a_rangeExpPre,
8162 a_tmpVarDecls )
8163 algorithm
8164 ✗ ret_3 := Tpl.isEmpty(a_foundFirst);
8165 ✗ txt := fun_211(txt, ret_3, i_ri_path, a_foundFirst, a_defaultValue, a_res, a_preDefault);
8166 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_rangeExpPre, a_tmpVarDecls);
8167 end match;
8168 end fun_212;
8169
8170 protected function fun_213
8171 input Tpl.Text in_txt;
8172 input DAE.ReductionIterators in_a_iterators;
8173 input Tpl.Text in_a_endLoop;
8174
8175 output Tpl.Text out_txt;
8176 algorithm
8177 out_txt :=
8178 match(in_txt, in_a_iterators, in_a_endLoop)
8179 local
8180 Tpl.Text txt;
8181 Tpl.Text a_endLoop;
8182 DAE.ReductionIterators i_iterators;
8183 Integer ret_0;
8184
8185 case ( txt,
8186 (i_iterators as _ :: _),
8187 a_endLoop )
8188 algorithm
8189 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("else if ("));
8190 ✗ txt := Tpl.writeText(txt, a_endLoop);
8191 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" == "));
8192 ✗ ret_0 := listLength(i_iterators);
8193 ✗ txt := Tpl.writeStr(txt, intString(ret_0));
8194 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
8195 ") {\n",
8196 " break;\n",
8197 "} else {\n",
8198 " throw ModelicaSimulationError(MODEL_ARRAY_FUNCTION,\"Internal error\");\n",
8199 "}"
8200 }, false));
8201 then txt;
8202
8203 case ( txt,
8204 _,
8205 _ )
8206 then txt;
8207 end match;
8208 end fun_213;
8209
8210 protected function fun_214
8211 input Tpl.Text in_txt;
8212 input Boolean in_mArg;
8213 input Tpl.Text in_a_res;
8214 input Tpl.Text in_a_resTail;
8215
8216 output Tpl.Text out_txt;
8217 algorithm
8218 out_txt :=
8219 match(in_txt, in_mArg, in_a_res, in_a_resTail)
8220 local
8221 Tpl.Text txt;
8222 Tpl.Text a_res;
8223 Tpl.Text a_resTail;
8224
8225 case ( txt,
8226 true,
8227 _,
8228 _ )
8229 then txt;
8230
8231 case ( txt,
8232 _,
8233 a_res,
8234 a_resTail )
8235 algorithm
8236 ✗ txt := Tpl.writeText(txt, a_resTail);
8237 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = &"));
8238 ✗ txt := Tpl.writeText(txt, a_res);
8239 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
8240 then txt;
8241 end match;
8242 end fun_214;
8243
8244 protected function fun_215
8245 input Tpl.Text in_txt;
8246 input Boolean in_mArg;
8247 input Tpl.Text in_a_foundFirst;
8248
8249 output Tpl.Text out_txt;
8250 algorithm
8251 out_txt :=
8252 match(in_txt, in_mArg, in_a_foundFirst)
8253 local
8254 Tpl.Text txt;
8255 Tpl.Text a_foundFirst;
8256
8257 case ( txt,
8258 true,
8259 _ )
8260 then txt;
8261
8262 case ( txt,
8263 _,
8264 a_foundFirst )
8265 algorithm
8266 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("if (!"));
8267 ✗ txt := Tpl.writeText(txt, a_foundFirst);
8268 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(") throw ModelicaSimulationError(MODEL_ARRAY_FUNCTION,\"Internal error\");"));
8269 then txt;
8270 end match;
8271 end fun_215;
8272
8273 protected function fun_216
8274 input Tpl.Text in_txt;
8275 input Boolean in_mArg;
8276 input Tpl.Text in_a_resTail;
8277
8278 output Tpl.Text out_txt;
8279 algorithm
8280 out_txt :=
8281 match(in_txt, in_mArg, in_a_resTail)
8282 local
8283 Tpl.Text txt;
8284 Tpl.Text a_resTail;
8285
8286 case ( txt,
8287 true,
8288 _ )
8289 then txt;
8290
8291 case ( txt,
8292 _,
8293 a_resTail )
8294 algorithm
8295 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("*"));
8296 ✗ txt := Tpl.writeText(txt, a_resTail);
8297 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = NULL;"));
8298 then txt;
8299 end match;
8300 end fun_216;
8301
8302 protected function fun_217
8303 input Tpl.Text in_txt;
8304 input Absyn.Path in_a_ri_path;
8305 input Tpl.Text in_a_tmpVarDecls;
8306
8307 output Tpl.Text out_txt;
8308 output Tpl.Text out_a_tmpVarDecls;
8309 algorithm
8310 (out_txt, out_a_tmpVarDecls) :=
8311 match(in_txt, in_a_ri_path, in_a_tmpVarDecls)
8312 local
8313 Tpl.Text txt;
8314 Tpl.Text a_tmpVarDecls;
8315
8316 case ( txt,
8317 Absyn.IDENT(name = "array"),
8318 a_tmpVarDecls )
8319 algorithm
8320 6 (txt, a_tmpVarDecls) := tempDecl(txt, "int", a_tmpVarDecls);
8321 then (txt, a_tmpVarDecls);
8322
8323 case ( txt,
8324 _,
8325 a_tmpVarDecls )
8326 3 then (txt, a_tmpVarDecls);
8327 end match;
8328 end fun_217;
8329
8330 protected function fun_218
8331 input Tpl.Text in_txt;
8332 input Option<Values.Value> in_a_ri_defaultValue;
8333 input Tpl.Text in_a_tmpVarDecls;
8334
8335 output Tpl.Text out_txt;
8336 output Tpl.Text out_a_tmpVarDecls;
8337 algorithm
8338 (out_txt, out_a_tmpVarDecls) :=
8339 match(in_txt, in_a_ri_defaultValue, in_a_tmpVarDecls)
8340 local
8341 Tpl.Text txt;
8342 Tpl.Text a_tmpVarDecls;
8343
8344 case ( txt,
8345 NONE(),
8346 a_tmpVarDecls )
8347 algorithm
8348 1 (txt, a_tmpVarDecls) := tempDecl(txt, "int", a_tmpVarDecls);
8349 then (txt, a_tmpVarDecls);
8350
8351 case ( txt,
8352 _,
8353 a_tmpVarDecls )
8354 2 then (txt, a_tmpVarDecls);
8355 end match;
8356 end fun_218;
8357
8358 protected function fun_219
8359 input Tpl.Text in_txt;
8360 input Absyn.Path in_a_ri_path;
8361 input Tpl.Text in_a_tmpVarDecls;
8362 input Option<Values.Value> in_a_ri_defaultValue;
8363
8364 output Tpl.Text out_txt;
8365 output Tpl.Text out_a_tmpVarDecls;
8366 algorithm
8367 (out_txt, out_a_tmpVarDecls) :=
8368 match(in_txt, in_a_ri_path, in_a_tmpVarDecls, in_a_ri_defaultValue)
8369 local
8370 Tpl.Text txt;
8371 Tpl.Text a_tmpVarDecls;
8372 Option<Values.Value> a_ri_defaultValue;
8373
8374 case ( txt,
8375 Absyn.IDENT(name = "array"),
8376 a_tmpVarDecls,
8377 _ )
8378 6 then (txt, a_tmpVarDecls);
8379
8380 case ( txt,
8381 _,
8382 a_tmpVarDecls,
8383 a_ri_defaultValue )
8384 algorithm
8385 3 (txt, a_tmpVarDecls) := fun_218(txt, a_ri_defaultValue, a_tmpVarDecls);
8386 then (txt, a_tmpVarDecls);
8387 end match;
8388 end fun_219;
8389
8390 protected function fun_220
8391 input Tpl.Text in_txt;
8392 input Absyn.Path in_a_ri_path;
8393 input Tpl.Text in_a_tmpVarDecls;
8394
8395 output Tpl.Text out_txt;
8396 output Tpl.Text out_a_tmpVarDecls;
8397 algorithm
8398 (out_txt, out_a_tmpVarDecls) :=
8399 match(in_txt, in_a_ri_path, in_a_tmpVarDecls)
8400 local
8401 Tpl.Text txt;
8402 Tpl.Text a_tmpVarDecls;
8403
8404 case ( txt,
8405 Absyn.IDENT(name = "list"),
8406 a_tmpVarDecls )
8407 algorithm
8408 ✗ (txt, a_tmpVarDecls) := tempDecl(txt, "modelica_metatype*", a_tmpVarDecls);
8409 then (txt, a_tmpVarDecls);
8410
8411 case ( txt,
8412 _,
8413 a_tmpVarDecls )
8414 9 then (txt, a_tmpVarDecls);
8415 end match;
8416 end fun_220;
8417
8418 protected function fun_221
8419 input Tpl.Text in_txt;
8420 input Option<Values.Value> in_a_ri_defaultValue;
8421 input Boolean in_a_useFlatArrayNotation;
8422 input Tpl.Text in_a_stateDerVectorName;
8423 input Tpl.Text in_a_extraFuncsNamespace;
8424 input Tpl.Text in_a_extraFuncsDecl;
8425 input Tpl.Text in_a_extraFuncs;
8426 input SimCode.SimCode in_a_simCode;
8427 input Tpl.Text in_a_tmpVarDecls;
8428 input Tpl.Text in_a_preDefault;
8429 input SimCodeFunction.Context in_a_context;
8430
8431 output Tpl.Text out_txt;
8432 output Tpl.Text out_a_stateDerVectorName;
8433 output Tpl.Text out_a_extraFuncsNamespace;
8434 output Tpl.Text out_a_extraFuncsDecl;
8435 output Tpl.Text out_a_extraFuncs;
8436 output Tpl.Text out_a_tmpVarDecls;
8437 output Tpl.Text out_a_preDefault;
8438 algorithm
8439 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_tmpVarDecls, out_a_preDefault) :=
8440 match(in_txt, in_a_ri_defaultValue, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_tmpVarDecls, in_a_preDefault, in_a_context)
8441 local
8442 Tpl.Text txt;
8443 Boolean a_useFlatArrayNotation;
8444 Tpl.Text a_stateDerVectorName;
8445 Tpl.Text a_extraFuncsNamespace;
8446 Tpl.Text a_extraFuncsDecl;
8447 Tpl.Text a_extraFuncs;
8448 SimCode.SimCode a_simCode;
8449 Tpl.Text a_tmpVarDecls;
8450 Tpl.Text a_preDefault;
8451 SimCodeFunction.Context a_context;
8452 Values.Value i_v;
8453 DAE.Exp ret_0;
8454
8455 case ( txt,
8456 SOME(i_v),
8457 a_useFlatArrayNotation,
8458 a_stateDerVectorName,
8459 a_extraFuncsNamespace,
8460 a_extraFuncsDecl,
8461 a_extraFuncs,
8462 a_simCode,
8463 a_tmpVarDecls,
8464 a_preDefault,
8465 a_context )
8466 algorithm
8467 2 ret_0 := ValuesUtil.valueExpNoOriginal(i_v);
8468 2 (txt, a_preDefault, a_tmpVarDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, ret_0, a_context, a_preDefault, a_tmpVarDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
8469 2 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_preDefault);
8470
8471 case ( txt,
8472 _,
8473 _,
8474 a_stateDerVectorName,
8475 a_extraFuncsNamespace,
8476 a_extraFuncsDecl,
8477 a_extraFuncs,
8478 _,
8479 a_tmpVarDecls,
8480 a_preDefault,
8481 _ )
8482 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_preDefault);
8483 end match;
8484 end fun_221;
8485
8486 protected function fun_222
8487 input Tpl.Text in_txt;
8488 input Absyn.Path in_a_ri_path;
8489 input Boolean in_a_useFlatArrayNotation;
8490 input Tpl.Text in_a_stateDerVectorName;
8491 input Tpl.Text in_a_extraFuncsNamespace;
8492 input Tpl.Text in_a_extraFuncsDecl;
8493 input Tpl.Text in_a_extraFuncs;
8494 input SimCode.SimCode in_a_simCode;
8495 input Tpl.Text in_a_tmpVarDecls;
8496 input Tpl.Text in_a_preDefault;
8497 input SimCodeFunction.Context in_a_context;
8498 input Option<Values.Value> in_a_ri_defaultValue;
8499
8500 output Tpl.Text out_txt;
8501 output Tpl.Text out_a_stateDerVectorName;
8502 output Tpl.Text out_a_extraFuncsNamespace;
8503 output Tpl.Text out_a_extraFuncsDecl;
8504 output Tpl.Text out_a_extraFuncs;
8505 output Tpl.Text out_a_tmpVarDecls;
8506 output Tpl.Text out_a_preDefault;
8507 algorithm
8508 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_tmpVarDecls, out_a_preDefault) :=
8509 match(in_txt, in_a_ri_path, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_tmpVarDecls, in_a_preDefault, in_a_context, in_a_ri_defaultValue)
8510 local
8511 Tpl.Text txt;
8512 Boolean a_useFlatArrayNotation;
8513 Tpl.Text a_stateDerVectorName;
8514 Tpl.Text a_extraFuncsNamespace;
8515 Tpl.Text a_extraFuncsDecl;
8516 Tpl.Text a_extraFuncs;
8517 SimCode.SimCode a_simCode;
8518 Tpl.Text a_tmpVarDecls;
8519 Tpl.Text a_preDefault;
8520 SimCodeFunction.Context a_context;
8521 Option<Values.Value> a_ri_defaultValue;
8522
8523 case ( txt,
8524 Absyn.IDENT(name = "array"),
8525 _,
8526 a_stateDerVectorName,
8527 a_extraFuncsNamespace,
8528 a_extraFuncsDecl,
8529 a_extraFuncs,
8530 _,
8531 a_tmpVarDecls,
8532 a_preDefault,
8533 _,
8534 _ )
8535 6 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_preDefault);
8536
8537 case ( txt,
8538 _,
8539 a_useFlatArrayNotation,
8540 a_stateDerVectorName,
8541 a_extraFuncsNamespace,
8542 a_extraFuncsDecl,
8543 a_extraFuncs,
8544 a_simCode,
8545 a_tmpVarDecls,
8546 a_preDefault,
8547 a_context,
8548 a_ri_defaultValue )
8549 algorithm
8550 3 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_preDefault) := fun_221(txt, a_ri_defaultValue, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_tmpVarDecls, a_preDefault, a_context);
8551 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_preDefault);
8552 end match;
8553 end fun_222;
8554
8555 protected function fun_223
8556 input Tpl.Text in_txt;
8557 input DAE.Type in_mArg;
8558 input Tpl.Text in_a_reductionBodyExpr;
8559 input Tpl.Text in_a_res;
8560 input Tpl.Text in_a_arrIndex;
8561 input Tpl.Text in_a_varDecls;
8562
8563 output Tpl.Text out_txt;
8564 output Tpl.Text out_a_varDecls;
8565 algorithm
8566 (out_txt, out_a_varDecls) :=
8567 match(in_txt, in_mArg, in_a_reductionBodyExpr, in_a_res, in_a_arrIndex, in_a_varDecls)
8568 local
8569 Tpl.Text txt;
8570 Tpl.Text a_reductionBodyExpr;
8571 Tpl.Text a_res;
8572 Tpl.Text a_arrIndex;
8573 Tpl.Text a_varDecls;
8574 DAE.Type i_ty;
8575 Tpl.Text l_tmp__slice;
8576
8577 case ( txt,
8578 DAE.T_ARRAY(ty = i_ty),
8579 a_reductionBodyExpr,
8580 a_res,
8581 a_arrIndex,
8582 a_varDecls )
8583 algorithm
8584 1 (l_tmp__slice, a_varDecls) := tempDecl(Tpl.emptyTxt, "vector<Slice>", a_varDecls);
8585 1 txt := Tpl.writeText(txt, l_tmp__slice);
8586 1 txt := Tpl.writeTok(txt, Tpl.ST_LINE(".clear();\n"));
8587 1 txt := Tpl.writeText(txt, l_tmp__slice);
8588 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING(".push_back(Slice("));
8589 1 txt := Tpl.writeText(txt, a_arrIndex);
8590 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
8591 "++));\n",
8592 "ArraySlice<"
8593 }, false));
8594 1 txt := expTypeShort(txt, i_ty);
8595 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING(">("));
8596 1 txt := Tpl.writeText(txt, a_res);
8597 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
8598 1 txt := Tpl.writeText(txt, l_tmp__slice);
8599 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING(").assign("));
8600 1 txt := Tpl.writeText(txt, a_reductionBodyExpr);
8601 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
8602 1 then (txt, a_varDecls);
8603
8604 case ( txt,
8605 _,
8606 a_reductionBodyExpr,
8607 a_res,
8608 a_arrIndex,
8609 a_varDecls )
8610 algorithm
8611 5 txt := Tpl.writeText(txt, a_res);
8612 5 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
8613 5 txt := Tpl.writeText(txt, a_arrIndex);
8614 5 txt := Tpl.writeTok(txt, Tpl.ST_STRING("++) = "));
8615 5 txt := Tpl.writeText(txt, a_reductionBodyExpr);
8616 5 txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
8617 5 then (txt, a_varDecls);
8618 end match;
8619 end fun_223;
8620
8621 protected function fun_224
8622 input Tpl.Text in_txt;
8623 input Boolean in_mArg;
8624 input Tpl.Text in_a_reductionBodyExpr;
8625 input Tpl.Text in_a_foldExpPre;
8626 input Tpl.Text in_a_foundFirst;
8627 input Tpl.Text in_a_fExpStr;
8628 input Tpl.Text in_a_res;
8629
8630 output Tpl.Text out_txt;
8631 algorithm
8632 out_txt :=
8633 match(in_txt, in_mArg, in_a_reductionBodyExpr, in_a_foldExpPre, in_a_foundFirst, in_a_fExpStr, in_a_res)
8634 local
8635 Tpl.Text txt;
8636 Tpl.Text a_reductionBodyExpr;
8637 Tpl.Text a_foldExpPre;
8638 Tpl.Text a_foundFirst;
8639 Tpl.Text a_fExpStr;
8640 Tpl.Text a_res;
8641
8642 case ( txt,
8643 true,
8644 _,
8645 _,
8646 _,
8647 a_fExpStr,
8648 a_res )
8649 algorithm
8650 2 txt := Tpl.writeText(txt, a_res);
8651 2 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = "));
8652 2 txt := Tpl.writeText(txt, a_fExpStr);
8653 2 txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
8654 then txt;
8655
8656 case ( txt,
8657 _,
8658 a_reductionBodyExpr,
8659 a_foldExpPre,
8660 a_foundFirst,
8661 a_fExpStr,
8662 a_res )
8663 algorithm
8664 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("if ("));
8665 1 txt := Tpl.writeText(txt, a_foundFirst);
8666 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
8667 ")\n",
8668 "{\n"
8669 }, true));
8670 1 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
8671 1 txt := Tpl.writeText(txt, a_foldExpPre);
8672 1 txt := Tpl.softNewLine(txt);
8673 1 txt := Tpl.writeText(txt, a_res);
8674 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = "));
8675 1 txt := Tpl.writeText(txt, a_fExpStr);
8676 1 txt := Tpl.writeTok(txt, Tpl.ST_LINE(";\n"));
8677 1 txt := Tpl.popBlock(txt);
8678 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
8679 "}\n",
8680 "else\n",
8681 "{\n"
8682 }, true));
8683 1 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
8684 1 txt := Tpl.writeText(txt, a_res);
8685 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = "));
8686 1 txt := Tpl.writeText(txt, a_reductionBodyExpr);
8687 1 txt := Tpl.writeTok(txt, Tpl.ST_LINE(";\n"));
8688 1 txt := Tpl.writeText(txt, a_foundFirst);
8689 1 txt := Tpl.writeTok(txt, Tpl.ST_LINE(" = 1;\n"));
8690 1 txt := Tpl.popBlock(txt);
8691 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("}"));
8692 then txt;
8693 end match;
8694 end fun_224;
8695
8696 protected function fun_225
8697 input Tpl.Text in_txt;
8698 input Option<DAE.Exp> in_a_ri_foldExp;
8699 input Tpl.Text in_a_reductionBodyExpr;
8700 input Tpl.Text in_a_res;
8701 input Tpl.Text in_a_foundFirst;
8702 input Boolean in_a_useFlatArrayNotation;
8703 input Tpl.Text in_a_stateDerVectorName;
8704 input Tpl.Text in_a_extraFuncsNamespace;
8705 input Tpl.Text in_a_extraFuncsDecl;
8706 input Tpl.Text in_a_extraFuncs;
8707 input SimCode.SimCode in_a_simCode;
8708 input Tpl.Text in_a_tmpVarDecls;
8709 input SimCodeFunction.Context in_a_context;
8710
8711 output Tpl.Text out_txt;
8712 output Tpl.Text out_a_stateDerVectorName;
8713 output Tpl.Text out_a_extraFuncsNamespace;
8714 output Tpl.Text out_a_extraFuncsDecl;
8715 output Tpl.Text out_a_extraFuncs;
8716 output Tpl.Text out_a_tmpVarDecls;
8717 algorithm
8718 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_tmpVarDecls) :=
8719 match(in_txt, in_a_ri_foldExp, in_a_reductionBodyExpr, in_a_res, in_a_foundFirst, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_tmpVarDecls, in_a_context)
8720 local
8721 Tpl.Text txt;
8722 Tpl.Text a_reductionBodyExpr;
8723 Tpl.Text a_res;
8724 Tpl.Text a_foundFirst;
8725 Boolean a_useFlatArrayNotation;
8726 Tpl.Text a_stateDerVectorName;
8727 Tpl.Text a_extraFuncsNamespace;
8728 Tpl.Text a_extraFuncsDecl;
8729 Tpl.Text a_extraFuncs;
8730 SimCode.SimCode a_simCode;
8731 Tpl.Text a_tmpVarDecls;
8732 SimCodeFunction.Context a_context;
8733 DAE.Exp i_fExp;
8734 Boolean ret_2;
8735 Tpl.Text l_fExpStr;
8736 Tpl.Text l_foldExpPre;
8737
8738 case ( txt,
8739 SOME(i_fExp),
8740 a_reductionBodyExpr,
8741 a_res,
8742 a_foundFirst,
8743 a_useFlatArrayNotation,
8744 a_stateDerVectorName,
8745 a_extraFuncsNamespace,
8746 a_extraFuncsDecl,
8747 a_extraFuncs,
8748 a_simCode,
8749 a_tmpVarDecls,
8750 a_context )
8751 algorithm
8752 3 l_foldExpPre := Tpl.emptyTxt;
8753 3 (l_fExpStr, l_foldExpPre, a_tmpVarDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_fExp, a_context, l_foldExpPre, a_tmpVarDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
8754 3 ret_2 := Tpl.isEmpty(a_foundFirst);
8755 3 txt := fun_224(txt, ret_2, a_reductionBodyExpr, l_foldExpPre, a_foundFirst, l_fExpStr, a_res);
8756 3 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls);
8757
8758 case ( txt,
8759 _,
8760 _,
8761 _,
8762 _,
8763 _,
8764 a_stateDerVectorName,
8765 a_extraFuncsNamespace,
8766 a_extraFuncsDecl,
8767 a_extraFuncs,
8768 _,
8769 a_tmpVarDecls,
8770 _ )
8771 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls);
8772 end match;
8773 end fun_225;
8774
8775 protected function fun_226
8776 input Tpl.Text in_txt;
8777 input Absyn.Path in_a_ri_path;
8778 input Tpl.Text in_a_foundFirst;
8779 input Boolean in_a_useFlatArrayNotation;
8780 input Tpl.Text in_a_stateDerVectorName;
8781 input Tpl.Text in_a_extraFuncsNamespace;
8782 input Tpl.Text in_a_extraFuncsDecl;
8783 input Tpl.Text in_a_extraFuncs;
8784 input SimCode.SimCode in_a_simCode;
8785 input Tpl.Text in_a_tmpVarDecls;
8786 input SimCodeFunction.Context in_a_context;
8787 input Option<DAE.Exp> in_a_ri_foldExp;
8788 input Tpl.Text in_a_arrIndex;
8789 input Tpl.Text in_a_varDecls;
8790 input DAE.Exp in_a_r_expr;
8791 input Tpl.Text in_a_res;
8792 input Tpl.Text in_a_reductionBodyExpr;
8793 input Tpl.Text in_a_resTail;
8794
8795 output Tpl.Text out_txt;
8796 output Tpl.Text out_a_stateDerVectorName;
8797 output Tpl.Text out_a_extraFuncsNamespace;
8798 output Tpl.Text out_a_extraFuncsDecl;
8799 output Tpl.Text out_a_extraFuncs;
8800 output Tpl.Text out_a_tmpVarDecls;
8801 output Tpl.Text out_a_varDecls;
8802 algorithm
8803 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_tmpVarDecls, out_a_varDecls) :=
8804 match(in_txt, in_a_ri_path, in_a_foundFirst, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_tmpVarDecls, in_a_context, in_a_ri_foldExp, in_a_arrIndex, in_a_varDecls, in_a_r_expr, in_a_res, in_a_reductionBodyExpr, in_a_resTail)
8805 local
8806 Tpl.Text txt;
8807 Tpl.Text a_foundFirst;
8808 Boolean a_useFlatArrayNotation;
8809 Tpl.Text a_stateDerVectorName;
8810 Tpl.Text a_extraFuncsNamespace;
8811 Tpl.Text a_extraFuncsDecl;
8812 Tpl.Text a_extraFuncs;
8813 SimCode.SimCode a_simCode;
8814 Tpl.Text a_tmpVarDecls;
8815 SimCodeFunction.Context a_context;
8816 Option<DAE.Exp> a_ri_foldExp;
8817 Tpl.Text a_arrIndex;
8818 Tpl.Text a_varDecls;
8819 DAE.Exp a_r_expr;
8820 Tpl.Text a_res;
8821 Tpl.Text a_reductionBodyExpr;
8822 Tpl.Text a_resTail;
8823 DAE.Type ret_0;
8824
8825 case ( txt,
8826 Absyn.IDENT(name = "list"),
8827 _,
8828 _,
8829 a_stateDerVectorName,
8830 a_extraFuncsNamespace,
8831 a_extraFuncsDecl,
8832 a_extraFuncs,
8833 _,
8834 a_tmpVarDecls,
8835 _,
8836 _,
8837 _,
8838 a_varDecls,
8839 _,
8840 _,
8841 a_reductionBodyExpr,
8842 a_resTail )
8843 algorithm
8844 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("*"));
8845 ✗ txt := Tpl.writeText(txt, a_resTail);
8846 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = mmc_mk_cons("));
8847 ✗ txt := Tpl.writeText(txt, a_reductionBodyExpr);
8848 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(",0);\n"));
8849 ✗ txt := Tpl.writeText(txt, a_resTail);
8850 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = &MMC_CDR(*"));
8851 ✗ txt := Tpl.writeText(txt, a_resTail);
8852 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
8853 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_varDecls);
8854
8855 case ( txt,
8856 Absyn.IDENT(name = "listReverse"),
8857 _,
8858 _,
8859 a_stateDerVectorName,
8860 a_extraFuncsNamespace,
8861 a_extraFuncsDecl,
8862 a_extraFuncs,
8863 _,
8864 a_tmpVarDecls,
8865 _,
8866 _,
8867 _,
8868 a_varDecls,
8869 _,
8870 a_res,
8871 a_reductionBodyExpr,
8872 _ )
8873 algorithm
8874 ✗ txt := Tpl.writeText(txt, a_res);
8875 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = mmc_mk_cons("));
8876 ✗ txt := Tpl.writeText(txt, a_reductionBodyExpr);
8877 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(","));
8878 ✗ txt := Tpl.writeText(txt, a_res);
8879 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
8880 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_varDecls);
8881
8882 case ( txt,
8883 Absyn.IDENT(name = "array"),
8884 _,
8885 _,
8886 a_stateDerVectorName,
8887 a_extraFuncsNamespace,
8888 a_extraFuncsDecl,
8889 a_extraFuncs,
8890 _,
8891 a_tmpVarDecls,
8892 _,
8893 _,
8894 a_arrIndex,
8895 a_varDecls,
8896 a_r_expr,
8897 a_res,
8898 a_reductionBodyExpr,
8899 _ )
8900 algorithm
8901 6 ret_0 := Expression.typeof(a_r_expr);
8902 6 (txt, a_varDecls) := fun_223(txt, ret_0, a_reductionBodyExpr, a_res, a_arrIndex, a_varDecls);
8903 6 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_varDecls);
8904
8905 case ( txt,
8906 _,
8907 a_foundFirst,
8908 a_useFlatArrayNotation,
8909 a_stateDerVectorName,
8910 a_extraFuncsNamespace,
8911 a_extraFuncsDecl,
8912 a_extraFuncs,
8913 a_simCode,
8914 a_tmpVarDecls,
8915 a_context,
8916 a_ri_foldExp,
8917 _,
8918 a_varDecls,
8919 _,
8920 a_res,
8921 a_reductionBodyExpr,
8922 _ )
8923 algorithm
8924 3 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls) := fun_225(txt, a_ri_foldExp, a_reductionBodyExpr, a_res, a_foundFirst, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_tmpVarDecls, a_context);
8925 3 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_varDecls);
8926 end match;
8927 end fun_226;
8928
8929 protected function fun_227
8930 input Tpl.Text in_txt;
8931 input Boolean in_mArg;
8932 input Tpl.Text in_a_firstIndex;
8933
8934 output Tpl.Text out_txt;
8935 algorithm
8936 out_txt :=
8937 match(in_txt, in_mArg, in_a_firstIndex)
8938 local
8939 Tpl.Text txt;
8940 Tpl.Text a_firstIndex;
8941
8942 case ( txt,
8943 true,
8944 _ )
8945 then txt;
8946
8947 case ( txt,
8948 _,
8949 a_firstIndex )
8950 algorithm
8951 9 txt := Tpl.writeText(txt, a_firstIndex);
8952 9 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = 1;"));
8953 9 txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
8954 then txt;
8955 end match;
8956 end fun_227;
8957
8958 protected function fun_228
8959 input Tpl.Text in_txt;
8960 input Option<DAE.Exp> in_a_iter_guardExp;
8961 input Boolean in_a_useFlatArrayNotation;
8962 input Tpl.Text in_a_stateDerVectorName;
8963 input Tpl.Text in_a_extraFuncsNamespace;
8964 input Tpl.Text in_a_extraFuncsDecl;
8965 input Tpl.Text in_a_extraFuncs;
8966 input SimCode.SimCode in_a_simCode;
8967 input Tpl.Text in_a_tmpVarDecls;
8968 input Tpl.Text in_a_guardExpPre;
8969 input SimCodeFunction.Context in_a_context;
8970
8971 output Tpl.Text out_txt;
8972 output Tpl.Text out_a_stateDerVectorName;
8973 output Tpl.Text out_a_extraFuncsNamespace;
8974 output Tpl.Text out_a_extraFuncsDecl;
8975 output Tpl.Text out_a_extraFuncs;
8976 output Tpl.Text out_a_tmpVarDecls;
8977 output Tpl.Text out_a_guardExpPre;
8978 algorithm
8979 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_tmpVarDecls, out_a_guardExpPre) :=
8980 match(in_txt, in_a_iter_guardExp, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_tmpVarDecls, in_a_guardExpPre, in_a_context)
8981 local
8982 Tpl.Text txt;
8983 Boolean a_useFlatArrayNotation;
8984 Tpl.Text a_stateDerVectorName;
8985 Tpl.Text a_extraFuncsNamespace;
8986 Tpl.Text a_extraFuncsDecl;
8987 Tpl.Text a_extraFuncs;
8988 SimCode.SimCode a_simCode;
8989 Tpl.Text a_tmpVarDecls;
8990 Tpl.Text a_guardExpPre;
8991 SimCodeFunction.Context a_context;
8992 DAE.Exp i_grd;
8993
8994 case ( txt,
8995 SOME(i_grd),
8996 a_useFlatArrayNotation,
8997 a_stateDerVectorName,
8998 a_extraFuncsNamespace,
8999 a_extraFuncsDecl,
9000 a_extraFuncs,
9001 a_simCode,
9002 a_tmpVarDecls,
9003 a_guardExpPre,
9004 a_context )
9005 algorithm
9006 ✗ (txt, a_guardExpPre, a_tmpVarDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_grd, a_context, a_guardExpPre, a_tmpVarDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
9007 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_guardExpPre);
9008
9009 case ( txt,
9010 _,
9011 _,
9012 a_stateDerVectorName,
9013 a_extraFuncsNamespace,
9014 a_extraFuncsDecl,
9015 a_extraFuncs,
9016 _,
9017 a_tmpVarDecls,
9018 a_guardExpPre,
9019 _ )
9020 algorithm
9021 9 txt := Tpl.writeTok(txt, Tpl.ST_STRING("1"));
9022 9 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_guardExpPre);
9023 end match;
9024 end fun_228;
9025
9026 protected function fun_229
9027 input Tpl.Text in_txt;
9028 input DAE.Type in_a_iter_ty;
9029 input Tpl.Text in_a_firstIndex;
9030 input Tpl.Text in_a_loopVar;
9031
9032 output Tpl.Text out_txt;
9033 algorithm
9034 out_txt :=
9035 match(in_txt, in_a_iter_ty, in_a_firstIndex, in_a_loopVar)
9036 local
9037 Tpl.Text txt;
9038 Tpl.Text a_firstIndex;
9039 Tpl.Text a_loopVar;
9040 ClassInf.State i_record__state;
9041 Absyn.Path ret_1;
9042 Tpl.Text l_rec__name;
9043
9044 case ( txt,
9045 DAE.T_ARRAY(ty = DAE.T_COMPLEX(complexClassType = i_record__state)),
9046 a_firstIndex,
9047 a_loopVar )
9048 algorithm
9049 ✗ ret_1 := ClassInfUtil.getStateName(i_record__state);
9050 ✗ l_rec__name := CodegenUtil.underscorePath(Tpl.emptyTxt, ret_1);
9051 ✗ txt := Tpl.writeText(txt, l_rec__name);
9052 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_array_get("));
9053 ✗ txt := Tpl.writeText(txt, a_loopVar);
9054 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(", 1, "));
9055 ✗ txt := Tpl.writeText(txt, a_firstIndex);
9056 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("++)"));
9057 then txt;
9058
9059 case ( txt,
9060 _,
9061 a_firstIndex,
9062 a_loopVar )
9063 algorithm
9064 9 txt := Tpl.writeText(txt, a_loopVar);
9065 9 txt := Tpl.writeTok(txt, Tpl.ST_STRING("( "));
9066 9 txt := Tpl.writeText(txt, a_firstIndex);
9067 9 txt := Tpl.writeTok(txt, Tpl.ST_STRING("++)"));
9068 then txt;
9069 end match;
9070 end fun_229;
9071
9072 protected function lm_230
9073 input output Tpl.Text txt;
9074 input DAE.ReductionIterators items;
9075 input Tpl.Text a_endLoop;
9076 input Boolean a_useFlatArrayNotation;
9077 input output Tpl.Text a_stateDerVectorName;
9078 input output Tpl.Text a_extraFuncsNamespace;
9079 input output Tpl.Text a_extraFuncsDecl;
9080 input output Tpl.Text a_extraFuncs;
9081 input SimCode.SimCode a_simCode;
9082 input output Tpl.Text a_rangeExpPre;
9083 input SimCodeFunction.Context a_context;
9084 input output Tpl.Text a_tmpVarDecls;
9085 algorithm
9086
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 for lstElt_230 in items loop
9087 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_rangeExpPre, a_tmpVarDecls) := match lstElt_230
9088 local
9089 DAE.Type i_iter_ty;
9090 Option<DAE.Exp> i_iter_guardExp;
9091 String i_iter_id;
9092 DAE.Type i_ty;
9093 DAE.Exp i_iter_exp;
9094 Tpl.Text l_addr;
9095 Tpl.Text l_guardExp;
9096 Tpl.Text l_iteratorName;
9097 Tpl.Text l_empty;
9098 Tpl.Text l_guardCond;
9099 Boolean ret_7;
9100 Tpl.Text l_rangeExp;
9101 Tpl.Text l_firstIndex;
9102 Tpl.Text l_guardExpPre;
9103 Tpl.Text l_loopVar;
9104 Tpl.Text l_arrayType;
9105 Tpl.Text l_ty__str;
9106 Tpl.Text l_identType;
9107
9108 case DAE.REDUCTIONITER(exp = i_iter_exp, ty = (i_iter_ty as i_ty), id = i_iter_id, guardExp = i_iter_guardExp)
9109 algorithm
9110 9 l_identType := expTypeFromExpModelica(Tpl.emptyTxt, i_iter_exp);
9111 9 l_ty__str := expTypeShort(Tpl.emptyTxt, i_ty);
9112 9 l_arrayType := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("DynArrayDim1<"));
9113 9 l_arrayType := Tpl.writeText(l_arrayType, l_identType);
9114 9 l_arrayType := Tpl.writeTok(l_arrayType, Tpl.ST_STRING(">"));
9115 9 l_loopVar := Tpl.writeStr(Tpl.emptyTxt, i_iter_id);
9116 9 l_loopVar := Tpl.writeTok(l_loopVar, Tpl.ST_STRING("_loopVar"));
9117 9 l_guardExpPre := Tpl.emptyTxt;
9118 9 a_tmpVarDecls := Tpl.writeText(a_tmpVarDecls, l_arrayType);
9119 9 a_tmpVarDecls := Tpl.writeTok(a_tmpVarDecls, Tpl.ST_STRING(" "));
9120 9 a_tmpVarDecls := Tpl.writeText(a_tmpVarDecls, l_loopVar);
9121 9 a_tmpVarDecls := Tpl.writeTok(a_tmpVarDecls, Tpl.ST_STRING(";/*testloopvar*/"));
9122 9 a_tmpVarDecls := Tpl.writeTok(a_tmpVarDecls, Tpl.ST_NEW_LINE());
9123 9 (l_firstIndex, a_tmpVarDecls) := tempDecl(Tpl.emptyTxt, "int", a_tmpVarDecls);
9124 9 (l_rangeExp, a_rangeExpPre, a_tmpVarDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_iter_exp, a_context, a_rangeExpPre, a_tmpVarDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
9125 9 a_rangeExpPre := Tpl.writeText(a_rangeExpPre, l_loopVar);
9126 9 a_rangeExpPre := Tpl.writeTok(a_rangeExpPre, Tpl.ST_STRING(" = "));
9127 9 a_rangeExpPre := Tpl.writeText(a_rangeExpPre, l_rangeExp);
9128 9 a_rangeExpPre := Tpl.writeTok(a_rangeExpPre, Tpl.ST_STRING("/*testloopvar2*/;"));
9129 9 a_rangeExpPre := Tpl.writeTok(a_rangeExpPre, Tpl.ST_NEW_LINE());
9130 9 ret_7 := Tpl.isEmpty(l_firstIndex);
9131 9 a_rangeExpPre := fun_227(a_rangeExpPre, ret_7, l_firstIndex);
9132 9 (l_guardCond, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, l_guardExpPre) := fun_228(Tpl.emptyTxt, i_iter_guardExp, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_tmpVarDecls, l_guardExpPre, a_context);
9133 9 l_empty := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("0 == ("));
9134 9 l_empty := Tpl.writeText(l_empty, l_loopVar);
9135 9 l_empty := Tpl.writeTok(l_empty, Tpl.ST_STRING(".getDim(2))"));
9136 9 l_iteratorName := contextIteratorName(Tpl.emptyTxt, i_iter_id, a_context);
9137 9 a_tmpVarDecls := Tpl.writeText(a_tmpVarDecls, l_identType);
9138 9 a_tmpVarDecls := Tpl.writeTok(a_tmpVarDecls, Tpl.ST_STRING(" "));
9139 9 a_tmpVarDecls := Tpl.writeText(a_tmpVarDecls, l_iteratorName);
9140 9 a_tmpVarDecls := Tpl.writeTok(a_tmpVarDecls, Tpl.ST_STRING(";"));
9141 9 a_tmpVarDecls := Tpl.writeTok(a_tmpVarDecls, Tpl.ST_NEW_LINE());
9142 9 l_guardExp := Tpl.writeText(Tpl.emptyTxt, l_guardExpPre);
9143 9 l_guardExp := Tpl.softNewLine(l_guardExp);
9144 9 l_guardExp := Tpl.writeTok(l_guardExp, Tpl.ST_STRING("if("));
9145 9 l_guardExp := Tpl.writeText(l_guardExp, l_guardCond);
9146 9 l_guardExp := Tpl.writeTok(l_guardExp, Tpl.ST_LINE(") { /* found non-guarded */\n"));
9147 9 l_guardExp := Tpl.pushBlock(l_guardExp, Tpl.BT_INDENT(2));
9148 9 l_guardExp := Tpl.writeText(l_guardExp, a_endLoop);
9149 9 l_guardExp := Tpl.writeTok(l_guardExp, Tpl.ST_STRING_LIST({
9150 "--;\n",
9151 "break;\n"
9152 }, true));
9153 9 l_guardExp := Tpl.popBlock(l_guardExp);
9154 9 l_guardExp := Tpl.writeTok(l_guardExp, Tpl.ST_STRING("}"));
9155 9 l_addr := fun_229(Tpl.emptyTxt, i_iter_ty, l_firstIndex, l_loopVar);
9156 9 txt := Tpl.writeTok(txt, Tpl.ST_STRING("while("));
9157 9 txt := Tpl.writeText(txt, l_firstIndex);
9158 9 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" <= "));
9159 9 txt := Tpl.writeText(txt, l_loopVar);
9160 9 txt := Tpl.writeTok(txt, Tpl.ST_LINE(".getDim(1)) {\n"));
9161 9 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
9162 9 txt := Tpl.writeText(txt, l_iteratorName);
9163 9 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = "));
9164 9 txt := Tpl.writeText(txt, l_addr);
9165 9 txt := Tpl.writeTok(txt, Tpl.ST_LINE(";\n"));
9166 9 txt := Tpl.writeText(txt, l_guardExp);
9167 9 txt := Tpl.softNewLine(txt);
9168 9 txt := Tpl.popBlock(txt);
9169 9 txt := Tpl.writeTok(txt, Tpl.ST_STRING("}"));
9170 9 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_rangeExpPre, a_tmpVarDecls);
9171
9172 case _
9173 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_rangeExpPre, a_tmpVarDecls);
9174 end match;
9175 end for;
9176 end lm_230;
9177
9178 protected function lm_231
9179 input output Tpl.Text txt;
9180 input DAE.ReductionIterators items;
9181 input Tpl.Text a_length;
9182 input output Tpl.Text a_rangeExpPre;
9183 algorithm
9184
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
12 for lstElt_231 in items loop
9185 (txt, a_rangeExpPre) := match lstElt_231
9186 local
9187 String i_iter_id;
9188 Tpl.Text l_loopVar;
9189
9190 case DAE.REDUCTIONITER(id = i_iter_id)
9191 algorithm
9192 6 l_loopVar := Tpl.writeStr(Tpl.emptyTxt, i_iter_id);
9193 6 l_loopVar := Tpl.writeTok(l_loopVar, Tpl.ST_STRING("_loopVar"));
9194 6 a_rangeExpPre := Tpl.writeText(a_rangeExpPre, a_length);
9195 6 a_rangeExpPre := Tpl.writeTok(a_rangeExpPre, Tpl.ST_STRING(" = max("));
9196 6 a_rangeExpPre := Tpl.writeText(a_rangeExpPre, a_length);
9197 6 a_rangeExpPre := Tpl.writeTok(a_rangeExpPre, Tpl.ST_STRING(", "));
9198 6 a_rangeExpPre := Tpl.writeText(a_rangeExpPre, l_loopVar);
9199 6 a_rangeExpPre := Tpl.writeTok(a_rangeExpPre, Tpl.ST_STRING(".getDim(1));"));
9200 6 a_rangeExpPre := Tpl.writeTok(a_rangeExpPre, Tpl.ST_NEW_LINE());
9201 then (txt, a_rangeExpPre);
9202
9203 case _
9204 then (txt, a_rangeExpPre);
9205 end match;
9206 end for;
9207 end lm_231;
9208
9209 protected function fun_232
9210 input Tpl.Text in_txt;
9211 input DAE.Dimension in_a_dim;
9212 input DAE.Exp in_a_r_expr;
9213 input Boolean in_a_useFlatArrayNotation;
9214 input Tpl.Text in_a_stateDerVectorName;
9215 input Tpl.Text in_a_extraFuncsNamespace;
9216 input Tpl.Text in_a_extraFuncsDecl;
9217 input Tpl.Text in_a_extraFuncs;
9218 input SimCode.SimCode in_a_simCode;
9219 input Tpl.Text in_a_tmpVarDecls;
9220 input Tpl.Text in_a_rangeExpPre;
9221 input SimCodeFunction.Context in_a_context;
9222 input Tpl.Text in_a_dim__vec;
9223
9224 output Tpl.Text out_txt;
9225 output Tpl.Text out_a_stateDerVectorName;
9226 output Tpl.Text out_a_extraFuncsNamespace;
9227 output Tpl.Text out_a_extraFuncsDecl;
9228 output Tpl.Text out_a_extraFuncs;
9229 output Tpl.Text out_a_tmpVarDecls;
9230 output Tpl.Text out_a_rangeExpPre;
9231 algorithm
9232 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_tmpVarDecls, out_a_rangeExpPre) :=
9233 match(in_txt, in_a_dim, in_a_r_expr, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_tmpVarDecls, in_a_rangeExpPre, in_a_context, in_a_dim__vec)
9234 local
9235 Tpl.Text txt;
9236 DAE.Exp a_r_expr;
9237 Boolean a_useFlatArrayNotation;
9238 Tpl.Text a_stateDerVectorName;
9239 Tpl.Text a_extraFuncsNamespace;
9240 Tpl.Text a_extraFuncsDecl;
9241 Tpl.Text a_extraFuncs;
9242 SimCode.SimCode a_simCode;
9243 Tpl.Text a_tmpVarDecls;
9244 Tpl.Text a_rangeExpPre;
9245 SimCodeFunction.Context a_context;
9246 Tpl.Text a_dim__vec;
9247 DAE.Exp i_exp;
9248 Integer i_size;
9249 Integer i_integer;
9250 Tpl.Text txt_1;
9251 String ret_2;
9252 DAE.Type ret_1;
9253 Tpl.Text l_val;
9254
9255 case ( txt,
9256 DAE.DIM_INTEGER(integer = i_integer),
9257 _,
9258 _,
9259 a_stateDerVectorName,
9260 a_extraFuncsNamespace,
9261 a_extraFuncsDecl,
9262 a_extraFuncs,
9263 _,
9264 a_tmpVarDecls,
9265 a_rangeExpPre,
9266 _,
9267 a_dim__vec )
9268 algorithm
9269 ✗ txt := Tpl.writeText(txt, a_dim__vec);
9270 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".push_back("));
9271 ✗ txt := Tpl.writeStr(txt, intString(i_integer));
9272 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
9273 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_rangeExpPre);
9274
9275 case ( txt,
9276 DAE.DIM_BOOLEAN(),
9277 _,
9278 _,
9279 a_stateDerVectorName,
9280 a_extraFuncsNamespace,
9281 a_extraFuncsDecl,
9282 a_extraFuncs,
9283 _,
9284 a_tmpVarDecls,
9285 a_rangeExpPre,
9286 _,
9287 a_dim__vec )
9288 algorithm
9289 ✗ txt := Tpl.writeText(txt, a_dim__vec);
9290 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".push_back(2)"));
9291 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_rangeExpPre);
9292
9293 case ( txt,
9294 DAE.DIM_ENUM(size = i_size),
9295 _,
9296 _,
9297 a_stateDerVectorName,
9298 a_extraFuncsNamespace,
9299 a_extraFuncsDecl,
9300 a_extraFuncs,
9301 _,
9302 a_tmpVarDecls,
9303 a_rangeExpPre,
9304 _,
9305 a_dim__vec )
9306 algorithm
9307 ✗ txt := Tpl.writeText(txt, a_dim__vec);
9308 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".push_back("));
9309 ✗ txt := Tpl.writeStr(txt, intString(i_size));
9310 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
9311 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_rangeExpPre);
9312
9313 case ( txt,
9314 DAE.DIM_EXP(exp = i_exp),
9315 _,
9316 a_useFlatArrayNotation,
9317 a_stateDerVectorName,
9318 a_extraFuncsNamespace,
9319 a_extraFuncsDecl,
9320 a_extraFuncs,
9321 a_simCode,
9322 a_tmpVarDecls,
9323 a_rangeExpPre,
9324 a_context,
9325 a_dim__vec )
9326 algorithm
9327 1 (l_val, a_rangeExpPre, a_tmpVarDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_exp, a_context, a_rangeExpPre, a_tmpVarDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
9328 1 txt := Tpl.writeText(txt, a_dim__vec);
9329 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING(".push_back("));
9330 1 txt := Tpl.writeText(txt, l_val);
9331 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
9332 1 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_rangeExpPre);
9333
9334 case ( txt,
9335 _,
9336 a_r_expr,
9337 _,
9338 a_stateDerVectorName,
9339 a_extraFuncsNamespace,
9340 a_extraFuncsDecl,
9341 a_extraFuncs,
9342 _,
9343 a_tmpVarDecls,
9344 a_rangeExpPre,
9345 _,
9346 _ )
9347 algorithm
9348 ✗ txt_1 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("array reduction unable to generate code for element of unknown dimension sizes; type "));
9349 ✗ ret_1 := Expression.typeof(a_r_expr);
9350 ✗ ret_2 := TypesDump.unparseType(ret_1);
9351 ✗ txt_1 := Tpl.writeStr(txt_1, ret_2);
9352 ✗ txt_1 := Tpl.writeTok(txt_1, Tpl.ST_STRING(": "));
9353 ✗ txt_1 := ExpressionDumpTpl.dumpExp(txt_1, a_r_expr, "\"");
9354 ✗ txt := error(txt, Tpl.sourceInfo("CodegenCppCommon.tpl", 1186, 24), Tpl.textString(txt_1));
9355 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_rangeExpPre);
9356 end match;
9357 end fun_232;
9358
9359 protected function lm_233
9360 input output Tpl.Text txt;
9361 input DAE.Dimensions items;
9362 input DAE.Exp a_r_expr;
9363 input Boolean a_useFlatArrayNotation;
9364 input output Tpl.Text a_stateDerVectorName;
9365 input output Tpl.Text a_extraFuncsNamespace;
9366 input output Tpl.Text a_extraFuncsDecl;
9367 input output Tpl.Text a_extraFuncs;
9368 input SimCode.SimCode a_simCode;
9369 input output Tpl.Text a_tmpVarDecls;
9370 input output Tpl.Text a_rangeExpPre;
9371 input SimCodeFunction.Context a_context;
9372 input Tpl.Text a_dim__vec;
9373 algorithm
9374
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
2 for lstElt_233 in items loop
9375 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_rangeExpPre) := match lstElt_233
9376 local
9377 DAE.Dimension i_dim;
9378
9379 case i_dim
9380 algorithm
9381 1 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_rangeExpPre) := fun_232(txt, i_dim, a_r_expr, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_tmpVarDecls, a_rangeExpPre, a_context, a_dim__vec);
9382 1 txt := Tpl.nextIter(txt);
9383 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_rangeExpPre);
9384 end match;
9385 end for;
9386 end lm_233;
9387
9388 protected function fun_234
9389 input Tpl.Text in_txt;
9390 input DAE.Type in_mArg;
9391 input Tpl.Text in_a_res;
9392 input Tpl.Text in_a_length;
9393 input DAE.Exp in_a_r_expr;
9394 input Boolean in_a_useFlatArrayNotation;
9395 input Tpl.Text in_a_stateDerVectorName;
9396 input Tpl.Text in_a_extraFuncsNamespace;
9397 input Tpl.Text in_a_extraFuncsDecl;
9398 input Tpl.Text in_a_extraFuncs;
9399 input SimCode.SimCode in_a_simCode;
9400 input Tpl.Text in_a_rangeExpPre;
9401 input SimCodeFunction.Context in_a_context;
9402 input Tpl.Text in_a_tmpVarDecls;
9403
9404 output Tpl.Text out_txt;
9405 output Tpl.Text out_a_stateDerVectorName;
9406 output Tpl.Text out_a_extraFuncsNamespace;
9407 output Tpl.Text out_a_extraFuncsDecl;
9408 output Tpl.Text out_a_extraFuncs;
9409 output Tpl.Text out_a_rangeExpPre;
9410 output Tpl.Text out_a_tmpVarDecls;
9411 algorithm
9412 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_rangeExpPre, out_a_tmpVarDecls) :=
9413 match(in_txt, in_mArg, in_a_res, in_a_length, in_a_r_expr, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_rangeExpPre, in_a_context, in_a_tmpVarDecls)
9414 local
9415 Tpl.Text txt;
9416 Tpl.Text a_res;
9417 Tpl.Text a_length;
9418 DAE.Exp a_r_expr;
9419 Boolean a_useFlatArrayNotation;
9420 Tpl.Text a_stateDerVectorName;
9421 Tpl.Text a_extraFuncsNamespace;
9422 Tpl.Text a_extraFuncsDecl;
9423 Tpl.Text a_extraFuncs;
9424 SimCode.SimCode a_simCode;
9425 Tpl.Text a_rangeExpPre;
9426 SimCodeFunction.Context a_context;
9427 Tpl.Text a_tmpVarDecls;
9428 DAE.Dimensions i_dims;
9429 Tpl.Text l_dimSizes;
9430 Tpl.Text l_dim__vec;
9431
9432 case ( txt,
9433 DAE.T_ARRAY(dims = i_dims),
9434 a_res,
9435 a_length,
9436 a_r_expr,
9437 a_useFlatArrayNotation,
9438 a_stateDerVectorName,
9439 a_extraFuncsNamespace,
9440 a_extraFuncsDecl,
9441 a_extraFuncs,
9442 a_simCode,
9443 a_rangeExpPre,
9444 a_context,
9445 a_tmpVarDecls )
9446 algorithm
9447 1 (l_dim__vec, a_tmpVarDecls) := tempDecl(Tpl.emptyTxt, "std::vector<size_t>", a_tmpVarDecls);
9448 1 l_dimSizes := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING("; ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
9449 1 (l_dimSizes, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_tmpVarDecls, a_rangeExpPre) := lm_233(l_dimSizes, i_dims, a_r_expr, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_tmpVarDecls, a_rangeExpPre, a_context, l_dim__vec);
9450 1 l_dimSizes := Tpl.popIter(l_dimSizes);
9451 1 txt := Tpl.writeText(txt, l_dim__vec);
9452 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING(".push_back("));
9453 1 txt := Tpl.writeText(txt, a_length);
9454 1 txt := Tpl.writeTok(txt, Tpl.ST_LINE(");\n"));
9455 1 txt := Tpl.writeText(txt, l_dimSizes);
9456 1 txt := Tpl.writeTok(txt, Tpl.ST_LINE(";\n"));
9457 1 txt := Tpl.writeText(txt, a_res);
9458 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING(".setDims("));
9459 1 txt := Tpl.writeText(txt, l_dim__vec);
9460 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
9461 1 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_rangeExpPre, a_tmpVarDecls);
9462
9463 case ( txt,
9464 _,
9465 a_res,
9466 a_length,
9467 _,
9468 _,
9469 a_stateDerVectorName,
9470 a_extraFuncsNamespace,
9471 a_extraFuncsDecl,
9472 a_extraFuncs,
9473 _,
9474 a_rangeExpPre,
9475 _,
9476 a_tmpVarDecls )
9477 algorithm
9478 5 txt := Tpl.writeText(txt, a_res);
9479 5 txt := Tpl.writeTok(txt, Tpl.ST_STRING(".setDims("));
9480 5 txt := Tpl.writeText(txt, a_length);
9481 5 txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
9482 5 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_rangeExpPre, a_tmpVarDecls);
9483 end match;
9484 end fun_234;
9485
9486 protected function fun_235
9487 input Tpl.Text in_txt;
9488 input Boolean in_mArg;
9489 input Absyn.Path in_a_ri_path;
9490 input Tpl.Text in_a_foundFirst;
9491 input Tpl.Text in_a_defaultValue;
9492 input Tpl.Text in_a_res;
9493 input Tpl.Text in_a_preDefault;
9494
9495 output Tpl.Text out_txt;
9496 algorithm
9497 out_txt :=
9498 match(in_txt, in_mArg, in_a_ri_path, in_a_foundFirst, in_a_defaultValue, in_a_res, in_a_preDefault)
9499 local
9500 Tpl.Text txt;
9501 Absyn.Path a_ri_path;
9502 Tpl.Text a_foundFirst;
9503 Tpl.Text a_defaultValue;
9504 Tpl.Text a_res;
9505 Tpl.Text a_preDefault;
9506
9507 case ( txt,
9508 true,
9509 _,
9510 _,
9511 a_defaultValue,
9512 a_res,
9513 a_preDefault )
9514 algorithm
9515 2 txt := Tpl.writeText(txt, a_preDefault);
9516 2 txt := Tpl.softNewLine(txt);
9517 2 txt := Tpl.writeText(txt, a_res);
9518 2 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = "));
9519 2 txt := Tpl.writeText(txt, a_defaultValue);
9520 2 txt := Tpl.writeTok(txt, Tpl.ST_STRING("; /* defaultValue */"));
9521 then txt;
9522
9523 case ( txt,
9524 _,
9525 a_ri_path,
9526 a_foundFirst,
9527 _,
9528 _,
9529 _ )
9530 algorithm
9531 1 txt := Tpl.writeText(txt, a_foundFirst);
9532 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = 0; /* "));
9533 1 txt := CodegenUtil.dotPath(txt, a_ri_path);
9534 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" lacks default-value */"));
9535 then txt;
9536 end match;
9537 end fun_235;
9538
9539 protected function fun_236
9540 input Tpl.Text in_txt;
9541 input Absyn.Path in_a_ri_path;
9542 input Tpl.Text in_a_defaultValue;
9543 input Tpl.Text in_a_preDefault;
9544 input Tpl.Text in_a_foundFirst;
9545 input Tpl.Text in_a_res;
9546 input Boolean in_a_useFlatArrayNotation;
9547 input Tpl.Text in_a_stateDerVectorName;
9548 input Tpl.Text in_a_extraFuncsNamespace;
9549 input Tpl.Text in_a_extraFuncsDecl;
9550 input Tpl.Text in_a_extraFuncs;
9551 input SimCode.SimCode in_a_simCode;
9552 input SimCodeFunction.Context in_a_context;
9553 input DAE.Exp in_a_r_expr;
9554 input Tpl.Text in_a_arrIndex;
9555 input DAE.ReductionIterators in_a_iterators;
9556 input Tpl.Text in_a_rangeExpPre;
9557 input Tpl.Text in_a_tmpVarDecls;
9558
9559 output Tpl.Text out_txt;
9560 output Tpl.Text out_a_stateDerVectorName;
9561 output Tpl.Text out_a_extraFuncsNamespace;
9562 output Tpl.Text out_a_extraFuncsDecl;
9563 output Tpl.Text out_a_extraFuncs;
9564 output Tpl.Text out_a_rangeExpPre;
9565 output Tpl.Text out_a_tmpVarDecls;
9566 algorithm
9567 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_rangeExpPre, out_a_tmpVarDecls) :=
9568 match(in_txt, in_a_ri_path, in_a_defaultValue, in_a_preDefault, in_a_foundFirst, in_a_res, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_context, in_a_r_expr, in_a_arrIndex, in_a_iterators, in_a_rangeExpPre, in_a_tmpVarDecls)
9569 local
9570 Tpl.Text txt;
9571 Tpl.Text a_defaultValue;
9572 Tpl.Text a_preDefault;
9573 Tpl.Text a_foundFirst;
9574 Tpl.Text a_res;
9575 Boolean a_useFlatArrayNotation;
9576 Tpl.Text a_stateDerVectorName;
9577 Tpl.Text a_extraFuncsNamespace;
9578 Tpl.Text a_extraFuncsDecl;
9579 Tpl.Text a_extraFuncs;
9580 SimCode.SimCode a_simCode;
9581 SimCodeFunction.Context a_context;
9582 DAE.Exp a_r_expr;
9583 Tpl.Text a_arrIndex;
9584 DAE.ReductionIterators a_iterators;
9585 Tpl.Text a_rangeExpPre;
9586 Tpl.Text a_tmpVarDecls;
9587 Absyn.Path i_ri_path;
9588 Boolean ret_3;
9589 DAE.Type ret_2;
9590 Tpl.Text l_0__;
9591 Tpl.Text l_length;
9592
9593 case ( txt,
9594 Absyn.IDENT(name = "array"),
9595 _,
9596 _,
9597 _,
9598 a_res,
9599 a_useFlatArrayNotation,
9600 a_stateDerVectorName,
9601 a_extraFuncsNamespace,
9602 a_extraFuncsDecl,
9603 a_extraFuncs,
9604 a_simCode,
9605 a_context,
9606 a_r_expr,
9607 a_arrIndex,
9608 a_iterators,
9609 a_rangeExpPre,
9610 a_tmpVarDecls )
9611 algorithm
9612 6 (l_length, a_tmpVarDecls) := tempDecl(Tpl.emptyTxt, "int", a_tmpVarDecls);
9613 6 a_rangeExpPre := Tpl.writeText(a_rangeExpPre, l_length);
9614 6 a_rangeExpPre := Tpl.writeTok(a_rangeExpPre, Tpl.ST_STRING(" = 0;"));
9615 6 a_rangeExpPre := Tpl.writeTok(a_rangeExpPre, Tpl.ST_NEW_LINE());
9616 6 (l_0__, a_rangeExpPre) := lm_231(Tpl.emptyTxt, a_iterators, l_length, a_rangeExpPre);
9617 6 txt := Tpl.writeText(txt, a_arrIndex);
9618 6 txt := Tpl.writeTok(txt, Tpl.ST_LINE(" = 1;\n"));
9619 6 ret_2 := Expression.typeof(a_r_expr);
9620 6 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_rangeExpPre, a_tmpVarDecls) := fun_234(txt, ret_2, a_res, l_length, a_r_expr, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_rangeExpPre, a_context, a_tmpVarDecls);
9621 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_rangeExpPre, a_tmpVarDecls);
9622
9623 case ( txt,
9624 i_ri_path,
9625 a_defaultValue,
9626 a_preDefault,
9627 a_foundFirst,
9628 a_res,
9629 _,
9630 a_stateDerVectorName,
9631 a_extraFuncsNamespace,
9632 a_extraFuncsDecl,
9633 a_extraFuncs,
9634 _,
9635 _,
9636 _,
9637 _,
9638 _,
9639 a_rangeExpPre,
9640 a_tmpVarDecls )
9641 algorithm
9642 3 ret_3 := Tpl.isEmpty(a_foundFirst);
9643 3 txt := fun_235(txt, ret_3, i_ri_path, a_foundFirst, a_defaultValue, a_res, a_preDefault);
9644 3 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_rangeExpPre, a_tmpVarDecls);
9645 end match;
9646 end fun_236;
9647
9648 protected function fun_237
9649 input Tpl.Text in_txt;
9650 input DAE.ReductionIterators in_a_iterators;
9651 input Tpl.Text in_a_endLoop;
9652
9653 output Tpl.Text out_txt;
9654 algorithm
9655 out_txt :=
9656 match(in_txt, in_a_iterators, in_a_endLoop)
9657 local
9658 Tpl.Text txt;
9659 Tpl.Text a_endLoop;
9660 DAE.ReductionIterators i_iterators;
9661 Integer ret_0;
9662
9663 case ( txt,
9664 (i_iterators as _ :: _),
9665 a_endLoop )
9666 algorithm
9667 9 txt := Tpl.writeTok(txt, Tpl.ST_STRING("else if ("));
9668 9 txt := Tpl.writeText(txt, a_endLoop);
9669 9 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" == "));
9670 9 ret_0 := listLength(i_iterators);
9671 9 txt := Tpl.writeStr(txt, intString(ret_0));
9672 9 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
9673 ") {\n",
9674 " break;\n",
9675 "} else {\n",
9676 " throw ModelicaSimulationError(MODEL_ARRAY_FUNCTION,\"Internal error\");\n",
9677 "}"
9678 }, false));
9679 then txt;
9680
9681 case ( txt,
9682 _,
9683 _ )
9684 then txt;
9685 end match;
9686 end fun_237;
9687
9688 protected function fun_238
9689 input Tpl.Text in_txt;
9690 input Boolean in_mArg;
9691 input Tpl.Text in_a_res;
9692 input Tpl.Text in_a_resTail;
9693
9694 output Tpl.Text out_txt;
9695 algorithm
9696 out_txt :=
9697 match(in_txt, in_mArg, in_a_res, in_a_resTail)
9698 local
9699 Tpl.Text txt;
9700 Tpl.Text a_res;
9701 Tpl.Text a_resTail;
9702
9703 case ( txt,
9704 true,
9705 _,
9706 _ )
9707 then txt;
9708
9709 case ( txt,
9710 _,
9711 a_res,
9712 a_resTail )
9713 algorithm
9714 ✗ txt := Tpl.writeText(txt, a_resTail);
9715 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = &"));
9716 ✗ txt := Tpl.writeText(txt, a_res);
9717 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
9718 then txt;
9719 end match;
9720 end fun_238;
9721
9722 protected function fun_239
9723 input Tpl.Text in_txt;
9724 input Boolean in_mArg;
9725 input Tpl.Text in_a_foundFirst;
9726
9727 output Tpl.Text out_txt;
9728 algorithm
9729 out_txt :=
9730 match(in_txt, in_mArg, in_a_foundFirst)
9731 local
9732 Tpl.Text txt;
9733 Tpl.Text a_foundFirst;
9734
9735 case ( txt,
9736 true,
9737 _ )
9738 then txt;
9739
9740 case ( txt,
9741 _,
9742 a_foundFirst )
9743 algorithm
9744 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("if (!"));
9745 1 txt := Tpl.writeText(txt, a_foundFirst);
9746 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING(") throw ModelicaSimulationError(MODEL_ARRAY_FUNCTION,\"Internal error\");"));
9747 then txt;
9748 end match;
9749 end fun_239;
9750
9751 protected function fun_240
9752 input Tpl.Text in_txt;
9753 input Boolean in_mArg;
9754 input Tpl.Text in_a_resTail;
9755
9756 output Tpl.Text out_txt;
9757 algorithm
9758 out_txt :=
9759 match(in_txt, in_mArg, in_a_resTail)
9760 local
9761 Tpl.Text txt;
9762 Tpl.Text a_resTail;
9763
9764 case ( txt,
9765 true,
9766 _ )
9767 then txt;
9768
9769 case ( txt,
9770 _,
9771 a_resTail )
9772 algorithm
9773 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("*"));
9774 ✗ txt := Tpl.writeText(txt, a_resTail);
9775 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = NULL;"));
9776 then txt;
9777 end match;
9778 end fun_240;
9779
9780 public function daeExpReduction
9781 input Tpl.Text in_txt;
9782 input DAE.Exp in_a_exp;
9783 input SimCodeFunction.Context in_a_context;
9784 input Tpl.Text in_a_preExp;
9785 input Tpl.Text in_a_varDecls;
9786 input SimCode.SimCode in_a_simCode;
9787 input Tpl.Text in_a_extraFuncs;
9788 input Tpl.Text in_a_extraFuncsDecl;
9789 input Tpl.Text in_a_extraFuncsNamespace;
9790 input Tpl.Text in_a_stateDerVectorName;
9791 input Boolean in_a_useFlatArrayNotation;
9792
9793 output Tpl.Text out_txt;
9794 output Tpl.Text out_a_preExp;
9795 output Tpl.Text out_a_varDecls;
9796 output Tpl.Text out_a_extraFuncs;
9797 output Tpl.Text out_a_extraFuncsDecl;
9798 output Tpl.Text out_a_extraFuncsNamespace;
9799 output Tpl.Text out_a_stateDerVectorName;
9800 algorithm
9801 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
9802 match(in_txt, in_a_exp, in_a_context, in_a_preExp, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
9803 local
9804 Tpl.Text txt;
9805 SimCodeFunction.Context a_context;
9806 Tpl.Text a_preExp;
9807 Tpl.Text a_varDecls;
9808 SimCode.SimCode a_simCode;
9809 Tpl.Text a_extraFuncs;
9810 Tpl.Text a_extraFuncsDecl;
9811 Tpl.Text a_extraFuncsNamespace;
9812 Tpl.Text a_stateDerVectorName;
9813 Boolean a_useFlatArrayNotation;
9814 DAE.Exp i_exp;
9815 DAE.ReductionIterators i_iterators;
9816 Option<DAE.Exp> i_ri_foldExp;
9817 DAE.Exp i_r_expr;
9818 String i_ri_foldName;
9819 String i_ri_resultName;
9820 Option<Values.Value> i_ri_defaultValue;
9821 Absyn.Path i_ri_path;
9822 DAE.Exp i_r;
9823 Tpl.Text txt_36;
9824 Boolean ret_35;
9825 Boolean ret_34;
9826 Boolean ret_33;
9827 Integer ret_32;
9828 DAE.Type ret_31;
9829 DAE.ComponentRef ret_30;
9830 DAE.ComponentRef ret_29;
9831 DAE.Type ret_28;
9832 Boolean ret_27;
9833 Boolean ret_26;
9834 Boolean ret_25;
9835 Integer ret_24;
9836 Tpl.Text l_loop;
9837 Tpl.Text l_firstValue;
9838 Tpl.Text l_loopHeadIter;
9839 Tpl.Text l_endLoop;
9840 Tpl.Text l_foldExp;
9841 Tpl.Text l_reductionBodyExprWork;
9842 DAE.Type ret_17;
9843 Tpl.Text l_bodyExprType;
9844 DAE.ComponentRef ret_15;
9845 Tpl.Text l_reductionBodyExpr;
9846 Tpl.Text l_defaultValue;
9847 Tpl.Text l_resTail;
9848 Tpl.Text l_preDefault;
9849 Tpl.Text l_resTmp;
9850 DAE.ComponentRef ret_9;
9851 Tpl.Text l_res;
9852 DAE.Type ret_7;
9853 Tpl.Text l_resType;
9854 Tpl.Text l_foundFirst;
9855 Tpl.Text l_arrIndex;
9856 Tpl.Text l_arrayTypeResult;
9857 Tpl.Text l_rangeExpPre;
9858 Tpl.Text l_bodyExpPre;
9859 Tpl.Text l_tmpVarDecls;
9860
9861 case ( txt,
9862 (i_r as DAE.REDUCTION(reductionInfo = DAE.REDUCTIONINFO(iterType = Absyn.THREAD(), path = i_ri_path, defaultValue = i_ri_defaultValue, resultName = i_ri_resultName, foldName = i_ri_foldName, foldExp = i_ri_foldExp), iterators = i_iterators, expr = i_r_expr)),
9863 a_context,
9864 a_preExp,
9865 a_varDecls,
9866 a_simCode,
9867 a_extraFuncs,
9868 a_extraFuncsDecl,
9869 a_extraFuncsNamespace,
9870 a_stateDerVectorName,
9871 a_useFlatArrayNotation )
9872 algorithm
9873 ✗ l_tmpVarDecls := Tpl.emptyTxt;
9874 ✗ l_bodyExpPre := Tpl.emptyTxt;
9875 ✗ l_rangeExpPre := Tpl.emptyTxt;
9876 ✗ l_arrayTypeResult := expTypeFromExpArray(Tpl.emptyTxt, i_r);
9877 ✗ (l_arrIndex, l_tmpVarDecls) := fun_193(Tpl.emptyTxt, i_ri_path, l_tmpVarDecls);
9878 ✗ (l_foundFirst, l_tmpVarDecls) := fun_195(Tpl.emptyTxt, i_ri_path, l_tmpVarDecls, i_ri_defaultValue);
9879 ✗ ret_7 := Expression.typeof(i_r);
9880 ✗ l_resType := expTypeArrayIf(Tpl.emptyTxt, ret_7);
9881 ✗ ret_9 := ComponentReference.makeUntypedCrefIdent(i_ri_resultName);
9882 ✗ (l_res, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := contextCref(Tpl.emptyTxt, ret_9, a_context, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
9883 ✗ l_tmpVarDecls := Tpl.writeText(l_tmpVarDecls, l_resType);
9884 ✗ l_tmpVarDecls := Tpl.writeTok(l_tmpVarDecls, Tpl.ST_STRING(" "));
9885 ✗ l_tmpVarDecls := Tpl.writeText(l_tmpVarDecls, l_res);
9886 ✗ l_tmpVarDecls := Tpl.writeTok(l_tmpVarDecls, Tpl.ST_STRING(";"));
9887 ✗ l_tmpVarDecls := Tpl.writeTok(l_tmpVarDecls, Tpl.ST_NEW_LINE());
9888 ✗ (l_resTmp, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(l_resType), a_varDecls);
9889 ✗ l_preDefault := Tpl.emptyTxt;
9890 ✗ (l_resTail, l_tmpVarDecls) := fun_196(Tpl.emptyTxt, i_ri_path, l_tmpVarDecls);
9891 ✗ (l_defaultValue, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, l_tmpVarDecls, l_preDefault) := fun_198(Tpl.emptyTxt, i_ri_path, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, l_tmpVarDecls, l_preDefault, a_context, i_ri_defaultValue);
9892 ✗ ret_15 := ComponentReference.makeUntypedCrefIdent(i_ri_foldName);
9893 ✗ (l_reductionBodyExpr, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := contextCref(Tpl.emptyTxt, ret_15, a_context, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
9894 ✗ ret_17 := Expression.typeof(i_r_expr);
9895 ✗ l_bodyExprType := expTypeArrayIf(Tpl.emptyTxt, ret_17);
9896 ✗ (l_reductionBodyExprWork, l_bodyExpPre, l_tmpVarDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_r_expr, a_context, l_bodyExpPre, l_tmpVarDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
9897 ✗ l_tmpVarDecls := Tpl.writeText(l_tmpVarDecls, l_bodyExprType);
9898 ✗ l_tmpVarDecls := Tpl.writeTok(l_tmpVarDecls, Tpl.ST_STRING(" "));
9899 ✗ l_tmpVarDecls := Tpl.writeText(l_tmpVarDecls, l_reductionBodyExpr);
9900 ✗ l_tmpVarDecls := Tpl.writeTok(l_tmpVarDecls, Tpl.ST_STRING(";"));
9901 ✗ l_tmpVarDecls := Tpl.writeTok(l_tmpVarDecls, Tpl.ST_NEW_LINE());
9902 ✗ l_bodyExpPre := Tpl.writeText(l_bodyExpPre, l_reductionBodyExpr);
9903 ✗ l_bodyExpPre := Tpl.writeTok(l_bodyExpPre, Tpl.ST_STRING(" = "));
9904 ✗ l_bodyExpPre := Tpl.writeText(l_bodyExpPre, l_reductionBodyExprWork);
9905 ✗ l_bodyExpPre := Tpl.writeTok(l_bodyExpPre, Tpl.ST_STRING(";"));
9906 ✗ l_bodyExpPre := Tpl.writeTok(l_bodyExpPre, Tpl.ST_NEW_LINE());
9907 ✗ (l_foldExp, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, l_tmpVarDecls, a_varDecls) := fun_202(Tpl.emptyTxt, i_ri_path, l_foundFirst, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, l_tmpVarDecls, a_context, i_ri_foldExp, l_arrIndex, a_varDecls, i_r_expr, l_res, l_reductionBodyExpr, l_resTail);
9908 ✗ (l_endLoop, l_tmpVarDecls) := tempDecl(Tpl.emptyTxt, "int", l_tmpVarDecls);
9909 ✗ (l_loopHeadIter, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, l_rangeExpPre, l_tmpVarDecls) := lm_206(Tpl.emptyTxt, i_iterators, l_endLoop, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, l_rangeExpPre, a_context, l_tmpVarDecls);
9910 ✗ (l_firstValue, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, l_rangeExpPre, l_tmpVarDecls) := fun_212(Tpl.emptyTxt, i_ri_path, l_defaultValue, l_preDefault, l_foundFirst, l_res, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_context, i_r_expr, l_arrIndex, i_iterators, l_rangeExpPre, l_tmpVarDecls);
9911 ✗ l_loop := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_LINE("while(1) {\n"));
9912 ✗ l_loop := Tpl.pushBlock(l_loop, Tpl.BT_INDENT(2));
9913 ✗ l_loop := Tpl.writeText(l_loop, l_endLoop);
9914 ✗ l_loop := Tpl.writeTok(l_loop, Tpl.ST_STRING(" = "));
9915 ✗ ret_24 := listLength(i_iterators);
9916 ✗ l_loop := Tpl.writeStr(l_loop, intString(ret_24));
9917 ✗ l_loop := Tpl.writeTok(l_loop, Tpl.ST_LINE(";\n"));
9918 ✗ l_loop := Tpl.writeText(l_loop, l_loopHeadIter);
9919 ✗ l_loop := Tpl.softNewLine(l_loop);
9920 ✗ l_loop := Tpl.writeTok(l_loop, Tpl.ST_STRING("if ("));
9921 ✗ l_loop := Tpl.writeText(l_loop, l_endLoop);
9922 ✗ l_loop := Tpl.writeTok(l_loop, Tpl.ST_LINE(" == 0) {\n"));
9923 ✗ l_loop := Tpl.pushBlock(l_loop, Tpl.BT_INDENT(2));
9924 ✗ l_loop := Tpl.writeText(l_loop, l_bodyExpPre);
9925 ✗ l_loop := Tpl.softNewLine(l_loop);
9926 ✗ l_loop := Tpl.writeText(l_loop, l_foldExp);
9927 ✗ l_loop := Tpl.softNewLine(l_loop);
9928 ✗ l_loop := Tpl.popBlock(l_loop);
9929 ✗ l_loop := Tpl.writeTok(l_loop, Tpl.ST_STRING("} "));
9930 ✗ l_loop := fun_213(l_loop, i_iterators, l_endLoop);
9931 ✗ l_loop := Tpl.softNewLine(l_loop);
9932 ✗ l_loop := Tpl.popBlock(l_loop);
9933 ✗ l_loop := Tpl.writeTok(l_loop, Tpl.ST_STRING("}"));
9934 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_LINE("{\n"));
9935 ✗ a_preExp := Tpl.pushBlock(a_preExp, Tpl.BT_INDENT(2));
9936 ✗ a_preExp := Tpl.writeText(a_preExp, l_tmpVarDecls);
9937 ✗ a_preExp := Tpl.softNewLine(a_preExp);
9938 ✗ a_preExp := Tpl.writeText(a_preExp, l_rangeExpPre);
9939 ✗ a_preExp := Tpl.softNewLine(a_preExp);
9940 ✗ a_preExp := Tpl.writeText(a_preExp, l_firstValue);
9941 ✗ a_preExp := Tpl.softNewLine(a_preExp);
9942 ✗ ret_25 := Tpl.isEmpty(l_resTail);
9943 ✗ a_preExp := fun_214(a_preExp, ret_25, l_res, l_resTail);
9944 ✗ a_preExp := Tpl.softNewLine(a_preExp);
9945 ✗ a_preExp := Tpl.writeText(a_preExp, l_loop);
9946 ✗ a_preExp := Tpl.softNewLine(a_preExp);
9947 ✗ ret_26 := Tpl.isEmpty(l_foundFirst);
9948 ✗ a_preExp := fun_215(a_preExp, ret_26, l_foundFirst);
9949 ✗ a_preExp := Tpl.softNewLine(a_preExp);
9950 ✗ ret_27 := Tpl.isEmpty(l_resTail);
9951 ✗ a_preExp := fun_216(a_preExp, ret_27, l_resTail);
9952 ✗ a_preExp := Tpl.softNewLine(a_preExp);
9953 ✗ a_preExp := Tpl.writeText(a_preExp, l_resTmp);
9954 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(" = "));
9955 ✗ a_preExp := Tpl.writeText(a_preExp, l_res);
9956 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_LINE(";\n"));
9957 ✗ a_preExp := Tpl.popBlock(a_preExp);
9958 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("}"));
9959 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
9960 ✗ txt := Tpl.writeText(txt, l_resTmp);
9961 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
9962
9963 case ( txt,
9964 (i_r as DAE.REDUCTION(reductionInfo = DAE.REDUCTIONINFO(iterType = Absyn.COMBINE(), path = i_ri_path, defaultValue = i_ri_defaultValue, resultName = i_ri_resultName, foldName = i_ri_foldName, foldExp = i_ri_foldExp), iterators = (i_iterators as {_}), expr = i_r_expr)),
9965 a_context,
9966 a_preExp,
9967 a_varDecls,
9968 a_simCode,
9969 a_extraFuncs,
9970 a_extraFuncsDecl,
9971 a_extraFuncsNamespace,
9972 a_stateDerVectorName,
9973 a_useFlatArrayNotation )
9974 algorithm
9975 9 l_tmpVarDecls := Tpl.emptyTxt;
9976 9 l_bodyExpPre := Tpl.emptyTxt;
9977 9 l_rangeExpPre := Tpl.emptyTxt;
9978 9 l_arrayTypeResult := expTypeFromExpArray(Tpl.emptyTxt, i_r);
9979 9 (l_arrIndex, l_tmpVarDecls) := fun_217(Tpl.emptyTxt, i_ri_path, l_tmpVarDecls);
9980 9 (l_foundFirst, l_tmpVarDecls) := fun_219(Tpl.emptyTxt, i_ri_path, l_tmpVarDecls, i_ri_defaultValue);
9981 9 ret_28 := Expression.typeof(i_r);
9982 9 l_resType := expTypeArrayIf(Tpl.emptyTxt, ret_28);
9983 9 ret_29 := ComponentReference.makeUntypedCrefIdent(i_ri_resultName);
9984 9 (l_res, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := contextCref(Tpl.emptyTxt, ret_29, a_context, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
9985 9 l_tmpVarDecls := Tpl.writeText(l_tmpVarDecls, l_resType);
9986 9 l_tmpVarDecls := Tpl.writeTok(l_tmpVarDecls, Tpl.ST_STRING(" "));
9987 9 l_tmpVarDecls := Tpl.writeText(l_tmpVarDecls, l_res);
9988 9 l_tmpVarDecls := Tpl.writeTok(l_tmpVarDecls, Tpl.ST_STRING(";"));
9989 9 l_tmpVarDecls := Tpl.writeTok(l_tmpVarDecls, Tpl.ST_NEW_LINE());
9990 9 (l_resTmp, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(l_resType), a_varDecls);
9991 9 l_preDefault := Tpl.emptyTxt;
9992 9 (l_resTail, l_tmpVarDecls) := fun_220(Tpl.emptyTxt, i_ri_path, l_tmpVarDecls);
9993 9 (l_defaultValue, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, l_tmpVarDecls, l_preDefault) := fun_222(Tpl.emptyTxt, i_ri_path, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, l_tmpVarDecls, l_preDefault, a_context, i_ri_defaultValue);
9994 9 ret_30 := ComponentReference.makeUntypedCrefIdent(i_ri_foldName);
9995 9 (l_reductionBodyExpr, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := contextCref(Tpl.emptyTxt, ret_30, a_context, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
9996 9 ret_31 := Expression.typeof(i_r_expr);
9997 9 l_bodyExprType := expTypeArrayIf(Tpl.emptyTxt, ret_31);
9998 9 (l_reductionBodyExprWork, l_bodyExpPre, l_tmpVarDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_r_expr, a_context, l_bodyExpPre, l_tmpVarDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
9999 9 l_tmpVarDecls := Tpl.writeText(l_tmpVarDecls, l_bodyExprType);
10000 9 l_tmpVarDecls := Tpl.writeTok(l_tmpVarDecls, Tpl.ST_STRING(" "));
10001 9 l_tmpVarDecls := Tpl.writeText(l_tmpVarDecls, l_reductionBodyExpr);
10002 9 l_tmpVarDecls := Tpl.writeTok(l_tmpVarDecls, Tpl.ST_STRING(";"));
10003 9 l_tmpVarDecls := Tpl.writeTok(l_tmpVarDecls, Tpl.ST_NEW_LINE());
10004 9 l_bodyExpPre := Tpl.writeText(l_bodyExpPre, l_reductionBodyExpr);
10005 9 l_bodyExpPre := Tpl.writeTok(l_bodyExpPre, Tpl.ST_STRING(" = "));
10006 9 l_bodyExpPre := Tpl.writeText(l_bodyExpPre, l_reductionBodyExprWork);
10007 9 l_bodyExpPre := Tpl.writeTok(l_bodyExpPre, Tpl.ST_STRING(";"));
10008 9 l_bodyExpPre := Tpl.writeTok(l_bodyExpPre, Tpl.ST_NEW_LINE());
10009 9 (l_foldExp, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, l_tmpVarDecls, a_varDecls) := fun_226(Tpl.emptyTxt, i_ri_path, l_foundFirst, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, l_tmpVarDecls, a_context, i_ri_foldExp, l_arrIndex, a_varDecls, i_r_expr, l_res, l_reductionBodyExpr, l_resTail);
10010 9 (l_endLoop, l_tmpVarDecls) := tempDecl(Tpl.emptyTxt, "int", l_tmpVarDecls);
10011 9 (l_loopHeadIter, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, l_rangeExpPre, l_tmpVarDecls) := lm_230(Tpl.emptyTxt, i_iterators, l_endLoop, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, l_rangeExpPre, a_context, l_tmpVarDecls);
10012 9 (l_firstValue, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, l_rangeExpPre, l_tmpVarDecls) := fun_236(Tpl.emptyTxt, i_ri_path, l_defaultValue, l_preDefault, l_foundFirst, l_res, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_context, i_r_expr, l_arrIndex, i_iterators, l_rangeExpPre, l_tmpVarDecls);
10013 9 l_loop := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_LINE("while(1) {\n"));
10014 9 l_loop := Tpl.pushBlock(l_loop, Tpl.BT_INDENT(2));
10015 9 l_loop := Tpl.writeText(l_loop, l_endLoop);
10016 9 l_loop := Tpl.writeTok(l_loop, Tpl.ST_STRING(" = "));
10017 9 ret_32 := listLength(i_iterators);
10018 9 l_loop := Tpl.writeStr(l_loop, intString(ret_32));
10019 9 l_loop := Tpl.writeTok(l_loop, Tpl.ST_LINE(";\n"));
10020 9 l_loop := Tpl.writeText(l_loop, l_loopHeadIter);
10021 9 l_loop := Tpl.softNewLine(l_loop);
10022 9 l_loop := Tpl.writeTok(l_loop, Tpl.ST_STRING("if ("));
10023 9 l_loop := Tpl.writeText(l_loop, l_endLoop);
10024 9 l_loop := Tpl.writeTok(l_loop, Tpl.ST_LINE(" == 0) {\n"));
10025 9 l_loop := Tpl.pushBlock(l_loop, Tpl.BT_INDENT(2));
10026 9 l_loop := Tpl.writeText(l_loop, l_bodyExpPre);
10027 9 l_loop := Tpl.softNewLine(l_loop);
10028 9 l_loop := Tpl.writeText(l_loop, l_foldExp);
10029 9 l_loop := Tpl.softNewLine(l_loop);
10030 9 l_loop := Tpl.popBlock(l_loop);
10031 9 l_loop := Tpl.writeTok(l_loop, Tpl.ST_STRING("} "));
10032 9 l_loop := fun_237(l_loop, i_iterators, l_endLoop);
10033 9 l_loop := Tpl.softNewLine(l_loop);
10034 9 l_loop := Tpl.popBlock(l_loop);
10035 9 l_loop := Tpl.writeTok(l_loop, Tpl.ST_STRING("}"));
10036 9 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_LINE("{\n"));
10037 9 a_preExp := Tpl.pushBlock(a_preExp, Tpl.BT_INDENT(2));
10038 9 a_preExp := Tpl.writeText(a_preExp, l_tmpVarDecls);
10039 9 a_preExp := Tpl.softNewLine(a_preExp);
10040 9 a_preExp := Tpl.writeText(a_preExp, l_rangeExpPre);
10041 9 a_preExp := Tpl.softNewLine(a_preExp);
10042 9 a_preExp := Tpl.writeText(a_preExp, l_firstValue);
10043 9 a_preExp := Tpl.softNewLine(a_preExp);
10044 9 ret_33 := Tpl.isEmpty(l_resTail);
10045 9 a_preExp := fun_238(a_preExp, ret_33, l_res, l_resTail);
10046 9 a_preExp := Tpl.softNewLine(a_preExp);
10047 9 a_preExp := Tpl.writeText(a_preExp, l_loop);
10048 9 a_preExp := Tpl.softNewLine(a_preExp);
10049 9 ret_34 := Tpl.isEmpty(l_foundFirst);
10050 9 a_preExp := fun_239(a_preExp, ret_34, l_foundFirst);
10051 9 a_preExp := Tpl.softNewLine(a_preExp);
10052 9 ret_35 := Tpl.isEmpty(l_resTail);
10053 9 a_preExp := fun_240(a_preExp, ret_35, l_resTail);
10054 9 a_preExp := Tpl.softNewLine(a_preExp);
10055 9 a_preExp := Tpl.writeText(a_preExp, l_resTmp);
10056 9 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(" = "));
10057 9 a_preExp := Tpl.writeText(a_preExp, l_res);
10058 9 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_LINE(";\n"));
10059 9 a_preExp := Tpl.popBlock(a_preExp);
10060 9 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("}"));
10061 9 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
10062 9 txt := Tpl.writeText(txt, l_resTmp);
10063 9 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
10064
10065 case ( txt,
10066 i_exp,
10067 _,
10068 a_preExp,
10069 a_varDecls,
10070 _,
10071 a_extraFuncs,
10072 a_extraFuncsDecl,
10073 a_extraFuncsNamespace,
10074 a_stateDerVectorName,
10075 _ )
10076 algorithm
10077 ✗ txt_36 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("Code generation does not support multiple iterators: "));
10078 ✗ txt_36 := ExpressionDumpTpl.dumpExp(txt_36, i_exp, "\"");
10079 ✗ txt := error(txt, Tpl.sourceInfo("CodegenCppCommon.tpl", 1238, 14), Tpl.textString(txt_36));
10080 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
10081 end match;
10082 end daeExpReduction;
10083
10084 public function daeExpSize
10085 input Tpl.Text in_txt;
10086 input DAE.Exp in_a_exp;
10087 input SimCodeFunction.Context in_a_context;
10088 input Tpl.Text in_a_preExp;
10089 input Tpl.Text in_a_varDecls;
10090 input SimCode.SimCode in_a_simCode;
10091 input Tpl.Text in_a_extraFuncs;
10092 input Tpl.Text in_a_extraFuncsDecl;
10093 input Tpl.Text in_a_extraFuncsNamespace;
10094 input Tpl.Text in_a_stateDerVectorName;
10095 input Boolean in_a_useFlatArrayNotation;
10096
10097 output Tpl.Text out_txt;
10098 output Tpl.Text out_a_preExp;
10099 output Tpl.Text out_a_varDecls;
10100 output Tpl.Text out_a_extraFuncs;
10101 output Tpl.Text out_a_extraFuncsDecl;
10102 output Tpl.Text out_a_extraFuncsNamespace;
10103 output Tpl.Text out_a_stateDerVectorName;
10104 algorithm
10105 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
10106 match(in_txt, in_a_exp, in_a_context, in_a_preExp, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
10107 local
10108 Tpl.Text txt;
10109 SimCodeFunction.Context a_context;
10110 Tpl.Text a_preExp;
10111 Tpl.Text a_varDecls;
10112 SimCode.SimCode a_simCode;
10113 Tpl.Text a_extraFuncs;
10114 Tpl.Text a_extraFuncsDecl;
10115 Tpl.Text a_extraFuncsNamespace;
10116 Tpl.Text a_stateDerVectorName;
10117 Boolean a_useFlatArrayNotation;
10118 DAE.Exp i_dim;
10119 DAE.Exp i_exp;
10120 Tpl.Text txt_3;
10121 Tpl.Text l_tmp;
10122 Tpl.Text l_dimPart;
10123 Tpl.Text l_expPart;
10124
10125 case ( txt,
10126 DAE.SIZE(sz = SOME(i_dim), exp = i_exp),
10127 a_context,
10128 a_preExp,
10129 a_varDecls,
10130 a_simCode,
10131 a_extraFuncs,
10132 a_extraFuncsDecl,
10133 a_extraFuncsNamespace,
10134 a_stateDerVectorName,
10135 a_useFlatArrayNotation )
10136 algorithm
10137 131 (l_expPart, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
10138 131 (l_dimPart, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_dim, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
10139 131 txt := Tpl.writeText(txt, l_expPart);
10140 131 txt := Tpl.writeTok(txt, Tpl.ST_STRING(".getDim("));
10141 131 txt := Tpl.writeText(txt, l_dimPart);
10142 131 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
10143 131 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
10144
10145 case ( txt,
10146 DAE.SIZE(sz = NONE(), exp = i_exp),
10147 a_context,
10148 a_preExp,
10149 a_varDecls,
10150 a_simCode,
10151 a_extraFuncs,
10152 a_extraFuncsDecl,
10153 a_extraFuncsNamespace,
10154 a_stateDerVectorName,
10155 a_useFlatArrayNotation )
10156 algorithm
10157 1 (l_expPart, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
10158 1 (l_tmp, a_varDecls) := tempDecl(Tpl.emptyTxt, "vector<size_t>", a_varDecls);
10159 1 a_preExp := Tpl.writeText(a_preExp, l_tmp);
10160 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(" = "));
10161 1 a_preExp := Tpl.writeText(a_preExp, l_expPart);
10162 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING_LIST({
10163 ".getDims();\n",
10164 "DynArrayDim1<int> "
10165 }, false));
10166 1 a_preExp := Tpl.writeText(a_preExp, l_tmp);
10167 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("_size("));
10168 1 a_preExp := Tpl.writeText(a_preExp, l_tmp);
10169 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING_LIST({
10170 ".size());\n",
10171 "for (size_t "
10172 }, false));
10173 1 a_preExp := Tpl.writeText(a_preExp, l_tmp);
10174 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("_i = 1; "));
10175 1 a_preExp := Tpl.writeText(a_preExp, l_tmp);
10176 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("_i <= "));
10177 1 a_preExp := Tpl.writeText(a_preExp, l_tmp);
10178 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(".size(); "));
10179 1 a_preExp := Tpl.writeText(a_preExp, l_tmp);
10180 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_LINE("_i++)\n"));
10181 1 a_preExp := Tpl.pushBlock(a_preExp, Tpl.BT_INDENT(2));
10182 1 a_preExp := Tpl.writeText(a_preExp, l_tmp);
10183 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("_size("));
10184 1 a_preExp := Tpl.writeText(a_preExp, l_tmp);
10185 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("_i) = (int)"));
10186 1 a_preExp := Tpl.writeText(a_preExp, l_tmp);
10187 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("["));
10188 1 a_preExp := Tpl.writeText(a_preExp, l_tmp);
10189 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("_i-1];"));
10190 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
10191 1 a_preExp := Tpl.popBlock(a_preExp);
10192 1 txt := Tpl.writeText(txt, l_tmp);
10193 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_size"));
10194 1 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
10195
10196 case ( txt,
10197 i_exp,
10198 _,
10199 a_preExp,
10200 a_varDecls,
10201 _,
10202 a_extraFuncs,
10203 a_extraFuncsDecl,
10204 a_extraFuncsNamespace,
10205 a_stateDerVectorName,
10206 _ )
10207 algorithm
10208 ✗ txt_3 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_exp, "\"");
10209 ✗ txt_3 := Tpl.writeTok(txt_3, Tpl.ST_STRING(" not implemented"));
10210 ✗ txt := error(txt, Tpl.sourceInfo("CodegenCppCommon.tpl", 1262, 14), Tpl.textString(txt_3));
10211 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
10212 end match;
10213 end daeExpSize;
10214
10215 protected function lm_243
10216 input output Tpl.Text txt;
10217 input list<list<DAE.Exp>> items;
10218 input Boolean a_useFlatArrayNotation;
10219 input output Tpl.Text a_stateDerVectorName;
10220 input output Tpl.Text a_extraFuncsNamespace;
10221 input output Tpl.Text a_extraFuncsDecl;
10222 input output Tpl.Text a_extraFuncs;
10223 input SimCode.SimCode a_simCode;
10224 input output Tpl.Text a_preExp;
10225 input output Tpl.Text a_varDecls;
10226 input SimCodeFunction.Context a_context;
10227 algorithm
10228
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 8 times.
28 for lstElt_243 in items loop
10229 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_preExp, a_varDecls) := match lstElt_243
10230 local
10231 list<DAE.Exp> i_row;
10232 Tpl.Text l_vars;
10233
10234 case i_row
10235 algorithm
10236 20 (l_vars, a_varDecls, a_preExp, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpMatrixRow2(Tpl.emptyTxt, i_row, a_context, a_varDecls, a_preExp, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
10237 20 txt := Tpl.writeText(txt, l_vars);
10238 20 txt := Tpl.nextIter(txt);
10239 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_preExp, a_varDecls);
10240 end match;
10241 end for;
10242 end lm_243;
10243
10244 protected function fun_244
10245 input Tpl.Text in_txt;
10246 input String in_mArg;
10247 input Tpl.Text in_a_vars;
10248 input Tpl.Text in_a_arrayTypeStr;
10249 input Tpl.Text in_a_arrayVar;
10250 input Tpl.Text in_a_StatArrayDim;
10251 input Boolean in_a_useFlatArrayNotation;
10252 input Tpl.Text in_a_stateDerVectorName;
10253 input Tpl.Text in_a_extraFuncsNamespace;
10254 input Tpl.Text in_a_extraFuncsDecl;
10255 input Tpl.Text in_a_extraFuncs;
10256 input SimCode.SimCode in_a_simCode;
10257 input Tpl.Text in_a_preExp;
10258 input Tpl.Text in_a_varDecls;
10259 input SimCodeFunction.Context in_a_context;
10260 input list<list<DAE.Exp>> in_a_m_matrix;
10261
10262 output Tpl.Text out_txt;
10263 output Tpl.Text out_a_stateDerVectorName;
10264 output Tpl.Text out_a_extraFuncsNamespace;
10265 output Tpl.Text out_a_extraFuncsDecl;
10266 output Tpl.Text out_a_extraFuncs;
10267 output Tpl.Text out_a_preExp;
10268 output Tpl.Text out_a_varDecls;
10269 algorithm
10270 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_preExp, out_a_varDecls) :=
10271 match(in_txt, in_mArg, in_a_vars, in_a_arrayTypeStr, in_a_arrayVar, in_a_StatArrayDim, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_preExp, in_a_varDecls, in_a_context, in_a_m_matrix)
10272 local
10273 Tpl.Text txt;
10274 Tpl.Text a_vars;
10275 Tpl.Text a_arrayTypeStr;
10276 Tpl.Text a_arrayVar;
10277 Tpl.Text a_StatArrayDim;
10278 Boolean a_useFlatArrayNotation;
10279 Tpl.Text a_stateDerVectorName;
10280 Tpl.Text a_extraFuncsNamespace;
10281 Tpl.Text a_extraFuncsDecl;
10282 Tpl.Text a_extraFuncs;
10283 SimCode.SimCode a_simCode;
10284 Tpl.Text a_preExp;
10285 Tpl.Text a_varDecls;
10286 SimCodeFunction.Context a_context;
10287 list<list<DAE.Exp>> a_m_matrix;
10288 Tpl.Text l_params;
10289
10290 case ( txt,
10291 "NO_ASSIGN",
10292 _,
10293 a_arrayTypeStr,
10294 a_arrayVar,
10295 a_StatArrayDim,
10296 a_useFlatArrayNotation,
10297 a_stateDerVectorName,
10298 a_extraFuncsNamespace,
10299 a_extraFuncsDecl,
10300 a_extraFuncs,
10301 a_simCode,
10302 a_preExp,
10303 a_varDecls,
10304 a_context,
10305 a_m_matrix )
10306 algorithm
10307 8 l_params := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(",")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
10308 8 (l_params, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_preExp, a_varDecls) := lm_243(l_params, a_m_matrix, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_preExp, a_varDecls, a_context);
10309 8 l_params := Tpl.popIter(l_params);
10310 8 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_LINE("//default matrix assign\n"));
10311 8 a_preExp := Tpl.writeText(a_preExp, a_StatArrayDim);
10312 8 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(" "));
10313 8 a_preExp := Tpl.writeText(a_preExp, a_arrayVar);
10314 8 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_LINE(";\n"));
10315 8 a_preExp := Tpl.writeText(a_preExp, a_arrayTypeStr);
10316 8 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(" "));
10317 8 a_preExp := Tpl.writeText(a_preExp, a_arrayVar);
10318 8 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("_data[] = {"));
10319 8 a_preExp := Tpl.writeText(a_preExp, l_params);
10320 8 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING_LIST({
10321 "};\n",
10322 "assignRowMajorData("
10323 }, false));
10324 8 a_preExp := Tpl.writeText(a_preExp, a_arrayVar);
10325 8 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("_data, "));
10326 8 a_preExp := Tpl.writeText(a_preExp, a_arrayVar);
10327 8 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
10328 8 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
10329 8 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_preExp, a_varDecls);
10330
10331 case ( txt,
10332 _,
10333 a_vars,
10334 _,
10335 a_arrayVar,
10336 a_StatArrayDim,
10337 _,
10338 a_stateDerVectorName,
10339 a_extraFuncsNamespace,
10340 a_extraFuncsDecl,
10341 a_extraFuncs,
10342 _,
10343 a_preExp,
10344 a_varDecls,
10345 _,
10346 _ )
10347 algorithm
10348 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_LINE("//optimized matrix assign\n"));
10349 ✗ a_preExp := Tpl.writeText(a_preExp, a_StatArrayDim);
10350 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(" "));
10351 ✗ a_preExp := Tpl.writeText(a_preExp, a_arrayVar);
10352 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_LINE(";\n"));
10353 ✗ a_preExp := Tpl.writeText(a_preExp, a_arrayVar);
10354 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(".assign( "));
10355 ✗ a_preExp := Tpl.writeText(a_preExp, a_vars);
10356 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(" );"));
10357 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
10358 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_preExp, a_varDecls);
10359 end match;
10360 end fun_244;
10361
10362 protected function fun_245
10363 input Tpl.Text in_txt;
10364 input list<list<DAE.Exp>> in_a_m_matrix;
10365 input Tpl.Text in_a_arrayTypeStr;
10366 input Tpl.Text in_a_arrayVar;
10367 input Tpl.Text in_a_StatArrayDim;
10368 input Boolean in_a_useFlatArrayNotation;
10369 input Tpl.Text in_a_stateDerVectorName;
10370 input Tpl.Text in_a_extraFuncsNamespace;
10371 input Tpl.Text in_a_extraFuncsDecl;
10372 input Tpl.Text in_a_extraFuncs;
10373 input SimCode.SimCode in_a_simCode;
10374 input Tpl.Text in_a_preExp;
10375 input Tpl.Text in_a_varDecls;
10376 input SimCodeFunction.Context in_a_context;
10377
10378 output Tpl.Text out_txt;
10379 output Tpl.Text out_a_stateDerVectorName;
10380 output Tpl.Text out_a_extraFuncsNamespace;
10381 output Tpl.Text out_a_extraFuncsDecl;
10382 output Tpl.Text out_a_extraFuncs;
10383 output Tpl.Text out_a_preExp;
10384 output Tpl.Text out_a_varDecls;
10385 algorithm
10386 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_preExp, out_a_varDecls) :=
10387 match(in_txt, in_a_m_matrix, in_a_arrayTypeStr, in_a_arrayVar, in_a_StatArrayDim, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_preExp, in_a_varDecls, in_a_context)
10388 local
10389 Tpl.Text txt;
10390 Tpl.Text a_arrayTypeStr;
10391 Tpl.Text a_arrayVar;
10392 Tpl.Text a_StatArrayDim;
10393 Boolean a_useFlatArrayNotation;
10394 Tpl.Text a_stateDerVectorName;
10395 Tpl.Text a_extraFuncsNamespace;
10396 Tpl.Text a_extraFuncsDecl;
10397 Tpl.Text a_extraFuncs;
10398 SimCode.SimCode a_simCode;
10399 Tpl.Text a_preExp;
10400 Tpl.Text a_varDecls;
10401 SimCodeFunction.Context a_context;
10402 list<list<DAE.Exp>> i_m_matrix;
10403 String str_1;
10404 Tpl.Text l_vars;
10405
10406 case ( txt,
10407 (i_m_matrix as _ :: _),
10408 a_arrayTypeStr,
10409 a_arrayVar,
10410 a_StatArrayDim,
10411 a_useFlatArrayNotation,
10412 a_stateDerVectorName,
10413 a_extraFuncsNamespace,
10414 a_extraFuncsDecl,
10415 a_extraFuncs,
10416 a_simCode,
10417 a_preExp,
10418 a_varDecls,
10419 a_context )
10420 algorithm
10421 8 l_vars := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("NO_ASSIGN"));
10422 8 str_1 := Tpl.textString(l_vars);
10423 8 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_preExp, a_varDecls) := fun_244(txt, str_1, l_vars, a_arrayTypeStr, a_arrayVar, a_StatArrayDim, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_preExp, a_varDecls, a_context, i_m_matrix);
10424 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_preExp, a_varDecls);
10425
10426 case ( txt,
10427 _,
10428 _,
10429 _,
10430 _,
10431 _,
10432 a_stateDerVectorName,
10433 a_extraFuncsNamespace,
10434 a_extraFuncsDecl,
10435 a_extraFuncs,
10436 _,
10437 a_preExp,
10438 a_varDecls,
10439 _ )
10440 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_preExp, a_varDecls);
10441 end match;
10442 end fun_245;
10443
10444 public function daeExpMatrix
10445 input Tpl.Text in_txt;
10446 input DAE.Exp in_a_exp;
10447 input SimCodeFunction.Context in_a_context;
10448 input Tpl.Text in_a_preExp;
10449 input Tpl.Text in_a_varDecls;
10450 input SimCode.SimCode in_a_simCode;
10451 input Tpl.Text in_a_extraFuncs;
10452 input Tpl.Text in_a_extraFuncsDecl;
10453 input Tpl.Text in_a_extraFuncsNamespace;
10454 input Tpl.Text in_a_stateDerVectorName;
10455 input Boolean in_a_useFlatArrayNotation;
10456
10457 output Tpl.Text out_txt;
10458 output Tpl.Text out_a_preExp;
10459 output Tpl.Text out_a_varDecls;
10460 output Tpl.Text out_a_extraFuncs;
10461 output Tpl.Text out_a_extraFuncsDecl;
10462 output Tpl.Text out_a_extraFuncsNamespace;
10463 output Tpl.Text out_a_stateDerVectorName;
10464 algorithm
10465 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
10466 match(in_txt, in_a_exp, in_a_context, in_a_preExp, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
10467 local
10468 Tpl.Text txt;
10469 SimCodeFunction.Context a_context;
10470 Tpl.Text a_preExp;
10471 Tpl.Text a_varDecls;
10472 SimCode.SimCode a_simCode;
10473 Tpl.Text a_extraFuncs;
10474 Tpl.Text a_extraFuncsDecl;
10475 Tpl.Text a_extraFuncsNamespace;
10476 Tpl.Text a_stateDerVectorName;
10477 Boolean a_useFlatArrayNotation;
10478 list<list<DAE.Exp>> i_m_matrix;
10479 list<DAE.Exp> i_row1;
10480 DAE.Type i_ty;
10481 Tpl.Text l_matrixassign;
10482 Integer ret_7;
10483 Tpl.Text l_dim__cols;
10484 Tpl.Text l_vals;
10485 Tpl.Text l_arrayVar;
10486 Tpl.Text l_StatArrayDim;
10487 Tpl.Text l_tmp;
10488 Tpl.Text l_arrayTypeStr;
10489 Tpl.Text l_typestr;
10490
10491 case ( txt,
10492 DAE.MATRIX(matrix = {{}}, ty = i_ty),
10493 _,
10494 a_preExp,
10495 a_varDecls,
10496 _,
10497 a_extraFuncs,
10498 a_extraFuncsDecl,
10499 a_extraFuncsNamespace,
10500 a_stateDerVectorName,
10501 _ )
10502 algorithm
10503 ✗ l_typestr := expTypeShort(Tpl.emptyTxt, i_ty);
10504 ✗ l_arrayTypeStr := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("DynArrayDim2<"));
10505 ✗ l_arrayTypeStr := Tpl.writeText(l_arrayTypeStr, l_typestr);
10506 ✗ l_arrayTypeStr := Tpl.writeTok(l_arrayTypeStr, Tpl.ST_STRING(">"));
10507 ✗ (l_tmp, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(l_arrayTypeStr), a_varDecls);
10508 ✗ txt := Tpl.writeText(txt, l_tmp);
10509 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
10510
10511 case ( txt,
10512 DAE.MATRIX(matrix = {}, ty = i_ty),
10513 _,
10514 a_preExp,
10515 a_varDecls,
10516 _,
10517 a_extraFuncs,
10518 a_extraFuncsDecl,
10519 a_extraFuncsNamespace,
10520 a_stateDerVectorName,
10521 _ )
10522 algorithm
10523 ✗ l_typestr := expTypeShort(Tpl.emptyTxt, i_ty);
10524 ✗ l_arrayTypeStr := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("DynArrayDim2<"));
10525 ✗ l_arrayTypeStr := Tpl.writeText(l_arrayTypeStr, l_typestr);
10526 ✗ l_arrayTypeStr := Tpl.writeTok(l_arrayTypeStr, Tpl.ST_STRING(">"));
10527 ✗ (l_tmp, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(l_arrayTypeStr), a_varDecls);
10528 ✗ txt := Tpl.writeText(txt, l_tmp);
10529 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
10530
10531 case ( txt,
10532 DAE.MATRIX(matrix = (i_m_matrix as i_row1 :: _), ty = i_ty),
10533 a_context,
10534 a_preExp,
10535 a_varDecls,
10536 a_simCode,
10537 a_extraFuncs,
10538 a_extraFuncsDecl,
10539 a_extraFuncsNamespace,
10540 a_stateDerVectorName,
10541 a_useFlatArrayNotation )
10542 algorithm
10543 8 l_arrayTypeStr := expTypeShort(Tpl.emptyTxt, i_ty);
10544 8 l_StatArrayDim := expTypeArrayIf(Tpl.emptyTxt, i_ty);
10545 8 l_tmp := Tpl.emptyTxt;
10546 8 (l_arrayVar, l_tmp) := tempDecl(Tpl.emptyTxt, Tpl.textString(l_arrayTypeStr), l_tmp);
10547 l_vals := Tpl.emptyTxt;
10548 8 ret_7 := listLength(i_row1);
10549 8 l_dim__cols := Tpl.writeStr(Tpl.emptyTxt, intString(ret_7));
10550 8 (l_matrixassign, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_preExp, a_varDecls) := fun_245(Tpl.emptyTxt, i_m_matrix, l_arrayTypeStr, l_arrayVar, l_StatArrayDim, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_preExp, a_varDecls, a_context);
10551 8 txt := Tpl.writeText(txt, l_arrayVar);
10552 8 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
10553
10554 case ( txt,
10555 _,
10556 _,
10557 a_preExp,
10558 a_varDecls,
10559 _,
10560 a_extraFuncs,
10561 a_extraFuncsDecl,
10562 a_extraFuncsNamespace,
10563 a_stateDerVectorName,
10564 _ )
10565 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
10566 end match;
10567 end daeExpMatrix;
10568
10569 protected function lm_247
10570 input output Tpl.Text txt;
10571 input list<DAE.Exp> items;
10572 input Boolean a_useFlatArrayNotation;
10573 input output Tpl.Text a_stateDerVectorName;
10574 input output Tpl.Text a_extraFuncsNamespace;
10575 input output Tpl.Text a_extraFuncsDecl;
10576 input output Tpl.Text a_extraFuncs;
10577 input SimCode.SimCode a_simCode;
10578 input output Tpl.Text a_varDecls;
10579 input output Tpl.Text a_preExp;
10580 input SimCodeFunction.Context a_context;
10581 algorithm
10582
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 20 times.
72 for lstElt_247 in items loop
10583 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_247
10584 local
10585 DAE.Exp i_e;
10586 Tpl.Text l_expVar;
10587
10588 case i_e
10589 algorithm
10590 52 (l_expVar, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
10591 52 txt := Tpl.writeText(txt, l_expVar);
10592 52 txt := Tpl.nextIter(txt);
10593 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
10594 end match;
10595 end for;
10596 end lm_247;
10597
10598 public function daeExpMatrixRow2
10599 input Tpl.Text txt;
10600 input list<DAE.Exp> a_row;
10601 input SimCodeFunction.Context a_context;
10602 input Tpl.Text a_varDecls;
10603 input Tpl.Text a_preExp;
10604 input SimCode.SimCode a_simCode;
10605 input Tpl.Text a_extraFuncs;
10606 input Tpl.Text a_extraFuncsDecl;
10607 input Tpl.Text a_extraFuncsNamespace;
10608 input Tpl.Text a_stateDerVectorName;
10609 input Boolean a_useFlatArrayNotation;
10610
10611 output Tpl.Text out_txt;
10612 output Tpl.Text out_a_varDecls;
10613 output Tpl.Text out_a_preExp;
10614 output Tpl.Text out_a_extraFuncs;
10615 output Tpl.Text out_a_extraFuncsDecl;
10616 output Tpl.Text out_a_extraFuncsNamespace;
10617 output Tpl.Text out_a_stateDerVectorName;
10618 protected
10619 Tpl.Text l_varLstStr;
10620 algorithm
10621 20 l_varLstStr := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(",")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
10622 20 (l_varLstStr, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls, out_a_preExp) := lm_247(l_varLstStr, a_row, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
10623 20 l_varLstStr := Tpl.popIter(l_varLstStr);
10624 20 out_txt := Tpl.writeText(txt, l_varLstStr);
10625 end daeExpMatrixRow2;
10626
10627 protected function fun_249
10628 input Tpl.Text in_txt;
10629 input list<list<DAE.Exp>> in_a_matrix;
10630 input Tpl.Text in_a_stateDerVectorName;
10631 input Tpl.Text in_a_extraFuncsNamespace;
10632 input Tpl.Text in_a_extraFuncsDecl;
10633 input Tpl.Text in_a_extraFuncs;
10634 input SimCode.SimCode in_a_simCode;
10635 input SimCodeFunction.Context in_a_context;
10636
10637 output Tpl.Text out_txt;
10638 output Tpl.Text out_a_stateDerVectorName;
10639 output Tpl.Text out_a_extraFuncsNamespace;
10640 output Tpl.Text out_a_extraFuncsDecl;
10641 output Tpl.Text out_a_extraFuncs;
10642 algorithm
10643 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs) :=
10644 match(in_txt, in_a_matrix, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_context)
10645 local
10646 Tpl.Text txt;
10647 Tpl.Text a_stateDerVectorName;
10648 Tpl.Text a_extraFuncsNamespace;
10649 Tpl.Text a_extraFuncsDecl;
10650 Tpl.Text a_extraFuncs;
10651 SimCode.SimCode a_simCode;
10652 SimCodeFunction.Context a_context;
10653 list<DAE.Exp> i_row;
10654
10655 case ( txt,
10656 i_row :: _,
10657 a_stateDerVectorName,
10658 a_extraFuncsNamespace,
10659 a_extraFuncsDecl,
10660 a_extraFuncs,
10661 a_simCode,
10662 a_context )
10663 algorithm
10664 ✗ (txt, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpMatrixName(txt, i_row, a_context, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
10665 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs);
10666
10667 case ( txt,
10668 _,
10669 a_stateDerVectorName,
10670 a_extraFuncsNamespace,
10671 a_extraFuncsDecl,
10672 a_extraFuncs,
10673 _,
10674 _ )
10675 algorithm
10676 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("NO_ASSIGN"));
10677 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs);
10678 end match;
10679 end fun_249;
10680
10681 protected function fun_250
10682 input Tpl.Text in_txt;
10683 input Boolean in_mArg;
10684 input list<list<DAE.Exp>> in_a_matrix;
10685 input SimCodeFunction.Context in_a_context;
10686 input SimCode.SimCode in_a_simCode;
10687 input Tpl.Text in_a_extraFuncs;
10688 input Tpl.Text in_a_extraFuncsDecl;
10689 input Tpl.Text in_a_extraFuncsNamespace;
10690 input Tpl.Text in_a_stateDerVectorName;
10691
10692 output Tpl.Text out_txt;
10693 output Tpl.Text out_a_extraFuncs;
10694 output Tpl.Text out_a_extraFuncsDecl;
10695 output Tpl.Text out_a_extraFuncsNamespace;
10696 output Tpl.Text out_a_stateDerVectorName;
10697 algorithm
10698 (out_txt, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
10699 match(in_txt, in_mArg, in_a_matrix, in_a_context, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName)
10700 local
10701 Tpl.Text txt;
10702 list<list<DAE.Exp>> a_matrix;
10703 SimCodeFunction.Context a_context;
10704 SimCode.SimCode a_simCode;
10705 Tpl.Text a_extraFuncs;
10706 Tpl.Text a_extraFuncsDecl;
10707 Tpl.Text a_extraFuncsNamespace;
10708 Tpl.Text a_stateDerVectorName;
10709
10710 case ( txt,
10711 false,
10712 _,
10713 _,
10714 _,
10715 a_extraFuncs,
10716 a_extraFuncsDecl,
10717 a_extraFuncsNamespace,
10718 a_stateDerVectorName )
10719 algorithm
10720 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("NO_ASSIGN"));
10721 then (txt, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
10722
10723 case ( txt,
10724 _,
10725 a_matrix,
10726 a_context,
10727 a_simCode,
10728 a_extraFuncs,
10729 a_extraFuncsDecl,
10730 a_extraFuncsNamespace,
10731 a_stateDerVectorName )
10732 algorithm
10733 ✗ (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs) := fun_249(txt, a_matrix, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_context);
10734 ✗ then (txt, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
10735 end match;
10736 end fun_250;
10737
10738 public function daeExpMatrixRow
10739 input Tpl.Text txt;
10740 input list<list<DAE.Exp>> a_matrix;
10741 input SimCodeFunction.Context a_context;
10742 input SimCode.SimCode a_simCode;
10743 input Tpl.Text a_extraFuncs;
10744 input Tpl.Text a_extraFuncsDecl;
10745 input Tpl.Text a_extraFuncsNamespace;
10746 input Tpl.Text a_stateDerVectorName;
10747
10748 output Tpl.Text out_txt;
10749 output Tpl.Text out_a_extraFuncs;
10750 output Tpl.Text out_a_extraFuncsDecl;
10751 output Tpl.Text out_a_extraFuncsNamespace;
10752 output Tpl.Text out_a_stateDerVectorName;
10753 protected
10754 Boolean ret_1;
10755 list<DAE.Exp> ret_0;
10756 algorithm
10757 ✗ ret_0 := List.flatten(a_matrix);
10758 ✗ ret_1 := Expression.isCrefListWithEqualIdents(ret_0);
10759 ✗ (out_txt, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) := fun_250(txt, ret_1, a_matrix, a_context, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
10760 end daeExpMatrixRow;
10761
10762 protected function fun_252
10763 input Tpl.Text in_txt;
10764 input list<DAE.Exp> in_a_row;
10765 input Tpl.Text in_a_stateDerVectorName;
10766 input Tpl.Text in_a_extraFuncsNamespace;
10767 input Tpl.Text in_a_extraFuncsDecl;
10768 input Tpl.Text in_a_extraFuncs;
10769 input SimCode.SimCode in_a_simCode;
10770 input SimCodeFunction.Context in_a_context;
10771
10772 output Tpl.Text out_txt;
10773 output Tpl.Text out_a_stateDerVectorName;
10774 output Tpl.Text out_a_extraFuncsNamespace;
10775 output Tpl.Text out_a_extraFuncsDecl;
10776 output Tpl.Text out_a_extraFuncs;
10777 algorithm
10778 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs) :=
10779 match(in_txt, in_a_row, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_context)
10780 local
10781 Tpl.Text txt;
10782 Tpl.Text a_stateDerVectorName;
10783 Tpl.Text a_extraFuncsNamespace;
10784 Tpl.Text a_extraFuncsDecl;
10785 Tpl.Text a_extraFuncs;
10786 SimCode.SimCode a_simCode;
10787 SimCodeFunction.Context a_context;
10788 DAE.ComponentRef i_cr;
10789 DAE.ComponentRef ret_0;
10790
10791 case ( txt,
10792 DAE.CREF(componentRef = i_cr) :: _,
10793 a_stateDerVectorName,
10794 a_extraFuncsNamespace,
10795 a_extraFuncsDecl,
10796 a_extraFuncs,
10797 a_simCode,
10798 a_context )
10799 algorithm
10800 ✗ ret_0 := ComponentReferenceBasics.crefStripLastSubs(i_cr);
10801 ✗ (txt, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := contextCref(txt, ret_0, a_context, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, false);
10802 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs);
10803
10804 case ( txt,
10805 _,
10806 a_stateDerVectorName,
10807 a_extraFuncsNamespace,
10808 a_extraFuncsDecl,
10809 a_extraFuncs,
10810 _,
10811 _ )
10812 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs);
10813 end match;
10814 end fun_252;
10815
10816 public function daeExpMatrixName
10817 input Tpl.Text txt;
10818 input list<DAE.Exp> a_row;
10819 input SimCodeFunction.Context a_context;
10820 input SimCode.SimCode a_simCode;
10821 input Tpl.Text a_extraFuncs;
10822 input Tpl.Text a_extraFuncsDecl;
10823 input Tpl.Text a_stateDerVectorName;
10824 input Tpl.Text a_extraFuncsNamespace;
10825
10826 output Tpl.Text out_txt;
10827 output Tpl.Text out_a_extraFuncs;
10828 output Tpl.Text out_a_extraFuncsDecl;
10829 output Tpl.Text out_a_stateDerVectorName;
10830 output Tpl.Text out_a_extraFuncsNamespace;
10831 protected
10832 Tpl.Text l_preExp;
10833 Tpl.Text l_varDecls;
10834 algorithm
10835 l_varDecls := Tpl.emptyTxt;
10836 l_preExp := Tpl.emptyTxt;
10837 ✗ (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs) := fun_252(txt, a_row, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_context);
10838 end daeExpMatrixName;
10839
10840 public function daeExpMatrixName2
10841 input Tpl.Text in_txt;
10842 input DAE.ComponentRef in_a_cr;
10843
10844 output Tpl.Text out_txt;
10845 algorithm
10846 out_txt :=
10847 match(in_txt, in_a_cr)
10848 local
10849 Tpl.Text txt;
10850 DAE.ComponentRef i_componentRef;
10851 list<DAE.Subscript> i_subscriptLst;
10852 DAE.Ident i_ident;
10853 String ret_1;
10854 String ret_0;
10855
10856 case ( txt,
10857 DAE.CREF_IDENT(ident = i_ident) )
10858 algorithm
10859 ✗ ret_0 := System.unquoteIdentifier(i_ident);
10860 ✗ txt := Tpl.writeStr(txt, ret_0);
10861 then txt;
10862
10863 case ( txt,
10864 DAE.CREF_QUAL(ident = i_ident, subscriptLst = i_subscriptLst, componentRef = i_componentRef) )
10865 algorithm
10866 ✗ ret_1 := System.unquoteIdentifier(i_ident);
10867 ✗ txt := Tpl.writeStr(txt, ret_1);
10868 ✗ txt := subscriptsToCStrForArray(txt, i_subscriptLst);
10869 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_P_"));
10870 ✗ txt := daeExpMatrixName2(txt, i_componentRef);
10871 then txt;
10872
10873 case ( txt,
10874 DAE.WILD() )
10875 algorithm
10876 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
10877 then txt;
10878
10879 case ( txt,
10880 _ )
10881 algorithm
10882 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("CREF_NOT_IDENT_OR_QUAL"));
10883 then txt;
10884 end match;
10885 end daeExpMatrixName2;
10886
10887 protected function fun_255
10888 input Tpl.Text in_txt;
10889 input Boolean in_a_scalar;
10890 input Tpl.Text in_a_arrayTypeStr;
10891 input Boolean in_a_useFlatArrayNotation;
10892 input Tpl.Text in_a_stateDerVectorName;
10893 input Tpl.Text in_a_extraFuncsNamespace;
10894 input Tpl.Text in_a_extraFuncsDecl;
10895 input Tpl.Text in_a_extraFuncs;
10896 input SimCode.SimCode in_a_simCode;
10897 input Tpl.Text in_a_preExp;
10898 input SimCodeFunction.Context in_a_context;
10899 input list<DAE.Exp> in_a_array;
10900 input Tpl.Text in_a_arrayVar;
10901 input Tpl.Text in_a_ArrayType;
10902 input Tpl.Text in_a_varDecls;
10903
10904 output Tpl.Text out_txt;
10905 output Tpl.Text out_a_stateDerVectorName;
10906 output Tpl.Text out_a_extraFuncsNamespace;
10907 output Tpl.Text out_a_extraFuncsDecl;
10908 output Tpl.Text out_a_extraFuncs;
10909 output Tpl.Text out_a_preExp;
10910 output Tpl.Text out_a_varDecls;
10911 algorithm
10912 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_preExp, out_a_varDecls) :=
10913 match(in_txt, in_a_scalar, in_a_arrayTypeStr, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_preExp, in_a_context, in_a_array, in_a_arrayVar, in_a_ArrayType, in_a_varDecls)
10914 local
10915 Tpl.Text txt;
10916 Tpl.Text a_arrayTypeStr;
10917 Boolean a_useFlatArrayNotation;
10918 Tpl.Text a_stateDerVectorName;
10919 Tpl.Text a_extraFuncsNamespace;
10920 Tpl.Text a_extraFuncsDecl;
10921 Tpl.Text a_extraFuncs;
10922 SimCode.SimCode a_simCode;
10923 Tpl.Text a_preExp;
10924 SimCodeFunction.Context a_context;
10925 list<DAE.Exp> a_array;
10926 Tpl.Text a_arrayVar;
10927 Tpl.Text a_ArrayType;
10928 Tpl.Text a_varDecls;
10929 Tpl.Text l_params;
10930
10931 case ( txt,
10932 false,
10933 _,
10934 a_useFlatArrayNotation,
10935 a_stateDerVectorName,
10936 a_extraFuncsNamespace,
10937 a_extraFuncsDecl,
10938 a_extraFuncs,
10939 a_simCode,
10940 a_preExp,
10941 a_context,
10942 a_array,
10943 a_arrayVar,
10944 a_ArrayType,
10945 a_varDecls )
10946 algorithm
10947 2 a_varDecls := Tpl.writeText(a_varDecls, a_ArrayType);
10948 2 a_varDecls := Tpl.writeTok(a_varDecls, Tpl.ST_STRING(" "));
10949 2 a_varDecls := Tpl.writeText(a_varDecls, a_arrayVar);
10950 2 a_varDecls := Tpl.writeTok(a_varDecls, Tpl.ST_STRING(";"));
10951 2 a_varDecls := Tpl.writeTok(a_varDecls, Tpl.ST_NEW_LINE());
10952 2 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpArray3(txt, a_array, Tpl.textString(a_arrayVar), Tpl.textString(a_ArrayType), a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
10953 2 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_preExp, a_varDecls);
10954
10955 case ( txt,
10956 _,
10957 a_arrayTypeStr,
10958 a_useFlatArrayNotation,
10959 a_stateDerVectorName,
10960 a_extraFuncsNamespace,
10961 a_extraFuncsDecl,
10962 a_extraFuncs,
10963 a_simCode,
10964 a_preExp,
10965 a_context,
10966 a_array,
10967 a_arrayVar,
10968 a_ArrayType,
10969 a_varDecls )
10970 algorithm
10971 407 (l_params, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpArray2(Tpl.emptyTxt, a_array, Tpl.textString(a_arrayVar), Tpl.textString(a_ArrayType), Tpl.textString(a_arrayTypeStr), a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
10972 407 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_preExp, a_varDecls);
10973 end match;
10974 end fun_255;
10975
10976 public function daeExpArray
10977 input Tpl.Text in_txt;
10978 input DAE.Exp in_a_exp;
10979 input SimCodeFunction.Context in_a_context;
10980 input Tpl.Text in_a_preExp;
10981 input Tpl.Text in_a_varDecls;
10982 input SimCode.SimCode in_a_simCode;
10983 input Tpl.Text in_a_extraFuncs;
10984 input Tpl.Text in_a_extraFuncsDecl;
10985 input Tpl.Text in_a_extraFuncsNamespace;
10986 input Tpl.Text in_a_stateDerVectorName;
10987 input Boolean in_a_useFlatArrayNotation;
10988
10989 output Tpl.Text out_txt;
10990 output Tpl.Text out_a_preExp;
10991 output Tpl.Text out_a_varDecls;
10992 output Tpl.Text out_a_extraFuncs;
10993 output Tpl.Text out_a_extraFuncsDecl;
10994 output Tpl.Text out_a_extraFuncsNamespace;
10995 output Tpl.Text out_a_stateDerVectorName;
10996 algorithm
10997 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
10998 match(in_txt, in_a_exp, in_a_context, in_a_preExp, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
10999 local
11000 Tpl.Text txt;
11001 SimCodeFunction.Context a_context;
11002 Tpl.Text a_preExp;
11003 Tpl.Text a_varDecls;
11004 SimCode.SimCode a_simCode;
11005 Tpl.Text a_extraFuncs;
11006 Tpl.Text a_extraFuncsDecl;
11007 Tpl.Text a_extraFuncsNamespace;
11008 Tpl.Text a_stateDerVectorName;
11009 Boolean a_useFlatArrayNotation;
11010 list<DAE.Exp> i_array;
11011 Boolean i_scalar;
11012 DAE.Type i_ty;
11013 Tpl.Text l_tmpdecl;
11014 Tpl.Text l_arrayDef;
11015 Tpl.Text l_arrayassign;
11016 Tpl.Text l_arrayVar;
11017 Tpl.Text l_tmpVar;
11018 Tpl.Text l_ArrayType;
11019 Tpl.Text l_arrayTypeStr;
11020
11021 case ( txt,
11022 DAE.ARRAY(array = (i_array as _ :: _), ty = i_ty, scalar = i_scalar),
11023 a_context,
11024 a_preExp,
11025 a_varDecls,
11026 a_simCode,
11027 a_extraFuncs,
11028 a_extraFuncsDecl,
11029 a_extraFuncsNamespace,
11030 a_stateDerVectorName,
11031 a_useFlatArrayNotation )
11032 algorithm
11033 409 l_arrayTypeStr := expTypeShort(Tpl.emptyTxt, i_ty);
11034 409 l_ArrayType := expTypeArrayIf(Tpl.emptyTxt, i_ty);
11035 409 l_tmpVar := Tpl.emptyTxt;
11036 409 (l_arrayVar, l_tmpVar) := tempDecl(Tpl.emptyTxt, Tpl.textString(l_arrayTypeStr), l_tmpVar);
11037 409 (l_arrayassign, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_preExp, a_varDecls) := fun_255(Tpl.emptyTxt, i_scalar, l_arrayTypeStr, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_preExp, a_context, i_array, l_arrayVar, l_ArrayType, a_varDecls);
11038 409 txt := Tpl.writeText(txt, l_arrayVar);
11039 409 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
11040
11041 case ( txt,
11042 DAE.ARRAY(ty = i_ty),
11043 _,
11044 a_preExp,
11045 a_varDecls,
11046 _,
11047 a_extraFuncs,
11048 a_extraFuncsDecl,
11049 a_extraFuncsNamespace,
11050 a_stateDerVectorName,
11051 _ )
11052 algorithm
11053 ✗ l_arrayTypeStr := expTypeShort(Tpl.emptyTxt, i_ty);
11054 ✗ l_arrayDef := expTypeArrayIf(Tpl.emptyTxt, i_ty);
11055 ✗ l_tmpdecl := Tpl.emptyTxt;
11056 ✗ (l_arrayVar, l_tmpdecl) := tempDecl(Tpl.emptyTxt, Tpl.textString(l_arrayTypeStr), l_tmpdecl);
11057 l_tmpVar := Tpl.emptyTxt;
11058 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING_LIST({
11059 "\n",
11060 " //tmp array\n"
11061 }, true));
11062 ✗ a_preExp := Tpl.pushBlock(a_preExp, Tpl.BT_INDENT(3));
11063 ✗ a_preExp := Tpl.writeText(a_preExp, l_arrayDef);
11064 ✗ a_preExp := Tpl.writeText(a_preExp, l_arrayVar);
11065 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(";"));
11066 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
11067 ✗ a_preExp := Tpl.popBlock(a_preExp);
11068 ✗ txt := Tpl.writeText(txt, l_arrayVar);
11069 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
11070
11071 case ( txt,
11072 _,
11073 _,
11074 a_preExp,
11075 a_varDecls,
11076 _,
11077 a_extraFuncs,
11078 a_extraFuncsDecl,
11079 a_extraFuncsNamespace,
11080 a_stateDerVectorName,
11081 _ )
11082 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
11083 end match;
11084 end daeExpArray;
11085
11086 protected function lm_257
11087 input output Tpl.Text txt;
11088 input list<DAE.Exp> items;
11089 input list<DAE.Exp> a_array;
11090 input String a_arrayVar;
11091 input Boolean a_useFlatArrayNotation;
11092 input output Tpl.Text a_stateDerVectorName;
11093 input output Tpl.Text a_extraFuncsNamespace;
11094 input output Tpl.Text a_extraFuncsDecl;
11095 input output Tpl.Text a_extraFuncs;
11096 input SimCode.SimCode a_simCode;
11097 input output Tpl.Text a_varDecls;
11098 input output Tpl.Text a_preExp;
11099 input SimCodeFunction.Context a_context;
11100 algorithm
11101
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 for lstElt_257 in items loop
11102 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_257
11103 local
11104 Integer x_i0;
11105 DAE.Exp i_e;
11106 Integer ret_1;
11107 Tpl.Text l_subArraycall;
11108
11109 case i_e
11110 algorithm
11111 6 x_i0 := Tpl.getIteri_i0(txt);
11112 6 (l_subArraycall, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
11113 6 txt := Tpl.writeStr(txt, a_arrayVar);
11114 6 txt := Tpl.writeTok(txt, Tpl.ST_STRING(".append("));
11115 6 txt := Tpl.writeStr(txt, intString(x_i0));
11116 6 txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
11117 6 txt := Tpl.writeText(txt, l_subArraycall);
11118 6 txt := Tpl.writeTok(txt, Tpl.ST_STRING(","));
11119 6 ret_1 := listLength(a_array);
11120 6 txt := Tpl.writeStr(txt, intString(ret_1));
11121 6 txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
11122 6 txt := Tpl.nextIter(txt);
11123 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
11124 end match;
11125 end for;
11126 end lm_257;
11127
11128 public function daeExpArray3
11129 input Tpl.Text txt;
11130 input list<DAE.Exp> a_array;
11131 input String a_arrayVar;
11132 input String a_ArrayType;
11133 input SimCodeFunction.Context a_context;
11134 input Tpl.Text a_preExp;
11135 input Tpl.Text a_varDecls;
11136 input SimCode.SimCode a_simCode;
11137 input Tpl.Text a_extraFuncs;
11138 input Tpl.Text a_extraFuncsDecl;
11139 input Tpl.Text a_extraFuncsNamespace;
11140 input Tpl.Text a_stateDerVectorName;
11141 input Boolean a_useFlatArrayNotation;
11142
11143 output Tpl.Text out_txt;
11144 output Tpl.Text out_a_preExp;
11145 output Tpl.Text out_a_varDecls;
11146 output Tpl.Text out_a_extraFuncs;
11147 output Tpl.Text out_a_extraFuncsDecl;
11148 output Tpl.Text out_a_extraFuncsNamespace;
11149 output Tpl.Text out_a_stateDerVectorName;
11150 protected
11151 Tpl.Text l_arraycreate;
11152 algorithm
11153 2 l_arraycreate := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(1, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
11154 2 (l_arraycreate, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls, out_a_preExp) := lm_257(l_arraycreate, a_array, a_array, a_arrayVar, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
11155 2 l_arraycreate := Tpl.popIter(l_arraycreate);
11156 2 out_a_preExp := Tpl.pushBlock(out_a_preExp, Tpl.BT_INDENT(2));
11157 2 out_a_preExp := Tpl.writeText(out_a_preExp, l_arraycreate);
11158 2 out_a_preExp := Tpl.softNewLine(out_a_preExp);
11159 2 out_a_preExp := Tpl.writeTok(out_a_preExp, Tpl.ST_NEW_LINE());
11160 2 out_a_preExp := Tpl.popBlock(out_a_preExp);
11161 2 out_txt := Tpl.writeText(txt, l_arraycreate);
11162 end daeExpArray3;
11163
11164 protected function lm_259
11165 input output Tpl.Text txt;
11166 input list<DAE.Exp> items;
11167 input Boolean a_useFlatArrayNotation;
11168 input output Tpl.Text a_stateDerVectorName;
11169 input output Tpl.Text a_extraFuncsNamespace;
11170 input output Tpl.Text a_extraFuncsDecl;
11171 input output Tpl.Text a_extraFuncs;
11172 input SimCode.SimCode a_simCode;
11173 input output Tpl.Text a_varDecls;
11174 input output Tpl.Text a_preExp;
11175 input SimCodeFunction.Context a_context;
11176 algorithm
11177
2/2
✓ Branch 0 taken 843 times.
✓ Branch 1 taken 407 times.
1250 for lstElt_259 in items loop
11178 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_259
11179 local
11180 DAE.Exp i_e;
11181
11182 case i_e
11183 algorithm
11184 843 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
11185 843 txt := Tpl.nextIter(txt);
11186 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
11187 end match;
11188 end for;
11189 end lm_259;
11190
11191 public function daeExpArray2
11192 input Tpl.Text txt;
11193 input list<DAE.Exp> a_array;
11194 input String a_arrayVar;
11195 input String a_ArrayType;
11196 input String a_arrayTypeStr;
11197 input SimCodeFunction.Context a_context;
11198 input Tpl.Text a_preExp;
11199 input Tpl.Text a_varDecls;
11200 input SimCode.SimCode a_simCode;
11201 input Tpl.Text a_extraFuncs;
11202 input Tpl.Text a_extraFuncsDecl;
11203 input Tpl.Text a_extraFuncsNamespace;
11204 input Tpl.Text a_stateDerVectorName;
11205 input Boolean a_useFlatArrayNotation;
11206
11207 output Tpl.Text out_txt;
11208 output Tpl.Text out_a_preExp;
11209 output Tpl.Text out_a_varDecls;
11210 output Tpl.Text out_a_extraFuncs;
11211 output Tpl.Text out_a_extraFuncsDecl;
11212 output Tpl.Text out_a_extraFuncsNamespace;
11213 output Tpl.Text out_a_stateDerVectorName;
11214 protected
11215 Tpl.Text l_params;
11216 algorithm
11217 407 l_params := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
11218 407 (l_params, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls, out_a_preExp) := lm_259(l_params, a_array, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
11219 407 l_params := Tpl.popIter(l_params);
11220 407 out_a_preExp := Tpl.writeStr(out_a_preExp, a_arrayTypeStr);
11221 407 out_a_preExp := Tpl.writeTok(out_a_preExp, Tpl.ST_STRING(" "));
11222 407 out_a_preExp := Tpl.writeStr(out_a_preExp, a_arrayVar);
11223 407 out_a_preExp := Tpl.writeTok(out_a_preExp, Tpl.ST_STRING("_data[]={"));
11224 407 out_a_preExp := Tpl.writeText(out_a_preExp, l_params);
11225 407 out_a_preExp := Tpl.writeTok(out_a_preExp, Tpl.ST_LINE("};\n"));
11226 407 out_a_preExp := Tpl.writeStr(out_a_preExp, a_ArrayType);
11227 407 out_a_preExp := Tpl.writeTok(out_a_preExp, Tpl.ST_STRING(" "));
11228 407 out_a_preExp := Tpl.writeStr(out_a_preExp, a_arrayVar);
11229 407 out_a_preExp := Tpl.writeTok(out_a_preExp, Tpl.ST_STRING("("));
11230 407 out_a_preExp := Tpl.writeStr(out_a_preExp, a_arrayVar);
11231 407 out_a_preExp := Tpl.writeTok(out_a_preExp, Tpl.ST_STRING("_data);"));
11232 407 out_a_preExp := Tpl.writeTok(out_a_preExp, Tpl.ST_NEW_LINE());
11233 407 out_txt := Tpl.writeText(txt, l_params);
11234 end daeExpArray2;
11235
11236 public function daeSubscript
11237 input Tpl.Text in_txt;
11238 input DAE.Subscript in_a_sub;
11239 input SimCodeFunction.Context in_a_context;
11240 input Tpl.Text in_a_preExp;
11241 input Tpl.Text in_a_varDecls;
11242 input SimCode.SimCode in_a_simCode;
11243 input Tpl.Text in_a_extraFuncs;
11244 input Tpl.Text in_a_extraFuncsDecl;
11245 input Tpl.Text in_a_extraFuncsNamespace;
11246 input Tpl.Text in_a_stateDerVectorName;
11247 input Boolean in_a_useFlatArrayNotation;
11248
11249 output Tpl.Text out_txt;
11250 output Tpl.Text out_a_preExp;
11251 output Tpl.Text out_a_varDecls;
11252 output Tpl.Text out_a_extraFuncs;
11253 output Tpl.Text out_a_extraFuncsDecl;
11254 output Tpl.Text out_a_extraFuncsNamespace;
11255 output Tpl.Text out_a_stateDerVectorName;
11256 algorithm
11257 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
11258 match(in_txt, in_a_sub, in_a_context, in_a_preExp, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
11259 local
11260 Tpl.Text txt;
11261 SimCodeFunction.Context a_context;
11262 Tpl.Text a_preExp;
11263 Tpl.Text a_varDecls;
11264 SimCode.SimCode a_simCode;
11265 Tpl.Text a_extraFuncs;
11266 Tpl.Text a_extraFuncsDecl;
11267 Tpl.Text a_extraFuncsNamespace;
11268 Tpl.Text a_stateDerVectorName;
11269 Boolean a_useFlatArrayNotation;
11270 DAE.Exp i_exp;
11271
11272 case ( txt,
11273 DAE.INDEX(exp = i_exp),
11274 a_context,
11275 a_preExp,
11276 a_varDecls,
11277 a_simCode,
11278 a_extraFuncs,
11279 a_extraFuncsDecl,
11280 a_extraFuncsNamespace,
11281 a_stateDerVectorName,
11282 a_useFlatArrayNotation )
11283 algorithm
11284 ✗ (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
11285 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
11286
11287 case ( txt,
11288 _,
11289 _,
11290 a_preExp,
11291 a_varDecls,
11292 _,
11293 a_extraFuncs,
11294 a_extraFuncsDecl,
11295 a_extraFuncsNamespace,
11296 a_stateDerVectorName,
11297 _ )
11298 algorithm
11299 ✗ txt := error(txt, Tpl.sourceInfo("CodegenCppCommon.tpl", 1570, 14), "non INDEX(_) (i.e., slice) subscripts probably should not reach here. Check indexedAssign template.");
11300 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
11301 end match;
11302 end daeSubscript;
11303
11304 protected function fun_262
11305 input Tpl.Text in_txt;
11306 input DAE.Exp in_a_inExp;
11307 input Boolean in_a_useFlatArrayNotation;
11308 input Tpl.Text in_a_stateDerVectorName;
11309 input Tpl.Text in_a_extraFuncsNamespace;
11310 input Tpl.Text in_a_extraFuncsDecl;
11311 input Tpl.Text in_a_extraFuncs;
11312 input SimCode.SimCode in_a_simCode;
11313 input Tpl.Text in_a_varDecls;
11314 input Tpl.Text in_a_preExp;
11315 input SimCodeFunction.Context in_a_context;
11316
11317 output Tpl.Text out_txt;
11318 output Tpl.Text out_a_stateDerVectorName;
11319 output Tpl.Text out_a_extraFuncsNamespace;
11320 output Tpl.Text out_a_extraFuncsDecl;
11321 output Tpl.Text out_a_extraFuncs;
11322 output Tpl.Text out_a_varDecls;
11323 output Tpl.Text out_a_preExp;
11324 algorithm
11325 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls, out_a_preExp) :=
11326 match(in_txt, in_a_inExp, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_varDecls, in_a_preExp, in_a_context)
11327 local
11328 Tpl.Text txt;
11329 Boolean a_useFlatArrayNotation;
11330 Tpl.Text a_stateDerVectorName;
11331 Tpl.Text a_extraFuncsNamespace;
11332 Tpl.Text a_extraFuncsDecl;
11333 Tpl.Text a_extraFuncs;
11334 SimCode.SimCode a_simCode;
11335 Tpl.Text a_varDecls;
11336 Tpl.Text a_preExp;
11337 SimCodeFunction.Context a_context;
11338 DAE.Subscript i_idx;
11339 DAE.Exp i_e;
11340 Tpl.Text l_idx1;
11341 Tpl.Text l_e1;
11342
11343 case ( txt,
11344 DAE.ASUB(exp = i_e, sub = {i_idx}),
11345 a_useFlatArrayNotation,
11346 a_stateDerVectorName,
11347 a_extraFuncsNamespace,
11348 a_extraFuncsDecl,
11349 a_extraFuncs,
11350 a_simCode,
11351 a_varDecls,
11352 a_preExp,
11353 a_context )
11354 algorithm
11355 ✗ (l_e1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
11356 ✗ (l_idx1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeSubscript(Tpl.emptyTxt, i_idx, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
11357 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("arrayGet("));
11358 ✗ txt := Tpl.writeText(txt, l_e1);
11359 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(","));
11360 ✗ txt := Tpl.writeText(txt, l_idx1);
11361 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(") /* DAE.ASUB */"));
11362 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
11363
11364 case ( txt,
11365 _,
11366 _,
11367 a_stateDerVectorName,
11368 a_extraFuncsNamespace,
11369 a_extraFuncsDecl,
11370 a_extraFuncs,
11371 _,
11372 a_varDecls,
11373 a_preExp,
11374 _ )
11375 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
11376 end match;
11377 end fun_262;
11378
11379 protected function lm_263
11380 input output Tpl.Text txt;
11381 input list<DAE.Exp> items;
11382 input Tpl.Text a_res;
11383 input Boolean a_useFlatArrayNotation;
11384 input output Tpl.Text a_stateDerVectorName;
11385 input output Tpl.Text a_extraFuncsNamespace;
11386 input output Tpl.Text a_extraFuncsDecl;
11387 input output Tpl.Text a_extraFuncs;
11388 input SimCode.SimCode a_simCode;
11389 input SimCodeFunction.Context a_context;
11390 algorithm
11391 ✗ for lstElt_263 in items loop
11392 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs) := match lstElt_263
11393 local
11394 Integer x_i1;
11395 DAE.Exp i_e;
11396 Tpl.Text l_v;
11397 Tpl.Text l_casePreExp;
11398 Tpl.Text l_caseVarDecls;
11399
11400 case i_e
11401 algorithm
11402 ✗ x_i1 := Tpl.getIteri_i0(txt);
11403 ✗ l_caseVarDecls := Tpl.emptyTxt;
11404 ✗ l_casePreExp := Tpl.emptyTxt;
11405 ✗ (l_v, l_casePreExp, l_caseVarDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e, a_context, l_casePreExp, l_caseVarDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
11406 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("case "));
11407 ✗ txt := Tpl.writeStr(txt, intString(x_i1));
11408 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(": {\n"));
11409 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
11410 ✗ txt := Tpl.writeText(txt, l_caseVarDecls);
11411 ✗ txt := Tpl.softNewLine(txt);
11412 ✗ txt := Tpl.writeText(txt, l_casePreExp);
11413 ✗ txt := Tpl.softNewLine(txt);
11414 ✗ txt := Tpl.writeText(txt, a_res);
11415 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = "));
11416 ✗ txt := Tpl.writeText(txt, l_v);
11417 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
11418 ";\n",
11419 "break;\n"
11420 }, true));
11421 ✗ txt := Tpl.popBlock(txt);
11422 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("}"));
11423 ✗ txt := Tpl.nextIter(txt);
11424 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs);
11425 end match;
11426 end for;
11427 end lm_263;
11428
11429 protected function fun_264
11430 input Tpl.Text in_txt;
11431 input SimCodeFunction.Context in_a_context;
11432 input Boolean in_a_useFlatArrayNotation;
11433 input Tpl.Text in_a_stateDerVectorName;
11434 input Tpl.Text in_a_extraFuncsNamespace;
11435 input Tpl.Text in_a_extraFuncsDecl;
11436 input Tpl.Text in_a_extraFuncs;
11437 input SimCode.SimCode in_a_simCode;
11438 input Tpl.Text in_a_varDecls;
11439 input Tpl.Text in_a_preExp;
11440 input list<DAE.Subscript> in_a_subs;
11441 input DAE.Type in_a_ecr_ty;
11442 input Tpl.Text in_a_arrName;
11443
11444 output Tpl.Text out_txt;
11445 output Tpl.Text out_a_stateDerVectorName;
11446 output Tpl.Text out_a_extraFuncsNamespace;
11447 output Tpl.Text out_a_extraFuncsDecl;
11448 output Tpl.Text out_a_extraFuncs;
11449 output Tpl.Text out_a_varDecls;
11450 output Tpl.Text out_a_preExp;
11451 algorithm
11452 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls, out_a_preExp) :=
11453 match(in_txt, in_a_context, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_varDecls, in_a_preExp, in_a_subs, in_a_ecr_ty, in_a_arrName)
11454 local
11455 Tpl.Text txt;
11456 Boolean a_useFlatArrayNotation;
11457 Tpl.Text a_stateDerVectorName;
11458 Tpl.Text a_extraFuncsNamespace;
11459 Tpl.Text a_extraFuncsDecl;
11460 Tpl.Text a_extraFuncs;
11461 SimCode.SimCode a_simCode;
11462 Tpl.Text a_varDecls;
11463 Tpl.Text a_preExp;
11464 list<DAE.Subscript> a_subs;
11465 DAE.Type a_ecr_ty;
11466 Tpl.Text a_arrName;
11467 SimCodeFunction.Context i_context;
11468
11469 case ( txt,
11470 SimCodeFunction.FUNCTION_CONTEXT(cref_prefix = _),
11471 _,
11472 a_stateDerVectorName,
11473 a_extraFuncsNamespace,
11474 a_extraFuncsDecl,
11475 a_extraFuncs,
11476 _,
11477 a_varDecls,
11478 a_preExp,
11479 _,
11480 _,
11481 a_arrName )
11482 algorithm
11483 ✗ txt := Tpl.writeText(txt, a_arrName);
11484 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
11485
11486 case ( txt,
11487 i_context,
11488 a_useFlatArrayNotation,
11489 a_stateDerVectorName,
11490 a_extraFuncsNamespace,
11491 a_extraFuncsDecl,
11492 a_extraFuncs,
11493 a_simCode,
11494 a_varDecls,
11495 a_preExp,
11496 a_subs,
11497 a_ecr_ty,
11498 a_arrName )
11499 algorithm
11500 ✗ (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := arrayScalarRhs(txt, a_ecr_ty, a_subs, Tpl.textString(a_arrName), i_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
11501 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
11502 end match;
11503 end fun_264;
11504
11505 protected function lm_265
11506 input output Tpl.Text txt;
11507 input list<DAE.Subscript> items;
11508 input Boolean a_useFlatArrayNotation;
11509 input output Tpl.Text a_stateDerVectorName;
11510 input output Tpl.Text a_extraFuncsNamespace;
11511 input output Tpl.Text a_extraFuncsDecl;
11512 input output Tpl.Text a_extraFuncs;
11513 input SimCode.SimCode a_simCode;
11514 input output Tpl.Text a_varDecls;
11515 input output Tpl.Text a_preExp;
11516 input SimCodeFunction.Context a_context;
11517 algorithm
11518
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 140 times.
360 for lstElt_265 in items loop
11519 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_265
11520 local
11521 DAE.Subscript i_index;
11522
11523 case i_index
11524 algorithm
11525 220 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeSubscriptASubIndex(txt, i_index, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
11526 220 txt := Tpl.nextIter(txt);
11527 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
11528 end match;
11529 end for;
11530 end lm_265;
11531
11532 protected function fun_266
11533 input Tpl.Text in_txt;
11534 input DAE.Exp in_a_inExp;
11535 input Boolean in_a_useFlatArrayNotation;
11536 input Tpl.Text in_a_stateDerVectorName;
11537 input Tpl.Text in_a_extraFuncsNamespace;
11538 input Tpl.Text in_a_extraFuncsDecl;
11539 input Tpl.Text in_a_extraFuncs;
11540 input SimCode.SimCode in_a_simCode;
11541 input Tpl.Text in_a_preExp;
11542 input SimCodeFunction.Context in_a_context;
11543 input Tpl.Text in_a_varDecls;
11544
11545 output Tpl.Text out_txt;
11546 output Tpl.Text out_a_stateDerVectorName;
11547 output Tpl.Text out_a_extraFuncsNamespace;
11548 output Tpl.Text out_a_extraFuncsDecl;
11549 output Tpl.Text out_a_extraFuncs;
11550 output Tpl.Text out_a_preExp;
11551 output Tpl.Text out_a_varDecls;
11552 algorithm
11553 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_preExp, out_a_varDecls) :=
11554 match(in_txt, in_a_inExp, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_preExp, in_a_context, in_a_varDecls)
11555 local
11556 Tpl.Text txt;
11557 Boolean a_useFlatArrayNotation;
11558 Tpl.Text a_stateDerVectorName;
11559 Tpl.Text a_extraFuncsNamespace;
11560 Tpl.Text a_extraFuncsDecl;
11561 Tpl.Text a_extraFuncs;
11562 SimCode.SimCode a_simCode;
11563 Tpl.Text a_preExp;
11564 SimCodeFunction.Context a_context;
11565 Tpl.Text a_varDecls;
11566 list<DAE.Subscript> i_indexes;
11567 DAE.Exp i_e;
11568 DAE.Type i_ecr_ty;
11569 list<DAE.Subscript> i_subs;
11570 DAE.Exp i_ecr;
11571 list<DAE.Exp> i_exp_array;
11572 DAE.Subscript i_idx;
11573 DAE.Exp i_exp;
11574 Tpl.Text txt_9;
11575 Tpl.Text l_expIndexes;
11576 Tpl.Text l_exp;
11577 DAE.Exp ret_6;
11578 Tpl.Text l_arrName;
11579 Tpl.Text l_expl;
11580 Tpl.Text l_idx1;
11581 Tpl.Text txt_2;
11582 Tpl.Text l_res;
11583 Tpl.Text txt_0;
11584
11585 case ( txt,
11586 DAE.ASUB(exp = (i_exp as DAE.ASUB(exp = _))),
11587 _,
11588 a_stateDerVectorName,
11589 a_extraFuncsNamespace,
11590 a_extraFuncsDecl,
11591 a_extraFuncs,
11592 _,
11593 a_preExp,
11594 _,
11595 a_varDecls )
11596 algorithm
11597 ✗ txt_0 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("Nested array subscripting *should* have been handled by the routine creating the asub, but for some reason it was not: "));
11598 ✗ txt_0 := ExpressionDumpTpl.dumpExp(txt_0, i_exp, "\"");
11599 ✗ txt := error(txt, Tpl.sourceInfo("CodegenCppCommon.tpl", 1590, 11), Tpl.textString(txt_0));
11600 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_preExp, a_varDecls);
11601
11602 case ( txt,
11603 DAE.ASUB(exp = (i_exp as DAE.ARRAY(scalar = true, array = i_exp_array)), sub = {i_idx}),
11604 a_useFlatArrayNotation,
11605 a_stateDerVectorName,
11606 a_extraFuncsNamespace,
11607 a_extraFuncsDecl,
11608 a_extraFuncs,
11609 a_simCode,
11610 a_preExp,
11611 a_context,
11612 a_varDecls )
11613 algorithm
11614 ✗ txt_2 := expTypeFromExpModelica(Tpl.emptyTxt, i_exp);
11615 ✗ (l_res, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(txt_2), a_varDecls);
11616 ✗ (l_idx1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeSubscript(Tpl.emptyTxt, i_idx, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
11617 ✗ l_expl := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(1, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
11618 ✗ (l_expl, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs) := lm_263(l_expl, i_exp_array, l_res, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_context);
11619 ✗ l_expl := Tpl.popIter(l_expl);
11620 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("switch ("));
11621 ✗ a_preExp := Tpl.writeText(a_preExp, l_idx1);
11622 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_LINE(") { /* ASUB */\n"));
11623 ✗ a_preExp := Tpl.writeText(a_preExp, l_expl);
11624 ✗ a_preExp := Tpl.softNewLine(a_preExp);
11625 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING_LIST({
11626 "default:\n",
11627 " assert(NULL == \"index out of bounds\");\n",
11628 "}"
11629 }, false));
11630 ✗ txt := Tpl.writeText(txt, l_res);
11631 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_preExp, a_varDecls);
11632
11633 case ( txt,
11634 DAE.ASUB(exp = (i_ecr as DAE.CREF(ty = i_ecr_ty)), sub = i_subs),
11635 a_useFlatArrayNotation,
11636 a_stateDerVectorName,
11637 a_extraFuncsNamespace,
11638 a_extraFuncsDecl,
11639 a_extraFuncs,
11640 a_simCode,
11641 a_preExp,
11642 a_context,
11643 a_varDecls )
11644 algorithm
11645 ✗ ret_6 := SimCodeFunctionUtil.buildCrefExpFromSubs(i_ecr, i_subs);
11646 ✗ (l_arrName, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpCrefRhs(Tpl.emptyTxt, ret_6, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
11647 ✗ (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := fun_264(txt, a_context, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, i_subs, i_ecr_ty, l_arrName);
11648 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_preExp, a_varDecls);
11649
11650 case ( txt,
11651 DAE.ASUB(exp = i_e, sub = i_indexes),
11652 a_useFlatArrayNotation,
11653 a_stateDerVectorName,
11654 a_extraFuncsNamespace,
11655 a_extraFuncsDecl,
11656 a_extraFuncs,
11657 a_simCode,
11658 a_preExp,
11659 a_context,
11660 a_varDecls )
11661 algorithm
11662 140 (l_exp, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
11663 140 l_expIndexes := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(",")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
11664 140 (l_expIndexes, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_265(l_expIndexes, i_indexes, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
11665 140 l_expIndexes := Tpl.popIter(l_expIndexes);
11666 140 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
11667 140 txt := Tpl.writeText(txt, l_exp);
11668 140 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")("));
11669 140 txt := Tpl.writeText(txt, l_expIndexes);
11670 140 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
11671 140 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_preExp, a_varDecls);
11672
11673 case ( txt,
11674 i_exp,
11675 _,
11676 a_stateDerVectorName,
11677 a_extraFuncsNamespace,
11678 a_extraFuncsDecl,
11679 a_extraFuncs,
11680 _,
11681 a_preExp,
11682 _,
11683 a_varDecls )
11684 algorithm
11685 ✗ txt_9 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("OTHER_ASUB "));
11686 ✗ txt_9 := ExpressionDumpTpl.dumpExp(txt_9, i_exp, "\"");
11687 ✗ txt := error(txt, Tpl.sourceInfo("CodegenCppCommon.tpl", 1633, 11), Tpl.textString(txt_9));
11688 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_preExp, a_varDecls);
11689 end match;
11690 end fun_266;
11691
11692 protected function fun_267
11693 input Tpl.Text in_txt;
11694 input String in_mArg;
11695 input DAE.Exp in_a_inExp;
11696 input SimCodeFunction.Context in_a_context;
11697 input Tpl.Text in_a_preExp;
11698 input Tpl.Text in_a_varDecls;
11699 input SimCode.SimCode in_a_simCode;
11700 input Tpl.Text in_a_extraFuncs;
11701 input Tpl.Text in_a_extraFuncsDecl;
11702 input Tpl.Text in_a_extraFuncsNamespace;
11703 input Tpl.Text in_a_stateDerVectorName;
11704 input Boolean in_a_useFlatArrayNotation;
11705
11706 output Tpl.Text out_txt;
11707 output Tpl.Text out_a_preExp;
11708 output Tpl.Text out_a_varDecls;
11709 output Tpl.Text out_a_extraFuncs;
11710 output Tpl.Text out_a_extraFuncsDecl;
11711 output Tpl.Text out_a_extraFuncsNamespace;
11712 output Tpl.Text out_a_stateDerVectorName;
11713 algorithm
11714 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
11715 match(in_txt, in_mArg, in_a_inExp, in_a_context, in_a_preExp, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
11716 local
11717 Tpl.Text txt;
11718 DAE.Exp a_inExp;
11719 SimCodeFunction.Context a_context;
11720 Tpl.Text a_preExp;
11721 Tpl.Text a_varDecls;
11722 SimCode.SimCode a_simCode;
11723 Tpl.Text a_extraFuncs;
11724 Tpl.Text a_extraFuncsDecl;
11725 Tpl.Text a_extraFuncsNamespace;
11726 Tpl.Text a_stateDerVectorName;
11727 Boolean a_useFlatArrayNotation;
11728
11729 case ( txt,
11730 "metatype",
11731 a_inExp,
11732 a_context,
11733 a_preExp,
11734 a_varDecls,
11735 a_simCode,
11736 a_extraFuncs,
11737 a_extraFuncsDecl,
11738 a_extraFuncsNamespace,
11739 a_stateDerVectorName,
11740 a_useFlatArrayNotation )
11741 algorithm
11742 ✗ (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := fun_262(txt, a_inExp, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
11743 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
11744
11745 case ( txt,
11746 _,
11747 a_inExp,
11748 a_context,
11749 a_preExp,
11750 a_varDecls,
11751 a_simCode,
11752 a_extraFuncs,
11753 a_extraFuncsDecl,
11754 a_extraFuncsNamespace,
11755 a_stateDerVectorName,
11756 a_useFlatArrayNotation )
11757 algorithm
11758 140 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_preExp, a_varDecls) := fun_266(txt, a_inExp, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_preExp, a_context, a_varDecls);
11759 140 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
11760 end match;
11761 end fun_267;
11762
11763 public function daeExpAsub
11764 input Tpl.Text txt;
11765 input DAE.Exp a_inExp;
11766 input SimCodeFunction.Context a_context;
11767 input Tpl.Text a_preExp;
11768 input Tpl.Text a_varDecls;
11769 input SimCode.SimCode a_simCode;
11770 input Tpl.Text a_extraFuncs;
11771 input Tpl.Text a_extraFuncsDecl;
11772 input Tpl.Text a_extraFuncsNamespace;
11773 input Tpl.Text a_stateDerVectorName;
11774 input Boolean a_useFlatArrayNotation;
11775
11776 output Tpl.Text out_txt;
11777 output Tpl.Text out_a_preExp;
11778 output Tpl.Text out_a_varDecls;
11779 output Tpl.Text out_a_extraFuncs;
11780 output Tpl.Text out_a_extraFuncsDecl;
11781 output Tpl.Text out_a_extraFuncsNamespace;
11782 output Tpl.Text out_a_stateDerVectorName;
11783 protected
11784 String str_1;
11785 Tpl.Text txt_0;
11786 algorithm
11787 140 txt_0 := expTypeFromExpShort(Tpl.emptyTxt, a_inExp);
11788 140 str_1 := Tpl.textString(txt_0);
11789 140 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) := fun_267(txt, str_1, a_inExp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
11790 end daeExpAsub;
11791
11792 public function daeSubscriptASubIndex
11793 input Tpl.Text in_txt;
11794 input DAE.Subscript in_a_sub;
11795 input SimCodeFunction.Context in_a_context;
11796 input Tpl.Text in_a_preExp;
11797 input Tpl.Text in_a_varDecls;
11798 input SimCode.SimCode in_a_simCode;
11799 input Tpl.Text in_a_extraFuncs;
11800 input Tpl.Text in_a_extraFuncsDecl;
11801 input Tpl.Text in_a_extraFuncsNamespace;
11802 input Tpl.Text in_a_stateDerVectorName;
11803 input Boolean in_a_useFlatArrayNotation;
11804
11805 output Tpl.Text out_txt;
11806 output Tpl.Text out_a_preExp;
11807 output Tpl.Text out_a_varDecls;
11808 output Tpl.Text out_a_extraFuncs;
11809 output Tpl.Text out_a_extraFuncsDecl;
11810 output Tpl.Text out_a_extraFuncsNamespace;
11811 output Tpl.Text out_a_stateDerVectorName;
11812 algorithm
11813 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
11814 match(in_txt, in_a_sub, in_a_context, in_a_preExp, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
11815 local
11816 Tpl.Text txt;
11817 SimCodeFunction.Context a_context;
11818 Tpl.Text a_preExp;
11819 Tpl.Text a_varDecls;
11820 SimCode.SimCode a_simCode;
11821 Tpl.Text a_extraFuncs;
11822 Tpl.Text a_extraFuncsDecl;
11823 Tpl.Text a_extraFuncsNamespace;
11824 Tpl.Text a_stateDerVectorName;
11825 Boolean a_useFlatArrayNotation;
11826 DAE.Subscript i_sub;
11827 DAE.Exp i_exp;
11828
11829 case ( txt,
11830 DAE.INDEX(exp = i_exp),
11831 a_context,
11832 a_preExp,
11833 a_varDecls,
11834 a_simCode,
11835 a_extraFuncs,
11836 a_extraFuncsDecl,
11837 a_extraFuncsNamespace,
11838 a_stateDerVectorName,
11839 a_useFlatArrayNotation )
11840 algorithm
11841 220 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpASubIndex(txt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
11842 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
11843
11844 case ( txt,
11845 i_sub,
11846 a_context,
11847 a_preExp,
11848 a_varDecls,
11849 a_simCode,
11850 a_extraFuncs,
11851 a_extraFuncsDecl,
11852 a_extraFuncsNamespace,
11853 a_stateDerVectorName,
11854 a_useFlatArrayNotation )
11855 algorithm
11856 ✗ (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeSubscript(txt, i_sub, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
11857 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
11858 end match;
11859 end daeSubscriptASubIndex;
11860
11861 public function daeExpASubIndex
11862 input Tpl.Text in_txt;
11863 input DAE.Exp in_a_exp;
11864 input SimCodeFunction.Context in_a_context;
11865 input Tpl.Text in_a_preExp;
11866 input Tpl.Text in_a_varDecls;
11867 input SimCode.SimCode in_a_simCode;
11868 input Tpl.Text in_a_extraFuncs;
11869 input Tpl.Text in_a_extraFuncsDecl;
11870 input Tpl.Text in_a_extraFuncsNamespace;
11871 input Tpl.Text in_a_stateDerVectorName;
11872 input Boolean in_a_useFlatArrayNotation;
11873
11874 output Tpl.Text out_txt;
11875 output Tpl.Text out_a_preExp;
11876 output Tpl.Text out_a_varDecls;
11877 output Tpl.Text out_a_extraFuncs;
11878 output Tpl.Text out_a_extraFuncsDecl;
11879 output Tpl.Text out_a_extraFuncsNamespace;
11880 output Tpl.Text out_a_stateDerVectorName;
11881 algorithm
11882 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
11883 match(in_txt, in_a_exp, in_a_context, in_a_preExp, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
11884 local
11885 Tpl.Text txt;
11886 SimCodeFunction.Context a_context;
11887 Tpl.Text a_preExp;
11888 Tpl.Text a_varDecls;
11889 SimCode.SimCode a_simCode;
11890 Tpl.Text a_extraFuncs;
11891 Tpl.Text a_extraFuncsDecl;
11892 Tpl.Text a_extraFuncsNamespace;
11893 Tpl.Text a_stateDerVectorName;
11894 Boolean a_useFlatArrayNotation;
11895 DAE.Exp i_exp;
11896 Integer i_index;
11897 Integer i_integer;
11898
11899 case ( txt,
11900 DAE.ICONST(integer = i_integer),
11901 _,
11902 a_preExp,
11903 a_varDecls,
11904 _,
11905 a_extraFuncs,
11906 a_extraFuncsDecl,
11907 a_extraFuncsNamespace,
11908 a_stateDerVectorName,
11909 _ )
11910 algorithm
11911 4 txt := Tpl.writeStr(txt, intString(i_integer));
11912 4 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
11913
11914 case ( txt,
11915 DAE.ENUM_LITERAL(index = i_index),
11916 _,
11917 a_preExp,
11918 a_varDecls,
11919 _,
11920 a_extraFuncs,
11921 a_extraFuncsDecl,
11922 a_extraFuncsNamespace,
11923 a_stateDerVectorName,
11924 _ )
11925 algorithm
11926 ✗ txt := Tpl.writeStr(txt, intString(i_index));
11927 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
11928
11929 case ( txt,
11930 i_exp,
11931 a_context,
11932 a_preExp,
11933 a_varDecls,
11934 a_simCode,
11935 a_extraFuncs,
11936 a_extraFuncsDecl,
11937 a_extraFuncsNamespace,
11938 a_stateDerVectorName,
11939 a_useFlatArrayNotation )
11940 algorithm
11941 216 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
11942 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
11943 end match;
11944 end daeExpASubIndex;
11945
11946 protected function lm_271
11947 input output Tpl.Text txt;
11948 input list<DAE.Subscript> items;
11949 input Boolean a_useFlatArrayNotation;
11950 input output Tpl.Text a_stateDerVectorName;
11951 input output Tpl.Text a_extraFuncsNamespace;
11952 input output Tpl.Text a_extraFuncsDecl;
11953 input output Tpl.Text a_extraFuncs;
11954 input SimCode.SimCode a_simCode;
11955 input output Tpl.Text a_varDecls;
11956 input output Tpl.Text a_preExp;
11957 input SimCodeFunction.Context a_context;
11958 algorithm
11959 ✗ for lstElt_271 in items loop
11960 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_271
11961 local
11962 DAE.Subscript i_sub;
11963
11964 case i_sub
11965 algorithm
11966 ✗ (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeSubscript(txt, i_sub, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
11967 ✗ txt := Tpl.nextIter(txt);
11968 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
11969 end match;
11970 end for;
11971 end lm_271;
11972
11973 protected function fun_272
11974 input Tpl.Text in_txt;
11975 input String in_mArg;
11976 input Tpl.Text in_a_dimsValuesStr;
11977 input String in_a_arrName;
11978
11979 output Tpl.Text out_txt;
11980 algorithm
11981 out_txt :=
11982 match(in_txt, in_mArg, in_a_dimsValuesStr, in_a_arrName)
11983 local
11984 Tpl.Text txt;
11985 Tpl.Text a_dimsValuesStr;
11986 String a_arrName;
11987
11988 case ( txt,
11989 "metatype_array",
11990 a_dimsValuesStr,
11991 a_arrName )
11992 algorithm
11993 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("arrayGet("));
11994 ✗ txt := Tpl.writeStr(txt, a_arrName);
11995 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(","));
11996 ✗ txt := Tpl.writeText(txt, a_dimsValuesStr);
11997 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(") /*arrayScalarRhs*/"));
11998 then txt;
11999
12000 case ( txt,
12001 _,
12002 a_dimsValuesStr,
12003 a_arrName )
12004 algorithm
12005 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(1));
12006 ✗ txt := Tpl.writeStr(txt, a_arrName);
12007 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
12008 ✗ txt := Tpl.writeText(txt, a_dimsValuesStr);
12009 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(") "));
12010 ✗ txt := Tpl.popBlock(txt);
12011 then txt;
12012 end match;
12013 end fun_272;
12014
12015 public function arrayScalarRhs
12016 input Tpl.Text txt;
12017 input DAE.Type a_ty;
12018 input list<DAE.Subscript> a_subs;
12019 input String a_arrName;
12020 input SimCodeFunction.Context a_context;
12021 input Tpl.Text a_preExp;
12022 input Tpl.Text a_varDecls;
12023 input SimCode.SimCode a_simCode;
12024 input Tpl.Text a_extraFuncs;
12025 input Tpl.Text a_extraFuncsDecl;
12026 input Tpl.Text a_extraFuncsNamespace;
12027 input Tpl.Text a_stateDerVectorName;
12028 input Boolean a_useFlatArrayNotation;
12029
12030 output Tpl.Text out_txt;
12031 output Tpl.Text out_a_preExp;
12032 output Tpl.Text out_a_varDecls;
12033 output Tpl.Text out_a_extraFuncs;
12034 output Tpl.Text out_a_extraFuncsDecl;
12035 output Tpl.Text out_a_extraFuncsNamespace;
12036 output Tpl.Text out_a_stateDerVectorName;
12037 protected
12038 String str_4;
12039 Tpl.Text l_dimsValuesStr;
12040 Integer ret_2;
12041 Tpl.Text l_dimsLenStr;
12042 Tpl.Text l_arrayType;
12043 algorithm
12044 ✗ l_arrayType := expTypeShort(Tpl.emptyTxt, a_ty);
12045 ✗ ret_2 := listLength(a_subs);
12046 ✗ l_dimsLenStr := Tpl.writeStr(Tpl.emptyTxt, intString(ret_2));
12047 ✗ l_dimsValuesStr := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(",")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
12048 ✗ (l_dimsValuesStr, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls, out_a_preExp) := lm_271(l_dimsValuesStr, a_subs, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
12049 ✗ l_dimsValuesStr := Tpl.popIter(l_dimsValuesStr);
12050 ✗ str_4 := Tpl.textString(l_arrayType);
12051 ✗ out_txt := fun_272(txt, str_4, l_dimsValuesStr, a_arrName);
12052 end arrayScalarRhs;
12053
12054 protected function fun_274
12055 input Tpl.Text in_txt;
12056 input DAE.Type in_a_ty;
12057 input Tpl.Text in_a_preExp;
12058 input Tpl.Text in_a_varDecls;
12059 input DAE.Exp in_a_exp;
12060 input Tpl.Text in_a_expVar;
12061
12062 output Tpl.Text out_txt;
12063 output Tpl.Text out_a_preExp;
12064 output Tpl.Text out_a_varDecls;
12065 algorithm
12066 (out_txt, out_a_preExp, out_a_varDecls) :=
12067 match(in_txt, in_a_ty, in_a_preExp, in_a_varDecls, in_a_exp, in_a_expVar)
12068 local
12069 Tpl.Text txt;
12070 Tpl.Text a_preExp;
12071 Tpl.Text a_varDecls;
12072 DAE.Exp a_exp;
12073 Tpl.Text a_expVar;
12074 list<DAE.Var> i_vl;
12075 Absyn.Path i_rec_path;
12076 DAE.Dimensions i_dims;
12077 DAE.Type i_ty;
12078 Tpl.Text txt_4;
12079 Tpl.Text txt_3;
12080 Tpl.Text l_tvar;
12081 Tpl.Text l_to;
12082 Tpl.Text l_from;
12083
12084 case ( txt,
12085 DAE.T_INTEGER(varLst = _),
12086 a_preExp,
12087 a_varDecls,
12088 _,
12089 a_expVar )
12090 algorithm
12091 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("((int)"));
12092 ✗ txt := Tpl.writeText(txt, a_expVar);
12093 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
12094 ✗ then (txt, a_preExp, a_varDecls);
12095
12096 case ( txt,
12097 DAE.T_REAL(varLst = _),
12098 a_preExp,
12099 a_varDecls,
12100 _,
12101 a_expVar )
12102 algorithm
12103 165 txt := Tpl.writeTok(txt, Tpl.ST_STRING("((double)"));
12104 165 txt := Tpl.writeText(txt, a_expVar);
12105 165 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
12106 165 then (txt, a_preExp, a_varDecls);
12107
12108 case ( txt,
12109 DAE.T_ENUMERATION(index = _),
12110 a_preExp,
12111 a_varDecls,
12112 _,
12113 a_expVar )
12114 algorithm
12115 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("((int)"));
12116 ✗ txt := Tpl.writeText(txt, a_expVar);
12117 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
12118 ✗ then (txt, a_preExp, a_varDecls);
12119
12120 case ( txt,
12121 DAE.T_BOOL(varLst = _),
12122 a_preExp,
12123 a_varDecls,
12124 _,
12125 a_expVar )
12126 algorithm
12127 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("((bool)"));
12128 ✗ txt := Tpl.writeText(txt, a_expVar);
12129 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
12130 ✗ then (txt, a_preExp, a_varDecls);
12131
12132 case ( txt,
12133 DAE.T_ARRAY(dims = i_dims, ty = i_ty),
12134 a_preExp,
12135 a_varDecls,
12136 a_exp,
12137 a_expVar )
12138 algorithm
12139 ✗ l_from := expTypeFromExpShort(Tpl.emptyTxt, a_exp);
12140 ✗ l_to := expTypeShort(Tpl.emptyTxt, i_ty);
12141 ✗ txt_3 := expTypeArrayDims(Tpl.emptyTxt, i_ty, i_dims);
12142 ✗ (l_tvar, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(txt_3), a_varDecls);
12143 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("cast_array<"));
12144 ✗ a_preExp := Tpl.writeText(a_preExp, l_from);
12145 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
12146 ✗ a_preExp := Tpl.writeText(a_preExp, l_to);
12147 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(">("));
12148 ✗ a_preExp := Tpl.writeText(a_preExp, a_expVar);
12149 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
12150 ✗ a_preExp := Tpl.writeText(a_preExp, l_tvar);
12151 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
12152 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
12153 ✗ txt := Tpl.writeText(txt, l_tvar);
12154 ✗ then (txt, a_preExp, a_varDecls);
12155
12156 case ( txt,
12157 DAE.T_COMPLEX(varLst = i_vl, complexClassType = ClassInf.RECORD(path = i_rec_path)),
12158 a_preExp,
12159 a_varDecls,
12160 _,
12161 a_expVar )
12162 algorithm
12163 ✗ txt_4 := CodegenUtil.underscorePath(Tpl.emptyTxt, i_rec_path);
12164 ✗ txt_4 := Tpl.writeTok(txt_4, Tpl.ST_STRING("Type"));
12165 ✗ (l_tvar, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(txt_4), a_varDecls);
12166 ✗ a_preExp := structParams(a_preExp, Tpl.textString(a_expVar), Tpl.textString(l_tvar), i_vl);
12167 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
12168 ✗ txt := Tpl.writeText(txt, l_tvar);
12169 ✗ then (txt, a_preExp, a_varDecls);
12170
12171 case ( txt,
12172 _,
12173 a_preExp,
12174 a_varDecls,
12175 _,
12176 a_expVar )
12177 algorithm
12178 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
12179 ✗ txt := Tpl.writeText(txt, a_expVar);
12180 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(") /* could not cast, using the variable as it is */"));
12181 ✗ then (txt, a_preExp, a_varDecls);
12182 end match;
12183 end fun_274;
12184
12185 public function daeExpCast
12186 input Tpl.Text in_txt;
12187 input DAE.Exp in_a_exp;
12188 input SimCodeFunction.Context in_a_context;
12189 input Tpl.Text in_a_preExp;
12190 input Tpl.Text in_a_varDecls;
12191 input SimCode.SimCode in_a_simCode;
12192 input Tpl.Text in_a_extraFuncs;
12193 input Tpl.Text in_a_extraFuncsDecl;
12194 input Tpl.Text in_a_extraFuncsNamespace;
12195 input Tpl.Text in_a_stateDerVectorName;
12196 input Boolean in_a_useFlatArrayNotation;
12197
12198 output Tpl.Text out_txt;
12199 output Tpl.Text out_a_preExp;
12200 output Tpl.Text out_a_varDecls;
12201 output Tpl.Text out_a_extraFuncs;
12202 output Tpl.Text out_a_extraFuncsDecl;
12203 output Tpl.Text out_a_extraFuncsNamespace;
12204 output Tpl.Text out_a_stateDerVectorName;
12205 algorithm
12206 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
12207 match(in_txt, in_a_exp, in_a_context, in_a_preExp, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
12208 local
12209 Tpl.Text txt;
12210 SimCodeFunction.Context a_context;
12211 Tpl.Text a_preExp;
12212 Tpl.Text a_varDecls;
12213 SimCode.SimCode a_simCode;
12214 Tpl.Text a_extraFuncs;
12215 Tpl.Text a_extraFuncsDecl;
12216 Tpl.Text a_extraFuncsNamespace;
12217 Tpl.Text a_stateDerVectorName;
12218 Boolean a_useFlatArrayNotation;
12219 DAE.Type i_ty;
12220 DAE.Exp i_exp;
12221 Tpl.Text l_expVar;
12222
12223 case ( txt,
12224 DAE.CAST(exp = i_exp, ty = i_ty),
12225 a_context,
12226 a_preExp,
12227 a_varDecls,
12228 a_simCode,
12229 a_extraFuncs,
12230 a_extraFuncsDecl,
12231 a_extraFuncsNamespace,
12232 a_stateDerVectorName,
12233 a_useFlatArrayNotation )
12234 algorithm
12235 165 (l_expVar, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
12236 165 (txt, a_preExp, a_varDecls) := fun_274(txt, i_ty, a_preExp, a_varDecls, i_exp, l_expVar);
12237 165 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
12238
12239 case ( txt,
12240 _,
12241 _,
12242 a_preExp,
12243 a_varDecls,
12244 _,
12245 a_extraFuncs,
12246 a_extraFuncsDecl,
12247 a_extraFuncsNamespace,
12248 a_stateDerVectorName,
12249 _ )
12250 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
12251 end match;
12252 end daeExpCast;
12253
12254 protected function fun_276
12255 input Tpl.Text in_txt;
12256 input DAE.Var in_a_e;
12257 input String in_a_structName;
12258 input String in_a_varName;
12259
12260 output Tpl.Text out_txt;
12261 algorithm
12262 out_txt :=
12263 match(in_txt, in_a_e, in_a_structName, in_a_varName)
12264 local
12265 Tpl.Text txt;
12266 String a_structName;
12267 String a_varName;
12268 DAE.Ident i_name;
12269
12270 case ( txt,
12271 DAE.TYPES_VAR(name = i_name),
12272 a_structName,
12273 a_varName )
12274 algorithm
12275 ✗ txt := Tpl.writeStr(txt, a_varName);
12276 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("."));
12277 ✗ txt := Tpl.writeStr(txt, i_name);
12278 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_ = "));
12279 ✗ txt := Tpl.writeStr(txt, a_structName);
12280 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("."));
12281 ✗ txt := Tpl.writeStr(txt, i_name);
12282 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_;"));
12283 then txt;
12284
12285 case ( txt,
12286 _,
12287 _,
12288 _ )
12289 then txt;
12290 end match;
12291 end fun_276;
12292
12293 protected function lm_277
12294 input output Tpl.Text txt;
12295 input list<DAE.Var> items;
12296 input String a_structName;
12297 input String a_varName;
12298 algorithm
12299 ✗ for lstElt_277 in items loop
12300 txt := match lstElt_277
12301 local
12302 DAE.Var i_e;
12303
12304 case i_e
12305 algorithm
12306 ✗ txt := fun_276(txt, i_e, a_structName, a_varName);
12307 ✗ txt := Tpl.nextIter(txt);
12308 then txt;
12309 end match;
12310 end for;
12311 end lm_277;
12312
12313 public function structParams
12314 input Tpl.Text txt;
12315 input String a_structName;
12316 input String a_varName;
12317 input list<DAE.Var> a_exps;
12318
12319 output Tpl.Text out_txt;
12320 protected
12321 Tpl.Text l_params;
12322 algorithm
12323 ✗ l_params := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
12324 ✗ l_params := lm_277(l_params, a_exps, a_structName, a_varName);
12325 ✗ l_params := Tpl.popIter(l_params);
12326 ✗ out_txt := Tpl.writeText(txt, l_params);
12327 end structParams;
12328
12329 protected function lm_279
12330 input output Tpl.Text txt;
12331 input list<tuple<DAE.Exp, String>> items;
12332 input Boolean a_useFlatArrayNotation;
12333 input output Tpl.Text a_stateDerVectorName;
12334 input output Tpl.Text a_extraFuncsNamespace;
12335 input output Tpl.Text a_extraFuncsDecl;
12336 input output Tpl.Text a_extraFuncs;
12337 input SimCode.SimCode a_simCode;
12338 input output Tpl.Text a_varDecls;
12339 input output Tpl.Text a_preExp;
12340 input SimCodeFunction.Context a_context;
12341 input Tpl.Text a_name;
12342 algorithm
12343
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 260 times.
1080 for lstElt_279 in items loop
12344 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_279
12345 local
12346 DAE.Exp i_exp;
12347 String i_compn;
12348 DAE.ComponentRef ret_1;
12349 Tpl.Text l_compnStr;
12350
12351 case (i_exp, i_compn)
12352 algorithm
12353 820 ret_1 := ComponentReference.makeUntypedCrefIdent(i_compn);
12354 820 l_compnStr := crefStr(Tpl.emptyTxt, ret_1);
12355 820 txt := Tpl.writeText(txt, a_name);
12356 820 txt := Tpl.writeTok(txt, Tpl.ST_STRING("."));
12357 820 txt := Tpl.writeText(txt, l_compnStr);
12358 820 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = "));
12359 820 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
12360 820 txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
12361 820 txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
12362 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
12363 end match;
12364 end for;
12365 end lm_279;
12366
12367 public function daeExpRecord
12368 input Tpl.Text in_txt;
12369 input DAE.Exp in_a_rec;
12370 input SimCodeFunction.Context in_a_context;
12371 input Tpl.Text in_a_preExp;
12372 input Tpl.Text in_a_varDecls;
12373 input SimCode.SimCode in_a_simCode;
12374 input Tpl.Text in_a_extraFuncs;
12375 input Tpl.Text in_a_extraFuncsDecl;
12376 input Tpl.Text in_a_extraFuncsNamespace;
12377 input Tpl.Text in_a_stateDerVectorName;
12378 input Boolean in_a_useFlatArrayNotation;
12379
12380 output Tpl.Text out_txt;
12381 output Tpl.Text out_a_preExp;
12382 output Tpl.Text out_a_varDecls;
12383 output Tpl.Text out_a_extraFuncs;
12384 output Tpl.Text out_a_extraFuncsDecl;
12385 output Tpl.Text out_a_extraFuncsNamespace;
12386 output Tpl.Text out_a_stateDerVectorName;
12387 algorithm
12388 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
12389 match(in_txt, in_a_rec, in_a_context, in_a_preExp, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
12390 local
12391 Tpl.Text txt;
12392 SimCodeFunction.Context a_context;
12393 Tpl.Text a_preExp;
12394 Tpl.Text a_varDecls;
12395 SimCode.SimCode a_simCode;
12396 Tpl.Text a_extraFuncs;
12397 Tpl.Text a_extraFuncsDecl;
12398 Tpl.Text a_extraFuncsNamespace;
12399 Tpl.Text a_stateDerVectorName;
12400 Boolean a_useFlatArrayNotation;
12401 list<String> i_comp;
12402 list<DAE.Exp> i_exps;
12403 Absyn.Path i_path;
12404 list<tuple<DAE.Exp, String>> ret_3;
12405 Tpl.Text l_ass;
12406 Tpl.Text txt_1;
12407 Tpl.Text l_name;
12408
12409 case ( txt,
12410 DAE.RECORD(path = i_path, exps = i_exps, comp = i_comp),
12411 a_context,
12412 a_preExp,
12413 a_varDecls,
12414 a_simCode,
12415 a_extraFuncs,
12416 a_extraFuncsDecl,
12417 a_extraFuncsNamespace,
12418 a_stateDerVectorName,
12419 a_useFlatArrayNotation )
12420 algorithm
12421 260 txt_1 := CodegenUtil.underscorePath(Tpl.emptyTxt, i_path);
12422 260 txt_1 := Tpl.writeTok(txt_1, Tpl.ST_STRING("Type"));
12423 260 (l_name, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(txt_1), a_varDecls);
12424 260 ret_3 := List.zip(i_exps, i_comp);
12425 260 (l_ass, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_279(Tpl.emptyTxt, ret_3, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context, l_name);
12426 260 a_preExp := Tpl.writeText(a_preExp, l_ass);
12427 260 txt := Tpl.writeText(txt, l_name);
12428 260 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
12429
12430 case ( txt,
12431 _,
12432 _,
12433 a_preExp,
12434 a_varDecls,
12435 _,
12436 a_extraFuncs,
12437 a_extraFuncsDecl,
12438 a_extraFuncsNamespace,
12439 a_stateDerVectorName,
12440 _ )
12441 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
12442 end match;
12443 end daeExpRecord;
12444
12445 protected function lm_281
12446 input output Tpl.Text txt;
12447 input list<tuple<DAE.Exp, String>> items;
12448 input Boolean a_useFlatArrayNotation;
12449 input output Tpl.Text a_stateDerVectorName;
12450 input output Tpl.Text a_extraFuncsNamespace;
12451 input output Tpl.Text a_extraFuncsDecl;
12452 input output Tpl.Text a_extraFuncs;
12453 input SimCode.SimCode a_simCode;
12454 input output Tpl.Text a_varDecls;
12455 input output Tpl.Text a_preExp;
12456 input SimCodeFunction.Context a_context;
12457 input Tpl.Text a_name;
12458 algorithm
12459 ✗ for lstElt_281 in items loop
12460 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_281
12461 local
12462 DAE.Exp i_exp;
12463 String i_compn;
12464 DAE.ComponentRef ret_1;
12465 Tpl.Text l_compnStr;
12466
12467 case (i_exp, i_compn)
12468 algorithm
12469 ✗ ret_1 := ComponentReference.makeUntypedCrefIdent(i_compn);
12470 ✗ l_compnStr := crefStr(Tpl.emptyTxt, ret_1);
12471 ✗ txt := Tpl.writeText(txt, a_name);
12472 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("."));
12473 ✗ txt := Tpl.writeText(txt, l_compnStr);
12474 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = "));
12475 ✗ (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
12476 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
12477 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
12478 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
12479 end match;
12480 end for;
12481 end lm_281;
12482
12483 public function daeExpRecordCall
12484 input Tpl.Text in_txt;
12485 input DAE.Exp in_a_rec;
12486 input SimCodeFunction.Context in_a_context;
12487 input Tpl.Text in_a_preExp;
12488 input Tpl.Text in_a_varDecls;
12489 input SimCode.SimCode in_a_simCode;
12490 input Tpl.Text in_a_extraFuncs;
12491 input Tpl.Text in_a_extraFuncsDecl;
12492 input Tpl.Text in_a_extraFuncsNamespace;
12493 input Tpl.Text in_a_stateDerVectorName;
12494 input Boolean in_a_useFlatArrayNotation;
12495
12496 output Tpl.Text out_txt;
12497 output Tpl.Text out_a_preExp;
12498 output Tpl.Text out_a_varDecls;
12499 output Tpl.Text out_a_extraFuncs;
12500 output Tpl.Text out_a_extraFuncsDecl;
12501 output Tpl.Text out_a_extraFuncsNamespace;
12502 output Tpl.Text out_a_stateDerVectorName;
12503 algorithm
12504 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
12505 match(in_txt, in_a_rec, in_a_context, in_a_preExp, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
12506 local
12507 Tpl.Text txt;
12508 SimCodeFunction.Context a_context;
12509 Tpl.Text a_preExp;
12510 Tpl.Text a_varDecls;
12511 SimCode.SimCode a_simCode;
12512 Tpl.Text a_extraFuncs;
12513 Tpl.Text a_extraFuncsDecl;
12514 Tpl.Text a_extraFuncsNamespace;
12515 Tpl.Text a_stateDerVectorName;
12516 Boolean a_useFlatArrayNotation;
12517 list<String> i_comp;
12518 list<DAE.Exp> i_exps;
12519 Absyn.Path i_path;
12520 list<tuple<DAE.Exp, String>> ret_3;
12521 Tpl.Text l_ass;
12522 Tpl.Text txt_1;
12523 Tpl.Text l_name;
12524
12525 case ( txt,
12526 DAE.METARECORDCALL(path = i_path, args = i_exps, fieldNames = i_comp),
12527 a_context,
12528 a_preExp,
12529 a_varDecls,
12530 a_simCode,
12531 a_extraFuncs,
12532 a_extraFuncsDecl,
12533 a_extraFuncsNamespace,
12534 a_stateDerVectorName,
12535 a_useFlatArrayNotation )
12536 algorithm
12537 ✗ txt_1 := CodegenUtil.underscorePath(Tpl.emptyTxt, i_path);
12538 ✗ txt_1 := Tpl.writeTok(txt_1, Tpl.ST_STRING("Type"));
12539 ✗ (l_name, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(txt_1), a_varDecls);
12540 ✗ ret_3 := List.zip(i_exps, i_comp);
12541 ✗ (l_ass, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_281(Tpl.emptyTxt, ret_3, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context, l_name);
12542 ✗ a_preExp := Tpl.writeText(a_preExp, l_ass);
12543 ✗ txt := Tpl.writeText(txt, l_name);
12544 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
12545
12546 case ( txt,
12547 _,
12548 _,
12549 a_preExp,
12550 a_varDecls,
12551 _,
12552 a_extraFuncs,
12553 a_extraFuncsDecl,
12554 a_extraFuncsNamespace,
12555 a_stateDerVectorName,
12556 _ )
12557 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
12558 end match;
12559 end daeExpRecordCall;
12560
12561 protected function fun_283
12562 input Tpl.Text in_txt;
12563 input SimCodeFunction.Context in_a_context;
12564
12565 output Tpl.Text out_txt;
12566 algorithm
12567 out_txt :=
12568 match(in_txt, in_a_context)
12569 local
12570 Tpl.Text txt;
12571 SimCodeFunction.Context i_context;
12572
12573 case ( txt,
12574 (i_context as SimCodeFunction.SIMULATION_CONTEXT(genDiscrete = _)) )
12575 algorithm
12576 6 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
12577 6 txt := contextSystem(txt, i_context);
12578 6 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_clockStart[clockIndex - 1])"));
12579 then txt;
12580
12581 case ( txt,
12582 i_context )
12583 algorithm
12584 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
12585 ✗ txt := contextSystem(txt, i_context);
12586 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_clockStart[clockIndex - 1] || "));
12587 ✗ txt := contextSystem(txt, i_context);
12588 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_clockSubactive[clockIndex - 1])"));
12589 then txt;
12590 end match;
12591 end fun_283;
12592
12593 protected function fun_284
12594 input Tpl.Text in_txt;
12595 input SimCodeFunction.Context in_a_context;
12596 input Integer in_a_index;
12597
12598 output Tpl.Text out_txt;
12599 algorithm
12600 out_txt :=
12601 match(in_txt, in_a_context, in_a_index)
12602 local
12603 Tpl.Text txt;
12604 Integer a_index;
12605 Integer ret_1;
12606 Integer ret_0;
12607
12608 case ( txt,
12609 SimCodeFunction.ALGLOOP_CONTEXT(genInitialisation = false),
12610 a_index )
12611 algorithm
12612 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_system->_time_conditions["));
12613 ✗ ret_0 := intSub(a_index, 1);
12614 ✗ txt := Tpl.writeStr(txt, intString(ret_0));
12615 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("]"));
12616 then txt;
12617
12618 case ( txt,
12619 _,
12620 a_index )
12621 algorithm
12622 36 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_time_conditions["));
12623 36 ret_1 := intSub(a_index, 1);
12624 36 txt := Tpl.writeStr(txt, intString(ret_1));
12625 36 txt := Tpl.writeTok(txt, Tpl.ST_STRING("]"));
12626 then txt;
12627 end match;
12628 end fun_284;
12629
12630 protected function fun_285
12631 input Tpl.Text in_txt;
12632 input SimCodeFunction.Context in_a_context;
12633
12634 output Tpl.Text out_txt;
12635 algorithm
12636 out_txt :=
12637 match(in_txt, in_a_context)
12638 local
12639 Tpl.Text txt;
12640
12641 case ( txt,
12642 SimCodeFunction.ALGLOOP_CONTEXT(genInitialisation = false) )
12643 algorithm
12644 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_system->_initial"));
12645 then txt;
12646
12647 case ( txt,
12648 _ )
12649 algorithm
12650 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_initial"));
12651 then txt;
12652 end match;
12653 end fun_285;
12654
12655 protected function fun_286
12656 input Tpl.Text in_txt;
12657 input SimCodeFunction.Context in_a_context;
12658
12659 output Tpl.Text out_txt;
12660 algorithm
12661 out_txt :=
12662 match(in_txt, in_a_context)
12663 local
12664 Tpl.Text txt;
12665
12666 case ( txt,
12667 SimCodeFunction.ALGLOOP_CONTEXT(genInitialisation = false) )
12668 algorithm
12669 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_system->_terminal"));
12670 then txt;
12671
12672 case ( txt,
12673 _ )
12674 algorithm
12675 4 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_terminal"));
12676 then txt;
12677 end match;
12678 end fun_286;
12679
12680 protected function fun_287
12681 input Tpl.Text in_txt;
12682 input SimCodeFunction.Context in_a_context;
12683 input Tpl.Text in_a_var3;
12684 input Tpl.Text in_a_var2;
12685 input Tpl.Text in_a_var1;
12686
12687 output Tpl.Text out_txt;
12688 algorithm
12689 out_txt :=
12690 match(in_txt, in_a_context, in_a_var3, in_a_var2, in_a_var1)
12691 local
12692 Tpl.Text txt;
12693 Tpl.Text a_var3;
12694 Tpl.Text a_var2;
12695 Tpl.Text a_var1;
12696
12697 case ( txt,
12698 SimCodeFunction.ALGLOOP_CONTEXT(genInitialisation = false),
12699 a_var3,
12700 a_var2,
12701 a_var1 )
12702 algorithm
12703 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(1));
12704 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("division("));
12705 ✗ txt := Tpl.writeText(txt, a_var1);
12706 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(","));
12707 ✗ txt := Tpl.writeText(txt, a_var2);
12708 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(",!_system->_initial,\""));
12709 ✗ txt := Tpl.writeText(txt, a_var3);
12710 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\")"));
12711 ✗ txt := Tpl.popBlock(txt);
12712 then txt;
12713
12714 case ( txt,
12715 _,
12716 a_var3,
12717 a_var2,
12718 a_var1 )
12719 algorithm
12720 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(1));
12721 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("division("));
12722 ✗ txt := Tpl.writeText(txt, a_var1);
12723 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(","));
12724 ✗ txt := Tpl.writeText(txt, a_var2);
12725 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(",!_initial,\""));
12726 ✗ txt := Tpl.writeText(txt, a_var3);
12727 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\")"));
12728 ✗ txt := Tpl.popBlock(txt);
12729 then txt;
12730 end match;
12731 end fun_287;
12732
12733 protected function fun_288
12734 input Tpl.Text in_txt;
12735 input DAE.Type in_a_ty;
12736
12737 output Tpl.Text out_txt;
12738 algorithm
12739 out_txt :=
12740 match(in_txt, in_a_ty)
12741 local
12742 Tpl.Text txt;
12743
12744 case ( txt,
12745 DAE.T_ARRAY(ty = DAE.T_INTEGER(varLst = _)) )
12746 algorithm
12747 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("int"));
12748 then txt;
12749
12750 case ( txt,
12751 DAE.T_ARRAY(ty = DAE.T_ENUMERATION(index = _)) )
12752 algorithm
12753 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("int"));
12754 then txt;
12755
12756 case ( txt,
12757 _ )
12758 algorithm
12759 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("double"));
12760 then txt;
12761 end match;
12762 end fun_288;
12763
12764 protected function smf_289
12765 input Tpl.Text in_txt;
12766 input SimCodeVar.SimVar in_it;
12767
12768 output Tpl.Text out_txt;
12769 algorithm
12770 out_txt :=
12771 match(in_txt, in_it)
12772 local
12773 Tpl.Text txt;
12774 Integer i_i;
12775
12776 case ( txt,
12777 SimCodeVar.SIMVAR(index = i_i) )
12778 algorithm
12779 249 txt := Tpl.writeTok(txt, Tpl.ST_STRING("__zDot["));
12780 249 txt := Tpl.writeStr(txt, intString(i_i));
12781 249 txt := Tpl.writeTok(txt, Tpl.ST_STRING("]"));
12782 then txt;
12783
12784 case ( txt,
12785 _ )
12786 then txt;
12787 end match;
12788 end smf_289;
12789
12790 protected function fun_290
12791 input Tpl.Text in_txt;
12792 input Boolean in_mArg;
12793 input Tpl.Text in_a_var1;
12794
12795 output Tpl.Text out_txt;
12796 algorithm
12797 out_txt :=
12798 match(in_txt, in_mArg, in_a_var1)
12799 local
12800 Tpl.Text txt;
12801 Tpl.Text a_var1;
12802
12803 case ( txt,
12804 false,
12805 a_var1 )
12806 algorithm
12807 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("puts("));
12808 ✗ txt := Tpl.writeText(txt, a_var1);
12809 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
12810 then txt;
12811
12812 case ( txt,
12813 _,
12814 a_var1 )
12815 algorithm
12816 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("print("));
12817 ✗ txt := Tpl.writeText(txt, a_var1);
12818 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
12819 then txt;
12820 end match;
12821 end fun_290;
12822
12823 protected function lm_291
12824 input output Tpl.Text txt;
12825 input list<DAE.Exp> items;
12826 input Boolean a_useFlatArrayNotation;
12827 input output Tpl.Text a_stateDerVectorName;
12828 input output Tpl.Text a_extraFuncsNamespace;
12829 input output Tpl.Text a_extraFuncsDecl;
12830 input output Tpl.Text a_extraFuncs;
12831 input SimCode.SimCode a_simCode;
12832 input output Tpl.Text a_varDecls;
12833 input output Tpl.Text a_preExp;
12834 input SimCodeFunction.Context a_context;
12835 algorithm
12836
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 76 times.
152 for lstElt_291 in items loop
12837 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_291
12838 local
12839 DAE.Exp i_exp;
12840
12841 case i_exp
12842 algorithm
12843 76 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
12844 76 txt := Tpl.nextIter(txt);
12845 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
12846 end match;
12847 end for;
12848 end lm_291;
12849
12850 protected function fun_292
12851 input Tpl.Text in_txt;
12852 input Boolean in_mArg;
12853 input DAE.Type in_a_attr_ty;
12854 input SimCodeFunction.Context in_a_context;
12855 input Tpl.Text in_a_argStr;
12856 input Tpl.Text in_a_preExp;
12857 input Tpl.Text in_a_varDecls;
12858 input DAE.Exp in_a_e1;
12859
12860 output Tpl.Text out_txt;
12861 output Tpl.Text out_a_preExp;
12862 output Tpl.Text out_a_varDecls;
12863 algorithm
12864 (out_txt, out_a_preExp, out_a_varDecls) :=
12865 match(in_txt, in_mArg, in_a_attr_ty, in_a_context, in_a_argStr, in_a_preExp, in_a_varDecls, in_a_e1)
12866 local
12867 Tpl.Text txt;
12868 DAE.Type a_attr_ty;
12869 SimCodeFunction.Context a_context;
12870 Tpl.Text a_argStr;
12871 Tpl.Text a_preExp;
12872 Tpl.Text a_varDecls;
12873 DAE.Exp a_e1;
12874 Tpl.Text l_retVar;
12875 Tpl.Text l_typeStr;
12876 Tpl.Text txt_4;
12877 String ret_4;
12878 Tpl.Text txt_3;
12879 Tpl.Text l_cstr;
12880 Tpl.Text txt_1;
12881 Tpl.Text l_tmp;
12882
12883 case ( txt,
12884 false,
12885 _,
12886 a_context,
12887 a_argStr,
12888 a_preExp,
12889 a_varDecls,
12890 a_e1 )
12891 algorithm
12892 76 txt_1 := expTypeFromExpModelica(Tpl.emptyTxt, a_e1);
12893 76 (l_tmp, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(txt_1), a_varDecls);
12894 76 l_cstr := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, a_e1, "\"");
12895 76 a_preExp := Tpl.writeText(a_preExp, l_tmp);
12896 76 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(" = "));
12897 76 a_preExp := Tpl.writeText(a_preExp, a_argStr);
12898 76 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_LINE(";\n"));
12899 76 txt_3 := Tpl.writeText(Tpl.emptyTxt, l_tmp);
12900 76 txt_3 := Tpl.writeTok(txt_3, Tpl.ST_STRING(" >= 0.0"));
12901 76 txt_4 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("\"Model error: Argument of sqrt("));
12902 76 ret_4 := Util.escapeModelicaStringToCString(Tpl.textString(l_cstr));
12903 76 txt_4 := Tpl.writeStr(txt_4, ret_4);
12904 76 txt_4 := Tpl.writeTok(txt_4, Tpl.ST_STRING(") should be >= 0\""));
12905 76 (a_preExp, txt_3, txt_4, a_varDecls) := assertCommonVar(a_preExp, txt_3, txt_4, a_context, a_varDecls, Absyn.dummyInfo);
12906 76 txt := Tpl.writeTok(txt, Tpl.ST_STRING("sqrt("));
12907 76 txt := Tpl.writeText(txt, l_tmp);
12908 76 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
12909 76 then (txt, a_preExp, a_varDecls);
12910
12911 case ( txt,
12912 _,
12913 a_attr_ty,
12914 _,
12915 a_argStr,
12916 a_preExp,
12917 a_varDecls,
12918 _ )
12919 algorithm
12920 ✗ l_typeStr := expTypeShort(Tpl.emptyTxt, a_attr_ty);
12921 ✗ (l_retVar, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(l_typeStr), a_varDecls);
12922 ✗ a_preExp := Tpl.writeText(a_preExp, l_retVar);
12923 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(" = std::sqrt("));
12924 ✗ a_preExp := Tpl.writeText(a_preExp, a_argStr);
12925 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
12926 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
12927 ✗ txt := Tpl.writeText(txt, l_retVar);
12928 ✗ then (txt, a_preExp, a_varDecls);
12929 end match;
12930 end fun_292;
12931
12932 protected function lm_293
12933 input output Tpl.Text txt;
12934 input list<DAE.Exp> items;
12935 input Boolean a_useFlatArrayNotation;
12936 input output Tpl.Text a_stateDerVectorName;
12937 input output Tpl.Text a_extraFuncsNamespace;
12938 input output Tpl.Text a_extraFuncsDecl;
12939 input output Tpl.Text a_extraFuncs;
12940 input SimCode.SimCode a_simCode;
12941 input output Tpl.Text a_varDecls;
12942 input output Tpl.Text a_preExp;
12943 input SimCodeFunction.Context a_context;
12944 algorithm
12945
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 43 times.
86 for lstElt_293 in items loop
12946 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_293
12947 local
12948 DAE.Exp i_exp;
12949
12950 case i_exp
12951 algorithm
12952 43 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
12953 43 txt := Tpl.nextIter(txt);
12954 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
12955 end match;
12956 end for;
12957 end lm_293;
12958
12959 protected function lm_294
12960 input output Tpl.Text txt;
12961 input list<DAE.Exp> items;
12962 input Boolean a_useFlatArrayNotation;
12963 input output Tpl.Text a_stateDerVectorName;
12964 input output Tpl.Text a_extraFuncsNamespace;
12965 input output Tpl.Text a_extraFuncsDecl;
12966 input output Tpl.Text a_extraFuncs;
12967 input SimCode.SimCode a_simCode;
12968 input output Tpl.Text a_varDecls;
12969 input output Tpl.Text a_preExp;
12970 input SimCodeFunction.Context a_context;
12971 algorithm
12972
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 33 times.
66 for lstElt_294 in items loop
12973 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_294
12974 local
12975 DAE.Exp i_exp;
12976
12977 case i_exp
12978 algorithm
12979 33 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
12980 33 txt := Tpl.nextIter(txt);
12981 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
12982 end match;
12983 end for;
12984 end lm_294;
12985
12986 protected function lm_295
12987 input output Tpl.Text txt;
12988 input list<DAE.Exp> items;
12989 input Boolean a_useFlatArrayNotation;
12990 input output Tpl.Text a_stateDerVectorName;
12991 input output Tpl.Text a_extraFuncsNamespace;
12992 input output Tpl.Text a_extraFuncsDecl;
12993 input output Tpl.Text a_extraFuncs;
12994 input SimCode.SimCode a_simCode;
12995 input output Tpl.Text a_varDecls;
12996 input output Tpl.Text a_preExp;
12997 input SimCodeFunction.Context a_context;
12998 algorithm
12999
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 for lstElt_295 in items loop
13000 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_295
13001 local
13002 DAE.Exp i_exp;
13003
13004 case i_exp
13005 algorithm
13006 2 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
13007 2 txt := Tpl.nextIter(txt);
13008 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
13009 end match;
13010 end for;
13011 end lm_295;
13012
13013 protected function lm_296
13014 input output Tpl.Text txt;
13015 input list<DAE.Exp> items;
13016 input Boolean a_useFlatArrayNotation;
13017 input output Tpl.Text a_stateDerVectorName;
13018 input output Tpl.Text a_extraFuncsNamespace;
13019 input output Tpl.Text a_extraFuncsDecl;
13020 input output Tpl.Text a_extraFuncs;
13021 input SimCode.SimCode a_simCode;
13022 input output Tpl.Text a_varDecls;
13023 input output Tpl.Text a_preExp;
13024 input SimCodeFunction.Context a_context;
13025 algorithm
13026
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
2 for lstElt_296 in items loop
13027 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_296
13028 local
13029 DAE.Exp i_exp;
13030
13031 case i_exp
13032 algorithm
13033 1 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
13034 1 txt := Tpl.nextIter(txt);
13035 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
13036 end match;
13037 end for;
13038 end lm_296;
13039
13040 protected function lm_297
13041 input output Tpl.Text txt;
13042 input list<DAE.Exp> items;
13043 input Boolean a_useFlatArrayNotation;
13044 input output Tpl.Text a_stateDerVectorName;
13045 input output Tpl.Text a_extraFuncsNamespace;
13046 input output Tpl.Text a_extraFuncsDecl;
13047 input output Tpl.Text a_extraFuncs;
13048 input SimCode.SimCode a_simCode;
13049 input output Tpl.Text a_varDecls;
13050 input output Tpl.Text a_preExp;
13051 input SimCodeFunction.Context a_context;
13052 algorithm
13053
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 73 times.
146 for lstElt_297 in items loop
13054 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_297
13055 local
13056 DAE.Exp i_exp;
13057
13058 case i_exp
13059 algorithm
13060 73 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
13061 73 txt := Tpl.nextIter(txt);
13062 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
13063 end match;
13064 end for;
13065 end lm_297;
13066
13067 protected function lm_298
13068 input output Tpl.Text txt;
13069 input list<DAE.Exp> items;
13070 input Boolean a_useFlatArrayNotation;
13071 input output Tpl.Text a_stateDerVectorName;
13072 input output Tpl.Text a_extraFuncsNamespace;
13073 input output Tpl.Text a_extraFuncsDecl;
13074 input output Tpl.Text a_extraFuncs;
13075 input SimCode.SimCode a_simCode;
13076 input output Tpl.Text a_varDecls;
13077 input output Tpl.Text a_preExp;
13078 input SimCodeFunction.Context a_context;
13079 algorithm
13080
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
2 for lstElt_298 in items loop
13081 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_298
13082 local
13083 DAE.Exp i_exp;
13084
13085 case i_exp
13086 algorithm
13087 1 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
13088 1 txt := Tpl.nextIter(txt);
13089 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
13090 end match;
13091 end for;
13092 end lm_298;
13093
13094 protected function lm_299
13095 input output Tpl.Text txt;
13096 input list<DAE.Exp> items;
13097 input Boolean a_useFlatArrayNotation;
13098 input output Tpl.Text a_stateDerVectorName;
13099 input output Tpl.Text a_extraFuncsNamespace;
13100 input output Tpl.Text a_extraFuncsDecl;
13101 input output Tpl.Text a_extraFuncs;
13102 input SimCode.SimCode a_simCode;
13103 input output Tpl.Text a_varDecls;
13104 input output Tpl.Text a_preExp;
13105 input SimCodeFunction.Context a_context;
13106 algorithm
13107 ✗ for lstElt_299 in items loop
13108 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_299
13109 local
13110 DAE.Exp i_exp;
13111
13112 case i_exp
13113 algorithm
13114 ✗ (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
13115 ✗ txt := Tpl.nextIter(txt);
13116 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
13117 end match;
13118 end for;
13119 end lm_299;
13120
13121 protected function lm_300
13122 input output Tpl.Text txt;
13123 input list<DAE.Exp> items;
13124 input Boolean a_useFlatArrayNotation;
13125 input output Tpl.Text a_stateDerVectorName;
13126 input output Tpl.Text a_extraFuncsNamespace;
13127 input output Tpl.Text a_extraFuncsDecl;
13128 input output Tpl.Text a_extraFuncs;
13129 input SimCode.SimCode a_simCode;
13130 input output Tpl.Text a_varDecls;
13131 input output Tpl.Text a_preExp;
13132 input SimCodeFunction.Context a_context;
13133 algorithm
13134 ✗ for lstElt_300 in items loop
13135 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_300
13136 local
13137 DAE.Exp i_exp;
13138
13139 case i_exp
13140 algorithm
13141 ✗ (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
13142 ✗ txt := Tpl.nextIter(txt);
13143 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
13144 end match;
13145 end for;
13146 end lm_300;
13147
13148 protected function lm_301
13149 input output Tpl.Text txt;
13150 input list<DAE.Exp> items;
13151 input Boolean a_useFlatArrayNotation;
13152 input output Tpl.Text a_stateDerVectorName;
13153 input output Tpl.Text a_extraFuncsNamespace;
13154 input output Tpl.Text a_extraFuncsDecl;
13155 input output Tpl.Text a_extraFuncs;
13156 input SimCode.SimCode a_simCode;
13157 input output Tpl.Text a_varDecls;
13158 input output Tpl.Text a_preExp;
13159 input SimCodeFunction.Context a_context;
13160 algorithm
13161
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
2 for lstElt_301 in items loop
13162 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_301
13163 local
13164 DAE.Exp i_exp;
13165
13166 case i_exp
13167 algorithm
13168 1 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
13169 1 txt := Tpl.nextIter(txt);
13170 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
13171 end match;
13172 end for;
13173 end lm_301;
13174
13175 protected function lm_302
13176 input output Tpl.Text txt;
13177 input list<DAE.Exp> items;
13178 input Boolean a_useFlatArrayNotation;
13179 input output Tpl.Text a_stateDerVectorName;
13180 input output Tpl.Text a_extraFuncsNamespace;
13181 input output Tpl.Text a_extraFuncsDecl;
13182 input output Tpl.Text a_extraFuncs;
13183 input SimCode.SimCode a_simCode;
13184 input output Tpl.Text a_varDecls;
13185 input output Tpl.Text a_preExp;
13186 input SimCodeFunction.Context a_context;
13187 algorithm
13188
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 for lstElt_302 in items loop
13189 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_302
13190 local
13191 DAE.Exp i_exp;
13192
13193 case i_exp
13194 algorithm
13195 9 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
13196 9 txt := Tpl.nextIter(txt);
13197 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
13198 end match;
13199 end for;
13200 end lm_302;
13201
13202 protected function lm_303
13203 input output Tpl.Text txt;
13204 input list<DAE.Exp> items;
13205 input Boolean a_useFlatArrayNotation;
13206 input output Tpl.Text a_stateDerVectorName;
13207 input output Tpl.Text a_extraFuncsNamespace;
13208 input output Tpl.Text a_extraFuncsDecl;
13209 input output Tpl.Text a_extraFuncs;
13210 input SimCode.SimCode a_simCode;
13211 input output Tpl.Text a_varDecls;
13212 input output Tpl.Text a_preExp;
13213 input SimCodeFunction.Context a_context;
13214 algorithm
13215
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
12 for lstElt_303 in items loop
13216 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_303
13217 local
13218 DAE.Exp i_exp;
13219
13220 case i_exp
13221 algorithm
13222 6 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
13223 6 txt := Tpl.nextIter(txt);
13224 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
13225 end match;
13226 end for;
13227 end lm_303;
13228
13229 protected function lm_304
13230 input output Tpl.Text txt;
13231 input list<DAE.Exp> items;
13232 input Boolean a_useFlatArrayNotation;
13233 input output Tpl.Text a_stateDerVectorName;
13234 input output Tpl.Text a_extraFuncsNamespace;
13235 input output Tpl.Text a_extraFuncsDecl;
13236 input output Tpl.Text a_extraFuncs;
13237 input SimCode.SimCode a_simCode;
13238 input output Tpl.Text a_varDecls;
13239 input output Tpl.Text a_preExp;
13240 input SimCodeFunction.Context a_context;
13241 algorithm
13242
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 11 times.
22 for lstElt_304 in items loop
13243 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_304
13244 local
13245 DAE.Exp i_exp;
13246
13247 case i_exp
13248 algorithm
13249 11 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
13250 11 txt := Tpl.nextIter(txt);
13251 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
13252 end match;
13253 end for;
13254 end lm_304;
13255
13256 protected function lm_305
13257 input output Tpl.Text txt;
13258 input list<DAE.Exp> items;
13259 input Boolean a_useFlatArrayNotation;
13260 input output Tpl.Text a_stateDerVectorName;
13261 input output Tpl.Text a_extraFuncsNamespace;
13262 input output Tpl.Text a_extraFuncsDecl;
13263 input output Tpl.Text a_extraFuncs;
13264 input SimCode.SimCode a_simCode;
13265 input output Tpl.Text a_varDecls;
13266 input output Tpl.Text a_preExp;
13267 input SimCodeFunction.Context a_context;
13268 algorithm
13269
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
18 for lstElt_305 in items loop
13270 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_305
13271 local
13272 DAE.Exp i_exp;
13273
13274 case i_exp
13275 algorithm
13276 12 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
13277 12 txt := Tpl.nextIter(txt);
13278 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
13279 end match;
13280 end for;
13281 end lm_305;
13282
13283 protected function fun_306
13284 input Tpl.Text in_txt;
13285 input DAE.Type in_a_ty;
13286 input Tpl.Text in_a_expVar;
13287
13288 output Tpl.Text out_txt;
13289 algorithm
13290 out_txt :=
13291 match(in_txt, in_a_ty, in_a_expVar)
13292 local
13293 Tpl.Text txt;
13294 Tpl.Text a_expVar;
13295 DAE.Type i_ty;
13296 DAE.Type i_elty;
13297
13298 case ( txt,
13299 DAE.T_ARRAY(ty = i_elty),
13300 a_expVar )
13301 algorithm
13302 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("DynArrayDim1<"));
13303 ✗ txt := expTypeShort(txt, i_elty);
13304 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(">("));
13305 ✗ txt := Tpl.writeText(txt, a_expVar);
13306 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".getNumElems(), ConstArray("));
13307 ✗ txt := Tpl.writeText(txt, a_expVar);
13308 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(").getData())"));
13309 then txt;
13310
13311 case ( txt,
13312 i_ty,
13313 a_expVar )
13314 algorithm
13315 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("StatArrayDim1<"));
13316 ✗ txt := expTypeShort(txt, i_ty);
13317 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(", 1, true>(&"));
13318 ✗ txt := Tpl.writeText(txt, a_expVar);
13319 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
13320 then txt;
13321 end match;
13322 end fun_306;
13323
13324 protected function lm_307
13325 input output Tpl.Text txt;
13326 input list<DAE.Exp> items;
13327 input Boolean a_useFlatArrayNotation;
13328 input output Tpl.Text a_stateDerVectorName;
13329 input output Tpl.Text a_extraFuncsNamespace;
13330 input output Tpl.Text a_extraFuncsDecl;
13331 input output Tpl.Text a_extraFuncs;
13332 input SimCode.SimCode a_simCode;
13333 input output Tpl.Text a_varDecls;
13334 input output Tpl.Text a_preExp;
13335 input SimCodeFunction.Context a_context;
13336 algorithm
13337
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 for lstElt_307 in items loop
13338 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_307
13339 local
13340 DAE.Exp i_dim;
13341
13342 case i_dim
13343 algorithm
13344 3 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_dim, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
13345 3 txt := Tpl.nextIter(txt);
13346 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
13347 end match;
13348 end for;
13349 end lm_307;
13350
13351 protected function fun_308
13352 input Tpl.Text in_txt;
13353 input DAE.Type in_mArg;
13354 input Tpl.Text in_a_dimstr;
13355
13356 output Tpl.Text out_txt;
13357 output Tpl.Text out_a_dimstr;
13358 algorithm
13359 (out_txt, out_a_dimstr) :=
13360 match(in_txt, in_mArg, in_a_dimstr)
13361 local
13362 Tpl.Text txt;
13363 Tpl.Text a_dimstr;
13364 DAE.Type i_ty;
13365 DAE.Dimensions i_dims;
13366 Integer ret_1;
13367 Integer ret_0;
13368
13369 case ( txt,
13370 (i_ty as DAE.T_ARRAY(dims = i_dims)),
13371 a_dimstr )
13372 algorithm
13373 4 ret_0 := listLength(i_dims);
13374 4 a_dimstr := Tpl.writeStr(a_dimstr, intString(ret_0));
13375 4 txt := Tpl.writeTok(txt, Tpl.ST_STRING("DynArrayDim"));
13376 4 ret_1 := listLength(i_dims);
13377 4 txt := Tpl.writeStr(txt, intString(ret_1));
13378 4 txt := Tpl.writeTok(txt, Tpl.ST_STRING("<"));
13379 4 txt := expTypeShort(txt, i_ty);
13380 4 txt := Tpl.writeTok(txt, Tpl.ST_STRING(">"));
13381 then (txt, a_dimstr);
13382
13383 case ( txt,
13384 _,
13385 a_dimstr )
13386 algorithm
13387 ✗ a_dimstr := Tpl.writeTok(a_dimstr, Tpl.ST_STRING("error array dims"));
13388 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("array error"));
13389 then (txt, a_dimstr);
13390 end match;
13391 end fun_308;
13392
13393 protected function lm_309
13394 input output Tpl.Text txt;
13395 input list<DAE.Exp> items;
13396 input Boolean a_useFlatArrayNotation;
13397 input output Tpl.Text a_stateDerVectorName;
13398 input output Tpl.Text a_extraFuncsNamespace;
13399 input output Tpl.Text a_extraFuncsDecl;
13400 input output Tpl.Text a_extraFuncs;
13401 input SimCode.SimCode a_simCode;
13402 input output Tpl.Text a_varDecls;
13403 input output Tpl.Text a_preExp;
13404 input SimCodeFunction.Context a_context;
13405 input Tpl.Text a_tvar;
13406 algorithm
13407
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4 times.
8 for lstElt_309 in items loop
13408 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_309
13409 local
13410 DAE.Exp i_array;
13411
13412 case i_array
13413 algorithm
13414 4 txt := Tpl.writeText(txt, a_tvar);
13415 4 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_list.push_back(&"));
13416 4 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_array, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
13417 4 txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
13418 4 txt := Tpl.nextIter(txt);
13419 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
13420 end match;
13421 end for;
13422 end lm_309;
13423
13424 protected function fun_310
13425 input Tpl.Text in_txt;
13426 input DAE.Type in_a_ty;
13427
13428 output Tpl.Text out_txt;
13429 algorithm
13430 out_txt :=
13431 match(in_txt, in_a_ty)
13432 local
13433 Tpl.Text txt;
13434
13435 case ( txt,
13436 DAE.T_ARRAY(ty = DAE.T_INTEGER(varLst = _)) )
13437 algorithm
13438 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("int"));
13439 then txt;
13440
13441 case ( txt,
13442 DAE.T_ARRAY(ty = DAE.T_ENUMERATION(index = _)) )
13443 algorithm
13444 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("int"));
13445 then txt;
13446
13447 case ( txt,
13448 _ )
13449 algorithm
13450 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("double"));
13451 then txt;
13452 end match;
13453 end fun_310;
13454
13455 protected function lm_311
13456 input output Tpl.Text txt;
13457 input list<DAE.Exp> items;
13458 input Boolean a_useFlatArrayNotation;
13459 input output Tpl.Text a_stateDerVectorName;
13460 input output Tpl.Text a_extraFuncsNamespace;
13461 input output Tpl.Text a_extraFuncsDecl;
13462 input output Tpl.Text a_extraFuncs;
13463 input SimCode.SimCode a_simCode;
13464 input output Tpl.Text a_varDecls;
13465 input output Tpl.Text a_preExp;
13466 input SimCodeFunction.Context a_context;
13467 algorithm
13468
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 31 times.
112 for lstElt_311 in items loop
13469 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_311
13470 local
13471 DAE.Exp i_exp;
13472
13473 case i_exp
13474 algorithm
13475 81 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
13476 81 txt := Tpl.nextIter(txt);
13477 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
13478 end match;
13479 end for;
13480 end lm_311;
13481
13482 protected function lm_312
13483 input output Tpl.Text txt;
13484 input list<DAE.Exp> items;
13485 input Boolean a_useFlatArrayNotation;
13486 input output Tpl.Text a_stateDerVectorName;
13487 input output Tpl.Text a_extraFuncsNamespace;
13488 input output Tpl.Text a_extraFuncsDecl;
13489 input output Tpl.Text a_extraFuncs;
13490 input SimCode.SimCode a_simCode;
13491 input output Tpl.Text a_varDecls;
13492 input output Tpl.Text a_preExp;
13493 input SimCodeFunction.Context a_context;
13494 algorithm
13495
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 46 times.
145 for lstElt_312 in items loop
13496 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_312
13497 local
13498 DAE.Exp i_exp;
13499
13500 case i_exp
13501 algorithm
13502 99 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
13503 99 txt := Tpl.nextIter(txt);
13504 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
13505 end match;
13506 end for;
13507 end lm_312;
13508
13509 protected function fun_313
13510 input Tpl.Text in_txt;
13511 input Boolean in_mArg;
13512
13513 output Tpl.Text out_txt;
13514 algorithm
13515 out_txt :=
13516 match(in_txt, in_mArg)
13517 local
13518 Tpl.Text txt;
13519
13520 case ( txt,
13521 true )
13522 then txt;
13523
13524 case ( txt,
13525 _ )
13526 algorithm
13527 46 txt := Tpl.writeTok(txt, Tpl.ST_STRING(","));
13528 then txt;
13529 end match;
13530 end fun_313;
13531
13532 protected function fun_314
13533 input Tpl.Text in_txt;
13534 input list<DAE.Exp> in_a_expLst;
13535 input Tpl.Text in_a_retVar;
13536
13537 output Tpl.Text out_txt;
13538 algorithm
13539 out_txt :=
13540 match(in_txt, in_a_expLst, in_a_retVar)
13541 local
13542 Tpl.Text txt;
13543 Tpl.Text a_retVar;
13544 Boolean ret_0;
13545
13546 case ( txt,
13547 {},
13548 _ )
13549 then txt;
13550
13551 case ( txt,
13552 _,
13553 a_retVar )
13554 algorithm
13555 46 ret_0 := Tpl.isEmpty(a_retVar);
13556 46 txt := fun_313(txt, ret_0);
13557 then txt;
13558 end match;
13559 end fun_314;
13560
13561 protected function lm_315
13562 input output Tpl.Text txt;
13563 input list<DAE.Exp> items;
13564 input Boolean a_useFlatArrayNotation;
13565 input output Tpl.Text a_stateDerVectorName;
13566 input output Tpl.Text a_extraFuncsNamespace;
13567 input output Tpl.Text a_extraFuncsDecl;
13568 input output Tpl.Text a_extraFuncs;
13569 input SimCode.SimCode a_simCode;
13570 input output Tpl.Text a_varDecls;
13571 input output Tpl.Text a_preExp;
13572 input SimCodeFunction.Context a_context;
13573 algorithm
13574
2/2
✓ Branch 0 taken 3657 times.
✓ Branch 1 taken 1362 times.
5019 for lstElt_315 in items loop
13575 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_315
13576 local
13577 DAE.Exp i_exp;
13578
13579 case i_exp
13580 algorithm
13581 3657 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
13582 3657 txt := Tpl.nextIter(txt);
13583 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
13584 end match;
13585 end for;
13586 end lm_315;
13587
13588 protected function fun_316
13589 input Tpl.Text in_txt;
13590 input Boolean in_mArg;
13591
13592 output Tpl.Text out_txt;
13593 algorithm
13594 out_txt :=
13595 match(in_txt, in_mArg)
13596 local
13597 Tpl.Text txt;
13598
13599 case ( txt,
13600 true )
13601 then txt;
13602
13603 case ( txt,
13604 _ )
13605 algorithm
13606 591 txt := Tpl.writeTok(txt, Tpl.ST_STRING(","));
13607 then txt;
13608 end match;
13609 end fun_316;
13610
13611 protected function fun_317
13612 input Tpl.Text in_txt;
13613 input list<DAE.Exp> in_a_explist;
13614 input Tpl.Text in_a_retVar;
13615
13616 output Tpl.Text out_txt;
13617 algorithm
13618 out_txt :=
13619 match(in_txt, in_a_explist, in_a_retVar)
13620 local
13621 Tpl.Text txt;
13622 Tpl.Text a_retVar;
13623 Boolean ret_0;
13624
13625 case ( txt,
13626 {},
13627 _ )
13628 then txt;
13629
13630 case ( txt,
13631 _,
13632 a_retVar )
13633 algorithm
13634 591 ret_0 := Tpl.isEmpty(a_retVar);
13635 591 txt := fun_316(txt, ret_0);
13636 then txt;
13637 end match;
13638 end fun_317;
13639
13640 protected function fun_318
13641 input Tpl.Text in_txt;
13642 input Boolean in_mArg;
13643 input Tpl.Text in_a_retVar;
13644
13645 output Tpl.Text out_txt;
13646 algorithm
13647 out_txt :=
13648 match(in_txt, in_mArg, in_a_retVar)
13649 local
13650 Tpl.Text txt;
13651 Tpl.Text a_retVar;
13652
13653 case ( txt,
13654 true,
13655 _ )
13656 then txt;
13657
13658 case ( txt,
13659 _,
13660 a_retVar )
13661 algorithm
13662 591 txt := Tpl.writeText(txt, a_retVar);
13663 then txt;
13664 end match;
13665 end fun_318;
13666
13667 protected function fun_319
13668 input Tpl.Text in_txt;
13669 input Boolean in_mArg;
13670
13671 output Tpl.Text out_txt;
13672 algorithm
13673 out_txt :=
13674 match(in_txt, in_mArg)
13675 local
13676 Tpl.Text txt;
13677
13678 case ( txt,
13679 true )
13680 then txt;
13681
13682 case ( txt,
13683 _ )
13684 algorithm
13685 770 txt := Tpl.writeTok(txt, Tpl.ST_STRING(","));
13686 then txt;
13687 end match;
13688 end fun_319;
13689
13690 protected function fun_320
13691 input Tpl.Text in_txt;
13692 input list<DAE.Exp> in_a_explist;
13693 input Tpl.Text in_a_retVar;
13694
13695 output Tpl.Text out_txt;
13696 algorithm
13697 out_txt :=
13698 match(in_txt, in_a_explist, in_a_retVar)
13699 local
13700 Tpl.Text txt;
13701 Tpl.Text a_retVar;
13702 Boolean ret_0;
13703
13704 case ( txt,
13705 {},
13706 _ )
13707 then txt;
13708
13709 case ( txt,
13710 _,
13711 a_retVar )
13712 algorithm
13713 770 ret_0 := Tpl.isEmpty(a_retVar);
13714 770 txt := fun_319(txt, ret_0);
13715 then txt;
13716 end match;
13717 end fun_320;
13718
13719 protected function fun_321
13720 input Tpl.Text in_txt;
13721 input Boolean in_mArg;
13722 input Tpl.Text in_a_retVar;
13723
13724 output Tpl.Text out_txt;
13725 algorithm
13726 out_txt :=
13727 match(in_txt, in_mArg, in_a_retVar)
13728 local
13729 Tpl.Text txt;
13730 Tpl.Text a_retVar;
13731
13732 case ( txt,
13733 true,
13734 _ )
13735 then txt;
13736
13737 case ( txt,
13738 _,
13739 a_retVar )
13740 algorithm
13741 771 txt := Tpl.writeText(txt, a_retVar);
13742 then txt;
13743 end match;
13744 end fun_321;
13745
13746 protected function fun_322
13747 input Tpl.Text in_txt;
13748 input SimCodeFunction.Context in_a_context;
13749 input Tpl.Text in_a_retVar;
13750 input list<DAE.Exp> in_a_explist;
13751 input Tpl.Text in_a_argStr;
13752 input Tpl.Text in_a_funName;
13753
13754 output Tpl.Text out_txt;
13755 algorithm
13756 out_txt :=
13757 match(in_txt, in_a_context, in_a_retVar, in_a_explist, in_a_argStr, in_a_funName)
13758 local
13759 Tpl.Text txt;
13760 Tpl.Text a_retVar;
13761 list<DAE.Exp> a_explist;
13762 Tpl.Text a_argStr;
13763 Tpl.Text a_funName;
13764 SimCodeFunction.Context i_context;
13765 Boolean ret_1;
13766 Boolean ret_0;
13767
13768 case ( txt,
13769 SimCodeFunction.FUNCTION_CONTEXT(cref_prefix = _),
13770 a_retVar,
13771 a_explist,
13772 a_argStr,
13773 a_funName )
13774 algorithm
13775 591 txt := Tpl.writeText(txt, a_funName);
13776 591 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
13777 591 txt := Tpl.writeText(txt, a_argStr);
13778 591 txt := fun_317(txt, a_explist, a_retVar);
13779 591 ret_0 := Tpl.isEmpty(a_retVar);
13780 591 txt := fun_318(txt, ret_0, a_retVar);
13781 591 txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
13782 591 txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
13783 then txt;
13784
13785 case ( txt,
13786 i_context,
13787 a_retVar,
13788 a_explist,
13789 a_argStr,
13790 a_funName )
13791 algorithm
13792 771 txt := contextFunName(txt, Tpl.textString(a_funName), i_context);
13793 771 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
13794 771 txt := Tpl.writeText(txt, a_argStr);
13795 771 txt := fun_320(txt, a_explist, a_retVar);
13796 771 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
13797 771 ret_1 := Tpl.isEmpty(a_retVar);
13798 771 txt := fun_321(txt, ret_1, a_retVar);
13799 771 txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
13800 771 txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
13801 then txt;
13802 end match;
13803 end fun_322;
13804
13805 protected function fun_323
13806 input Tpl.Text in_txt;
13807 input String in_mArg;
13808 input Tpl.Text in_a_funName;
13809 input Boolean in_a_useFlatArrayNotation;
13810 input Tpl.Text in_a_stateDerVectorName;
13811 input Tpl.Text in_a_extraFuncsNamespace;
13812 input Tpl.Text in_a_extraFuncsDecl;
13813 input Tpl.Text in_a_extraFuncs;
13814 input SimCode.SimCode in_a_simCode;
13815 input Tpl.Text in_a_varDecls;
13816 input Tpl.Text in_a_preExp;
13817 input SimCodeFunction.Context in_a_context;
13818 input list<DAE.Exp> in_a_explist;
13819
13820 output Tpl.Text out_txt;
13821 output Tpl.Text out_a_stateDerVectorName;
13822 output Tpl.Text out_a_extraFuncsNamespace;
13823 output Tpl.Text out_a_extraFuncsDecl;
13824 output Tpl.Text out_a_extraFuncs;
13825 output Tpl.Text out_a_varDecls;
13826 output Tpl.Text out_a_preExp;
13827 algorithm
13828 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls, out_a_preExp) :=
13829 match(in_txt, in_mArg, in_a_funName, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_varDecls, in_a_preExp, in_a_context, in_a_explist)
13830 local
13831 Tpl.Text txt;
13832 Tpl.Text a_funName;
13833 Boolean a_useFlatArrayNotation;
13834 Tpl.Text a_stateDerVectorName;
13835 Tpl.Text a_extraFuncsNamespace;
13836 Tpl.Text a_extraFuncsDecl;
13837 Tpl.Text a_extraFuncs;
13838 SimCode.SimCode a_simCode;
13839 Tpl.Text a_varDecls;
13840 Tpl.Text a_preExp;
13841 SimCodeFunction.Context a_context;
13842 list<DAE.Exp> a_explist;
13843 Tpl.Text l_retVar;
13844 Tpl.Text l_retType;
13845 Tpl.Text l_argStr;
13846
13847 case ( txt,
13848 "Modelica_Utilities_Files_loadResource",
13849 _,
13850 _,
13851 a_stateDerVectorName,
13852 a_extraFuncsNamespace,
13853 a_extraFuncsDecl,
13854 a_extraFuncs,
13855 _,
13856 a_varDecls,
13857 a_preExp,
13858 _,
13859 _ )
13860 algorithm
13861 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"noName\""));
13862 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
13863
13864 case ( txt,
13865 _,
13866 a_funName,
13867 a_useFlatArrayNotation,
13868 a_stateDerVectorName,
13869 a_extraFuncsNamespace,
13870 a_extraFuncsDecl,
13871 a_extraFuncs,
13872 a_simCode,
13873 a_varDecls,
13874 a_preExp,
13875 a_context,
13876 a_explist )
13877 algorithm
13878 1362 l_argStr := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
13879 1362 (l_argStr, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_315(l_argStr, a_explist, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
13880 1362 l_argStr := Tpl.popIter(l_argStr);
13881 1362 l_retType := Tpl.writeText(Tpl.emptyTxt, a_funName);
13882 1362 l_retType := Tpl.writeTok(l_retType, Tpl.ST_STRING("RetType"));
13883 1362 (l_retVar, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(l_retType), a_varDecls);
13884 1362 a_preExp := fun_322(a_preExp, a_context, l_retVar, a_explist, l_argStr, a_funName);
13885 1362 txt := Tpl.writeText(txt, l_retVar);
13886 1362 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
13887 end match;
13888 end fun_323;
13889
13890 public function daeExpCall
13891 input Tpl.Text in_txt;
13892 input DAE.Exp in_a_call;
13893 input SimCodeFunction.Context in_a_context;
13894 input Tpl.Text in_a_preExp;
13895 input Tpl.Text in_a_varDecls;
13896 input SimCode.SimCode in_a_simCode;
13897 input Tpl.Text in_a_extraFuncs;
13898 input Tpl.Text in_a_extraFuncsDecl;
13899 input Tpl.Text in_a_extraFuncsNamespace;
13900 input Tpl.Text in_a_stateDerVectorName;
13901 input Boolean in_a_useFlatArrayNotation;
13902
13903 output Tpl.Text out_txt;
13904 output Tpl.Text out_a_preExp;
13905 output Tpl.Text out_a_varDecls;
13906 output Tpl.Text out_a_extraFuncs;
13907 output Tpl.Text out_a_extraFuncsDecl;
13908 output Tpl.Text out_a_extraFuncsNamespace;
13909 output Tpl.Text out_a_stateDerVectorName;
13910 algorithm
13911 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
13912 match(in_txt, in_a_call, in_a_context, in_a_preExp, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
13913 local
13914 Tpl.Text txt;
13915 SimCodeFunction.Context a_context;
13916 Tpl.Text a_preExp;
13917 Tpl.Text a_varDecls;
13918 SimCode.SimCode a_simCode;
13919 Tpl.Text a_extraFuncs;
13920 Tpl.Text a_extraFuncsDecl;
13921 Tpl.Text a_extraFuncsNamespace;
13922 Tpl.Text a_stateDerVectorName;
13923 Boolean a_useFlatArrayNotation;
13924 DAE.Exp i_call;
13925 list<DAE.Exp> i_explist;
13926 Integer i_i;
13927 DAE.Exp i_s1;
13928 DAE.Exp i_toBeCasted;
13929 DAE.Exp i_delayMax;
13930 DAE.Exp i_d;
13931 DAE.Exp i_e;
13932 DAE.Exp i_signdig;
13933 DAE.Exp i_leftjust;
13934 DAE.Exp i_minlen;
13935 DAE.Exp i_format;
13936 DAE.Exp i_s;
13937 DAE.Type i_elty;
13938 DAE.Exp i_v;
13939 DAE.Exp i_v2;
13940 DAE.Exp i_v1;
13941 DAE.Exp i_n;
13942 DAE.Exp i_A;
13943 list<DAE.Exp> i_arrays;
13944 DAE.Exp i_a0;
13945 DAE.Exp i_dim;
13946 list<DAE.Exp> i_dims_1;
13947 DAE.Exp i_val;
13948 DAE.Exp i_exp;
13949 DAE.Exp i_array;
13950 DAE.Exp i_e3;
13951 Absyn.Path i_path;
13952 DAE.Type i_attr_ty;
13953 list<DAE.Exp> i_expLst;
13954 DAE.Exp i_inExp;
13955 DAE.Dimensions i_dims;
13956 DAE.Type i_ty;
13957 DAE.Exp i_e2;
13958 Integer i_index;
13959 DAE.Exp i_interval;
13960 DAE.Exp i_start;
13961 Integer i_arg_integer;
13962 DAE.ComponentRef i_arg_componentRef;
13963 DAE.Exp i_arg;
13964 DAE.Exp i_e1;
13965 Tpl.Text txt_57;
13966 String str_56;
13967 Tpl.Text l_expPart;
13968 Tpl.Text l_castedVar;
13969 Tpl.Text l_signdigExp;
13970 Tpl.Text l_leftjustExp;
13971 Tpl.Text l_minlenExp;
13972 Tpl.Text l_formatExp;
13973 Tpl.Text l_sExp;
13974 Tpl.Text l_emptybuf;
13975 Tpl.Text l_typeStr;
13976 Tpl.Text txt_46;
13977 Tpl.Text txt_44;
13978 Integer ret_44;
13979 Tpl.Text l_type__str;
13980 Tpl.Text l_tmp;
13981 Tpl.Text l_arrayType;
13982 Tpl.Text l_arrays__exp;
13983 Tpl.Text l_a0str;
13984 DAE.Type ret_38;
13985 Tpl.Text l_dimstr;
13986 Tpl.Text l_dim__exp;
13987 Integer ret_35;
13988 Tpl.Text l_tmp__type__str;
13989 Tpl.Text l_ty__str;
13990 Tpl.Text l_dimsExp;
13991 Tpl.Text l_valExp;
13992 Tpl.Text l_tvar;
13993 Tpl.Text l_arr__tp__str;
13994 Tpl.Text l_expVar;
13995 Tpl.Text l_retVar;
13996 Tpl.Text l_retType;
13997 Tpl.Text l_funName;
13998 Boolean ret_24;
13999 Tpl.Text l_argStr;
14000 Tpl.Text l_exp;
14001 Boolean ret_21;
14002 SimCodeVar.SimVar ret_20;
14003 Integer ret_19;
14004 String ret_18;
14005 Tpl.Text txt_17;
14006 Tpl.Text txt_15;
14007 Integer ret_15;
14008 Tpl.Text l_var;
14009 Tpl.Text l_type;
14010 String ret_12;
14011 Tpl.Text txt_11;
14012 Tpl.Text l_var3;
14013 Tpl.Text l_var2;
14014 Tpl.Text l_eInterval;
14015 Tpl.Text l_eStart;
14016 Tpl.Text l_preExp;
14017 Integer ret_5;
14018 list<SimCode.ClockedPartition> ret_4;
14019 Tpl.Text l_absClockIdx;
14020 DAE.Exp ret_2;
14021 DAE.ComponentRef ret_1;
14022 Tpl.Text l_var1;
14023
14024 case ( txt,
14025 DAE.CALL(path = Absyn.IDENT(name = "edge"), expLst = {i_e1}),
14026 a_context,
14027 a_preExp,
14028 a_varDecls,
14029 a_simCode,
14030 a_extraFuncs,
14031 a_extraFuncsDecl,
14032 a_extraFuncsNamespace,
14033 a_stateDerVectorName,
14034 a_useFlatArrayNotation )
14035 algorithm
14036 ✗ (l_var1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e1, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14037 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_discrete_events.edge("));
14038 ✗ txt := Tpl.writeText(txt, l_var1);
14039 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14040 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14041
14042 case ( txt,
14043 DAE.CALL(path = Absyn.IDENT(name = "pre"), expLst = {(i_arg as DAE.CREF(componentRef = _))}),
14044 a_context,
14045 a_preExp,
14046 a_varDecls,
14047 a_simCode,
14048 a_extraFuncs,
14049 a_extraFuncsDecl,
14050 a_extraFuncsNamespace,
14051 a_stateDerVectorName,
14052 a_useFlatArrayNotation )
14053 algorithm
14054 354 (l_var1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_arg, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14055 354 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_discrete_events->pre("));
14056 354 txt := Tpl.writeText(txt, l_var1);
14057 354 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14058 354 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14059
14060 case ( txt,
14061 DAE.CALL(path = Absyn.IDENT(name = "previous"), expLst = {DAE.CREF(componentRef = i_arg_componentRef)}),
14062 a_context,
14063 a_preExp,
14064 a_varDecls,
14065 a_simCode,
14066 a_extraFuncs,
14067 a_extraFuncsDecl,
14068 a_extraFuncsNamespace,
14069 a_stateDerVectorName,
14070 a_useFlatArrayNotation )
14071 algorithm
14072 116 ret_1 := ComponentReference.crefPrefixPrevious(i_arg_componentRef);
14073 116 ret_2 := Expression.crefExp(ret_1);
14074 116 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, ret_2, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14075 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14076
14077 case ( txt,
14078 DAE.CALL(path = Absyn.IDENT(name = "firstTick")),
14079 a_context,
14080 a_preExp,
14081 a_varDecls,
14082 _,
14083 a_extraFuncs,
14084 a_extraFuncsDecl,
14085 a_extraFuncsNamespace,
14086 a_stateDerVectorName,
14087 _ )
14088 algorithm
14089 6 txt := fun_283(txt, a_context);
14090 6 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14091
14092 case ( txt,
14093 DAE.CALL(path = Absyn.IDENT(name = "interval")),
14094 a_context,
14095 a_preExp,
14096 a_varDecls,
14097 _,
14098 a_extraFuncs,
14099 a_extraFuncsDecl,
14100 a_extraFuncsNamespace,
14101 a_stateDerVectorName,
14102 _ )
14103 algorithm
14104 4 txt := contextSystem(txt, a_context);
14105 4 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_clockInterval[clockIndex - 1]"));
14106 4 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14107
14108 case ( txt,
14109 DAE.CALL(path = Absyn.IDENT(name = "$_clkfire"), expLst = {DAE.ICONST(integer = i_arg_integer)}),
14110 _,
14111 a_preExp,
14112 a_varDecls,
14113 a_simCode,
14114 a_extraFuncs,
14115 a_extraFuncsDecl,
14116 a_extraFuncsNamespace,
14117 a_stateDerVectorName,
14118 _ )
14119 algorithm
14120 6 ret_4 := SimCodeCodegenUtil.getClockedPartitions(a_simCode);
14121 6 ret_5 := SimCodeCodegenUtil.absoluteClockIdxForBaseClock(i_arg_integer, ret_4);
14122 6 l_absClockIdx := Tpl.writeStr(Tpl.emptyTxt, intString(ret_5));
14123 6 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_time_conditions["));
14124 6 txt := Tpl.writeText(txt, l_absClockIdx);
14125 6 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" - 1 + "));
14126 6 txt := timeEventLength(txt, a_simCode);
14127 6 txt := Tpl.writeTok(txt, Tpl.ST_STRING("] = (_simTime > _clockTime["));
14128 6 txt := Tpl.writeText(txt, l_absClockIdx);
14129 6 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" - 1])"));
14130 6 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14131
14132 case ( txt,
14133 DAE.CALL(path = Absyn.IDENT(name = "$getPart"), expLst = {i_e1}),
14134 a_context,
14135 a_preExp,
14136 a_varDecls,
14137 a_simCode,
14138 a_extraFuncs,
14139 a_extraFuncsDecl,
14140 a_extraFuncsNamespace,
14141 a_stateDerVectorName,
14142 a_useFlatArrayNotation )
14143 algorithm
14144 44 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_e1, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14145 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14146
14147 case ( txt,
14148 DAE.CALL(path = Absyn.IDENT(name = "sample"), expLst = {DAE.ICONST(integer = i_index), i_start, i_interval}),
14149 a_context,
14150 a_preExp,
14151 a_varDecls,
14152 a_simCode,
14153 a_extraFuncs,
14154 a_extraFuncsDecl,
14155 a_extraFuncsNamespace,
14156 a_stateDerVectorName,
14157 a_useFlatArrayNotation )
14158 algorithm
14159 36 l_preExp := Tpl.emptyTxt;
14160 36 (l_eStart, l_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_start, SimCodeFunction.contextOther, l_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14161 36 (l_eInterval, l_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_interval, SimCodeFunction.contextOther, l_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14162 36 txt := fun_284(txt, a_context, i_index);
14163 36 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14164
14165 case ( txt,
14166 DAE.CALL(path = Absyn.IDENT(name = "initial")),
14167 a_context,
14168 a_preExp,
14169 a_varDecls,
14170 _,
14171 a_extraFuncs,
14172 a_extraFuncsDecl,
14173 a_extraFuncsNamespace,
14174 a_stateDerVectorName,
14175 _ )
14176 algorithm
14177 ✗ txt := fun_285(txt, a_context);
14178 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14179
14180 case ( txt,
14181 DAE.CALL(path = Absyn.IDENT(name = "terminal")),
14182 a_context,
14183 a_preExp,
14184 a_varDecls,
14185 _,
14186 a_extraFuncs,
14187 a_extraFuncsDecl,
14188 a_extraFuncsNamespace,
14189 a_stateDerVectorName,
14190 _ )
14191 algorithm
14192 4 txt := fun_286(txt, a_context);
14193 4 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14194
14195 case ( txt,
14196 DAE.CALL(path = Absyn.IDENT(name = "DIVISION"), expLst = {i_e1, i_e2}),
14197 a_context,
14198 a_preExp,
14199 a_varDecls,
14200 a_simCode,
14201 a_extraFuncs,
14202 a_extraFuncsDecl,
14203 a_extraFuncsNamespace,
14204 a_stateDerVectorName,
14205 a_useFlatArrayNotation )
14206 algorithm
14207 ✗ (l_var1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e1, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14208 ✗ (l_var2, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e2, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14209 ✗ txt_11 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_e2, "\"");
14210 ✗ ret_12 := Util.escapeModelicaStringToCString(Tpl.textString(txt_11));
14211 ✗ l_var3 := Tpl.writeStr(Tpl.emptyTxt, ret_12);
14212 ✗ txt := fun_287(txt, a_context, l_var3, l_var2, l_var1);
14213 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14214
14215 case ( txt,
14216 DAE.CALL(path = Absyn.IDENT(name = "sign"), expLst = {i_e1}),
14217 a_context,
14218 a_preExp,
14219 a_varDecls,
14220 a_simCode,
14221 a_extraFuncs,
14222 a_extraFuncsDecl,
14223 a_extraFuncsNamespace,
14224 a_stateDerVectorName,
14225 a_useFlatArrayNotation )
14226 algorithm
14227 4 (l_var1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e1, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14228 4 txt := Tpl.writeTok(txt, Tpl.ST_STRING("sgn("));
14229 4 txt := Tpl.writeText(txt, l_var1);
14230 4 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14231 4 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14232
14233 case ( txt,
14234 DAE.CALL(attr = DAE.CALL_ATTR(ty = (i_ty as DAE.T_ARRAY(dims = i_dims))), path = Absyn.IDENT(name = "DIVISION_ARRAY_SCALAR"), expLst = {i_e1, i_e2}),
14235 a_context,
14236 a_preExp,
14237 a_varDecls,
14238 a_simCode,
14239 a_extraFuncs,
14240 a_extraFuncsDecl,
14241 a_extraFuncsNamespace,
14242 a_stateDerVectorName,
14243 a_useFlatArrayNotation )
14244 algorithm
14245 ✗ l_type := fun_288(Tpl.emptyTxt, i_ty);
14246 ✗ txt_15 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("multi_array<"));
14247 ✗ txt_15 := Tpl.writeText(txt_15, l_type);
14248 ✗ txt_15 := Tpl.writeTok(txt_15, Tpl.ST_STRING(","));
14249 ✗ ret_15 := listLength(i_dims);
14250 ✗ txt_15 := Tpl.writeStr(txt_15, intString(ret_15));
14251 ✗ txt_15 := Tpl.writeTok(txt_15, Tpl.ST_STRING(">"));
14252 ✗ (l_var, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(txt_15), a_varDecls);
14253 ✗ (l_var1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e1, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14254 ✗ (l_var2, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e2, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14255 ✗ txt_17 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_e2, "\"");
14256 ✗ ret_18 := Util.escapeModelicaStringToCString(Tpl.textString(txt_17));
14257 ✗ l_var3 := Tpl.writeStr(Tpl.emptyTxt, ret_18);
14258 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("assign_array("));
14259 ✗ a_preExp := Tpl.writeText(a_preExp, l_var);
14260 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(",divide_array<"));
14261 ✗ a_preExp := Tpl.writeText(a_preExp, l_type);
14262 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(","));
14263 ✗ ret_19 := listLength(i_dims);
14264 ✗ a_preExp := Tpl.writeStr(a_preExp, intString(ret_19));
14265 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(">("));
14266 ✗ a_preExp := Tpl.writeText(a_preExp, l_var1);
14267 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
14268 ✗ a_preExp := Tpl.writeText(a_preExp, l_var2);
14269 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("));"));
14270 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
14271 ✗ txt := Tpl.writeText(txt, l_var);
14272 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14273
14274 case ( txt,
14275 DAE.CALL(path = Absyn.IDENT(name = "der"), expLst = {DAE.CREF(componentRef = i_arg_componentRef)}),
14276 _,
14277 a_preExp,
14278 a_varDecls,
14279 a_simCode,
14280 a_extraFuncs,
14281 a_extraFuncsDecl,
14282 a_extraFuncsNamespace,
14283 a_stateDerVectorName,
14284 _ )
14285 algorithm
14286 249 ret_20 := SimCodeCodegenUtil.cref2simvar(i_arg_componentRef, a_simCode);
14287 249 l_var := smf_289(Tpl.emptyTxt, ret_20);
14288 249 txt := Tpl.writeText(txt, l_var);
14289 249 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14290
14291 case ( txt,
14292 DAE.CALL(path = Absyn.IDENT(name = "print"), expLst = {i_e1}),
14293 a_context,
14294 a_preExp,
14295 a_varDecls,
14296 a_simCode,
14297 a_extraFuncs,
14298 a_extraFuncsDecl,
14299 a_extraFuncsNamespace,
14300 a_stateDerVectorName,
14301 a_useFlatArrayNotation )
14302 algorithm
14303 ✗ (l_var1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e1, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14304 ✗ ret_21 := Config.acceptMetaModelicaGrammar();
14305 ✗ txt := fun_290(txt, ret_21, l_var1);
14306 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14307
14308 case ( txt,
14309 DAE.CALL(path = Absyn.IDENT(name = "integer"), expLst = {i_inExp, _}),
14310 a_context,
14311 a_preExp,
14312 a_varDecls,
14313 a_simCode,
14314 a_extraFuncs,
14315 a_extraFuncsDecl,
14316 a_extraFuncsNamespace,
14317 a_stateDerVectorName,
14318 a_useFlatArrayNotation )
14319 algorithm
14320 8 (l_exp, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_inExp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14321 8 txt := Tpl.writeTok(txt, Tpl.ST_STRING("integer("));
14322 8 txt := Tpl.writeText(txt, l_exp);
14323 8 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14324 8 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14325
14326 case ( txt,
14327 DAE.CALL(path = Absyn.IDENT(name = "floor"), expLst = {i_inExp, _}, attr = DAE.CALL_ATTR(ty = _)),
14328 a_context,
14329 a_preExp,
14330 a_varDecls,
14331 a_simCode,
14332 a_extraFuncs,
14333 a_extraFuncsDecl,
14334 a_extraFuncsNamespace,
14335 a_stateDerVectorName,
14336 a_useFlatArrayNotation )
14337 algorithm
14338 ✗ (l_exp, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_inExp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14339 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("std::floor("));
14340 ✗ txt := Tpl.writeText(txt, l_exp);
14341 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14342 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14343
14344 case ( txt,
14345 DAE.CALL(path = Absyn.IDENT(name = "floor"), expLst = {i_inExp}, attr = DAE.CALL_ATTR(ty = _)),
14346 a_context,
14347 a_preExp,
14348 a_varDecls,
14349 a_simCode,
14350 a_extraFuncs,
14351 a_extraFuncsDecl,
14352 a_extraFuncsNamespace,
14353 a_stateDerVectorName,
14354 a_useFlatArrayNotation )
14355 algorithm
14356 ✗ (l_exp, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_inExp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14357 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("std::floor("));
14358 ✗ txt := Tpl.writeText(txt, l_exp);
14359 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14360 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14361
14362 case ( txt,
14363 DAE.CALL(path = Absyn.IDENT(name = "ceil"), expLst = {i_inExp, _}, attr = DAE.CALL_ATTR(ty = _)),
14364 a_context,
14365 a_preExp,
14366 a_varDecls,
14367 a_simCode,
14368 a_extraFuncs,
14369 a_extraFuncsDecl,
14370 a_extraFuncsNamespace,
14371 a_stateDerVectorName,
14372 a_useFlatArrayNotation )
14373 algorithm
14374 ✗ (l_exp, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_inExp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14375 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("std::ceil("));
14376 ✗ txt := Tpl.writeText(txt, l_exp);
14377 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14378 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14379
14380 case ( txt,
14381 DAE.CALL(path = Absyn.IDENT(name = "ceil"), expLst = {i_inExp}, attr = DAE.CALL_ATTR(ty = _)),
14382 a_context,
14383 a_preExp,
14384 a_varDecls,
14385 a_simCode,
14386 a_extraFuncs,
14387 a_extraFuncsDecl,
14388 a_extraFuncsNamespace,
14389 a_stateDerVectorName,
14390 a_useFlatArrayNotation )
14391 algorithm
14392 ✗ (l_exp, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_inExp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14393 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("std::ceil("));
14394 ✗ txt := Tpl.writeText(txt, l_exp);
14395 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14396 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14397
14398 case ( txt,
14399 DAE.CALL(path = Absyn.IDENT(name = "integer"), expLst = {i_inExp}),
14400 a_context,
14401 a_preExp,
14402 a_varDecls,
14403 a_simCode,
14404 a_extraFuncs,
14405 a_extraFuncsDecl,
14406 a_extraFuncsNamespace,
14407 a_stateDerVectorName,
14408 a_useFlatArrayNotation )
14409 algorithm
14410 10 (l_exp, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_inExp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14411 10 txt := Tpl.writeTok(txt, Tpl.ST_STRING("integer("));
14412 10 txt := Tpl.writeText(txt, l_exp);
14413 10 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14414 10 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14415
14416 case ( txt,
14417 DAE.CALL(path = Absyn.IDENT(name = "max"), attr = DAE.CALL_ATTR(ty = DAE.T_REAL(varLst = _)), expLst = {i_e1, i_e2}),
14418 a_context,
14419 a_preExp,
14420 a_varDecls,
14421 a_simCode,
14422 a_extraFuncs,
14423 a_extraFuncsDecl,
14424 a_extraFuncsNamespace,
14425 a_stateDerVectorName,
14426 a_useFlatArrayNotation )
14427 algorithm
14428 383 (l_var1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e1, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14429 383 (l_var2, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e2, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14430 383 txt := Tpl.writeTok(txt, Tpl.ST_STRING("max("));
14431 383 txt := Tpl.writeText(txt, l_var1);
14432 383 txt := Tpl.writeTok(txt, Tpl.ST_STRING(","));
14433 383 txt := Tpl.writeText(txt, l_var2);
14434 383 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14435 383 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14436
14437 case ( txt,
14438 DAE.CALL(path = Absyn.IDENT(name = "max"), expLst = {i_e1, i_e2}),
14439 a_context,
14440 a_preExp,
14441 a_varDecls,
14442 a_simCode,
14443 a_extraFuncs,
14444 a_extraFuncsDecl,
14445 a_extraFuncsNamespace,
14446 a_stateDerVectorName,
14447 a_useFlatArrayNotation )
14448 algorithm
14449 10 (l_var1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e1, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14450 10 (l_var2, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e2, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14451 10 txt := Tpl.writeTok(txt, Tpl.ST_STRING("max("));
14452 10 txt := Tpl.writeText(txt, l_var1);
14453 10 txt := Tpl.writeTok(txt, Tpl.ST_STRING(","));
14454 10 txt := Tpl.writeText(txt, l_var2);
14455 10 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14456 10 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14457
14458 case ( txt,
14459 DAE.CALL(attr = DAE.CALL_ATTR(ty = DAE.T_REAL(varLst = _)), path = Absyn.IDENT(name = "min"), expLst = {i_e1, i_e2}),
14460 a_context,
14461 a_preExp,
14462 a_varDecls,
14463 a_simCode,
14464 a_extraFuncs,
14465 a_extraFuncsDecl,
14466 a_extraFuncsNamespace,
14467 a_stateDerVectorName,
14468 a_useFlatArrayNotation )
14469 algorithm
14470 116 (l_var1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e1, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14471 116 (l_var2, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e2, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14472 116 txt := Tpl.writeTok(txt, Tpl.ST_STRING("min("));
14473 116 txt := Tpl.writeText(txt, l_var1);
14474 116 txt := Tpl.writeTok(txt, Tpl.ST_STRING(","));
14475 116 txt := Tpl.writeText(txt, l_var2);
14476 116 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14477 116 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14478
14479 case ( txt,
14480 DAE.CALL(path = Absyn.IDENT(name = "min"), expLst = {i_e1, i_e2}),
14481 a_context,
14482 a_preExp,
14483 a_varDecls,
14484 a_simCode,
14485 a_extraFuncs,
14486 a_extraFuncsDecl,
14487 a_extraFuncsNamespace,
14488 a_stateDerVectorName,
14489 a_useFlatArrayNotation )
14490 algorithm
14491 4 (l_var1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e1, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14492 4 (l_var2, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e2, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14493 4 txt := Tpl.writeTok(txt, Tpl.ST_STRING("min("));
14494 4 txt := Tpl.writeText(txt, l_var1);
14495 4 txt := Tpl.writeTok(txt, Tpl.ST_STRING(","));
14496 4 txt := Tpl.writeText(txt, l_var2);
14497 4 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14498 4 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14499
14500 case ( txt,
14501 DAE.CALL(path = Absyn.IDENT(name = "abs"), expLst = {i_e1}, attr = DAE.CALL_ATTR(ty = DAE.T_INTEGER(varLst = _))),
14502 a_context,
14503 a_preExp,
14504 a_varDecls,
14505 a_simCode,
14506 a_extraFuncs,
14507 a_extraFuncsDecl,
14508 a_extraFuncsNamespace,
14509 a_stateDerVectorName,
14510 a_useFlatArrayNotation )
14511 algorithm
14512 ✗ (l_var1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e1, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14513 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("std::labs("));
14514 ✗ txt := Tpl.writeText(txt, l_var1);
14515 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14516 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14517
14518 case ( txt,
14519 DAE.CALL(path = Absyn.IDENT(name = "abs"), expLst = {i_e1}),
14520 a_context,
14521 a_preExp,
14522 a_varDecls,
14523 a_simCode,
14524 a_extraFuncs,
14525 a_extraFuncsDecl,
14526 a_extraFuncsNamespace,
14527 a_stateDerVectorName,
14528 a_useFlatArrayNotation )
14529 algorithm
14530 121 (l_var1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e1, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14531 121 txt := Tpl.writeTok(txt, Tpl.ST_STRING("std::abs("));
14532 121 txt := Tpl.writeText(txt, l_var1);
14533 121 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14534 121 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14535
14536 case ( txt,
14537 DAE.CALL(path = Absyn.IDENT(name = "sqrt"), expLst = (i_expLst as {i_e1}), attr = DAE.CALL_ATTR(ty = i_attr_ty)),
14538 a_context,
14539 a_preExp,
14540 a_varDecls,
14541 a_simCode,
14542 a_extraFuncs,
14543 a_extraFuncsDecl,
14544 a_extraFuncsNamespace,
14545 a_stateDerVectorName,
14546 a_useFlatArrayNotation )
14547 algorithm
14548 76 l_argStr := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
14549 76 (l_argStr, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_291(l_argStr, i_expLst, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
14550 76 l_argStr := Tpl.popIter(l_argStr);
14551 76 ret_24 := Expression.isPositiveOrZero(i_e1);
14552 76 (txt, a_preExp, a_varDecls) := fun_292(txt, ret_24, i_attr_ty, a_context, l_argStr, a_preExp, a_varDecls, i_e1);
14553 76 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14554
14555 case ( txt,
14556 DAE.CALL(path = (i_path as Absyn.IDENT(name = "sin")), expLst = (i_expLst as {_})),
14557 a_context,
14558 a_preExp,
14559 a_varDecls,
14560 a_simCode,
14561 a_extraFuncs,
14562 a_extraFuncsDecl,
14563 a_extraFuncsNamespace,
14564 a_stateDerVectorName,
14565 a_useFlatArrayNotation )
14566 algorithm
14567 43 l_argStr := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
14568 43 (l_argStr, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_293(l_argStr, i_expLst, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
14569 43 l_argStr := Tpl.popIter(l_argStr);
14570 43 l_funName := CodegenUtil.underscorePath(Tpl.emptyTxt, i_path);
14571 43 txt := Tpl.writeTok(txt, Tpl.ST_STRING("std::"));
14572 43 txt := Tpl.writeText(txt, l_funName);
14573 43 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
14574 43 txt := Tpl.writeText(txt, l_argStr);
14575 43 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14576 43 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14577
14578 case ( txt,
14579 DAE.CALL(path = (i_path as Absyn.IDENT(name = "cos")), expLst = (i_expLst as {_})),
14580 a_context,
14581 a_preExp,
14582 a_varDecls,
14583 a_simCode,
14584 a_extraFuncs,
14585 a_extraFuncsDecl,
14586 a_extraFuncsNamespace,
14587 a_stateDerVectorName,
14588 a_useFlatArrayNotation )
14589 algorithm
14590 33 l_argStr := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
14591 33 (l_argStr, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_294(l_argStr, i_expLst, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
14592 33 l_argStr := Tpl.popIter(l_argStr);
14593 33 l_funName := CodegenUtil.underscorePath(Tpl.emptyTxt, i_path);
14594 33 txt := Tpl.writeTok(txt, Tpl.ST_STRING("std::"));
14595 33 txt := Tpl.writeText(txt, l_funName);
14596 33 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
14597 33 txt := Tpl.writeText(txt, l_argStr);
14598 33 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14599 33 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14600
14601 case ( txt,
14602 DAE.CALL(path = (i_path as Absyn.IDENT(name = "tan")), expLst = (i_expLst as {_})),
14603 a_context,
14604 a_preExp,
14605 a_varDecls,
14606 a_simCode,
14607 a_extraFuncs,
14608 a_extraFuncsDecl,
14609 a_extraFuncsNamespace,
14610 a_stateDerVectorName,
14611 a_useFlatArrayNotation )
14612 algorithm
14613 2 l_argStr := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
14614 2 (l_argStr, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_295(l_argStr, i_expLst, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
14615 2 l_argStr := Tpl.popIter(l_argStr);
14616 2 l_funName := CodegenUtil.underscorePath(Tpl.emptyTxt, i_path);
14617 2 txt := Tpl.writeTok(txt, Tpl.ST_STRING("std::"));
14618 2 txt := Tpl.writeText(txt, l_funName);
14619 2 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
14620 2 txt := Tpl.writeText(txt, l_argStr);
14621 2 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14622 2 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14623
14624 case ( txt,
14625 DAE.CALL(path = (i_path as Absyn.IDENT(name = "asin")), expLst = (i_expLst as {_})),
14626 a_context,
14627 a_preExp,
14628 a_varDecls,
14629 a_simCode,
14630 a_extraFuncs,
14631 a_extraFuncsDecl,
14632 a_extraFuncsNamespace,
14633 a_stateDerVectorName,
14634 a_useFlatArrayNotation )
14635 algorithm
14636 1 l_argStr := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
14637 1 (l_argStr, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_296(l_argStr, i_expLst, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
14638 1 l_argStr := Tpl.popIter(l_argStr);
14639 1 l_funName := CodegenUtil.underscorePath(Tpl.emptyTxt, i_path);
14640 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("std::"));
14641 1 txt := Tpl.writeText(txt, l_funName);
14642 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
14643 1 txt := Tpl.writeText(txt, l_argStr);
14644 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14645 1 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14646
14647 case ( txt,
14648 DAE.CALL(path = (i_path as Absyn.IDENT(name = "acos")), expLst = (i_expLst as {_})),
14649 a_context,
14650 a_preExp,
14651 a_varDecls,
14652 a_simCode,
14653 a_extraFuncs,
14654 a_extraFuncsDecl,
14655 a_extraFuncsNamespace,
14656 a_stateDerVectorName,
14657 a_useFlatArrayNotation )
14658 algorithm
14659 73 l_argStr := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
14660 73 (l_argStr, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_297(l_argStr, i_expLst, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
14661 73 l_argStr := Tpl.popIter(l_argStr);
14662 73 l_funName := CodegenUtil.underscorePath(Tpl.emptyTxt, i_path);
14663 73 txt := Tpl.writeTok(txt, Tpl.ST_STRING("std::"));
14664 73 txt := Tpl.writeText(txt, l_funName);
14665 73 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
14666 73 txt := Tpl.writeText(txt, l_argStr);
14667 73 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14668 73 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14669
14670 case ( txt,
14671 DAE.CALL(path = (i_path as Absyn.IDENT(name = "atan")), expLst = (i_expLst as {_})),
14672 a_context,
14673 a_preExp,
14674 a_varDecls,
14675 a_simCode,
14676 a_extraFuncs,
14677 a_extraFuncsDecl,
14678 a_extraFuncsNamespace,
14679 a_stateDerVectorName,
14680 a_useFlatArrayNotation )
14681 algorithm
14682 1 l_argStr := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
14683 1 (l_argStr, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_298(l_argStr, i_expLst, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
14684 1 l_argStr := Tpl.popIter(l_argStr);
14685 1 l_funName := CodegenUtil.underscorePath(Tpl.emptyTxt, i_path);
14686 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("std::"));
14687 1 txt := Tpl.writeText(txt, l_funName);
14688 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
14689 1 txt := Tpl.writeText(txt, l_argStr);
14690 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14691 1 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14692
14693 case ( txt,
14694 DAE.CALL(path = (i_path as Absyn.IDENT(name = "sinh")), expLst = (i_expLst as {_})),
14695 a_context,
14696 a_preExp,
14697 a_varDecls,
14698 a_simCode,
14699 a_extraFuncs,
14700 a_extraFuncsDecl,
14701 a_extraFuncsNamespace,
14702 a_stateDerVectorName,
14703 a_useFlatArrayNotation )
14704 algorithm
14705 ✗ l_argStr := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
14706 ✗ (l_argStr, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_299(l_argStr, i_expLst, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
14707 ✗ l_argStr := Tpl.popIter(l_argStr);
14708 ✗ l_funName := CodegenUtil.underscorePath(Tpl.emptyTxt, i_path);
14709 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("std::"));
14710 ✗ txt := Tpl.writeText(txt, l_funName);
14711 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
14712 ✗ txt := Tpl.writeText(txt, l_argStr);
14713 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14714 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14715
14716 case ( txt,
14717 DAE.CALL(path = (i_path as Absyn.IDENT(name = "cosh")), expLst = (i_expLst as {_})),
14718 a_context,
14719 a_preExp,
14720 a_varDecls,
14721 a_simCode,
14722 a_extraFuncs,
14723 a_extraFuncsDecl,
14724 a_extraFuncsNamespace,
14725 a_stateDerVectorName,
14726 a_useFlatArrayNotation )
14727 algorithm
14728 ✗ l_argStr := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
14729 ✗ (l_argStr, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_300(l_argStr, i_expLst, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
14730 ✗ l_argStr := Tpl.popIter(l_argStr);
14731 ✗ l_funName := CodegenUtil.underscorePath(Tpl.emptyTxt, i_path);
14732 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("std::"));
14733 ✗ txt := Tpl.writeText(txt, l_funName);
14734 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
14735 ✗ txt := Tpl.writeText(txt, l_argStr);
14736 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14737 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14738
14739 case ( txt,
14740 DAE.CALL(path = (i_path as Absyn.IDENT(name = "tanh")), expLst = (i_expLst as {_})),
14741 a_context,
14742 a_preExp,
14743 a_varDecls,
14744 a_simCode,
14745 a_extraFuncs,
14746 a_extraFuncsDecl,
14747 a_extraFuncsNamespace,
14748 a_stateDerVectorName,
14749 a_useFlatArrayNotation )
14750 algorithm
14751 1 l_argStr := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
14752 1 (l_argStr, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_301(l_argStr, i_expLst, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
14753 1 l_argStr := Tpl.popIter(l_argStr);
14754 1 l_funName := CodegenUtil.underscorePath(Tpl.emptyTxt, i_path);
14755 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("std::"));
14756 1 txt := Tpl.writeText(txt, l_funName);
14757 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
14758 1 txt := Tpl.writeText(txt, l_argStr);
14759 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14760 1 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14761
14762 case ( txt,
14763 DAE.CALL(path = (i_path as Absyn.IDENT(name = "exp")), expLst = (i_expLst as {_})),
14764 a_context,
14765 a_preExp,
14766 a_varDecls,
14767 a_simCode,
14768 a_extraFuncs,
14769 a_extraFuncsDecl,
14770 a_extraFuncsNamespace,
14771 a_stateDerVectorName,
14772 a_useFlatArrayNotation )
14773 algorithm
14774 9 l_argStr := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
14775 9 (l_argStr, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_302(l_argStr, i_expLst, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
14776 9 l_argStr := Tpl.popIter(l_argStr);
14777 9 l_funName := CodegenUtil.underscorePath(Tpl.emptyTxt, i_path);
14778 9 txt := Tpl.writeTok(txt, Tpl.ST_STRING("std::"));
14779 9 txt := Tpl.writeText(txt, l_funName);
14780 9 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
14781 9 txt := Tpl.writeText(txt, l_argStr);
14782 9 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14783 9 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14784
14785 case ( txt,
14786 DAE.CALL(path = (i_path as Absyn.IDENT(name = "log")), expLst = (i_expLst as {_})),
14787 a_context,
14788 a_preExp,
14789 a_varDecls,
14790 a_simCode,
14791 a_extraFuncs,
14792 a_extraFuncsDecl,
14793 a_extraFuncsNamespace,
14794 a_stateDerVectorName,
14795 a_useFlatArrayNotation )
14796 algorithm
14797 6 l_argStr := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
14798 6 (l_argStr, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_303(l_argStr, i_expLst, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
14799 6 l_argStr := Tpl.popIter(l_argStr);
14800 6 l_funName := CodegenUtil.underscorePath(Tpl.emptyTxt, i_path);
14801 6 txt := Tpl.writeTok(txt, Tpl.ST_STRING("std::"));
14802 6 txt := Tpl.writeText(txt, l_funName);
14803 6 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
14804 6 txt := Tpl.writeText(txt, l_argStr);
14805 6 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14806 6 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14807
14808 case ( txt,
14809 DAE.CALL(path = (i_path as Absyn.IDENT(name = "log10")), expLst = (i_expLst as {_})),
14810 a_context,
14811 a_preExp,
14812 a_varDecls,
14813 a_simCode,
14814 a_extraFuncs,
14815 a_extraFuncsDecl,
14816 a_extraFuncsNamespace,
14817 a_stateDerVectorName,
14818 a_useFlatArrayNotation )
14819 algorithm
14820 11 l_argStr := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
14821 11 (l_argStr, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_304(l_argStr, i_expLst, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
14822 11 l_argStr := Tpl.popIter(l_argStr);
14823 11 l_funName := CodegenUtil.underscorePath(Tpl.emptyTxt, i_path);
14824 11 txt := Tpl.writeTok(txt, Tpl.ST_STRING("std::"));
14825 11 txt := Tpl.writeText(txt, l_funName);
14826 11 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
14827 11 txt := Tpl.writeText(txt, l_argStr);
14828 11 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14829 11 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14830
14831 case ( txt,
14832 DAE.CALL(path = Absyn.IDENT(name = "atan2"), expLst = (i_expLst as {_, _}), attr = DAE.CALL_ATTR(ty = _)),
14833 a_context,
14834 a_preExp,
14835 a_varDecls,
14836 a_simCode,
14837 a_extraFuncs,
14838 a_extraFuncsDecl,
14839 a_extraFuncsNamespace,
14840 a_stateDerVectorName,
14841 a_useFlatArrayNotation )
14842 algorithm
14843 6 l_argStr := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
14844 6 (l_argStr, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_305(l_argStr, i_expLst, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
14845 6 l_argStr := Tpl.popIter(l_argStr);
14846 6 l_retType := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("double"));
14847 6 (l_retVar, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(l_retType), a_varDecls);
14848 6 a_preExp := Tpl.writeText(a_preExp, l_retVar);
14849 6 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(" = std::atan2("));
14850 6 a_preExp := Tpl.writeText(a_preExp, l_argStr);
14851 6 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
14852 6 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
14853 6 txt := Tpl.writeText(txt, l_retVar);
14854 6 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14855
14856 case ( txt,
14857 DAE.CALL(path = Absyn.IDENT(name = "smooth"), expLst = {i_e1, i_e2}, attr = DAE.CALL_ATTR(ty = _)),
14858 a_context,
14859 a_preExp,
14860 a_varDecls,
14861 a_simCode,
14862 a_extraFuncs,
14863 a_extraFuncsDecl,
14864 a_extraFuncsNamespace,
14865 a_stateDerVectorName,
14866 a_useFlatArrayNotation )
14867 algorithm
14868 43 (l_var1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e1, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14869 43 (l_var2, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e2, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14870 43 txt := Tpl.writeText(txt, l_var2);
14871 43 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14872
14873 case ( txt,
14874 DAE.CALL(path = Absyn.IDENT(name = "homotopy"), expLst = {i_e1, i_e2}, attr = DAE.CALL_ATTR(ty = _)),
14875 a_context,
14876 a_preExp,
14877 a_varDecls,
14878 a_simCode,
14879 a_extraFuncs,
14880 a_extraFuncsDecl,
14881 a_extraFuncsNamespace,
14882 a_stateDerVectorName,
14883 a_useFlatArrayNotation )
14884 algorithm
14885 23 (l_var1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e1, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14886 23 (l_var2, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e2, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14887 23 txt := Tpl.writeText(txt, l_var1);
14888 23 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14889
14890 case ( txt,
14891 DAE.CALL(path = Absyn.IDENT(name = "div"), expLst = {i_e1, i_e2}, attr = DAE.CALL_ATTR(ty = DAE.T_INTEGER(varLst = _))),
14892 a_context,
14893 a_preExp,
14894 a_varDecls,
14895 a_simCode,
14896 a_extraFuncs,
14897 a_extraFuncsDecl,
14898 a_extraFuncsNamespace,
14899 a_stateDerVectorName,
14900 a_useFlatArrayNotation )
14901 algorithm
14902 14 (l_var1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e1, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14903 14 (l_var2, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e2, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14904 14 txt := Tpl.writeTok(txt, Tpl.ST_STRING("ldiv("));
14905 14 txt := Tpl.writeText(txt, l_var1);
14906 14 txt := Tpl.writeTok(txt, Tpl.ST_STRING(","));
14907 14 txt := Tpl.writeText(txt, l_var2);
14908 14 txt := Tpl.writeTok(txt, Tpl.ST_STRING(").quot"));
14909 14 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14910
14911 case ( txt,
14912 DAE.CALL(path = Absyn.IDENT(name = "div"), expLst = {i_e1, i_e2}),
14913 a_context,
14914 a_preExp,
14915 a_varDecls,
14916 a_simCode,
14917 a_extraFuncs,
14918 a_extraFuncsDecl,
14919 a_extraFuncsNamespace,
14920 a_stateDerVectorName,
14921 a_useFlatArrayNotation )
14922 algorithm
14923 ✗ (l_var1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e1, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14924 ✗ (l_var2, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e2, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14925 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("omcpp::trunc("));
14926 ✗ txt := Tpl.writeText(txt, l_var1);
14927 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("/"));
14928 ✗ txt := Tpl.writeText(txt, l_var2);
14929 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14930 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14931
14932 case ( txt,
14933 DAE.CALL(path = Absyn.IDENT(name = "div"), expLst = {i_e1, i_e2, _}),
14934 a_context,
14935 a_preExp,
14936 a_varDecls,
14937 a_simCode,
14938 a_extraFuncs,
14939 a_extraFuncsDecl,
14940 a_extraFuncsNamespace,
14941 a_stateDerVectorName,
14942 a_useFlatArrayNotation )
14943 algorithm
14944 ✗ (l_var1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e1, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14945 ✗ (l_var2, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e2, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14946 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("omcpp::trunc("));
14947 ✗ txt := Tpl.writeText(txt, l_var1);
14948 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("/"));
14949 ✗ txt := Tpl.writeText(txt, l_var2);
14950 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14951 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14952
14953 case ( txt,
14954 DAE.CALL(path = Absyn.IDENT(name = "mod"), expLst = {i_e1, i_e2, _}, attr = DAE.CALL_ATTR(ty = i_attr_ty)),
14955 a_context,
14956 a_preExp,
14957 a_varDecls,
14958 a_simCode,
14959 a_extraFuncs,
14960 a_extraFuncsDecl,
14961 a_extraFuncsNamespace,
14962 a_stateDerVectorName,
14963 a_useFlatArrayNotation )
14964 algorithm
14965 ✗ (l_var1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e1, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14966 ✗ (l_var2, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e2, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14967 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_mod_"));
14968 ✗ txt := expTypeShort(txt, i_attr_ty);
14969 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
14970 ✗ txt := Tpl.writeText(txt, l_var1);
14971 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(","));
14972 ✗ txt := Tpl.writeText(txt, l_var2);
14973 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14974 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14975
14976 case ( txt,
14977 DAE.CALL(path = Absyn.IDENT(name = "mod"), expLst = {i_e1, i_e2}, attr = DAE.CALL_ATTR(ty = i_attr_ty)),
14978 a_context,
14979 a_preExp,
14980 a_varDecls,
14981 a_simCode,
14982 a_extraFuncs,
14983 a_extraFuncsDecl,
14984 a_extraFuncsNamespace,
14985 a_stateDerVectorName,
14986 a_useFlatArrayNotation )
14987 algorithm
14988 ✗ (l_var1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e1, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14989 ✗ (l_var2, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e2, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
14990 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_mod_"));
14991 ✗ txt := expTypeShort(txt, i_attr_ty);
14992 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
14993 ✗ txt := Tpl.writeText(txt, l_var1);
14994 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(","));
14995 ✗ txt := Tpl.writeText(txt, l_var2);
14996 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
14997 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
14998
14999 case ( txt,
15000 DAE.CALL(path = Absyn.IDENT(name = "semiLinear"), expLst = {i_e1, i_e2, i_e3}, attr = DAE.CALL_ATTR(ty = _)),
15001 a_context,
15002 a_preExp,
15003 a_varDecls,
15004 a_simCode,
15005 a_extraFuncs,
15006 a_extraFuncsDecl,
15007 a_extraFuncsNamespace,
15008 a_stateDerVectorName,
15009 a_useFlatArrayNotation )
15010 algorithm
15011 96 (l_var1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e1, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15012 96 (l_var2, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e2, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15013 96 (l_var3, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e3, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15014 96 txt := Tpl.writeTok(txt, Tpl.ST_STRING("semiLinear("));
15015 96 txt := Tpl.writeText(txt, l_var1);
15016 96 txt := Tpl.writeTok(txt, Tpl.ST_STRING(","));
15017 96 txt := Tpl.writeText(txt, l_var2);
15018 96 txt := Tpl.writeTok(txt, Tpl.ST_STRING(","));
15019 96 txt := Tpl.writeText(txt, l_var3);
15020 96 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
15021 96 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15022
15023 case ( txt,
15024 DAE.CALL(path = Absyn.IDENT(name = "max"), attr = DAE.CALL_ATTR(ty = i_ty), expLst = {i_array}),
15025 a_context,
15026 a_preExp,
15027 a_varDecls,
15028 a_simCode,
15029 a_extraFuncs,
15030 a_extraFuncsDecl,
15031 a_extraFuncsNamespace,
15032 a_stateDerVectorName,
15033 a_useFlatArrayNotation )
15034 algorithm
15035 5 (l_expVar, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_array, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15036 5 l_arr__tp__str := expTypeShort(Tpl.emptyTxt, i_ty);
15037 5 (l_tvar, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(l_arr__tp__str), a_varDecls);
15038 5 a_preExp := Tpl.writeText(a_preExp, l_tvar);
15039 5 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(" = min_max<"));
15040 5 a_preExp := Tpl.writeText(a_preExp, l_arr__tp__str);
15041 5 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(">("));
15042 5 a_preExp := Tpl.writeText(a_preExp, l_expVar);
15043 5 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(").second;"));
15044 5 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
15045 5 txt := Tpl.writeText(txt, l_tvar);
15046 5 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15047
15048 case ( txt,
15049 DAE.CALL(path = Absyn.IDENT(name = "min"), attr = DAE.CALL_ATTR(ty = i_ty), expLst = {i_array}),
15050 a_context,
15051 a_preExp,
15052 a_varDecls,
15053 a_simCode,
15054 a_extraFuncs,
15055 a_extraFuncsDecl,
15056 a_extraFuncsNamespace,
15057 a_stateDerVectorName,
15058 a_useFlatArrayNotation )
15059 algorithm
15060 1 (l_expVar, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_array, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15061 1 l_arr__tp__str := expTypeShort(Tpl.emptyTxt, i_ty);
15062 1 (l_tvar, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(l_arr__tp__str), a_varDecls);
15063 1 a_preExp := Tpl.writeText(a_preExp, l_tvar);
15064 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(" = min_max<"));
15065 1 a_preExp := Tpl.writeText(a_preExp, l_arr__tp__str);
15066 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(">("));
15067 1 a_preExp := Tpl.writeText(a_preExp, l_expVar);
15068 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(").first;"));
15069 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
15070 1 txt := Tpl.writeText(txt, l_tvar);
15071 1 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15072
15073 case ( txt,
15074 DAE.CALL(path = Absyn.IDENT(name = "sum"), attr = DAE.CALL_ATTR(ty = i_ty), expLst = {i_array}),
15075 a_context,
15076 a_preExp,
15077 a_varDecls,
15078 a_simCode,
15079 a_extraFuncs,
15080 a_extraFuncsDecl,
15081 a_extraFuncsNamespace,
15082 a_stateDerVectorName,
15083 a_useFlatArrayNotation )
15084 algorithm
15085 55 (l_expVar, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_array, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15086 55 l_arr__tp__str := expTypeShort(Tpl.emptyTxt, i_ty);
15087 55 txt := Tpl.writeTok(txt, Tpl.ST_STRING("sum_array<"));
15088 55 txt := Tpl.writeText(txt, l_arr__tp__str);
15089 55 txt := Tpl.writeTok(txt, Tpl.ST_STRING(">("));
15090 55 txt := Tpl.writeText(txt, l_expVar);
15091 55 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
15092 55 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15093
15094 case ( txt,
15095 DAE.CALL(path = Absyn.IDENT(name = "product"), attr = DAE.CALL_ATTR(ty = i_ty), expLst = {i_array}),
15096 a_context,
15097 a_preExp,
15098 a_varDecls,
15099 a_simCode,
15100 a_extraFuncs,
15101 a_extraFuncsDecl,
15102 a_extraFuncsNamespace,
15103 a_stateDerVectorName,
15104 a_useFlatArrayNotation )
15105 algorithm
15106 1 (l_expVar, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_array, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15107 1 l_arr__tp__str := expTypeShort(Tpl.emptyTxt, i_ty);
15108 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING("product_array<"));
15109 1 txt := Tpl.writeText(txt, l_arr__tp__str);
15110 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING(">("));
15111 1 txt := Tpl.writeText(txt, l_expVar);
15112 1 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
15113 1 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15114
15115 case ( txt,
15116 DAE.CALL(path = Absyn.IDENT(name = "vector"), expLst = {i_exp}, attr = DAE.CALL_ATTR(ty = i_ty)),
15117 a_context,
15118 a_preExp,
15119 a_varDecls,
15120 a_simCode,
15121 a_extraFuncs,
15122 a_extraFuncsDecl,
15123 a_extraFuncsNamespace,
15124 a_stateDerVectorName,
15125 a_useFlatArrayNotation )
15126 algorithm
15127 ✗ (l_expVar, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15128 ✗ l_tvar := fun_306(Tpl.emptyTxt, i_ty, l_expVar);
15129 ✗ txt := Tpl.writeText(txt, l_tvar);
15130 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15131
15132 case ( txt,
15133 DAE.CALL(path = Absyn.IDENT(name = "fill"), expLst = i_val :: i_dims_1, attr = DAE.CALL_ATTR(ty = i_attr_ty)),
15134 a_context,
15135 a_preExp,
15136 a_varDecls,
15137 a_simCode,
15138 a_extraFuncs,
15139 a_extraFuncsDecl,
15140 a_extraFuncsNamespace,
15141 a_stateDerVectorName,
15142 a_useFlatArrayNotation )
15143 algorithm
15144 3 (l_valExp, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_val, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15145 3 l_dimsExp := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(",")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
15146 3 (l_dimsExp, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_307(l_dimsExp, i_dims_1, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
15147 3 l_dimsExp := Tpl.popIter(l_dimsExp);
15148 3 l_ty__str := expTypeShort(Tpl.emptyTxt, i_attr_ty);
15149 3 l_tmp__type__str := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("DynArrayDim"));
15150 3 ret_35 := listLength(i_dims_1);
15151 3 l_tmp__type__str := Tpl.writeStr(l_tmp__type__str, intString(ret_35));
15152 3 l_tmp__type__str := Tpl.writeTok(l_tmp__type__str, Tpl.ST_STRING("<"));
15153 3 l_tmp__type__str := Tpl.writeText(l_tmp__type__str, l_ty__str);
15154 3 l_tmp__type__str := Tpl.writeTok(l_tmp__type__str, Tpl.ST_STRING(">"));
15155 3 (l_tvar, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(l_tmp__type__str), a_varDecls);
15156 3 a_preExp := Tpl.writeText(a_preExp, l_tvar);
15157 3 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(".setDims("));
15158 3 a_preExp := Tpl.writeText(a_preExp, l_dimsExp);
15159 3 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
15160 3 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
15161 3 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("fill_array<"));
15162 3 a_preExp := Tpl.writeText(a_preExp, l_ty__str);
15163 3 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(">("));
15164 3 a_preExp := Tpl.writeText(a_preExp, l_tvar);
15165 3 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
15166 3 a_preExp := Tpl.writeText(a_preExp, l_valExp);
15167 3 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
15168 3 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
15169 3 txt := Tpl.writeText(txt, l_tvar);
15170 3 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15171
15172 case ( txt,
15173 DAE.CALL(path = Absyn.IDENT(name = "cat"), expLst = i_dim :: i_a0 :: i_arrays, attr = DAE.CALL_ATTR(ty = i_attr_ty)),
15174 a_context,
15175 a_preExp,
15176 a_varDecls,
15177 a_simCode,
15178 a_extraFuncs,
15179 a_extraFuncsDecl,
15180 a_extraFuncsNamespace,
15181 a_stateDerVectorName,
15182 a_useFlatArrayNotation )
15183 algorithm
15184 4 (l_dim__exp, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_dim, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15185 4 l_dimstr := Tpl.emptyTxt;
15186 4 ret_38 := Expression.typeof(i_a0);
15187 4 (l_tmp__type__str, l_dimstr) := fun_308(Tpl.emptyTxt, ret_38, l_dimstr);
15188 4 l_ty__str := expTypeShort(Tpl.emptyTxt, i_attr_ty);
15189 4 (l_tvar, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(l_tmp__type__str), a_varDecls);
15190 4 (l_a0str, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_a0, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15191 4 l_arrays__exp := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
15192 4 (l_arrays__exp, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_309(l_arrays__exp, i_arrays, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context, l_tvar);
15193 4 l_arrays__exp := Tpl.popIter(l_arrays__exp);
15194 4 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("vector<const BaseArray<"));
15195 4 a_preExp := Tpl.writeText(a_preExp, l_ty__str);
15196 4 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(">*> "));
15197 4 a_preExp := Tpl.writeText(a_preExp, l_tvar);
15198 4 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_LINE("_list;\n"));
15199 4 a_preExp := Tpl.writeText(a_preExp, l_tvar);
15200 4 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("_list.push_back(&"));
15201 4 a_preExp := Tpl.writeText(a_preExp, l_a0str);
15202 4 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_LINE(");\n"));
15203 4 a_preExp := Tpl.writeText(a_preExp, l_arrays__exp);
15204 4 a_preExp := Tpl.softNewLine(a_preExp);
15205 4 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("cat_array<"));
15206 4 a_preExp := Tpl.writeText(a_preExp, l_ty__str);
15207 4 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(">("));
15208 4 a_preExp := Tpl.writeText(a_preExp, l_dim__exp);
15209 4 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
15210 4 a_preExp := Tpl.writeText(a_preExp, l_tvar);
15211 4 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("_list, "));
15212 4 a_preExp := Tpl.writeText(a_preExp, l_tvar);
15213 4 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
15214 4 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
15215 4 txt := Tpl.writeText(txt, l_tvar);
15216 4 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15217
15218 case ( txt,
15219 DAE.CALL(path = Absyn.IDENT(name = "promote"), expLst = {i_A, i_n}, attr = DAE.CALL_ATTR(ty = i_ty)),
15220 a_context,
15221 a_preExp,
15222 a_varDecls,
15223 a_simCode,
15224 a_extraFuncs,
15225 a_extraFuncsDecl,
15226 a_extraFuncsNamespace,
15227 a_stateDerVectorName,
15228 a_useFlatArrayNotation )
15229 algorithm
15230 ✗ (l_var1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_A, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15231 ✗ (l_var2, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_n, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15232 ✗ l_arrayType := expTypeArrayIf(Tpl.emptyTxt, i_ty);
15233 ✗ (l_tmp, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(l_arrayType), a_varDecls);
15234 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("promote_array("));
15235 ✗ a_preExp := Tpl.writeText(a_preExp, l_var2);
15236 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
15237 ✗ a_preExp := Tpl.writeText(a_preExp, l_var1);
15238 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
15239 ✗ a_preExp := Tpl.writeText(a_preExp, l_tmp);
15240 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
15241 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
15242 ✗ txt := Tpl.writeText(txt, l_tmp);
15243 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
15244 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15245
15246 case ( txt,
15247 DAE.CALL(path = Absyn.IDENT(name = "transpose"), expLst = {i_A}),
15248 a_context,
15249 a_preExp,
15250 a_varDecls,
15251 a_simCode,
15252 a_extraFuncs,
15253 a_extraFuncsDecl,
15254 a_extraFuncsNamespace,
15255 a_stateDerVectorName,
15256 a_useFlatArrayNotation )
15257 algorithm
15258 ✗ (l_var1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_A, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15259 ✗ l_type__str := expTypeFromExpShort(Tpl.emptyTxt, i_A);
15260 ✗ l_arr__tp__str := expTypeFromExpArray(Tpl.emptyTxt, i_A);
15261 ✗ (l_tvar, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(l_arr__tp__str), a_varDecls);
15262 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("transpose_array<"));
15263 ✗ a_preExp := Tpl.writeText(a_preExp, l_type__str);
15264 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(">("));
15265 ✗ a_preExp := Tpl.writeText(a_preExp, l_var1);
15266 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
15267 ✗ a_preExp := Tpl.writeText(a_preExp, l_tvar);
15268 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
15269 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
15270 ✗ txt := Tpl.writeText(txt, l_tvar);
15271 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15272
15273 case ( txt,
15274 DAE.CALL(path = Absyn.IDENT(name = "cross"), expLst = {i_v1, i_v2}, attr = DAE.CALL_ATTR(ty = (i_ty as DAE.T_ARRAY(dims = i_dims)))),
15275 a_context,
15276 a_preExp,
15277 a_varDecls,
15278 a_simCode,
15279 a_extraFuncs,
15280 a_extraFuncsDecl,
15281 a_extraFuncsNamespace,
15282 a_stateDerVectorName,
15283 a_useFlatArrayNotation )
15284 algorithm
15285 ✗ (l_var1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_v1, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15286 ✗ (l_var2, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_v2, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15287 ✗ l_type := fun_310(Tpl.emptyTxt, i_ty);
15288 ✗ txt_44 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("multi_array<"));
15289 ✗ txt_44 := Tpl.writeText(txt_44, l_type);
15290 ✗ txt_44 := Tpl.writeTok(txt_44, Tpl.ST_STRING(","));
15291 ✗ ret_44 := listLength(i_dims);
15292 ✗ txt_44 := Tpl.writeStr(txt_44, intString(ret_44));
15293 ✗ txt_44 := Tpl.writeTok(txt_44, Tpl.ST_STRING(">"));
15294 ✗ (l_tvar, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(txt_44), a_varDecls);
15295 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("assign_array("));
15296 ✗ a_preExp := Tpl.writeText(a_preExp, l_tvar);
15297 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(",cross_array<"));
15298 ✗ a_preExp := Tpl.writeText(a_preExp, l_type);
15299 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(">("));
15300 ✗ a_preExp := Tpl.writeText(a_preExp, l_var1);
15301 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(","));
15302 ✗ a_preExp := Tpl.writeText(a_preExp, l_var2);
15303 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("));"));
15304 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
15305 ✗ txt := Tpl.writeText(txt, l_tvar);
15306 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15307
15308 case ( txt,
15309 DAE.CALL(path = Absyn.IDENT(name = "identity"), expLst = {i_A}),
15310 a_context,
15311 a_preExp,
15312 a_varDecls,
15313 a_simCode,
15314 a_extraFuncs,
15315 a_extraFuncsDecl,
15316 a_extraFuncsNamespace,
15317 a_stateDerVectorName,
15318 a_useFlatArrayNotation )
15319 algorithm
15320 ✗ (l_var1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_A, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15321 ✗ (l_tvar, a_varDecls) := tempDecl(Tpl.emptyTxt, "DynArrayDim2<int>", a_varDecls);
15322 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("identity_alloc("));
15323 ✗ a_preExp := Tpl.writeText(a_preExp, l_var1);
15324 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
15325 ✗ a_preExp := Tpl.writeText(a_preExp, l_tvar);
15326 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
15327 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
15328 ✗ txt := Tpl.writeText(txt, l_tvar);
15329 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15330
15331 case ( txt,
15332 DAE.CALL(path = Absyn.IDENT(name = "diagonal"), expLst = {i_v}, attr = DAE.CALL_ATTR(ty = DAE.T_ARRAY(ty = i_elty))),
15333 a_context,
15334 a_preExp,
15335 a_varDecls,
15336 a_simCode,
15337 a_extraFuncs,
15338 a_extraFuncsDecl,
15339 a_extraFuncsNamespace,
15340 a_stateDerVectorName,
15341 a_useFlatArrayNotation )
15342 algorithm
15343 ✗ (l_var1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_v, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15344 ✗ txt_46 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("DynArrayDim2<"));
15345 ✗ txt_46 := expTypeShort(txt_46, i_elty);
15346 ✗ txt_46 := Tpl.writeTok(txt_46, Tpl.ST_STRING(">"));
15347 ✗ (l_tvar, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(txt_46), a_varDecls);
15348 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("diagonal_alloc("));
15349 ✗ a_preExp := Tpl.writeText(a_preExp, l_var1);
15350 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
15351 ✗ a_preExp := Tpl.writeText(a_preExp, l_tvar);
15352 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
15353 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
15354 ✗ txt := Tpl.writeText(txt, l_tvar);
15355 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15356
15357 case ( txt,
15358 DAE.CALL(path = Absyn.IDENT(name = "rem"), expLst = {i_e1, i_e2}),
15359 a_context,
15360 a_preExp,
15361 a_varDecls,
15362 a_simCode,
15363 a_extraFuncs,
15364 a_extraFuncsDecl,
15365 a_extraFuncsNamespace,
15366 a_stateDerVectorName,
15367 a_useFlatArrayNotation )
15368 algorithm
15369 ✗ (l_var1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e1, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15370 ✗ (l_var2, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e2, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15371 ✗ l_typeStr := expTypeFromExpShort(Tpl.emptyTxt, i_e1);
15372 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_rem_"));
15373 ✗ txt := Tpl.writeText(txt, l_typeStr);
15374 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
15375 ✗ txt := Tpl.writeText(txt, l_var1);
15376 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(","));
15377 ✗ txt := Tpl.writeText(txt, l_var2);
15378 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
15379 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15380
15381 case ( txt,
15382 DAE.CALL(path = Absyn.IDENT(name = "String"), expLst = {i_s, i_format}),
15383 a_context,
15384 a_preExp,
15385 a_varDecls,
15386 a_simCode,
15387 a_extraFuncs,
15388 a_extraFuncsDecl,
15389 a_extraFuncsNamespace,
15390 a_stateDerVectorName,
15391 a_useFlatArrayNotation )
15392 algorithm
15393 l_emptybuf := Tpl.emptyTxt;
15394 915 (l_tvar, a_varDecls) := tempDecl(Tpl.emptyTxt, "string", a_varDecls);
15395 915 (l_sExp, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_s, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15396 915 (l_formatExp, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_format, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15397 915 l_typeStr := expTypeFromExpModelica(Tpl.emptyTxt, i_s);
15398 915 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("string "));
15399 915 a_preExp := Tpl.writeText(a_preExp, l_tvar);
15400 915 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(" = omcpp::to_string("));
15401 915 a_preExp := Tpl.writeText(a_preExp, l_sExp);
15402 915 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
15403 915 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
15404 915 txt := Tpl.writeText(txt, l_tvar);
15405 915 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15406
15407 case ( txt,
15408 DAE.CALL(path = Absyn.IDENT(name = "String"), expLst = {i_s, i_minlen, i_leftjust}),
15409 a_context,
15410 a_preExp,
15411 a_varDecls,
15412 a_simCode,
15413 a_extraFuncs,
15414 a_extraFuncsDecl,
15415 a_extraFuncsNamespace,
15416 a_stateDerVectorName,
15417 a_useFlatArrayNotation )
15418 algorithm
15419 12 l_emptybuf := Tpl.emptyTxt;
15420 12 (l_tvar, l_emptybuf) := tempDecl(Tpl.emptyTxt, "string", l_emptybuf);
15421 12 (l_sExp, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_s, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15422 12 (l_minlenExp, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_minlen, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15423 12 (l_leftjustExp, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_leftjust, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15424 12 l_typeStr := expTypeFromExpModelica(Tpl.emptyTxt, i_s);
15425 12 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("string "));
15426 12 a_preExp := Tpl.writeText(a_preExp, l_tvar);
15427 12 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(" = omcpp::to_string("));
15428 12 a_preExp := Tpl.writeText(a_preExp, l_sExp);
15429 12 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
15430 12 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
15431 12 txt := Tpl.writeText(txt, l_tvar);
15432 12 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15433
15434 case ( txt,
15435 DAE.CALL(path = Absyn.IDENT(name = "String"), expLst = {i_s, i_minlen, i_leftjust, i_signdig}),
15436 a_context,
15437 a_preExp,
15438 a_varDecls,
15439 a_simCode,
15440 a_extraFuncs,
15441 a_extraFuncsDecl,
15442 a_extraFuncsNamespace,
15443 a_stateDerVectorName,
15444 a_useFlatArrayNotation )
15445 algorithm
15446 214 l_emptybuf := Tpl.emptyTxt;
15447 214 (l_tvar, l_emptybuf) := tempDecl(Tpl.emptyTxt, "string", l_emptybuf);
15448 214 (l_sExp, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_s, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15449 214 (l_minlenExp, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_minlen, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15450 214 (l_leftjustExp, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_leftjust, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15451 214 (l_signdigExp, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_signdig, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15452 214 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("string "));
15453 214 a_preExp := Tpl.writeText(a_preExp, l_tvar);
15454 214 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(" = omcpp::to_string("));
15455 214 a_preExp := Tpl.writeText(a_preExp, l_sExp);
15456 214 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
15457 214 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
15458 214 txt := Tpl.writeText(txt, l_tvar);
15459 214 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15460
15461 case ( txt,
15462 DAE.CALL(path = Absyn.IDENT(name = "delay"), expLst = {DAE.ICONST(integer = i_index), i_e, i_d, i_delayMax}),
15463 a_context,
15464 a_preExp,
15465 a_varDecls,
15466 a_simCode,
15467 a_extraFuncs,
15468 a_extraFuncsDecl,
15469 a_extraFuncsNamespace,
15470 a_stateDerVectorName,
15471 a_useFlatArrayNotation )
15472 algorithm
15473 8 (l_tvar, a_varDecls) := tempDecl(Tpl.emptyTxt, "double", a_varDecls);
15474 8 (l_var1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15475 8 (l_var2, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_d, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15476 8 (l_var3, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_delayMax, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15477 8 a_preExp := Tpl.writeText(a_preExp, l_tvar);
15478 8 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(" = delay("));
15479 8 a_preExp := Tpl.writeStr(a_preExp, intString(i_index));
15480 8 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
15481 8 a_preExp := Tpl.writeText(a_preExp, l_var1);
15482 8 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
15483 8 a_preExp := Tpl.writeText(a_preExp, l_var2);
15484 8 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
15485 8 a_preExp := Tpl.writeText(a_preExp, l_var3);
15486 8 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
15487 8 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
15488 8 txt := Tpl.writeText(txt, l_tvar);
15489 8 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15490
15491 case ( txt,
15492 DAE.CALL(path = Absyn.IDENT(name = "integer"), expLst = {i_toBeCasted}),
15493 a_context,
15494 a_preExp,
15495 a_varDecls,
15496 a_simCode,
15497 a_extraFuncs,
15498 a_extraFuncsDecl,
15499 a_extraFuncsNamespace,
15500 a_stateDerVectorName,
15501 a_useFlatArrayNotation )
15502 algorithm
15503 ✗ (l_castedVar, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_toBeCasted, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15504 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("((int)"));
15505 ✗ txt := Tpl.writeText(txt, l_castedVar);
15506 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
15507 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15508
15509 case ( txt,
15510 DAE.CALL(path = Absyn.IDENT(name = "Integer"), expLst = {i_toBeCasted}),
15511 a_context,
15512 a_preExp,
15513 a_varDecls,
15514 a_simCode,
15515 a_extraFuncs,
15516 a_extraFuncsDecl,
15517 a_extraFuncsNamespace,
15518 a_stateDerVectorName,
15519 a_useFlatArrayNotation )
15520 algorithm
15521 16 (l_castedVar, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_toBeCasted, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15522 16 txt := Tpl.writeTok(txt, Tpl.ST_STRING("((int)"));
15523 16 txt := Tpl.writeText(txt, l_castedVar);
15524 16 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
15525 16 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15526
15527 case ( txt,
15528 DAE.CALL(path = Absyn.IDENT(name = "clock"), expLst = {}),
15529 _,
15530 a_preExp,
15531 a_varDecls,
15532 _,
15533 a_extraFuncs,
15534 a_extraFuncsDecl,
15535 a_extraFuncsNamespace,
15536 a_stateDerVectorName,
15537 _ )
15538 algorithm
15539 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("mmc_clock()"));
15540 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15541
15542 case ( txt,
15543 DAE.CALL(path = Absyn.IDENT(name = "noEvent"), expLst = {i_e1}),
15544 a_context,
15545 a_preExp,
15546 a_varDecls,
15547 a_simCode,
15548 a_extraFuncs,
15549 a_extraFuncsDecl,
15550 a_extraFuncsNamespace,
15551 a_stateDerVectorName,
15552 a_useFlatArrayNotation )
15553 algorithm
15554 315 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_e1, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15555 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15556
15557 case ( txt,
15558 DAE.CALL(path = Absyn.IDENT(name = "anyString"), expLst = {i_e1}),
15559 a_context,
15560 a_preExp,
15561 a_varDecls,
15562 a_simCode,
15563 a_extraFuncs,
15564 a_extraFuncsDecl,
15565 a_extraFuncsNamespace,
15566 a_stateDerVectorName,
15567 a_useFlatArrayNotation )
15568 algorithm
15569 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("mmc_anyString("));
15570 ✗ (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_e1, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15571 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
15572 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15573
15574 case ( txt,
15575 DAE.CALL(path = Absyn.IDENT(name = "mmc_get_field"), expLst = {i_s1, DAE.ICONST(integer = i_i)}),
15576 a_context,
15577 a_preExp,
15578 a_varDecls,
15579 a_simCode,
15580 a_extraFuncs,
15581 a_extraFuncsDecl,
15582 a_extraFuncsNamespace,
15583 a_stateDerVectorName,
15584 a_useFlatArrayNotation )
15585 algorithm
15586 ✗ (l_tvar, a_varDecls) := tempDecl(Tpl.emptyTxt, "modelica_metatype", a_varDecls);
15587 ✗ (l_expPart, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_s1, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15588 ✗ a_preExp := Tpl.writeText(a_preExp, l_tvar);
15589 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(" = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR("));
15590 ✗ a_preExp := Tpl.writeText(a_preExp, l_expPart);
15591 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("), "));
15592 ✗ a_preExp := Tpl.writeStr(a_preExp, intString(i_i));
15593 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("));"));
15594 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
15595 ✗ txt := Tpl.writeText(txt, l_tvar);
15596 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15597
15598 case ( txt,
15599 DAE.CALL(attr = DAE.CALL_ATTR(ty = DAE.T_NORETCALL()), expLst = i_expLst, path = i_path),
15600 a_context,
15601 a_preExp,
15602 a_varDecls,
15603 a_simCode,
15604 a_extraFuncs,
15605 a_extraFuncsDecl,
15606 a_extraFuncsNamespace,
15607 a_stateDerVectorName,
15608 a_useFlatArrayNotation )
15609 algorithm
15610 31 l_argStr := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
15611 31 (l_argStr, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_311(l_argStr, i_expLst, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
15612 31 l_argStr := Tpl.popIter(l_argStr);
15613 31 l_funName := CodegenUtil.underscorePath(Tpl.emptyTxt, i_path);
15614 31 a_preExp := contextFunName(a_preExp, Tpl.textString(l_funName), a_context);
15615 31 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("("));
15616 31 a_preExp := Tpl.writeText(a_preExp, l_argStr);
15617 31 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
15618 31 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
15619 31 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15620
15621 case ( txt,
15622 DAE.CALL(attr = DAE.CALL_ATTR(ty = DAE.T_ARRAY(ty = _, dims = _)), expLst = i_expLst, path = i_path),
15623 a_context,
15624 a_preExp,
15625 a_varDecls,
15626 a_simCode,
15627 a_extraFuncs,
15628 a_extraFuncsDecl,
15629 a_extraFuncsNamespace,
15630 a_stateDerVectorName,
15631 a_useFlatArrayNotation )
15632 algorithm
15633 46 l_argStr := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(",")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
15634 46 (l_argStr, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_312(l_argStr, i_expLst, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
15635 46 l_argStr := Tpl.popIter(l_argStr);
15636 46 l_funName := CodegenUtil.underscorePath(Tpl.emptyTxt, i_path);
15637 46 l_retType := Tpl.writeText(Tpl.emptyTxt, l_funName);
15638 46 l_retType := Tpl.writeTok(l_retType, Tpl.ST_STRING("RetType"));
15639 46 (l_retVar, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(l_retType), a_varDecls);
15640 46 a_preExp := contextFunName(a_preExp, Tpl.textString(l_funName), a_context);
15641 46 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("("));
15642 46 a_preExp := Tpl.writeText(a_preExp, l_argStr);
15643 46 a_preExp := fun_314(a_preExp, i_expLst, l_retVar);
15644 46 a_preExp := Tpl.writeText(a_preExp, l_retVar);
15645 46 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
15646 46 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
15647 46 txt := Tpl.writeText(txt, l_retVar);
15648 46 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15649
15650 case ( txt,
15651 DAE.CALL(expLst = i_explist, attr = DAE.CALL_ATTR(ty = _), path = i_path),
15652 a_context,
15653 a_preExp,
15654 a_varDecls,
15655 a_simCode,
15656 a_extraFuncs,
15657 a_extraFuncsDecl,
15658 a_extraFuncsNamespace,
15659 a_stateDerVectorName,
15660 a_useFlatArrayNotation )
15661 algorithm
15662 1362 l_funName := CodegenUtil.underscorePath(Tpl.emptyTxt, i_path);
15663 1362 str_56 := Tpl.textString(l_funName);
15664 1362 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := fun_323(txt, str_56, l_funName, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context, i_explist);
15665 1362 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15666
15667 case ( txt,
15668 i_call,
15669 _,
15670 a_preExp,
15671 a_varDecls,
15672 _,
15673 a_extraFuncs,
15674 a_extraFuncsDecl,
15675 a_extraFuncsNamespace,
15676 a_stateDerVectorName,
15677 _ )
15678 algorithm
15679 ✗ txt_57 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("Code generation does not support daeExpCall("));
15680 ✗ txt_57 := ExpressionDumpTpl.dumpExp(txt_57, i_call, "\"");
15681 ✗ txt_57 := Tpl.writeTok(txt_57, Tpl.ST_STRING(")"));
15682 ✗ txt := error(txt, Tpl.sourceInfo("CodegenCppCommon.tpl", 2231, 11), Tpl.textString(txt_57));
15683 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15684 end match;
15685 end daeExpCall;
15686
15687 protected function fun_325
15688 input Tpl.Text in_txt;
15689 input DAE.Operator in_a_operator;
15690 input Tpl.Text in_a_e;
15691
15692 output Tpl.Text out_txt;
15693 algorithm
15694 out_txt :=
15695 match(in_txt, in_a_operator, in_a_e)
15696 local
15697 Tpl.Text txt;
15698 Tpl.Text a_e;
15699
15700 case ( txt,
15701 DAE.NOT(ty = _),
15702 a_e )
15703 algorithm
15704 570 txt := Tpl.writeTok(txt, Tpl.ST_STRING("(!"));
15705 570 txt := Tpl.writeText(txt, a_e);
15706 570 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
15707 then txt;
15708
15709 case ( txt,
15710 _,
15711 _ )
15712 then txt;
15713 end match;
15714 end fun_325;
15715
15716 public function daeExpLunary
15717 input Tpl.Text in_txt;
15718 input DAE.Exp in_a_exp;
15719 input SimCodeFunction.Context in_a_context;
15720 input Tpl.Text in_a_preExp;
15721 input Tpl.Text in_a_varDecls;
15722 input SimCode.SimCode in_a_simCode;
15723 input Tpl.Text in_a_extraFuncs;
15724 input Tpl.Text in_a_extraFuncsDecl;
15725 input Tpl.Text in_a_extraFuncsNamespace;
15726 input Tpl.Text in_a_stateDerVectorName;
15727 input Boolean in_a_useFlatArrayNotation;
15728
15729 output Tpl.Text out_txt;
15730 output Tpl.Text out_a_preExp;
15731 output Tpl.Text out_a_varDecls;
15732 output Tpl.Text out_a_extraFuncs;
15733 output Tpl.Text out_a_extraFuncsDecl;
15734 output Tpl.Text out_a_extraFuncsNamespace;
15735 output Tpl.Text out_a_stateDerVectorName;
15736 algorithm
15737 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
15738 match(in_txt, in_a_exp, in_a_context, in_a_preExp, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
15739 local
15740 Tpl.Text txt;
15741 SimCodeFunction.Context a_context;
15742 Tpl.Text a_preExp;
15743 Tpl.Text a_varDecls;
15744 SimCode.SimCode a_simCode;
15745 Tpl.Text a_extraFuncs;
15746 Tpl.Text a_extraFuncsDecl;
15747 Tpl.Text a_extraFuncsNamespace;
15748 Tpl.Text a_stateDerVectorName;
15749 Boolean a_useFlatArrayNotation;
15750 DAE.Operator i_operator;
15751 DAE.Exp i_exp;
15752 Tpl.Text l_e;
15753
15754 case ( txt,
15755 DAE.LUNARY(exp = i_exp, operator = i_operator),
15756 a_context,
15757 a_preExp,
15758 a_varDecls,
15759 a_simCode,
15760 a_extraFuncs,
15761 a_extraFuncsDecl,
15762 a_extraFuncsNamespace,
15763 a_stateDerVectorName,
15764 a_useFlatArrayNotation )
15765 algorithm
15766 570 (l_e, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15767 570 txt := fun_325(txt, i_operator, l_e);
15768 570 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15769
15770 case ( txt,
15771 _,
15772 _,
15773 a_preExp,
15774 a_varDecls,
15775 _,
15776 a_extraFuncs,
15777 a_extraFuncsDecl,
15778 a_extraFuncsNamespace,
15779 a_stateDerVectorName,
15780 _ )
15781 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15782 end match;
15783 end daeExpLunary;
15784
15785 protected function fun_327
15786 input Tpl.Text in_txt;
15787 input DAE.Operator in_a_operator;
15788 input Tpl.Text in_a_e2;
15789 input Tpl.Text in_a_e1;
15790
15791 output Tpl.Text out_txt;
15792 algorithm
15793 out_txt :=
15794 match(in_txt, in_a_operator, in_a_e2, in_a_e1)
15795 local
15796 Tpl.Text txt;
15797 Tpl.Text a_e2;
15798 Tpl.Text a_e1;
15799
15800 case ( txt,
15801 DAE.AND(ty = _),
15802 a_e2,
15803 a_e1 )
15804 algorithm
15805 484 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
15806 484 txt := Tpl.writeText(txt, a_e1);
15807 484 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" && "));
15808 484 txt := Tpl.writeText(txt, a_e2);
15809 484 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
15810 then txt;
15811
15812 case ( txt,
15813 DAE.OR(ty = _),
15814 a_e2,
15815 a_e1 )
15816 algorithm
15817 69 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
15818 69 txt := Tpl.writeText(txt, a_e1);
15819 69 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" || "));
15820 69 txt := Tpl.writeText(txt, a_e2);
15821 69 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
15822 then txt;
15823
15824 case ( txt,
15825 _,
15826 _,
15827 _ )
15828 algorithm
15829 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("daeExpLbinary:ERR"));
15830 then txt;
15831 end match;
15832 end fun_327;
15833
15834 public function daeExpLbinary
15835 input Tpl.Text in_txt;
15836 input DAE.Exp in_a_exp;
15837 input SimCodeFunction.Context in_a_context;
15838 input Tpl.Text in_a_preExp;
15839 input Tpl.Text in_a_varDecls;
15840 input SimCode.SimCode in_a_simCode;
15841 input Tpl.Text in_a_extraFuncs;
15842 input Tpl.Text in_a_extraFuncsDecl;
15843 input Tpl.Text in_a_extraFuncsNamespace;
15844 input Tpl.Text in_a_stateDerVectorName;
15845 input Boolean in_a_useFlatArrayNotation;
15846
15847 output Tpl.Text out_txt;
15848 output Tpl.Text out_a_preExp;
15849 output Tpl.Text out_a_varDecls;
15850 output Tpl.Text out_a_extraFuncs;
15851 output Tpl.Text out_a_extraFuncsDecl;
15852 output Tpl.Text out_a_extraFuncsNamespace;
15853 output Tpl.Text out_a_stateDerVectorName;
15854 algorithm
15855 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
15856 match(in_txt, in_a_exp, in_a_context, in_a_preExp, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
15857 local
15858 Tpl.Text txt;
15859 SimCodeFunction.Context a_context;
15860 Tpl.Text a_preExp;
15861 Tpl.Text a_varDecls;
15862 SimCode.SimCode a_simCode;
15863 Tpl.Text a_extraFuncs;
15864 Tpl.Text a_extraFuncsDecl;
15865 Tpl.Text a_extraFuncsNamespace;
15866 Tpl.Text a_stateDerVectorName;
15867 Boolean a_useFlatArrayNotation;
15868 DAE.Operator i_operator;
15869 DAE.Exp i_exp2;
15870 DAE.Exp i_exp1;
15871 Tpl.Text l_e2;
15872 Tpl.Text l_e1;
15873
15874 case ( txt,
15875 DAE.LBINARY(exp1 = i_exp1, exp2 = i_exp2, operator = i_operator),
15876 a_context,
15877 a_preExp,
15878 a_varDecls,
15879 a_simCode,
15880 a_extraFuncs,
15881 a_extraFuncsDecl,
15882 a_extraFuncsNamespace,
15883 a_stateDerVectorName,
15884 a_useFlatArrayNotation )
15885 algorithm
15886 553 (l_e1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_exp1, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15887 553 (l_e2, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_exp2, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
15888 553 txt := fun_327(txt, i_operator, l_e2, l_e1);
15889 553 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15890
15891 case ( txt,
15892 _,
15893 _,
15894 a_preExp,
15895 a_varDecls,
15896 _,
15897 a_extraFuncs,
15898 a_extraFuncsDecl,
15899 a_extraFuncsNamespace,
15900 a_stateDerVectorName,
15901 _ )
15902 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
15903 end match;
15904 end daeExpLbinary;
15905
15906 protected function fun_329
15907 input Tpl.Text in_txt;
15908 input Integer in_a_flag;
15909
15910 output Tpl.Text out_txt;
15911 algorithm
15912 out_txt :=
15913 match(in_txt, in_a_flag)
15914 local
15915 Tpl.Text txt;
15916
15917 case ( txt,
15918 8 )
15919 algorithm
15920 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("int"));
15921 then txt;
15922
15923 case ( txt,
15924 1 )
15925 algorithm
15926 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("int"));
15927 then txt;
15928
15929 case ( txt,
15930 _ )
15931 algorithm
15932 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("int"));
15933 then txt;
15934 end match;
15935 end fun_329;
15936
15937 protected function fun_330
15938 input Tpl.Text in_txt;
15939 input Integer in_a_flag;
15940
15941 output Tpl.Text out_txt;
15942 algorithm
15943 out_txt :=
15944 match(in_txt, in_a_flag)
15945 local
15946 Tpl.Text txt;
15947
15948 case ( txt,
15949 1 )
15950 algorithm
15951 5 txt := Tpl.writeTok(txt, Tpl.ST_STRING("double"));
15952 then txt;
15953
15954 case ( txt,
15955 _ )
15956 algorithm
15957 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("double"));
15958 then txt;
15959 end match;
15960 end fun_330;
15961
15962 protected function fun_331
15963 input Tpl.Text in_txt;
15964 input Integer in_a_flag;
15965
15966 output Tpl.Text out_txt;
15967 algorithm
15968 out_txt :=
15969 match(in_txt, in_a_flag)
15970 local
15971 Tpl.Text txt;
15972
15973 case ( txt,
15974 1 )
15975 algorithm
15976 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("string"));
15977 then txt;
15978
15979 case ( txt,
15980 _ )
15981 algorithm
15982 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_string"));
15983 then txt;
15984 end match;
15985 end fun_331;
15986
15987 protected function fun_332
15988 input Tpl.Text in_txt;
15989 input Integer in_a_flag;
15990
15991 output Tpl.Text out_txt;
15992 algorithm
15993 out_txt :=
15994 match(in_txt, in_a_flag)
15995 local
15996 Tpl.Text txt;
15997
15998 case ( txt,
15999 1 )
16000 algorithm
16001 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("bool"));
16002 then txt;
16003
16004 case ( txt,
16005 _ )
16006 algorithm
16007 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_boolean"));
16008 then txt;
16009 end match;
16010 end fun_332;
16011
16012 protected function fun_333
16013 input Tpl.Text in_txt;
16014 input Integer in_a_flag;
16015
16016 output Tpl.Text out_txt;
16017 algorithm
16018 out_txt :=
16019 match(in_txt, in_a_flag)
16020 local
16021 Tpl.Text txt;
16022
16023 case ( txt,
16024 8 )
16025 algorithm
16026 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("int"));
16027 then txt;
16028
16029 case ( txt,
16030 1 )
16031 algorithm
16032 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("int"));
16033 then txt;
16034
16035 case ( txt,
16036 _ )
16037 algorithm
16038 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("int"));
16039 then txt;
16040 end match;
16041 end fun_333;
16042
16043 protected function fun_334
16044 input Tpl.Text in_txt;
16045 input Integer in_a_flag;
16046
16047 output Tpl.Text out_txt;
16048 algorithm
16049 out_txt :=
16050 match(in_txt, in_a_flag)
16051 local
16052 Tpl.Text txt;
16053
16054 case ( txt,
16055 1 )
16056 algorithm
16057 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("metatype"));
16058 then txt;
16059
16060 case ( txt,
16061 _ )
16062 algorithm
16063 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_metatype"));
16064 then txt;
16065 end match;
16066 end fun_334;
16067
16068 protected function fun_335
16069 input Tpl.Text in_txt;
16070 input Integer in_a_flag;
16071
16072 output Tpl.Text out_txt;
16073 algorithm
16074 out_txt :=
16075 match(in_txt, in_a_flag)
16076 local
16077 Tpl.Text txt;
16078
16079 case ( txt,
16080 1 )
16081 algorithm
16082 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("metatype"));
16083 then txt;
16084
16085 case ( txt,
16086 _ )
16087 algorithm
16088 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_metatype"));
16089 then txt;
16090 end match;
16091 end fun_335;
16092
16093 protected function fun_336
16094 input Tpl.Text in_txt;
16095 input Integer in_a_flag;
16096
16097 output Tpl.Text out_txt;
16098 algorithm
16099 out_txt :=
16100 match(in_txt, in_a_flag)
16101 local
16102 Tpl.Text txt;
16103
16104 case ( txt,
16105 1 )
16106 algorithm
16107 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("metatype"));
16108 then txt;
16109
16110 case ( txt,
16111 _ )
16112 algorithm
16113 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_metatype"));
16114 then txt;
16115 end match;
16116 end fun_336;
16117
16118 protected function fun_337
16119 input Tpl.Text in_txt;
16120 input Integer in_a_flag;
16121
16122 output Tpl.Text out_txt;
16123 algorithm
16124 out_txt :=
16125 match(in_txt, in_a_flag)
16126 local
16127 Tpl.Text txt;
16128
16129 case ( txt,
16130 1 )
16131 algorithm
16132 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("metatype"));
16133 then txt;
16134
16135 case ( txt,
16136 _ )
16137 algorithm
16138 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_metatype"));
16139 then txt;
16140 end match;
16141 end fun_337;
16142
16143 protected function fun_338
16144 input Tpl.Text in_txt;
16145 input Integer in_a_flag;
16146
16147 output Tpl.Text out_txt;
16148 algorithm
16149 out_txt :=
16150 match(in_txt, in_a_flag)
16151 local
16152 Tpl.Text txt;
16153
16154 case ( txt,
16155 1 )
16156 algorithm
16157 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("metatype"));
16158 then txt;
16159
16160 case ( txt,
16161 _ )
16162 algorithm
16163 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_metatype"));
16164 then txt;
16165 end match;
16166 end fun_338;
16167
16168 protected function fun_339
16169 input Tpl.Text in_txt;
16170 input Integer in_a_flag;
16171
16172 output Tpl.Text out_txt;
16173 algorithm
16174 out_txt :=
16175 match(in_txt, in_a_flag)
16176 local
16177 Tpl.Text txt;
16178
16179 case ( txt,
16180 1 )
16181 algorithm
16182 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("metatype"));
16183 then txt;
16184
16185 case ( txt,
16186 _ )
16187 algorithm
16188 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_metatype"));
16189 then txt;
16190 end match;
16191 end fun_339;
16192
16193 public function expTypeFromExpFlag
16194 input Tpl.Text in_txt;
16195 input DAE.Exp in_a_exp;
16196 input Integer in_a_flag;
16197
16198 output Tpl.Text out_txt;
16199 algorithm
16200 out_txt :=
16201 match(in_txt, in_a_exp, in_a_flag)
16202 local
16203 Tpl.Text txt;
16204 Integer a_flag;
16205 DAE.Exp i_c_exp;
16206 DAE.Exp i_e;
16207 DAE.Exp i_exp;
16208 DAE.Exp i_c;
16209 DAE.Type i_c_ty;
16210 DAE.Type i_attr_ty;
16211 DAE.Exp i_expThen;
16212 DAE.Operator i_e_operator;
16213 Tpl.Text txt_5;
16214 DAE.Type ret_4;
16215 DAE.Type ret_3;
16216 DAE.Type ret_2;
16217 DAE.Type ret_1;
16218 DAE.Type ret_0;
16219
16220 case ( txt,
16221 DAE.ICONST(integer = _),
16222 a_flag )
16223 algorithm
16224 ✗ txt := fun_329(txt, a_flag);
16225 then txt;
16226
16227 case ( txt,
16228 DAE.RCONST(real = _),
16229 a_flag )
16230 algorithm
16231 5 txt := fun_330(txt, a_flag);
16232 then txt;
16233
16234 case ( txt,
16235 DAE.SCONST(string = _),
16236 a_flag )
16237 algorithm
16238 ✗ txt := fun_331(txt, a_flag);
16239 then txt;
16240
16241 case ( txt,
16242 DAE.BCONST(bool = _),
16243 a_flag )
16244 algorithm
16245 ✗ txt := fun_332(txt, a_flag);
16246 then txt;
16247
16248 case ( txt,
16249 DAE.ENUM_LITERAL(name = _),
16250 a_flag )
16251 algorithm
16252 ✗ txt := fun_333(txt, a_flag);
16253 then txt;
16254
16255 case ( txt,
16256 DAE.BINARY(operator = i_e_operator),
16257 a_flag )
16258 algorithm
16259 70 txt := expTypeFromOpFlag(txt, i_e_operator, a_flag);
16260 then txt;
16261
16262 case ( txt,
16263 DAE.UNARY(operator = i_e_operator),
16264 a_flag )
16265 algorithm
16266 2 txt := expTypeFromOpFlag(txt, i_e_operator, a_flag);
16267 then txt;
16268
16269 case ( txt,
16270 DAE.LBINARY(operator = i_e_operator),
16271 a_flag )
16272 algorithm
16273 ✗ txt := expTypeFromOpFlag(txt, i_e_operator, a_flag);
16274 then txt;
16275
16276 case ( txt,
16277 DAE.LUNARY(operator = i_e_operator),
16278 a_flag )
16279 algorithm
16280 ✗ txt := expTypeFromOpFlag(txt, i_e_operator, a_flag);
16281 then txt;
16282
16283 case ( txt,
16284 DAE.RELATION(operator = i_e_operator),
16285 a_flag )
16286 algorithm
16287 ✗ txt := expTypeFromOpFlag(txt, i_e_operator, a_flag);
16288 then txt;
16289
16290 case ( txt,
16291 DAE.IFEXP(expThen = i_expThen),
16292 a_flag )
16293 algorithm
16294 1 txt := expTypeFromExpFlag(txt, i_expThen, a_flag);
16295 then txt;
16296
16297 case ( txt,
16298 DAE.CALL(attr = DAE.CALL_ATTR(ty = i_attr_ty)),
16299 a_flag )
16300 algorithm
16301 33 txt := expTypeFlag(txt, i_attr_ty, a_flag);
16302 then txt;
16303
16304 case ( txt,
16305 DAE.RECORD(ty = i_c_ty),
16306 a_flag )
16307 algorithm
16308 ✗ txt := expTypeFlag(txt, i_c_ty, a_flag);
16309 then txt;
16310
16311 case ( txt,
16312 DAE.ARRAY(ty = i_c_ty),
16313 a_flag )
16314 algorithm
16315 26 txt := expTypeFlag(txt, i_c_ty, a_flag);
16316 then txt;
16317
16318 case ( txt,
16319 DAE.MATRIX(ty = i_c_ty),
16320 a_flag )
16321 algorithm
16322 ✗ txt := expTypeFlag(txt, i_c_ty, a_flag);
16323 then txt;
16324
16325 case ( txt,
16326 DAE.RANGE(ty = i_c_ty),
16327 a_flag )
16328 algorithm
16329 11 txt := expTypeFlag(txt, i_c_ty, a_flag);
16330 then txt;
16331
16332 case ( txt,
16333 DAE.CAST(ty = i_c_ty),
16334 a_flag )
16335 algorithm
16336 ✗ txt := expTypeFlag(txt, i_c_ty, a_flag);
16337 then txt;
16338
16339 case ( txt,
16340 DAE.TSUB(ty = i_c_ty),
16341 a_flag )
16342 algorithm
16343 ✗ txt := expTypeFlag(txt, i_c_ty, a_flag);
16344 then txt;
16345
16346 case ( txt,
16347 DAE.CREF(ty = i_c_ty),
16348 a_flag )
16349 algorithm
16350 982 txt := expTypeFlag(txt, i_c_ty, a_flag);
16351 then txt;
16352
16353 case ( txt,
16354 DAE.CODE(ty = i_c_ty),
16355 a_flag )
16356 algorithm
16357 ✗ txt := expTypeFlag(txt, i_c_ty, a_flag);
16358 then txt;
16359
16360 case ( txt,
16361 (i_c as DAE.ASUB(exp = _)),
16362 a_flag )
16363 algorithm
16364 140 ret_0 := Expression.typeof(i_c);
16365 140 txt := expTypeFlag(txt, ret_0, a_flag);
16366 then txt;
16367
16368 case ( txt,
16369 (i_exp as DAE.REDUCTION(reductionInfo = _)),
16370 a_flag )
16371 algorithm
16372 10 ret_1 := Expression.typeof(i_exp);
16373 10 txt := expTypeFlag(txt, ret_1, a_flag);
16374 then txt;
16375
16376 case ( txt,
16377 (i_e as DAE.CONS(car = _)),
16378 a_flag )
16379 algorithm
16380 ✗ ret_2 := Expression.typeof(i_e);
16381 ✗ txt := expTypeFlag(txt, ret_2, a_flag);
16382 then txt;
16383
16384 case ( txt,
16385 (i_e as DAE.LIST(valList = _)),
16386 a_flag )
16387 algorithm
16388 ✗ ret_3 := Expression.typeof(i_e);
16389 ✗ txt := expTypeFlag(txt, ret_3, a_flag);
16390 then txt;
16391
16392 case ( txt,
16393 (i_e as DAE.SIZE(exp = _)),
16394 a_flag )
16395 algorithm
16396 ✗ ret_4 := Expression.typeof(i_e);
16397 ✗ txt := expTypeFlag(txt, ret_4, a_flag);
16398 then txt;
16399
16400 case ( txt,
16401 DAE.RSUB(ix = -1, ty = i_c_ty),
16402 a_flag )
16403 algorithm
16404 ✗ txt := expTypeFlag(txt, i_c_ty, a_flag);
16405 then txt;
16406
16407 case ( txt,
16408 DAE.META_TUPLE(listExp = _),
16409 a_flag )
16410 algorithm
16411 ✗ txt := fun_334(txt, a_flag);
16412 then txt;
16413
16414 case ( txt,
16415 DAE.META_OPTION(exp = _),
16416 a_flag )
16417 algorithm
16418 ✗ txt := fun_335(txt, a_flag);
16419 then txt;
16420
16421 case ( txt,
16422 DAE.MATCHEXPRESSION(matchType = _),
16423 a_flag )
16424 algorithm
16425 ✗ txt := fun_336(txt, a_flag);
16426 then txt;
16427
16428 case ( txt,
16429 DAE.METARECORDCALL(path = _),
16430 a_flag )
16431 algorithm
16432 ✗ txt := fun_337(txt, a_flag);
16433 then txt;
16434
16435 case ( txt,
16436 DAE.RSUB(exp = _),
16437 a_flag )
16438 algorithm
16439 ✗ txt := fun_338(txt, a_flag);
16440 then txt;
16441
16442 case ( txt,
16443 DAE.BOX(exp = _),
16444 a_flag )
16445 algorithm
16446 ✗ txt := fun_339(txt, a_flag);
16447 then txt;
16448
16449 case ( txt,
16450 DAE.UNBOX(ty = i_c_ty),
16451 a_flag )
16452 algorithm
16453 ✗ txt := expTypeFlag(txt, i_c_ty, a_flag);
16454 then txt;
16455
16456 case ( txt,
16457 DAE.SHARED_LITERAL(exp = i_c_exp),
16458 a_flag )
16459 algorithm
16460 1 txt := expTypeFromExpFlag(txt, i_c_exp, a_flag);
16461 then txt;
16462
16463 case ( txt,
16464 i_exp,
16465 a_flag )
16466 algorithm
16467 ✗ txt_5 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("expTypeFromExpFlag(flag="));
16468 ✗ txt_5 := Tpl.writeStr(txt_5, intString(a_flag));
16469 ✗ txt_5 := Tpl.writeTok(txt_5, Tpl.ST_STRING("):"));
16470 ✗ txt_5 := ExpressionDumpTpl.dumpExp(txt_5, i_exp, "\"");
16471 ✗ txt := error(txt, Tpl.sourceInfo("CodegenCppCommon.tpl", 2298, 14), Tpl.textString(txt_5));
16472 then txt;
16473 end match;
16474 end expTypeFromExpFlag;
16475
16476 protected function fun_341
16477 input Tpl.Text in_txt;
16478 input Integer in_a_flag;
16479
16480 output Tpl.Text out_txt;
16481 algorithm
16482 out_txt :=
16483 match(in_txt, in_a_flag)
16484 local
16485 Tpl.Text txt;
16486
16487 case ( txt,
16488 1 )
16489 algorithm
16490 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("bool"));
16491 then txt;
16492
16493 case ( txt,
16494 _ )
16495 algorithm
16496 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_boolean"));
16497 then txt;
16498 end match;
16499 end fun_341;
16500
16501 protected function fun_342
16502 input Tpl.Text in_txt;
16503 input Integer in_a_flag;
16504
16505 output Tpl.Text out_txt;
16506 algorithm
16507 out_txt :=
16508 match(in_txt, in_a_flag)
16509 local
16510 Tpl.Text txt;
16511
16512 case ( txt,
16513 1 )
16514 algorithm
16515 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("bool"));
16516 then txt;
16517
16518 case ( txt,
16519 _ )
16520 algorithm
16521 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_boolean"));
16522 then txt;
16523 end match;
16524 end fun_342;
16525
16526 protected function fun_343
16527 input Tpl.Text in_txt;
16528 input Integer in_a_flag;
16529
16530 output Tpl.Text out_txt;
16531 algorithm
16532 out_txt :=
16533 match(in_txt, in_a_flag)
16534 local
16535 Tpl.Text txt;
16536
16537 case ( txt,
16538 1 )
16539 algorithm
16540 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("bool"));
16541 then txt;
16542
16543 case ( txt,
16544 _ )
16545 algorithm
16546 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_boolean"));
16547 then txt;
16548 end match;
16549 end fun_343;
16550
16551 public function expTypeFromOpFlag
16552 input Tpl.Text in_txt;
16553 input DAE.Operator in_a_op;
16554 input Integer in_a_flag;
16555
16556 output Tpl.Text out_txt;
16557 algorithm
16558 out_txt :=
16559 match(in_txt, in_a_op, in_a_flag)
16560 local
16561 Tpl.Text txt;
16562 Integer a_flag;
16563 DAE.Type i_o_ty;
16564
16565 case ( txt,
16566 DAE.ADD(ty = i_o_ty),
16567 a_flag )
16568 algorithm
16569 26 txt := expTypeFlag(txt, i_o_ty, a_flag);
16570 then txt;
16571
16572 case ( txt,
16573 DAE.SUB(ty = i_o_ty),
16574 a_flag )
16575 algorithm
16576 24 txt := expTypeFlag(txt, i_o_ty, a_flag);
16577 then txt;
16578
16579 case ( txt,
16580 DAE.MUL(ty = i_o_ty),
16581 a_flag )
16582 algorithm
16583 5 txt := expTypeFlag(txt, i_o_ty, a_flag);
16584 then txt;
16585
16586 case ( txt,
16587 DAE.DIV(ty = i_o_ty),
16588 a_flag )
16589 algorithm
16590 13 txt := expTypeFlag(txt, i_o_ty, a_flag);
16591 then txt;
16592
16593 case ( txt,
16594 DAE.POW(ty = i_o_ty),
16595 a_flag )
16596 algorithm
16597 ✗ txt := expTypeFlag(txt, i_o_ty, a_flag);
16598 then txt;
16599
16600 case ( txt,
16601 DAE.UMINUS(ty = i_o_ty),
16602 a_flag )
16603 algorithm
16604 2 txt := expTypeFlag(txt, i_o_ty, a_flag);
16605 then txt;
16606
16607 case ( txt,
16608 DAE.UMINUS_ARR(ty = i_o_ty),
16609 a_flag )
16610 algorithm
16611 ✗ txt := expTypeFlag(txt, i_o_ty, a_flag);
16612 then txt;
16613
16614 case ( txt,
16615 DAE.ADD_ARR(ty = i_o_ty),
16616 a_flag )
16617 algorithm
16618 ✗ txt := expTypeFlag(txt, i_o_ty, a_flag);
16619 then txt;
16620
16621 case ( txt,
16622 DAE.SUB_ARR(ty = i_o_ty),
16623 a_flag )
16624 algorithm
16625 ✗ txt := expTypeFlag(txt, i_o_ty, a_flag);
16626 then txt;
16627
16628 case ( txt,
16629 DAE.MUL_ARR(ty = i_o_ty),
16630 a_flag )
16631 algorithm
16632 ✗ txt := expTypeFlag(txt, i_o_ty, a_flag);
16633 then txt;
16634
16635 case ( txt,
16636 DAE.DIV_ARR(ty = i_o_ty),
16637 a_flag )
16638 algorithm
16639 ✗ txt := expTypeFlag(txt, i_o_ty, a_flag);
16640 then txt;
16641
16642 case ( txt,
16643 DAE.MUL_ARRAY_SCALAR(ty = i_o_ty),
16644 a_flag )
16645 algorithm
16646 ✗ txt := expTypeFlag(txt, i_o_ty, a_flag);
16647 then txt;
16648
16649 case ( txt,
16650 DAE.ADD_ARRAY_SCALAR(ty = i_o_ty),
16651 a_flag )
16652 algorithm
16653 ✗ txt := expTypeFlag(txt, i_o_ty, a_flag);
16654 then txt;
16655
16656 case ( txt,
16657 DAE.SUB_SCALAR_ARRAY(ty = i_o_ty),
16658 a_flag )
16659 algorithm
16660 ✗ txt := expTypeFlag(txt, i_o_ty, a_flag);
16661 then txt;
16662
16663 case ( txt,
16664 DAE.MUL_SCALAR_PRODUCT(ty = i_o_ty),
16665 a_flag )
16666 algorithm
16667 2 txt := expTypeFlag(txt, i_o_ty, a_flag);
16668 then txt;
16669
16670 case ( txt,
16671 DAE.MUL_MATRIX_PRODUCT(ty = i_o_ty),
16672 a_flag )
16673 algorithm
16674 ✗ txt := expTypeFlag(txt, i_o_ty, a_flag);
16675 then txt;
16676
16677 case ( txt,
16678 DAE.DIV_ARRAY_SCALAR(ty = i_o_ty),
16679 a_flag )
16680 algorithm
16681 ✗ txt := expTypeFlag(txt, i_o_ty, a_flag);
16682 then txt;
16683
16684 case ( txt,
16685 DAE.DIV_SCALAR_ARRAY(ty = i_o_ty),
16686 a_flag )
16687 algorithm
16688 ✗ txt := expTypeFlag(txt, i_o_ty, a_flag);
16689 then txt;
16690
16691 case ( txt,
16692 DAE.POW_ARRAY_SCALAR(ty = i_o_ty),
16693 a_flag )
16694 algorithm
16695 ✗ txt := expTypeFlag(txt, i_o_ty, a_flag);
16696 then txt;
16697
16698 case ( txt,
16699 DAE.POW_SCALAR_ARRAY(ty = i_o_ty),
16700 a_flag )
16701 algorithm
16702 ✗ txt := expTypeFlag(txt, i_o_ty, a_flag);
16703 then txt;
16704
16705 case ( txt,
16706 DAE.POW_ARR(ty = i_o_ty),
16707 a_flag )
16708 algorithm
16709 ✗ txt := expTypeFlag(txt, i_o_ty, a_flag);
16710 then txt;
16711
16712 case ( txt,
16713 DAE.POW_ARR2(ty = i_o_ty),
16714 a_flag )
16715 algorithm
16716 ✗ txt := expTypeFlag(txt, i_o_ty, a_flag);
16717 then txt;
16718
16719 case ( txt,
16720 DAE.LESS(ty = i_o_ty),
16721 a_flag )
16722 algorithm
16723 ✗ txt := expTypeFlag(txt, i_o_ty, a_flag);
16724 then txt;
16725
16726 case ( txt,
16727 DAE.LESSEQ(ty = i_o_ty),
16728 a_flag )
16729 algorithm
16730 ✗ txt := expTypeFlag(txt, i_o_ty, a_flag);
16731 then txt;
16732
16733 case ( txt,
16734 DAE.GREATER(ty = i_o_ty),
16735 a_flag )
16736 algorithm
16737 ✗ txt := expTypeFlag(txt, i_o_ty, a_flag);
16738 then txt;
16739
16740 case ( txt,
16741 DAE.GREATEREQ(ty = i_o_ty),
16742 a_flag )
16743 algorithm
16744 ✗ txt := expTypeFlag(txt, i_o_ty, a_flag);
16745 then txt;
16746
16747 case ( txt,
16748 DAE.EQUAL(ty = i_o_ty),
16749 a_flag )
16750 algorithm
16751 ✗ txt := expTypeFlag(txt, i_o_ty, a_flag);
16752 then txt;
16753
16754 case ( txt,
16755 DAE.NEQUAL(ty = i_o_ty),
16756 a_flag )
16757 algorithm
16758 ✗ txt := expTypeFlag(txt, i_o_ty, a_flag);
16759 then txt;
16760
16761 case ( txt,
16762 DAE.AND(ty = _),
16763 a_flag )
16764 algorithm
16765 ✗ txt := fun_341(txt, a_flag);
16766 then txt;
16767
16768 case ( txt,
16769 DAE.OR(ty = _),
16770 a_flag )
16771 algorithm
16772 ✗ txt := fun_342(txt, a_flag);
16773 then txt;
16774
16775 case ( txt,
16776 DAE.NOT(ty = _),
16777 a_flag )
16778 algorithm
16779 ✗ txt := fun_343(txt, a_flag);
16780 then txt;
16781
16782 case ( txt,
16783 _,
16784 _ )
16785 algorithm
16786 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("expTypeFromOpFlag:ERROR"));
16787 then txt;
16788 end match;
16789 end expTypeFromOpFlag;
16790
16791 protected function fun_345
16792 input Tpl.Text in_txt;
16793 input SimCodeFunction.Context in_a_context;
16794 input Tpl.Text in_a_e2str;
16795 input Tpl.Text in_a_e2;
16796 input Tpl.Text in_a_e1;
16797
16798 output Tpl.Text out_txt;
16799 algorithm
16800 out_txt :=
16801 match(in_txt, in_a_context, in_a_e2str, in_a_e2, in_a_e1)
16802 local
16803 Tpl.Text txt;
16804 Tpl.Text a_e2str;
16805 Tpl.Text a_e2;
16806 Tpl.Text a_e1;
16807
16808 case ( txt,
16809 SimCodeFunction.ALGLOOP_CONTEXT(genInitialisation = false),
16810 a_e2str,
16811 a_e2,
16812 a_e1 )
16813 algorithm
16814 544 txt := Tpl.writeTok(txt, Tpl.ST_STRING("division("));
16815 544 txt := Tpl.writeText(txt, a_e1);
16816 544 txt := Tpl.writeTok(txt, Tpl.ST_STRING(","));
16817 544 txt := Tpl.writeText(txt, a_e2);
16818 544 txt := Tpl.writeTok(txt, Tpl.ST_STRING(",!_system->_initial,\""));
16819 544 txt := Tpl.writeText(txt, a_e2str);
16820 544 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\")"));
16821 then txt;
16822
16823 case ( txt,
16824 _,
16825 a_e2str,
16826 a_e2,
16827 a_e1 )
16828 algorithm
16829 1960 txt := Tpl.writeTok(txt, Tpl.ST_STRING("division("));
16830 1960 txt := Tpl.writeText(txt, a_e1);
16831 1960 txt := Tpl.writeTok(txt, Tpl.ST_STRING(","));
16832 1960 txt := Tpl.writeText(txt, a_e2);
16833 1960 txt := Tpl.writeTok(txt, Tpl.ST_STRING(",!_initial,\""));
16834 1960 txt := Tpl.writeText(txt, a_e2str);
16835 1960 txt := Tpl.writeTok(txt, Tpl.ST_STRING("\")"));
16836 then txt;
16837 end match;
16838 end fun_345;
16839
16840 protected function fun_346
16841 input Tpl.Text in_txt;
16842 input Boolean in_mArg;
16843 input Tpl.Text in_a_tvar;
16844 input Tpl.Text in_a_e1;
16845 input Tpl.Text in_a_e2;
16846 input Tpl.Text in_a_type;
16847
16848 output Tpl.Text out_txt;
16849 algorithm
16850 out_txt :=
16851 match(in_txt, in_mArg, in_a_tvar, in_a_e1, in_a_e2, in_a_type)
16852 local
16853 Tpl.Text txt;
16854 Tpl.Text a_tvar;
16855 Tpl.Text a_e1;
16856 Tpl.Text a_e2;
16857 Tpl.Text a_type;
16858
16859 case ( txt,
16860 false,
16861 a_tvar,
16862 a_e1,
16863 a_e2,
16864 a_type )
16865 algorithm
16866 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("add_array_scalar<"));
16867 ✗ txt := Tpl.writeText(txt, a_type);
16868 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(">("));
16869 ✗ txt := Tpl.writeText(txt, a_e2);
16870 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
16871 ✗ txt := Tpl.writeText(txt, a_e1);
16872 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
16873 ✗ txt := Tpl.writeText(txt, a_tvar);
16874 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
16875 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
16876 then txt;
16877
16878 case ( txt,
16879 _,
16880 a_tvar,
16881 a_e1,
16882 a_e2,
16883 a_type )
16884 algorithm
16885 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("add_array_scalar<"));
16886 ✗ txt := Tpl.writeText(txt, a_type);
16887 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(">("));
16888 ✗ txt := Tpl.writeText(txt, a_e1);
16889 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
16890 ✗ txt := Tpl.writeText(txt, a_e2);
16891 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
16892 ✗ txt := Tpl.writeText(txt, a_tvar);
16893 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
16894 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
16895 then txt;
16896 end match;
16897 end fun_346;
16898
16899 protected function fun_347
16900 input Tpl.Text in_txt;
16901 input DAE.Operator in_a_it;
16902 input DAE.Exp in_a_exp1;
16903 input Tpl.Text in_a_preExp;
16904 input Tpl.Text in_a_varDecls;
16905 input SimCodeFunction.Context in_a_context;
16906 input DAE.Exp in_a_exp2;
16907 input Tpl.Text in_a_e2;
16908 input Tpl.Text in_a_e1;
16909
16910 output Tpl.Text out_txt;
16911 output Tpl.Text out_a_preExp;
16912 output Tpl.Text out_a_varDecls;
16913 algorithm
16914 (out_txt, out_a_preExp, out_a_varDecls) :=
16915 match(in_txt, in_a_it, in_a_exp1, in_a_preExp, in_a_varDecls, in_a_context, in_a_exp2, in_a_e2, in_a_e1)
16916 local
16917 Tpl.Text txt;
16918 DAE.Exp a_exp1;
16919 Tpl.Text a_preExp;
16920 Tpl.Text a_varDecls;
16921 SimCodeFunction.Context a_context;
16922 DAE.Exp a_exp2;
16923 Tpl.Text a_e2;
16924 Tpl.Text a_e1;
16925 DAE.Operator i_it;
16926 DAE.Type i_ty;
16927 DAE.Dimensions i_dims;
16928 DAE.Type i_ty_ty;
16929 String ret_18;
16930 Tpl.Text txt_17;
16931 Tpl.Text txt_16;
16932 Boolean ret_15;
16933 DAE.Type ret_14;
16934 Tpl.Text txt_13;
16935 Tpl.Text txt_12;
16936 Tpl.Text txt_11;
16937 Tpl.Text txt_10;
16938 Tpl.Text txt_9;
16939 Tpl.Text txt_8;
16940 Tpl.Text txt_7;
16941 Tpl.Text txt_6;
16942 Tpl.Text txt_5;
16943 Tpl.Text l_tvar;
16944 Tpl.Text l_type;
16945 String ret_2;
16946 Tpl.Text txt_1;
16947 Tpl.Text l_e2str;
16948
16949 case ( txt,
16950 DAE.ADD(ty = _),
16951 _,
16952 a_preExp,
16953 a_varDecls,
16954 _,
16955 _,
16956 a_e2,
16957 a_e1 )
16958 algorithm
16959 15889 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
16960 15889 txt := Tpl.writeText(txt, a_e1);
16961 15889 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" + "));
16962 15889 txt := Tpl.writeText(txt, a_e2);
16963 15889 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
16964 15889 then (txt, a_preExp, a_varDecls);
16965
16966 case ( txt,
16967 DAE.SUB(ty = _),
16968 _,
16969 a_preExp,
16970 a_varDecls,
16971 _,
16972 _,
16973 a_e2,
16974 a_e1 )
16975 algorithm
16976 4265 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
16977 4265 txt := Tpl.writeText(txt, a_e1);
16978 4265 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" - "));
16979 4265 txt := Tpl.writeText(txt, a_e2);
16980 4265 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
16981 4265 then (txt, a_preExp, a_varDecls);
16982
16983 case ( txt,
16984 DAE.MUL(ty = _),
16985 _,
16986 a_preExp,
16987 a_varDecls,
16988 _,
16989 _,
16990 a_e2,
16991 a_e1 )
16992 algorithm
16993 27289 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
16994 27289 txt := Tpl.writeText(txt, a_e1);
16995 27289 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" * "));
16996 27289 txt := Tpl.writeText(txt, a_e2);
16997 27289 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
16998 27289 then (txt, a_preExp, a_varDecls);
16999
17000 case ( txt,
17001 DAE.DIV(ty = _),
17002 _,
17003 a_preExp,
17004 a_varDecls,
17005 a_context,
17006 a_exp2,
17007 a_e2,
17008 a_e1 )
17009 algorithm
17010 2504 txt_1 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, a_exp2, "\"");
17011 2504 ret_2 := Util.escapeModelicaStringToCString(Tpl.textString(txt_1));
17012 2504 l_e2str := Tpl.writeStr(Tpl.emptyTxt, ret_2);
17013 2504 txt := fun_345(txt, a_context, l_e2str, a_e2, a_e1);
17014 2504 then (txt, a_preExp, a_varDecls);
17015
17016 case ( txt,
17017 DAE.POW(ty = _),
17018 _,
17019 a_preExp,
17020 a_varDecls,
17021 _,
17022 _,
17023 a_e2,
17024 a_e1 )
17025 algorithm
17026 2187 txt := Tpl.writeTok(txt, Tpl.ST_STRING("std::pow("));
17027 2187 txt := Tpl.writeText(txt, a_e1);
17028 2187 txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
17029 2187 txt := Tpl.writeText(txt, a_e2);
17030 2187 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
17031 2187 then (txt, a_preExp, a_varDecls);
17032
17033 case ( txt,
17034 DAE.AND(ty = _),
17035 _,
17036 a_preExp,
17037 a_varDecls,
17038 _,
17039 _,
17040 a_e2,
17041 a_e1 )
17042 algorithm
17043 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
17044 ✗ txt := Tpl.writeText(txt, a_e1);
17045 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" && "));
17046 ✗ txt := Tpl.writeText(txt, a_e2);
17047 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
17048 ✗ then (txt, a_preExp, a_varDecls);
17049
17050 case ( txt,
17051 DAE.OR(ty = _),
17052 _,
17053 a_preExp,
17054 a_varDecls,
17055 _,
17056 _,
17057 a_e2,
17058 a_e1 )
17059 algorithm
17060 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
17061 ✗ txt := Tpl.writeText(txt, a_e1);
17062 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" || "));
17063 ✗ txt := Tpl.writeText(txt, a_e2);
17064 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
17065 ✗ then (txt, a_preExp, a_varDecls);
17066
17067 case ( txt,
17068 DAE.MUL_ARRAY_SCALAR(ty = DAE.T_ARRAY(dims = i_dims, ty = i_ty_ty)),
17069 _,
17070 a_preExp,
17071 a_varDecls,
17072 _,
17073 _,
17074 a_e2,
17075 a_e1 )
17076 algorithm
17077 1 l_type := expTypeShort(Tpl.emptyTxt, i_ty_ty);
17078 1 txt_5 := expTypeArrayDims(Tpl.emptyTxt, i_ty_ty, i_dims);
17079 1 (l_tvar, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(txt_5), a_varDecls);
17080 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("multiply_array<"));
17081 1 a_preExp := Tpl.writeText(a_preExp, l_type);
17082 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(">("));
17083 1 a_preExp := Tpl.writeText(a_preExp, a_e1);
17084 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
17085 1 a_preExp := Tpl.writeText(a_preExp, a_e2);
17086 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
17087 1 a_preExp := Tpl.writeText(a_preExp, l_tvar);
17088 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
17089 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
17090 1 txt := Tpl.writeText(txt, l_tvar);
17091 1 then (txt, a_preExp, a_varDecls);
17092
17093 case ( txt,
17094 DAE.MUL_MATRIX_PRODUCT(ty = DAE.T_ARRAY(dims = i_dims, ty = i_ty_ty)),
17095 _,
17096 a_preExp,
17097 a_varDecls,
17098 _,
17099 _,
17100 a_e2,
17101 a_e1 )
17102 algorithm
17103 ✗ l_type := expTypeShort(Tpl.emptyTxt, i_ty_ty);
17104 ✗ txt_6 := expTypeArrayDims(Tpl.emptyTxt, i_ty_ty, i_dims);
17105 ✗ (l_tvar, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(txt_6), a_varDecls);
17106 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("multiply_array<"));
17107 ✗ a_preExp := Tpl.writeText(a_preExp, l_type);
17108 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(">("));
17109 ✗ a_preExp := Tpl.writeText(a_preExp, a_e1);
17110 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
17111 ✗ a_preExp := Tpl.writeText(a_preExp, a_e2);
17112 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
17113 ✗ a_preExp := Tpl.writeText(a_preExp, l_tvar);
17114 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
17115 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
17116 ✗ txt := Tpl.writeText(txt, l_tvar);
17117 ✗ then (txt, a_preExp, a_varDecls);
17118
17119 case ( txt,
17120 DAE.DIV_ARRAY_SCALAR(ty = DAE.T_ARRAY(dims = i_dims, ty = i_ty_ty)),
17121 _,
17122 a_preExp,
17123 a_varDecls,
17124 _,
17125 _,
17126 a_e2,
17127 a_e1 )
17128 algorithm
17129 5 l_type := expTypeShort(Tpl.emptyTxt, i_ty_ty);
17130 5 txt_7 := expTypeArrayDims(Tpl.emptyTxt, i_ty_ty, i_dims);
17131 5 (l_tvar, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(txt_7), a_varDecls);
17132 5 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("divide_array<"));
17133 5 a_preExp := Tpl.writeText(a_preExp, l_type);
17134 5 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(">("));
17135 5 a_preExp := Tpl.writeText(a_preExp, a_e1);
17136 5 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
17137 5 a_preExp := Tpl.writeText(a_preExp, a_e2);
17138 5 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
17139 5 a_preExp := Tpl.writeText(a_preExp, l_tvar);
17140 5 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
17141 5 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
17142 5 txt := Tpl.writeText(txt, l_tvar);
17143 5 then (txt, a_preExp, a_varDecls);
17144
17145 case ( txt,
17146 DAE.DIV_SCALAR_ARRAY(ty = DAE.T_ARRAY(dims = i_dims, ty = i_ty_ty)),
17147 _,
17148 a_preExp,
17149 a_varDecls,
17150 _,
17151 _,
17152 a_e2,
17153 a_e1 )
17154 algorithm
17155 ✗ l_type := expTypeShort(Tpl.emptyTxt, i_ty_ty);
17156 ✗ txt_8 := expTypeArrayDims(Tpl.emptyTxt, i_ty_ty, i_dims);
17157 ✗ (l_tvar, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(txt_8), a_varDecls);
17158 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("divide_array<"));
17159 ✗ a_preExp := Tpl.writeText(a_preExp, l_type);
17160 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(">("));
17161 ✗ a_preExp := Tpl.writeText(a_preExp, a_e1);
17162 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
17163 ✗ a_preExp := Tpl.writeText(a_preExp, a_e2);
17164 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
17165 ✗ a_preExp := Tpl.writeText(a_preExp, l_tvar);
17166 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
17167 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
17168 ✗ txt := Tpl.writeText(txt, l_tvar);
17169 ✗ then (txt, a_preExp, a_varDecls);
17170
17171 case ( txt,
17172 DAE.UMINUS(ty = _),
17173 _,
17174 a_preExp,
17175 a_varDecls,
17176 _,
17177 _,
17178 _,
17179 _ )
17180 algorithm
17181 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("daeExpBinary:ERR UMINUS not supported"));
17182 ✗ then (txt, a_preExp, a_varDecls);
17183
17184 case ( txt,
17185 DAE.UMINUS_ARR(ty = _),
17186 _,
17187 a_preExp,
17188 a_varDecls,
17189 _,
17190 _,
17191 _,
17192 _ )
17193 algorithm
17194 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("daeExpBinary:ERR UMINUS_ARR not supported"));
17195 ✗ then (txt, a_preExp, a_varDecls);
17196
17197 case ( txt,
17198 DAE.ADD_ARR(ty = DAE.T_ARRAY(dims = i_dims, ty = i_ty_ty)),
17199 _,
17200 a_preExp,
17201 a_varDecls,
17202 _,
17203 _,
17204 a_e2,
17205 a_e1 )
17206 algorithm
17207 3 l_type := expTypeShort(Tpl.emptyTxt, i_ty_ty);
17208 3 txt_9 := expTypeArrayDims(Tpl.emptyTxt, i_ty_ty, i_dims);
17209 3 (l_tvar, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(txt_9), a_varDecls);
17210 3 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("add_array<"));
17211 3 a_preExp := Tpl.writeText(a_preExp, l_type);
17212 3 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(">("));
17213 3 a_preExp := Tpl.writeText(a_preExp, a_e1);
17214 3 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
17215 3 a_preExp := Tpl.writeText(a_preExp, a_e2);
17216 3 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
17217 3 a_preExp := Tpl.writeText(a_preExp, l_tvar);
17218 3 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
17219 3 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
17220 3 txt := Tpl.writeText(txt, l_tvar);
17221 3 then (txt, a_preExp, a_varDecls);
17222
17223 case ( txt,
17224 DAE.SUB_ARR(ty = DAE.T_ARRAY(dims = i_dims, ty = i_ty_ty)),
17225 _,
17226 a_preExp,
17227 a_varDecls,
17228 _,
17229 _,
17230 a_e2,
17231 a_e1 )
17232 algorithm
17233 1 l_type := expTypeShort(Tpl.emptyTxt, i_ty_ty);
17234 1 txt_10 := expTypeArrayDims(Tpl.emptyTxt, i_ty_ty, i_dims);
17235 1 (l_tvar, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(txt_10), a_varDecls);
17236 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("subtract_array<"));
17237 1 a_preExp := Tpl.writeText(a_preExp, l_type);
17238 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(">("));
17239 1 a_preExp := Tpl.writeText(a_preExp, a_e1);
17240 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
17241 1 a_preExp := Tpl.writeText(a_preExp, a_e2);
17242 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
17243 1 a_preExp := Tpl.writeText(a_preExp, l_tvar);
17244 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
17245 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
17246 1 txt := Tpl.writeText(txt, l_tvar);
17247 1 then (txt, a_preExp, a_varDecls);
17248
17249 case ( txt,
17250 DAE.MUL_ARR(ty = DAE.T_ARRAY(dims = i_dims, ty = i_ty_ty)),
17251 _,
17252 a_preExp,
17253 a_varDecls,
17254 _,
17255 _,
17256 a_e2,
17257 a_e1 )
17258 algorithm
17259 ✗ l_type := expTypeShort(Tpl.emptyTxt, i_ty_ty);
17260 ✗ txt_11 := expTypeArrayDims(Tpl.emptyTxt, i_ty_ty, i_dims);
17261 ✗ (l_tvar, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(txt_11), a_varDecls);
17262 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("multiply_array_elem_wise<"));
17263 ✗ a_preExp := Tpl.writeText(a_preExp, l_type);
17264 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(">("));
17265 ✗ a_preExp := Tpl.writeText(a_preExp, a_e1);
17266 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
17267 ✗ a_preExp := Tpl.writeText(a_preExp, a_e2);
17268 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
17269 ✗ a_preExp := Tpl.writeText(a_preExp, l_tvar);
17270 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
17271 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
17272 ✗ txt := Tpl.writeText(txt, l_tvar);
17273 ✗ then (txt, a_preExp, a_varDecls);
17274
17275 case ( txt,
17276 DAE.DIV_ARR(ty = DAE.T_ARRAY(dims = i_dims, ty = i_ty_ty)),
17277 _,
17278 a_preExp,
17279 a_varDecls,
17280 _,
17281 _,
17282 a_e2,
17283 a_e1 )
17284 algorithm
17285 ✗ l_type := expTypeShort(Tpl.emptyTxt, i_ty_ty);
17286 ✗ txt_12 := expTypeArrayDims(Tpl.emptyTxt, i_ty_ty, i_dims);
17287 ✗ (l_tvar, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(txt_12), a_varDecls);
17288 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("divide_array_elem_wise<"));
17289 ✗ a_preExp := Tpl.writeText(a_preExp, l_type);
17290 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(">("));
17291 ✗ a_preExp := Tpl.writeText(a_preExp, a_e1);
17292 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
17293 ✗ a_preExp := Tpl.writeText(a_preExp, a_e2);
17294 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
17295 ✗ a_preExp := Tpl.writeText(a_preExp, l_tvar);
17296 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
17297 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
17298 ✗ txt := Tpl.writeText(txt, l_tvar);
17299 ✗ then (txt, a_preExp, a_varDecls);
17300
17301 case ( txt,
17302 DAE.ADD_ARRAY_SCALAR(ty = DAE.T_ARRAY(dims = i_dims, ty = i_ty_ty)),
17303 a_exp1,
17304 a_preExp,
17305 a_varDecls,
17306 _,
17307 _,
17308 a_e2,
17309 a_e1 )
17310 algorithm
17311 ✗ l_type := expTypeShort(Tpl.emptyTxt, i_ty_ty);
17312 ✗ txt_13 := expTypeArrayDims(Tpl.emptyTxt, i_ty_ty, i_dims);
17313 ✗ (l_tvar, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(txt_13), a_varDecls);
17314 ✗ ret_14 := Expression.typeof(a_exp1);
17315 ✗ ret_15 := Expression.isArrayType(ret_14);
17316 ✗ a_preExp := fun_346(a_preExp, ret_15, l_tvar, a_e1, a_e2, l_type);
17317 ✗ txt := Tpl.writeText(txt, l_tvar);
17318 ✗ then (txt, a_preExp, a_varDecls);
17319
17320 case ( txt,
17321 DAE.SUB_SCALAR_ARRAY(ty = DAE.T_ARRAY(dims = i_dims, ty = i_ty_ty)),
17322 _,
17323 a_preExp,
17324 a_varDecls,
17325 _,
17326 _,
17327 a_e2,
17328 a_e1 )
17329 algorithm
17330 ✗ l_type := expTypeShort(Tpl.emptyTxt, i_ty_ty);
17331 ✗ txt_16 := expTypeArrayDims(Tpl.emptyTxt, i_ty_ty, i_dims);
17332 ✗ (l_tvar, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(txt_16), a_varDecls);
17333 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("subtract_array_scalar<"));
17334 ✗ a_preExp := Tpl.writeText(a_preExp, l_type);
17335 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(">("));
17336 ✗ a_preExp := Tpl.writeText(a_preExp, a_e2);
17337 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
17338 ✗ a_preExp := Tpl.writeText(a_preExp, a_e1);
17339 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
17340 ✗ a_preExp := Tpl.writeText(a_preExp, l_tvar);
17341 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
17342 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
17343 ✗ txt := Tpl.writeText(txt, l_tvar);
17344 ✗ then (txt, a_preExp, a_varDecls);
17345
17346 case ( txt,
17347 DAE.MUL_SCALAR_PRODUCT(ty = i_ty),
17348 _,
17349 a_preExp,
17350 a_varDecls,
17351 _,
17352 _,
17353 a_e2,
17354 a_e1 )
17355 algorithm
17356 10 l_type := expTypeShort(Tpl.emptyTxt, i_ty);
17357 10 txt := Tpl.writeTok(txt, Tpl.ST_STRING("dot_array<"));
17358 10 txt := Tpl.writeText(txt, l_type);
17359 10 txt := Tpl.writeTok(txt, Tpl.ST_STRING(">("));
17360 10 txt := Tpl.writeText(txt, a_e1);
17361 10 txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
17362 10 txt := Tpl.writeText(txt, a_e2);
17363 10 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
17364 10 then (txt, a_preExp, a_varDecls);
17365
17366 case ( txt,
17367 DAE.POW_ARRAY_SCALAR(ty = DAE.T_ARRAY(dims = i_dims, ty = i_ty_ty)),
17368 _,
17369 a_preExp,
17370 a_varDecls,
17371 _,
17372 _,
17373 a_e2,
17374 a_e1 )
17375 algorithm
17376 1 txt_17 := expTypeArrayDims(Tpl.emptyTxt, i_ty_ty, i_dims);
17377 1 (l_tvar, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(txt_17), a_varDecls);
17378 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("pow_array_scalar("));
17379 1 a_preExp := Tpl.writeText(a_preExp, a_e1);
17380 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
17381 1 a_preExp := Tpl.writeText(a_preExp, a_e2);
17382 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(", "));
17383 1 a_preExp := Tpl.writeText(a_preExp, l_tvar);
17384 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
17385 1 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
17386 1 txt := Tpl.writeText(txt, l_tvar);
17387 1 then (txt, a_preExp, a_varDecls);
17388
17389 case ( txt,
17390 DAE.POW_SCALAR_ARRAY(ty = _),
17391 _,
17392 a_preExp,
17393 a_varDecls,
17394 _,
17395 _,
17396 _,
17397 _ )
17398 algorithm
17399 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("daeExpBinary:ERR POW_SCALAR_ARRAY not supported"));
17400 ✗ then (txt, a_preExp, a_varDecls);
17401
17402 case ( txt,
17403 DAE.POW_ARR(ty = _),
17404 _,
17405 a_preExp,
17406 a_varDecls,
17407 _,
17408 _,
17409 _,
17410 _ )
17411 algorithm
17412 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("daeExpBinary:ERR POW_ARR not supported"));
17413 ✗ then (txt, a_preExp, a_varDecls);
17414
17415 case ( txt,
17416 DAE.POW_ARR2(ty = _),
17417 _,
17418 a_preExp,
17419 a_varDecls,
17420 _,
17421 _,
17422 _,
17423 _ )
17424 algorithm
17425 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("daeExpBinary:ERR POW_ARR2 not supported"));
17426 ✗ then (txt, a_preExp, a_varDecls);
17427
17428 case ( txt,
17429 DAE.NOT(ty = _),
17430 _,
17431 a_preExp,
17432 a_varDecls,
17433 _,
17434 _,
17435 _,
17436 _ )
17437 algorithm
17438 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("daeExpBinary:ERR NOT not supported"));
17439 ✗ then (txt, a_preExp, a_varDecls);
17440
17441 case ( txt,
17442 DAE.LESS(ty = _),
17443 _,
17444 a_preExp,
17445 a_varDecls,
17446 _,
17447 _,
17448 _,
17449 _ )
17450 algorithm
17451 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("daeExpBinary:ERR LESS not supported"));
17452 ✗ then (txt, a_preExp, a_varDecls);
17453
17454 case ( txt,
17455 DAE.LESSEQ(ty = _),
17456 _,
17457 a_preExp,
17458 a_varDecls,
17459 _,
17460 _,
17461 _,
17462 _ )
17463 algorithm
17464 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("daeExpBinary:ERR LESSEQ not supported"));
17465 ✗ then (txt, a_preExp, a_varDecls);
17466
17467 case ( txt,
17468 DAE.GREATER(ty = _),
17469 _,
17470 a_preExp,
17471 a_varDecls,
17472 _,
17473 _,
17474 _,
17475 _ )
17476 algorithm
17477 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("daeExpBinary:ERR GREATER not supported"));
17478 ✗ then (txt, a_preExp, a_varDecls);
17479
17480 case ( txt,
17481 DAE.GREATEREQ(ty = _),
17482 _,
17483 a_preExp,
17484 a_varDecls,
17485 _,
17486 _,
17487 _,
17488 _ )
17489 algorithm
17490 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("daeExpBinary:ERR GREATEREQ not supported"));
17491 ✗ then (txt, a_preExp, a_varDecls);
17492
17493 case ( txt,
17494 DAE.EQUAL(ty = _),
17495 _,
17496 a_preExp,
17497 a_varDecls,
17498 _,
17499 _,
17500 _,
17501 _ )
17502 algorithm
17503 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("daeExpBinary:ERR EQUAL not supported"));
17504 ✗ then (txt, a_preExp, a_varDecls);
17505
17506 case ( txt,
17507 DAE.NEQUAL(ty = _),
17508 _,
17509 a_preExp,
17510 a_varDecls,
17511 _,
17512 _,
17513 _,
17514 _ )
17515 algorithm
17516 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("daeExpBinary:ERR NEQUAL not supported"));
17517 ✗ then (txt, a_preExp, a_varDecls);
17518
17519 case ( txt,
17520 DAE.USERDEFINED(fqName = _),
17521 _,
17522 a_preExp,
17523 a_varDecls,
17524 _,
17525 _,
17526 _,
17527 _ )
17528 algorithm
17529 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("daeExpBinary:ERR POW_ARR not supported"));
17530 ✗ then (txt, a_preExp, a_varDecls);
17531
17532 case ( txt,
17533 i_it,
17534 a_exp1,
17535 a_preExp,
17536 a_varDecls,
17537 _,
17538 a_exp2,
17539 _,
17540 _ )
17541 algorithm
17542 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("daeExpBinary:ERR "));
17543 ✗ txt := ExpressionDumpTpl.dumpExp(txt, a_exp1, "\"");
17544 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
17545 ✗ ret_18 := ExpressionDump.binopSymbol(i_it);
17546 ✗ txt := Tpl.writeStr(txt, ret_18);
17547 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
17548 ✗ txt := ExpressionDumpTpl.dumpExp(txt, a_exp2, "\"");
17549 ✗ then (txt, a_preExp, a_varDecls);
17550 end match;
17551 end fun_347;
17552
17553 public function daeExpBinary
17554 input Tpl.Text txt;
17555 input DAE.Operator a_it;
17556 input DAE.Exp a_exp1;
17557 input DAE.Exp a_exp2;
17558 input SimCodeFunction.Context a_context;
17559 input Tpl.Text a_preExp;
17560 input Tpl.Text a_varDecls;
17561 input SimCode.SimCode a_simCode;
17562 input Tpl.Text a_extraFuncs;
17563 input Tpl.Text a_extraFuncsDecl;
17564 input Tpl.Text a_extraFuncsNamespace;
17565 input Tpl.Text a_stateDerVectorName;
17566 input Boolean a_useFlatArrayNotation;
17567
17568 output Tpl.Text out_txt;
17569 output Tpl.Text out_a_preExp;
17570 output Tpl.Text out_a_varDecls;
17571 output Tpl.Text out_a_extraFuncs;
17572 output Tpl.Text out_a_extraFuncsDecl;
17573 output Tpl.Text out_a_extraFuncsNamespace;
17574 output Tpl.Text out_a_stateDerVectorName;
17575 protected
17576 Tpl.Text l_e2;
17577 Tpl.Text l_e1;
17578 algorithm
17579 52155 (l_e1, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) := daeExp(Tpl.emptyTxt, a_exp1, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
17580 52155 (l_e2, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) := daeExp(Tpl.emptyTxt, a_exp2, a_context, out_a_preExp, out_a_varDecls, a_simCode, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName, a_useFlatArrayNotation);
17581 52155 (out_txt, out_a_preExp, out_a_varDecls) := fun_347(txt, a_it, a_exp1, out_a_preExp, out_a_varDecls, a_context, a_exp2, l_e2, l_e1);
17582 end daeExpBinary;
17583
17584 public function daeExpSconst
17585 input Tpl.Text txt;
17586 input String a_string;
17587 input SimCodeFunction.Context a_context;
17588 input Tpl.Text a_preExp;
17589 input Tpl.Text a_varDecls;
17590 input SimCode.SimCode a_simCode;
17591 input Tpl.Text a_extraFuncs;
17592 input Tpl.Text a_extraFuncsDecl;
17593 input Tpl.Text a_extraFuncsNamespace;
17594 input Tpl.Text a_stateDerVectorName;
17595 input Boolean a_useFlatArrayNotation;
17596
17597 output Tpl.Text out_txt;
17598 output Tpl.Text out_a_preExp;
17599 output Tpl.Text out_a_varDecls;
17600 output Tpl.Text out_a_extraFuncs;
17601 output Tpl.Text out_a_extraFuncsDecl;
17602 output Tpl.Text out_a_extraFuncsNamespace;
17603 output Tpl.Text out_a_stateDerVectorName;
17604 protected
17605 String ret_0;
17606 algorithm
17607 1028 out_txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
17608 1028 ret_0 := Util.escapeModelicaStringToCString(a_string);
17609 1028 out_txt := Tpl.writeStr(out_txt, ret_0);
17610 1028 out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("\""));
17611 out_a_preExp := a_preExp;
17612 out_a_varDecls := a_varDecls;
17613 out_a_extraFuncs := a_extraFuncs;
17614 out_a_extraFuncsDecl := a_extraFuncsDecl;
17615 out_a_extraFuncsNamespace := a_extraFuncsNamespace;
17616 out_a_stateDerVectorName := a_stateDerVectorName;
17617 end daeExpSconst;
17618
17619 protected function lm_350
17620 input output Tpl.Text txt;
17621 input DAE.Dimensions items;
17622 algorithm
17623 ✗ for lstElt_350 in items loop
17624 txt := match lstElt_350
17625 local
17626 Integer i_i;
17627
17628 case DAE.DIM_INTEGER(integer = i_i)
17629 algorithm
17630 ✗ txt := Tpl.writeStr(txt, intString(i_i));
17631 ✗ txt := Tpl.nextIter(txt);
17632 then txt;
17633
17634 case _
17635 then txt;
17636 end match;
17637 end for;
17638 end lm_350;
17639
17640 protected function fun_351
17641 input Tpl.Text in_txt;
17642 input String in_mArg;
17643 input Tpl.Text in_a_dimensions;
17644 input Tpl.Text in_a_listlength;
17645
17646 output Tpl.Text out_txt;
17647 algorithm
17648 out_txt :=
17649 match(in_txt, in_mArg, in_a_dimensions, in_a_listlength)
17650 local
17651 Tpl.Text txt;
17652 Tpl.Text a_dimensions;
17653 Tpl.Text a_listlength;
17654
17655 case ( txt,
17656 "",
17657 _,
17658 a_listlength )
17659 algorithm
17660 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("DynArrayDim"));
17661 ✗ txt := Tpl.writeText(txt, a_listlength);
17662 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<double>"));
17663 then txt;
17664
17665 case ( txt,
17666 _,
17667 a_dimensions,
17668 a_listlength )
17669 algorithm
17670 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("StatArrayDim"));
17671 ✗ txt := Tpl.writeText(txt, a_listlength);
17672 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<double, "));
17673 ✗ txt := Tpl.writeText(txt, a_dimensions);
17674 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(">"));
17675 then txt;
17676 end match;
17677 end fun_351;
17678
17679 protected function fun_352
17680 input Tpl.Text in_txt;
17681 input DAE.Operator in_a_operator;
17682 input Tpl.Text in_a_preExp;
17683 input Tpl.Text in_a_varDecls;
17684 input Tpl.Text in_a_e;
17685
17686 output Tpl.Text out_txt;
17687 output Tpl.Text out_a_preExp;
17688 output Tpl.Text out_a_varDecls;
17689 algorithm
17690 (out_txt, out_a_preExp, out_a_varDecls) :=
17691 match(in_txt, in_a_operator, in_a_preExp, in_a_varDecls, in_a_e)
17692 local
17693 Tpl.Text txt;
17694 Tpl.Text a_preExp;
17695 Tpl.Text a_varDecls;
17696 Tpl.Text a_e;
17697 DAE.Dimensions i_ty_dims;
17698 Integer ret_6;
17699 Tpl.Text l_tvar;
17700 String str_4;
17701 Tpl.Text l_tmp__type__str;
17702 Integer ret_2;
17703 Tpl.Text l_listlength;
17704 Tpl.Text l_dimensions;
17705
17706 case ( txt,
17707 DAE.UMINUS(ty = _),
17708 a_preExp,
17709 a_varDecls,
17710 a_e )
17711 algorithm
17712 1314 txt := Tpl.writeTok(txt, Tpl.ST_STRING("(-"));
17713 1314 txt := Tpl.writeText(txt, a_e);
17714 1314 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
17715 1314 then (txt, a_preExp, a_varDecls);
17716
17717 case ( txt,
17718 DAE.UMINUS_ARR(ty = DAE.T_ARRAY(ty = DAE.T_REAL(varLst = _), dims = i_ty_dims)),
17719 a_preExp,
17720 a_varDecls,
17721 a_e )
17722 algorithm
17723 ✗ l_dimensions := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(",")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
17724 ✗ l_dimensions := lm_350(l_dimensions, i_ty_dims);
17725 ✗ l_dimensions := Tpl.popIter(l_dimensions);
17726 ✗ ret_2 := listLength(i_ty_dims);
17727 ✗ l_listlength := Tpl.writeStr(Tpl.emptyTxt, intString(ret_2));
17728 ✗ str_4 := Tpl.textString(l_dimensions);
17729 ✗ l_tmp__type__str := fun_351(Tpl.emptyTxt, str_4, l_dimensions, l_listlength);
17730 ✗ (l_tvar, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(l_tmp__type__str), a_varDecls);
17731 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("usub_array<double>("));
17732 ✗ a_preExp := Tpl.writeText(a_preExp, a_e);
17733 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(","));
17734 ✗ a_preExp := Tpl.writeText(a_preExp, l_tvar);
17735 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
17736 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
17737 ✗ txt := Tpl.writeText(txt, l_tvar);
17738 ✗ then (txt, a_preExp, a_varDecls);
17739
17740 case ( txt,
17741 DAE.UMINUS_ARR(ty = DAE.T_ARRAY(ty = DAE.T_INTEGER(varLst = _), dims = i_ty_dims)),
17742 a_preExp,
17743 a_varDecls,
17744 a_e )
17745 algorithm
17746 ✗ l_tmp__type__str := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("multi_array<int,"));
17747 ✗ ret_6 := listLength(i_ty_dims);
17748 ✗ l_tmp__type__str := Tpl.writeStr(l_tmp__type__str, intString(ret_6));
17749 ✗ l_tmp__type__str := Tpl.writeTok(l_tmp__type__str, Tpl.ST_STRING(">/*multi3*/"));
17750 ✗ (l_tvar, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(l_tmp__type__str), a_varDecls);
17751 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING("usub_array<int>("));
17752 ✗ a_preExp := Tpl.writeText(a_preExp, a_e);
17753 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(","));
17754 ✗ a_preExp := Tpl.writeText(a_preExp, l_tvar);
17755 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(");"));
17756 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
17757 ✗ txt := Tpl.writeText(txt, l_tvar);
17758 ✗ then (txt, a_preExp, a_varDecls);
17759
17760 case ( txt,
17761 DAE.UMINUS_ARR(ty = _),
17762 a_preExp,
17763 a_varDecls,
17764 _ )
17765 algorithm
17766 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("unary minus for non-real arrays not implemented"));
17767 ✗ then (txt, a_preExp, a_varDecls);
17768
17769 case ( txt,
17770 _,
17771 a_preExp,
17772 a_varDecls,
17773 _ )
17774 algorithm
17775 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("daeExpUnary:ERR"));
17776 ✗ then (txt, a_preExp, a_varDecls);
17777 end match;
17778 end fun_352;
17779
17780 public function daeExpUnary
17781 input Tpl.Text in_txt;
17782 input DAE.Exp in_a_exp;
17783 input SimCodeFunction.Context in_a_context;
17784 input Tpl.Text in_a_preExp;
17785 input Tpl.Text in_a_varDecls;
17786 input SimCode.SimCode in_a_simCode;
17787 input Tpl.Text in_a_extraFuncs;
17788 input Tpl.Text in_a_extraFuncsDecl;
17789 input Tpl.Text in_a_extraFuncsNamespace;
17790 input Tpl.Text in_a_stateDerVectorName;
17791 input Boolean in_a_useFlatArrayNotation;
17792
17793 output Tpl.Text out_txt;
17794 output Tpl.Text out_a_preExp;
17795 output Tpl.Text out_a_varDecls;
17796 output Tpl.Text out_a_extraFuncs;
17797 output Tpl.Text out_a_extraFuncsDecl;
17798 output Tpl.Text out_a_extraFuncsNamespace;
17799 output Tpl.Text out_a_stateDerVectorName;
17800 algorithm
17801 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
17802 match(in_txt, in_a_exp, in_a_context, in_a_preExp, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
17803 local
17804 Tpl.Text txt;
17805 SimCodeFunction.Context a_context;
17806 Tpl.Text a_preExp;
17807 Tpl.Text a_varDecls;
17808 SimCode.SimCode a_simCode;
17809 Tpl.Text a_extraFuncs;
17810 Tpl.Text a_extraFuncsDecl;
17811 Tpl.Text a_extraFuncsNamespace;
17812 Tpl.Text a_stateDerVectorName;
17813 Boolean a_useFlatArrayNotation;
17814 DAE.Operator i_operator;
17815 DAE.Exp i_exp;
17816 Tpl.Text l_e;
17817
17818 case ( txt,
17819 DAE.UNARY(exp = i_exp, operator = i_operator),
17820 a_context,
17821 a_preExp,
17822 a_varDecls,
17823 a_simCode,
17824 a_extraFuncs,
17825 a_extraFuncsDecl,
17826 a_extraFuncsNamespace,
17827 a_stateDerVectorName,
17828 a_useFlatArrayNotation )
17829 algorithm
17830 1314 (l_e, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
17831 1314 (txt, a_preExp, a_varDecls) := fun_352(txt, i_operator, a_preExp, a_varDecls, l_e);
17832 1314 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
17833
17834 case ( txt,
17835 _,
17836 _,
17837 a_preExp,
17838 a_varDecls,
17839 _,
17840 a_extraFuncs,
17841 a_extraFuncsDecl,
17842 a_extraFuncsNamespace,
17843 a_stateDerVectorName,
17844 _ )
17845 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
17846 end match;
17847 end daeExpUnary;
17848
17849 protected function fun_354
17850 input Tpl.Text in_txt;
17851 input DAE.Operator in_a_rel_operator;
17852 input Tpl.Text in_a_e2;
17853 input Tpl.Text in_a_e1;
17854 input Integer in_a_rel_index;
17855
17856 output Tpl.Text out_txt;
17857 algorithm
17858 out_txt :=
17859 match(in_txt, in_a_rel_operator, in_a_e2, in_a_e1, in_a_rel_index)
17860 local
17861 Tpl.Text txt;
17862 Tpl.Text a_e2;
17863 Tpl.Text a_e1;
17864 Integer a_rel_index;
17865
17866 case ( txt,
17867 DAE.LESS(ty = _),
17868 a_e2,
17869 a_e1,
17870 a_rel_index )
17871 algorithm
17872 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_system->getCondition("));
17873 ✗ txt := Tpl.writeStr(txt, intString(a_rel_index));
17874 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(") && ("));
17875 ✗ txt := Tpl.writeText(txt, a_e1);
17876 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" < "));
17877 ✗ txt := Tpl.writeText(txt, a_e2);
17878 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
17879 then txt;
17880
17881 case ( txt,
17882 DAE.LESSEQ(ty = _),
17883 a_e2,
17884 a_e1,
17885 a_rel_index )
17886 algorithm
17887 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_system->getCondition("));
17888 ✗ txt := Tpl.writeStr(txt, intString(a_rel_index));
17889 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(") && ("));
17890 ✗ txt := Tpl.writeText(txt, a_e1);
17891 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" <= "));
17892 ✗ txt := Tpl.writeText(txt, a_e2);
17893 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
17894 then txt;
17895
17896 case ( txt,
17897 DAE.GREATER(ty = _),
17898 a_e2,
17899 a_e1,
17900 a_rel_index )
17901 algorithm
17902 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_system->getCondition("));
17903 ✗ txt := Tpl.writeStr(txt, intString(a_rel_index));
17904 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(") && ("));
17905 ✗ txt := Tpl.writeText(txt, a_e1);
17906 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" > "));
17907 ✗ txt := Tpl.writeText(txt, a_e2);
17908 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
17909 then txt;
17910
17911 case ( txt,
17912 DAE.GREATEREQ(ty = _),
17913 a_e2,
17914 a_e1,
17915 a_rel_index )
17916 algorithm
17917 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_system->getCondition("));
17918 ✗ txt := Tpl.writeStr(txt, intString(a_rel_index));
17919 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(") && ("));
17920 ✗ txt := Tpl.writeText(txt, a_e1);
17921 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" >= "));
17922 ✗ txt := Tpl.writeText(txt, a_e2);
17923 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
17924 then txt;
17925
17926 case ( txt,
17927 _,
17928 _,
17929 _,
17930 _ )
17931 then txt;
17932 end match;
17933 end fun_354;
17934
17935 protected function fun_355
17936 input Tpl.Text in_txt;
17937 input DAE.Operator in_a_rel_operator;
17938 input Tpl.Text in_a_e2;
17939 input Tpl.Text in_a_e1;
17940
17941 output Tpl.Text out_txt;
17942 algorithm
17943 out_txt :=
17944 match(in_txt, in_a_rel_operator, in_a_e2, in_a_e1)
17945 local
17946 Tpl.Text txt;
17947 Tpl.Text a_e2;
17948 Tpl.Text a_e1;
17949
17950 case ( txt,
17951 DAE.LESS(ty = _),
17952 a_e2,
17953 a_e1 )
17954 algorithm
17955 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
17956 ✗ txt := Tpl.writeText(txt, a_e1);
17957 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" < "));
17958 ✗ txt := Tpl.writeText(txt, a_e2);
17959 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
17960 then txt;
17961
17962 case ( txt,
17963 DAE.LESSEQ(ty = _),
17964 a_e2,
17965 a_e1 )
17966 algorithm
17967 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
17968 ✗ txt := Tpl.writeText(txt, a_e1);
17969 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" <= "));
17970 ✗ txt := Tpl.writeText(txt, a_e2);
17971 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
17972 then txt;
17973
17974 case ( txt,
17975 DAE.GREATER(ty = _),
17976 a_e2,
17977 a_e1 )
17978 algorithm
17979 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
17980 ✗ txt := Tpl.writeText(txt, a_e1);
17981 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" > "));
17982 ✗ txt := Tpl.writeText(txt, a_e2);
17983 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
17984 then txt;
17985
17986 case ( txt,
17987 DAE.GREATEREQ(ty = _),
17988 a_e2,
17989 a_e1 )
17990 algorithm
17991 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
17992 ✗ txt := Tpl.writeText(txt, a_e1);
17993 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" >= "));
17994 ✗ txt := Tpl.writeText(txt, a_e2);
17995 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
17996 then txt;
17997
17998 case ( txt,
17999 _,
18000 _,
18001 _ )
18002 then txt;
18003 end match;
18004 end fun_355;
18005
18006 protected function fun_356
18007 input Tpl.Text in_txt;
18008 input SimCodeFunction.Context in_a_context;
18009 input Tpl.Text in_a_e2;
18010 input Tpl.Text in_a_e1;
18011 input Integer in_a_rel_index;
18012 input DAE.Operator in_a_rel_operator;
18013
18014 output Tpl.Text out_txt;
18015 algorithm
18016 out_txt :=
18017 match(in_txt, in_a_context, in_a_e2, in_a_e1, in_a_rel_index, in_a_rel_operator)
18018 local
18019 Tpl.Text txt;
18020 Tpl.Text a_e2;
18021 Tpl.Text a_e1;
18022 Integer a_rel_index;
18023 DAE.Operator a_rel_operator;
18024
18025 case ( txt,
18026 SimCodeFunction.ALGLOOP_CONTEXT(genInitialisation = false),
18027 a_e2,
18028 a_e1,
18029 a_rel_index,
18030 a_rel_operator )
18031 algorithm
18032 ✗ txt := fun_354(txt, a_rel_operator, a_e2, a_e1, a_rel_index);
18033 then txt;
18034
18035 case ( txt,
18036 _,
18037 a_e2,
18038 a_e1,
18039 _,
18040 a_rel_operator )
18041 algorithm
18042 ✗ txt := fun_355(txt, a_rel_operator, a_e2, a_e1);
18043 then txt;
18044 end match;
18045 end fun_356;
18046
18047 protected function fun_357
18048 input Tpl.Text in_txt;
18049 input Option<tuple<DAE.Exp, Integer, Integer>> in_a_rel_optionExpisASUB;
18050 input Boolean in_a_useFlatArrayNotation;
18051 input Tpl.Text in_a_stateDerVectorName;
18052 input Tpl.Text in_a_extraFuncsNamespace;
18053 input Tpl.Text in_a_extraFuncsDecl;
18054 input Tpl.Text in_a_extraFuncs;
18055 input SimCode.SimCode in_a_simCode;
18056 input Tpl.Text in_a_varDecls;
18057 input Tpl.Text in_a_preExp;
18058 input SimCodeFunction.Context in_a_context;
18059 input DAE.Exp in_a_rel_exp2;
18060 input DAE.Exp in_a_rel_exp1;
18061 input Integer in_a_rel_index;
18062 input DAE.Operator in_a_rel_operator;
18063
18064 output Tpl.Text out_txt;
18065 output Tpl.Text out_a_stateDerVectorName;
18066 output Tpl.Text out_a_extraFuncsNamespace;
18067 output Tpl.Text out_a_extraFuncsDecl;
18068 output Tpl.Text out_a_extraFuncs;
18069 output Tpl.Text out_a_varDecls;
18070 output Tpl.Text out_a_preExp;
18071 algorithm
18072 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls, out_a_preExp) :=
18073 match(in_txt, in_a_rel_optionExpisASUB, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_varDecls, in_a_preExp, in_a_context, in_a_rel_exp2, in_a_rel_exp1, in_a_rel_index, in_a_rel_operator)
18074 local
18075 Tpl.Text txt;
18076 Boolean a_useFlatArrayNotation;
18077 Tpl.Text a_stateDerVectorName;
18078 Tpl.Text a_extraFuncsNamespace;
18079 Tpl.Text a_extraFuncsDecl;
18080 Tpl.Text a_extraFuncs;
18081 SimCode.SimCode a_simCode;
18082 Tpl.Text a_varDecls;
18083 Tpl.Text a_preExp;
18084 SimCodeFunction.Context a_context;
18085 DAE.Exp a_rel_exp2;
18086 DAE.Exp a_rel_exp1;
18087 Integer a_rel_index;
18088 DAE.Operator a_rel_operator;
18089 Tpl.Text l_e2;
18090 Tpl.Text l_e1;
18091
18092 case ( txt,
18093 NONE(),
18094 a_useFlatArrayNotation,
18095 a_stateDerVectorName,
18096 a_extraFuncsNamespace,
18097 a_extraFuncsDecl,
18098 a_extraFuncs,
18099 a_simCode,
18100 a_varDecls,
18101 a_preExp,
18102 a_context,
18103 a_rel_exp2,
18104 a_rel_exp1,
18105 a_rel_index,
18106 a_rel_operator )
18107 algorithm
18108 2730 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpRelation2(txt, a_rel_operator, a_rel_index, a_rel_exp1, a_rel_exp2, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
18109 2730 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
18110
18111 case ( txt,
18112 SOME((_, _, _)),
18113 a_useFlatArrayNotation,
18114 a_stateDerVectorName,
18115 a_extraFuncsNamespace,
18116 a_extraFuncsDecl,
18117 a_extraFuncs,
18118 a_simCode,
18119 a_varDecls,
18120 a_preExp,
18121 a_context,
18122 a_rel_exp2,
18123 a_rel_exp1,
18124 a_rel_index,
18125 a_rel_operator )
18126 algorithm
18127 ✗ (l_e1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, a_rel_exp1, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
18128 ✗ (l_e2, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, a_rel_exp2, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
18129 ✗ txt := fun_356(txt, a_context, l_e2, l_e1, a_rel_index, a_rel_operator);
18130 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
18131
18132 case ( txt,
18133 _,
18134 _,
18135 a_stateDerVectorName,
18136 a_extraFuncsNamespace,
18137 a_extraFuncsDecl,
18138 a_extraFuncs,
18139 _,
18140 a_varDecls,
18141 a_preExp,
18142 _,
18143 _,
18144 _,
18145 _,
18146 _ )
18147 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
18148 end match;
18149 end fun_357;
18150
18151 public function daeExpRelation
18152 input Tpl.Text in_txt;
18153 input DAE.Exp in_a_exp;
18154 input SimCodeFunction.Context in_a_context;
18155 input Tpl.Text in_a_preExp;
18156 input Tpl.Text in_a_varDecls;
18157 input SimCode.SimCode in_a_simCode;
18158 input Tpl.Text in_a_extraFuncs;
18159 input Tpl.Text in_a_extraFuncsDecl;
18160 input Tpl.Text in_a_extraFuncsNamespace;
18161 input Tpl.Text in_a_stateDerVectorName;
18162 input Boolean in_a_useFlatArrayNotation;
18163
18164 output Tpl.Text out_txt;
18165 output Tpl.Text out_a_preExp;
18166 output Tpl.Text out_a_varDecls;
18167 output Tpl.Text out_a_extraFuncs;
18168 output Tpl.Text out_a_extraFuncsDecl;
18169 output Tpl.Text out_a_extraFuncsNamespace;
18170 output Tpl.Text out_a_stateDerVectorName;
18171 algorithm
18172 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
18173 match(in_txt, in_a_exp, in_a_context, in_a_preExp, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
18174 local
18175 Tpl.Text txt;
18176 SimCodeFunction.Context a_context;
18177 Tpl.Text a_preExp;
18178 Tpl.Text a_varDecls;
18179 SimCode.SimCode a_simCode;
18180 Tpl.Text a_extraFuncs;
18181 Tpl.Text a_extraFuncsDecl;
18182 Tpl.Text a_extraFuncsNamespace;
18183 Tpl.Text a_stateDerVectorName;
18184 Boolean a_useFlatArrayNotation;
18185 DAE.Exp i_rel_exp2;
18186 DAE.Exp i_rel_exp1;
18187 Integer i_rel_index;
18188 DAE.Operator i_rel_operator;
18189 Option<tuple<DAE.Exp, Integer, Integer>> i_rel_optionExpisASUB;
18190
18191 case ( txt,
18192 DAE.RELATION(optionExpisASUB = i_rel_optionExpisASUB, operator = i_rel_operator, index = i_rel_index, exp1 = i_rel_exp1, exp2 = i_rel_exp2),
18193 a_context,
18194 a_preExp,
18195 a_varDecls,
18196 a_simCode,
18197 a_extraFuncs,
18198 a_extraFuncsDecl,
18199 a_extraFuncsNamespace,
18200 a_stateDerVectorName,
18201 a_useFlatArrayNotation )
18202 algorithm
18203 2730 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := fun_357(txt, i_rel_optionExpisASUB, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context, i_rel_exp2, i_rel_exp1, i_rel_index, i_rel_operator);
18204 2730 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
18205
18206 case ( txt,
18207 _,
18208 _,
18209 a_preExp,
18210 a_varDecls,
18211 _,
18212 a_extraFuncs,
18213 a_extraFuncsDecl,
18214 a_extraFuncsNamespace,
18215 a_stateDerVectorName,
18216 _ )
18217 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
18218 end match;
18219 end daeExpRelation;
18220
18221 public function daeExpRelation3
18222 input Tpl.Text in_txt;
18223 input SimCodeFunction.Context in_a_context;
18224 input Integer in_a_index;
18225
18226 output Tpl.Text out_txt;
18227 algorithm
18228 out_txt :=
18229 match(in_txt, in_a_context, in_a_index)
18230 local
18231 Tpl.Text txt;
18232 Integer a_index;
18233
18234 case ( txt,
18235 SimCodeFunction.ALGLOOP_CONTEXT(genInitialisation = false),
18236 a_index )
18237 algorithm
18238 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_system->getCondition("));
18239 ✗ txt := Tpl.writeStr(txt, intString(a_index));
18240 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
18241 then txt;
18242
18243 case ( txt,
18244 _,
18245 a_index )
18246 algorithm
18247 113 txt := Tpl.writeTok(txt, Tpl.ST_STRING("getCondition("));
18248 113 txt := Tpl.writeStr(txt, intString(a_index));
18249 113 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
18250 then txt;
18251 end match;
18252 end daeExpRelation3;
18253
18254 protected function fun_360
18255 input Tpl.Text in_txt;
18256 input DAE.Operator in_a_op;
18257 input Tpl.Text in_a_e2;
18258 input Tpl.Text in_a_e1;
18259
18260 output Tpl.Text out_txt;
18261 algorithm
18262 out_txt :=
18263 match(in_txt, in_a_op, in_a_e2, in_a_e1)
18264 local
18265 Tpl.Text txt;
18266 Tpl.Text a_e2;
18267 Tpl.Text a_e1;
18268
18269 case ( txt,
18270 DAE.LESS(ty = DAE.T_BOOL(varLst = _)),
18271 a_e2,
18272 a_e1 )
18273 algorithm
18274 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("(!"));
18275 ✗ txt := Tpl.writeText(txt, a_e1);
18276 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" && "));
18277 ✗ txt := Tpl.writeText(txt, a_e2);
18278 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
18279 then txt;
18280
18281 case ( txt,
18282 DAE.LESS(ty = DAE.T_STRING(varLst = _)),
18283 _,
18284 _ )
18285 algorithm
18286 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("# string comparison not supported\n"));
18287 then txt;
18288
18289 case ( txt,
18290 DAE.LESS(ty = DAE.T_INTEGER(varLst = _)),
18291 a_e2,
18292 a_e1 )
18293 algorithm
18294 9 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
18295 9 txt := Tpl.writeText(txt, a_e1);
18296 9 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" < "));
18297 9 txt := Tpl.writeText(txt, a_e2);
18298 9 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
18299 then txt;
18300
18301 case ( txt,
18302 DAE.LESS(ty = DAE.T_REAL(varLst = _)),
18303 a_e2,
18304 a_e1 )
18305 algorithm
18306 291 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
18307 291 txt := Tpl.writeText(txt, a_e1);
18308 291 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" < "));
18309 291 txt := Tpl.writeText(txt, a_e2);
18310 291 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
18311 then txt;
18312
18313 case ( txt,
18314 DAE.LESS(ty = DAE.T_ENUMERATION(index = _)),
18315 a_e2,
18316 a_e1 )
18317 algorithm
18318 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
18319 ✗ txt := Tpl.writeText(txt, a_e1);
18320 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" < "));
18321 ✗ txt := Tpl.writeText(txt, a_e2);
18322 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
18323 then txt;
18324
18325 case ( txt,
18326 DAE.GREATER(ty = DAE.T_BOOL(varLst = _)),
18327 a_e2,
18328 a_e1 )
18329 algorithm
18330 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
18331 ✗ txt := Tpl.writeText(txt, a_e1);
18332 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" && !"));
18333 ✗ txt := Tpl.writeText(txt, a_e2);
18334 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
18335 then txt;
18336
18337 case ( txt,
18338 DAE.GREATER(ty = DAE.T_STRING(varLst = _)),
18339 _,
18340 _ )
18341 algorithm
18342 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("# string comparison not supported\n"));
18343 then txt;
18344
18345 case ( txt,
18346 DAE.GREATER(ty = DAE.T_INTEGER(varLst = _)),
18347 a_e2,
18348 a_e1 )
18349 algorithm
18350 21 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
18351 21 txt := Tpl.writeText(txt, a_e1);
18352 21 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" > "));
18353 21 txt := Tpl.writeText(txt, a_e2);
18354 21 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
18355 then txt;
18356
18357 case ( txt,
18358 DAE.GREATER(ty = DAE.T_REAL(varLst = _)),
18359 a_e2,
18360 a_e1 )
18361 algorithm
18362 343 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
18363 343 txt := Tpl.writeText(txt, a_e1);
18364 343 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" > "));
18365 343 txt := Tpl.writeText(txt, a_e2);
18366 343 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
18367 then txt;
18368
18369 case ( txt,
18370 DAE.GREATER(ty = DAE.T_ENUMERATION(index = _)),
18371 a_e2,
18372 a_e1 )
18373 algorithm
18374 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
18375 ✗ txt := Tpl.writeText(txt, a_e1);
18376 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" > "));
18377 ✗ txt := Tpl.writeText(txt, a_e2);
18378 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
18379 then txt;
18380
18381 case ( txt,
18382 DAE.LESSEQ(ty = DAE.T_BOOL(varLst = _)),
18383 a_e2,
18384 a_e1 )
18385 algorithm
18386 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("(!"));
18387 ✗ txt := Tpl.writeText(txt, a_e1);
18388 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" || "));
18389 ✗ txt := Tpl.writeText(txt, a_e2);
18390 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
18391 then txt;
18392
18393 case ( txt,
18394 DAE.LESSEQ(ty = DAE.T_STRING(varLst = _)),
18395 _,
18396 _ )
18397 algorithm
18398 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("# string comparison not supported\n"));
18399 then txt;
18400
18401 case ( txt,
18402 DAE.LESSEQ(ty = DAE.T_INTEGER(varLst = _)),
18403 a_e2,
18404 a_e1 )
18405 algorithm
18406 38 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
18407 38 txt := Tpl.writeText(txt, a_e1);
18408 38 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" <= "));
18409 38 txt := Tpl.writeText(txt, a_e2);
18410 38 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
18411 then txt;
18412
18413 case ( txt,
18414 DAE.LESSEQ(ty = DAE.T_REAL(varLst = _)),
18415 a_e2,
18416 a_e1 )
18417 algorithm
18418 299 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
18419 299 txt := Tpl.writeText(txt, a_e1);
18420 299 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" <= "));
18421 299 txt := Tpl.writeText(txt, a_e2);
18422 299 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
18423 then txt;
18424
18425 case ( txt,
18426 DAE.LESSEQ(ty = DAE.T_ENUMERATION(index = _)),
18427 a_e2,
18428 a_e1 )
18429 algorithm
18430 96 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
18431 96 txt := Tpl.writeText(txt, a_e1);
18432 96 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" <= "));
18433 96 txt := Tpl.writeText(txt, a_e2);
18434 96 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
18435 then txt;
18436
18437 case ( txt,
18438 DAE.GREATEREQ(ty = DAE.T_BOOL(varLst = _)),
18439 a_e2,
18440 a_e1 )
18441 algorithm
18442 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
18443 ✗ txt := Tpl.writeText(txt, a_e1);
18444 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" || !"));
18445 ✗ txt := Tpl.writeText(txt, a_e2);
18446 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
18447 then txt;
18448
18449 case ( txt,
18450 DAE.GREATEREQ(ty = DAE.T_STRING(varLst = _)),
18451 _,
18452 _ )
18453 algorithm
18454 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("# string comparison not supported\n"));
18455 then txt;
18456
18457 case ( txt,
18458 DAE.GREATEREQ(ty = DAE.T_INTEGER(varLst = _)),
18459 a_e2,
18460 a_e1 )
18461 algorithm
18462 163 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
18463 163 txt := Tpl.writeText(txt, a_e1);
18464 163 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" >= "));
18465 163 txt := Tpl.writeText(txt, a_e2);
18466 163 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
18467 then txt;
18468
18469 case ( txt,
18470 DAE.GREATEREQ(ty = DAE.T_REAL(varLst = _)),
18471 a_e2,
18472 a_e1 )
18473 algorithm
18474 874 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
18475 874 txt := Tpl.writeText(txt, a_e1);
18476 874 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" >= "));
18477 874 txt := Tpl.writeText(txt, a_e2);
18478 874 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
18479 then txt;
18480
18481 case ( txt,
18482 DAE.GREATEREQ(ty = DAE.T_ENUMERATION(index = _)),
18483 a_e2,
18484 a_e1 )
18485 algorithm
18486 96 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
18487 96 txt := Tpl.writeText(txt, a_e1);
18488 96 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" >= "));
18489 96 txt := Tpl.writeText(txt, a_e2);
18490 96 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
18491 then txt;
18492
18493 case ( txt,
18494 DAE.EQUAL(ty = DAE.T_BOOL(varLst = _)),
18495 a_e2,
18496 a_e1 )
18497 algorithm
18498 18 txt := Tpl.writeTok(txt, Tpl.ST_STRING("((!"));
18499 18 txt := Tpl.writeText(txt, a_e1);
18500 18 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" && !"));
18501 18 txt := Tpl.writeText(txt, a_e2);
18502 18 txt := Tpl.writeTok(txt, Tpl.ST_STRING(") || ("));
18503 18 txt := Tpl.writeText(txt, a_e1);
18504 18 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" && "));
18505 18 txt := Tpl.writeText(txt, a_e2);
18506 18 txt := Tpl.writeTok(txt, Tpl.ST_STRING("))"));
18507 then txt;
18508
18509 case ( txt,
18510 DAE.EQUAL(ty = DAE.T_STRING(varLst = _)),
18511 a_e2,
18512 a_e1 )
18513 algorithm
18514 24 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
18515 24 txt := Tpl.writeText(txt, a_e1);
18516 24 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" == "));
18517 24 txt := Tpl.writeText(txt, a_e2);
18518 24 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
18519 then txt;
18520
18521 case ( txt,
18522 DAE.EQUAL(ty = DAE.T_INTEGER(varLst = _)),
18523 a_e2,
18524 a_e1 )
18525 algorithm
18526 134 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
18527 134 txt := Tpl.writeText(txt, a_e1);
18528 134 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" == "));
18529 134 txt := Tpl.writeText(txt, a_e2);
18530 134 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
18531 then txt;
18532
18533 case ( txt,
18534 DAE.EQUAL(ty = DAE.T_REAL(varLst = _)),
18535 a_e2,
18536 a_e1 )
18537 algorithm
18538 14 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
18539 14 txt := Tpl.writeText(txt, a_e1);
18540 14 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" == "));
18541 14 txt := Tpl.writeText(txt, a_e2);
18542 14 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
18543 then txt;
18544
18545 case ( txt,
18546 DAE.EQUAL(ty = DAE.T_ENUMERATION(index = _)),
18547 a_e2,
18548 a_e1 )
18549 algorithm
18550 75 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
18551 75 txt := Tpl.writeText(txt, a_e1);
18552 75 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" == "));
18553 75 txt := Tpl.writeText(txt, a_e2);
18554 75 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
18555 then txt;
18556
18557 case ( txt,
18558 DAE.NEQUAL(ty = DAE.T_BOOL(varLst = _)),
18559 a_e2,
18560 a_e1 )
18561 algorithm
18562 4 txt := Tpl.writeTok(txt, Tpl.ST_STRING("((!"));
18563 4 txt := Tpl.writeText(txt, a_e1);
18564 4 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" && "));
18565 4 txt := Tpl.writeText(txt, a_e2);
18566 4 txt := Tpl.writeTok(txt, Tpl.ST_STRING(") || ("));
18567 4 txt := Tpl.writeText(txt, a_e1);
18568 4 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" && !"));
18569 4 txt := Tpl.writeText(txt, a_e2);
18570 4 txt := Tpl.writeTok(txt, Tpl.ST_STRING("))"));
18571 then txt;
18572
18573 case ( txt,
18574 DAE.NEQUAL(ty = DAE.T_STRING(varLst = _)),
18575 a_e2,
18576 a_e1 )
18577 algorithm
18578 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
18579 ✗ txt := Tpl.writeText(txt, a_e1);
18580 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" != "));
18581 ✗ txt := Tpl.writeText(txt, a_e2);
18582 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
18583 then txt;
18584
18585 case ( txt,
18586 DAE.NEQUAL(ty = DAE.T_INTEGER(varLst = _)),
18587 a_e2,
18588 a_e1 )
18589 algorithm
18590 18 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
18591 18 txt := Tpl.writeText(txt, a_e1);
18592 18 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" != "));
18593 18 txt := Tpl.writeText(txt, a_e2);
18594 18 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
18595 then txt;
18596
18597 case ( txt,
18598 DAE.NEQUAL(ty = DAE.T_REAL(varLst = _)),
18599 a_e2,
18600 a_e1 )
18601 algorithm
18602 100 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
18603 100 txt := Tpl.writeText(txt, a_e1);
18604 100 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" != "));
18605 100 txt := Tpl.writeText(txt, a_e2);
18606 100 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
18607 then txt;
18608
18609 case ( txt,
18610 DAE.NEQUAL(ty = DAE.T_ENUMERATION(index = _)),
18611 a_e2,
18612 a_e1 )
18613 algorithm
18614 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
18615 ✗ txt := Tpl.writeText(txt, a_e1);
18616 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" != "));
18617 ✗ txt := Tpl.writeText(txt, a_e2);
18618 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
18619 then txt;
18620
18621 case ( txt,
18622 _,
18623 _,
18624 _ )
18625 algorithm
18626 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("daeExpRelation:ERR"));
18627 then txt;
18628 end match;
18629 end fun_360;
18630
18631 protected function fun_361
18632 input Tpl.Text in_txt;
18633 input DAE.Operator in_a_op;
18634 input Integer in_a_index;
18635 input SimCodeFunction.Context in_a_context;
18636
18637 output Tpl.Text out_txt;
18638 algorithm
18639 out_txt :=
18640 match(in_txt, in_a_op, in_a_index, in_a_context)
18641 local
18642 Tpl.Text txt;
18643 Integer a_index;
18644 SimCodeFunction.Context a_context;
18645
18646 case ( txt,
18647 DAE.LESS(ty = DAE.T_BOOL(varLst = _)),
18648 a_index,
18649 a_context )
18650 algorithm
18651 ✗ txt := daeExpRelation3(txt, a_context, a_index);
18652 then txt;
18653
18654 case ( txt,
18655 DAE.LESS(ty = DAE.T_STRING(varLst = _)),
18656 _,
18657 _ )
18658 algorithm
18659 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("# string comparison not supported\n"));
18660 then txt;
18661
18662 case ( txt,
18663 DAE.LESS(ty = DAE.T_INTEGER(varLst = _)),
18664 a_index,
18665 a_context )
18666 algorithm
18667 ✗ txt := daeExpRelation3(txt, a_context, a_index);
18668 then txt;
18669
18670 case ( txt,
18671 DAE.LESS(ty = DAE.T_REAL(varLst = _)),
18672 a_index,
18673 a_context )
18674 algorithm
18675 48 txt := daeExpRelation3(txt, a_context, a_index);
18676 then txt;
18677
18678 case ( txt,
18679 DAE.GREATER(ty = DAE.T_BOOL(varLst = _)),
18680 a_index,
18681 a_context )
18682 algorithm
18683 ✗ txt := daeExpRelation3(txt, a_context, a_index);
18684 then txt;
18685
18686 case ( txt,
18687 DAE.GREATER(ty = DAE.T_STRING(varLst = _)),
18688 _,
18689 _ )
18690 algorithm
18691 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("# string comparison not supported\n"));
18692 then txt;
18693
18694 case ( txt,
18695 DAE.GREATER(ty = DAE.T_INTEGER(varLst = _)),
18696 a_index,
18697 a_context )
18698 algorithm
18699 ✗ txt := daeExpRelation3(txt, a_context, a_index);
18700 then txt;
18701
18702 case ( txt,
18703 DAE.GREATER(ty = DAE.T_REAL(varLst = _)),
18704 a_index,
18705 a_context )
18706 algorithm
18707 9 txt := daeExpRelation3(txt, a_context, a_index);
18708 then txt;
18709
18710 case ( txt,
18711 DAE.LESSEQ(ty = DAE.T_BOOL(varLst = _)),
18712 a_index,
18713 a_context )
18714 algorithm
18715 ✗ txt := daeExpRelation3(txt, a_context, a_index);
18716 then txt;
18717
18718 case ( txt,
18719 DAE.LESSEQ(ty = DAE.T_STRING(varLst = _)),
18720 _,
18721 _ )
18722 algorithm
18723 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("# string comparison not supported\n"));
18724 then txt;
18725
18726 case ( txt,
18727 DAE.LESSEQ(ty = DAE.T_INTEGER(varLst = _)),
18728 a_index,
18729 a_context )
18730 algorithm
18731 ✗ txt := daeExpRelation3(txt, a_context, a_index);
18732 then txt;
18733
18734 case ( txt,
18735 DAE.LESSEQ(ty = DAE.T_REAL(varLst = _)),
18736 a_index,
18737 a_context )
18738 algorithm
18739 4 txt := daeExpRelation3(txt, a_context, a_index);
18740 then txt;
18741
18742 case ( txt,
18743 DAE.GREATEREQ(ty = DAE.T_BOOL(varLst = _)),
18744 a_index,
18745 a_context )
18746 algorithm
18747 ✗ txt := daeExpRelation3(txt, a_context, a_index);
18748 then txt;
18749
18750 case ( txt,
18751 DAE.GREATEREQ(ty = DAE.T_STRING(varLst = _)),
18752 _,
18753 _ )
18754 algorithm
18755 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("# string comparison not supported\n"));
18756 then txt;
18757
18758 case ( txt,
18759 DAE.GREATEREQ(ty = DAE.T_INTEGER(varLst = _)),
18760 a_index,
18761 a_context )
18762 algorithm
18763 ✗ txt := daeExpRelation3(txt, a_context, a_index);
18764 then txt;
18765
18766 case ( txt,
18767 DAE.GREATEREQ(ty = DAE.T_REAL(varLst = _)),
18768 a_index,
18769 a_context )
18770 algorithm
18771 52 txt := daeExpRelation3(txt, a_context, a_index);
18772 then txt;
18773
18774 case ( txt,
18775 DAE.EQUAL(ty = DAE.T_BOOL(varLst = _)),
18776 a_index,
18777 a_context )
18778 algorithm
18779 ✗ txt := daeExpRelation3(txt, a_context, a_index);
18780 then txt;
18781
18782 case ( txt,
18783 DAE.EQUAL(ty = DAE.T_STRING(varLst = _)),
18784 a_index,
18785 a_context )
18786 algorithm
18787 ✗ txt := daeExpRelation3(txt, a_context, a_index);
18788 then txt;
18789
18790 case ( txt,
18791 DAE.EQUAL(ty = DAE.T_INTEGER(varLst = _)),
18792 a_index,
18793 a_context )
18794 algorithm
18795 ✗ txt := daeExpRelation3(txt, a_context, a_index);
18796 then txt;
18797
18798 case ( txt,
18799 DAE.EQUAL(ty = DAE.T_REAL(varLst = _)),
18800 a_index,
18801 a_context )
18802 algorithm
18803 ✗ txt := daeExpRelation3(txt, a_context, a_index);
18804 then txt;
18805
18806 case ( txt,
18807 DAE.NEQUAL(ty = DAE.T_BOOL(varLst = _)),
18808 a_index,
18809 a_context )
18810 algorithm
18811 ✗ txt := daeExpRelation3(txt, a_context, a_index);
18812 then txt;
18813
18814 case ( txt,
18815 DAE.NEQUAL(ty = DAE.T_STRING(varLst = _)),
18816 a_index,
18817 a_context )
18818 algorithm
18819 ✗ txt := daeExpRelation3(txt, a_context, a_index);
18820 then txt;
18821
18822 case ( txt,
18823 DAE.NEQUAL(ty = DAE.T_INTEGER(varLst = _)),
18824 a_index,
18825 a_context )
18826 algorithm
18827 ✗ txt := daeExpRelation3(txt, a_context, a_index);
18828 then txt;
18829
18830 case ( txt,
18831 DAE.NEQUAL(ty = DAE.T_REAL(varLst = _)),
18832 a_index,
18833 a_context )
18834 algorithm
18835 ✗ txt := daeExpRelation3(txt, a_context, a_index);
18836 then txt;
18837
18838 case ( txt,
18839 _,
18840 _,
18841 _ )
18842 algorithm
18843 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("daeExpRelationCondition:ERR"));
18844 then txt;
18845 end match;
18846 end fun_361;
18847
18848 protected function fun_362
18849 input Tpl.Text in_txt;
18850 input Integer in_a_index;
18851 input SimCodeFunction.Context in_a_context;
18852 input Tpl.Text in_a_e2;
18853 input Tpl.Text in_a_e1;
18854 input DAE.Operator in_a_op;
18855
18856 output Tpl.Text out_txt;
18857 algorithm
18858 out_txt :=
18859 match(in_txt, in_a_index, in_a_context, in_a_e2, in_a_e1, in_a_op)
18860 local
18861 Tpl.Text txt;
18862 SimCodeFunction.Context a_context;
18863 Tpl.Text a_e2;
18864 Tpl.Text a_e1;
18865 DAE.Operator a_op;
18866 Integer i_index;
18867
18868 case ( txt,
18869 -1,
18870 _,
18871 a_e2,
18872 a_e1,
18873 a_op )
18874 algorithm
18875 2617 txt := fun_360(txt, a_op, a_e2, a_e1);
18876 then txt;
18877
18878 case ( txt,
18879 i_index,
18880 a_context,
18881 _,
18882 _,
18883 a_op )
18884 algorithm
18885 113 txt := fun_361(txt, a_op, i_index, a_context);
18886 then txt;
18887 end match;
18888 end fun_362;
18889
18890 public function daeExpRelation2
18891 input Tpl.Text txt;
18892 input DAE.Operator a_op;
18893 input Integer a_index;
18894 input DAE.Exp a_exp1;
18895 input DAE.Exp a_exp2;
18896 input SimCodeFunction.Context a_context;
18897 input Tpl.Text a_preExp;
18898 input Tpl.Text a_varDecls;
18899 input SimCode.SimCode a_simCode;
18900 input Tpl.Text a_extraFuncs;
18901 input Tpl.Text a_extraFuncsDecl;
18902 input Tpl.Text a_extraFuncsNamespace;
18903 input Tpl.Text a_stateDerVectorName;
18904 input Boolean a_useFlatArrayNotation;
18905
18906 output Tpl.Text out_txt;
18907 output Tpl.Text out_a_preExp;
18908 output Tpl.Text out_a_varDecls;
18909 output Tpl.Text out_a_extraFuncs;
18910 output Tpl.Text out_a_extraFuncsDecl;
18911 output Tpl.Text out_a_extraFuncsNamespace;
18912 output Tpl.Text out_a_stateDerVectorName;
18913 protected
18914 Tpl.Text l_e2;
18915 Tpl.Text l_e1;
18916 algorithm
18917 2730 (l_e1, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) := daeExp(Tpl.emptyTxt, a_exp1, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
18918 2730 (l_e2, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) := daeExp(Tpl.emptyTxt, a_exp2, a_context, out_a_preExp, out_a_varDecls, a_simCode, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName, a_useFlatArrayNotation);
18919 2730 out_txt := fun_362(txt, a_index, a_context, l_e2, l_e1, a_op);
18920 end daeExpRelation2;
18921
18922 protected function fun_364
18923 input Tpl.Text in_txt;
18924 input DAE.Type in_mArg;
18925 input Tpl.Text in_a_eThen;
18926 input Tpl.Text in_a_resVar;
18927
18928 output Tpl.Text out_txt;
18929 algorithm
18930 out_txt :=
18931 match(in_txt, in_mArg, in_a_eThen, in_a_resVar)
18932 local
18933 Tpl.Text txt;
18934 Tpl.Text a_eThen;
18935 Tpl.Text a_resVar;
18936
18937 case ( txt,
18938 DAE.T_ARRAY(dims = _),
18939 a_eThen,
18940 a_resVar )
18941 algorithm
18942 11 txt := Tpl.writeText(txt, a_resVar);
18943 11 txt := Tpl.writeTok(txt, Tpl.ST_STRING(".assign("));
18944 11 txt := Tpl.writeText(txt, a_eThen);
18945 11 txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
18946 then txt;
18947
18948 case ( txt,
18949 _,
18950 a_eThen,
18951 a_resVar )
18952 algorithm
18953 1574 txt := Tpl.writeText(txt, a_resVar);
18954 1574 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = "));
18955 1574 txt := Tpl.writeText(txt, a_eThen);
18956 1574 txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
18957 then txt;
18958 end match;
18959 end fun_364;
18960
18961 protected function fun_365
18962 input Tpl.Text in_txt;
18963 input DAE.Type in_mArg;
18964 input Tpl.Text in_a_eElse;
18965 input Tpl.Text in_a_resVar;
18966
18967 output Tpl.Text out_txt;
18968 algorithm
18969 out_txt :=
18970 match(in_txt, in_mArg, in_a_eElse, in_a_resVar)
18971 local
18972 Tpl.Text txt;
18973 Tpl.Text a_eElse;
18974 Tpl.Text a_resVar;
18975
18976 case ( txt,
18977 DAE.T_ARRAY(dims = _),
18978 a_eElse,
18979 a_resVar )
18980 algorithm
18981 11 txt := Tpl.writeText(txt, a_resVar);
18982 11 txt := Tpl.writeTok(txt, Tpl.ST_STRING(".assign("));
18983 11 txt := Tpl.writeText(txt, a_eElse);
18984 11 txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
18985 then txt;
18986
18987 case ( txt,
18988 _,
18989 a_eElse,
18990 a_resVar )
18991 algorithm
18992 1574 txt := Tpl.writeText(txt, a_resVar);
18993 1574 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = "));
18994 1574 txt := Tpl.writeText(txt, a_eElse);
18995 1574 txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
18996 then txt;
18997 end match;
18998 end fun_365;
18999
19000 public function daeExpIf
19001 input Tpl.Text txt;
19002 input DAE.Exp a_cond;
19003 input DAE.Exp a_then__;
19004 input DAE.Exp a_else__;
19005 input SimCodeFunction.Context a_context;
19006 input Tpl.Text a_preExp;
19007 input Tpl.Text a_varDecls;
19008 input SimCode.SimCode a_simCode;
19009 input Tpl.Text a_extraFuncs;
19010 input Tpl.Text a_extraFuncsDecl;
19011 input Tpl.Text a_extraFuncsNamespace;
19012 input Tpl.Text a_stateDerVectorName;
19013 input Boolean a_useFlatArrayNotation;
19014
19015 output Tpl.Text out_txt;
19016 output Tpl.Text out_a_preExp;
19017 output Tpl.Text out_a_varDecls;
19018 output Tpl.Text out_a_extraFuncs;
19019 output Tpl.Text out_a_extraFuncsDecl;
19020 output Tpl.Text out_a_extraFuncsNamespace;
19021 output Tpl.Text out_a_stateDerVectorName;
19022 protected
19023 DAE.Type ret_7;
19024 DAE.Type ret_6;
19025 Tpl.Text l_resVar;
19026 Tpl.Text l_eElse;
19027 Tpl.Text l_preExpElse;
19028 Tpl.Text l_eThen;
19029 Tpl.Text l_preExpThen;
19030 Tpl.Text l_condExp;
19031 algorithm
19032 1585 (l_condExp, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) := daeExp(Tpl.emptyTxt, a_cond, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
19033 1585 l_preExpThen := Tpl.emptyTxt;
19034 1585 (l_eThen, l_preExpThen, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) := daeExp(Tpl.emptyTxt, a_then__, a_context, l_preExpThen, out_a_varDecls, a_simCode, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName, a_useFlatArrayNotation);
19035 1585 l_preExpElse := Tpl.emptyTxt;
19036 1585 (l_eElse, l_preExpElse, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) := daeExp(Tpl.emptyTxt, a_else__, a_context, l_preExpElse, out_a_varDecls, a_simCode, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName, a_useFlatArrayNotation);
19037 1585 (l_resVar, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) := expTypeFromExpArrayIf(Tpl.emptyTxt, a_else__, a_context, out_a_preExp, out_a_varDecls, a_simCode, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName, a_useFlatArrayNotation);
19038 1585 out_a_preExp := Tpl.writeTok(out_a_preExp, Tpl.ST_STRING("if "));
19039 1585 out_a_preExp := encloseInParantheses(out_a_preExp, Tpl.textString(l_condExp));
19040 1585 out_a_preExp := Tpl.writeTok(out_a_preExp, Tpl.ST_LINE(" {\n"));
19041 1585 out_a_preExp := Tpl.pushBlock(out_a_preExp, Tpl.BT_INDENT(2));
19042 1585 out_a_preExp := Tpl.writeText(out_a_preExp, l_preExpThen);
19043 1585 out_a_preExp := Tpl.softNewLine(out_a_preExp);
19044 1585 ret_6 := Expression.typeof(a_then__);
19045 1585 out_a_preExp := fun_364(out_a_preExp, ret_6, l_eThen, l_resVar);
19046 1585 out_a_preExp := Tpl.softNewLine(out_a_preExp);
19047 1585 out_a_preExp := Tpl.popBlock(out_a_preExp);
19048 1585 out_a_preExp := Tpl.writeTok(out_a_preExp, Tpl.ST_LINE("} else {\n"));
19049 1585 out_a_preExp := Tpl.pushBlock(out_a_preExp, Tpl.BT_INDENT(2));
19050 1585 out_a_preExp := Tpl.writeText(out_a_preExp, l_preExpElse);
19051 1585 out_a_preExp := Tpl.softNewLine(out_a_preExp);
19052 1585 ret_7 := Expression.typeof(a_else__);
19053 1585 out_a_preExp := fun_365(out_a_preExp, ret_7, l_eElse, l_resVar);
19054 1585 out_a_preExp := Tpl.softNewLine(out_a_preExp);
19055 1585 out_a_preExp := Tpl.popBlock(out_a_preExp);
19056 1585 out_a_preExp := Tpl.writeTok(out_a_preExp, Tpl.ST_STRING("}"));
19057 1585 out_a_preExp := Tpl.writeTok(out_a_preExp, Tpl.ST_NEW_LINE());
19058 1585 out_txt := Tpl.writeText(txt, l_resVar);
19059 end daeExpIf;
19060
19061 protected function lm_367
19062 input output Tpl.Text txt;
19063 input list<DAE.Exp> items;
19064 input Boolean a_useFlatArrayNotation;
19065 input output Tpl.Text a_stateDerVectorName;
19066 input output Tpl.Text a_extraFuncsNamespace;
19067 input output Tpl.Text a_extraFuncsDecl;
19068 input output Tpl.Text a_extraFuncs;
19069 input SimCode.SimCode a_simCode;
19070 input output Tpl.Text a_varDecls;
19071 input output Tpl.Text a_preExp;
19072 input SimCodeFunction.Context a_context;
19073 algorithm
19074 ✗ for lstElt_367 in items loop
19075 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_367
19076 local
19077 DAE.Exp i_e;
19078
19079 case i_e
19080 algorithm
19081 ✗ (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
19082 ✗ txt := Tpl.nextIter(txt);
19083 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
19084 end match;
19085 end for;
19086 end lm_367;
19087
19088 protected function fun_368
19089 input Tpl.Text in_txt;
19090 input DAE.Type in_mArg;
19091 input DAE.Exp in_a_exp;
19092 input Tpl.Text in_a_varDecls;
19093
19094 output Tpl.Text out_txt;
19095 output Tpl.Text out_a_varDecls;
19096 algorithm
19097 (out_txt, out_a_varDecls) :=
19098 match(in_txt, in_mArg, in_a_exp, in_a_varDecls)
19099 local
19100 Tpl.Text txt;
19101 DAE.Exp a_exp;
19102 Tpl.Text a_varDecls;
19103 DAE.Type i_ty;
19104 DAE.Dimensions i_dims;
19105 DAE.Type ret_3;
19106 Tpl.Text l_resVar;
19107 Integer ret_1;
19108 Tpl.Text l_resVarType;
19109
19110 case ( txt,
19111 (i_ty as DAE.T_ARRAY(dims = i_dims)),
19112 _,
19113 a_varDecls )
19114 algorithm
19115 11 l_resVarType := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("DynArrayDim"));
19116 11 ret_1 := listLength(i_dims);
19117 11 l_resVarType := Tpl.writeStr(l_resVarType, intString(ret_1));
19118 11 l_resVarType := Tpl.writeTok(l_resVarType, Tpl.ST_STRING("<"));
19119 11 l_resVarType := expTypeShort(l_resVarType, i_ty);
19120 11 l_resVarType := Tpl.writeTok(l_resVarType, Tpl.ST_STRING(">"));
19121 11 (l_resVar, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(l_resVarType), a_varDecls);
19122 11 txt := Tpl.writeText(txt, l_resVar);
19123 11 then (txt, a_varDecls);
19124
19125 case ( txt,
19126 _,
19127 a_exp,
19128 a_varDecls )
19129 algorithm
19130 1574 ret_3 := Expression.typeof(a_exp);
19131 1574 l_resVarType := expTypeFlag(Tpl.emptyTxt, ret_3, 2);
19132 1574 (l_resVar, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(l_resVarType), a_varDecls);
19133 1574 txt := Tpl.writeText(txt, l_resVar);
19134 1574 then (txt, a_varDecls);
19135 end match;
19136 end fun_368;
19137
19138 public function expTypeFromExpArrayIf
19139 input Tpl.Text in_txt;
19140 input DAE.Exp in_a_exp;
19141 input SimCodeFunction.Context in_a_context;
19142 input Tpl.Text in_a_preExp;
19143 input Tpl.Text in_a_varDecls;
19144 input SimCode.SimCode in_a_simCode;
19145 input Tpl.Text in_a_extraFuncs;
19146 input Tpl.Text in_a_extraFuncsDecl;
19147 input Tpl.Text in_a_extraFuncsNamespace;
19148 input Tpl.Text in_a_stateDerVectorName;
19149 input Boolean in_a_useFlatArrayNotation;
19150
19151 output Tpl.Text out_txt;
19152 output Tpl.Text out_a_preExp;
19153 output Tpl.Text out_a_varDecls;
19154 output Tpl.Text out_a_extraFuncs;
19155 output Tpl.Text out_a_extraFuncsDecl;
19156 output Tpl.Text out_a_extraFuncsNamespace;
19157 output Tpl.Text out_a_stateDerVectorName;
19158 algorithm
19159 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
19160 match(in_txt, in_a_exp, in_a_context, in_a_preExp, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
19161 local
19162 Tpl.Text txt;
19163 SimCodeFunction.Context a_context;
19164 Tpl.Text a_preExp;
19165 Tpl.Text a_varDecls;
19166 SimCode.SimCode a_simCode;
19167 Tpl.Text a_extraFuncs;
19168 Tpl.Text a_extraFuncsDecl;
19169 Tpl.Text a_extraFuncsNamespace;
19170 Tpl.Text a_stateDerVectorName;
19171 Boolean a_useFlatArrayNotation;
19172 DAE.Exp i_exp;
19173 list<DAE.Exp> i_array;
19174 DAE.Type i_ty;
19175 DAE.Type ret_6;
19176 Tpl.Text l_params;
19177 Tpl.Text l_tmpVar;
19178 Tpl.Text l_arrayVar;
19179 Tpl.Text l_tmpdecl;
19180 Tpl.Text l_StatArrayDim;
19181 Tpl.Text l_arrayTypeStr;
19182
19183 case ( txt,
19184 DAE.ARRAY(ty = i_ty, array = i_array),
19185 a_context,
19186 a_preExp,
19187 a_varDecls,
19188 a_simCode,
19189 a_extraFuncs,
19190 a_extraFuncsDecl,
19191 a_extraFuncsNamespace,
19192 a_stateDerVectorName,
19193 a_useFlatArrayNotation )
19194 algorithm
19195 ✗ l_arrayTypeStr := expTypeShort(Tpl.emptyTxt, i_ty);
19196 ✗ l_StatArrayDim := expTypeArrayIf(Tpl.emptyTxt, i_ty);
19197 ✗ l_tmpdecl := Tpl.emptyTxt;
19198 ✗ (l_arrayVar, l_tmpdecl) := tempDecl(Tpl.emptyTxt, Tpl.textString(l_arrayTypeStr), l_tmpdecl);
19199 l_tmpVar := Tpl.emptyTxt;
19200 ✗ l_params := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
19201 ✗ (l_params, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_367(l_params, i_array, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
19202 ✗ l_params := Tpl.popIter(l_params);
19203 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING_LIST({
19204 "\n",
19205 " //tmp array\n"
19206 }, true));
19207 ✗ a_preExp := Tpl.pushBlock(a_preExp, Tpl.BT_INDENT(3));
19208 ✗ a_preExp := Tpl.writeText(a_preExp, l_StatArrayDim);
19209 ✗ a_preExp := Tpl.writeText(a_preExp, l_arrayVar);
19210 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(";/*testarray6*/"));
19211 ✗ a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
19212 ✗ a_preExp := Tpl.popBlock(a_preExp);
19213 ✗ txt := Tpl.writeText(txt, l_arrayVar);
19214 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
19215
19216 case ( txt,
19217 i_exp,
19218 _,
19219 a_preExp,
19220 a_varDecls,
19221 _,
19222 a_extraFuncs,
19223 a_extraFuncsDecl,
19224 a_extraFuncsNamespace,
19225 a_stateDerVectorName,
19226 _ )
19227 algorithm
19228 1585 ret_6 := Expression.typeof(i_exp);
19229 1585 (txt, a_varDecls) := fun_368(txt, ret_6, i_exp, a_varDecls);
19230 1585 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
19231 end match;
19232 end expTypeFromExpArrayIf;
19233
19234 public function expTypeFromExp
19235 input Tpl.Text in_txt;
19236 input DAE.Exp in_a_it;
19237
19238 output Tpl.Text out_txt;
19239 algorithm
19240 out_txt :=
19241 match(in_txt, in_a_it)
19242 local
19243 Tpl.Text txt;
19244 DAE.Exp i_expr;
19245 DAE.Exp i_exp;
19246 DAE.Type i_ty;
19247 DAE.Type i_attr_ty;
19248 DAE.Exp i_expThen;
19249 DAE.Operator i_operator;
19250
19251 case ( txt,
19252 DAE.ICONST(integer = _) )
19253 algorithm
19254 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("int"));
19255 then txt;
19256
19257 case ( txt,
19258 DAE.ENUM_LITERAL(name = _) )
19259 algorithm
19260 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("int"));
19261 then txt;
19262
19263 case ( txt,
19264 DAE.RCONST(real = _) )
19265 algorithm
19266 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("double"));
19267 then txt;
19268
19269 case ( txt,
19270 DAE.SCONST(string = _) )
19271 algorithm
19272 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("string"));
19273 then txt;
19274
19275 case ( txt,
19276 DAE.BCONST(bool = _) )
19277 algorithm
19278 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("bool"));
19279 then txt;
19280
19281 case ( txt,
19282 DAE.BINARY(operator = i_operator) )
19283 algorithm
19284 ✗ txt := expTypeFromOp(txt, i_operator);
19285 then txt;
19286
19287 case ( txt,
19288 DAE.UNARY(operator = i_operator) )
19289 algorithm
19290 ✗ txt := expTypeFromOp(txt, i_operator);
19291 then txt;
19292
19293 case ( txt,
19294 DAE.LBINARY(operator = i_operator) )
19295 algorithm
19296 ✗ txt := expTypeFromOp(txt, i_operator);
19297 then txt;
19298
19299 case ( txt,
19300 DAE.LUNARY(operator = i_operator) )
19301 algorithm
19302 ✗ txt := expTypeFromOp(txt, i_operator);
19303 then txt;
19304
19305 case ( txt,
19306 DAE.RELATION(exp1 = _) )
19307 algorithm
19308 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("bool"));
19309 then txt;
19310
19311 case ( txt,
19312 DAE.IFEXP(expThen = i_expThen) )
19313 algorithm
19314 ✗ txt := expTypeFromExp(txt, i_expThen);
19315 then txt;
19316
19317 case ( txt,
19318 DAE.CALL(attr = DAE.CALL_ATTR(ty = i_attr_ty)) )
19319 algorithm
19320 ✗ txt := expTypeShort(txt, i_attr_ty);
19321 then txt;
19322
19323 case ( txt,
19324 DAE.ARRAY(ty = i_ty) )
19325 algorithm
19326 ✗ txt := expTypeShort(txt, i_ty);
19327 then txt;
19328
19329 case ( txt,
19330 DAE.MATRIX(ty = i_ty) )
19331 algorithm
19332 ✗ txt := expTypeShort(txt, i_ty);
19333 then txt;
19334
19335 case ( txt,
19336 DAE.RANGE(ty = i_ty) )
19337 algorithm
19338 ✗ txt := expTypeShort(txt, i_ty);
19339 then txt;
19340
19341 case ( txt,
19342 DAE.CAST(ty = i_ty) )
19343 algorithm
19344 ✗ txt := expTypeShort(txt, i_ty);
19345 then txt;
19346
19347 case ( txt,
19348 DAE.CREF(ty = i_ty) )
19349 algorithm
19350 ✗ txt := expTypeShort(txt, i_ty);
19351 then txt;
19352
19353 case ( txt,
19354 DAE.CODE(ty = i_ty) )
19355 algorithm
19356 ✗ txt := expTypeShort(txt, i_ty);
19357 then txt;
19358
19359 case ( txt,
19360 DAE.ASUB(exp = i_exp) )
19361 algorithm
19362 ✗ txt := expTypeFromExp(txt, i_exp);
19363 then txt;
19364
19365 case ( txt,
19366 DAE.REDUCTION(expr = i_expr) )
19367 algorithm
19368 ✗ txt := expTypeFromExp(txt, i_expr);
19369 then txt;
19370
19371 case ( txt,
19372 DAE.TUPLE(PR = _) )
19373 algorithm
19374 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("expTypeFromExp:ERROR TUPLE unsupported"));
19375 then txt;
19376
19377 case ( txt,
19378 DAE.TSUB(exp = _) )
19379 algorithm
19380 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("expTypeFromExp:ERROR TSUB unsupported"));
19381 then txt;
19382
19383 case ( txt,
19384 DAE.SIZE(exp = _) )
19385 algorithm
19386 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("expTypeFromExp:ERROR SIZE unsupported"));
19387 then txt;
19388
19389 case ( txt,
19390 DAE.LIST(valList = _) )
19391 algorithm
19392 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("expTypeFromExp:ERROR LIST unsupported"));
19393 then txt;
19394
19395 case ( txt,
19396 DAE.CONS(car = _) )
19397 algorithm
19398 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("expTypeFromExp:ERROR CONS unsupported"));
19399 then txt;
19400
19401 case ( txt,
19402 DAE.META_TUPLE(listExp = _) )
19403 algorithm
19404 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("expTypeFromExp:ERROR META_TUPLE unsupported"));
19405 then txt;
19406
19407 case ( txt,
19408 DAE.META_OPTION(exp = _) )
19409 algorithm
19410 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("expTypeFromExp:ERROR META_OPTION unsupported"));
19411 then txt;
19412
19413 case ( txt,
19414 DAE.METARECORDCALL(path = _) )
19415 algorithm
19416 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("expTypeFromExp:ERROR METARECORDCALL unsupported"));
19417 then txt;
19418
19419 case ( txt,
19420 DAE.MATCHEXPRESSION(matchType = _) )
19421 algorithm
19422 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("expTypeFromExp:ERROR MATCHEXPRESSION unsupported"));
19423 then txt;
19424
19425 case ( txt,
19426 DAE.BOX(exp = _) )
19427 algorithm
19428 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("expTypeFromExp:ERROR BOX unsupported"));
19429 then txt;
19430
19431 case ( txt,
19432 DAE.UNBOX(exp = _) )
19433 algorithm
19434 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("expTypeFromExp:ERROR UNBOX unsupported"));
19435 then txt;
19436
19437 case ( txt,
19438 DAE.SHARED_LITERAL(exp = i_exp) )
19439 algorithm
19440 ✗ txt := expTypeFromExp(txt, i_exp);
19441 then txt;
19442
19443 case ( txt,
19444 DAE.PATTERN(pattern = _) )
19445 algorithm
19446 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("expTypeFromExp:ERROR PATTERN unsupported"));
19447 then txt;
19448
19449 case ( txt,
19450 _ )
19451 algorithm
19452 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("expTypeFromExp:ERROR"));
19453 then txt;
19454 end match;
19455 end expTypeFromExp;
19456
19457 public function expTypeFromOp
19458 input Tpl.Text in_txt;
19459 input DAE.Operator in_a_it;
19460
19461 output Tpl.Text out_txt;
19462 algorithm
19463 out_txt :=
19464 match(in_txt, in_a_it)
19465 local
19466 Tpl.Text txt;
19467 DAE.Type i_ty;
19468
19469 case ( txt,
19470 DAE.ADD(ty = i_ty) )
19471 algorithm
19472 ✗ txt := expTypeShort(txt, i_ty);
19473 then txt;
19474
19475 case ( txt,
19476 DAE.SUB(ty = i_ty) )
19477 algorithm
19478 ✗ txt := expTypeShort(txt, i_ty);
19479 then txt;
19480
19481 case ( txt,
19482 DAE.MUL(ty = i_ty) )
19483 algorithm
19484 ✗ txt := expTypeShort(txt, i_ty);
19485 then txt;
19486
19487 case ( txt,
19488 DAE.DIV(ty = i_ty) )
19489 algorithm
19490 ✗ txt := expTypeShort(txt, i_ty);
19491 then txt;
19492
19493 case ( txt,
19494 DAE.POW(ty = i_ty) )
19495 algorithm
19496 ✗ txt := expTypeShort(txt, i_ty);
19497 then txt;
19498
19499 case ( txt,
19500 DAE.UMINUS(ty = i_ty) )
19501 algorithm
19502 ✗ txt := expTypeShort(txt, i_ty);
19503 then txt;
19504
19505 case ( txt,
19506 DAE.UMINUS_ARR(ty = i_ty) )
19507 algorithm
19508 ✗ txt := expTypeShort(txt, i_ty);
19509 then txt;
19510
19511 case ( txt,
19512 DAE.ADD_ARR(ty = i_ty) )
19513 algorithm
19514 ✗ txt := expTypeShort(txt, i_ty);
19515 then txt;
19516
19517 case ( txt,
19518 DAE.SUB_ARR(ty = i_ty) )
19519 algorithm
19520 ✗ txt := expTypeShort(txt, i_ty);
19521 then txt;
19522
19523 case ( txt,
19524 DAE.MUL_ARR(ty = i_ty) )
19525 algorithm
19526 ✗ txt := expTypeShort(txt, i_ty);
19527 then txt;
19528
19529 case ( txt,
19530 DAE.DIV_ARR(ty = i_ty) )
19531 algorithm
19532 ✗ txt := expTypeShort(txt, i_ty);
19533 then txt;
19534
19535 case ( txt,
19536 DAE.MUL_ARRAY_SCALAR(ty = i_ty) )
19537 algorithm
19538 ✗ txt := expTypeShort(txt, i_ty);
19539 then txt;
19540
19541 case ( txt,
19542 DAE.ADD_ARRAY_SCALAR(ty = i_ty) )
19543 algorithm
19544 ✗ txt := expTypeShort(txt, i_ty);
19545 then txt;
19546
19547 case ( txt,
19548 DAE.SUB_SCALAR_ARRAY(ty = i_ty) )
19549 algorithm
19550 ✗ txt := expTypeShort(txt, i_ty);
19551 then txt;
19552
19553 case ( txt,
19554 DAE.MUL_SCALAR_PRODUCT(ty = i_ty) )
19555 algorithm
19556 ✗ txt := expTypeShort(txt, i_ty);
19557 then txt;
19558
19559 case ( txt,
19560 DAE.MUL_MATRIX_PRODUCT(ty = i_ty) )
19561 algorithm
19562 ✗ txt := expTypeShort(txt, i_ty);
19563 then txt;
19564
19565 case ( txt,
19566 DAE.DIV_ARRAY_SCALAR(ty = i_ty) )
19567 algorithm
19568 ✗ txt := expTypeShort(txt, i_ty);
19569 then txt;
19570
19571 case ( txt,
19572 DAE.DIV_SCALAR_ARRAY(ty = i_ty) )
19573 algorithm
19574 ✗ txt := expTypeShort(txt, i_ty);
19575 then txt;
19576
19577 case ( txt,
19578 DAE.POW_ARRAY_SCALAR(ty = i_ty) )
19579 algorithm
19580 ✗ txt := expTypeShort(txt, i_ty);
19581 then txt;
19582
19583 case ( txt,
19584 DAE.POW_SCALAR_ARRAY(ty = i_ty) )
19585 algorithm
19586 ✗ txt := expTypeShort(txt, i_ty);
19587 then txt;
19588
19589 case ( txt,
19590 DAE.POW_ARR(ty = i_ty) )
19591 algorithm
19592 ✗ txt := expTypeShort(txt, i_ty);
19593 then txt;
19594
19595 case ( txt,
19596 DAE.POW_ARR2(ty = i_ty) )
19597 algorithm
19598 ✗ txt := expTypeShort(txt, i_ty);
19599 then txt;
19600
19601 case ( txt,
19602 DAE.LESS(ty = i_ty) )
19603 algorithm
19604 ✗ txt := expTypeShort(txt, i_ty);
19605 then txt;
19606
19607 case ( txt,
19608 DAE.LESSEQ(ty = i_ty) )
19609 algorithm
19610 ✗ txt := expTypeShort(txt, i_ty);
19611 then txt;
19612
19613 case ( txt,
19614 DAE.GREATER(ty = i_ty) )
19615 algorithm
19616 ✗ txt := expTypeShort(txt, i_ty);
19617 then txt;
19618
19619 case ( txt,
19620 DAE.GREATEREQ(ty = i_ty) )
19621 algorithm
19622 ✗ txt := expTypeShort(txt, i_ty);
19623 then txt;
19624
19625 case ( txt,
19626 DAE.EQUAL(ty = i_ty) )
19627 algorithm
19628 ✗ txt := expTypeShort(txt, i_ty);
19629 then txt;
19630
19631 case ( txt,
19632 DAE.NEQUAL(ty = i_ty) )
19633 algorithm
19634 ✗ txt := expTypeShort(txt, i_ty);
19635 then txt;
19636
19637 case ( txt,
19638 DAE.AND(ty = _) )
19639 algorithm
19640 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("bool"));
19641 then txt;
19642
19643 case ( txt,
19644 DAE.OR(ty = _) )
19645 algorithm
19646 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("bool"));
19647 then txt;
19648
19649 case ( txt,
19650 DAE.NOT(ty = _) )
19651 algorithm
19652 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("bool"));
19653 then txt;
19654
19655 case ( txt,
19656 _ )
19657 algorithm
19658 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("expTypeFromOp:ERROR"));
19659 then txt;
19660 end match;
19661 end expTypeFromOp;
19662
19663 protected function lm_372
19664 input output Tpl.Text txt;
19665 input list<DAE.Exp> items;
19666 algorithm
19667
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 54 times.
170 for lstElt_372 in items loop
19668 txt := match lstElt_372
19669 local
19670 DAE.Exp i_e;
19671
19672 case i_e
19673 algorithm
19674 116 txt := ExpressionDumpTpl.dumpExp(txt, i_e, "\"");
19675 116 txt := Tpl.nextIter(txt);
19676 then txt;
19677 end match;
19678 end for;
19679 end lm_372;
19680
19681 protected function lm_373
19682 input output Tpl.Text txt;
19683 input list<DAE.Exp> items;
19684 input Boolean a_useFlatArrayNotation;
19685 input output Tpl.Text a_stateDerVectorName;
19686 input output Tpl.Text a_extraFuncsNamespace;
19687 input output Tpl.Text a_extraFuncsDecl;
19688 input output Tpl.Text a_extraFuncs;
19689 input SimCode.SimCode a_simCode;
19690 input output Tpl.Text a_varDecls;
19691 input output Tpl.Text a_preExp;
19692 input SimCodeFunction.Context a_context;
19693 input Tpl.Text a_retStruct;
19694 algorithm
19695
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 54 times.
170 for lstElt_373 in items loop
19696 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_373
19697 local
19698 Integer x_i1;
19699 DAE.Exp i_cr;
19700 Tpl.Text l_rhsStr;
19701
19702 case i_cr
19703 algorithm
19704 116 x_i1 := Tpl.getIteri_i0(txt);
19705 116 l_rhsStr := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("get<"));
19706 116 l_rhsStr := Tpl.writeStr(l_rhsStr, intString(x_i1));
19707 116 l_rhsStr := Tpl.writeTok(l_rhsStr, Tpl.ST_STRING(">("));
19708 116 l_rhsStr := Tpl.writeText(l_rhsStr, a_retStruct);
19709 116 l_rhsStr := Tpl.writeTok(l_rhsStr, Tpl.ST_STRING(".data)"));
19710 116 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := writeLhsCref(txt, i_cr, Tpl.textString(l_rhsStr), a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
19711 116 txt := Tpl.nextIter(txt);
19712 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
19713 end match;
19714 end for;
19715 end lm_373;
19716
19717 public function algStmtTupleAssign
19718 input Tpl.Text in_txt;
19719 input DAE.Statement in_a_stmt;
19720 input SimCodeFunction.Context in_a_context;
19721 input Tpl.Text in_a_varDecls;
19722 input SimCode.SimCode in_a_simCode;
19723 input Tpl.Text in_a_extraFuncs;
19724 input Tpl.Text in_a_extraFuncsDecl;
19725 input Tpl.Text in_a_extraFuncsNamespace;
19726 input Tpl.Text in_a_stateDerVectorName;
19727 input Boolean in_a_useFlatArrayNotation;
19728
19729 output Tpl.Text out_txt;
19730 output Tpl.Text out_a_varDecls;
19731 output Tpl.Text out_a_extraFuncs;
19732 output Tpl.Text out_a_extraFuncsDecl;
19733 output Tpl.Text out_a_extraFuncsNamespace;
19734 output Tpl.Text out_a_stateDerVectorName;
19735 algorithm
19736 (out_txt, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
19737 match(in_txt, in_a_stmt, in_a_context, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
19738 local
19739 Tpl.Text txt;
19740 SimCodeFunction.Context a_context;
19741 Tpl.Text a_varDecls;
19742 SimCode.SimCode a_simCode;
19743 Tpl.Text a_extraFuncs;
19744 Tpl.Text a_extraFuncsDecl;
19745 Tpl.Text a_extraFuncsNamespace;
19746 Tpl.Text a_stateDerVectorName;
19747 Boolean a_useFlatArrayNotation;
19748 DAE.Exp i_exp;
19749 list<DAE.Exp> i_expExpLst;
19750 Tpl.Text l_lhsCrefs;
19751 Tpl.Text l_retStruct;
19752 Tpl.Text l_marker;
19753 Tpl.Text l_crefs;
19754 Tpl.Text l_preExp;
19755
19756 case ( txt,
19757 DAE.STMT_TUPLE_ASSIGN(exp = (i_exp as DAE.CALL(path = _)), expExpLst = i_expExpLst),
19758 a_context,
19759 a_varDecls,
19760 a_simCode,
19761 a_extraFuncs,
19762 a_extraFuncsDecl,
19763 a_extraFuncsNamespace,
19764 a_stateDerVectorName,
19765 a_useFlatArrayNotation )
19766 algorithm
19767 54 l_preExp := Tpl.emptyTxt;
19768 54 l_crefs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
19769 54 l_crefs := lm_372(l_crefs, i_expExpLst);
19770 54 l_crefs := Tpl.popIter(l_crefs);
19771 54 l_marker := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("("));
19772 54 l_marker := Tpl.writeText(l_marker, l_crefs);
19773 54 l_marker := Tpl.writeTok(l_marker, Tpl.ST_STRING(") = "));
19774 54 l_marker := ExpressionDumpTpl.dumpExp(l_marker, i_exp, "\"");
19775 54 (l_retStruct, l_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_exp, a_context, l_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
19776 54 l_lhsCrefs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, SOME(Tpl.ST_STRING("")), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
19777 54 (l_lhsCrefs, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, l_preExp) := lm_373(l_lhsCrefs, i_expExpLst, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, l_preExp, a_context, l_retStruct);
19778 54 l_lhsCrefs := Tpl.popIter(l_lhsCrefs);
19779 54 txt := Tpl.writeTok(txt, Tpl.ST_STRING("// algStmtTupleAssign: preExp "));
19780 54 txt := Tpl.writeText(txt, l_marker);
19781 54 txt := Tpl.softNewLine(txt);
19782 54 txt := Tpl.writeText(txt, l_preExp);
19783 54 txt := Tpl.softNewLine(txt);
19784 54 txt := Tpl.writeTok(txt, Tpl.ST_LINE("// algStmtTupleAssign: writeLhsCref\n"));
19785 54 txt := Tpl.writeText(txt, l_lhsCrefs);
19786 54 then (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
19787
19788 case ( txt,
19789 _,
19790 _,
19791 a_varDecls,
19792 _,
19793 a_extraFuncs,
19794 a_extraFuncsDecl,
19795 a_extraFuncsNamespace,
19796 a_stateDerVectorName,
19797 _ )
19798 algorithm
19799 ✗ txt := error(txt, Tpl.sourceInfo("CodegenCppCommon.tpl", 2794, 12), "algStmtTupleAssign failed");
19800 ✗ then (txt, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
19801 end match;
19802 end algStmtTupleAssign;
19803
19804 public function error
19805 input Tpl.Text txt;
19806 input SourceInfo a_srcInfo;
19807 input String a_errMessage;
19808
19809 output Tpl.Text out_txt;
19810 protected
19811 String ret_0;
19812 algorithm
19813 ✗ Tpl.addSourceTemplateError(a_errMessage, a_srcInfo);
19814 ✗ out_txt := Tpl.writeTok(txt, Tpl.ST_STRING("#error \""));
19815 ✗ ret_0 := Error.infoStr(a_srcInfo);
19816 ✗ out_txt := Tpl.writeStr(out_txt, ret_0);
19817 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING(" "));
19818 ✗ out_txt := Tpl.writeStr(out_txt, a_errMessage);
19819 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("\""));
19820 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_NEW_LINE());
19821 end error;
19822
19823 public function errorMsg
19824 input Tpl.Text txt;
19825 input String a_errMessage;
19826
19827 output Tpl.Text out_txt;
19828 algorithm
19829 ✗ Tpl.addTemplateError(a_errMessage);
19830 ✗ out_txt := Tpl.writeTok(txt, Tpl.ST_STRING("#error \""));
19831 ✗ out_txt := Tpl.writeStr(out_txt, a_errMessage);
19832 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("\""));
19833 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_NEW_LINE());
19834 end errorMsg;
19835
19836 protected function fun_377
19837 input Tpl.Text in_txt;
19838 input Boolean in_mArg;
19839 input String in_a_expStr;
19840
19841 output Tpl.Text out_txt;
19842 algorithm
19843 out_txt :=
19844 match(in_txt, in_mArg, in_a_expStr)
19845 local
19846 Tpl.Text txt;
19847 String a_expStr;
19848
19849 case ( txt,
19850 false,
19851 a_expStr )
19852 algorithm
19853 597 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
19854 597 txt := Tpl.writeStr(txt, a_expStr);
19855 597 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
19856 then txt;
19857
19858 case ( txt,
19859 _,
19860 a_expStr )
19861 algorithm
19862 1286 txt := Tpl.writeStr(txt, a_expStr);
19863 then txt;
19864 end match;
19865 end fun_377;
19866
19867 public function encloseInParantheses
19868 input Tpl.Text txt;
19869 input String a_expStr;
19870
19871 output Tpl.Text out_txt;
19872 protected
19873 Boolean ret_2;
19874 Integer ret_1;
19875 Integer ret_0;
19876 algorithm
19877 1883 ret_0 := stringGet(a_expStr, 1);
19878 1883 ret_1 := stringGet("(", 1);
19879 1883 ret_2 := intEq(ret_0, ret_1);
19880 1883 out_txt := fun_377(txt, ret_2, a_expStr);
19881 end encloseInParantheses;
19882
19883 protected function fun_379
19884 input Tpl.Text in_txt;
19885 input DAE.Type in_a_ty;
19886 input String in_a_lhsStr;
19887 input String in_a_rhsStr;
19888
19889 output Tpl.Text out_txt;
19890 algorithm
19891 out_txt :=
19892 match(in_txt, in_a_ty, in_a_lhsStr, in_a_rhsStr)
19893 local
19894 Tpl.Text txt;
19895 String a_lhsStr;
19896 String a_rhsStr;
19897 DAE.Type i_elty;
19898 DAE.Dimensions i_dims;
19899 Integer ret_2;
19900 Tpl.Text l_arrayWrapper;
19901 Tpl.Text l_dimstr;
19902
19903 case ( txt,
19904 DAE.T_ARRAY(ty = i_elty, dims = i_dims),
19905 a_lhsStr,
19906 a_rhsStr )
19907 algorithm
19908 ✗ l_dimstr := listDimsFlat(Tpl.emptyTxt, i_dims, i_elty);
19909 ✗ l_arrayWrapper := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("tmp"));
19910 ✗ ret_2 := System.tmpTick();
19911 ✗ l_arrayWrapper := Tpl.writeStr(l_arrayWrapper, intString(ret_2));
19912 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
19913 "/*assign through wrapper array*/\n",
19914 "StatArrayDim"
19915 }, false));
19916 ✗ txt := nDimsFlat(txt, i_dims, i_elty, 0);
19917 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("<"));
19918 ✗ txt := expTypeShort(txt, i_elty);
19919 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
19920 ✗ txt := Tpl.writeText(txt, l_dimstr);
19921 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(", true> "));
19922 ✗ txt := Tpl.writeText(txt, l_arrayWrapper);
19923 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("(&"));
19924 ✗ txt := Tpl.writeStr(txt, a_lhsStr);
19925 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
19926 ");\n",
19927 "assignRowMajorData("
19928 }, false));
19929 ✗ txt := Tpl.writeStr(txt, a_rhsStr);
19930 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(".getData(), "));
19931 ✗ txt := Tpl.writeText(txt, l_arrayWrapper);
19932 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
19933 then txt;
19934
19935 case ( txt,
19936 _,
19937 _,
19938 _ )
19939 then txt;
19940 end match;
19941 end fun_379;
19942
19943 public function assignJacArray
19944 input Tpl.Text txt;
19945 input String a_lhsStr;
19946 input String a_rhsStr;
19947 input DAE.Type a_ty;
19948
19949 output Tpl.Text out_txt;
19950 algorithm
19951 ✗ out_txt := fun_379(txt, a_ty, a_lhsStr, a_rhsStr);
19952 end assignJacArray;
19953
19954 protected function fun_381
19955 input Tpl.Text in_txt;
19956 input BackendDAE.VarKind in_a_varKind;
19957 input DAE.Type in_a_ty;
19958 input String in_a_rhsStr;
19959 input Tpl.Text in_a_lhsStr;
19960
19961 output Tpl.Text out_txt;
19962 algorithm
19963 out_txt :=
19964 match(in_txt, in_a_varKind, in_a_ty, in_a_rhsStr, in_a_lhsStr)
19965 local
19966 Tpl.Text txt;
19967 DAE.Type a_ty;
19968 String a_rhsStr;
19969 Tpl.Text a_lhsStr;
19970
19971 case ( txt,
19972 BackendDAE.JAC_VAR(),
19973 a_ty,
19974 a_rhsStr,
19975 a_lhsStr )
19976 algorithm
19977 ✗ txt := assignJacArray(txt, Tpl.textString(a_lhsStr), a_rhsStr, a_ty);
19978 then txt;
19979
19980 case ( txt,
19981 BackendDAE.JAC_TMP_VAR(),
19982 a_ty,
19983 a_rhsStr,
19984 a_lhsStr )
19985 algorithm
19986 ✗ txt := assignJacArray(txt, Tpl.textString(a_lhsStr), a_rhsStr, a_ty);
19987 then txt;
19988
19989 case ( txt,
19990 BackendDAE.SEED_VAR(),
19991 a_ty,
19992 a_rhsStr,
19993 a_lhsStr )
19994 algorithm
19995 ✗ txt := assignJacArray(txt, Tpl.textString(a_lhsStr), a_rhsStr, a_ty);
19996 then txt;
19997
19998 case ( txt,
19999 _,
20000 _,
20001 a_rhsStr,
20002 a_lhsStr )
20003 algorithm
20004 12 txt := Tpl.writeText(txt, a_lhsStr);
20005 12 txt := Tpl.writeTok(txt, Tpl.ST_STRING(".assign("));
20006 12 txt := Tpl.writeStr(txt, a_rhsStr);
20007 12 txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
20008 then txt;
20009 end match;
20010 end fun_381;
20011
20012 protected function fun_382
20013 input Tpl.Text in_txt;
20014 input SimCodeVar.SimVar in_mArg;
20015 input DAE.Type in_a_ty;
20016 input String in_a_rhsStr;
20017 input Tpl.Text in_a_lhsStr;
20018
20019 output Tpl.Text out_txt;
20020 algorithm
20021 out_txt :=
20022 match(in_txt, in_mArg, in_a_ty, in_a_rhsStr, in_a_lhsStr)
20023 local
20024 Tpl.Text txt;
20025 DAE.Type a_ty;
20026 String a_rhsStr;
20027 Tpl.Text a_lhsStr;
20028 BackendDAE.VarKind i_varKind;
20029
20030 case ( txt,
20031 SimCodeVar.SIMVAR(varKind = i_varKind),
20032 a_ty,
20033 a_rhsStr,
20034 a_lhsStr )
20035 algorithm
20036 12 txt := fun_381(txt, i_varKind, a_ty, a_rhsStr, a_lhsStr);
20037 then txt;
20038
20039 case ( txt,
20040 _,
20041 _,
20042 _,
20043 _ )
20044 then txt;
20045 end match;
20046 end fun_382;
20047
20048 protected function fun_383
20049 input Tpl.Text in_txt;
20050 input SimCodeFunction.Context in_a_context;
20051 input Tpl.Text in_a_lhsStr;
20052 input String in_a_rhsStr;
20053 input DAE.Type in_a_t;
20054
20055 output Tpl.Text out_txt;
20056 algorithm
20057 out_txt :=
20058 match(in_txt, in_a_context, in_a_lhsStr, in_a_rhsStr, in_a_t)
20059 local
20060 Tpl.Text txt;
20061 Tpl.Text a_lhsStr;
20062 String a_rhsStr;
20063 DAE.Type a_t;
20064
20065 case ( txt,
20066 SimCodeFunction.SIMULATION_CONTEXT(genDiscrete = _),
20067 a_lhsStr,
20068 a_rhsStr,
20069 a_t )
20070 algorithm
20071 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("usub_"));
20072 ✗ txt := expTypeShort(txt, a_t);
20073 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_array(&"));
20074 ✗ txt := Tpl.writeStr(txt, a_rhsStr);
20075 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
20076 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
20077 "\n",
20078 "copy_"
20079 }, false));
20080 ✗ txt := expTypeShort(txt, a_t);
20081 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_array_data_mem(&"));
20082 ✗ txt := Tpl.writeStr(txt, a_rhsStr);
20083 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(", &"));
20084 ✗ txt := Tpl.writeText(txt, a_lhsStr);
20085 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
20086 then txt;
20087
20088 case ( txt,
20089 _,
20090 a_lhsStr,
20091 a_rhsStr,
20092 _ )
20093 algorithm
20094 ✗ txt := Tpl.writeText(txt, a_lhsStr);
20095 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = -"));
20096 ✗ txt := Tpl.writeStr(txt, a_rhsStr);
20097 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
20098 then txt;
20099 end match;
20100 end fun_383;
20101
20102 protected function lm_384
20103 input output Tpl.Text txt;
20104 input list<DAE.Var> items;
20105 input String a_rhsStr;
20106 input Tpl.Text a_lhsStr;
20107 algorithm
20108
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2 times.
6 for lstElt_384 in items loop
20109 txt := match lstElt_384
20110 local
20111 DAE.Ident i_var_name;
20112
20113 case DAE.TYPES_VAR(name = i_var_name)
20114 algorithm
20115 4 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
20116 4 txt := Tpl.writeText(txt, a_lhsStr);
20117 4 txt := Tpl.writeTok(txt, Tpl.ST_STRING("P_"));
20118 4 txt := Tpl.writeStr(txt, i_var_name);
20119 4 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_ = "));
20120 4 txt := Tpl.writeStr(txt, a_rhsStr);
20121 4 txt := Tpl.writeTok(txt, Tpl.ST_STRING("."));
20122 4 txt := Tpl.writeStr(txt, i_var_name);
20123 4 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_;"));
20124 4 txt := Tpl.nextIter(txt);
20125 then txt;
20126
20127 case _
20128 then txt;
20129 end match;
20130 end for;
20131 end lm_384;
20132
20133 protected function fun_385
20134 input Tpl.Text in_txt;
20135 input SimCodeFunction.Context in_a_context;
20136 input list<DAE.Var> in_a_varLst;
20137 input DAE.ComponentRef in_a_cr;
20138 input String in_a_rhsStr;
20139 input Boolean in_a_useFlatArrayNotation;
20140 input Tpl.Text in_a_stateDerVectorName;
20141 input Tpl.Text in_a_extraFuncsNamespace;
20142 input Tpl.Text in_a_extraFuncsDecl;
20143 input Tpl.Text in_a_extraFuncs;
20144 input SimCode.SimCode in_a_simCode;
20145 input Tpl.Text in_a_varDecls;
20146 input Tpl.Text in_a_preExp;
20147 input DAE.Exp in_a_exp;
20148
20149 output Tpl.Text out_txt;
20150 output Tpl.Text out_a_stateDerVectorName;
20151 output Tpl.Text out_a_extraFuncsNamespace;
20152 output Tpl.Text out_a_extraFuncsDecl;
20153 output Tpl.Text out_a_extraFuncs;
20154 output Tpl.Text out_a_varDecls;
20155 output Tpl.Text out_a_preExp;
20156 algorithm
20157 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls, out_a_preExp) :=
20158 match(in_txt, in_a_context, in_a_varLst, in_a_cr, in_a_rhsStr, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_varDecls, in_a_preExp, in_a_exp)
20159 local
20160 Tpl.Text txt;
20161 list<DAE.Var> a_varLst;
20162 DAE.ComponentRef a_cr;
20163 String a_rhsStr;
20164 Boolean a_useFlatArrayNotation;
20165 Tpl.Text a_stateDerVectorName;
20166 Tpl.Text a_extraFuncsNamespace;
20167 Tpl.Text a_extraFuncsDecl;
20168 Tpl.Text a_extraFuncs;
20169 SimCode.SimCode a_simCode;
20170 Tpl.Text a_varDecls;
20171 Tpl.Text a_preExp;
20172 DAE.Exp a_exp;
20173 SimCodeFunction.Context i_context;
20174 DAE.ComponentRef ret_1;
20175 Tpl.Text l_lhsStr;
20176
20177 case ( txt,
20178 (i_context as SimCodeFunction.FUNCTION_CONTEXT(cref_prefix = _)),
20179 _,
20180 _,
20181 a_rhsStr,
20182 a_useFlatArrayNotation,
20183 a_stateDerVectorName,
20184 a_extraFuncsNamespace,
20185 a_extraFuncsDecl,
20186 a_extraFuncs,
20187 a_simCode,
20188 a_varDecls,
20189 a_preExp,
20190 a_exp )
20191 algorithm
20192 3 (l_lhsStr, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpCref(Tpl.emptyTxt, true, a_exp, i_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
20193 3 txt := Tpl.writeText(txt, l_lhsStr);
20194 3 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = "));
20195 3 txt := Tpl.writeStr(txt, a_rhsStr);
20196 3 txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
20197 3 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
20198
20199 case ( txt,
20200 i_context,
20201 a_varLst,
20202 a_cr,
20203 a_rhsStr,
20204 a_useFlatArrayNotation,
20205 a_stateDerVectorName,
20206 a_extraFuncsNamespace,
20207 a_extraFuncsDecl,
20208 a_extraFuncs,
20209 a_simCode,
20210 a_varDecls,
20211 a_preExp,
20212 _ )
20213 algorithm
20214 2 ret_1 := ComponentReference.crefStripSubs(a_cr);
20215 2 (l_lhsStr, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := contextCref(Tpl.emptyTxt, ret_1, i_context, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
20216 2 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()));
20217 2 txt := lm_384(txt, a_varLst, a_rhsStr, l_lhsStr);
20218 2 txt := Tpl.popIter(txt);
20219 2 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
20220 end match;
20221 end fun_385;
20222
20223 protected function lm_386
20224 input output Tpl.Text txt;
20225 input list<Integer> items;
20226 algorithm
20227 ✗ for lstElt_386 in items loop
20228 txt := match lstElt_386
20229 local
20230 Integer i_i;
20231
20232 case i_i
20233 algorithm
20234 ✗ txt := Tpl.writeStr(txt, intString(i_i));
20235 ✗ txt := Tpl.nextIter(txt);
20236 then txt;
20237 end match;
20238 end for;
20239 end lm_386;
20240
20241 protected function lm_387
20242 input output Tpl.Text txt;
20243 input list<tuple<DAE.Exp, list<Integer>>> items;
20244 input String a_rhsStr;
20245 input Boolean a_useFlatArrayNotation;
20246 input output Tpl.Text a_stateDerVectorName;
20247 input output Tpl.Text a_extraFuncsNamespace;
20248 input output Tpl.Text a_extraFuncsDecl;
20249 input output Tpl.Text a_extraFuncs;
20250 input SimCode.SimCode a_simCode;
20251 input output Tpl.Text a_varDecls;
20252 input output Tpl.Text a_preExp;
20253 input SimCodeFunction.Context a_context;
20254 algorithm
20255 ✗ for lstElt_387 in items loop
20256 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_387
20257 local
20258 list<Integer> i_indxs;
20259 DAE.Exp i_lhs;
20260 Tpl.Text l_indexStr;
20261 Tpl.Text l_lhsStr;
20262
20263 case (i_lhs, i_indxs)
20264 algorithm
20265 ✗ (l_lhsStr, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpCref(Tpl.emptyTxt, true, i_lhs, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
20266 ✗ l_indexStr := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(",")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
20267 ✗ l_indexStr := lm_386(l_indexStr, i_indxs);
20268 ✗ l_indexStr := Tpl.popIter(l_indexStr);
20269 ✗ txt := Tpl.writeText(txt, l_lhsStr);
20270 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = ("));
20271 ✗ txt := Tpl.writeStr(txt, a_rhsStr);
20272 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")("));
20273 ✗ txt := Tpl.writeText(txt, l_indexStr);
20274 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
20275 ✗ txt := Tpl.nextIter(txt);
20276 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
20277 end match;
20278 end for;
20279 end lm_387;
20280
20281 protected function lm_388
20282 input output Tpl.Text txt;
20283 input list<tuple<DAE.Exp, String>> items;
20284 input String a_rhsStr;
20285 input Boolean a_useFlatArrayNotation;
20286 input output Tpl.Text a_stateDerVectorName;
20287 input output Tpl.Text a_extraFuncsNamespace;
20288 input output Tpl.Text a_extraFuncsDecl;
20289 input output Tpl.Text a_extraFuncs;
20290 input SimCode.SimCode a_simCode;
20291 input output Tpl.Text a_varDecls;
20292 input output Tpl.Text a_preExp;
20293 input SimCodeFunction.Context a_context;
20294 algorithm
20295 ✗ for lstElt_388 in items loop
20296 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_388
20297 local
20298 String i_compn;
20299 DAE.Exp i_exp;
20300 DAE.ComponentRef ret_2;
20301 Tpl.Text l_compnStr;
20302 Tpl.Text l_lhsStr;
20303
20304 case (i_exp, i_compn)
20305 algorithm
20306 ✗ (l_lhsStr, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpCref(Tpl.emptyTxt, true, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
20307 ✗ ret_2 := ComponentReference.makeUntypedCrefIdent(i_compn);
20308 ✗ l_compnStr := crefStr(Tpl.emptyTxt, ret_2);
20309 ✗ txt := Tpl.writeText(txt, l_lhsStr);
20310 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = "));
20311 ✗ txt := Tpl.writeStr(txt, a_rhsStr);
20312 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("."));
20313 ✗ txt := Tpl.writeText(txt, l_compnStr);
20314 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
20315 ✗ txt := Tpl.nextIter(txt);
20316 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
20317 end match;
20318 end for;
20319 end lm_388;
20320
20321 public function writeLhsCref
20322 input Tpl.Text in_txt;
20323 input DAE.Exp in_a_exp;
20324 input String in_a_rhsStr;
20325 input SimCodeFunction.Context in_a_context;
20326 input Tpl.Text in_a_preExp;
20327 input Tpl.Text in_a_varDecls;
20328 input SimCode.SimCode in_a_simCode;
20329 input Tpl.Text in_a_extraFuncs;
20330 input Tpl.Text in_a_extraFuncsDecl;
20331 input Tpl.Text in_a_extraFuncsNamespace;
20332 input Tpl.Text in_a_stateDerVectorName;
20333 input Boolean in_a_useFlatArrayNotation;
20334
20335 output Tpl.Text out_txt;
20336 output Tpl.Text out_a_preExp;
20337 output Tpl.Text out_a_varDecls;
20338 output Tpl.Text out_a_extraFuncs;
20339 output Tpl.Text out_a_extraFuncsDecl;
20340 output Tpl.Text out_a_extraFuncsNamespace;
20341 output Tpl.Text out_a_stateDerVectorName;
20342 algorithm
20343 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
20344 match(in_txt, in_a_exp, in_a_rhsStr, in_a_context, in_a_preExp, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
20345 local
20346 Tpl.Text txt;
20347 String a_rhsStr;
20348 SimCodeFunction.Context a_context;
20349 Tpl.Text a_preExp;
20350 Tpl.Text a_varDecls;
20351 SimCode.SimCode a_simCode;
20352 Tpl.Text a_extraFuncs;
20353 Tpl.Text a_extraFuncsDecl;
20354 Tpl.Text a_extraFuncsNamespace;
20355 Tpl.Text a_stateDerVectorName;
20356 Boolean a_useFlatArrayNotation;
20357 list<String> i_comp;
20358 list<DAE.Exp> i_exps;
20359 DAE.Dimensions i_dims;
20360 list<DAE.Exp> i_expl;
20361 list<DAE.Var> i_varLst;
20362 DAE.Exp i_exp;
20363 DAE.Type i_t;
20364 DAE.Exp i_e;
20365 DAE.Type i_ty;
20366 DAE.ComponentRef i_cr;
20367 DAE.Exp i_ecr;
20368 Tpl.Text txt_7;
20369 Tpl.Text txt_6;
20370 list<tuple<DAE.Exp, String>> ret_5;
20371 list<tuple<DAE.Exp, list<Integer>>> ret_4;
20372 list<list<Integer>> ret_3;
20373 Tpl.Text l_body;
20374 SimCodeVar.SimVar ret_1;
20375 Tpl.Text l_lhsStr;
20376
20377 case ( txt,
20378 DAE.CREF(componentRef = DAE.WILD()),
20379 _,
20380 _,
20381 a_preExp,
20382 a_varDecls,
20383 _,
20384 a_extraFuncs,
20385 a_extraFuncsDecl,
20386 a_extraFuncsNamespace,
20387 a_stateDerVectorName,
20388 _ )
20389 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
20390
20391 case ( txt,
20392 (i_ecr as DAE.CREF(componentRef = i_cr, ty = (i_ty as DAE.T_ARRAY(ty = _)))),
20393 a_rhsStr,
20394 a_context,
20395 a_preExp,
20396 a_varDecls,
20397 a_simCode,
20398 a_extraFuncs,
20399 a_extraFuncsDecl,
20400 a_extraFuncsNamespace,
20401 a_stateDerVectorName,
20402 a_useFlatArrayNotation )
20403 algorithm
20404 12 (l_lhsStr, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpCref(Tpl.emptyTxt, true, i_ecr, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
20405 12 ret_1 := SimCodeCodegenUtil.cref2simvar(i_cr, a_simCode);
20406 12 txt := fun_382(txt, ret_1, i_ty, a_rhsStr, l_lhsStr);
20407 12 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
20408
20409 case ( txt,
20410 DAE.UNARY(exp = (i_e as DAE.CREF(ty = (i_t as DAE.T_ARRAY(ty = _))))),
20411 a_rhsStr,
20412 a_context,
20413 a_preExp,
20414 a_varDecls,
20415 a_simCode,
20416 a_extraFuncs,
20417 a_extraFuncsDecl,
20418 a_extraFuncsNamespace,
20419 a_stateDerVectorName,
20420 a_useFlatArrayNotation )
20421 algorithm
20422 ✗ (l_lhsStr, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpCref(Tpl.emptyTxt, true, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
20423 ✗ txt := fun_383(txt, a_context, l_lhsStr, a_rhsStr, i_t);
20424 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
20425
20426 case ( txt,
20427 (i_exp as DAE.CREF(componentRef = i_cr, ty = DAE.T_COMPLEX(varLst = i_varLst, complexClassType = ClassInf.RECORD(path = _)))),
20428 a_rhsStr,
20429 a_context,
20430 a_preExp,
20431 a_varDecls,
20432 a_simCode,
20433 a_extraFuncs,
20434 a_extraFuncsDecl,
20435 a_extraFuncsNamespace,
20436 a_stateDerVectorName,
20437 a_useFlatArrayNotation )
20438 algorithm
20439 5 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := fun_385(txt, a_context, i_varLst, i_cr, a_rhsStr, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, i_exp);
20440 5 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
20441
20442 case ( txt,
20443 (i_exp as DAE.CREF(componentRef = _)),
20444 a_rhsStr,
20445 a_context,
20446 a_preExp,
20447 a_varDecls,
20448 a_simCode,
20449 a_extraFuncs,
20450 a_extraFuncsDecl,
20451 a_extraFuncsNamespace,
20452 a_stateDerVectorName,
20453 a_useFlatArrayNotation )
20454 algorithm
20455 101 (l_lhsStr, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpCref(Tpl.emptyTxt, true, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
20456 101 txt := Tpl.writeText(txt, l_lhsStr);
20457 101 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = "));
20458 101 txt := Tpl.writeStr(txt, a_rhsStr);
20459 101 txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
20460 101 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
20461
20462 case ( txt,
20463 DAE.UNARY(exp = (i_e as DAE.CREF(componentRef = _))),
20464 a_rhsStr,
20465 a_context,
20466 a_preExp,
20467 a_varDecls,
20468 a_simCode,
20469 a_extraFuncs,
20470 a_extraFuncsDecl,
20471 a_extraFuncsNamespace,
20472 a_stateDerVectorName,
20473 a_useFlatArrayNotation )
20474 algorithm
20475 ✗ (l_lhsStr, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpCref(Tpl.emptyTxt, true, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
20476 ✗ txt := Tpl.writeText(txt, l_lhsStr);
20477 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = -"));
20478 ✗ txt := Tpl.writeStr(txt, a_rhsStr);
20479 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
20480 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
20481
20482 case ( txt,
20483 DAE.ARRAY(array = {}),
20484 _,
20485 _,
20486 a_preExp,
20487 a_varDecls,
20488 _,
20489 a_extraFuncs,
20490 a_extraFuncsDecl,
20491 a_extraFuncsNamespace,
20492 a_stateDerVectorName,
20493 _ )
20494 algorithm
20495 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
20496 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
20497
20498 case ( txt,
20499 DAE.ARRAY(ty = DAE.T_ARRAY(ty = _, dims = i_dims), array = i_expl),
20500 a_rhsStr,
20501 a_context,
20502 a_preExp,
20503 a_varDecls,
20504 a_simCode,
20505 a_extraFuncs,
20506 a_extraFuncsDecl,
20507 a_extraFuncsNamespace,
20508 a_stateDerVectorName,
20509 a_useFlatArrayNotation )
20510 algorithm
20511 ✗ ret_3 := SimCodeCodegenUtil.dimsToAllIndexes(i_dims);
20512 ✗ ret_4 := List.zip(i_expl, ret_3);
20513 ✗ l_body := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
20514 ✗ (l_body, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_387(l_body, ret_4, a_rhsStr, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
20515 ✗ l_body := Tpl.popIter(l_body);
20516 ✗ txt := Tpl.writeText(txt, l_body);
20517 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
20518
20519 case ( txt,
20520 DAE.RECORD(exps = i_exps, comp = i_comp),
20521 a_rhsStr,
20522 a_context,
20523 a_preExp,
20524 a_varDecls,
20525 a_simCode,
20526 a_extraFuncs,
20527 a_extraFuncsDecl,
20528 a_extraFuncsNamespace,
20529 a_stateDerVectorName,
20530 a_useFlatArrayNotation )
20531 algorithm
20532 ✗ ret_5 := List.zip(i_exps, i_comp);
20533 ✗ l_body := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
20534 ✗ (l_body, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_388(l_body, ret_5, a_rhsStr, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
20535 ✗ l_body := Tpl.popIter(l_body);
20536 ✗ txt := Tpl.writeText(txt, l_body);
20537 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
20538
20539 case ( txt,
20540 DAE.ASUB(exp = i_exp),
20541 a_rhsStr,
20542 _,
20543 a_preExp,
20544 a_varDecls,
20545 _,
20546 a_extraFuncs,
20547 a_extraFuncsDecl,
20548 a_extraFuncsNamespace,
20549 a_stateDerVectorName,
20550 _ )
20551 algorithm
20552 ✗ txt_6 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("writeLhsCref UNHANDLED ASUB (should never be part of a lhs expression): "));
20553 ✗ txt_6 := ExpressionDumpTpl.dumpExp(txt_6, i_exp, "\"");
20554 ✗ txt_6 := Tpl.writeTok(txt_6, Tpl.ST_STRING(" = "));
20555 ✗ txt_6 := Tpl.writeStr(txt_6, a_rhsStr);
20556 ✗ txt := error(txt, Tpl.sourceInfo("CodegenCppCommon.tpl", 2927, 9), Tpl.textString(txt_6));
20557 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
20558
20559 case ( txt,
20560 i_exp,
20561 a_rhsStr,
20562 _,
20563 a_preExp,
20564 a_varDecls,
20565 _,
20566 a_extraFuncs,
20567 a_extraFuncsDecl,
20568 a_extraFuncsNamespace,
20569 a_stateDerVectorName,
20570 _ )
20571 algorithm
20572 ✗ txt_7 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("writeLhsCref UNHANDLED: "));
20573 ✗ txt_7 := ExpressionDumpTpl.dumpExp(txt_7, i_exp, "\"");
20574 ✗ txt_7 := Tpl.writeTok(txt_7, Tpl.ST_STRING(" = "));
20575 ✗ txt_7 := Tpl.writeStr(txt_7, a_rhsStr);
20576 ✗ txt := error(txt, Tpl.sourceInfo("CodegenCppCommon.tpl", 2929, 9), Tpl.textString(txt_7));
20577 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
20578 end match;
20579 end writeLhsCref;
20580
20581 public function daeExpTsub
20582 input Tpl.Text in_txt;
20583 input DAE.Exp in_a_inExp;
20584 input SimCodeFunction.Context in_a_context;
20585 input Tpl.Text in_a_preExp;
20586 input Tpl.Text in_a_varDecls;
20587 input SimCode.SimCode in_a_simCode;
20588 input Tpl.Text in_a_extraFuncs;
20589 input Tpl.Text in_a_extraFuncsDecl;
20590 input Tpl.Text in_a_extraFuncsNamespace;
20591 input Tpl.Text in_a_stateDerVectorName;
20592 input Boolean in_a_useFlatArrayNotation;
20593
20594 output Tpl.Text out_txt;
20595 output Tpl.Text out_a_preExp;
20596 output Tpl.Text out_a_varDecls;
20597 output Tpl.Text out_a_extraFuncs;
20598 output Tpl.Text out_a_extraFuncsDecl;
20599 output Tpl.Text out_a_extraFuncsNamespace;
20600 output Tpl.Text out_a_stateDerVectorName;
20601 algorithm
20602 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
20603 match(in_txt, in_a_inExp, in_a_context, in_a_preExp, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
20604 local
20605 Tpl.Text txt;
20606 SimCodeFunction.Context a_context;
20607 Tpl.Text a_preExp;
20608 Tpl.Text a_varDecls;
20609 SimCode.SimCode a_simCode;
20610 Tpl.Text a_extraFuncs;
20611 Tpl.Text a_extraFuncsDecl;
20612 Tpl.Text a_extraFuncsNamespace;
20613 Tpl.Text a_stateDerVectorName;
20614 Boolean a_useFlatArrayNotation;
20615 DAE.Exp i_inExp;
20616 Integer i_ix;
20617 Absyn.Path i_p;
20618 DAE.Exp i_exp;
20619 Tpl.Text txt_5;
20620 Integer ret_4;
20621 Tpl.Text l_res;
20622 Tpl.Text l_retVar;
20623 Tpl.Text l_retType;
20624 Tpl.Text l_tuple__val;
20625
20626 case ( txt,
20627 DAE.TSUB(ix = 1, exp = i_exp),
20628 a_context,
20629 a_preExp,
20630 a_varDecls,
20631 a_simCode,
20632 a_extraFuncs,
20633 a_extraFuncsDecl,
20634 a_extraFuncsNamespace,
20635 a_stateDerVectorName,
20636 a_useFlatArrayNotation )
20637 algorithm
20638 13 (l_tuple__val, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
20639 13 txt := Tpl.writeTok(txt, Tpl.ST_STRING("get<0>("));
20640 13 txt := Tpl.writeText(txt, l_tuple__val);
20641 13 txt := Tpl.writeTok(txt, Tpl.ST_STRING(".data)"));
20642 13 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
20643
20644 case ( txt,
20645 DAE.TSUB(exp = (i_exp as DAE.CALL(path = i_p, attr = DAE.CALL_ATTR(ty = DAE.T_TUPLE(types = _)))), ix = i_ix),
20646 a_context,
20647 a_preExp,
20648 a_varDecls,
20649 a_simCode,
20650 a_extraFuncs,
20651 a_extraFuncsDecl,
20652 a_extraFuncsNamespace,
20653 a_stateDerVectorName,
20654 a_useFlatArrayNotation )
20655 algorithm
20656 8 l_retType := CodegenUtil.underscorePath(Tpl.emptyTxt, i_p);
20657 8 l_retType := Tpl.writeTok(l_retType, Tpl.ST_STRING("RetType"));
20658 8 (l_retVar, a_varDecls) := tempDecl(Tpl.emptyTxt, Tpl.textString(l_retType), a_varDecls);
20659 8 (l_res, l_retVar, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExpCallTuple(Tpl.emptyTxt, i_exp, l_retVar, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
20660 8 a_preExp := Tpl.writeText(a_preExp, l_res);
20661 8 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_STRING(";"));
20662 8 a_preExp := Tpl.writeTok(a_preExp, Tpl.ST_NEW_LINE());
20663 8 txt := Tpl.writeTok(txt, Tpl.ST_STRING("get<"));
20664 8 ret_4 := intAdd(-1, i_ix);
20665 8 txt := Tpl.writeStr(txt, intString(ret_4));
20666 8 txt := Tpl.writeTok(txt, Tpl.ST_STRING(">("));
20667 8 txt := Tpl.writeText(txt, l_retVar);
20668 8 txt := Tpl.writeTok(txt, Tpl.ST_STRING(".data)"));
20669 8 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
20670
20671 case ( txt,
20672 (i_inExp as DAE.TSUB(exp = _)),
20673 _,
20674 a_preExp,
20675 a_varDecls,
20676 _,
20677 a_extraFuncs,
20678 a_extraFuncsDecl,
20679 a_extraFuncsNamespace,
20680 a_stateDerVectorName,
20681 _ )
20682 algorithm
20683 ✗ txt_5 := ExpressionDumpTpl.dumpExp(Tpl.emptyTxt, i_inExp, "\"");
20684 ✗ txt_5 := Tpl.writeTok(txt_5, Tpl.ST_STRING(": TSUB only makes sense if the subscripted expression is a function call of tuple type"));
20685 ✗ txt := error(txt, Tpl.sourceInfo("CodegenCppCommon.tpl", 2952, 11), Tpl.textString(txt_5));
20686 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
20687
20688 case ( txt,
20689 _,
20690 _,
20691 a_preExp,
20692 a_varDecls,
20693 _,
20694 a_extraFuncs,
20695 a_extraFuncsDecl,
20696 a_extraFuncsNamespace,
20697 a_stateDerVectorName,
20698 _ )
20699 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
20700 end match;
20701 end daeExpTsub;
20702
20703 protected function lm_391
20704 input output Tpl.Text txt;
20705 input list<DAE.Exp> items;
20706 input Boolean a_useFlatArrayNotation;
20707 input output Tpl.Text a_stateDerVectorName;
20708 input output Tpl.Text a_extraFuncsNamespace;
20709 input output Tpl.Text a_extraFuncsDecl;
20710 input output Tpl.Text a_extraFuncs;
20711 input SimCode.SimCode a_simCode;
20712 input output Tpl.Text a_varDecls;
20713 input output Tpl.Text a_preExp;
20714 input SimCodeFunction.Context a_context;
20715 algorithm
20716
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 8 times.
60 for lstElt_391 in items loop
20717 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_391
20718 local
20719 DAE.Exp i_exp;
20720
20721 case i_exp
20722 algorithm
20723 52 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
20724 52 txt := Tpl.nextIter(txt);
20725 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
20726 end match;
20727 end for;
20728 end lm_391;
20729
20730 protected function lm_392
20731 input output Tpl.Text txt;
20732 input list<DAE.Exp> items;
20733 input Boolean a_useFlatArrayNotation;
20734 input output Tpl.Text a_stateDerVectorName;
20735 input output Tpl.Text a_extraFuncsNamespace;
20736 input output Tpl.Text a_extraFuncsDecl;
20737 input output Tpl.Text a_extraFuncs;
20738 input SimCode.SimCode a_simCode;
20739 input output Tpl.Text a_varDecls;
20740 input output Tpl.Text a_preExp;
20741 input SimCodeFunction.Context a_context;
20742 algorithm
20743 ✗ for lstElt_392 in items loop
20744 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_392
20745 local
20746 DAE.Exp i_exp;
20747
20748 case i_exp
20749 algorithm
20750 ✗ (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
20751 ✗ txt := Tpl.nextIter(txt);
20752 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
20753 end match;
20754 end for;
20755 end lm_392;
20756
20757 protected function fun_393
20758 input Tpl.Text in_txt;
20759 input Boolean in_mArg;
20760 input Boolean in_a_useFlatArrayNotation;
20761 input Tpl.Text in_a_stateDerVectorName;
20762 input Tpl.Text in_a_extraFuncsNamespace;
20763 input Tpl.Text in_a_extraFuncsDecl;
20764 input Tpl.Text in_a_extraFuncs;
20765 input SimCode.SimCode in_a_simCode;
20766 input Tpl.Text in_a_varDecls;
20767 input Tpl.Text in_a_preExp;
20768 input SimCodeFunction.Context in_a_context;
20769 input list<DAE.Exp> in_a_expLst;
20770
20771 output Tpl.Text out_txt;
20772 output Tpl.Text out_a_stateDerVectorName;
20773 output Tpl.Text out_a_extraFuncsNamespace;
20774 output Tpl.Text out_a_extraFuncsDecl;
20775 output Tpl.Text out_a_extraFuncs;
20776 output Tpl.Text out_a_varDecls;
20777 output Tpl.Text out_a_preExp;
20778 algorithm
20779 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls, out_a_preExp) :=
20780 match(in_txt, in_mArg, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_varDecls, in_a_preExp, in_a_context, in_a_expLst)
20781 local
20782 Tpl.Text txt;
20783 Boolean a_useFlatArrayNotation;
20784 Tpl.Text a_stateDerVectorName;
20785 Tpl.Text a_extraFuncsNamespace;
20786 Tpl.Text a_extraFuncsDecl;
20787 Tpl.Text a_extraFuncs;
20788 SimCode.SimCode a_simCode;
20789 Tpl.Text a_varDecls;
20790 Tpl.Text a_preExp;
20791 SimCodeFunction.Context a_context;
20792 list<DAE.Exp> a_expLst;
20793
20794 case ( txt,
20795 false,
20796 a_useFlatArrayNotation,
20797 a_stateDerVectorName,
20798 a_extraFuncsNamespace,
20799 a_extraFuncsDecl,
20800 a_extraFuncs,
20801 a_simCode,
20802 a_varDecls,
20803 a_preExp,
20804 a_context,
20805 a_expLst )
20806 algorithm
20807 8 txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
20808 8 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_391(txt, a_expLst, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
20809 8 txt := Tpl.popIter(txt);
20810 8 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
20811
20812 case ( txt,
20813 _,
20814 a_useFlatArrayNotation,
20815 a_stateDerVectorName,
20816 a_extraFuncsNamespace,
20817 a_extraFuncsDecl,
20818 a_extraFuncs,
20819 a_simCode,
20820 a_varDecls,
20821 a_preExp,
20822 a_context,
20823 a_expLst )
20824 algorithm
20825 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
20826 ✗ (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_392(txt, a_expLst, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
20827 ✗ txt := Tpl.popIter(txt);
20828 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
20829 end match;
20830 end fun_393;
20831
20832 protected function lm_394
20833 input output Tpl.Text txt;
20834 input list<DAE.Exp> items;
20835 input Boolean a_useFlatArrayNotation;
20836 input output Tpl.Text a_stateDerVectorName;
20837 input output Tpl.Text a_extraFuncsNamespace;
20838 input output Tpl.Text a_extraFuncsDecl;
20839 input output Tpl.Text a_extraFuncs;
20840 input SimCode.SimCode a_simCode;
20841 input output Tpl.Text a_varDecls;
20842 input output Tpl.Text a_preExp;
20843 input SimCodeFunction.Context a_context;
20844 algorithm
20845 ✗ for lstElt_394 in items loop
20846 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_394
20847 local
20848 DAE.Exp i_exp;
20849
20850 case i_exp
20851 algorithm
20852 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
20853 ✗ (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
20854 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
20855 end match;
20856 end for;
20857 end lm_394;
20858
20859 protected function fun_395
20860 input Tpl.Text in_txt;
20861 input Boolean in_a_attr_isFunctionPointerCall;
20862 input Boolean in_a_useFlatArrayNotation;
20863 input Tpl.Text in_a_stateDerVectorName;
20864 input Tpl.Text in_a_extraFuncsNamespace;
20865 input Tpl.Text in_a_extraFuncsDecl;
20866 input Tpl.Text in_a_extraFuncs;
20867 input SimCode.SimCode in_a_simCode;
20868 input Tpl.Text in_a_varDecls;
20869 input Tpl.Text in_a_preExp;
20870 input list<DAE.Exp> in_a_expLst;
20871 input DAE.Type in_a_attr_ty;
20872 input Tpl.Text in_a_additionalOutputs;
20873 input Tpl.Text in_a_argStr;
20874 input SimCodeFunction.Context in_a_context;
20875 input Absyn.Path in_a_path;
20876
20877 output Tpl.Text out_txt;
20878 output Tpl.Text out_a_stateDerVectorName;
20879 output Tpl.Text out_a_extraFuncsNamespace;
20880 output Tpl.Text out_a_extraFuncsDecl;
20881 output Tpl.Text out_a_extraFuncs;
20882 output Tpl.Text out_a_varDecls;
20883 output Tpl.Text out_a_preExp;
20884 algorithm
20885 (out_txt, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls, out_a_preExp) :=
20886 match(in_txt, in_a_attr_isFunctionPointerCall, in_a_useFlatArrayNotation, in_a_stateDerVectorName, in_a_extraFuncsNamespace, in_a_extraFuncsDecl, in_a_extraFuncs, in_a_simCode, in_a_varDecls, in_a_preExp, in_a_expLst, in_a_attr_ty, in_a_additionalOutputs, in_a_argStr, in_a_context, in_a_path)
20887 local
20888 Tpl.Text txt;
20889 Boolean a_useFlatArrayNotation;
20890 Tpl.Text a_stateDerVectorName;
20891 Tpl.Text a_extraFuncsNamespace;
20892 Tpl.Text a_extraFuncsDecl;
20893 Tpl.Text a_extraFuncs;
20894 SimCode.SimCode a_simCode;
20895 Tpl.Text a_varDecls;
20896 Tpl.Text a_preExp;
20897 list<DAE.Exp> a_expLst;
20898 DAE.Type a_attr_ty;
20899 Tpl.Text a_additionalOutputs;
20900 Tpl.Text a_argStr;
20901 SimCodeFunction.Context a_context;
20902 Absyn.Path a_path;
20903 Tpl.Text l_argStrPointer;
20904 Tpl.Text l_closure;
20905 Tpl.Text l_func;
20906 Tpl.Text l_typeCast2;
20907 Tpl.Text l_typeCast1;
20908 Tpl.Text l_name;
20909
20910 case ( txt,
20911 false,
20912 _,
20913 a_stateDerVectorName,
20914 a_extraFuncsNamespace,
20915 a_extraFuncsDecl,
20916 a_extraFuncs,
20917 _,
20918 a_varDecls,
20919 a_preExp,
20920 _,
20921 _,
20922 a_additionalOutputs,
20923 a_argStr,
20924 a_context,
20925 a_path )
20926 algorithm
20927 8 l_name := CodegenUtil.underscorePath(Tpl.emptyTxt, a_path);
20928 8 txt := contextFunName(txt, Tpl.textString(l_name), a_context);
20929 8 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
20930 8 txt := Tpl.writeText(txt, a_argStr);
20931 8 txt := Tpl.writeTok(txt, Tpl.ST_STRING(","));
20932 8 txt := Tpl.writeText(txt, a_additionalOutputs);
20933 8 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
20934 8 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
20935
20936 case ( txt,
20937 _,
20938 a_useFlatArrayNotation,
20939 a_stateDerVectorName,
20940 a_extraFuncsNamespace,
20941 a_extraFuncsDecl,
20942 a_extraFuncs,
20943 a_simCode,
20944 a_varDecls,
20945 a_preExp,
20946 a_expLst,
20947 a_attr_ty,
20948 a_additionalOutputs,
20949 a_argStr,
20950 a_context,
20951 a_path )
20952 algorithm
20953 ✗ (l_typeCast1, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := generateTypeCast(Tpl.emptyTxt, a_attr_ty, a_expLst, true, a_preExp, a_varDecls, a_context, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
20954 ✗ (l_typeCast2, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := generateTypeCast(Tpl.emptyTxt, a_attr_ty, a_expLst, false, a_preExp, a_varDecls, a_context, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
20955 ✗ l_name := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("_"));
20956 ✗ l_name := CodegenUtil.underscorePath(l_name, a_path);
20957 ✗ l_func := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("(MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR("));
20958 ✗ l_func := Tpl.writeText(l_func, l_name);
20959 ✗ l_func := Tpl.writeTok(l_func, Tpl.ST_STRING("), 1)))"));
20960 ✗ l_closure := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("(MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR("));
20961 ✗ l_closure := Tpl.writeText(l_closure, l_name);
20962 ✗ l_closure := Tpl.writeTok(l_closure, Tpl.ST_STRING("), 2)))"));
20963 ✗ l_argStrPointer := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("threadData, "));
20964 ✗ l_argStrPointer := Tpl.writeText(l_argStrPointer, l_closure);
20965 ✗ (l_argStrPointer, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_394(l_argStrPointer, a_expLst, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
20966 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("/*Closure?*/"));
20967 ✗ txt := Tpl.writeText(txt, l_closure);
20968 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" ? ("));
20969 ✗ txt := Tpl.writeText(txt, l_typeCast1);
20970 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
20971 ✗ txt := Tpl.writeText(txt, l_func);
20972 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(") ("));
20973 ✗ txt := Tpl.writeText(txt, l_argStrPointer);
20974 ✗ txt := Tpl.writeText(txt, a_additionalOutputs);
20975 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(") : ("));
20976 ✗ txt := Tpl.writeText(txt, l_typeCast2);
20977 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
20978 ✗ txt := Tpl.writeText(txt, l_func);
20979 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(") ("));
20980 ✗ txt := Tpl.writeText(txt, a_argStr);
20981 ✗ txt := Tpl.writeText(txt, a_additionalOutputs);
20982 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
20983 ✗ then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
20984 end match;
20985 end fun_395;
20986
20987 protected function fun_396
20988 input Tpl.Text in_txt;
20989 input DAE.Exp in_a_call;
20990 input Tpl.Text in_a_additionalOutputs;
20991 input SimCodeFunction.Context in_a_context;
20992 input Tpl.Text in_a_preExp;
20993 input Tpl.Text in_a_varDecls;
20994 input SimCode.SimCode in_a_simCode;
20995 input Tpl.Text in_a_extraFuncs;
20996 input Tpl.Text in_a_extraFuncsDecl;
20997 input Tpl.Text in_a_extraFuncsNamespace;
20998 input Tpl.Text in_a_stateDerVectorName;
20999 input Boolean in_a_useFlatArrayNotation;
21000
21001 output Tpl.Text out_txt;
21002 output Tpl.Text out_a_preExp;
21003 output Tpl.Text out_a_varDecls;
21004 output Tpl.Text out_a_extraFuncs;
21005 output Tpl.Text out_a_extraFuncsDecl;
21006 output Tpl.Text out_a_extraFuncsNamespace;
21007 output Tpl.Text out_a_stateDerVectorName;
21008 algorithm
21009 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
21010 match(in_txt, in_a_call, in_a_additionalOutputs, in_a_context, in_a_preExp, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
21011 local
21012 Tpl.Text txt;
21013 Tpl.Text a_additionalOutputs;
21014 SimCodeFunction.Context a_context;
21015 Tpl.Text a_preExp;
21016 Tpl.Text a_varDecls;
21017 SimCode.SimCode a_simCode;
21018 Tpl.Text a_extraFuncs;
21019 Tpl.Text a_extraFuncsDecl;
21020 Tpl.Text a_extraFuncsNamespace;
21021 Tpl.Text a_stateDerVectorName;
21022 Boolean a_useFlatArrayNotation;
21023 DAE.Type i_attr_ty;
21024 Absyn.Path i_path;
21025 Boolean i_attr_isFunctionPointerCall;
21026 list<DAE.Exp> i_expLst;
21027 Boolean i_attr_builtin;
21028 Boolean ret_2;
21029 Boolean ret_1;
21030 Tpl.Text l_argStr;
21031
21032 case ( txt,
21033 DAE.CALL(attr = DAE.CALL_ATTR(builtin = i_attr_builtin, isFunctionPointerCall = i_attr_isFunctionPointerCall, ty = i_attr_ty), expLst = i_expLst, path = i_path),
21034 a_additionalOutputs,
21035 a_context,
21036 a_preExp,
21037 a_varDecls,
21038 a_simCode,
21039 a_extraFuncs,
21040 a_extraFuncsDecl,
21041 a_extraFuncsNamespace,
21042 a_stateDerVectorName,
21043 a_useFlatArrayNotation )
21044 algorithm
21045 8 ret_1 := SimCodeFunctionUtil.isParallelFunctionContext(a_context);
21046 8 ret_2 := boolOr(i_attr_builtin, ret_1);
21047 8 (l_argStr, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := fun_393(Tpl.emptyTxt, ret_2, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context, i_expLst);
21048 8 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := fun_395(txt, i_attr_isFunctionPointerCall, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, i_expLst, i_attr_ty, a_additionalOutputs, l_argStr, a_context, i_path);
21049 8 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
21050
21051 case ( txt,
21052 _,
21053 _,
21054 _,
21055 a_preExp,
21056 a_varDecls,
21057 _,
21058 a_extraFuncs,
21059 a_extraFuncsDecl,
21060 a_extraFuncsNamespace,
21061 a_stateDerVectorName,
21062 _ )
21063 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
21064 end match;
21065 end fun_396;
21066
21067 public function daeExpCallTuple
21068 input Tpl.Text txt;
21069 input DAE.Exp a_call;
21070 input Tpl.Text a_additionalOutputs;
21071 input SimCodeFunction.Context a_context;
21072 input Tpl.Text a_preExp;
21073 input Tpl.Text a_varDecls;
21074 input SimCode.SimCode a_simCode;
21075 input Tpl.Text a_extraFuncs;
21076 input Tpl.Text a_extraFuncsDecl;
21077 input Tpl.Text a_extraFuncsNamespace;
21078 input Tpl.Text a_stateDerVectorName;
21079 input Boolean a_useFlatArrayNotation;
21080
21081 output Tpl.Text out_txt;
21082 output Tpl.Text out_a_additionalOutputs;
21083 output Tpl.Text out_a_preExp;
21084 output Tpl.Text out_a_varDecls;
21085 output Tpl.Text out_a_extraFuncs;
21086 output Tpl.Text out_a_extraFuncsDecl;
21087 output Tpl.Text out_a_extraFuncsNamespace;
21088 output Tpl.Text out_a_stateDerVectorName;
21089 algorithm
21090 8 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) := fun_396(txt, a_call, a_additionalOutputs, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
21091 out_a_additionalOutputs := a_additionalOutputs;
21092 end daeExpCallTuple;
21093
21094 protected function fun_398
21095 input Tpl.Text in_txt;
21096 input DAE.Type in_a_ty;
21097
21098 output Tpl.Text out_txt;
21099 algorithm
21100 out_txt :=
21101 match(in_txt, in_a_ty)
21102 local
21103 Tpl.Text txt;
21104
21105 case ( txt,
21106 DAE.T_NORETCALL() )
21107 algorithm
21108 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("void"));
21109 then txt;
21110
21111 case ( txt,
21112 _ )
21113 algorithm
21114 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_metatype"));
21115 then txt;
21116 end match;
21117 end fun_398;
21118
21119 protected function lm_399
21120 input output Tpl.Text txt;
21121 input list<DAE.Exp> items;
21122 input Boolean a_useFlatArrayNotation;
21123 input output Tpl.Text a_stateDerVectorName;
21124 input output Tpl.Text a_extraFuncsNamespace;
21125 input output Tpl.Text a_extraFuncsDecl;
21126 input output Tpl.Text a_extraFuncs;
21127 input SimCode.SimCode a_simCode;
21128 input output Tpl.Text a_varDecls;
21129 input output Tpl.Text a_preExp;
21130 input SimCodeFunction.Context a_context;
21131 algorithm
21132 ✗ for lstElt_399 in items loop
21133 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_399
21134 local
21135 DAE.Exp i_e;
21136
21137 case i_e
21138 algorithm
21139 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
21140 ✗ (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := expTypeFromExpArrayIf(txt, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
21141 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
21142 end match;
21143 end for;
21144 end lm_399;
21145
21146 protected function lm_400
21147 input output Tpl.Text txt;
21148 input list<DAE.Type> items;
21149 algorithm
21150 ✗ for lstElt_400 in items loop
21151 txt := match lstElt_400
21152 local
21153 DAE.Type i_t;
21154
21155 case i_t
21156 algorithm
21157 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
21158 ✗ txt := expTypeArrayIf(txt, i_t);
21159 then txt;
21160 end match;
21161 end for;
21162 end lm_400;
21163
21164 protected function fun_401
21165 input Tpl.Text in_txt;
21166 input DAE.Type in_a_ty;
21167
21168 output Tpl.Text out_txt;
21169 algorithm
21170 out_txt :=
21171 match(in_txt, in_a_ty)
21172 local
21173 Tpl.Text txt;
21174 list<DAE.Type> i_tys;
21175
21176 case ( txt,
21177 DAE.T_TUPLE(types = _ :: i_tys) )
21178 algorithm
21179 ✗ txt := lm_400(txt, i_tys);
21180 then txt;
21181
21182 case ( txt,
21183 _ )
21184 then txt;
21185 end match;
21186 end fun_401;
21187
21188 protected function fun_402
21189 input Tpl.Text in_txt;
21190 input Boolean in_a_isClosure;
21191
21192 output Tpl.Text out_txt;
21193 algorithm
21194 out_txt :=
21195 match(in_txt, in_a_isClosure)
21196 local
21197 Tpl.Text txt;
21198
21199 case ( txt,
21200 false )
21201 then txt;
21202
21203 case ( txt,
21204 _ )
21205 algorithm
21206 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(", modelica_metatype"));
21207 then txt;
21208 end match;
21209 end fun_402;
21210
21211 public function generateTypeCast
21212 input Tpl.Text txt;
21213 input DAE.Type a_ty;
21214 input list<DAE.Exp> a_es;
21215 input Boolean a_isClosure;
21216 input Tpl.Text a_preExp;
21217 input Tpl.Text a_varDecls;
21218 input SimCodeFunction.Context a_context;
21219 input SimCode.SimCode a_simCode;
21220 input Tpl.Text a_extraFuncs;
21221 input Tpl.Text a_extraFuncsDecl;
21222 input Tpl.Text a_extraFuncsNamespace;
21223 input Tpl.Text a_stateDerVectorName;
21224 input Boolean a_useFlatArrayNotation;
21225
21226 output Tpl.Text out_txt;
21227 output Tpl.Text out_a_preExp;
21228 output Tpl.Text out_a_varDecls;
21229 output Tpl.Text out_a_extraFuncs;
21230 output Tpl.Text out_a_extraFuncsDecl;
21231 output Tpl.Text out_a_extraFuncsNamespace;
21232 output Tpl.Text out_a_stateDerVectorName;
21233 protected
21234 Tpl.Text l_outputs;
21235 Tpl.Text l_inputs;
21236 Tpl.Text l_ret;
21237 algorithm
21238 ✗ l_ret := fun_398(Tpl.emptyTxt, a_ty);
21239 ✗ (l_inputs, out_a_stateDerVectorName, out_a_extraFuncsNamespace, out_a_extraFuncsDecl, out_a_extraFuncs, out_a_varDecls, out_a_preExp) := lm_399(Tpl.emptyTxt, a_es, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
21240 ✗ l_outputs := fun_401(Tpl.emptyTxt, a_ty);
21241 ✗ out_txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
21242 ✗ out_txt := Tpl.writeText(out_txt, l_ret);
21243 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("(*)(threadData_t*"));
21244 ✗ out_txt := fun_402(out_txt, a_isClosure);
21245 ✗ out_txt := Tpl.writeText(out_txt, l_inputs);
21246 ✗ out_txt := Tpl.writeText(out_txt, l_outputs);
21247 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("))"));
21248 end generateTypeCast;
21249
21250 protected function fun_404
21251 input Tpl.Text in_txt;
21252 input DAE.Exp in_a_exp;
21253 input SimCodeFunction.Context in_a_context;
21254
21255 output Tpl.Text out_txt;
21256 algorithm
21257 out_txt :=
21258 match(in_txt, in_a_exp, in_a_context)
21259 local
21260 Tpl.Text txt;
21261 SimCodeFunction.Context a_context;
21262 Integer i_exp_index;
21263 Tpl.Text l_lit;
21264
21265 case ( txt,
21266 DAE.SHARED_LITERAL(index = i_exp_index),
21267 a_context )
21268 algorithm
21269 2092 l_lit := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("_OMC_LIT"));
21270 2092 l_lit := Tpl.writeStr(l_lit, intString(i_exp_index));
21271 2092 txt := contextFunName(txt, Tpl.textString(l_lit), a_context);
21272 then txt;
21273
21274 case ( txt,
21275 _,
21276 _ )
21277 then txt;
21278 end match;
21279 end fun_404;
21280
21281 public function daeExpSharedLiteral
21282 input Tpl.Text txt;
21283 input DAE.Exp a_exp;
21284 input SimCodeFunction.Context a_context;
21285 input Tpl.Text a_preExp;
21286 input Tpl.Text a_varDecls;
21287 input Boolean a_useFlatArrayNotation;
21288
21289 output Tpl.Text out_txt;
21290 output Tpl.Text out_a_preExp;
21291 output Tpl.Text out_a_varDecls;
21292 algorithm
21293 2092 out_txt := fun_404(txt, a_exp, a_context);
21294 out_a_preExp := a_preExp;
21295 out_a_varDecls := a_varDecls;
21296 end daeExpSharedLiteral;
21297
21298 protected function lm_406
21299 input output Tpl.Text txt;
21300 input list<DAE.Exp> items;
21301 input Boolean a_useFlatArrayNotation;
21302 input output Tpl.Text a_stateDerVectorName;
21303 input output Tpl.Text a_extraFuncsNamespace;
21304 input output Tpl.Text a_extraFuncsDecl;
21305 input output Tpl.Text a_extraFuncs;
21306 input SimCode.SimCode a_simCode;
21307 input output Tpl.Text a_varDecls;
21308 input output Tpl.Text a_preExp;
21309 input SimCodeFunction.Context a_context;
21310 algorithm
21311
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 16 times.
64 for lstElt_406 in items loop
21312 (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := match lstElt_406
21313 local
21314 DAE.Exp i_e;
21315
21316 case i_e
21317 algorithm
21318 48 txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
21319 48 (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(txt, i_e, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
21320 then (txt, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp);
21321 end match;
21322 end for;
21323 end lm_406;
21324
21325 public function daeExpPartEvalFunction
21326 input Tpl.Text in_txt;
21327 input DAE.Exp in_a_exp;
21328 input SimCodeFunction.Context in_a_context;
21329 input Tpl.Text in_a_preExp;
21330 input Tpl.Text in_a_varDecls;
21331 input SimCode.SimCode in_a_simCode;
21332 input Tpl.Text in_a_extraFuncs;
21333 input Tpl.Text in_a_extraFuncsDecl;
21334 input Tpl.Text in_a_extraFuncsNamespace;
21335 input Tpl.Text in_a_stateDerVectorName;
21336 input Boolean in_a_useFlatArrayNotation;
21337
21338 output Tpl.Text out_txt;
21339 output Tpl.Text out_a_preExp;
21340 output Tpl.Text out_a_varDecls;
21341 output Tpl.Text out_a_extraFuncs;
21342 output Tpl.Text out_a_extraFuncsDecl;
21343 output Tpl.Text out_a_extraFuncsNamespace;
21344 output Tpl.Text out_a_stateDerVectorName;
21345 algorithm
21346 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
21347 match(in_txt, in_a_exp, in_a_context, in_a_preExp, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
21348 local
21349 Tpl.Text txt;
21350 SimCodeFunction.Context a_context;
21351 Tpl.Text a_preExp;
21352 Tpl.Text a_varDecls;
21353 SimCode.SimCode a_simCode;
21354 Tpl.Text a_extraFuncs;
21355 Tpl.Text a_extraFuncsDecl;
21356 Tpl.Text a_extraFuncsNamespace;
21357 Tpl.Text a_stateDerVectorName;
21358 Boolean a_useFlatArrayNotation;
21359 DAE.Type i_origType;
21360 DAE.Type i_ty;
21361 DAE.Exp i_exp;
21362 DAE.Type i_t__orig;
21363 DAE.Type i_t;
21364 list<DAE.Exp> i_expList;
21365 Absyn.Path i_name;
21366 Tpl.Text txt_2;
21367 String ret_3;
21368 String ret_2;
21369 Tpl.Text l_closureArgs;
21370 Tpl.Text l_funcName;
21371
21372 case ( txt,
21373 DAE.PARTEVALFUNCTION(ty = DAE.T_FUNCTION_REFERENCE_VAR(functionType = i_t), origType = DAE.T_FUNCTION_REFERENCE_VAR(functionType = (i_t__orig as DAE.T_FUNCTION(path = i_name))), expList = i_expList),
21374 a_context,
21375 a_preExp,
21376 a_varDecls,
21377 a_simCode,
21378 a_extraFuncs,
21379 a_extraFuncsDecl,
21380 a_extraFuncsNamespace,
21381 a_stateDerVectorName,
21382 a_useFlatArrayNotation )
21383 algorithm
21384 16 l_funcName := CodegenUtil.underscorePath(Tpl.emptyTxt, i_name);
21385 16 (l_closureArgs, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_varDecls, a_preExp) := lm_406(Tpl.emptyTxt, i_expList, a_useFlatArrayNotation, a_stateDerVectorName, a_extraFuncsNamespace, a_extraFuncsDecl, a_extraFuncs, a_simCode, a_varDecls, a_preExp, a_context);
21386 16 (txt, a_extraFuncsDecl) := functionClosure(txt, Tpl.textString(l_funcName), Tpl.textString(l_closureArgs), i_t, i_t__orig, a_context, a_extraFuncsDecl);
21387 16 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
21388
21389 case ( txt,
21390 (i_exp as DAE.PARTEVALFUNCTION(ty = i_ty, origType = i_origType)),
21391 _,
21392 a_preExp,
21393 a_varDecls,
21394 _,
21395 a_extraFuncs,
21396 a_extraFuncsDecl,
21397 a_extraFuncsNamespace,
21398 a_stateDerVectorName,
21399 _ )
21400 algorithm
21401 ✗ txt_2 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("PARTEVALFUNCTION: "));
21402 ✗ txt_2 := ExpressionDumpTpl.dumpExp(txt_2, i_exp, "\"");
21403 ✗ txt_2 := Tpl.writeTok(txt_2, Tpl.ST_STRING(", ty="));
21404 ✗ ret_2 := TypesDump.unparseType(i_ty);
21405 ✗ txt_2 := Tpl.writeStr(txt_2, ret_2);
21406 ✗ txt_2 := Tpl.writeTok(txt_2, Tpl.ST_STRING(", origType="));
21407 ✗ ret_3 := TypesDump.unparseType(i_origType);
21408 ✗ txt_2 := Tpl.writeStr(txt_2, ret_3);
21409 ✗ txt := error(txt, Tpl.sourceInfo("CodegenCppCommon.tpl", 3008, 11), Tpl.textString(txt_2));
21410 ✗ then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
21411
21412 case ( txt,
21413 _,
21414 _,
21415 a_preExp,
21416 a_varDecls,
21417 _,
21418 a_extraFuncs,
21419 a_extraFuncsDecl,
21420 a_extraFuncsNamespace,
21421 a_stateDerVectorName,
21422 _ )
21423 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
21424 end match;
21425 end daeExpPartEvalFunction;
21426
21427 protected function fun_408
21428 input Tpl.Text in_txt;
21429 input SimCodeFunction.Context in_a_context;
21430
21431 output Tpl.Text out_txt;
21432 algorithm
21433 out_txt :=
21434 match(in_txt, in_a_context)
21435 local
21436 Tpl.Text txt;
21437
21438 case ( txt,
21439 SimCodeFunction.FUNCTION_CONTEXT(cref_prefix = _) )
21440 algorithm
21441 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("this"));
21442 then txt;
21443
21444 case ( txt,
21445 _ )
21446 algorithm
21447 16 txt := Tpl.writeTok(txt, Tpl.ST_STRING("_functions"));
21448 then txt;
21449 end match;
21450 end fun_408;
21451
21452 protected function lm_409
21453 input output Tpl.Text txt;
21454 input list<DAE.FuncArg> items;
21455 algorithm
21456
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 16 times.
64 for lstElt_409 in items loop
21457 txt := match lstElt_409
21458 local
21459 String i_a_name;
21460 DAE.Type i_a_ty;
21461
21462 case DAE.FUNCARG(ty = i_a_ty, name = i_a_name)
21463 algorithm
21464 48 txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
21465 48 txt := expTypeUnboxed(txt, i_a_ty);
21466 48 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
21467 48 txt := Tpl.writeStr(txt, i_a_name);
21468 then txt;
21469
21470 case _
21471 then txt;
21472 end match;
21473 end for;
21474 end lm_409;
21475
21476 protected function lm_410
21477 input output Tpl.Text txt;
21478 input list<DAE.FuncArg> items;
21479 algorithm
21480
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
32 for lstElt_410 in items loop
21481 txt := match lstElt_410
21482 local
21483 String i_a_name;
21484 DAE.Type i_a_ty;
21485
21486 case DAE.FUNCARG(ty = i_a_ty, name = i_a_name)
21487 algorithm
21488 16 txt := expTypeUnboxed(txt, i_a_ty);
21489 16 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
21490 16 txt := Tpl.writeStr(txt, i_a_name);
21491 16 txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
21492 then txt;
21493
21494 case _
21495 then txt;
21496 end match;
21497 end for;
21498 end lm_410;
21499
21500 protected function lm_411
21501 input output Tpl.Text txt;
21502 input list<DAE.FuncArg> items;
21503 algorithm
21504
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 16 times.
80 for lstElt_411 in items loop
21505 txt := match lstElt_411
21506 local
21507 String i_a_name;
21508
21509 case DAE.FUNCARG(name = i_a_name)
21510 algorithm
21511 64 txt := Tpl.writeStr(txt, i_a_name);
21512 64 txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
21513 then txt;
21514
21515 case _
21516 then txt;
21517 end match;
21518 end for;
21519 end lm_411;
21520
21521 protected function lm_412
21522 input output Tpl.Text txt;
21523 input list<DAE.FuncArg> items;
21524 algorithm
21525
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 16 times.
64 for lstElt_412 in items loop
21526 txt := match lstElt_412
21527 local
21528 String i_a_name;
21529 DAE.Type i_a_ty;
21530
21531 case DAE.FUNCARG(ty = i_a_ty, name = i_a_name)
21532 algorithm
21533 48 txt := expTypeUnboxed(txt, i_a_ty);
21534 48 txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
21535 48 txt := Tpl.writeStr(txt, i_a_name);
21536 48 txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
21537 48 txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
21538 then txt;
21539
21540 case _
21541 then txt;
21542 end match;
21543 end for;
21544 end lm_412;
21545
21546 protected function lm_413
21547 input output Tpl.Text txt;
21548 input list<DAE.FuncArg> items;
21549 algorithm
21550
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 16 times.
64 for lstElt_413 in items loop
21551 txt := match lstElt_413
21552 local
21553 String i_a_name;
21554
21555 case DAE.FUNCARG(name = i_a_name)
21556 algorithm
21557 48 txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
21558 48 txt := Tpl.writeStr(txt, i_a_name);
21559 48 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
21560 48 txt := Tpl.writeStr(txt, i_a_name);
21561 48 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
21562 48 txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
21563 then txt;
21564
21565 case _
21566 then txt;
21567 end match;
21568 end for;
21569 end lm_413;
21570
21571 protected function fun_414
21572 input Tpl.Text in_txt;
21573 input DAE.Type in_a_t__orig;
21574 input String in_a_closureArgs;
21575 input Tpl.Text in_a_extraFuncsDecl;
21576 input list<DAE.FuncArg> in_a_funcArgs;
21577 input SimCodeFunction.Context in_a_context;
21578 input String in_a_funcName;
21579
21580 output Tpl.Text out_txt;
21581 output Tpl.Text out_a_extraFuncsDecl;
21582 algorithm
21583 (out_txt, out_a_extraFuncsDecl) :=
21584 match(in_txt, in_a_t__orig, in_a_closureArgs, in_a_extraFuncsDecl, in_a_funcArgs, in_a_context, in_a_funcName)
21585 local
21586 Tpl.Text txt;
21587 String a_closureArgs;
21588 Tpl.Text a_extraFuncsDecl;
21589 list<DAE.FuncArg> a_funcArgs;
21590 SimCodeFunction.Context a_context;
21591 String a_funcName;
21592 list<DAE.FuncArg> i_funcArgsOrig;
21593 list<DAE.FuncArg> ret_8;
21594 list<DAE.FuncArg> ret_7;
21595 Tpl.Text l_callArgsOrig;
21596 Tpl.Text l_callArgsDecl;
21597 list<DAE.FuncArg> ret_4;
21598 Tpl.Text l_closureArgsDecl;
21599 Tpl.Text l_functionsObject;
21600 Integer ret_1;
21601 Tpl.Text l_closureName;
21602
21603 case ( txt,
21604 DAE.T_FUNCTION(funcArg = i_funcArgsOrig),
21605 a_closureArgs,
21606 a_extraFuncsDecl,
21607 a_funcArgs,
21608 a_context,
21609 a_funcName )
21610 algorithm
21611 16 l_closureName := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("_Closure"));
21612 16 ret_1 := System.tmpTickIndex(2);
21613 16 l_closureName := Tpl.writeStr(l_closureName, intString(ret_1));
21614 16 l_closureName := Tpl.writeTok(l_closureName, Tpl.ST_STRING("_"));
21615 16 l_closureName := Tpl.writeStr(l_closureName, a_funcName);
21616 16 l_functionsObject := fun_408(Tpl.emptyTxt, a_context);
21617 16 ret_4 := List.setDifference(i_funcArgsOrig, a_funcArgs);
21618 16 l_closureArgsDecl := lm_409(Tpl.emptyTxt, ret_4);
21619 16 l_callArgsDecl := lm_410(Tpl.emptyTxt, a_funcArgs);
21620 16 l_callArgsOrig := lm_411(Tpl.emptyTxt, i_funcArgsOrig);
21621 16 a_extraFuncsDecl := Tpl.writeTok(a_extraFuncsDecl, Tpl.ST_STRING_LIST({
21622 "\n",
21623 "class "
21624 }, false));
21625 16 a_extraFuncsDecl := Tpl.writeText(a_extraFuncsDecl, l_closureName);
21626 16 a_extraFuncsDecl := Tpl.softNewLine(a_extraFuncsDecl);
21627 16 a_extraFuncsDecl := Tpl.writeTok(a_extraFuncsDecl, Tpl.ST_STRING_LIST({
21628 "{\n",
21629 " Functions* _functions;\n"
21630 }, true));
21631 16 a_extraFuncsDecl := Tpl.pushBlock(a_extraFuncsDecl, Tpl.BT_INDENT(2));
21632 16 ret_7 := List.setDifference(i_funcArgsOrig, a_funcArgs);
21633 16 a_extraFuncsDecl := lm_412(a_extraFuncsDecl, ret_7);
21634 16 a_extraFuncsDecl := Tpl.softNewLine(a_extraFuncsDecl);
21635 16 a_extraFuncsDecl := Tpl.popBlock(a_extraFuncsDecl);
21636 16 a_extraFuncsDecl := Tpl.writeTok(a_extraFuncsDecl, Tpl.ST_LINE(" public:\n"));
21637 16 a_extraFuncsDecl := Tpl.pushBlock(a_extraFuncsDecl, Tpl.BT_INDENT(2));
21638 16 a_extraFuncsDecl := Tpl.writeText(a_extraFuncsDecl, l_closureName);
21639 16 a_extraFuncsDecl := Tpl.writeTok(a_extraFuncsDecl, Tpl.ST_STRING("(Functions* functions"));
21640 16 a_extraFuncsDecl := Tpl.writeText(a_extraFuncsDecl, l_closureArgsDecl);
21641 16 a_extraFuncsDecl := Tpl.writeTok(a_extraFuncsDecl, Tpl.ST_STRING_LIST({
21642 ")\n",
21643 " : _functions(functions)\n"
21644 }, true));
21645 16 a_extraFuncsDecl := Tpl.pushBlock(a_extraFuncsDecl, Tpl.BT_INDENT(2));
21646 16 ret_8 := List.setDifference(i_funcArgsOrig, a_funcArgs);
21647 16 a_extraFuncsDecl := lm_413(a_extraFuncsDecl, ret_8);
21648 16 a_extraFuncsDecl := Tpl.softNewLine(a_extraFuncsDecl);
21649 16 a_extraFuncsDecl := Tpl.popBlock(a_extraFuncsDecl);
21650 16 a_extraFuncsDecl := Tpl.writeTok(a_extraFuncsDecl, Tpl.ST_STRING_LIST({
21651 "{}\n",
21652 "void operator()("
21653 }, false));
21654 16 a_extraFuncsDecl := Tpl.writeText(a_extraFuncsDecl, l_callArgsDecl);
21655 16 a_extraFuncsDecl := Tpl.writeStr(a_extraFuncsDecl, a_funcName);
21656 16 a_extraFuncsDecl := Tpl.writeTok(a_extraFuncsDecl, Tpl.ST_LINE("RetType &output) {\n"));
21657 16 a_extraFuncsDecl := Tpl.pushBlock(a_extraFuncsDecl, Tpl.BT_INDENT(2));
21658 16 a_extraFuncsDecl := Tpl.writeTok(a_extraFuncsDecl, Tpl.ST_STRING("_functions->"));
21659 16 a_extraFuncsDecl := Tpl.writeStr(a_extraFuncsDecl, a_funcName);
21660 16 a_extraFuncsDecl := Tpl.writeTok(a_extraFuncsDecl, Tpl.ST_STRING("("));
21661 16 a_extraFuncsDecl := Tpl.writeText(a_extraFuncsDecl, l_callArgsOrig);
21662 16 a_extraFuncsDecl := Tpl.writeTok(a_extraFuncsDecl, Tpl.ST_LINE("output);\n"));
21663 16 a_extraFuncsDecl := Tpl.popBlock(a_extraFuncsDecl);
21664 16 a_extraFuncsDecl := Tpl.writeTok(a_extraFuncsDecl, Tpl.ST_LINE("}\n"));
21665 16 a_extraFuncsDecl := Tpl.popBlock(a_extraFuncsDecl);
21666 16 a_extraFuncsDecl := Tpl.writeTok(a_extraFuncsDecl, Tpl.ST_STRING("};"));
21667 16 a_extraFuncsDecl := Tpl.writeTok(a_extraFuncsDecl, Tpl.ST_NEW_LINE());
21668 16 txt := Tpl.writeText(txt, l_closureName);
21669 16 txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
21670 16 txt := Tpl.writeText(txt, l_functionsObject);
21671 16 txt := Tpl.writeStr(txt, a_closureArgs);
21672 16 txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
21673 then (txt, a_extraFuncsDecl);
21674
21675 case ( txt,
21676 _,
21677 _,
21678 a_extraFuncsDecl,
21679 _,
21680 _,
21681 _ )
21682 then (txt, a_extraFuncsDecl);
21683 end match;
21684 end fun_414;
21685
21686 protected function fun_415
21687 input Tpl.Text in_txt;
21688 input DAE.Type in_a_t;
21689 input String in_a_funcName;
21690 input String in_a_closureArgs;
21691 input DAE.Type in_a_t__orig;
21692 input SimCodeFunction.Context in_a_context;
21693 input Tpl.Text in_a_extraFuncsDecl;
21694
21695 output Tpl.Text out_txt;
21696 output Tpl.Text out_a_extraFuncsDecl;
21697 algorithm
21698 (out_txt, out_a_extraFuncsDecl) :=
21699 match(in_txt, in_a_t, in_a_funcName, in_a_closureArgs, in_a_t__orig, in_a_context, in_a_extraFuncsDecl)
21700 local
21701 Tpl.Text txt;
21702 String a_funcName;
21703 String a_closureArgs;
21704 DAE.Type a_t__orig;
21705 SimCodeFunction.Context a_context;
21706 Tpl.Text a_extraFuncsDecl;
21707 list<DAE.FuncArg> i_funcArgs;
21708
21709 case ( txt,
21710 DAE.T_FUNCTION(funcArg = i_funcArgs),
21711 a_funcName,
21712 a_closureArgs,
21713 a_t__orig,
21714 a_context,
21715 a_extraFuncsDecl )
21716 algorithm
21717 16 (txt, a_extraFuncsDecl) := fun_414(txt, a_t__orig, a_closureArgs, a_extraFuncsDecl, i_funcArgs, a_context, a_funcName);
21718 then (txt, a_extraFuncsDecl);
21719
21720 case ( txt,
21721 _,
21722 _,
21723 _,
21724 _,
21725 _,
21726 a_extraFuncsDecl )
21727 ✗ then (txt, a_extraFuncsDecl);
21728 end match;
21729 end fun_415;
21730
21731 public function functionClosure
21732 input Tpl.Text txt;
21733 input String a_funcName;
21734 input String a_closureArgs;
21735 input DAE.Type a_t;
21736 input DAE.Type a_t__orig;
21737 input SimCodeFunction.Context a_context;
21738 input Tpl.Text a_extraFuncsDecl;
21739
21740 output Tpl.Text out_txt;
21741 output Tpl.Text out_a_extraFuncsDecl;
21742 algorithm
21743 16 (out_txt, out_a_extraFuncsDecl) := fun_415(txt, a_t, a_funcName, a_closureArgs, a_t__orig, a_context, a_extraFuncsDecl);
21744 end functionClosure;
21745
21746 protected function fun_417
21747 input Tpl.Text in_txt;
21748 input SimCodeFunction.Context in_a_context;
21749 input Tpl.Text in_a_condVar;
21750 input Tpl.Text in_a_msgVar;
21751
21752 output Tpl.Text out_txt;
21753 algorithm
21754 out_txt :=
21755 match(in_txt, in_a_context, in_a_condVar, in_a_msgVar)
21756 local
21757 Tpl.Text txt;
21758 Tpl.Text a_condVar;
21759 Tpl.Text a_msgVar;
21760
21761 case ( txt,
21762 SimCodeFunction.FUNCTION_CONTEXT(is_parallel = true),
21763 a_condVar,
21764 _ )
21765 algorithm
21766 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("if(!("));
21767 ✗ txt := Tpl.writeText(txt, a_condVar);
21768 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
21769 "))\n",
21770 "{\n",
21771 "\n",
21772 " throw ModelicaSimulationError(MODEL_EQ_SYSTEM, \"Common assertion failed\");\n",
21773 "\n",
21774 "}"
21775 }, false));
21776 then txt;
21777
21778 case ( txt,
21779 SimCodeFunction.FUNCTION_CONTEXT(cref_prefix = _),
21780 a_condVar,
21781 a_msgVar )
21782 algorithm
21783 56 txt := Tpl.writeTok(txt, Tpl.ST_STRING("if(!("));
21784 56 txt := Tpl.writeText(txt, a_condVar);
21785 56 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
21786 "))\n",
21787 "{\n",
21788 "\n"
21789 }, true));
21790 56 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
21791 56 txt := Tpl.writeTok(txt, Tpl.ST_STRING("throw ModelicaSimulationError(MODEL_EQ_SYSTEM, "));
21792 56 txt := Tpl.writeText(txt, a_msgVar);
21793 56 txt := Tpl.writeTok(txt, Tpl.ST_LINE(");\n"));
21794 56 txt := Tpl.popBlock(txt);
21795 56 txt := Tpl.writeTok(txt, Tpl.ST_STRING("}"));
21796 then txt;
21797
21798 case ( txt,
21799 _,
21800 a_condVar,
21801 a_msgVar )
21802 algorithm
21803 20 txt := Tpl.writeTok(txt, Tpl.ST_STRING("if(!("));
21804 20 txt := Tpl.writeText(txt, a_condVar);
21805 20 txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
21806 "))\n",
21807 "{\n",
21808 " //string error_msg = \"The following assertion has been violated %sat time %f\", initial() ? \"during initialization \" : \"\", data->localData[0]->timeValue);\n"
21809 }, true));
21810 20 txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(3));
21811 20 txt := Tpl.writeTok(txt, Tpl.ST_STRING("throw ModelicaSimulationError(MODEL_EQ_SYSTEM,"));
21812 20 txt := Tpl.writeText(txt, a_msgVar);
21813 20 txt := Tpl.writeTok(txt, Tpl.ST_LINE(");\n"));
21814 20 txt := Tpl.popBlock(txt);
21815 20 txt := Tpl.writeTok(txt, Tpl.ST_STRING("}"));
21816 then txt;
21817 end match;
21818 end fun_417;
21819
21820 public function assertCommonVar
21821 input Tpl.Text txt;
21822 input Tpl.Text a_condVar;
21823 input Tpl.Text a_msgVar;
21824 input SimCodeFunction.Context a_context;
21825 input Tpl.Text a_varDecls;
21826 input SourceInfo a_info;
21827
21828 output Tpl.Text out_txt;
21829 output Tpl.Text out_a_condVar;
21830 output Tpl.Text out_a_msgVar;
21831 output Tpl.Text out_a_varDecls;
21832 algorithm
21833 76 out_txt := fun_417(txt, a_context, a_condVar, a_msgVar);
21834 out_a_condVar := a_condVar;
21835 out_a_msgVar := a_msgVar;
21836 out_a_varDecls := a_varDecls;
21837 end assertCommonVar;
21838
21839 public function expTypeUnboxed
21840 input Tpl.Text in_txt;
21841 input DAE.Type in_a_t;
21842
21843 output Tpl.Text out_txt;
21844 algorithm
21845 out_txt :=
21846 match(in_txt, in_a_t)
21847 local
21848 Tpl.Text txt;
21849 DAE.Type i_t;
21850 DAE.Type ret_0;
21851
21852 case ( txt,
21853 (i_t as DAE.T_METABOXED(ty = _)) )
21854 algorithm
21855 112 ret_0 := Types.unboxedType(i_t);
21856 112 txt := expTypeFlag(txt, ret_0, 8);
21857 then txt;
21858
21859 case ( txt,
21860 i_t )
21861 algorithm
21862 ✗ txt := expTypeFlag(txt, i_t, 8);
21863 then txt;
21864 end match;
21865 end expTypeUnboxed;
21866
21867 protected function fun_420
21868 input Tpl.Text in_txt;
21869 input Boolean in_mArg;
21870 input Tpl.Text in_a_elty;
21871
21872 output Tpl.Text out_txt;
21873 algorithm
21874 out_txt :=
21875 match(in_txt, in_mArg, in_a_elty)
21876 local
21877 Tpl.Text txt;
21878 Tpl.Text a_elty;
21879
21880 case ( txt,
21881 false,
21882 a_elty )
21883 algorithm
21884 35 txt := Tpl.writeText(txt, a_elty);
21885 then txt;
21886
21887 case ( txt,
21888 _,
21889 a_elty )
21890 algorithm
21891 16 txt := Tpl.writeTok(txt, Tpl.ST_STRING("BaseArray<"));
21892 16 txt := Tpl.writeText(txt, a_elty);
21893 16 txt := Tpl.writeTok(txt, Tpl.ST_STRING(">"));
21894 then txt;
21895 end match;
21896 end fun_420;
21897
21898 public function daeExpBox
21899 input Tpl.Text in_txt;
21900 input DAE.Exp in_a_exp;
21901 input SimCodeFunction.Context in_a_context;
21902 input Tpl.Text in_a_preExp;
21903 input Tpl.Text in_a_varDecls;
21904 input SimCode.SimCode in_a_simCode;
21905 input Tpl.Text in_a_extraFuncs;
21906 input Tpl.Text in_a_extraFuncsDecl;
21907 input Tpl.Text in_a_extraFuncsNamespace;
21908 input Tpl.Text in_a_stateDerVectorName;
21909 input Boolean in_a_useFlatArrayNotation;
21910
21911 output Tpl.Text out_txt;
21912 output Tpl.Text out_a_preExp;
21913 output Tpl.Text out_a_varDecls;
21914 output Tpl.Text out_a_extraFuncs;
21915 output Tpl.Text out_a_extraFuncsDecl;
21916 output Tpl.Text out_a_extraFuncsNamespace;
21917 output Tpl.Text out_a_stateDerVectorName;
21918 algorithm
21919 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
21920 match(in_txt, in_a_exp, in_a_context, in_a_preExp, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
21921 local
21922 Tpl.Text txt;
21923 SimCodeFunction.Context a_context;
21924 Tpl.Text a_preExp;
21925 Tpl.Text a_varDecls;
21926 SimCode.SimCode a_simCode;
21927 Tpl.Text a_extraFuncs;
21928 Tpl.Text a_extraFuncsDecl;
21929 Tpl.Text a_extraFuncsNamespace;
21930 Tpl.Text a_stateDerVectorName;
21931 Boolean a_useFlatArrayNotation;
21932 DAE.Exp i_exp;
21933 Tpl.Text l_res;
21934 Boolean ret_3;
21935 DAE.Type ret_2;
21936 Tpl.Text l_ty;
21937 Tpl.Text l_elty;
21938
21939 case ( txt,
21940 DAE.BOX(exp = i_exp),
21941 a_context,
21942 a_preExp,
21943 a_varDecls,
21944 a_simCode,
21945 a_extraFuncs,
21946 a_extraFuncsDecl,
21947 a_extraFuncsNamespace,
21948 a_stateDerVectorName,
21949 a_useFlatArrayNotation )
21950 algorithm
21951 51 l_elty := expTypeFromExpShort(Tpl.emptyTxt, i_exp);
21952 51 ret_2 := Expression.typeof(i_exp);
21953 51 ret_3 := Expression.isArrayType(ret_2);
21954 51 l_ty := fun_420(Tpl.emptyTxt, ret_3, l_elty);
21955 51 (l_res, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
21956 51 txt := Tpl.writeTok(txt, Tpl.ST_STRING("/*box "));
21957 51 txt := Tpl.writeText(txt, l_ty);
21958 51 txt := Tpl.writeTok(txt, Tpl.ST_STRING("*/"));
21959 51 txt := Tpl.writeText(txt, l_res);
21960 51 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
21961
21962 case ( txt,
21963 _,
21964 _,
21965 a_preExp,
21966 a_varDecls,
21967 _,
21968 a_extraFuncs,
21969 a_extraFuncsDecl,
21970 a_extraFuncsNamespace,
21971 a_stateDerVectorName,
21972 _ )
21973 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
21974 end match;
21975 end daeExpBox;
21976
21977 public function daeExpUnbox
21978 input Tpl.Text in_txt;
21979 input DAE.Exp in_a_exp;
21980 input SimCodeFunction.Context in_a_context;
21981 input Tpl.Text in_a_preExp;
21982 input Tpl.Text in_a_varDecls;
21983 input SimCode.SimCode in_a_simCode;
21984 input Tpl.Text in_a_extraFuncs;
21985 input Tpl.Text in_a_extraFuncsDecl;
21986 input Tpl.Text in_a_extraFuncsNamespace;
21987 input Tpl.Text in_a_stateDerVectorName;
21988 input Boolean in_a_useFlatArrayNotation;
21989
21990 output Tpl.Text out_txt;
21991 output Tpl.Text out_a_preExp;
21992 output Tpl.Text out_a_varDecls;
21993 output Tpl.Text out_a_extraFuncs;
21994 output Tpl.Text out_a_extraFuncsDecl;
21995 output Tpl.Text out_a_extraFuncsNamespace;
21996 output Tpl.Text out_a_stateDerVectorName;
21997 algorithm
21998 (out_txt, out_a_preExp, out_a_varDecls, out_a_extraFuncs, out_a_extraFuncsDecl, out_a_extraFuncsNamespace, out_a_stateDerVectorName) :=
21999 match(in_txt, in_a_exp, in_a_context, in_a_preExp, in_a_varDecls, in_a_simCode, in_a_extraFuncs, in_a_extraFuncsDecl, in_a_extraFuncsNamespace, in_a_stateDerVectorName, in_a_useFlatArrayNotation)
22000 local
22001 Tpl.Text txt;
22002 SimCodeFunction.Context a_context;
22003 Tpl.Text a_preExp;
22004 Tpl.Text a_varDecls;
22005 SimCode.SimCode a_simCode;
22006 Tpl.Text a_extraFuncs;
22007 Tpl.Text a_extraFuncsDecl;
22008 Tpl.Text a_extraFuncsNamespace;
22009 Tpl.Text a_stateDerVectorName;
22010 Boolean a_useFlatArrayNotation;
22011 DAE.Exp i_exp_exp;
22012 DAE.Type i_exp_ty;
22013 Tpl.Text l_res;
22014 Tpl.Text l_ty;
22015
22016 case ( txt,
22017 DAE.UNBOX(ty = i_exp_ty, exp = i_exp_exp),
22018 a_context,
22019 a_preExp,
22020 a_varDecls,
22021 a_simCode,
22022 a_extraFuncs,
22023 a_extraFuncsDecl,
22024 a_extraFuncsNamespace,
22025 a_stateDerVectorName,
22026 a_useFlatArrayNotation )
22027 algorithm
22028 3 l_ty := expTypeShort(Tpl.emptyTxt, i_exp_ty);
22029 3 (l_res, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName) := daeExp(Tpl.emptyTxt, i_exp_exp, a_context, a_preExp, a_varDecls, a_simCode, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName, a_useFlatArrayNotation);
22030 3 txt := Tpl.writeTok(txt, Tpl.ST_STRING("/*unbox "));
22031 3 txt := Tpl.writeText(txt, l_ty);
22032 3 txt := Tpl.writeTok(txt, Tpl.ST_STRING("*/"));
22033 3 txt := Tpl.writeText(txt, l_res);
22034 3 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
22035
22036 case ( txt,
22037 _,
22038 _,
22039 a_preExp,
22040 a_varDecls,
22041 _,
22042 a_extraFuncs,
22043 a_extraFuncsDecl,
22044 a_extraFuncsNamespace,
22045 a_stateDerVectorName,
22046 _ )
22047 then (txt, a_preExp, a_varDecls, a_extraFuncs, a_extraFuncsDecl, a_extraFuncsNamespace, a_stateDerVectorName);
22048 end match;
22049 end daeExpUnbox;
22050
22051 public function zeroCrossLength
22052 input Tpl.Text in_txt;
22053 input SimCode.SimCode in_a_simCode;
22054
22055 output Tpl.Text out_txt;
22056 algorithm
22057 out_txt :=
22058 match(in_txt, in_a_simCode)
22059 local
22060 Tpl.Text txt;
22061 Integer i_vi_numTimeEvents;
22062 list<BackendDAE.ZeroCrossing> i_zeroCrossings;
22063 Integer ret_3;
22064 Integer ret_2;
22065 Integer ret_1;
22066 Tpl.Text l_size;
22067
22068 case ( txt,
22069 SimCode.SIMCODE(modelInfo = SimCode.MODELINFO(varInfo = SimCode.VARINFO(numTimeEvents = i_vi_numTimeEvents)), zeroCrossings = i_zeroCrossings) )
22070 algorithm
22071 219 ret_1 := listLength(i_zeroCrossings);
22072 219 l_size := Tpl.writeStr(Tpl.emptyTxt, intString(ret_1));
22073 219 ret_2 := listLength(i_zeroCrossings);
22074 219 ret_3 := intSub(ret_2, i_vi_numTimeEvents);
22075 219 txt := Tpl.writeStr(txt, intString(ret_3));
22076 then txt;
22077
22078 case ( txt,
22079 _ )
22080 then txt;
22081 end match;
22082 end zeroCrossLength;
22083
22084 public function timeEventLength
22085 input Tpl.Text in_txt;
22086 input SimCode.SimCode in_a_simCode;
22087
22088 output Tpl.Text out_txt;
22089 algorithm
22090 out_txt :=
22091 match(in_txt, in_a_simCode)
22092 local
22093 Tpl.Text txt;
22094 Integer i_vi_numTimeEvents;
22095
22096 case ( txt,
22097 SimCode.SIMCODE(modelInfo = SimCode.MODELINFO(varInfo = SimCode.VARINFO(numTimeEvents = i_vi_numTimeEvents))) )
22098 algorithm
22099 153 txt := Tpl.writeStr(txt, intString(i_vi_numTimeEvents));
22100 then txt;
22101
22102 case ( txt,
22103 _ )
22104 then txt;
22105 end match;
22106 end timeEventLength;
22107
22108 annotation(__OpenModelica_Interface="codegen_cpp_common");
22109 end CodegenCppCommon;
22110