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

build_cmake/OMCompiler/Compiler/generated-mo/Template/Unparsing.mo
Line Branch Exec Source
1 encapsulated package Unparsing
2 "
3 file: Unparsing.mo
4 package: Unparsing
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
52 protected function lm_43
53 input output Tpl.Text txt;
54 input SCode.Program items;
55 algorithm
56 ✗ for lstElt_43 in items loop
57 txt := match lstElt_43
58 local
59 SCode.Element i_cl;
60
61 case i_cl
62 algorithm
63 ✗ txt := classExternalHeader(txt, i_cl, "");
64 then txt;
65 end match;
66 end for;
67 end lm_43;
68
69 public function programExternalHeader
70 input Tpl.Text txt;
71 input SCode.Program a_program;
72
73 output Tpl.Text out_txt;
74 algorithm
75 ✗ out_txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
76 "/* Automatically generated header for external MetaModelica functions */\n",
77 "#ifdef __cplusplus\n",
78 "extern \"C\" {\n",
79 "#endif\n"
80 }, true));
81 ✗ out_txt := lm_43(out_txt, a_program);
82 ✗ out_txt := Tpl.softNewLine(out_txt);
83 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({
84 "#ifdef __cplusplus\n",
85 "}\n",
86 "#endif\n",
87 "\n"
88 }, true));
89 end programExternalHeader;
90
91 protected function lm_45
92 input output Tpl.Text txt;
93 input list<DAE.Var> items;
94 algorithm
95 ✗ for lstElt_45 in items loop
96 txt := match lstElt_45
97 local
98 DAE.Ident i_var_name;
99
100 case DAE.TYPES_VAR(name = i_var_name)
101 algorithm
102 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
103 ✗ txt := Tpl.writeStr(txt, i_var_name);
104 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
105 ✗ txt := Tpl.nextIter(txt);
106 then txt;
107
108 case _
109 then txt;
110 end match;
111 end for;
112 end lm_45;
113
114 protected function fun_46
115 input Tpl.Text in_txt;
116 input String in_mArg;
117 input Tpl.Text in_a_fieldsStr;
118 input Tpl.Text in_a_nElts;
119 input Tpl.Text in_a_omcname;
120
121 output Tpl.Text out_txt;
122 algorithm
123 out_txt :=
124 match(in_txt, in_mArg, in_a_fieldsStr, in_a_nElts, in_a_omcname)
125 local
126 Tpl.Text txt;
127 Tpl.Text a_fieldsStr;
128 Tpl.Text a_nElts;
129 Tpl.Text a_omcname;
130
131 case ( txt,
132 "0",
133 _,
134 _,
135 a_omcname )
136 algorithm
137 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("ADD_METARECORD_DEFINITIONS const char* "));
138 ✗ txt := Tpl.writeText(txt, a_omcname);
139 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("__desc__fields[1] = {\"no fields\"};"));
140 then txt;
141
142 case ( txt,
143 _,
144 a_fieldsStr,
145 a_nElts,
146 a_omcname )
147 algorithm
148 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("ADD_METARECORD_DEFINITIONS const char* "));
149 ✗ txt := Tpl.writeText(txt, a_omcname);
150 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("__desc__fields["));
151 ✗ txt := Tpl.writeText(txt, a_nElts);
152 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("] = {"));
153 ✗ txt := Tpl.writeText(txt, a_fieldsStr);
154 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("};"));
155 then txt;
156 end match;
157 end fun_46;
158
159 protected function lm_47
160 input output Tpl.Text txt;
161 input list<DAE.Type> items;
162 algorithm
163 ✗ for lstElt_47 in items loop
164 txt := match lstElt_47
165 local
166 Absyn.Path i_path;
167 list<DAE.Var> i_ty_fields;
168 String ret_9;
169 String str_8;
170 Tpl.Text l_fieldsDescription;
171 Integer ret_6;
172 Tpl.Text l_nElts;
173 String ret_4;
174 String ret_3;
175 String ret_2;
176 Tpl.Text l_omcname;
177 Tpl.Text l_fieldsStr;
178
179 case DAE.T_METARECORD(fields = i_ty_fields, path = i_path)
180 algorithm
181 ✗ l_fieldsStr := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(",")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
182 ✗ l_fieldsStr := lm_45(l_fieldsStr, i_ty_fields);
183 ✗ l_fieldsStr := Tpl.popIter(l_fieldsStr);
184 ✗ ret_2 := AbsynUtil.pathString(i_path, "$", false, false);
185 ✗ ret_3 := System.stringReplace(ret_2, "_", "__");
186 ✗ ret_4 := System.stringReplace(ret_3, "$", "_");
187 ✗ l_omcname := Tpl.writeStr(Tpl.emptyTxt, ret_4);
188 ✗ ret_6 := listLength(i_ty_fields);
189 ✗ l_nElts := Tpl.writeStr(Tpl.emptyTxt, intString(ret_6));
190 ✗ str_8 := Tpl.textString(l_nElts);
191 ✗ l_fieldsDescription := fun_46(Tpl.emptyTxt, str_8, l_fieldsStr, l_nElts, l_omcname);
192 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
193 "#ifdef ADD_METARECORD_DEFINITIONS\n",
194 "#ifndef "
195 }, false));
196 ✗ txt := Tpl.writeText(txt, l_omcname);
197 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
198 "__desc_added\n",
199 "#define "
200 }, false));
201 ✗ txt := Tpl.writeText(txt, l_omcname);
202 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("__desc_added\n"));
203 ✗ txt := Tpl.writeText(txt, l_fieldsDescription);
204 ✗ txt := Tpl.softNewLine(txt);
205 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("ADD_METARECORD_DEFINITIONS struct record_description "));
206 ✗ txt := Tpl.writeText(txt, l_omcname);
207 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("__desc = {\n"));
208 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
209 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
210 ✗ txt := Tpl.writeText(txt, l_omcname);
211 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
212 "\",\n",
213 "\""
214 }, false));
215 ✗ ret_9 := AbsynUtil.pathString(i_path, ".", false, false);
216 ✗ txt := Tpl.writeStr(txt, ret_9);
217 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("\",\n"));
218 ✗ txt := Tpl.writeText(txt, l_omcname);
219 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("__desc__fields\n"));
220 ✗ txt := Tpl.popBlock(txt);
221 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
222 "};\n",
223 "#endif\n",
224 "#else /* Only use the file as a header */\n",
225 "extern struct record_description "
226 }, false));
227 ✗ txt := Tpl.writeText(txt, l_omcname);
228 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
229 "__desc;\n",
230 "#endif"
231 }, false));
232 ✗ txt := Tpl.nextIter(txt);
233 then txt;
234
235 case _
236 then txt;
237 end match;
238 end for;
239 end lm_47;
240
241 public function programExternalHeaderFromTypes
242 input Tpl.Text txt;
243 input list<DAE.Type> a_tys;
244
245 output Tpl.Text out_txt;
246 algorithm
247 ✗ out_txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
248 "/* Automatically generated header for bootstrapping MetaModelica */\n",
249 "#ifdef __cplusplus\n",
250 "extern \"C\" {\n",
251 "#endif\n"
252 }, true));
253 ✗ 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()));
254 ✗ out_txt := lm_47(out_txt, a_tys);
255 ✗ out_txt := Tpl.popIter(out_txt);
256 ✗ out_txt := Tpl.softNewLine(out_txt);
257 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({
258 "#ifdef __cplusplus\n",
259 "}\n",
260 "#endif\n",
261 "\n"
262 }, true));
263 end programExternalHeaderFromTypes;
264
265 protected function lm_49
266 input output Tpl.Text txt;
267 input list<SCode.Element> items;
268 input SCode.Ident a_c_name;
269 algorithm
270 ✗ for lstElt_49 in items loop
271 txt := match lstElt_49
272 local
273 SCode.Element i_elt;
274
275 case i_elt
276 algorithm
277 ✗ txt := elementExternalHeader(txt, i_elt, a_c_name);
278 then txt;
279 end match;
280 end for;
281 end lm_49;
282
283 protected function fun_50
284 input Tpl.Text in_txt;
285 input SCode.Element in_a_cl;
286
287 output Tpl.Text out_txt;
288 algorithm
289 out_txt :=
290 match(in_txt, in_a_cl)
291 local
292 Tpl.Text txt;
293 SCode.Ident i_c_name;
294 list<SCode.Element> i_p_elementLst;
295 String i_name;
296 SCode.Element i_c;
297
298 case ( txt,
299 (i_c as SCode.CLASS(restriction = SCode.R_METARECORD(moved = true, name = Absyn.IDENT(name = i_name)))) )
300 algorithm
301 ✗ txt := elementExternalHeader(txt, i_c, i_name);
302 then txt;
303
304 case ( txt,
305 SCode.CLASS(classDef = SCode.PARTS(elementLst = i_p_elementLst), name = i_c_name) )
306 algorithm
307 ✗ txt := lm_49(txt, i_p_elementLst, i_c_name);
308 then txt;
309
310 case ( txt,
311 _ )
312 then txt;
313 end match;
314 end fun_50;
315
316 public function classExternalHeader
317 input Tpl.Text txt;
318 input SCode.Element a_cl;
319 input String a_pack;
320
321 output Tpl.Text out_txt;
322 algorithm
323 ✗ out_txt := fun_50(txt, a_cl);
324 end classExternalHeader;
325
326 public function pathString
327 input Tpl.Text in_txt;
328 input Absyn.Path in_a_path;
329
330 output Tpl.Text out_txt;
331 algorithm
332 out_txt :=
333 match(in_txt, in_a_path)
334 local
335 Tpl.Text txt;
336 Absyn.Path i_path;
337 Absyn.Ident i_name_1;
338 String i_name;
339
340 case ( txt,
341 Absyn.IDENT(name = i_name) )
342 algorithm
343 ✗ txt := Tpl.writeStr(txt, i_name);
344 then txt;
345
346 case ( txt,
347 Absyn.QUALIFIED(name = i_name_1, path = i_path) )
348 algorithm
349 ✗ txt := Tpl.writeStr(txt, i_name_1);
350 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("."));
351 ✗ txt := pathString(txt, i_path);
352 then txt;
353
354 case ( txt,
355 Absyn.FULLYQUALIFIED(path = i_path) )
356 algorithm
357 ✗ txt := pathString(txt, i_path);
358 then txt;
359
360 case ( txt,
361 _ )
362 then txt;
363 end match;
364 end pathString;
365
366 public function metaHelperBoxStart
367 input Tpl.Text in_txt;
368 input Integer in_a_numVariables;
369
370 output Tpl.Text out_txt;
371 algorithm
372 out_txt :=
373 match(in_txt, in_a_numVariables)
374 local
375 Tpl.Text txt;
376 Integer i_numVariables;
377
378 case ( txt,
379 (i_numVariables as 0) )
380 algorithm
381 ✗ txt := Tpl.writeStr(txt, intString(i_numVariables));
382 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
383 then txt;
384
385 case ( txt,
386 (i_numVariables as 1) )
387 algorithm
388 ✗ txt := Tpl.writeStr(txt, intString(i_numVariables));
389 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
390 then txt;
391
392 case ( txt,
393 (i_numVariables as 2) )
394 algorithm
395 ✗ txt := Tpl.writeStr(txt, intString(i_numVariables));
396 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
397 then txt;
398
399 case ( txt,
400 (i_numVariables as 3) )
401 algorithm
402 ✗ txt := Tpl.writeStr(txt, intString(i_numVariables));
403 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
404 then txt;
405
406 case ( txt,
407 (i_numVariables as 4) )
408 algorithm
409 ✗ txt := Tpl.writeStr(txt, intString(i_numVariables));
410 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
411 then txt;
412
413 case ( txt,
414 (i_numVariables as 5) )
415 algorithm
416 ✗ txt := Tpl.writeStr(txt, intString(i_numVariables));
417 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
418 then txt;
419
420 case ( txt,
421 (i_numVariables as 6) )
422 algorithm
423 ✗ txt := Tpl.writeStr(txt, intString(i_numVariables));
424 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
425 then txt;
426
427 case ( txt,
428 (i_numVariables as 7) )
429 algorithm
430 ✗ txt := Tpl.writeStr(txt, intString(i_numVariables));
431 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
432 then txt;
433
434 case ( txt,
435 (i_numVariables as 8) )
436 algorithm
437 ✗ txt := Tpl.writeStr(txt, intString(i_numVariables));
438 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
439 then txt;
440
441 case ( txt,
442 (i_numVariables as 9) )
443 algorithm
444 ✗ txt := Tpl.writeStr(txt, intString(i_numVariables));
445 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
446 then txt;
447
448 case ( txt,
449 i_numVariables )
450 algorithm
451 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
452 ✗ txt := Tpl.writeStr(txt, intString(i_numVariables));
453 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
454 then txt;
455 end match;
456 end metaHelperBoxStart;
457
458 protected function lm_54
459 input output Tpl.Text txt;
460 input list<SCode.Element> items;
461 algorithm
462 ✗ for lstElt_54 in items loop
463 txt := match lstElt_54
464 local
465 SCode.Ident i_name;
466
467 case SCode.COMPONENT(name = i_name)
468 algorithm
469 ✗ txt := Tpl.writeStr(txt, i_name);
470 ✗ txt := Tpl.nextIter(txt);
471 then txt;
472
473 case _
474 then txt;
475 end match;
476 end for;
477 end lm_54;
478
479 protected function lm_55
480 input output Tpl.Text txt;
481 input list<SCode.Element> items;
482 algorithm
483 ✗ for lstElt_55 in items loop
484 txt := match lstElt_55
485 local
486 SCode.Ident i_name;
487
488 case SCode.COMPONENT(name = i_name)
489 algorithm
490 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
491 ✗ txt := Tpl.writeStr(txt, i_name);
492 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
493 ✗ txt := Tpl.nextIter(txt);
494 then txt;
495
496 case _
497 then txt;
498 end match;
499 end for;
500 end lm_55;
501
502 protected function fun_56
503 input Tpl.Text in_txt;
504 input String in_mArg;
505 input Tpl.Text in_a_fieldsStr;
506 input Tpl.Text in_a_nElts;
507 input Tpl.Text in_a_omcname;
508
509 output Tpl.Text out_txt;
510 algorithm
511 out_txt :=
512 match(in_txt, in_mArg, in_a_fieldsStr, in_a_nElts, in_a_omcname)
513 local
514 Tpl.Text txt;
515 Tpl.Text a_fieldsStr;
516 Tpl.Text a_nElts;
517 Tpl.Text a_omcname;
518
519 case ( txt,
520 "0",
521 _,
522 _,
523 a_omcname )
524 algorithm
525 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("ADD_METARECORD_DEFINITIONS const char* "));
526 ✗ txt := Tpl.writeText(txt, a_omcname);
527 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("__desc__fields[1] = {\"no fields\"};"));
528 then txt;
529
530 case ( txt,
531 _,
532 a_fieldsStr,
533 a_nElts,
534 a_omcname )
535 algorithm
536 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("ADD_METARECORD_DEFINITIONS const char* "));
537 ✗ txt := Tpl.writeText(txt, a_omcname);
538 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("__desc__fields["));
539 ✗ txt := Tpl.writeText(txt, a_nElts);
540 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("] = {"));
541 ✗ txt := Tpl.writeText(txt, a_fieldsStr);
542 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("};"));
543 then txt;
544 end match;
545 end fun_56;
546
547 protected function fun_57
548 input Tpl.Text in_txt;
549 input list<SCode.Element> in_a_p_elementLst;
550 input Tpl.Text in_a_fields;
551 input Tpl.Text in_a_omcname;
552 input Tpl.Text in_a_ctor;
553 input Tpl.Text in_a_fullname;
554
555 output Tpl.Text out_txt;
556 algorithm
557 out_txt :=
558 match(in_txt, in_a_p_elementLst, in_a_fields, in_a_omcname, in_a_ctor, in_a_fullname)
559 local
560 Tpl.Text txt;
561 Tpl.Text a_fields;
562 Tpl.Text a_omcname;
563 Tpl.Text a_ctor;
564 Tpl.Text a_fullname;
565 list<SCode.Element> i_p_elementLst;
566 Integer ret_1;
567 Integer ret_0;
568
569 case ( txt,
570 {},
571 _,
572 a_omcname,
573 a_ctor,
574 a_fullname )
575 algorithm
576 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("static const MMC_DEFSTRUCTLIT("));
577 ✗ txt := Tpl.writeText(txt, a_fullname);
578 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("__struct,1,"));
579 ✗ txt := Tpl.writeText(txt, a_ctor);
580 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(") {&"));
581 ✗ txt := Tpl.writeText(txt, a_omcname);
582 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
583 "__desc}};\n",
584 "static void *"
585 }, false));
586 ✗ txt := Tpl.writeText(txt, a_fullname);
587 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = MMC_REFSTRUCTLIT("));
588 ✗ txt := Tpl.writeText(txt, a_fullname);
589 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("__struct);"));
590 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
591 then txt;
592
593 case ( txt,
594 i_p_elementLst,
595 a_fields,
596 a_omcname,
597 a_ctor,
598 a_fullname )
599 algorithm
600 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("#define "));
601 ✗ txt := Tpl.writeText(txt, a_fullname);
602 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
603 ✗ txt := Tpl.writeText(txt, a_fields);
604 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(") (mmc_mk_box"));
605 ✗ ret_0 := listLength(i_p_elementLst);
606 ✗ ret_1 := intAdd(1, ret_0);
607 ✗ txt := metaHelperBoxStart(txt, ret_1);
608 ✗ txt := Tpl.writeText(txt, a_ctor);
609 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(",&"));
610 ✗ txt := Tpl.writeText(txt, a_omcname);
611 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("__desc,"));
612 ✗ txt := Tpl.writeText(txt, a_fields);
613 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("))"));
614 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
615 then txt;
616 end match;
617 end fun_57;
618
619 public function elementExternalHeader
620 input Tpl.Text in_txt;
621 input SCode.Element in_a_elt;
622 input String in_a_pack;
623
624 output Tpl.Text out_txt;
625 algorithm
626 out_txt :=
627 match(in_txt, in_a_elt, in_a_pack)
628 local
629 Tpl.Text txt;
630 String a_pack;
631 SCode.Element i_elt;
632 Integer i_r_index;
633 SCode.Ident i_c_name;
634 Absyn.Path i_r_name;
635 list<SCode.Element> i_p_elementLst;
636 String str_11;
637 Tpl.Text l_fieldsDescription;
638 Integer ret_9;
639 Tpl.Text l_ctor;
640 String ret_7;
641 Tpl.Text l_fullname;
642 Integer ret_5;
643 Tpl.Text l_nElts;
644 String ret_3;
645 Tpl.Text l_omcname;
646 Tpl.Text l_fieldsStr;
647 Tpl.Text l_fields;
648
649 case ( txt,
650 SCode.CLASS(restriction = SCode.R_METARECORD(moved = true, name = i_r_name, index = i_r_index), classDef = SCode.PARTS(elementLst = i_p_elementLst), name = i_c_name),
651 a_pack )
652 algorithm
653 ✗ l_fields := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(",")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
654 ✗ l_fields := lm_54(l_fields, i_p_elementLst);
655 ✗ l_fields := Tpl.popIter(l_fields);
656 ✗ l_fieldsStr := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(",")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
657 ✗ l_fieldsStr := lm_55(l_fieldsStr, i_p_elementLst);
658 ✗ l_fieldsStr := Tpl.popIter(l_fieldsStr);
659 ✗ l_omcname := Tpl.writeStr(Tpl.emptyTxt, a_pack);
660 ✗ l_omcname := Tpl.writeTok(l_omcname, Tpl.ST_STRING("_"));
661 ✗ l_omcname := pathString(l_omcname, i_r_name);
662 ✗ l_omcname := Tpl.writeTok(l_omcname, Tpl.ST_STRING("_"));
663 ✗ ret_3 := System.stringReplace(i_c_name, "_", "__");
664 ✗ l_omcname := Tpl.writeStr(l_omcname, ret_3);
665 ✗ ret_5 := listLength(i_p_elementLst);
666 ✗ l_nElts := Tpl.writeStr(Tpl.emptyTxt, intString(ret_5));
667 ✗ l_fullname := Tpl.writeStr(Tpl.emptyTxt, a_pack);
668 ✗ l_fullname := Tpl.writeTok(l_fullname, Tpl.ST_STRING("__"));
669 ✗ ret_7 := System.stringReplace(i_c_name, "_", "_5f");
670 ✗ l_fullname := Tpl.writeStr(l_fullname, ret_7);
671 ✗ ret_9 := intAdd(3, i_r_index);
672 ✗ l_ctor := Tpl.writeStr(Tpl.emptyTxt, intString(ret_9));
673 ✗ str_11 := Tpl.textString(l_nElts);
674 ✗ l_fieldsDescription := fun_56(Tpl.emptyTxt, str_11, l_fieldsStr, l_nElts, l_omcname);
675 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
676 "#ifdef ADD_METARECORD_DEFINITIONS\n",
677 "#ifndef "
678 }, false));
679 ✗ txt := Tpl.writeText(txt, l_omcname);
680 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
681 "__desc_added\n",
682 "#define "
683 }, false));
684 ✗ txt := Tpl.writeText(txt, l_omcname);
685 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("__desc_added\n"));
686 ✗ txt := Tpl.writeText(txt, l_fieldsDescription);
687 ✗ txt := Tpl.softNewLine(txt);
688 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("ADD_METARECORD_DEFINITIONS struct record_description "));
689 ✗ txt := Tpl.writeText(txt, l_omcname);
690 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("__desc = {\n"));
691 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
692 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("\""));
693 ✗ txt := Tpl.writeText(txt, l_omcname);
694 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
695 "\",\n",
696 "\""
697 }, false));
698 ✗ txt := Tpl.writeStr(txt, a_pack);
699 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("."));
700 ✗ txt := pathString(txt, i_r_name);
701 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("."));
702 ✗ txt := Tpl.writeStr(txt, i_c_name);
703 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("\",\n"));
704 ✗ txt := Tpl.writeText(txt, l_omcname);
705 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("__desc__fields\n"));
706 ✗ txt := Tpl.popBlock(txt);
707 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
708 "};\n",
709 "#endif\n",
710 "#else /* Only use the file as a header */\n",
711 "extern struct record_description "
712 }, false));
713 ✗ txt := Tpl.writeText(txt, l_omcname);
714 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
715 "__desc;\n",
716 "#endif\n",
717 "#define "
718 }, false));
719 ✗ txt := Tpl.writeText(txt, l_fullname);
720 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("_3dBOX"));
721 ✗ txt := Tpl.writeText(txt, l_nElts);
722 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" "));
723 ✗ txt := Tpl.writeText(txt, l_ctor);
724 ✗ txt := Tpl.softNewLine(txt);
725 ✗ txt := fun_57(txt, i_p_elementLst, l_fields, l_omcname, l_ctor, l_fullname);
726 then txt;
727
728 case ( txt,
729 (i_elt as SCode.CLASS(name = _)),
730 a_pack )
731 algorithm
732 ✗ txt := classExternalHeader(txt, i_elt, a_pack);
733 then txt;
734
735 case ( txt,
736 _,
737 _ )
738 then txt;
739 end match;
740 end elementExternalHeader;
741
742 protected function lm_59
743 input output Tpl.Text txt;
744 input SCode.Program items;
745 input output Tpl.Text a_buf2;
746 input output Tpl.Text a_buf1;
747 algorithm
748 ✗ for lstElt_59 in items loop
749 (txt, a_buf2, a_buf1) := match lstElt_59
750 local
751 SCode.Element i_cl;
752
753 case i_cl
754 algorithm
755 ✗ (txt, a_buf1, a_buf2) := classExternalHeaderJulia(txt, a_buf1, a_buf2, i_cl, "");
756 then (txt, a_buf2, a_buf1);
757 end match;
758 end for;
759 end lm_59;
760
761 public function programExternalHeaderJulia
762 input Tpl.Text txt;
763 input SCode.Program a_program;
764
765 output Tpl.Text out_txt;
766 protected
767 Tpl.Text l_res;
768 Tpl.Text l_buf2;
769 Tpl.Text l_buf1;
770 algorithm
771 ✗ l_buf1 := Tpl.emptyTxt;
772 ✗ l_buf2 := Tpl.emptyTxt;
773 ✗ (l_res, l_buf2, l_buf1) := lm_59(Tpl.emptyTxt, a_program, l_buf2, l_buf1);
774 ✗ out_txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
775 "/* Automatically generated header for external MetaModelica functions */\n",
776 "#include <julia.h>\n",
777 "#include <assert.h>\n",
778 "#ifdef __cplusplus\n",
779 "extern \"C\" {\n",
780 "#endif\n",
781 "#ifdef ADD_METARECORD_DEFINITIONS\n"
782 }, true));
783 ✗ out_txt := Tpl.writeText(out_txt, l_buf1);
784 ✗ out_txt := Tpl.softNewLine(out_txt);
785 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({
786 "void OpenModelica_initAbsynReferences()\n",
787 "{\n",
788 " /* Note: These values may be garbage collected away? Call this before each file is parsed? */\n"
789 }, true));
790 ✗ out_txt := Tpl.pushBlock(out_txt, Tpl.BT_INDENT(2));
791 ✗ out_txt := Tpl.writeText(out_txt, l_buf2);
792 ✗ out_txt := Tpl.softNewLine(out_txt);
793 ✗ out_txt := Tpl.popBlock(out_txt);
794 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({
795 "}\n",
796 "#else\n",
797 "void OpenModelica_initAbsynReferences();\n",
798 "#endif\n"
799 }, true));
800 ✗ out_txt := Tpl.writeText(out_txt, l_res);
801 ✗ out_txt := Tpl.softNewLine(out_txt);
802 ✗ out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING_LIST({
803 "#ifdef __cplusplus\n",
804 "}\n",
805 "#endif\n",
806 "\n"
807 }, true));
808 end programExternalHeaderJulia;
809
810 protected function fun_61
811 input Tpl.Text in_txt;
812 input SCode.Element in_a_cl;
813 input Tpl.Text in_a_buf1;
814 input Tpl.Text in_a_buf2;
815 input String in_a_pack;
816
817 output Tpl.Text out_txt;
818 output Tpl.Text out_a_buf1;
819 output Tpl.Text out_a_buf2;
820 algorithm
821 (out_txt, out_a_buf1, out_a_buf2) :=
822 match(in_txt, in_a_cl, in_a_buf1, in_a_buf2, in_a_pack)
823 local
824 Tpl.Text txt;
825 Tpl.Text a_buf1;
826 Tpl.Text a_buf2;
827 String a_pack;
828 SCode.Element i_c;
829 SCode.Ident i_c_name;
830
831 case ( txt,
832 (i_c as SCode.CLASS(name = i_c_name)),
833 a_buf1,
834 a_buf2,
835 a_pack )
836 algorithm
837 ✗ a_buf2 := Tpl.writeTok(a_buf2, Tpl.ST_STRING("jl_eval_string(\"using "));
838 ✗ a_buf2 := Tpl.writeStr(a_buf2, i_c_name);
839 ✗ a_buf2 := Tpl.writeTok(a_buf2, Tpl.ST_STRING_LIST({
840 "\");\n",
841 "jl_module_t* "
842 }, false));
843 ✗ a_buf2 := Tpl.writeStr(a_buf2, i_c_name);
844 ✗ a_buf2 := Tpl.writeTok(a_buf2, Tpl.ST_STRING(" = (jl_module_t *) jl_eval_string(\""));
845 ✗ a_buf2 := Tpl.writeStr(a_buf2, i_c_name);
846 ✗ a_buf2 := Tpl.writeTok(a_buf2, Tpl.ST_STRING_LIST({
847 "\");\n",
848 "if (!"
849 }, false));
850 ✗ a_buf2 := Tpl.writeStr(a_buf2, i_c_name);
851 ✗ a_buf2 := Tpl.writeTok(a_buf2, Tpl.ST_STRING_LIST({
852 ")\n",
853 "{\n"
854 }, true));
855 ✗ a_buf2 := Tpl.pushBlock(a_buf2, Tpl.BT_INDENT(2));
856 ✗ a_buf2 := Tpl.writeTok(a_buf2, Tpl.ST_STRING("fprintf(stderr, \"module "));
857 ✗ a_buf2 := Tpl.writeStr(a_buf2, i_c_name);
858 ✗ a_buf2 := Tpl.writeTok(a_buf2, Tpl.ST_STRING_LIST({
859 " not loaded, load it via using.\");\n",
860 "fflush(NULL);\n"
861 }, true));
862 ✗ a_buf2 := Tpl.popBlock(a_buf2);
863 ✗ a_buf2 := Tpl.writeTok(a_buf2, Tpl.ST_STRING_LIST({
864 "}\n",
865 "assert(jl_is_module("
866 }, false));
867 ✗ a_buf2 := Tpl.writeStr(a_buf2, i_c_name);
868 ✗ a_buf2 := Tpl.writeTok(a_buf2, Tpl.ST_STRING("));"));
869 ✗ a_buf2 := Tpl.writeTok(a_buf2, Tpl.ST_NEW_LINE());
870 ✗ (txt, a_buf1, a_buf2) := classExternalHeaderJuliaWork(txt, a_buf1, a_buf2, i_c, a_pack);
871 then (txt, a_buf1, a_buf2);
872
873 case ( txt,
874 _,
875 a_buf1,
876 a_buf2,
877 _ )
878 ✗ then (txt, a_buf1, a_buf2);
879 end match;
880 end fun_61;
881
882 public function classExternalHeaderJulia
883 input Tpl.Text txt;
884 input Tpl.Text a_buf1;
885 input Tpl.Text a_buf2;
886 input SCode.Element a_cl;
887 input String a_pack;
888
889 output Tpl.Text out_txt;
890 output Tpl.Text out_a_buf1;
891 output Tpl.Text out_a_buf2;
892 algorithm
893 ✗ (out_txt, out_a_buf1, out_a_buf2) := fun_61(txt, a_cl, a_buf1, a_buf2, a_pack);
894 end classExternalHeaderJulia;
895
896 protected function lm_63
897 input output Tpl.Text txt;
898 input list<SCode.Element> items;
899 input SCode.Ident a_c_name;
900 input output Tpl.Text a_buf2;
901 input output Tpl.Text a_buf1;
902 algorithm
903 ✗ for lstElt_63 in items loop
904 (txt, a_buf2, a_buf1) := match lstElt_63
905 local
906 SCode.Element i_elt;
907
908 case i_elt
909 algorithm
910 ✗ (txt, a_buf1, a_buf2) := elementExternalHeaderJulia(txt, a_buf1, a_buf2, i_elt, a_c_name);
911 then (txt, a_buf2, a_buf1);
912 end match;
913 end for;
914 end lm_63;
915
916 protected function fun_64
917 input Tpl.Text in_txt;
918 input SCode.Element in_a_cl;
919 input Tpl.Text in_a_buf1;
920 input Tpl.Text in_a_buf2;
921
922 output Tpl.Text out_txt;
923 output Tpl.Text out_a_buf1;
924 output Tpl.Text out_a_buf2;
925 algorithm
926 (out_txt, out_a_buf1, out_a_buf2) :=
927 match(in_txt, in_a_cl, in_a_buf1, in_a_buf2)
928 local
929 Tpl.Text txt;
930 Tpl.Text a_buf1;
931 Tpl.Text a_buf2;
932 SCode.Ident i_c_name;
933 list<SCode.Element> i_p_elementLst;
934
935 case ( txt,
936 SCode.CLASS(classDef = SCode.PARTS(elementLst = i_p_elementLst), name = i_c_name),
937 a_buf1,
938 a_buf2 )
939 algorithm
940 ✗ (txt, a_buf2, a_buf1) := lm_63(txt, i_p_elementLst, i_c_name, a_buf2, a_buf1);
941 ✗ then (txt, a_buf1, a_buf2);
942
943 case ( txt,
944 _,
945 a_buf1,
946 a_buf2 )
947 then (txt, a_buf1, a_buf2);
948 end match;
949 end fun_64;
950
951 public function classExternalHeaderJuliaWork
952 input Tpl.Text txt;
953 input Tpl.Text a_buf1;
954 input Tpl.Text a_buf2;
955 input SCode.Element a_cl;
956 input String a_pack;
957
958 output Tpl.Text out_txt;
959 output Tpl.Text out_a_buf1;
960 output Tpl.Text out_a_buf2;
961 algorithm
962 ✗ (out_txt, out_a_buf1, out_a_buf2) := fun_64(txt, a_cl, a_buf1, a_buf2);
963 end classExternalHeaderJuliaWork;
964
965 protected function lm_66
966 input output Tpl.Text txt;
967 input list<SCode.Element> items;
968 algorithm
969 ✗ for lstElt_66 in items loop
970 txt := match lstElt_66
971 local
972 SCode.Ident i_name;
973
974 case SCode.COMPONENT(name = i_name)
975 algorithm
976 ✗ txt := Tpl.writeStr(txt, i_name);
977 ✗ txt := Tpl.nextIter(txt);
978 then txt;
979
980 case _
981 then txt;
982 end match;
983 end for;
984 end lm_66;
985
986 protected function lm_67
987 input output Tpl.Text txt;
988 input list<SCode.Element> items;
989 algorithm
990 ✗ for lstElt_67 in items loop
991 txt := match lstElt_67
992 local
993 SCode.Ident i_name;
994
995 case SCode.COMPONENT(name = i_name)
996 algorithm
997 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(", "));
998 ✗ txt := Tpl.writeStr(txt, i_name);
999 then txt;
1000
1001 case _
1002 then txt;
1003 end match;
1004 end for;
1005 end lm_67;
1006
1007 protected function lm_68
1008 input output Tpl.Text txt;
1009 input list<SCode.Element> items;
1010 algorithm
1011 ✗ for lstElt_68 in items loop
1012 txt := match lstElt_68
1013 local
1014 SCode.Ident i_name;
1015
1016 case SCode.COMPONENT(name = i_name)
1017 algorithm
1018 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("jl_value_t *"));
1019 ✗ txt := Tpl.writeStr(txt, i_name);
1020 ✗ txt := Tpl.nextIter(txt);
1021 then txt;
1022
1023 case _
1024 then txt;
1025 end match;
1026 end for;
1027 end lm_68;
1028
1029 protected function fun_69
1030 input Tpl.Text in_txt;
1031 input Integer in_mArg;
1032 input Tpl.Text in_a_fields1;
1033 input Tpl.Text in_a_fields2;
1034 input list<SCode.Element> in_a_p_elementLst;
1035 input Tpl.Text in_a_fieldsWithType;
1036 input Tpl.Text in_a_omcname;
1037 input Tpl.Text in_a_fullname;
1038
1039 output Tpl.Text out_txt;
1040 algorithm
1041 out_txt :=
1042 match(in_txt, in_mArg, in_a_fields1, in_a_fields2, in_a_p_elementLst, in_a_fieldsWithType, in_a_omcname, in_a_fullname)
1043 local
1044 Tpl.Text txt;
1045 Tpl.Text a_fields1;
1046 Tpl.Text a_fields2;
1047 list<SCode.Element> a_p_elementLst;
1048 Tpl.Text a_fieldsWithType;
1049 Tpl.Text a_omcname;
1050 Tpl.Text a_fullname;
1051 Integer ret_4;
1052 Integer ret_3;
1053 Integer ret_2;
1054 Integer ret_1;
1055 Integer ret_0;
1056
1057 case ( txt,
1058 0,
1059 _,
1060 _,
1061 _,
1062 _,
1063 a_omcname,
1064 a_fullname )
1065 algorithm
1066 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("#define "));
1067 ✗ txt := Tpl.writeText(txt, a_fullname);
1068 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(" jl_call0("));
1069 ✗ txt := Tpl.writeText(txt, a_omcname);
1070 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(")"));
1071 then txt;
1072
1073 case ( txt,
1074 1,
1075 _,
1076 a_fields2,
1077 a_p_elementLst,
1078 a_fieldsWithType,
1079 a_omcname,
1080 a_fullname )
1081 algorithm
1082 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("static inline jl_value_t* "));
1083 ✗ txt := Tpl.writeText(txt, a_fullname);
1084 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
1085 ✗ txt := Tpl.writeText(txt, a_fieldsWithType);
1086 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(") {\n"));
1087 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
1088 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("return jl_call"));
1089 ✗ ret_0 := listLength(a_p_elementLst);
1090 ✗ txt := Tpl.writeStr(txt, intString(ret_0));
1091 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
1092 ✗ txt := Tpl.writeText(txt, a_omcname);
1093 ✗ txt := Tpl.writeText(txt, a_fields2);
1094 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(");\n"));
1095 ✗ txt := Tpl.popBlock(txt);
1096 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("}"));
1097 then txt;
1098
1099 case ( txt,
1100 2,
1101 _,
1102 a_fields2,
1103 a_p_elementLst,
1104 a_fieldsWithType,
1105 a_omcname,
1106 a_fullname )
1107 algorithm
1108 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("static inline jl_value_t* "));
1109 ✗ txt := Tpl.writeText(txt, a_fullname);
1110 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
1111 ✗ txt := Tpl.writeText(txt, a_fieldsWithType);
1112 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(") {\n"));
1113 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
1114 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("return jl_call"));
1115 ✗ ret_1 := listLength(a_p_elementLst);
1116 ✗ txt := Tpl.writeStr(txt, intString(ret_1));
1117 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
1118 ✗ txt := Tpl.writeText(txt, a_omcname);
1119 ✗ txt := Tpl.writeText(txt, a_fields2);
1120 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(");\n"));
1121 ✗ txt := Tpl.popBlock(txt);
1122 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("}"));
1123 then txt;
1124
1125 case ( txt,
1126 3,
1127 _,
1128 a_fields2,
1129 a_p_elementLst,
1130 a_fieldsWithType,
1131 a_omcname,
1132 a_fullname )
1133 algorithm
1134 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("static inline jl_value_t* "));
1135 ✗ txt := Tpl.writeText(txt, a_fullname);
1136 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
1137 ✗ txt := Tpl.writeText(txt, a_fieldsWithType);
1138 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(") {\n"));
1139 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
1140 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("return jl_call"));
1141 ✗ ret_2 := listLength(a_p_elementLst);
1142 ✗ txt := Tpl.writeStr(txt, intString(ret_2));
1143 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
1144 ✗ txt := Tpl.writeText(txt, a_omcname);
1145 ✗ txt := Tpl.writeText(txt, a_fields2);
1146 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(");\n"));
1147 ✗ txt := Tpl.popBlock(txt);
1148 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("}"));
1149 then txt;
1150
1151 case ( txt,
1152 _,
1153 a_fields1,
1154 _,
1155 a_p_elementLst,
1156 a_fieldsWithType,
1157 a_omcname,
1158 a_fullname )
1159 algorithm
1160 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("static inline jl_value_t* "));
1161 ✗ txt := Tpl.writeText(txt, a_fullname);
1162 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("("));
1163 ✗ txt := Tpl.writeText(txt, a_fieldsWithType);
1164 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(") {\n"));
1165 ✗ txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2));
1166 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("jl_value_t *values["));
1167 ✗ ret_3 := listLength(a_p_elementLst);
1168 ✗ txt := Tpl.writeStr(txt, intString(ret_3));
1169 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("] = {"));
1170 ✗ txt := Tpl.writeText(txt, a_fields1);
1171 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1172 "};\n",
1173 "return jl_call("
1174 }, false));
1175 ✗ txt := Tpl.writeText(txt, a_omcname);
1176 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(", values, "));
1177 ✗ ret_4 := listLength(a_p_elementLst);
1178 ✗ txt := Tpl.writeStr(txt, intString(ret_4));
1179 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE(");\n"));
1180 ✗ txt := Tpl.popBlock(txt);
1181 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("}"));
1182 then txt;
1183 end match;
1184 end fun_69;
1185
1186 protected function fun_70
1187 input Tpl.Text in_txt;
1188 input SCode.Element in_a_elt;
1189 input Tpl.Text in_a_buf1;
1190 input Tpl.Text in_a_buf2;
1191 input String in_a_pack;
1192
1193 output Tpl.Text out_txt;
1194 output Tpl.Text out_a_buf1;
1195 output Tpl.Text out_a_buf2;
1196 algorithm
1197 (out_txt, out_a_buf1, out_a_buf2) :=
1198 match(in_txt, in_a_elt, in_a_buf1, in_a_buf2, in_a_pack)
1199 local
1200 Tpl.Text txt;
1201 Tpl.Text a_buf1;
1202 Tpl.Text a_buf2;
1203 String a_pack;
1204 SCode.Element i_elt;
1205 Absyn.Path i_r_name;
1206 list<SCode.Element> i_p_elementLst;
1207 SCode.Ident i_c_name;
1208 Integer ret_8;
1209 String ret_7;
1210 Tpl.Text l_fullname;
1211 String ret_5;
1212 Tpl.Text l_funcName;
1213 Tpl.Text l_fieldsWithType;
1214 Tpl.Text l_fields2;
1215 Tpl.Text l_fields1;
1216 Tpl.Text l_omcname;
1217
1218 case ( txt,
1219 SCode.CLASS(restriction = SCode.R_UNIONTYPE(), classDef = SCode.PARTS(elementLst = _), name = i_c_name),
1220 a_buf1,
1221 a_buf2,
1222 a_pack )
1223 algorithm
1224 ✗ l_omcname := Tpl.writeStr(Tpl.emptyTxt, a_pack);
1225 ✗ l_omcname := Tpl.writeTok(l_omcname, Tpl.ST_STRING("_"));
1226 ✗ l_omcname := Tpl.writeStr(l_omcname, i_c_name);
1227 ✗ a_buf1 := Tpl.writeTok(a_buf1, Tpl.ST_STRING("jl_value_t *"));
1228 ✗ a_buf1 := Tpl.writeText(a_buf1, l_omcname);
1229 ✗ a_buf1 := Tpl.writeTok(a_buf1, Tpl.ST_LINE(" = NULL;\n"));
1230 ✗ a_buf1 := Tpl.writeTok(a_buf1, Tpl.ST_NEW_LINE());
1231 ✗ a_buf2 := Tpl.writeTok(a_buf2, Tpl.ST_STRING("assert(("));
1232 ✗ a_buf2 := Tpl.writeText(a_buf2, l_omcname);
1233 ✗ a_buf2 := Tpl.writeTok(a_buf2, Tpl.ST_STRING(" = jl_get_global("));
1234 ✗ a_buf2 := Tpl.writeStr(a_buf2, a_pack);
1235 ✗ a_buf2 := Tpl.writeTok(a_buf2, Tpl.ST_STRING(", jl_symbol(\""));
1236 ✗ a_buf2 := Tpl.writeStr(a_buf2, i_c_name);
1237 ✗ a_buf2 := Tpl.writeTok(a_buf2, Tpl.ST_STRING("\"))));"));
1238 ✗ a_buf2 := Tpl.writeTok(a_buf2, Tpl.ST_NEW_LINE());
1239 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("extern jl_value_t *"));
1240 ✗ txt := Tpl.writeText(txt, l_omcname);
1241 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING(";"));
1242 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
1243 ✗ then (txt, a_buf1, a_buf2);
1244
1245 case ( txt,
1246 SCode.CLASS(restriction = SCode.R_METARECORD(moved = true, name = i_r_name), classDef = SCode.PARTS(elementLst = i_p_elementLst), name = i_c_name),
1247 a_buf1,
1248 a_buf2,
1249 a_pack )
1250 algorithm
1251 ✗ l_fields1 := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(",")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1252 ✗ l_fields1 := lm_66(l_fields1, i_p_elementLst);
1253 ✗ l_fields1 := Tpl.popIter(l_fields1);
1254 ✗ l_fields2 := lm_67(Tpl.emptyTxt, i_p_elementLst);
1255 ✗ l_fieldsWithType := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(",")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE()));
1256 ✗ l_fieldsWithType := lm_68(l_fieldsWithType, i_p_elementLst);
1257 ✗ l_fieldsWithType := Tpl.popIter(l_fieldsWithType);
1258 ✗ l_funcName := Tpl.writeStr(Tpl.emptyTxt, a_pack);
1259 ✗ l_funcName := Tpl.writeTok(l_funcName, Tpl.ST_STRING("."));
1260 ✗ l_funcName := pathString(l_funcName, i_r_name);
1261 ✗ l_omcname := Tpl.writeStr(Tpl.emptyTxt, a_pack);
1262 ✗ l_omcname := Tpl.writeTok(l_omcname, Tpl.ST_STRING("_"));
1263 ✗ l_omcname := pathString(l_omcname, i_r_name);
1264 ✗ l_omcname := Tpl.writeTok(l_omcname, Tpl.ST_STRING("_"));
1265 ✗ ret_5 := System.stringReplace(i_c_name, "_", "__");
1266 ✗ l_omcname := Tpl.writeStr(l_omcname, ret_5);
1267 ✗ l_fullname := Tpl.writeStr(Tpl.emptyTxt, a_pack);
1268 ✗ l_fullname := Tpl.writeTok(l_fullname, Tpl.ST_STRING("__"));
1269 ✗ ret_7 := System.stringReplace(i_c_name, "_", "_5f");
1270 ✗ l_fullname := Tpl.writeStr(l_fullname, ret_7);
1271 ✗ a_buf1 := Tpl.writeTok(a_buf1, Tpl.ST_STRING("jl_function_t *"));
1272 ✗ a_buf1 := Tpl.writeText(a_buf1, l_omcname);
1273 ✗ a_buf1 := Tpl.writeTok(a_buf1, Tpl.ST_STRING_LIST({
1274 " = NULL;\n",
1275 "jl_value_t *"
1276 }, false));
1277 ✗ a_buf1 := Tpl.writeText(a_buf1, l_omcname);
1278 ✗ a_buf1 := Tpl.writeTok(a_buf1, Tpl.ST_LINE("_type = NULL;\n"));
1279 ✗ a_buf1 := Tpl.writeTok(a_buf1, Tpl.ST_NEW_LINE());
1280 ✗ a_buf2 := Tpl.writeTok(a_buf2, Tpl.ST_STRING("assert(("));
1281 ✗ a_buf2 := Tpl.writeText(a_buf2, l_omcname);
1282 ✗ a_buf2 := Tpl.writeTok(a_buf2, Tpl.ST_STRING(" = jl_get_function("));
1283 ✗ a_buf2 := Tpl.writeStr(a_buf2, a_pack);
1284 ✗ a_buf2 := Tpl.writeTok(a_buf2, Tpl.ST_STRING(", \""));
1285 ✗ a_buf2 := Tpl.writeStr(a_buf2, i_c_name);
1286 ✗ a_buf2 := Tpl.writeTok(a_buf2, Tpl.ST_STRING_LIST({
1287 "\")));\n",
1288 "assert(("
1289 }, false));
1290 ✗ a_buf2 := Tpl.writeText(a_buf2, l_omcname);
1291 ✗ a_buf2 := Tpl.writeTok(a_buf2, Tpl.ST_STRING("_type = jl_get_global("));
1292 ✗ a_buf2 := Tpl.writeStr(a_buf2, a_pack);
1293 ✗ a_buf2 := Tpl.writeTok(a_buf2, Tpl.ST_STRING(", jl_symbol(\""));
1294 ✗ a_buf2 := Tpl.writeStr(a_buf2, i_c_name);
1295 ✗ a_buf2 := Tpl.writeTok(a_buf2, Tpl.ST_STRING("\"))));"));
1296 ✗ a_buf2 := Tpl.writeTok(a_buf2, Tpl.ST_NEW_LINE());
1297 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING("extern jl_function_t *"));
1298 ✗ txt := Tpl.writeText(txt, l_omcname);
1299 ✗ txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({
1300 ";\n",
1301 "extern jl_function_t *"
1302 }, false));
1303 ✗ txt := Tpl.writeText(txt, l_omcname);
1304 ✗ txt := Tpl.writeTok(txt, Tpl.ST_LINE("_type;\n"));
1305 ✗ ret_8 := listLength(i_p_elementLst);
1306 ✗ txt := fun_69(txt, ret_8, l_fields1, l_fields2, i_p_elementLst, l_fieldsWithType, l_omcname, l_fullname);
1307 ✗ txt := Tpl.softNewLine(txt);
1308 ✗ txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE());
1309 ✗ then (txt, a_buf1, a_buf2);
1310
1311 case ( txt,
1312 (i_elt as SCode.CLASS(name = _)),
1313 a_buf1,
1314 a_buf2,
1315 a_pack )
1316 algorithm
1317 ✗ (txt, a_buf1, a_buf2) := classExternalHeaderJuliaWork(txt, a_buf1, a_buf2, i_elt, a_pack);
1318 then (txt, a_buf1, a_buf2);
1319
1320 case ( txt,
1321 _,
1322 a_buf1,
1323 a_buf2,
1324 _ )
1325 ✗ then (txt, a_buf1, a_buf2);
1326 end match;
1327 end fun_70;
1328
1329 public function elementExternalHeaderJulia
1330 input Tpl.Text txt;
1331 input Tpl.Text a_buf1;
1332 input Tpl.Text a_buf2;
1333 input SCode.Element a_elt;
1334 input String a_pack;
1335
1336 output Tpl.Text out_txt;
1337 output Tpl.Text out_a_buf1;
1338 output Tpl.Text out_a_buf2;
1339 algorithm
1340 ✗ (out_txt, out_a_buf1, out_a_buf2) := fun_70(txt, a_elt, a_buf1, a_buf2, a_pack);
1341 end elementExternalHeaderJulia;
1342
1343 annotation(__OpenModelica_Interface="backend_tools");
1344 end Unparsing;
1345