Linux GNU 11.4.0 Code Coverage Report


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

build_cmake/OMCompiler/Compiler/generated-mo/susan_codegen/TplCodegen.mo
Line Branch Exec Source
1 encapsulated package TplCodegen
2 "
3 file: TplCodegen.mo
4 package: TplCodegen
5 description: Generated by Susan.
6 "
7
8 public import Tpl;
9
10 public import TplAbsyn;
11
12 protected function lm_3
13 input output Tpl.Text txt;
14 input list<TplAbsyn.MMDeclaration> items;
15 algorithm
16 ✗ for lstElt_3 in items loop
17 txt := match lstElt_3
18 local
19 TplAbsyn.MMDeclaration i_it;
20
21 case i_it
22 algorithm
23 ✗ txt := mmDeclaration(txt, i_it);
24 ✗ txt := Tpl.nextIter(txt);
25 then txt;
26 end match;
27 end for;
28 end lm_3;
29
30 public function mmPackage
31 input Tpl.Text in_txt;
32 input TplAbsyn.MMPackage in_a_it;
33
34 output Tpl.Text out_txt;
35 algorithm
36 out_txt :=
37 match(in_txt, in_a_it)
38 local
39 Tpl.Text txt;
40 String i_annotationFooter;
41 list<TplAbsyn.MMDeclaration> i_mmDeclarations;
42 TplAbsyn.PathIdent i_name;
43
44 case ( txt,
45 TplAbsyn.MM_PACKAGE(name = i_name, mmDeclarations = i_mmDeclarations, annotationFooter = i_annotationFooter) )
46 algorithm
47 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("encapsulated package "));
48 ✗ txt := pathIdent(txt, i_name);
49 ✗ txt := Tpl.softNewLine(txt);
50 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("\"\n"));
51 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
52 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("file: "));
53 ✗ txt := pathIdent(txt, i_name);
54 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
55 ".mo\n",
56 "package: "
57 }, false));
58 ✗ txt := pathIdent(txt, i_name);
59 ✗ txt := Tpl.softNewLine(txt);
60 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("description: Generated by Susan.\n"));
61 ✗ txt := Tpl.popBlock(txt);
62 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
63 "\"\n",
64 "\n",
65 "public import Tpl;\n",
66 "\n"
67 }, true));
68 ✗ 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()));
69 ✗ txt := lm_3(txt, i_mmDeclarations);
70 ✗ txt := Tpl.popIter(txt);
71 ✗ txt := Tpl.softNewLine(txt);
72 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
73 ✗ txt := Tpl.writeStr(txt, i_annotationFooter);
74 ✗ txt := Tpl.softNewLine(txt);
75 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("end "));
76 ✗ txt := pathIdent(txt, i_name);
77 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
78 then txt;
79
80 case ( txt,
81 _ )
82 then txt;
83 end match;
84 end mmPackage;
85
86 protected function fun_5
87 input Tpl.Text in_txt;
88 input TplAbsyn.TypedIdents in_a_mf_locals;
89
90 output Tpl.Text out_txt;
91 algorithm
92 out_txt :=
93 match(in_txt, in_a_mf_locals)
94 local
95 Tpl.Text txt;
96 TplAbsyn.TypedIdents i_mf_locals;
97
98 case ( txt,
99 {} )
100 then txt;
101
102 case ( txt,
103 i_mf_locals )
104 algorithm
105 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("protected\n"));
106 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
107 ✗ txt := typedIdents(txt, i_mf_locals);
108 ✗ txt := Tpl.popBlock(txt);
109 then txt;
110 end match;
111 end fun_5;
112
113 protected function fun_6
114 input Tpl.Text in_txt;
115 input Boolean in_mArg;
116
117 output Tpl.Text out_txt;
118 algorithm
119 out_txt :=
120 match(in_txt, in_mArg)
121 local
122 Tpl.Text txt;
123
124 case ( txt,
125 false )
126 then txt;
127
128 case ( txt,
129 _ )
130 algorithm
131 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
132 "\n",
133 "try"
134 }, false));
135 then txt;
136 end match;
137 end fun_6;
138
139 protected function lm_7
140 input output Tpl.Text txt;
141 input list<TplAbsyn.MMExp> items;
142 algorithm
143 ✗ for lstElt_7 in items loop
144 txt := match lstElt_7
145 local
146 TplAbsyn.MMExp i_it;
147
148 case i_it
149 algorithm
150 ✗ txt := mmExp(txt, i_it, ":=");
151 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
152 ✗ txt := Tpl.nextIter(txt);
153 then txt;
154 end match;
155 end for;
156 end lm_7;
157
158 protected function fun_8
159 input Tpl.Text in_txt;
160 input Boolean in_mArg;
161
162 output Tpl.Text out_txt;
163 algorithm
164 out_txt :=
165 match(in_txt, in_mArg)
166 local
167 Tpl.Text txt;
168
169 case ( txt,
170 false )
171 then txt;
172
173 case ( txt,
174 _ )
175 algorithm
176 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
177 "else\n",
178 " Tpl.fakeStackOverflow();\n",
179 "end try;"
180 }, false));
181 then txt;
182 end match;
183 end fun_8;
184
185 protected function fun_9
186 input Tpl.Text in_txt;
187 input list<TplAbsyn.MMExp> in_a_statements;
188 input TplAbsyn.TypedIdents in_a_mf_locals;
189 input TplAbsyn.TypedIdents in_a_mf_outArgs;
190 input TplAbsyn.TypedIdents in_a_mf_inArgs;
191
192 output Tpl.Text out_txt;
193 algorithm
194 out_txt :=
195 match(in_txt, in_a_statements, in_a_mf_locals, in_a_mf_outArgs, in_a_mf_inArgs)
196 local
197 Tpl.Text txt;
198 TplAbsyn.TypedIdents a_mf_locals;
199 TplAbsyn.TypedIdents a_mf_outArgs;
200 TplAbsyn.TypedIdents a_mf_inArgs;
201 list<TplAbsyn.MMExp> i_sts;
202 TplAbsyn.TypedIdents i_c_matchLocals;
203 TplAbsyn.Ident i_c_listName;
204 list<TplAbsyn.MMExp> i_c_statements;
205 TplAbsyn.Ident i_c_eltName;
206 TplAbsyn.Ident i_c_arrName;
207 TplAbsyn.Ident i_c_idxName;
208 list<TplAbsyn.MMMatchCase> i_c_matchCases;
209 Boolean ret_1;
210 Boolean ret_0;
211
212 case ( txt,
213 {TplAbsyn.MM_MATCH(matchCases = i_c_matchCases)},
214 a_mf_locals,
215 a_mf_outArgs,
216 a_mf_inArgs )
217 algorithm
218 ✗ txt := mmMatchFunBody(txt, a_mf_inArgs, a_mf_outArgs, a_mf_locals, i_c_matchCases);
219 then txt;
220
221 case ( txt,
222 {TplAbsyn.MM_FOR_LOOP(idxName = i_c_idxName, arrName = i_c_arrName, eltName = i_c_eltName, statements = i_c_statements)},
223 a_mf_locals,
224 a_mf_outArgs,
225 a_mf_inArgs )
226 algorithm
227 ✗ txt := mmForLoopFunBody(txt, a_mf_inArgs, a_mf_outArgs, a_mf_locals, i_c_idxName, i_c_arrName, i_c_eltName, i_c_statements);
228 then txt;
229
230 case ( txt,
231 {TplAbsyn.MM_LIST_FOR_LOOP(eltName = i_c_eltName, listName = i_c_listName, matchLocals = i_c_matchLocals, matchCases = i_c_matchCases)},
232 a_mf_locals,
233 a_mf_outArgs,
234 a_mf_inArgs )
235 algorithm
236 ✗ txt := mmListForLoopFunBody(txt, a_mf_inArgs, a_mf_outArgs, a_mf_locals, i_c_eltName, i_c_listName, i_c_matchLocals, i_c_matchCases);
237 then txt;
238
239 case ( txt,
240 i_sts,
241 a_mf_locals,
242 a_mf_outArgs,
243 a_mf_inArgs )
244 algorithm
245 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
246 ✗ txt := typedIdentsEx(txt, a_mf_inArgs, "input", "");
247 ✗ txt := Tpl.softNewLine(txt);
248 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
249 ✗ txt := typedIdentsEx(txt, a_mf_outArgs, "output", "out_");
250 ✗ txt := Tpl.softNewLine(txt);
251 ✗ txt := Tpl.popBlock(txt);
252 ✗ txt := fun_5(txt, a_mf_locals);
253 ✗ txt := Tpl.softNewLine(txt);
254 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("algorithm"));
255 ✗ ret_0 := Tpl.debugSusan();
256 ✗ txt := fun_6(txt, ret_0);
257 ✗ txt := Tpl.softNewLine(txt);
258 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
259 ✗ 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()));
260 ✗ txt := lm_7(txt, i_sts);
261 ✗ txt := Tpl.popIter(txt);
262 ✗ txt := Tpl.softNewLine(txt);
263 ✗ txt := Tpl.popBlock(txt);
264 ✗ ret_1 := Tpl.debugSusan();
265 ✗ txt := fun_8(txt, ret_1);
266 then txt;
267 end match;
268 end fun_9;
269
270 public function mmDeclaration
271 input Tpl.Text in_txt;
272 input TplAbsyn.MMDeclaration in_a_it;
273
274 output Tpl.Text out_txt;
275 algorithm
276 out_txt :=
277 match(in_txt, in_a_it)
278 local
279 Tpl.Text txt;
280 TplAbsyn.TypedIdents i_mf_locals;
281 TplAbsyn.TypedIdents i_mf_outArgs;
282 TplAbsyn.TypedIdents i_mf_inArgs;
283 list<TplAbsyn.MMExp> i_statements;
284 String i_value_1;
285 TplAbsyn.TypeSignature i_litType;
286 TplAbsyn.StringToken i_value;
287 TplAbsyn.Ident i_name;
288 TplAbsyn.PathIdent i_packageName;
289 Boolean i_isPublic;
290
291 case ( txt,
292 TplAbsyn.MM_IMPORT(packageName = TplAbsyn.IDENT(ident = "Tpl")) )
293 then txt;
294
295 case ( txt,
296 TplAbsyn.MM_IMPORT(packageName = TplAbsyn.IDENT(ident = "builtin")) )
297 then txt;
298
299 case ( txt,
300 TplAbsyn.MM_IMPORT(isPublic = i_isPublic, packageName = i_packageName) )
301 algorithm
302 ✗ txt := mmPublic(txt, i_isPublic);
303 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" import "));
304 ✗ txt := pathIdent(txt, i_packageName);
305 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
306 then txt;
307
308 case ( txt,
309 TplAbsyn.MM_STR_TOKEN_DECL(isPublic = i_isPublic, name = i_name, value = i_value) )
310 algorithm
311 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
312 ✗ txt := mmPublic(txt, i_isPublic);
313 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" constant Tpl.StringToken "));
314 ✗ txt := Tpl.writeStr(txt, i_name);
315 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = "));
316 ✗ txt := mmStringTokenConstant(txt, i_value);
317 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
318 then txt;
319
320 case ( txt,
321 TplAbsyn.MM_LITERAL_DECL(isPublic = i_isPublic, litType = i_litType, name = i_name, value = i_value_1) )
322 algorithm
323 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
324 ✗ txt := mmPublic(txt, i_isPublic);
325 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" constant "));
326 ✗ txt := typeSig(txt, i_litType);
327 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
328 ✗ txt := Tpl.writeStr(txt, i_name);
329 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = "));
330 ✗ txt := Tpl.writeStr(txt, i_value_1);
331 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
332 then txt;
333
334 case ( txt,
335 TplAbsyn.MM_FUN(isPublic = i_isPublic, name = i_name, statements = i_statements, inArgs = i_mf_inArgs, outArgs = i_mf_outArgs, locals = i_mf_locals) )
336 algorithm
337 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
338 ✗ txt := mmPublic(txt, i_isPublic);
339 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" function "));
340 ✗ txt := Tpl.writeStr(txt, i_name);
341 ✗ txt := Tpl.softNewLine(txt);
342 ✗ txt := fun_9(txt, i_statements, i_mf_locals, i_mf_outArgs, i_mf_inArgs);
343 ✗ txt := Tpl.softNewLine(txt);
344 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("end "));
345 ✗ txt := Tpl.writeStr(txt, i_name);
346 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
347 then txt;
348
349 case ( txt,
350 _ )
351 then txt;
352 end match;
353 end mmDeclaration;
354
355 protected function fun_11
356 input Tpl.Text in_txt;
357 input Boolean in_mArg;
358
359 output Tpl.Text out_txt;
360 algorithm
361 out_txt :=
362 match(in_txt, in_mArg)
363 local
364 Tpl.Text txt;
365
366 case ( txt,
367 false )
368 then txt;
369
370 case ( txt,
371 _ )
372 algorithm
373 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
374 "\n",
375 "try"
376 }, false));
377 then txt;
378 end match;
379 end fun_11;
380
381 protected function lm_12
382 input output Tpl.Text txt;
383 input TplAbsyn.TypedIdents items;
384 algorithm
385 ✗ for lstElt_12 in items loop
386 txt := match lstElt_12
387 local
388 TplAbsyn.Ident i_nm;
389
390 case (i_nm, _)
391 algorithm
392 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("out_"));
393 ✗ txt := Tpl.writeStr(txt, i_nm);
394 ✗ txt := Tpl.nextIter(txt);
395 then txt;
396 end match;
397 end for;
398 end lm_12;
399
400 protected function fun_13
401 input Tpl.Text in_txt;
402 input TplAbsyn.TypedIdents in_a_outArgs;
403
404 output Tpl.Text out_txt;
405 algorithm
406 out_txt :=
407 match(in_txt, in_a_outArgs)
408 local
409 Tpl.Text txt;
410 TplAbsyn.TypedIdents i_outArgs;
411 TplAbsyn.Ident i_nm;
412
413 case ( txt,
414 {(i_nm, _)} )
415 algorithm
416 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("out_"));
417 ✗ txt := Tpl.writeStr(txt, i_nm);
418 then txt;
419
420 case ( txt,
421 i_outArgs )
422 algorithm
423 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
424 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
425 ✗ txt := lm_12(txt, i_outArgs);
426 ✗ txt := Tpl.popIter(txt);
427 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
428 then txt;
429 end match;
430 end fun_13;
431
432 protected function lm_14
433 input output Tpl.Text txt;
434 input TplAbsyn.TypedIdents items;
435 algorithm
436 ✗ for lstElt_14 in items loop
437 txt := match lstElt_14
438 local
439 TplAbsyn.Ident i_nm;
440
441 case (i_nm, _)
442 algorithm
443 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("in_"));
444 ✗ txt := Tpl.writeStr(txt, i_nm);
445 ✗ txt := Tpl.nextIter(txt);
446 then txt;
447 end match;
448 end for;
449 end lm_14;
450
451 protected function lm_15
452 input output Tpl.Text txt;
453 input list<TplAbsyn.MatchingExp> items;
454 algorithm
455 ✗ for lstElt_15 in items loop
456 txt := match lstElt_15
457 local
458 TplAbsyn.MatchingExp i_it;
459
460 case i_it
461 algorithm
462 ✗ txt := mmMatchingExp(txt, i_it);
463 ✗ txt := Tpl.nextIter(txt);
464 then txt;
465 end match;
466 end for;
467 end lm_15;
468
469 protected function lm_16
470 input output Tpl.Text txt;
471 input list<TplAbsyn.MMExp> items;
472 algorithm
473 ✗ for lstElt_16 in items loop
474 txt := match lstElt_16
475 local
476 TplAbsyn.MMExp i_it;
477
478 case i_it
479 algorithm
480 ✗ txt := mmExp(txt, i_it, ":=");
481 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
482 ✗ txt := Tpl.nextIter(txt);
483 then txt;
484 end match;
485 end for;
486 end lm_16;
487
488 protected function fun_17
489 input Tpl.Text in_txt;
490 input list<TplAbsyn.MMExp> in_a_statements;
491
492 output Tpl.Text out_txt;
493 algorithm
494 out_txt :=
495 match(in_txt, in_a_statements)
496 local
497 Tpl.Text txt;
498 list<TplAbsyn.MMExp> i_statements;
499
500 case ( txt,
501 {} )
502 then txt;
503
504 case ( txt,
505 i_statements )
506 algorithm
507 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("algorithm\n"));
508 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
509 ✗ 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()));
510 ✗ txt := lm_16(txt, i_statements);
511 ✗ txt := Tpl.popIter(txt);
512 ✗ txt := Tpl.popBlock(txt);
513 then txt;
514 end match;
515 end fun_17;
516
517 protected function lm_18
518 input output Tpl.Text txt;
519 input TplAbsyn.TypedIdents items;
520 algorithm
521 ✗ for lstElt_18 in items loop
522 txt := match lstElt_18
523 local
524 TplAbsyn.Ident i_nm;
525
526 case (i_nm, _)
527 algorithm
528 ✗ txt := Tpl.writeStr(txt, i_nm);
529 ✗ txt := Tpl.nextIter(txt);
530 then txt;
531 end match;
532 end for;
533 end lm_18;
534
535 protected function fun_19
536 input Tpl.Text in_txt;
537 input TplAbsyn.TypedIdents in_a_outArgs;
538
539 output Tpl.Text out_txt;
540 algorithm
541 out_txt :=
542 match(in_txt, in_a_outArgs)
543 local
544 Tpl.Text txt;
545 TplAbsyn.TypedIdents i_oas;
546 TplAbsyn.Ident i_nm;
547
548 case ( txt,
549 {(i_nm, _)} )
550 algorithm
551 ✗ txt := Tpl.writeStr(txt, i_nm);
552 then txt;
553
554 case ( txt,
555 i_oas )
556 algorithm
557 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
558 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
559 ✗ txt := lm_18(txt, i_oas);
560 ✗ txt := Tpl.popIter(txt);
561 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
562 then txt;
563 end match;
564 end fun_19;
565
566 protected function lm_20
567 input output Tpl.Text txt;
568 input list<TplAbsyn.MMMatchCase> items;
569 input TplAbsyn.TypedIdents a_outArgs;
570 algorithm
571 ✗ for lstElt_20 in items loop
572 txt := match lstElt_20
573 local
574 list<TplAbsyn.MMExp> i_statements;
575 list<TplAbsyn.MatchingExp> i_mexps;
576
577 case (i_mexps, i_statements)
578 algorithm
579 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
580 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
581 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("case ( "));
582 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_ANCHOR(0));
583 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_LINE(",\n")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
584 ✗ txt := lm_15(txt, i_mexps);
585 ✗ txt := Tpl.popIter(txt);
586 ✗ txt := Tpl.popBlock(txt);
587 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(" )\n"));
588 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
589 ✗ txt := fun_17(txt, i_statements);
590 ✗ txt := Tpl.softNewLine(txt);
591 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("then "));
592 ✗ txt := fun_19(txt, a_outArgs);
593 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
594 ✗ txt := Tpl.popBlock(txt);
595 ✗ txt := Tpl.popBlock(txt);
596 ✗ txt := Tpl.nextIter(txt);
597 then txt;
598 end match;
599 end for;
600 end lm_20;
601
602 protected function fun_21
603 input Tpl.Text in_txt;
604 input Boolean in_mArg;
605
606 output Tpl.Text out_txt;
607 algorithm
608 out_txt :=
609 match(in_txt, in_mArg)
610 local
611 Tpl.Text txt;
612
613 case ( txt,
614 false )
615 then txt;
616
617 case ( txt,
618 _ )
619 algorithm
620 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
621 "\n",
622 "else\n",
623 " Tpl.fakeStackOverflow();\n",
624 "end try;"
625 }, false));
626 then txt;
627 end match;
628 end fun_21;
629
630 public function mmMatchFunBody
631 input Tpl.Text txt;
632 input TplAbsyn.TypedIdents a_inArgs;
633 input TplAbsyn.TypedIdents a_outArgs;
634 input TplAbsyn.TypedIdents a_locals;
635 input list<TplAbsyn.MMMatchCase> a_matchCases;
636
637 output Tpl.Text out_txt;
638 protected
639 Boolean ret_1;
640 Boolean ret_0;
641 algorithm
642 ✗ out_txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
643 ✗ out_txt := typedIdentsEx(out_txt, a_inArgs, "input", "in_");
644 ✗ out_txt := Tpl.softNewLine(out_txt);
645 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_NEW_LINE());
646 ✗ out_txt := typedIdentsEx(out_txt, a_outArgs, "output", "out_");
647 ✗ out_txt := Tpl.softNewLine(out_txt);
648 ✗ out_txt := Tpl.popBlock(out_txt);
649 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("algorithm"));
650 ✗ ret_0 := Tpl.debugSusan();
651 ✗ out_txt := fun_11(out_txt, ret_0);
652 ✗ out_txt := Tpl.softNewLine(out_txt);
653 ✗ out_txt := Tpl.pushBlock(out_txt, Tpl.BT_INDENT(2));
654 ✗ out_txt := fun_13(out_txt, a_outArgs);
655 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({
656 " :=\n",
657 "match("
658 }, false));
659 ✗ out_txt := Tpl.pushIter(out_txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
660 ✗ out_txt := lm_14(out_txt, a_inArgs);
661 ✗ out_txt := Tpl.popIter(out_txt);
662 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({
663 ")\n",
664 " local\n"
665 }, true));
666 ✗ out_txt := Tpl.pushBlock(out_txt, Tpl.BT_INDENT(4));
667 ✗ out_txt := typedIdents(out_txt, a_locals);
668 ✗ out_txt := Tpl.softNewLine(out_txt);
669 ✗ out_txt := Tpl.popBlock(out_txt);
670 ✗ out_txt := Tpl.pushIter(out_txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
671 ✗ out_txt := lm_20(out_txt, a_matchCases, a_outArgs);
672 ✗ out_txt := Tpl.popIter(out_txt);
673 ✗ out_txt := Tpl.softNewLine(out_txt);
674 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("end match;"));
675 ✗ ret_1 := Tpl.debugSusan();
676 ✗ out_txt := fun_21(out_txt, ret_1);
677 ✗ out_txt := Tpl.popBlock(out_txt);
678 end mmMatchFunBody;
679
680 protected function fun_23
681 input Tpl.Text in_txt;
682 input TplAbsyn.TypedIdents in_a_locals;
683
684 output Tpl.Text out_txt;
685 algorithm
686 out_txt :=
687 match(in_txt, in_a_locals)
688 local
689 Tpl.Text txt;
690 TplAbsyn.TypedIdents i_locals;
691
692 case ( txt,
693 {} )
694 then txt;
695
696 case ( txt,
697 i_locals )
698 algorithm
699 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("protected\n"));
700 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
701 ✗ txt := typedIdents(txt, i_locals);
702 ✗ txt := Tpl.popBlock(txt);
703 then txt;
704 end match;
705 end fun_23;
706
707 protected function fun_24
708 input Tpl.Text in_txt;
709 input Boolean in_mArg;
710
711 output Tpl.Text out_txt;
712 algorithm
713 out_txt :=
714 match(in_txt, in_mArg)
715 local
716 Tpl.Text txt;
717
718 case ( txt,
719 false )
720 then txt;
721
722 case ( txt,
723 _ )
724 algorithm
725 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
726 "\n",
727 "try"
728 }, false));
729 then txt;
730 end match;
731 end fun_24;
732
733 protected function fun_25
734 input Tpl.Text in_txt;
735 input TplAbsyn.Ident in_a_eltName;
736 input TplAbsyn.Ident in_a_idxName;
737 input TplAbsyn.Ident in_a_arrName;
738
739 output Tpl.Text out_txt;
740 algorithm
741 out_txt :=
742 match(in_txt, in_a_eltName, in_a_idxName, in_a_arrName)
743 local
744 Tpl.Text txt;
745 TplAbsyn.Ident a_idxName;
746 TplAbsyn.Ident a_arrName;
747 TplAbsyn.Ident i_eltName;
748
749 case ( txt,
750 "",
751 _,
752 _ )
753 then txt;
754
755 case ( txt,
756 i_eltName,
757 a_idxName,
758 a_arrName )
759 algorithm
760 ✗ txt := Tpl.writeStr(txt, i_eltName);
761 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" := arrayGet("));
762 ✗ txt := Tpl.writeStr(txt, a_arrName);
763 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
764 ✗ txt := Tpl.writeStr(txt, a_idxName);
765 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(");"));
766 then txt;
767 end match;
768 end fun_25;
769
770 protected function lm_26
771 input output Tpl.Text txt;
772 input list<TplAbsyn.MMExp> items;
773 algorithm
774 ✗ for lstElt_26 in items loop
775 txt := match lstElt_26
776 local
777 TplAbsyn.MMExp i_it;
778
779 case i_it
780 algorithm
781 ✗ txt := mmExp(txt, i_it, ":=");
782 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
783 ✗ txt := Tpl.nextIter(txt);
784 then txt;
785 end match;
786 end for;
787 end lm_26;
788
789 protected function fun_27
790 input Tpl.Text in_txt;
791 input Boolean in_mArg;
792
793 output Tpl.Text out_txt;
794 algorithm
795 out_txt :=
796 match(in_txt, in_mArg)
797 local
798 Tpl.Text txt;
799
800 case ( txt,
801 false )
802 then txt;
803
804 case ( txt,
805 _ )
806 algorithm
807 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
808 "\n",
809 "else\n",
810 " Tpl.fakeStackOverflow();\n",
811 "end try;"
812 }, false));
813 then txt;
814 end match;
815 end fun_27;
816
817 public function mmForLoopFunBody
818 input Tpl.Text txt;
819 input TplAbsyn.TypedIdents a_inArgs;
820 input TplAbsyn.TypedIdents a_outArgs;
821 input TplAbsyn.TypedIdents a_locals;
822 input TplAbsyn.Ident a_idxName;
823 input TplAbsyn.Ident a_arrName;
824 input TplAbsyn.Ident a_eltName;
825 input list<TplAbsyn.MMExp> a_statements;
826
827 output Tpl.Text out_txt;
828 protected
829 Boolean ret_1;
830 Boolean ret_0;
831 algorithm
832 ✗ out_txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
833 ✗ out_txt := inOutArgs(out_txt, a_inArgs, a_outArgs);
834 ✗ out_txt := Tpl.softNewLine(out_txt);
835 ✗ out_txt := Tpl.popBlock(out_txt);
836 ✗ out_txt := fun_23(out_txt, a_locals);
837 ✗ out_txt := Tpl.softNewLine(out_txt);
838 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("algorithm"));
839 ✗ ret_0 := Tpl.debugSusan();
840 ✗ out_txt := fun_24(out_txt, ret_0);
841 ✗ out_txt := Tpl.softNewLine(out_txt);
842 ✗ out_txt := Tpl.pushBlock(out_txt, Tpl.BT_INDENT(2));
843 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("for "));
844 ✗ out_txt := Tpl.writeStr(out_txt, a_idxName);
845 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING(" in 1:arrayLength("));
846 ✗ out_txt := Tpl.writeStr(out_txt, a_arrName);
847 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_LINE(") loop\n"));
848 ✗ out_txt := Tpl.pushBlock(out_txt, Tpl.BT_INDENT(2));
849 ✗ out_txt := fun_25(out_txt, a_eltName, a_idxName, a_arrName);
850 ✗ out_txt := Tpl.softNewLine(out_txt);
851 ✗ out_txt := Tpl.pushIter(out_txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
852 ✗ out_txt := lm_26(out_txt, a_statements);
853 ✗ out_txt := Tpl.popIter(out_txt);
854 ✗ out_txt := Tpl.softNewLine(out_txt);
855 ✗ out_txt := Tpl.popBlock(out_txt);
856 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("end for;"));
857 ✗ ret_1 := Tpl.debugSusan();
858 ✗ out_txt := fun_27(out_txt, ret_1);
859 ✗ out_txt := Tpl.popBlock(out_txt);
860 end mmForLoopFunBody;
861
862 protected function fun_29
863 input Tpl.Text in_txt;
864 input Boolean in_mArg;
865
866 output Tpl.Text out_txt;
867 algorithm
868 out_txt :=
869 match(in_txt, in_mArg)
870 local
871 Tpl.Text txt;
872
873 case ( txt,
874 false )
875 algorithm
876 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("input"));
877 then txt;
878
879 case ( txt,
880 _ )
881 algorithm
882 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("input output"));
883 then txt;
884 end match;
885 end fun_29;
886
887 protected function lm_30
888 input output Tpl.Text txt;
889 input TplAbsyn.TypedIdents items;
890 input TplAbsyn.TypedIdents a_outArgs;
891 algorithm
892 ✗ for lstElt_30 in items loop
893 txt := match lstElt_30
894 local
895 TplAbsyn.TypeSignature i_ts;
896 TplAbsyn.Ident i_nm;
897 Boolean ret_0;
898
899 case (i_nm, i_ts)
900 algorithm
901 ✗ ret_0 := TplAbsyn.isTupleListMember(i_nm, a_outArgs);
902 ✗ txt := fun_29(txt, ret_0);
903 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
904 ✗ txt := typeSig(txt, i_ts);
905 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
906 ✗ txt := Tpl.writeStr(txt, i_nm);
907 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
908 ✗ txt := Tpl.nextIter(txt);
909 then txt;
910 end match;
911 end for;
912 end lm_30;
913
914 protected function fun_31
915 input Tpl.Text in_txt;
916 input TplAbsyn.TypedIdents in_a_locals;
917
918 output Tpl.Text out_txt;
919 algorithm
920 out_txt :=
921 match(in_txt, in_a_locals)
922 local
923 Tpl.Text txt;
924 TplAbsyn.TypedIdents i_locals;
925
926 case ( txt,
927 {} )
928 then txt;
929
930 case ( txt,
931 i_locals )
932 algorithm
933 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("protected\n"));
934 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
935 ✗ txt := typedIdents(txt, i_locals);
936 ✗ txt := Tpl.popBlock(txt);
937 then txt;
938 end match;
939 end fun_31;
940
941 protected function fun_32
942 input Tpl.Text in_txt;
943 input Boolean in_mArg;
944
945 output Tpl.Text out_txt;
946 algorithm
947 out_txt :=
948 match(in_txt, in_mArg)
949 local
950 Tpl.Text txt;
951
952 case ( txt,
953 false )
954 then txt;
955
956 case ( txt,
957 _ )
958 algorithm
959 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
960 "\n",
961 "try"
962 }, false));
963 then txt;
964 end match;
965 end fun_32;
966
967 protected function lm_33
968 input output Tpl.Text txt;
969 input TplAbsyn.TypedIdents items;
970 algorithm
971 ✗ for lstElt_33 in items loop
972 txt := match lstElt_33
973 local
974 TplAbsyn.Ident i_nm;
975
976 case (i_nm, _)
977 algorithm
978 ✗ txt := Tpl.writeStr(txt, i_nm);
979 ✗ txt := Tpl.nextIter(txt);
980 then txt;
981 end match;
982 end for;
983 end lm_33;
984
985 protected function fun_34
986 input Tpl.Text in_txt;
987 input TplAbsyn.TypedIdents in_a_outArgs;
988
989 output Tpl.Text out_txt;
990 algorithm
991 out_txt :=
992 match(in_txt, in_a_outArgs)
993 local
994 Tpl.Text txt;
995 TplAbsyn.TypedIdents i_oas;
996 TplAbsyn.Ident i_nm;
997
998 case ( txt,
999 {(i_nm, _)} )
1000 algorithm
1001 ✗ txt := Tpl.writeStr(txt, i_nm);
1002 then txt;
1003
1004 case ( txt,
1005 i_oas )
1006 algorithm
1007 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
1008 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1009 ✗ txt := lm_33(txt, i_oas);
1010 ✗ txt := Tpl.popIter(txt);
1011 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
1012 then txt;
1013 end match;
1014 end fun_34;
1015
1016 protected function fun_35
1017 input Tpl.Text in_txt;
1018 input TplAbsyn.TypedIdents in_a_matchLocals;
1019
1020 output Tpl.Text out_txt;
1021 algorithm
1022 out_txt :=
1023 match(in_txt, in_a_matchLocals)
1024 local
1025 Tpl.Text txt;
1026 TplAbsyn.TypedIdents i_matchLocals;
1027
1028 case ( txt,
1029 {} )
1030 then txt;
1031
1032 case ( txt,
1033 i_matchLocals )
1034 algorithm
1035 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1036 "\n",
1037 " local\n"
1038 }, true));
1039 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(4));
1040 ✗ txt := typedIdents(txt, i_matchLocals);
1041 ✗ txt := Tpl.popBlock(txt);
1042 then txt;
1043 end match;
1044 end fun_35;
1045
1046 protected function lm_36
1047 input output Tpl.Text txt;
1048 input list<TplAbsyn.MatchingExp> items;
1049 algorithm
1050 ✗ for lstElt_36 in items loop
1051 txt := match lstElt_36
1052 local
1053 TplAbsyn.MatchingExp i_it;
1054
1055 case i_it
1056 algorithm
1057 ✗ txt := mmMatchingExp(txt, i_it);
1058 ✗ txt := Tpl.nextIter(txt);
1059 then txt;
1060 end match;
1061 end for;
1062 end lm_36;
1063
1064 protected function lm_37
1065 input output Tpl.Text txt;
1066 input list<TplAbsyn.MMExp> items;
1067 algorithm
1068 ✗ for lstElt_37 in items loop
1069 txt := match lstElt_37
1070 local
1071 TplAbsyn.MMExp i_it;
1072
1073 case i_it
1074 algorithm
1075 ✗ txt := mmExp(txt, i_it, ":=");
1076 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
1077 ✗ txt := Tpl.nextIter(txt);
1078 then txt;
1079 end match;
1080 end for;
1081 end lm_37;
1082
1083 protected function fun_38
1084 input Tpl.Text in_txt;
1085 input list<TplAbsyn.MMExp> in_a_statements;
1086
1087 output Tpl.Text out_txt;
1088 algorithm
1089 out_txt :=
1090 match(in_txt, in_a_statements)
1091 local
1092 Tpl.Text txt;
1093 list<TplAbsyn.MMExp> i_statements;
1094
1095 case ( txt,
1096 {} )
1097 then txt;
1098
1099 case ( txt,
1100 i_statements )
1101 algorithm
1102 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("algorithm\n"));
1103 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
1104 ✗ 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()));
1105 ✗ txt := lm_37(txt, i_statements);
1106 ✗ txt := Tpl.popIter(txt);
1107 ✗ txt := Tpl.popBlock(txt);
1108 then txt;
1109 end match;
1110 end fun_38;
1111
1112 protected function lm_39
1113 input output Tpl.Text txt;
1114 input TplAbsyn.TypedIdents items;
1115 algorithm
1116 ✗ for lstElt_39 in items loop
1117 txt := match lstElt_39
1118 local
1119 TplAbsyn.Ident i_nm;
1120
1121 case (i_nm, _)
1122 algorithm
1123 ✗ txt := Tpl.writeStr(txt, i_nm);
1124 ✗ txt := Tpl.nextIter(txt);
1125 then txt;
1126 end match;
1127 end for;
1128 end lm_39;
1129
1130 protected function fun_40
1131 input Tpl.Text in_txt;
1132 input TplAbsyn.TypedIdents in_a_outArgs;
1133
1134 output Tpl.Text out_txt;
1135 algorithm
1136 out_txt :=
1137 match(in_txt, in_a_outArgs)
1138 local
1139 Tpl.Text txt;
1140 TplAbsyn.TypedIdents i_oas;
1141 TplAbsyn.Ident i_nm;
1142
1143 case ( txt,
1144 {(i_nm, _)} )
1145 algorithm
1146 ✗ txt := Tpl.writeStr(txt, i_nm);
1147 then txt;
1148
1149 case ( txt,
1150 i_oas )
1151 algorithm
1152 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
1153 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1154 ✗ txt := lm_39(txt, i_oas);
1155 ✗ txt := Tpl.popIter(txt);
1156 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
1157 then txt;
1158 end match;
1159 end fun_40;
1160
1161 protected function lm_41
1162 input output Tpl.Text txt;
1163 input list<TplAbsyn.MMMatchCase> items;
1164 input TplAbsyn.TypedIdents a_outArgs;
1165 algorithm
1166 ✗ for lstElt_41 in items loop
1167 txt := match lstElt_41
1168 local
1169 list<TplAbsyn.MMExp> i_statements;
1170 list<TplAbsyn.MatchingExp> i_mexps;
1171
1172 case (i_mexps, i_statements)
1173 algorithm
1174 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
1175 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
1176 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("case "));
1177 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_ANCHOR(0));
1178 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_LINE(",\n")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1179 ✗ txt := lm_36(txt, i_mexps);
1180 ✗ txt := Tpl.popIter(txt);
1181 ✗ txt := Tpl.popBlock(txt);
1182 ✗ txt := Tpl.softNewLine(txt);
1183 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
1184 ✗ txt := fun_38(txt, i_statements);
1185 ✗ txt := Tpl.softNewLine(txt);
1186 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("then "));
1187 ✗ txt := fun_40(txt, a_outArgs);
1188 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
1189 ✗ txt := Tpl.popBlock(txt);
1190 ✗ txt := Tpl.popBlock(txt);
1191 ✗ txt := Tpl.nextIter(txt);
1192 then txt;
1193 end match;
1194 end for;
1195 end lm_41;
1196
1197 protected function fun_42
1198 input Tpl.Text in_txt;
1199 input Boolean in_mArg;
1200
1201 output Tpl.Text out_txt;
1202 algorithm
1203 out_txt :=
1204 match(in_txt, in_mArg)
1205 local
1206 Tpl.Text txt;
1207
1208 case ( txt,
1209 false )
1210 then txt;
1211
1212 case ( txt,
1213 _ )
1214 algorithm
1215 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1216 "\n",
1217 "else\n",
1218 " Tpl.fakeStackOverflow();\n",
1219 "end try;"
1220 }, false));
1221 then txt;
1222 end match;
1223 end fun_42;
1224
1225 public function mmListForLoopFunBody
1226 input Tpl.Text txt;
1227 input TplAbsyn.TypedIdents a_inArgs;
1228 input TplAbsyn.TypedIdents a_outArgs;
1229 input TplAbsyn.TypedIdents a_locals;
1230 input TplAbsyn.Ident a_eltName;
1231 input TplAbsyn.Ident a_listName;
1232 input TplAbsyn.TypedIdents a_matchLocals;
1233 input list<TplAbsyn.MMMatchCase> a_matchCases;
1234
1235 output Tpl.Text out_txt;
1236 protected
1237 Boolean ret_1;
1238 Boolean ret_0;
1239 algorithm
1240 ✗ out_txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
1241 ✗ out_txt := Tpl.pushIter(out_txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1242 ✗ out_txt := lm_30(out_txt, a_inArgs, a_outArgs);
1243 ✗ out_txt := Tpl.popIter(out_txt);
1244 ✗ out_txt := Tpl.softNewLine(out_txt);
1245 ✗ out_txt := Tpl.popBlock(out_txt);
1246 ✗ out_txt := fun_31(out_txt, a_locals);
1247 ✗ out_txt := Tpl.softNewLine(out_txt);
1248 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("algorithm"));
1249 ✗ ret_0 := Tpl.debugSusan();
1250 ✗ out_txt := fun_32(out_txt, ret_0);
1251 ✗ out_txt := Tpl.softNewLine(out_txt);
1252 ✗ out_txt := Tpl.pushBlock(out_txt, Tpl.BT_INDENT(2));
1253 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("for "));
1254 ✗ out_txt := Tpl.writeStr(out_txt, a_eltName);
1255 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING(" in "));
1256 ✗ out_txt := Tpl.writeStr(out_txt, a_listName);
1257 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_LINE(" loop\n"));
1258 ✗ out_txt := Tpl.pushBlock(out_txt, Tpl.BT_INDENT(2));
1259 ✗ out_txt := fun_34(out_txt, a_outArgs);
1260 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING(" := match "));
1261 ✗ out_txt := Tpl.writeStr(out_txt, a_eltName);
1262 ✗ out_txt := fun_35(out_txt, a_matchLocals);
1263 ✗ out_txt := Tpl.softNewLine(out_txt);
1264 ✗ out_txt := Tpl.popBlock(out_txt);
1265 ✗ out_txt := Tpl.pushIter(out_txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1266 ✗ out_txt := lm_41(out_txt, a_matchCases, a_outArgs);
1267 ✗ out_txt := Tpl.popIter(out_txt);
1268 ✗ out_txt := Tpl.softNewLine(out_txt);
1269 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({
1270 " end match;\n",
1271 "end for;"
1272 }, false));
1273 ✗ ret_1 := Tpl.debugSusan();
1274 ✗ out_txt := fun_42(out_txt, ret_1);
1275 ✗ out_txt := Tpl.popBlock(out_txt);
1276 end mmListForLoopFunBody;
1277
1278 protected function fun_44
1279 input Tpl.Text in_txt;
1280 input TplAbsyn.TypedIdents in_a_out;
1281
1282 output Tpl.Text out_txt;
1283 algorithm
1284 out_txt :=
1285 match(in_txt, in_a_out)
1286 local
1287 Tpl.Text txt;
1288
1289 case ( txt,
1290 {} )
1291 then txt;
1292
1293 case ( txt,
1294 _ )
1295 algorithm
1296 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
1297 then txt;
1298 end match;
1299 end fun_44;
1300
1301 protected function fun_45
1302 input Tpl.Text in_txt;
1303 input TplAbsyn.TypedIdents in_a_in;
1304 input TplAbsyn.TypedIdents in_a_out;
1305
1306 output Tpl.Text out_txt;
1307 algorithm
1308 out_txt :=
1309 match(in_txt, in_a_in, in_a_out)
1310 local
1311 Tpl.Text txt;
1312 TplAbsyn.TypedIdents a_out;
1313
1314 case ( txt,
1315 {},
1316 a_out )
1317 algorithm
1318 ✗ txt := fun_44(txt, a_out);
1319 then txt;
1320
1321 case ( txt,
1322 _,
1323 _ )
1324 algorithm
1325 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
1326 then txt;
1327 end match;
1328 end fun_45;
1329
1330 protected function fun_46
1331 input Tpl.Text in_txt;
1332 input TplAbsyn.TypedIdents in_a_inOut;
1333 input TplAbsyn.TypedIdents in_a_out;
1334 input TplAbsyn.TypedIdents in_a_in;
1335
1336 output Tpl.Text out_txt;
1337 algorithm
1338 out_txt :=
1339 match(in_txt, in_a_inOut, in_a_out, in_a_in)
1340 local
1341 Tpl.Text txt;
1342 TplAbsyn.TypedIdents a_out;
1343 TplAbsyn.TypedIdents a_in;
1344 TplAbsyn.TypedIdents i_inOut;
1345
1346 case ( txt,
1347 {},
1348 _,
1349 _ )
1350 then txt;
1351
1352 case ( txt,
1353 i_inOut,
1354 a_out,
1355 a_in )
1356 algorithm
1357 ✗ txt := typedIdentsEx(txt, i_inOut, "input output", "");
1358 ✗ txt := Tpl.softNewLine(txt);
1359 ✗ txt := fun_45(txt, a_in, a_out);
1360 then txt;
1361 end match;
1362 end fun_46;
1363
1364 protected function fun_47
1365 input Tpl.Text in_txt;
1366 input TplAbsyn.TypedIdents in_a_out;
1367
1368 output Tpl.Text out_txt;
1369 algorithm
1370 out_txt :=
1371 match(in_txt, in_a_out)
1372 local
1373 Tpl.Text txt;
1374
1375 case ( txt,
1376 {} )
1377 then txt;
1378
1379 case ( txt,
1380 _ )
1381 algorithm
1382 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
1383 then txt;
1384 end match;
1385 end fun_47;
1386
1387 protected function fun_48
1388 input Tpl.Text in_txt;
1389 input TplAbsyn.TypedIdents in_a_in;
1390 input TplAbsyn.TypedIdents in_a_out;
1391
1392 output Tpl.Text out_txt;
1393 algorithm
1394 out_txt :=
1395 match(in_txt, in_a_in, in_a_out)
1396 local
1397 Tpl.Text txt;
1398 TplAbsyn.TypedIdents a_out;
1399 TplAbsyn.TypedIdents i_in;
1400
1401 case ( txt,
1402 {},
1403 _ )
1404 then txt;
1405
1406 case ( txt,
1407 i_in,
1408 a_out )
1409 algorithm
1410 ✗ txt := typedIdentsEx(txt, i_in, "input", "");
1411 ✗ txt := Tpl.softNewLine(txt);
1412 ✗ txt := fun_47(txt, a_out);
1413 then txt;
1414 end match;
1415 end fun_48;
1416
1417 protected function fun_49
1418 input Tpl.Text in_txt;
1419 input TplAbsyn.TypedIdents in_a_out;
1420
1421 output Tpl.Text out_txt;
1422 algorithm
1423 out_txt :=
1424 match(in_txt, in_a_out)
1425 local
1426 Tpl.Text txt;
1427 TplAbsyn.TypedIdents i_out;
1428
1429 case ( txt,
1430 {} )
1431 then txt;
1432
1433 case ( txt,
1434 i_out )
1435 algorithm
1436 ✗ txt := typedIdentsEx(txt, i_out, "output", "");
1437 then txt;
1438 end match;
1439 end fun_49;
1440
1441 protected function fun_50
1442 input Tpl.Text in_txt;
1443 input tuple<TplAbsyn.TypedIdents, TplAbsyn.TypedIdents, TplAbsyn.TypedIdents> in_mArg;
1444
1445 output Tpl.Text out_txt;
1446 algorithm
1447 out_txt :=
1448 match(in_txt, in_mArg)
1449 local
1450 Tpl.Text txt;
1451 TplAbsyn.TypedIdents i_out;
1452 TplAbsyn.TypedIdents i_in;
1453 TplAbsyn.TypedIdents i_inOut;
1454
1455 case ( txt,
1456 (i_inOut, i_in, i_out) )
1457 algorithm
1458 ✗ txt := fun_46(txt, i_inOut, i_out, i_in);
1459 ✗ txt := Tpl.softNewLine(txt);
1460 ✗ txt := fun_48(txt, i_in, i_out);
1461 ✗ txt := Tpl.softNewLine(txt);
1462 ✗ txt := fun_49(txt, i_out);
1463 then txt;
1464 end match;
1465 end fun_50;
1466
1467 public function inOutArgs
1468 input Tpl.Text txt;
1469 input TplAbsyn.TypedIdents a_inArgs;
1470 input TplAbsyn.TypedIdents a_outArgs;
1471
1472 output Tpl.Text out_txt;
1473 protected
1474 tuple<TplAbsyn.TypedIdents, TplAbsyn.TypedIdents, TplAbsyn.TypedIdents> ret_0;
1475 algorithm
1476 ✗ ret_0 := TplAbsyn.intersectInOutArgs(a_inArgs, a_outArgs);
1477 ✗ out_txt := fun_50(txt, ret_0);
1478 end inOutArgs;
1479
1480 public function pathIdent
1481 input Tpl.Text in_txt;
1482 input TplAbsyn.PathIdent in_a_path;
1483
1484 output Tpl.Text out_txt;
1485 algorithm
1486 out_txt :=
1487 match(in_txt, in_a_path)
1488 local
1489 Tpl.Text txt;
1490 TplAbsyn.PathIdent i_path;
1491 TplAbsyn.Ident i_ident;
1492
1493 case ( txt,
1494 TplAbsyn.IDENT(ident = i_ident) )
1495 algorithm
1496 ✗ txt := Tpl.writeStr(txt, i_ident);
1497 then txt;
1498
1499 case ( txt,
1500 TplAbsyn.PATH_IDENT(ident = "builtin", path = i_path) )
1501 algorithm
1502 ✗ txt := pathIdent(txt, i_path);
1503 then txt;
1504
1505 case ( txt,
1506 TplAbsyn.PATH_IDENT(ident = i_ident, path = i_path) )
1507 algorithm
1508 ✗ txt := Tpl.writeStr(txt, i_ident);
1509 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("."));
1510 ✗ txt := pathIdent(txt, i_path);
1511 then txt;
1512
1513 case ( txt,
1514 _ )
1515 then txt;
1516 end match;
1517 end pathIdent;
1518
1519 public function mmPublic
1520 input Tpl.Text in_txt;
1521 input Boolean in_a_it;
1522
1523 output Tpl.Text out_txt;
1524 algorithm
1525 out_txt :=
1526 match(in_txt, in_a_it)
1527 local
1528 Tpl.Text txt;
1529
1530 case ( txt,
1531 true )
1532 algorithm
1533 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("public"));
1534 then txt;
1535
1536 case ( txt,
1537 _ )
1538 algorithm
1539 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("protected"));
1540 then txt;
1541 end match;
1542 end mmPublic;
1543
1544 protected function lm_54
1545 input output Tpl.Text txt;
1546 input TplAbsyn.TypedIdents items;
1547 algorithm
1548 ✗ for lstElt_54 in items loop
1549 txt := match lstElt_54
1550 local
1551 TplAbsyn.Ident i_id;
1552 TplAbsyn.TypeSignature i_ts;
1553
1554 case (i_id, i_ts)
1555 algorithm
1556 ✗ txt := typeSig(txt, i_ts);
1557 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
1558 ✗ txt := Tpl.writeStr(txt, i_id);
1559 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
1560 ✗ txt := Tpl.nextIter(txt);
1561 then txt;
1562 end match;
1563 end for;
1564 end lm_54;
1565
1566 public function typedIdents
1567 input Tpl.Text txt;
1568 input TplAbsyn.TypedIdents a_decls;
1569
1570 output Tpl.Text out_txt;
1571 algorithm
1572 ✗ out_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()));
1573 ✗ out_txt := lm_54(out_txt, a_decls);
1574 ✗ out_txt := Tpl.popIter(out_txt);
1575 end typedIdents;
1576
1577 protected function lm_56
1578 input output Tpl.Text txt;
1579 input TplAbsyn.TypedIdents items;
1580 input String a_idPrfx;
1581 input String a_typePrfx;
1582 algorithm
1583 ✗ for lstElt_56 in items loop
1584 txt := match lstElt_56
1585 local
1586 TplAbsyn.Ident i_id;
1587 TplAbsyn.TypeSignature i_ty;
1588
1589 case (i_id, i_ty)
1590 algorithm
1591 ✗ txt := Tpl.writeStr(txt, a_typePrfx);
1592 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
1593 ✗ txt := typeSig(txt, i_ty);
1594 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
1595 ✗ txt := Tpl.writeStr(txt, a_idPrfx);
1596 ✗ txt := Tpl.writeStr(txt, i_id);
1597 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
1598 ✗ txt := Tpl.nextIter(txt);
1599 then txt;
1600 end match;
1601 end for;
1602 end lm_56;
1603
1604 public function typedIdentsEx
1605 input Tpl.Text txt;
1606 input TplAbsyn.TypedIdents a_decls;
1607 input String a_typePrfx;
1608 input String a_idPrfx;
1609
1610 output Tpl.Text out_txt;
1611 algorithm
1612 ✗ out_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()));
1613 ✗ out_txt := lm_56(out_txt, a_decls, a_idPrfx, a_typePrfx);
1614 ✗ out_txt := Tpl.popIter(out_txt);
1615 end typedIdentsEx;
1616
1617 protected function lm_58
1618 input output Tpl.Text txt;
1619 input list<TplAbsyn.TypeSignature> items;
1620 algorithm
1621 ✗ for lstElt_58 in items loop
1622 txt := match lstElt_58
1623 local
1624 TplAbsyn.TypeSignature i_it;
1625
1626 case i_it
1627 algorithm
1628 ✗ txt := typeSig(txt, i_it);
1629 ✗ txt := Tpl.nextIter(txt);
1630 then txt;
1631 end match;
1632 end for;
1633 end lm_58;
1634
1635 public function typeSig
1636 input Tpl.Text in_txt;
1637 input TplAbsyn.TypeSignature in_a_it;
1638
1639 output Tpl.Text out_txt;
1640 algorithm
1641 out_txt :=
1642 match(in_txt, in_a_it)
1643 local
1644 Tpl.Text txt;
1645 String i_reason;
1646 TplAbsyn.PathIdent i_name;
1647 list<TplAbsyn.TypeSignature> i_ofTypes;
1648 TplAbsyn.TypeSignature i_ofType;
1649
1650 case ( txt,
1651 TplAbsyn.LIST_TYPE(ofType = i_ofType) )
1652 algorithm
1653 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("list<"));
1654 ✗ txt := typeSig(txt, i_ofType);
1655 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(">"));
1656 then txt;
1657
1658 case ( txt,
1659 TplAbsyn.ARRAY_TYPE(ofType = i_ofType) )
1660 algorithm
1661 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("array<"));
1662 ✗ txt := typeSig(txt, i_ofType);
1663 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(">"));
1664 then txt;
1665
1666 case ( txt,
1667 TplAbsyn.OPTION_TYPE(ofType = i_ofType) )
1668 algorithm
1669 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("Option<"));
1670 ✗ txt := typeSig(txt, i_ofType);
1671 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(">"));
1672 then txt;
1673
1674 case ( txt,
1675 TplAbsyn.TUPLE_TYPE(ofTypes = i_ofTypes) )
1676 algorithm
1677 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("tuple<"));
1678 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1679 ✗ txt := lm_58(txt, i_ofTypes);
1680 ✗ txt := Tpl.popIter(txt);
1681 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(">"));
1682 then txt;
1683
1684 case ( txt,
1685 TplAbsyn.NAMED_TYPE(name = i_name) )
1686 algorithm
1687 ✗ txt := pathIdent(txt, i_name);
1688 then txt;
1689
1690 case ( txt,
1691 TplAbsyn.STRING_TYPE() )
1692 algorithm
1693 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("String"));
1694 then txt;
1695
1696 case ( txt,
1697 TplAbsyn.TEXT_TYPE() )
1698 algorithm
1699 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("Tpl.Text"));
1700 then txt;
1701
1702 case ( txt,
1703 TplAbsyn.STRING_TOKEN_TYPE() )
1704 algorithm
1705 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("Tpl.StringToken"));
1706 then txt;
1707
1708 case ( txt,
1709 TplAbsyn.INTEGER_TYPE() )
1710 algorithm
1711 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("Integer"));
1712 then txt;
1713
1714 case ( txt,
1715 TplAbsyn.REAL_TYPE() )
1716 algorithm
1717 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("Real"));
1718 then txt;
1719
1720 case ( txt,
1721 TplAbsyn.BOOLEAN_TYPE() )
1722 algorithm
1723 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("Boolean"));
1724 then txt;
1725
1726 case ( txt,
1727 TplAbsyn.UNRESOLVED_TYPE(reason = i_reason) )
1728 algorithm
1729 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("#type? "));
1730 ✗ txt := Tpl.writeStr(txt, i_reason);
1731 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" ?#"));
1732 then txt;
1733
1734 case ( txt,
1735 _ )
1736 then txt;
1737 end match;
1738 end typeSig;
1739
1740 protected function lm_60
1741 input output Tpl.Text txt;
1742 input list<String> items;
1743 algorithm
1744 ✗ for lstElt_60 in items loop
1745 txt := match lstElt_60
1746 local
1747 String i_it;
1748
1749 case i_it
1750 algorithm
1751 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
1752 ✗ txt := mmEscapeStringConst(txt, i_it, true);
1753 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
1754 ✗ txt := Tpl.nextIter(txt);
1755 then txt;
1756 end match;
1757 end for;
1758 end lm_60;
1759
1760 public function mmStringTokenConstant
1761 input Tpl.Text in_txt;
1762 input Tpl.StringToken in_a_it;
1763
1764 output Tpl.Text out_txt;
1765 algorithm
1766 out_txt :=
1767 match(in_txt, in_a_it)
1768 local
1769 Tpl.Text txt;
1770 Boolean i_lastHasNewLine;
1771 list<String> i_strList;
1772 String i_line;
1773 String i_value;
1774
1775 case ( txt,
1776 Tpl.ST_NEW_LINE() )
1777 algorithm
1778 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("Tpl.ST_NEW_LINE()"));
1779 then txt;
1780
1781 case ( txt,
1782 Tpl.ST_STRING(value = i_value) )
1783 algorithm
1784 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("Tpl.ST_STRING(\""));
1785 ✗ txt := mmEscapeStringConst(txt, i_value, true);
1786 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\")"));
1787 then txt;
1788
1789 case ( txt,
1790 Tpl.ST_LINE(line = i_line) )
1791 algorithm
1792 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("Tpl.ST_LINE(\""));
1793 ✗ txt := mmEscapeStringConst(txt, i_line, true);
1794 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\")"));
1795 then txt;
1796
1797 case ( txt,
1798 Tpl.ST_STRING_LIST(strList = i_strList, lastHasNewLine = i_lastHasNewLine) )
1799 algorithm
1800 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_ANCHOR(0));
1801 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("Tpl.ST_STRING_LIST({\n"));
1802 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(4));
1803 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_LINE(",\n")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1804 ✗ txt := lm_60(txt, i_strList);
1805 ✗ txt := Tpl.popIter(txt);
1806 ✗ txt := Tpl.softNewLine(txt);
1807 ✗ txt := Tpl.popBlock(txt);
1808 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("}, "));
1809 ✗ txt := Tpl.writeStr(txt, Tpl.booleanString(i_lastHasNewLine));
1810 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
1811 ✗ txt := Tpl.popBlock(txt);
1812 then txt;
1813
1814 case ( txt,
1815 _ )
1816 then txt;
1817 end match;
1818 end mmStringTokenConstant;
1819
1820 protected function fun_62
1821 input Tpl.Text in_txt;
1822 input Boolean in_a_escapeNewLine;
1823
1824 output Tpl.Text out_txt;
1825 algorithm
1826 out_txt :=
1827 match(in_txt, in_a_escapeNewLine)
1828 local
1829 Tpl.Text txt;
1830
1831 case ( txt,
1832 false )
1833 algorithm
1834 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
1835 then txt;
1836
1837 case ( txt,
1838 _ )
1839 algorithm
1840 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\\n"));
1841 then txt;
1842 end match;
1843 end fun_62;
1844
1845 protected function fun_63
1846 input Tpl.Text in_txt;
1847 input String in_a_it;
1848 input Boolean in_a_escapeNewLine;
1849
1850 output Tpl.Text out_txt;
1851 algorithm
1852 out_txt :=
1853 match(in_txt, in_a_it, in_a_escapeNewLine)
1854 local
1855 Tpl.Text txt;
1856 Boolean a_escapeNewLine;
1857 String i_c;
1858
1859 case ( txt,
1860 "\\",
1861 _ )
1862 algorithm
1863 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\\\\"));
1864 then txt;
1865
1866 case ( txt,
1867 "\'",
1868 _ )
1869 algorithm
1870 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\\\'"));
1871 then txt;
1872
1873 case ( txt,
1874 "\"",
1875 _ )
1876 algorithm
1877 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\\\""));
1878 then txt;
1879
1880 case ( txt,
1881 "\n",
1882 a_escapeNewLine )
1883 algorithm
1884 ✗ txt := fun_62(txt, a_escapeNewLine);
1885 then txt;
1886
1887 case ( txt,
1888 "\t",
1889 _ )
1890 algorithm
1891 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\\t"));
1892 then txt;
1893
1894 case ( txt,
1895 i_c,
1896 _ )
1897 algorithm
1898 ✗ txt := Tpl.writeStr(txt, i_c);
1899 then txt;
1900 end match;
1901 end fun_63;
1902
1903 protected function lm_64
1904 input output Tpl.Text txt;
1905 input list<String> items;
1906 input Boolean a_escapeNewLine;
1907 algorithm
1908 ✗ for lstElt_64 in items loop
1909 txt := match lstElt_64
1910 local
1911 String i_it;
1912
1913 case i_it
1914 algorithm
1915 ✗ txt := fun_63(txt, i_it, a_escapeNewLine);
1916 then txt;
1917 end match;
1918 end for;
1919 end lm_64;
1920
1921 public function mmEscapeStringConst
1922 input Tpl.Text txt;
1923 input String a_internalValue;
1924 input Boolean a_escapeNewLine;
1925
1926 output Tpl.Text out_txt;
1927 protected
1928 list<String> ret_0;
1929 algorithm
1930 ✗ ret_0 := stringListStringChar(a_internalValue);
1931 ✗ out_txt := lm_64(txt, ret_0, a_escapeNewLine);
1932 end mmEscapeStringConst;
1933
1934 protected function lm_66
1935 input output Tpl.Text txt;
1936 input list<TplAbsyn.Ident> items;
1937 algorithm
1938 ✗ for lstElt_66 in items loop
1939 txt := match lstElt_66
1940 local
1941 TplAbsyn.Ident i_it;
1942
1943 case i_it
1944 algorithm
1945 ✗ txt := Tpl.writeStr(txt, i_it);
1946 ✗ txt := Tpl.nextIter(txt);
1947 then txt;
1948 end match;
1949 end for;
1950 end lm_66;
1951
1952 protected function fun_67
1953 input Tpl.Text in_txt;
1954 input list<TplAbsyn.Ident> in_a_lhsArgs;
1955
1956 output Tpl.Text out_txt;
1957 algorithm
1958 out_txt :=
1959 match(in_txt, in_a_lhsArgs)
1960 local
1961 Tpl.Text txt;
1962 list<TplAbsyn.Ident> i_args;
1963 TplAbsyn.Ident i_id;
1964
1965 case ( txt,
1966 {i_id} )
1967 algorithm
1968 ✗ txt := Tpl.writeStr(txt, i_id);
1969 then txt;
1970
1971 case ( txt,
1972 i_args )
1973 algorithm
1974 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
1975 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1976 ✗ txt := lm_66(txt, i_args);
1977 ✗ txt := Tpl.popIter(txt);
1978 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
1979 then txt;
1980 end match;
1981 end fun_67;
1982
1983 protected function lm_68
1984 input output Tpl.Text txt;
1985 input list<TplAbsyn.MMExp> items;
1986 input String a_assignStr;
1987 algorithm
1988 ✗ for lstElt_68 in items loop
1989 txt := match lstElt_68
1990 local
1991 TplAbsyn.MMExp i_it;
1992
1993 case i_it
1994 algorithm
1995 ✗ txt := mmExp(txt, i_it, a_assignStr);
1996 ✗ txt := Tpl.nextIter(txt);
1997 then txt;
1998 end match;
1999 end for;
2000 end lm_68;
2001
2002 public function mmExp
2003 input Tpl.Text in_txt;
2004 input TplAbsyn.MMExp in_a_it;
2005 input String in_a_assignStr;
2006
2007 output Tpl.Text out_txt;
2008 algorithm
2009 out_txt :=
2010 match(in_txt, in_a_it, in_a_assignStr)
2011 local
2012 Tpl.Text txt;
2013 String a_assignStr;
2014 String i_value_1;
2015 TplAbsyn.StringToken i_value;
2016 TplAbsyn.PathIdent i_ident;
2017 list<TplAbsyn.MMExp> i_args;
2018 TplAbsyn.PathIdent i_fnName;
2019 TplAbsyn.MMExp i_rhs;
2020 list<TplAbsyn.Ident> i_lhsArgs;
2021
2022 case ( txt,
2023 TplAbsyn.MM_ASSIGN(lhsArgs = i_lhsArgs, rhs = i_rhs),
2024 a_assignStr )
2025 algorithm
2026 ✗ txt := fun_67(txt, i_lhsArgs);
2027 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
2028 ✗ txt := Tpl.writeStr(txt, a_assignStr);
2029 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
2030 ✗ txt := mmExp(txt, i_rhs, a_assignStr);
2031 then txt;
2032
2033 case ( txt,
2034 TplAbsyn.MM_FN_CALL(fnName = i_fnName, args = i_args),
2035 a_assignStr )
2036 algorithm
2037 ✗ txt := pathIdent(txt, i_fnName);
2038 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
2039 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2040 ✗ txt := lm_68(txt, i_args, a_assignStr);
2041 ✗ txt := Tpl.popIter(txt);
2042 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
2043 then txt;
2044
2045 case ( txt,
2046 TplAbsyn.MM_IDENT(ident = i_ident),
2047 _ )
2048 algorithm
2049 ✗ txt := pathIdent(txt, i_ident);
2050 then txt;
2051
2052 case ( txt,
2053 TplAbsyn.MM_STR_TOKEN(value = i_value),
2054 _ )
2055 algorithm
2056 ✗ txt := mmStringTokenConstant(txt, i_value);
2057 then txt;
2058
2059 case ( txt,
2060 TplAbsyn.MM_STRING(value = i_value_1),
2061 _ )
2062 algorithm
2063 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_ABS_INDENT(0));
2064 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
2065 ✗ txt := mmEscapeStringConst(txt, i_value_1, false);
2066 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
2067 ✗ txt := Tpl.popBlock(txt);
2068 then txt;
2069
2070 case ( txt,
2071 TplAbsyn.MM_LITERAL(value = i_value_1),
2072 _ )
2073 algorithm
2074 ✗ txt := Tpl.writeStr(txt, i_value_1);
2075 then txt;
2076
2077 case ( txt,
2078 _,
2079 _ )
2080 then txt;
2081 end match;
2082 end mmExp;
2083
2084 protected function lm_70
2085 input output Tpl.Text txt;
2086 input list<tuple<TplAbsyn.Ident, TplAbsyn.MatchingExp>> items;
2087 algorithm
2088 ✗ for lstElt_70 in items loop
2089 txt := match lstElt_70
2090 local
2091 TplAbsyn.MatchingExp i_mexp;
2092 TplAbsyn.Ident i_field;
2093
2094 case (i_field, i_mexp)
2095 algorithm
2096 ✗ txt := Tpl.writeStr(txt, i_field);
2097 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = "));
2098 ✗ txt := mmMatchingExp(txt, i_mexp);
2099 ✗ txt := Tpl.nextIter(txt);
2100 then txt;
2101 end match;
2102 end for;
2103 end lm_70;
2104
2105 protected function lm_71
2106 input output Tpl.Text txt;
2107 input list<TplAbsyn.MatchingExp> items;
2108 algorithm
2109 ✗ for lstElt_71 in items loop
2110 txt := match lstElt_71
2111 local
2112 TplAbsyn.MatchingExp i_it;
2113
2114 case i_it
2115 algorithm
2116 ✗ txt := mmMatchingExp(txt, i_it);
2117 ✗ txt := Tpl.nextIter(txt);
2118 then txt;
2119 end match;
2120 end for;
2121 end lm_71;
2122
2123 protected function lm_72
2124 input output Tpl.Text txt;
2125 input list<TplAbsyn.MatchingExp> items;
2126 algorithm
2127 ✗ for lstElt_72 in items loop
2128 txt := match lstElt_72
2129 local
2130 TplAbsyn.MatchingExp i_it;
2131
2132 case i_it
2133 algorithm
2134 ✗ txt := mmMatchingExp(txt, i_it);
2135 ✗ txt := Tpl.nextIter(txt);
2136 then txt;
2137 end match;
2138 end for;
2139 end lm_72;
2140
2141 public function mmMatchingExp
2142 input Tpl.Text in_txt;
2143 input TplAbsyn.MatchingExp in_a_it;
2144
2145 output Tpl.Text out_txt;
2146 algorithm
2147 out_txt :=
2148 match(in_txt, in_a_it)
2149 local
2150 Tpl.Text txt;
2151 String i_value_1;
2152 TplAbsyn.MatchingExp i_rest;
2153 TplAbsyn.MatchingExp i_head;
2154 list<TplAbsyn.MatchingExp> i_listElts;
2155 list<TplAbsyn.MatchingExp> i_tupleArgs;
2156 TplAbsyn.MatchingExp i_value;
2157 list<tuple<TplAbsyn.Ident, TplAbsyn.MatchingExp>> i_fieldMatchings;
2158 TplAbsyn.PathIdent i_tagName;
2159 TplAbsyn.MatchingExp i_matchingExp;
2160 TplAbsyn.Ident i_bindIdent;
2161
2162 case ( txt,
2163 TplAbsyn.BIND_AS_MATCH(bindIdent = i_bindIdent, matchingExp = i_matchingExp) )
2164 algorithm
2165 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
2166 ✗ txt := Tpl.writeStr(txt, i_bindIdent);
2167 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" as "));
2168 ✗ txt := mmMatchingExp(txt, i_matchingExp);
2169 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
2170 then txt;
2171
2172 case ( txt,
2173 TplAbsyn.BIND_MATCH(bindIdent = i_bindIdent) )
2174 algorithm
2175 ✗ txt := Tpl.writeStr(txt, i_bindIdent);
2176 then txt;
2177
2178 case ( txt,
2179 TplAbsyn.RECORD_MATCH(tagName = i_tagName, fieldMatchings = i_fieldMatchings) )
2180 algorithm
2181 ✗ txt := pathIdent(txt, i_tagName);
2182 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
2183 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2184 ✗ txt := lm_70(txt, i_fieldMatchings);
2185 ✗ txt := Tpl.popIter(txt);
2186 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
2187 then txt;
2188
2189 case ( txt,
2190 TplAbsyn.SOME_MATCH(value = i_value) )
2191 algorithm
2192 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("SOME("));
2193 ✗ txt := mmMatchingExp(txt, i_value);
2194 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
2195 then txt;
2196
2197 case ( txt,
2198 TplAbsyn.NONE_MATCH() )
2199 algorithm
2200 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("NONE()"));
2201 then txt;
2202
2203 case ( txt,
2204 TplAbsyn.TUPLE_MATCH(tupleArgs = i_tupleArgs) )
2205 algorithm
2206 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
2207 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2208 ✗ txt := lm_71(txt, i_tupleArgs);
2209 ✗ txt := Tpl.popIter(txt);
2210 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
2211 then txt;
2212
2213 case ( txt,
2214 TplAbsyn.LIST_MATCH(listElts = i_listElts) )
2215 algorithm
2216 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("{"));
2217 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2218 ✗ txt := lm_72(txt, i_listElts);
2219 ✗ txt := Tpl.popIter(txt);
2220 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("}"));
2221 then txt;
2222
2223 case ( txt,
2224 TplAbsyn.LIST_CONS_MATCH(head = i_head, rest = i_rest) )
2225 algorithm
2226 ✗ txt := mmMatchingExp(txt, i_head);
2227 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" :: "));
2228 ✗ txt := mmMatchingExp(txt, i_rest);
2229 then txt;
2230
2231 case ( txt,
2232 TplAbsyn.STRING_MATCH(value = i_value_1) )
2233 algorithm
2234 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
2235 ✗ txt := mmEscapeStringConst(txt, i_value_1, true);
2236 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
2237 then txt;
2238
2239 case ( txt,
2240 TplAbsyn.LITERAL_MATCH(value = i_value_1) )
2241 algorithm
2242 ✗ txt := Tpl.writeStr(txt, i_value_1);
2243 then txt;
2244
2245 case ( txt,
2246 TplAbsyn.REST_MATCH() )
2247 algorithm
2248 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_"));
2249 then txt;
2250
2251 case ( txt,
2252 _ )
2253 then txt;
2254 end match;
2255 end mmMatchingExp;
2256
2257 protected function lm_74
2258 input output Tpl.Text txt;
2259 input list<TplAbsyn.MMExp> items;
2260 algorithm
2261 ✗ for lstElt_74 in items loop
2262 txt := match lstElt_74
2263 local
2264 TplAbsyn.MMExp i_it;
2265
2266 case i_it
2267 algorithm
2268 ✗ txt := mmExp(txt, i_it, ":=");
2269 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
2270 ✗ txt := Tpl.nextIter(txt);
2271 then txt;
2272 end match;
2273 end for;
2274 end lm_74;
2275
2276 public function mmStatements
2277 input Tpl.Text txt;
2278 input list<TplAbsyn.MMExp> a_stmts;
2279
2280 output Tpl.Text out_txt;
2281 algorithm
2282 ✗ out_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()));
2283 ✗ out_txt := lm_74(out_txt, a_stmts);
2284 ✗ out_txt := Tpl.popIter(out_txt);
2285 end mmStatements;
2286
2287 protected function fun_76
2288 input Tpl.Text in_txt;
2289 input Boolean in_a_isDefault;
2290
2291 output Tpl.Text out_txt;
2292 algorithm
2293 out_txt :=
2294 match(in_txt, in_a_isDefault)
2295 local
2296 Tpl.Text txt;
2297
2298 case ( txt,
2299 false )
2300 then txt;
2301
2302 case ( txt,
2303 _ )
2304 algorithm
2305 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("default "));
2306 then txt;
2307 end match;
2308 end fun_76;
2309
2310 protected function lm_77
2311 input output Tpl.Text txt;
2312 input list<tuple<TplAbsyn.Ident, TplAbsyn.TypeInfo>> items;
2313 algorithm
2314 ✗ for lstElt_77 in items loop
2315 txt := match lstElt_77
2316 local
2317 TplAbsyn.TypeInfo i_tinfo;
2318 TplAbsyn.Ident i_id;
2319
2320 case (i_id, i_tinfo)
2321 algorithm
2322 ✗ txt := sASTDefType(txt, i_id, i_tinfo);
2323 ✗ txt := Tpl.nextIter(txt);
2324 then txt;
2325 end match;
2326 end for;
2327 end lm_77;
2328
2329 protected function lm_78
2330 input output Tpl.Text txt;
2331 input list<TplAbsyn.ASTDef> items;
2332 algorithm
2333 ✗ for lstElt_78 in items loop
2334 txt := match lstElt_78
2335 local
2336 list<tuple<TplAbsyn.Ident, TplAbsyn.TypeInfo>> i_types;
2337 TplAbsyn.PathIdent i_importPackage;
2338 Boolean i_isDefault;
2339
2340 case TplAbsyn.AST_DEF(isDefault = i_isDefault, importPackage = i_importPackage, types = i_types)
2341 algorithm
2342 ✗ txt := fun_76(txt, i_isDefault);
2343 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("absyn "));
2344 ✗ txt := pathIdent(txt, i_importPackage);
2345 ✗ txt := Tpl.softNewLine(txt);
2346 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
2347 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING_LIST({
2348 "\n",
2349 "\n"
2350 }, true)), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2351 ✗ txt := lm_77(txt, i_types);
2352 ✗ txt := Tpl.popIter(txt);
2353 ✗ txt := Tpl.softNewLine(txt);
2354 ✗ txt := Tpl.popBlock(txt);
2355 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("end "));
2356 ✗ txt := pathIdent(txt, i_importPackage);
2357 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
2358 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
2359 ✗ txt := Tpl.nextIter(txt);
2360 then txt;
2361
2362 case _
2363 then txt;
2364 end match;
2365 end for;
2366 end lm_78;
2367
2368 protected function lm_79
2369 input output Tpl.Text txt;
2370 input list<tuple<TplAbsyn.Ident, TplAbsyn.TemplateDef>> items;
2371 algorithm
2372 ✗ for lstElt_79 in items loop
2373 txt := match lstElt_79
2374 local
2375 TplAbsyn.Ident i_id;
2376 TplAbsyn.TemplateDef i_def;
2377
2378 case (i_id, i_def)
2379 algorithm
2380 ✗ txt := sTemplateDef(txt, i_def, i_id);
2381 ✗ txt := Tpl.nextIter(txt);
2382 then txt;
2383 end match;
2384 end for;
2385 end lm_79;
2386
2387 public function sTemplPackage
2388 input Tpl.Text in_txt;
2389 input TplAbsyn.TemplPackage in_a_it;
2390
2391 output Tpl.Text out_txt;
2392 algorithm
2393 out_txt :=
2394 match(in_txt, in_a_it)
2395 local
2396 Tpl.Text txt;
2397 list<tuple<TplAbsyn.Ident, TplAbsyn.TemplateDef>> i_templateDefs;
2398 list<TplAbsyn.ASTDef> i_astDefs;
2399 TplAbsyn.PathIdent i_name;
2400
2401 case ( txt,
2402 TplAbsyn.TEMPL_PACKAGE(name = i_name, astDefs = i_astDefs, templateDefs = i_templateDefs) )
2403 algorithm
2404 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
2405 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("spackage "));
2406 ✗ txt := pathIdent(txt, i_name);
2407 ✗ txt := Tpl.softNewLine(txt);
2408 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
2409 ✗ 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()));
2410 ✗ txt := lm_78(txt, i_astDefs);
2411 ✗ txt := Tpl.popIter(txt);
2412 ✗ txt := Tpl.softNewLine(txt);
2413 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
2414 ✗ txt := Tpl.popBlock(txt);
2415 ✗ txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING_LIST({
2416 "\n",
2417 "\n"
2418 }, true)), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2419 ✗ txt := lm_79(txt, i_templateDefs);
2420 ✗ txt := Tpl.popIter(txt);
2421 ✗ txt := Tpl.softNewLine(txt);
2422 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("end "));
2423 ✗ txt := pathIdent(txt, i_name);
2424 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
2425 ✗ txt := Tpl.popBlock(txt);
2426 then txt;
2427
2428 case ( txt,
2429 _ )
2430 then txt;
2431 end match;
2432 end sTemplPackage;
2433
2434 protected function lm_81
2435 input output Tpl.Text txt;
2436 input list<tuple<TplAbsyn.Ident, TplAbsyn.TypedIdents>> items;
2437 algorithm
2438 ✗ for lstElt_81 in items loop
2439 txt := match lstElt_81
2440 local
2441 TplAbsyn.TypedIdents i_tids;
2442 TplAbsyn.Ident i_rid;
2443
2444 case (i_rid, i_tids)
2445 algorithm
2446 ✗ txt := sRecordTypeDef(txt, i_rid, i_tids);
2447 ✗ txt := Tpl.nextIter(txt);
2448 then txt;
2449 end match;
2450 end for;
2451 end lm_81;
2452
2453 protected function lm_82
2454 input output Tpl.Text txt;
2455 input TplAbsyn.TypedIdents items;
2456 algorithm
2457 ✗ for lstElt_82 in items loop
2458 txt := match lstElt_82
2459 local
2460 TplAbsyn.Ident i_aid;
2461 TplAbsyn.TypeSignature i_ts;
2462
2463 case (i_aid, i_ts)
2464 algorithm
2465 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("input "));
2466 ✗ txt := typeSig(txt, i_ts);
2467 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
2468 ✗ txt := Tpl.writeStr(txt, i_aid);
2469 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
2470 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
2471 then txt;
2472 end match;
2473 end for;
2474 end lm_82;
2475
2476 protected function lm_83
2477 input output Tpl.Text txt;
2478 input TplAbsyn.TypedIdents items;
2479 algorithm
2480 ✗ for lstElt_83 in items loop
2481 txt := match lstElt_83
2482 local
2483 TplAbsyn.Ident i_aid;
2484 TplAbsyn.TypeSignature i_ts;
2485
2486 case (i_aid, i_ts)
2487 algorithm
2488 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("output "));
2489 ✗ txt := typeSig(txt, i_ts);
2490 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
2491 ✗ txt := Tpl.writeStr(txt, i_aid);
2492 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
2493 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
2494 then txt;
2495 end match;
2496 end for;
2497 end lm_83;
2498
2499 protected function fun_84
2500 input Tpl.Text in_txt;
2501 input TplAbsyn.TypeInfo in_a_info;
2502 input TplAbsyn.Ident in_a_id;
2503
2504 output Tpl.Text out_txt;
2505 algorithm
2506 out_txt :=
2507 match(in_txt, in_a_info, in_a_id)
2508 local
2509 Tpl.Text txt;
2510 TplAbsyn.Ident a_id;
2511 TplAbsyn.TypeSignature i_constType;
2512 TplAbsyn.TypedIdents i_outArgs;
2513 TplAbsyn.TypedIdents i_inArgs;
2514 TplAbsyn.TypeSignature i_aliasType;
2515 TplAbsyn.TypedIdents i_fields;
2516 list<tuple<TplAbsyn.Ident, TplAbsyn.TypedIdents>> i_recTags;
2517
2518 case ( txt,
2519 TplAbsyn.TI_UNION_TYPE(recTags = i_recTags),
2520 a_id )
2521 algorithm
2522 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
2523 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("uniontype "));
2524 ✗ txt := Tpl.writeStr(txt, a_id);
2525 ✗ txt := Tpl.softNewLine(txt);
2526 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
2527 ✗ 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()));
2528 ✗ txt := lm_81(txt, i_recTags);
2529 ✗ txt := Tpl.popIter(txt);
2530 ✗ txt := Tpl.softNewLine(txt);
2531 ✗ txt := Tpl.popBlock(txt);
2532 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("end "));
2533 ✗ txt := Tpl.writeStr(txt, a_id);
2534 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
2535 ✗ txt := Tpl.popBlock(txt);
2536 then txt;
2537
2538 case ( txt,
2539 TplAbsyn.TI_RECORD_TYPE(fields = i_fields),
2540 a_id )
2541 algorithm
2542 ✗ txt := sRecordTypeDef(txt, a_id, i_fields);
2543 then txt;
2544
2545 case ( txt,
2546 TplAbsyn.TI_ALIAS_TYPE(aliasType = i_aliasType),
2547 a_id )
2548 algorithm
2549 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("type "));
2550 ✗ txt := Tpl.writeStr(txt, a_id);
2551 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = "));
2552 ✗ txt := typeSig(txt, i_aliasType);
2553 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
2554 then txt;
2555
2556 case ( txt,
2557 TplAbsyn.TI_FUN_TYPE(inArgs = i_inArgs, outArgs = i_outArgs),
2558 a_id )
2559 algorithm
2560 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("function "));
2561 ✗ txt := Tpl.writeStr(txt, a_id);
2562 ✗ txt := Tpl.softNewLine(txt);
2563 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
2564 ✗ txt := lm_82(txt, i_inArgs);
2565 ✗ txt := Tpl.softNewLine(txt);
2566 ✗ txt := lm_83(txt, i_outArgs);
2567 ✗ txt := Tpl.softNewLine(txt);
2568 ✗ txt := Tpl.popBlock(txt);
2569 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("end "));
2570 ✗ txt := Tpl.writeStr(txt, a_id);
2571 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
2572 then txt;
2573
2574 case ( txt,
2575 TplAbsyn.TI_CONST_TYPE(constType = i_constType),
2576 a_id )
2577 algorithm
2578 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("constant "));
2579 ✗ txt := typeSig(txt, i_constType);
2580 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
2581 ✗ txt := Tpl.writeStr(txt, a_id);
2582 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
2583 then txt;
2584
2585 case ( txt,
2586 _,
2587 _ )
2588 then txt;
2589 end match;
2590 end fun_84;
2591
2592 public function sASTDefType
2593 input Tpl.Text txt;
2594 input TplAbsyn.Ident a_id;
2595 input TplAbsyn.TypeInfo a_info;
2596
2597 output Tpl.Text out_txt;
2598 algorithm
2599 ✗ out_txt := fun_84(txt, a_info, a_id);
2600 end sASTDefType;
2601
2602 protected function lm_86
2603 input output Tpl.Text txt;
2604 input TplAbsyn.TypedIdents items;
2605 algorithm
2606 ✗ for lstElt_86 in items loop
2607 txt := match lstElt_86
2608 local
2609 TplAbsyn.Ident i_fid;
2610 TplAbsyn.TypeSignature i_ts;
2611
2612 case (i_fid, i_ts)
2613 algorithm
2614 ✗ txt := typeSig(txt, i_ts);
2615 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
2616 ✗ txt := Tpl.writeStr(txt, i_fid);
2617 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
2618 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
2619 then txt;
2620 end match;
2621 end for;
2622 end lm_86;
2623
2624 protected function fun_87
2625 input Tpl.Text in_txt;
2626 input TplAbsyn.TypedIdents in_a_fields;
2627
2628 output Tpl.Text out_txt;
2629 algorithm
2630 out_txt :=
2631 match(in_txt, in_a_fields)
2632 local
2633 Tpl.Text txt;
2634 TplAbsyn.TypedIdents i_fields;
2635
2636 case ( txt,
2637 {} )
2638 then txt;
2639
2640 case ( txt,
2641 i_fields )
2642 algorithm
2643 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
2644 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
2645 ✗ txt := lm_86(txt, i_fields);
2646 ✗ txt := Tpl.popBlock(txt);
2647 then txt;
2648 end match;
2649 end fun_87;
2650
2651 public function sRecordTypeDef
2652 input Tpl.Text txt;
2653 input TplAbsyn.Ident a_id;
2654 input TplAbsyn.TypedIdents a_fields;
2655
2656 output Tpl.Text out_txt;
2657 algorithm
2658 ✗ out_txt := Tpl.writeTok(txt, Tpl.ST_STRING("record "));
2659 ✗ out_txt := Tpl.writeStr(out_txt, a_id);
2660 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING(" "));
2661 ✗ out_txt := fun_87(out_txt, a_fields);
2662 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("end "));
2663 ✗ out_txt := Tpl.writeStr(out_txt, a_id);
2664 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING(";"));
2665 end sRecordTypeDef;
2666
2667 public function sTemplateDef
2668 input Tpl.Text in_txt;
2669 input TplAbsyn.TemplateDef in_a_it;
2670 input TplAbsyn.Ident in_a_templId;
2671
2672 output Tpl.Text out_txt;
2673 algorithm
2674 out_txt :=
2675 match(in_txt, in_a_it, in_a_templId)
2676 local
2677 Tpl.Text txt;
2678 TplAbsyn.Ident a_templId;
2679 TplAbsyn.StringToken i_value;
2680
2681 case ( txt,
2682 TplAbsyn.STR_TOKEN_DEF(value = i_value),
2683 a_templId )
2684 algorithm
2685 ✗ txt := Tpl.writeStr(txt, a_templId);
2686 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = "));
2687 ✗ txt := sConstStringToken(txt, i_value);
2688 then txt;
2689
2690 case ( txt,
2691 _,
2692 _ )
2693 then txt;
2694 end match;
2695 end sTemplateDef;
2696
2697 protected function lm_90
2698 input output Tpl.Text txt;
2699 input list<String> items;
2700 algorithm
2701 ✗ for lstElt_90 in items loop
2702 txt := match lstElt_90
2703 local
2704 String i_it;
2705
2706 case i_it
2707 algorithm
2708 ✗ txt := mmEscapeStringConst(txt, i_it, false);
2709 then txt;
2710 end match;
2711 end for;
2712 end lm_90;
2713
2714 protected function lm_91
2715 input output Tpl.Text txt;
2716 input list<String> items;
2717 algorithm
2718 ✗ for lstElt_91 in items loop
2719 txt := match lstElt_91
2720 local
2721 String i_it;
2722
2723 case i_it
2724 algorithm
2725 ✗ txt := mmEscapeStringConst(txt, i_it, true);
2726 then txt;
2727 end match;
2728 end for;
2729 end lm_91;
2730
2731 protected function lm_92
2732 input output Tpl.Text txt;
2733 input list<String> items;
2734 algorithm
2735 ✗ for lstElt_92 in items loop
2736 txt := match lstElt_92
2737 local
2738 String i_it;
2739
2740 case i_it
2741 algorithm
2742 ✗ txt := mmEscapeStringConst(txt, i_it, true);
2743 then txt;
2744 end match;
2745 end for;
2746 end lm_92;
2747
2748 protected function fun_93
2749 input Tpl.Text in_txt;
2750 input Boolean in_mArg;
2751 input list<String> in_a_sl;
2752
2753 output Tpl.Text out_txt;
2754 algorithm
2755 out_txt :=
2756 match(in_txt, in_mArg, in_a_sl)
2757 local
2758 Tpl.Text txt;
2759 list<String> a_sl;
2760
2761 case ( txt,
2762 false,
2763 a_sl )
2764 algorithm
2765 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
2766 ✗ txt := lm_91(txt, a_sl);
2767 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
2768 then txt;
2769
2770 case ( txt,
2771 _,
2772 a_sl )
2773 algorithm
2774 ✗ txt := lm_92(txt, a_sl);
2775 then txt;
2776 end match;
2777 end fun_93;
2778
2779 protected function fun_94
2780 input Tpl.Text in_txt;
2781 input Boolean in_mArg;
2782 input list<String> in_a_sl;
2783
2784 output Tpl.Text out_txt;
2785 algorithm
2786 out_txt :=
2787 match(in_txt, in_mArg, in_a_sl)
2788 local
2789 Tpl.Text txt;
2790 list<String> a_sl;
2791 Boolean ret_0;
2792
2793 case ( txt,
2794 false,
2795 a_sl )
2796 algorithm
2797 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_ABS_INDENT(0));
2798 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
2799 ✗ txt := lm_90(txt, a_sl);
2800 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
2801 ✗ txt := Tpl.popBlock(txt);
2802 then txt;
2803
2804 case ( txt,
2805 _,
2806 a_sl )
2807 algorithm
2808 ✗ ret_0 := TplAbsyn.canBeEscapedUnquoted(a_sl);
2809 ✗ txt := fun_93(txt, ret_0, a_sl);
2810 then txt;
2811 end match;
2812 end fun_94;
2813
2814 public function sConstStringToken
2815 input Tpl.Text in_txt;
2816 input Tpl.StringToken in_a_it;
2817
2818 output Tpl.Text out_txt;
2819 algorithm
2820 out_txt :=
2821 match(in_txt, in_a_it)
2822 local
2823 Tpl.Text txt;
2824 list<String> i_sl;
2825 String i_line;
2826 String i_value;
2827 Boolean ret_0;
2828
2829 case ( txt,
2830 Tpl.ST_NEW_LINE() )
2831 algorithm
2832 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\\n"));
2833 then txt;
2834
2835 case ( txt,
2836 Tpl.ST_STRING(value = i_value) )
2837 algorithm
2838 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
2839 ✗ txt := mmEscapeStringConst(txt, i_value, true);
2840 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
2841 then txt;
2842
2843 case ( txt,
2844 Tpl.ST_LINE(line = i_line) )
2845 algorithm
2846 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
2847 ✗ txt := mmEscapeStringConst(txt, i_line, true);
2848 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
2849 then txt;
2850
2851 case ( txt,
2852 Tpl.ST_STRING_LIST(strList = i_sl) )
2853 algorithm
2854 ✗ ret_0 := TplAbsyn.canBeOnOneLine(i_sl);
2855 ✗ txt := fun_94(txt, ret_0, i_sl);
2856 then txt;
2857
2858 case ( txt,
2859 _ )
2860 then txt;
2861 end match;
2862 end sConstStringToken;
2863
2864 protected function lm_96
2865 input output Tpl.Text txt;
2866 input TplAbsyn.TypedIdents items;
2867 algorithm
2868 ✗ for lstElt_96 in items loop
2869 txt := match lstElt_96
2870 local
2871 TplAbsyn.Ident i_fid;
2872 TplAbsyn.TypeSignature i_ts;
2873
2874 case (i_fid, i_ts)
2875 algorithm
2876 ✗ txt := typeSig(txt, i_ts);
2877 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
2878 ✗ txt := Tpl.writeStr(txt, i_fid);
2879 ✗ txt := Tpl.nextIter(txt);
2880 then txt;
2881 end match;
2882 end for;
2883 end lm_96;
2884
2885 public function sTypedIdents
2886 input Tpl.Text txt;
2887 input TplAbsyn.TypedIdents a_args;
2888
2889 output Tpl.Text out_txt;
2890 algorithm
2891 ✗ 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()));
2892 ✗ out_txt := lm_96(out_txt, a_args);
2893 ✗ out_txt := Tpl.popIter(out_txt);
2894 end sTypedIdents;
2895
2896 public function sFunSignature
2897 input Tpl.Text txt;
2898 input TplAbsyn.PathIdent a_name;
2899 input TplAbsyn.TypedIdents a_iargs;
2900 input TplAbsyn.TypedIdents a_oargs;
2901
2902 output Tpl.Text out_txt;
2903 algorithm
2904 ✗ out_txt := pathIdent(txt, a_name);
2905 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("("));
2906 ✗ out_txt := sTypedIdents(out_txt, a_iargs);
2907 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING(") -> ("));
2908 ✗ out_txt := sTypedIdents(out_txt, a_oargs);
2909 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING(")"));
2910 end sFunSignature;
2911
2912 protected function lm_99
2913 input output Tpl.Text txt;
2914 input list<tuple<TplAbsyn.MMExp, TplAbsyn.TypeSignature>> items;
2915 algorithm
2916 ✗ for lstElt_99 in items loop
2917 txt := match lstElt_99
2918 local
2919 TplAbsyn.MMExp i_mexp;
2920 TplAbsyn.TypeSignature i_ts;
2921
2922 case (i_mexp, i_ts)
2923 algorithm
2924 ✗ txt := typeSig(txt, i_ts);
2925 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
2926 ✗ txt := mmExp(txt, i_mexp, "=");
2927 ✗ txt := Tpl.nextIter(txt);
2928 then txt;
2929 end match;
2930 end for;
2931 end lm_99;
2932
2933 public function sActualMMParams
2934 input Tpl.Text txt;
2935 input list<tuple<TplAbsyn.MMExp, TplAbsyn.TypeSignature>> a_argValues;
2936
2937 output Tpl.Text out_txt;
2938 algorithm
2939 ✗ out_txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
2940 ✗ out_txt := Tpl.pushIter(out_txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
2941 ✗ out_txt := lm_99(out_txt, a_argValues);
2942 ✗ out_txt := Tpl.popIter(out_txt);
2943 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING(")"));
2944 end sActualMMParams;
2945
2946 annotation(__OpenModelica_Interface="susan");
2947 end TplCodegen;
2948