build_cmake/OMCompiler/Compiler/generated-mo/Template/CodegenMidToC.mo
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | encapsulated package CodegenMidToC | ||
| 2 | " | ||
| 3 | file: CodegenMidToC.mo | ||
| 4 | package: CodegenMidToC | ||
| 5 | description: Generated by Susan. | ||
| 6 | " | ||
| 7 | |||
| 8 | public import Tpl; | ||
| 9 | |||
| 10 | public import MidCode; | ||
| 11 | public import SimCodeVar; | ||
| 12 | public import HashTableCrefSimVar; | ||
| 13 | public import SimCode; | ||
| 14 | public import SimCodeFunction; | ||
| 15 | public import SimCodeCodegenUtil; | ||
| 16 | public import SimCodeFunctionUtil; | ||
| 17 | public import BackendDAE; | ||
| 18 | public import System; | ||
| 19 | public import Autoconf; | ||
| 20 | protected import Absyn; | ||
| 21 | protected import AbsynUtil; | ||
| 22 | public import MMath; | ||
| 23 | public import DAE; | ||
| 24 | public import ClassInf; | ||
| 25 | public import ClassInfUtil; | ||
| 26 | protected import SCode; | ||
| 27 | protected import SCodeDump; | ||
| 28 | public import StringUtil; | ||
| 29 | public import Util; | ||
| 30 | public import List; | ||
| 31 | public import ComponentReferenceBasics; | ||
| 32 | public import ComponentReference; | ||
| 33 | public import Expression; | ||
| 34 | protected import ExpressionDump; | ||
| 35 | public import ExpressionBasics; | ||
| 36 | public import Config; | ||
| 37 | public import Testsuite; | ||
| 38 | public import Flags; | ||
| 39 | public import FlagsUtil; | ||
| 40 | public import Settings; | ||
| 41 | public import Patternm; | ||
| 42 | public import Error; | ||
| 43 | public import Values; | ||
| 44 | public import ValuesUtil; | ||
| 45 | public import DAEDump; | ||
| 46 | public import Algorithm; | ||
| 47 | protected import ElementSource; | ||
| 48 | public import DAEUtil; | ||
| 49 | public import TypesDump; | ||
| 50 | public import Types; | ||
| 51 | public import HashTableCrIListArray; | ||
| 52 | |||
| 53 | protected function lm_44 | ||
| 54 | input output Tpl.Text txt; | ||
| 55 | input list<MidCode.Function> items; | ||
| 56 | algorithm | ||
| 57 | ✗ | for lstElt_44 in items loop | |
| 58 | txt := match lstElt_44 | ||
| 59 | local | ||
| 60 | MidCode.Function i_fn; | ||
| 61 | |||
| 62 | case i_fn | ||
| 63 | algorithm | ||
| 64 | ✗ | txt := genFunction(txt, i_fn); | |
| 65 | ✗ | txt := Tpl.nextIter(txt); | |
| 66 | then txt; | ||
| 67 | end match; | ||
| 68 | end for; | ||
| 69 | end lm_44; | ||
| 70 | |||
| 71 | public function genProgram | ||
| 72 | input Tpl.Text in_txt; | ||
| 73 | input MidCode.Program in_a_p; | ||
| 74 | |||
| 75 | output Tpl.Text out_txt; | ||
| 76 | algorithm | ||
| 77 | out_txt := | ||
| 78 | match(in_txt, in_a_p) | ||
| 79 | local | ||
| 80 | Tpl.Text txt; | ||
| 81 | String i_name; | ||
| 82 | list<MidCode.Function> i_functions; | ||
| 83 | Integer ret_0; | ||
| 84 | |||
| 85 | case ( txt, | ||
| 86 | MidCode.PROGRAM(functions = i_functions, name = i_name) ) | ||
| 87 | algorithm | ||
| 88 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("// number of functions: ")); | |
| 89 | ✗ | ret_0 := listLength(i_functions); | |
| 90 | ✗ | txt := Tpl.writeStr(txt, intString(ret_0)); | |
| 91 | ✗ | txt := Tpl.softNewLine(txt); | |
| 92 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("#include \"")); | |
| 93 | ✗ | txt := Tpl.writeStr(txt, i_name); | |
| 94 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 95 | ".h\"\n", | ||
| 96 | "#include \"util/modelica.h\"\n", | ||
| 97 | "\n", | ||
| 98 | "#include \"" | ||
| 99 | }, false)); | ||
| 100 | ✗ | txt := Tpl.writeStr(txt, i_name); | |
| 101 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 102 | "_includes.h\"\n", | ||
| 103 | "\n" | ||
| 104 | }, true)); | ||
| 105 | ✗ | txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING_LIST({ | |
| 106 | "\n", | ||
| 107 | "\n" | ||
| 108 | }, true)), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | ||
| 109 | ✗ | txt := lm_44(txt, i_functions); | |
| 110 | ✗ | txt := Tpl.popIter(txt); | |
| 111 | then txt; | ||
| 112 | |||
| 113 | case ( txt, | ||
| 114 | _ ) | ||
| 115 | then txt; | ||
| 116 | end match; | ||
| 117 | end genProgram; | ||
| 118 | |||
| 119 | protected function fun_46 | ||
| 120 | input Tpl.Text in_txt; | ||
| 121 | input Boolean in_mArg; | ||
| 122 | input list<MidCode.Var> in_a_outputs; | ||
| 123 | |||
| 124 | output Tpl.Text out_txt; | ||
| 125 | algorithm | ||
| 126 | out_txt := | ||
| 127 | match(in_txt, in_mArg, in_a_outputs) | ||
| 128 | local | ||
| 129 | Tpl.Text txt; | ||
| 130 | list<MidCode.Var> a_outputs; | ||
| 131 | MidCode.Var ret_0; | ||
| 132 | |||
| 133 | case ( txt, | ||
| 134 | false, | ||
| 135 | a_outputs ) | ||
| 136 | algorithm | ||
| 137 | ✗ | ret_0 := listHead(a_outputs); | |
| 138 | ✗ | txt := genVarType(txt, ret_0); | |
| 139 | then txt; | ||
| 140 | |||
| 141 | case ( txt, | ||
| 142 | _, | ||
| 143 | _ ) | ||
| 144 | algorithm | ||
| 145 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("void")); | |
| 146 | then txt; | ||
| 147 | end match; | ||
| 148 | end fun_46; | ||
| 149 | |||
| 150 | protected function lm_47 | ||
| 151 | input output Tpl.Text txt; | ||
| 152 | input list<MidCode.Var> items; | ||
| 153 | algorithm | ||
| 154 | ✗ | for lstElt_47 in items loop | |
| 155 | txt := match lstElt_47 | ||
| 156 | local | ||
| 157 | MidCode.Var i_i; | ||
| 158 | |||
| 159 | case i_i | ||
| 160 | algorithm | ||
| 161 | ✗ | txt := genVarType(txt, i_i); | |
| 162 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" ")); | |
| 163 | ✗ | txt := genVarName(txt, i_i); | |
| 164 | ✗ | txt := Tpl.nextIter(txt); | |
| 165 | then txt; | ||
| 166 | end match; | ||
| 167 | end for; | ||
| 168 | end lm_47; | ||
| 169 | |||
| 170 | protected function lm_48 | ||
| 171 | input output Tpl.Text txt; | ||
| 172 | input list<MidCode.Var> items; | ||
| 173 | algorithm | ||
| 174 | ✗ | for lstElt_48 in items loop | |
| 175 | txt := match lstElt_48 | ||
| 176 | local | ||
| 177 | MidCode.Var i_o; | ||
| 178 | |||
| 179 | case i_o | ||
| 180 | algorithm | ||
| 181 | ✗ | txt := genVarType(txt, i_o); | |
| 182 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" *outPtr_")); | |
| 183 | ✗ | txt := genVarName(txt, i_o); | |
| 184 | ✗ | txt := Tpl.nextIter(txt); | |
| 185 | then txt; | ||
| 186 | end match; | ||
| 187 | end for; | ||
| 188 | end lm_48; | ||
| 189 | |||
| 190 | protected function smf_49 | ||
| 191 | input Tpl.Text in_txt; | ||
| 192 | input Tpl.StringToken in_it; | ||
| 193 | |||
| 194 | output Tpl.Text out_txt; | ||
| 195 | algorithm | ||
| 196 | out_txt := | ||
| 197 | match(in_txt, in_it) | ||
| 198 | local | ||
| 199 | Tpl.Text txt; | ||
| 200 | Tpl.StringToken i_it; | ||
| 201 | |||
| 202 | case ( txt, | ||
| 203 | i_it ) | ||
| 204 | algorithm | ||
| 205 | ✗ | txt := Tpl.writeTok(txt, i_it); | |
| 206 | ✗ | txt := Tpl.nextIter(txt); | |
| 207 | then txt; | ||
| 208 | end match; | ||
| 209 | end smf_49; | ||
| 210 | |||
| 211 | protected function smf_50 | ||
| 212 | input Tpl.Text in_txt; | ||
| 213 | input Tpl.Text in_it; | ||
| 214 | |||
| 215 | output Tpl.Text out_txt; | ||
| 216 | algorithm | ||
| 217 | out_txt := | ||
| 218 | match(in_txt, in_it) | ||
| 219 | local | ||
| 220 | Tpl.Text txt; | ||
| 221 | Tpl.Text i_it; | ||
| 222 | |||
| 223 | case ( txt, | ||
| 224 | i_it ) | ||
| 225 | algorithm | ||
| 226 | ✗ | txt := Tpl.writeText(txt, i_it); | |
| 227 | ✗ | txt := Tpl.nextIter(txt); | |
| 228 | then txt; | ||
| 229 | end match; | ||
| 230 | end smf_50; | ||
| 231 | |||
| 232 | protected function smf_51 | ||
| 233 | input Tpl.Text in_txt; | ||
| 234 | input Tpl.Text in_it; | ||
| 235 | |||
| 236 | output Tpl.Text out_txt; | ||
| 237 | algorithm | ||
| 238 | out_txt := | ||
| 239 | match(in_txt, in_it) | ||
| 240 | local | ||
| 241 | Tpl.Text txt; | ||
| 242 | Tpl.Text i_it; | ||
| 243 | |||
| 244 | case ( txt, | ||
| 245 | i_it ) | ||
| 246 | algorithm | ||
| 247 | ✗ | txt := Tpl.writeText(txt, i_it); | |
| 248 | ✗ | txt := Tpl.nextIter(txt); | |
| 249 | then txt; | ||
| 250 | end match; | ||
| 251 | end smf_51; | ||
| 252 | |||
| 253 | public function genFunction | ||
| 254 | input Tpl.Text in_txt; | ||
| 255 | input MidCode.Function in_a_fn; | ||
| 256 | |||
| 257 | output Tpl.Text out_txt; | ||
| 258 | algorithm | ||
| 259 | out_txt := | ||
| 260 | match(in_txt, in_a_fn) | ||
| 261 | local | ||
| 262 | Tpl.Text txt; | ||
| 263 | list<MidCode.Block> i_body; | ||
| 264 | list<MidCode.VarBufPtr> i_localBufPtrs; | ||
| 265 | list<MidCode.VarBuf> i_localBufs; | ||
| 266 | list<MidCode.Var> i_locals; | ||
| 267 | MidCode.Function i_fn; | ||
| 268 | Absyn.Path i_name; | ||
| 269 | list<MidCode.Var> i_inputs; | ||
| 270 | list<MidCode.Var> i_outputs; | ||
| 271 | Tpl.Text txt_4; | ||
| 272 | list<MidCode.Var> ret_4; | ||
| 273 | Tpl.Text txt_3; | ||
| 274 | Tpl.Text l_arguments; | ||
| 275 | Boolean ret_1; | ||
| 276 | Tpl.Text l_returnType; | ||
| 277 | |||
| 278 | case ( txt, | ||
| 279 | (i_fn as MidCode.FUNCTION(outputs = i_outputs, inputs = i_inputs, name = i_name, locals = i_locals, localBufs = i_localBufs, localBufPtrs = i_localBufPtrs, body = i_body)) ) | ||
| 280 | algorithm | ||
| 281 | ✗ | ret_1 := listEmpty(i_outputs); | |
| 282 | ✗ | l_returnType := fun_46(Tpl.emptyTxt, ret_1, i_outputs); | |
| 283 | ✗ | txt_3 := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 284 | ✗ | txt_3 := lm_47(txt_3, i_inputs); | |
| 285 | ✗ | txt_3 := Tpl.popIter(txt_3); | |
| 286 | ✗ | ret_4 := List.restOrEmpty(i_outputs); | |
| 287 | ✗ | txt_4 := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 288 | ✗ | txt_4 := lm_48(txt_4, ret_4); | |
| 289 | ✗ | txt_4 := Tpl.popIter(txt_4); | |
| 290 | ✗ | l_arguments := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING_LIST({ | |
| 291 | ",\n", | ||
| 292 | " " | ||
| 293 | }, false)), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | ||
| 294 | ✗ | l_arguments := smf_49(l_arguments, Tpl.ST_STRING("threadData_t *threadData")); | |
| 295 | ✗ | l_arguments := smf_50(l_arguments, txt_3); | |
| 296 | ✗ | l_arguments := smf_51(l_arguments, txt_4); | |
| 297 | ✗ | l_arguments := Tpl.popIter(l_arguments); | |
| 298 | ✗ | txt := Tpl.writeText(txt, l_returnType); | |
| 299 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" omc_")); | |
| 300 | ✗ | txt := underscorePath(txt, i_name); | |
| 301 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("(")); | |
| 302 | ✗ | txt := Tpl.writeText(txt, l_arguments); | |
| 303 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 304 | ")\n", | ||
| 305 | "{\n" | ||
| 306 | }, true)); | ||
| 307 | ✗ | txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(3)); | |
| 308 | ✗ | txt := genLocalDecls(txt, i_fn, i_locals, i_localBufs, i_localBufPtrs); | |
| 309 | ✗ | txt := Tpl.softNewLine(txt); | |
| 310 | ✗ | txt := genEntry(txt, i_fn); | |
| 311 | ✗ | txt := Tpl.softNewLine(txt); | |
| 312 | ✗ | txt := genBlocks(txt, i_fn, i_body); | |
| 313 | ✗ | txt := Tpl.softNewLine(txt); | |
| 314 | ✗ | txt := genExit(txt, i_fn); | |
| 315 | ✗ | txt := Tpl.softNewLine(txt); | |
| 316 | ✗ | txt := Tpl.popBlock(txt); | |
| 317 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 318 | "}\n", | ||
| 319 | "\n" | ||
| 320 | }, true)); | ||
| 321 | ✗ | txt := genInFunction(txt, i_fn); | |
| 322 | ✗ | txt := Tpl.softNewLine(txt); | |
| 323 | ✗ | txt := genBoxPtrFunction(txt, i_fn); | |
| 324 | ✗ | txt := Tpl.softNewLine(txt); | |
| 325 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE()); | |
| 326 | then txt; | ||
| 327 | |||
| 328 | case ( txt, | ||
| 329 | _ ) | ||
| 330 | then txt; | ||
| 331 | end match; | ||
| 332 | end genFunction; | ||
| 333 | |||
| 334 | protected function lm_53 | ||
| 335 | input output Tpl.Text txt; | ||
| 336 | input list<MidCode.Var> items; | ||
| 337 | algorithm | ||
| 338 | ✗ | for lstElt_53 in items loop | |
| 339 | txt := match lstElt_53 | ||
| 340 | local | ||
| 341 | MidCode.Var i_i; | ||
| 342 | |||
| 343 | case i_i | ||
| 344 | algorithm | ||
| 345 | ✗ | txt := genVarType(txt, i_i); | |
| 346 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" ")); | |
| 347 | ✗ | txt := genVarName(txt, i_i); | |
| 348 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(";")); | |
| 349 | ✗ | txt := Tpl.nextIter(txt); | |
| 350 | then txt; | ||
| 351 | end match; | ||
| 352 | end for; | ||
| 353 | end lm_53; | ||
| 354 | |||
| 355 | protected function lm_54 | ||
| 356 | input output Tpl.Text txt; | ||
| 357 | input list<MidCode.Var> items; | ||
| 358 | algorithm | ||
| 359 | ✗ | for lstElt_54 in items loop | |
| 360 | txt := match lstElt_54 | ||
| 361 | local | ||
| 362 | MidCode.Var i_o; | ||
| 363 | |||
| 364 | case i_o | ||
| 365 | algorithm | ||
| 366 | ✗ | txt := genVarType(txt, i_o); | |
| 367 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" ")); | |
| 368 | ✗ | txt := genVarName(txt, i_o); | |
| 369 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(";")); | |
| 370 | ✗ | txt := Tpl.nextIter(txt); | |
| 371 | then txt; | ||
| 372 | end match; | ||
| 373 | end for; | ||
| 374 | end lm_54; | ||
| 375 | |||
| 376 | protected function lm_55 | ||
| 377 | input output Tpl.Text txt; | ||
| 378 | input list<MidCode.Var> items; | ||
| 379 | algorithm | ||
| 380 | ✗ | for lstElt_55 in items loop | |
| 381 | txt := match lstElt_55 | ||
| 382 | local | ||
| 383 | MidCode.Var i_i; | ||
| 384 | |||
| 385 | case i_i | ||
| 386 | algorithm | ||
| 387 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("if(")); | |
| 388 | ✗ | txt := varModelicaRead(txt, i_i); | |
| 389 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(") return 1;")); | |
| 390 | ✗ | txt := Tpl.nextIter(txt); | |
| 391 | then txt; | ||
| 392 | end match; | ||
| 393 | end for; | ||
| 394 | end lm_55; | ||
| 395 | |||
| 396 | protected function lm_56 | ||
| 397 | input output Tpl.Text txt; | ||
| 398 | input list<MidCode.Var> items; | ||
| 399 | algorithm | ||
| 400 | ✗ | for lstElt_56 in items loop | |
| 401 | txt := match lstElt_56 | ||
| 402 | local | ||
| 403 | MidCode.Var i_o; | ||
| 404 | |||
| 405 | case i_o | ||
| 406 | algorithm | ||
| 407 | ✗ | txt := varModelicaWrite(txt, i_o); | |
| 408 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(";")); | |
| 409 | ✗ | txt := Tpl.nextIter(txt); | |
| 410 | then txt; | ||
| 411 | end match; | ||
| 412 | end for; | ||
| 413 | end lm_56; | ||
| 414 | |||
| 415 | protected function fun_57 | ||
| 416 | input Tpl.Text in_txt; | ||
| 417 | input Boolean in_mArg; | ||
| 418 | input list<MidCode.Var> in_a_outputs; | ||
| 419 | |||
| 420 | output Tpl.Text out_txt; | ||
| 421 | algorithm | ||
| 422 | out_txt := | ||
| 423 | match(in_txt, in_mArg, in_a_outputs) | ||
| 424 | local | ||
| 425 | Tpl.Text txt; | ||
| 426 | list<MidCode.Var> a_outputs; | ||
| 427 | MidCode.Var ret_0; | ||
| 428 | |||
| 429 | case ( txt, | ||
| 430 | false, | ||
| 431 | a_outputs ) | ||
| 432 | algorithm | ||
| 433 | ✗ | ret_0 := listHead(a_outputs); | |
| 434 | ✗ | txt := genVarName(txt, ret_0); | |
| 435 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = ")); | |
| 436 | then txt; | ||
| 437 | |||
| 438 | case ( txt, | ||
| 439 | _, | ||
| 440 | _ ) | ||
| 441 | then txt; | ||
| 442 | end match; | ||
| 443 | end fun_57; | ||
| 444 | |||
| 445 | protected function lm_58 | ||
| 446 | input output Tpl.Text txt; | ||
| 447 | input list<MidCode.Var> items; | ||
| 448 | algorithm | ||
| 449 | ✗ | for lstElt_58 in items loop | |
| 450 | txt := match lstElt_58 | ||
| 451 | local | ||
| 452 | MidCode.Var i_i; | ||
| 453 | |||
| 454 | case i_i | ||
| 455 | algorithm | ||
| 456 | ✗ | txt := genVarName(txt, i_i); | |
| 457 | ✗ | txt := Tpl.nextIter(txt); | |
| 458 | then txt; | ||
| 459 | end match; | ||
| 460 | end for; | ||
| 461 | end lm_58; | ||
| 462 | |||
| 463 | protected function lm_59 | ||
| 464 | input output Tpl.Text txt; | ||
| 465 | input list<MidCode.Var> items; | ||
| 466 | algorithm | ||
| 467 | ✗ | for lstElt_59 in items loop | |
| 468 | txt := match lstElt_59 | ||
| 469 | local | ||
| 470 | MidCode.Var i_o; | ||
| 471 | |||
| 472 | case i_o | ||
| 473 | algorithm | ||
| 474 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("&")); | |
| 475 | ✗ | txt := genVarName(txt, i_o); | |
| 476 | ✗ | txt := Tpl.nextIter(txt); | |
| 477 | then txt; | ||
| 478 | end match; | ||
| 479 | end for; | ||
| 480 | end lm_59; | ||
| 481 | |||
| 482 | protected function smf_60 | ||
| 483 | input Tpl.Text in_txt; | ||
| 484 | input Tpl.StringToken in_it; | ||
| 485 | |||
| 486 | output Tpl.Text out_txt; | ||
| 487 | algorithm | ||
| 488 | out_txt := | ||
| 489 | match(in_txt, in_it) | ||
| 490 | local | ||
| 491 | Tpl.Text txt; | ||
| 492 | Tpl.StringToken i_it; | ||
| 493 | |||
| 494 | case ( txt, | ||
| 495 | i_it ) | ||
| 496 | algorithm | ||
| 497 | ✗ | txt := Tpl.writeTok(txt, i_it); | |
| 498 | ✗ | txt := Tpl.nextIter(txt); | |
| 499 | then txt; | ||
| 500 | end match; | ||
| 501 | end smf_60; | ||
| 502 | |||
| 503 | protected function smf_61 | ||
| 504 | input Tpl.Text in_txt; | ||
| 505 | input Tpl.Text in_it; | ||
| 506 | |||
| 507 | output Tpl.Text out_txt; | ||
| 508 | algorithm | ||
| 509 | out_txt := | ||
| 510 | match(in_txt, in_it) | ||
| 511 | local | ||
| 512 | Tpl.Text txt; | ||
| 513 | Tpl.Text i_it; | ||
| 514 | |||
| 515 | case ( txt, | ||
| 516 | i_it ) | ||
| 517 | algorithm | ||
| 518 | ✗ | txt := Tpl.writeText(txt, i_it); | |
| 519 | ✗ | txt := Tpl.nextIter(txt); | |
| 520 | then txt; | ||
| 521 | end match; | ||
| 522 | end smf_61; | ||
| 523 | |||
| 524 | protected function smf_62 | ||
| 525 | input Tpl.Text in_txt; | ||
| 526 | input Tpl.Text in_it; | ||
| 527 | |||
| 528 | output Tpl.Text out_txt; | ||
| 529 | algorithm | ||
| 530 | out_txt := | ||
| 531 | match(in_txt, in_it) | ||
| 532 | local | ||
| 533 | Tpl.Text txt; | ||
| 534 | Tpl.Text i_it; | ||
| 535 | |||
| 536 | case ( txt, | ||
| 537 | i_it ) | ||
| 538 | algorithm | ||
| 539 | ✗ | txt := Tpl.writeText(txt, i_it); | |
| 540 | ✗ | txt := Tpl.nextIter(txt); | |
| 541 | then txt; | ||
| 542 | end match; | ||
| 543 | end smf_62; | ||
| 544 | |||
| 545 | protected function fun_63 | ||
| 546 | input Tpl.Text in_txt; | ||
| 547 | input Boolean in_mArg; | ||
| 548 | |||
| 549 | output Tpl.Text out_txt; | ||
| 550 | algorithm | ||
| 551 | out_txt := | ||
| 552 | match(in_txt, in_mArg) | ||
| 553 | local | ||
| 554 | Tpl.Text txt; | ||
| 555 | |||
| 556 | case ( txt, | ||
| 557 | false ) | ||
| 558 | then txt; | ||
| 559 | |||
| 560 | case ( txt, | ||
| 561 | _ ) | ||
| 562 | algorithm | ||
| 563 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("write_noretcall(outVar);")); | |
| 564 | then txt; | ||
| 565 | end match; | ||
| 566 | end fun_63; | ||
| 567 | |||
| 568 | public function genInFunction | ||
| 569 | input Tpl.Text in_txt; | ||
| 570 | input MidCode.Function in_a_fn; | ||
| 571 | |||
| 572 | output Tpl.Text out_txt; | ||
| 573 | algorithm | ||
| 574 | out_txt := | ||
| 575 | match(in_txt, in_a_fn) | ||
| 576 | local | ||
| 577 | Tpl.Text txt; | ||
| 578 | Absyn.Path i_name; | ||
| 579 | list<MidCode.Var> i_outputs; | ||
| 580 | list<MidCode.Var> i_inputs; | ||
| 581 | Boolean ret_10; | ||
| 582 | Tpl.Text txt_8; | ||
| 583 | list<MidCode.Var> ret_8; | ||
| 584 | Tpl.Text txt_7; | ||
| 585 | Tpl.Text l_callargs; | ||
| 586 | Boolean ret_5; | ||
| 587 | Tpl.Text l_callretval; | ||
| 588 | Tpl.Text l_outputLines; | ||
| 589 | Tpl.Text l_inputLines; | ||
| 590 | Tpl.Text l_outputDefs; | ||
| 591 | Tpl.Text l_inputDefs; | ||
| 592 | |||
| 593 | case ( txt, | ||
| 594 | MidCode.FUNCTION(inputs = i_inputs, outputs = i_outputs, name = i_name) ) | ||
| 595 | algorithm | ||
| 596 | ✗ | l_inputDefs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 597 | ✗ | l_inputDefs := lm_53(l_inputDefs, i_inputs); | |
| 598 | ✗ | l_inputDefs := Tpl.popIter(l_inputDefs); | |
| 599 | ✗ | l_outputDefs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 600 | ✗ | l_outputDefs := lm_54(l_outputDefs, i_outputs); | |
| 601 | ✗ | l_outputDefs := Tpl.popIter(l_outputDefs); | |
| 602 | ✗ | l_inputLines := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 603 | ✗ | l_inputLines := lm_55(l_inputLines, i_inputs); | |
| 604 | ✗ | l_inputLines := Tpl.popIter(l_inputLines); | |
| 605 | ✗ | l_outputLines := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 606 | ✗ | l_outputLines := lm_56(l_outputLines, i_outputs); | |
| 607 | ✗ | l_outputLines := Tpl.popIter(l_outputLines); | |
| 608 | ✗ | ret_5 := listEmpty(i_outputs); | |
| 609 | ✗ | l_callretval := fun_57(Tpl.emptyTxt, ret_5, i_outputs); | |
| 610 | ✗ | txt_7 := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 611 | ✗ | txt_7 := lm_58(txt_7, i_inputs); | |
| 612 | ✗ | txt_7 := Tpl.popIter(txt_7); | |
| 613 | ✗ | ret_8 := List.restOrEmpty(i_outputs); | |
| 614 | ✗ | txt_8 := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 615 | ✗ | txt_8 := lm_59(txt_8, ret_8); | |
| 616 | ✗ | txt_8 := Tpl.popIter(txt_8); | |
| 617 | ✗ | l_callargs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING_LIST({ | |
| 618 | ",\n", | ||
| 619 | " " | ||
| 620 | }, false)), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | ||
| 621 | ✗ | l_callargs := smf_60(l_callargs, Tpl.ST_STRING("threadData")); | |
| 622 | ✗ | l_callargs := smf_61(l_callargs, txt_7); | |
| 623 | ✗ | l_callargs := smf_62(l_callargs, txt_8); | |
| 624 | ✗ | l_callargs := Tpl.popIter(l_callargs); | |
| 625 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("int in_")); | |
| 626 | ✗ | txt := underscorePath(txt, i_name); | |
| 627 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 628 | "(threadData_t *threadData, type_description *inArgs, type_description *outVar)\n", | ||
| 629 | "{\n" | ||
| 630 | }, true)); | ||
| 631 | ✗ | txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2)); | |
| 632 | ✗ | txt := Tpl.writeText(txt, l_inputDefs); | |
| 633 | ✗ | txt := Tpl.softNewLine(txt); | |
| 634 | ✗ | txt := Tpl.writeText(txt, l_outputDefs); | |
| 635 | ✗ | txt := Tpl.softNewLine(txt); | |
| 636 | ✗ | txt := Tpl.writeText(txt, l_inputLines); | |
| 637 | ✗ | txt := Tpl.softNewLine(txt); | |
| 638 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_LINE("OMC_TRY_TOP_INTERNAL()\n")); | |
| 639 | ✗ | txt := Tpl.writeText(txt, l_callretval); | |
| 640 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("omc_")); | |
| 641 | ✗ | txt := underscorePath(txt, i_name); | |
| 642 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("(")); | |
| 643 | ✗ | txt := Tpl.writeText(txt, l_callargs); | |
| 644 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 645 | ");\n", | ||
| 646 | "OMC_CATCH_TOP(return 1)\n" | ||
| 647 | }, true)); | ||
| 648 | ✗ | txt := Tpl.writeText(txt, l_outputLines); | |
| 649 | ✗ | txt := Tpl.softNewLine(txt); | |
| 650 | ✗ | ret_10 := listEmpty(i_outputs); | |
| 651 | ✗ | txt := fun_63(txt, ret_10); | |
| 652 | ✗ | txt := Tpl.softNewLine(txt); | |
| 653 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 654 | "fflush(NULL);\n", | ||
| 655 | "return 0;\n" | ||
| 656 | }, true)); | ||
| 657 | ✗ | txt := Tpl.popBlock(txt); | |
| 658 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("}")); | |
| 659 | then txt; | ||
| 660 | |||
| 661 | case ( txt, | ||
| 662 | _ ) | ||
| 663 | then txt; | ||
| 664 | end match; | ||
| 665 | end genInFunction; | ||
| 666 | |||
| 667 | protected function fun_65 | ||
| 668 | input Tpl.Text in_txt; | ||
| 669 | input Boolean in_mArg; | ||
| 670 | |||
| 671 | output Tpl.Text out_txt; | ||
| 672 | algorithm | ||
| 673 | out_txt := | ||
| 674 | match(in_txt, in_mArg) | ||
| 675 | local | ||
| 676 | Tpl.Text txt; | ||
| 677 | |||
| 678 | case ( txt, | ||
| 679 | false ) | ||
| 680 | algorithm | ||
| 681 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_metatype")); | |
| 682 | then txt; | ||
| 683 | |||
| 684 | case ( txt, | ||
| 685 | _ ) | ||
| 686 | algorithm | ||
| 687 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("void")); | |
| 688 | then txt; | ||
| 689 | end match; | ||
| 690 | end fun_65; | ||
| 691 | |||
| 692 | protected function lm_66 | ||
| 693 | input output Tpl.Text txt; | ||
| 694 | input list<MidCode.Var> items; | ||
| 695 | algorithm | ||
| 696 | ✗ | for lstElt_66 in items loop | |
| 697 | txt := match lstElt_66 | ||
| 698 | local | ||
| 699 | MidCode.Var i_i; | ||
| 700 | |||
| 701 | case i_i | ||
| 702 | algorithm | ||
| 703 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_metatype ")); | |
| 704 | ✗ | txt := genVarName(txt, i_i); | |
| 705 | ✗ | txt := Tpl.nextIter(txt); | |
| 706 | then txt; | ||
| 707 | end match; | ||
| 708 | end for; | ||
| 709 | end lm_66; | ||
| 710 | |||
| 711 | protected function lm_67 | ||
| 712 | input output Tpl.Text txt; | ||
| 713 | input list<MidCode.Var> items; | ||
| 714 | algorithm | ||
| 715 | ✗ | for lstElt_67 in items loop | |
| 716 | txt := match lstElt_67 | ||
| 717 | local | ||
| 718 | MidCode.Var i_o; | ||
| 719 | |||
| 720 | case i_o | ||
| 721 | algorithm | ||
| 722 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_metatype *out_")); | |
| 723 | ✗ | txt := genVarName(txt, i_o); | |
| 724 | ✗ | txt := Tpl.nextIter(txt); | |
| 725 | then txt; | ||
| 726 | end match; | ||
| 727 | end for; | ||
| 728 | end lm_67; | ||
| 729 | |||
| 730 | protected function smf_68 | ||
| 731 | input Tpl.Text in_txt; | ||
| 732 | input Tpl.StringToken in_it; | ||
| 733 | |||
| 734 | output Tpl.Text out_txt; | ||
| 735 | algorithm | ||
| 736 | out_txt := | ||
| 737 | match(in_txt, in_it) | ||
| 738 | local | ||
| 739 | Tpl.Text txt; | ||
| 740 | Tpl.StringToken i_it; | ||
| 741 | |||
| 742 | case ( txt, | ||
| 743 | i_it ) | ||
| 744 | algorithm | ||
| 745 | ✗ | txt := Tpl.writeTok(txt, i_it); | |
| 746 | ✗ | txt := Tpl.nextIter(txt); | |
| 747 | then txt; | ||
| 748 | end match; | ||
| 749 | end smf_68; | ||
| 750 | |||
| 751 | protected function smf_69 | ||
| 752 | input Tpl.Text in_txt; | ||
| 753 | input Tpl.Text in_it; | ||
| 754 | |||
| 755 | output Tpl.Text out_txt; | ||
| 756 | algorithm | ||
| 757 | out_txt := | ||
| 758 | match(in_txt, in_it) | ||
| 759 | local | ||
| 760 | Tpl.Text txt; | ||
| 761 | Tpl.Text i_it; | ||
| 762 | |||
| 763 | case ( txt, | ||
| 764 | i_it ) | ||
| 765 | algorithm | ||
| 766 | ✗ | txt := Tpl.writeText(txt, i_it); | |
| 767 | ✗ | txt := Tpl.nextIter(txt); | |
| 768 | then txt; | ||
| 769 | end match; | ||
| 770 | end smf_69; | ||
| 771 | |||
| 772 | protected function smf_70 | ||
| 773 | input Tpl.Text in_txt; | ||
| 774 | input Tpl.Text in_it; | ||
| 775 | |||
| 776 | output Tpl.Text out_txt; | ||
| 777 | algorithm | ||
| 778 | out_txt := | ||
| 779 | match(in_txt, in_it) | ||
| 780 | local | ||
| 781 | Tpl.Text txt; | ||
| 782 | Tpl.Text i_it; | ||
| 783 | |||
| 784 | case ( txt, | ||
| 785 | i_it ) | ||
| 786 | algorithm | ||
| 787 | ✗ | txt := Tpl.writeText(txt, i_it); | |
| 788 | ✗ | txt := Tpl.nextIter(txt); | |
| 789 | then txt; | ||
| 790 | end match; | ||
| 791 | end smf_70; | ||
| 792 | |||
| 793 | protected function fun_71 | ||
| 794 | input Tpl.Text in_txt; | ||
| 795 | input Boolean in_mArg; | ||
| 796 | input MidCode.Var in_a_i; | ||
| 797 | |||
| 798 | output Tpl.Text out_txt; | ||
| 799 | algorithm | ||
| 800 | out_txt := | ||
| 801 | match(in_txt, in_mArg, in_a_i) | ||
| 802 | local | ||
| 803 | Tpl.Text txt; | ||
| 804 | MidCode.Var a_i; | ||
| 805 | |||
| 806 | case ( txt, | ||
| 807 | true, | ||
| 808 | _ ) | ||
| 809 | then txt; | ||
| 810 | |||
| 811 | case ( txt, | ||
| 812 | _, | ||
| 813 | a_i ) | ||
| 814 | algorithm | ||
| 815 | ✗ | txt := genVarType(txt, a_i); | |
| 816 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" unbox_")); | |
| 817 | ✗ | txt := genVarName(txt, a_i); | |
| 818 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(";")); | |
| 819 | then txt; | ||
| 820 | end match; | ||
| 821 | end fun_71; | ||
| 822 | |||
| 823 | protected function lm_72 | ||
| 824 | input output Tpl.Text txt; | ||
| 825 | input list<MidCode.Var> items; | ||
| 826 | algorithm | ||
| 827 | ✗ | for lstElt_72 in items loop | |
| 828 | txt := match lstElt_72 | ||
| 829 | local | ||
| 830 | MidCode.Var i_i; | ||
| 831 | Boolean ret_1; | ||
| 832 | Tpl.Text txt_0; | ||
| 833 | |||
| 834 | case i_i | ||
| 835 | algorithm | ||
| 836 | ✗ | txt_0 := varBoxType(Tpl.emptyTxt, i_i); | |
| 837 | ✗ | ret_1 := Tpl.isEmpty(txt_0); | |
| 838 | ✗ | txt := fun_71(txt, ret_1, i_i); | |
| 839 | ✗ | txt := Tpl.nextIter(txt); | |
| 840 | then txt; | ||
| 841 | end match; | ||
| 842 | end for; | ||
| 843 | end lm_72; | ||
| 844 | |||
| 845 | protected function fun_73 | ||
| 846 | input Tpl.Text in_txt; | ||
| 847 | input Boolean in_mArg; | ||
| 848 | input MidCode.Var in_a_o; | ||
| 849 | |||
| 850 | output Tpl.Text out_txt; | ||
| 851 | algorithm | ||
| 852 | out_txt := | ||
| 853 | match(in_txt, in_mArg, in_a_o) | ||
| 854 | local | ||
| 855 | Tpl.Text txt; | ||
| 856 | MidCode.Var a_o; | ||
| 857 | |||
| 858 | case ( txt, | ||
| 859 | true, | ||
| 860 | _ ) | ||
| 861 | then txt; | ||
| 862 | |||
| 863 | case ( txt, | ||
| 864 | _, | ||
| 865 | a_o ) | ||
| 866 | algorithm | ||
| 867 | ✗ | txt := genVarType(txt, a_o); | |
| 868 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" ")); | |
| 869 | ✗ | txt := genVarName(txt, a_o); | |
| 870 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(";")); | |
| 871 | then txt; | ||
| 872 | end match; | ||
| 873 | end fun_73; | ||
| 874 | |||
| 875 | protected function lm_74 | ||
| 876 | input output Tpl.Text txt; | ||
| 877 | input list<MidCode.Var> items; | ||
| 878 | algorithm | ||
| 879 | ✗ | for lstElt_74 in items loop | |
| 880 | txt := match lstElt_74 | ||
| 881 | local | ||
| 882 | MidCode.Var i_o; | ||
| 883 | Boolean ret_1; | ||
| 884 | Tpl.Text txt_0; | ||
| 885 | |||
| 886 | case i_o | ||
| 887 | algorithm | ||
| 888 | ✗ | txt_0 := varBoxType(Tpl.emptyTxt, i_o); | |
| 889 | ✗ | ret_1 := Tpl.isEmpty(txt_0); | |
| 890 | ✗ | txt := fun_73(txt, ret_1, i_o); | |
| 891 | ✗ | txt := Tpl.nextIter(txt); | |
| 892 | then txt; | ||
| 893 | end match; | ||
| 894 | end for; | ||
| 895 | end lm_74; | ||
| 896 | |||
| 897 | protected function fun_75 | ||
| 898 | input Tpl.Text in_txt; | ||
| 899 | input Boolean in_mArg; | ||
| 900 | input list<MidCode.Var> in_a_outputs; | ||
| 901 | |||
| 902 | output Tpl.Text out_txt; | ||
| 903 | algorithm | ||
| 904 | out_txt := | ||
| 905 | match(in_txt, in_mArg, in_a_outputs) | ||
| 906 | local | ||
| 907 | Tpl.Text txt; | ||
| 908 | list<MidCode.Var> a_outputs; | ||
| 909 | MidCode.Var ret_0; | ||
| 910 | |||
| 911 | case ( txt, | ||
| 912 | false, | ||
| 913 | a_outputs ) | ||
| 914 | algorithm | ||
| 915 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_metatype out_")); | |
| 916 | ✗ | ret_0 := listHead(a_outputs); | |
| 917 | ✗ | txt := genVarName(txt, ret_0); | |
| 918 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(";")); | |
| 919 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_NEW_LINE()); | |
| 920 | then txt; | ||
| 921 | |||
| 922 | case ( txt, | ||
| 923 | _, | ||
| 924 | _ ) | ||
| 925 | then txt; | ||
| 926 | end match; | ||
| 927 | end fun_75; | ||
| 928 | |||
| 929 | protected function fun_76 | ||
| 930 | input Tpl.Text in_txt; | ||
| 931 | input Boolean in_mArg; | ||
| 932 | input MidCode.Var in_a_i; | ||
| 933 | |||
| 934 | output Tpl.Text out_txt; | ||
| 935 | algorithm | ||
| 936 | out_txt := | ||
| 937 | match(in_txt, in_mArg, in_a_i) | ||
| 938 | local | ||
| 939 | Tpl.Text txt; | ||
| 940 | MidCode.Var a_i; | ||
| 941 | |||
| 942 | case ( txt, | ||
| 943 | true, | ||
| 944 | _ ) | ||
| 945 | then txt; | ||
| 946 | |||
| 947 | case ( txt, | ||
| 948 | _, | ||
| 949 | a_i ) | ||
| 950 | algorithm | ||
| 951 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("unbox_")); | |
| 952 | ✗ | txt := genVarName(txt, a_i); | |
| 953 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = ")); | |
| 954 | ✗ | txt := varUnbox2(txt, a_i); | |
| 955 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(";")); | |
| 956 | then txt; | ||
| 957 | end match; | ||
| 958 | end fun_76; | ||
| 959 | |||
| 960 | protected function lm_77 | ||
| 961 | input output Tpl.Text txt; | ||
| 962 | input list<MidCode.Var> items; | ||
| 963 | algorithm | ||
| 964 | ✗ | for lstElt_77 in items loop | |
| 965 | txt := match lstElt_77 | ||
| 966 | local | ||
| 967 | MidCode.Var i_i; | ||
| 968 | Boolean ret_1; | ||
| 969 | Tpl.Text txt_0; | ||
| 970 | |||
| 971 | case i_i | ||
| 972 | algorithm | ||
| 973 | ✗ | txt_0 := varBoxType(Tpl.emptyTxt, i_i); | |
| 974 | ✗ | ret_1 := Tpl.isEmpty(txt_0); | |
| 975 | ✗ | txt := fun_76(txt, ret_1, i_i); | |
| 976 | ✗ | txt := Tpl.nextIter(txt); | |
| 977 | then txt; | ||
| 978 | end match; | ||
| 979 | end for; | ||
| 980 | end lm_77; | ||
| 981 | |||
| 982 | protected function fun_78 | ||
| 983 | input Tpl.Text in_txt; | ||
| 984 | input Boolean in_mArg; | ||
| 985 | |||
| 986 | output Tpl.Text out_txt; | ||
| 987 | algorithm | ||
| 988 | out_txt := | ||
| 989 | match(in_txt, in_mArg) | ||
| 990 | local | ||
| 991 | Tpl.Text txt; | ||
| 992 | |||
| 993 | case ( txt, | ||
| 994 | true ) | ||
| 995 | algorithm | ||
| 996 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("out_")); | |
| 997 | then txt; | ||
| 998 | |||
| 999 | case ( txt, | ||
| 1000 | _ ) | ||
| 1001 | then txt; | ||
| 1002 | end match; | ||
| 1003 | end fun_78; | ||
| 1004 | |||
| 1005 | protected function fun_79 | ||
| 1006 | input Tpl.Text in_txt; | ||
| 1007 | input Boolean in_mArg; | ||
| 1008 | input list<MidCode.Var> in_a_outputs; | ||
| 1009 | |||
| 1010 | output Tpl.Text out_txt; | ||
| 1011 | algorithm | ||
| 1012 | out_txt := | ||
| 1013 | match(in_txt, in_mArg, in_a_outputs) | ||
| 1014 | local | ||
| 1015 | Tpl.Text txt; | ||
| 1016 | list<MidCode.Var> a_outputs; | ||
| 1017 | MidCode.Var ret_3; | ||
| 1018 | Boolean ret_2; | ||
| 1019 | Tpl.Text txt_1; | ||
| 1020 | MidCode.Var ret_0; | ||
| 1021 | |||
| 1022 | case ( txt, | ||
| 1023 | false, | ||
| 1024 | a_outputs ) | ||
| 1025 | algorithm | ||
| 1026 | ✗ | ret_0 := listHead(a_outputs); | |
| 1027 | ✗ | txt_1 := varBoxType(Tpl.emptyTxt, ret_0); | |
| 1028 | ✗ | ret_2 := Tpl.isEmpty(txt_1); | |
| 1029 | ✗ | txt := fun_78(txt, ret_2); | |
| 1030 | ✗ | ret_3 := listHead(a_outputs); | |
| 1031 | ✗ | txt := genVarName(txt, ret_3); | |
| 1032 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = ")); | |
| 1033 | then txt; | ||
| 1034 | |||
| 1035 | case ( txt, | ||
| 1036 | _, | ||
| 1037 | _ ) | ||
| 1038 | then txt; | ||
| 1039 | end match; | ||
| 1040 | end fun_79; | ||
| 1041 | |||
| 1042 | protected function fun_80 | ||
| 1043 | input Tpl.Text in_txt; | ||
| 1044 | input Boolean in_mArg; | ||
| 1045 | |||
| 1046 | output Tpl.Text out_txt; | ||
| 1047 | algorithm | ||
| 1048 | out_txt := | ||
| 1049 | match(in_txt, in_mArg) | ||
| 1050 | local | ||
| 1051 | Tpl.Text txt; | ||
| 1052 | |||
| 1053 | case ( txt, | ||
| 1054 | true ) | ||
| 1055 | then txt; | ||
| 1056 | |||
| 1057 | case ( txt, | ||
| 1058 | _ ) | ||
| 1059 | algorithm | ||
| 1060 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("unbox_")); | |
| 1061 | then txt; | ||
| 1062 | end match; | ||
| 1063 | end fun_80; | ||
| 1064 | |||
| 1065 | protected function lm_81 | ||
| 1066 | input output Tpl.Text txt; | ||
| 1067 | input list<MidCode.Var> items; | ||
| 1068 | algorithm | ||
| 1069 | ✗ | for lstElt_81 in items loop | |
| 1070 | txt := match lstElt_81 | ||
| 1071 | local | ||
| 1072 | MidCode.Var i_i; | ||
| 1073 | Boolean ret_1; | ||
| 1074 | Tpl.Text txt_0; | ||
| 1075 | |||
| 1076 | case i_i | ||
| 1077 | algorithm | ||
| 1078 | ✗ | txt_0 := varBoxType(Tpl.emptyTxt, i_i); | |
| 1079 | ✗ | ret_1 := Tpl.isEmpty(txt_0); | |
| 1080 | ✗ | txt := fun_80(txt, ret_1); | |
| 1081 | ✗ | txt := genVarName(txt, i_i); | |
| 1082 | ✗ | txt := Tpl.nextIter(txt); | |
| 1083 | then txt; | ||
| 1084 | end match; | ||
| 1085 | end for; | ||
| 1086 | end lm_81; | ||
| 1087 | |||
| 1088 | protected function fun_82 | ||
| 1089 | input Tpl.Text in_txt; | ||
| 1090 | input Boolean in_mArg; | ||
| 1091 | |||
| 1092 | output Tpl.Text out_txt; | ||
| 1093 | algorithm | ||
| 1094 | out_txt := | ||
| 1095 | match(in_txt, in_mArg) | ||
| 1096 | local | ||
| 1097 | Tpl.Text txt; | ||
| 1098 | |||
| 1099 | case ( txt, | ||
| 1100 | true ) | ||
| 1101 | algorithm | ||
| 1102 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("out_")); | |
| 1103 | then txt; | ||
| 1104 | |||
| 1105 | case ( txt, | ||
| 1106 | _ ) | ||
| 1107 | algorithm | ||
| 1108 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("&")); | |
| 1109 | then txt; | ||
| 1110 | end match; | ||
| 1111 | end fun_82; | ||
| 1112 | |||
| 1113 | protected function lm_83 | ||
| 1114 | input output Tpl.Text txt; | ||
| 1115 | input list<MidCode.Var> items; | ||
| 1116 | algorithm | ||
| 1117 | ✗ | for lstElt_83 in items loop | |
| 1118 | txt := match lstElt_83 | ||
| 1119 | local | ||
| 1120 | MidCode.Var i_o; | ||
| 1121 | Boolean ret_1; | ||
| 1122 | Tpl.Text txt_0; | ||
| 1123 | |||
| 1124 | case i_o | ||
| 1125 | algorithm | ||
| 1126 | ✗ | txt_0 := varBoxType(Tpl.emptyTxt, i_o); | |
| 1127 | ✗ | ret_1 := Tpl.isEmpty(txt_0); | |
| 1128 | ✗ | txt := fun_82(txt, ret_1); | |
| 1129 | ✗ | txt := genVarName(txt, i_o); | |
| 1130 | ✗ | txt := Tpl.nextIter(txt); | |
| 1131 | then txt; | ||
| 1132 | end match; | ||
| 1133 | end for; | ||
| 1134 | end lm_83; | ||
| 1135 | |||
| 1136 | protected function smf_84 | ||
| 1137 | input Tpl.Text in_txt; | ||
| 1138 | input Tpl.StringToken in_it; | ||
| 1139 | |||
| 1140 | output Tpl.Text out_txt; | ||
| 1141 | algorithm | ||
| 1142 | out_txt := | ||
| 1143 | match(in_txt, in_it) | ||
| 1144 | local | ||
| 1145 | Tpl.Text txt; | ||
| 1146 | Tpl.StringToken i_it; | ||
| 1147 | |||
| 1148 | case ( txt, | ||
| 1149 | i_it ) | ||
| 1150 | algorithm | ||
| 1151 | ✗ | txt := Tpl.writeTok(txt, i_it); | |
| 1152 | ✗ | txt := Tpl.nextIter(txt); | |
| 1153 | then txt; | ||
| 1154 | end match; | ||
| 1155 | end smf_84; | ||
| 1156 | |||
| 1157 | protected function smf_85 | ||
| 1158 | input Tpl.Text in_txt; | ||
| 1159 | input Tpl.Text in_it; | ||
| 1160 | |||
| 1161 | output Tpl.Text out_txt; | ||
| 1162 | algorithm | ||
| 1163 | out_txt := | ||
| 1164 | match(in_txt, in_it) | ||
| 1165 | local | ||
| 1166 | Tpl.Text txt; | ||
| 1167 | Tpl.Text i_it; | ||
| 1168 | |||
| 1169 | case ( txt, | ||
| 1170 | i_it ) | ||
| 1171 | algorithm | ||
| 1172 | ✗ | txt := Tpl.writeText(txt, i_it); | |
| 1173 | ✗ | txt := Tpl.nextIter(txt); | |
| 1174 | then txt; | ||
| 1175 | end match; | ||
| 1176 | end smf_85; | ||
| 1177 | |||
| 1178 | protected function smf_86 | ||
| 1179 | input Tpl.Text in_txt; | ||
| 1180 | input Tpl.Text in_it; | ||
| 1181 | |||
| 1182 | output Tpl.Text out_txt; | ||
| 1183 | algorithm | ||
| 1184 | out_txt := | ||
| 1185 | match(in_txt, in_it) | ||
| 1186 | local | ||
| 1187 | Tpl.Text txt; | ||
| 1188 | Tpl.Text i_it; | ||
| 1189 | |||
| 1190 | case ( txt, | ||
| 1191 | i_it ) | ||
| 1192 | algorithm | ||
| 1193 | ✗ | txt := Tpl.writeText(txt, i_it); | |
| 1194 | ✗ | txt := Tpl.nextIter(txt); | |
| 1195 | then txt; | ||
| 1196 | end match; | ||
| 1197 | end smf_86; | ||
| 1198 | |||
| 1199 | protected function fun_87 | ||
| 1200 | input Tpl.Text in_txt; | ||
| 1201 | input Boolean in_mArg; | ||
| 1202 | input list<MidCode.Var> in_a_outputs; | ||
| 1203 | |||
| 1204 | output Tpl.Text out_txt; | ||
| 1205 | algorithm | ||
| 1206 | out_txt := | ||
| 1207 | match(in_txt, in_mArg, in_a_outputs) | ||
| 1208 | local | ||
| 1209 | Tpl.Text txt; | ||
| 1210 | list<MidCode.Var> a_outputs; | ||
| 1211 | MidCode.Var ret_1; | ||
| 1212 | MidCode.Var ret_0; | ||
| 1213 | |||
| 1214 | case ( txt, | ||
| 1215 | true, | ||
| 1216 | _ ) | ||
| 1217 | then txt; | ||
| 1218 | |||
| 1219 | case ( txt, | ||
| 1220 | _, | ||
| 1221 | a_outputs ) | ||
| 1222 | algorithm | ||
| 1223 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("out_")); | |
| 1224 | ✗ | ret_0 := listHead(a_outputs); | |
| 1225 | ✗ | txt := genVarName(txt, ret_0); | |
| 1226 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = ")); | |
| 1227 | ✗ | ret_1 := listHead(a_outputs); | |
| 1228 | ✗ | txt := varBox(txt, ret_1); | |
| 1229 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(";")); | |
| 1230 | then txt; | ||
| 1231 | end match; | ||
| 1232 | end fun_87; | ||
| 1233 | |||
| 1234 | protected function fun_88 | ||
| 1235 | input Tpl.Text in_txt; | ||
| 1236 | input Boolean in_mArg; | ||
| 1237 | input list<MidCode.Var> in_a_outputs; | ||
| 1238 | |||
| 1239 | output Tpl.Text out_txt; | ||
| 1240 | algorithm | ||
| 1241 | out_txt := | ||
| 1242 | match(in_txt, in_mArg, in_a_outputs) | ||
| 1243 | local | ||
| 1244 | Tpl.Text txt; | ||
| 1245 | list<MidCode.Var> a_outputs; | ||
| 1246 | Boolean ret_2; | ||
| 1247 | Tpl.Text txt_1; | ||
| 1248 | MidCode.Var ret_0; | ||
| 1249 | |||
| 1250 | case ( txt, | ||
| 1251 | false, | ||
| 1252 | a_outputs ) | ||
| 1253 | algorithm | ||
| 1254 | ✗ | ret_0 := listHead(a_outputs); | |
| 1255 | ✗ | txt_1 := varBoxType(Tpl.emptyTxt, ret_0); | |
| 1256 | ✗ | ret_2 := Tpl.isEmpty(txt_1); | |
| 1257 | ✗ | txt := fun_87(txt, ret_2, a_outputs); | |
| 1258 | then txt; | ||
| 1259 | |||
| 1260 | case ( txt, | ||
| 1261 | _, | ||
| 1262 | _ ) | ||
| 1263 | then txt; | ||
| 1264 | end match; | ||
| 1265 | end fun_88; | ||
| 1266 | |||
| 1267 | protected function fun_89 | ||
| 1268 | input Tpl.Text in_txt; | ||
| 1269 | input Boolean in_mArg; | ||
| 1270 | input MidCode.Var in_a_o; | ||
| 1271 | |||
| 1272 | output Tpl.Text out_txt; | ||
| 1273 | algorithm | ||
| 1274 | out_txt := | ||
| 1275 | match(in_txt, in_mArg, in_a_o) | ||
| 1276 | local | ||
| 1277 | Tpl.Text txt; | ||
| 1278 | MidCode.Var a_o; | ||
| 1279 | |||
| 1280 | case ( txt, | ||
| 1281 | true, | ||
| 1282 | _ ) | ||
| 1283 | then txt; | ||
| 1284 | |||
| 1285 | case ( txt, | ||
| 1286 | _, | ||
| 1287 | a_o ) | ||
| 1288 | algorithm | ||
| 1289 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("if(out_")); | |
| 1290 | ✗ | txt := genVarName(txt, a_o); | |
| 1291 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(") *out_")); | |
| 1292 | ✗ | txt := genVarName(txt, a_o); | |
| 1293 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = ")); | |
| 1294 | ✗ | txt := varBox(txt, a_o); | |
| 1295 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(";")); | |
| 1296 | then txt; | ||
| 1297 | end match; | ||
| 1298 | end fun_89; | ||
| 1299 | |||
| 1300 | protected function lm_90 | ||
| 1301 | input output Tpl.Text txt; | ||
| 1302 | input list<MidCode.Var> items; | ||
| 1303 | algorithm | ||
| 1304 | ✗ | for lstElt_90 in items loop | |
| 1305 | txt := match lstElt_90 | ||
| 1306 | local | ||
| 1307 | MidCode.Var i_o; | ||
| 1308 | Boolean ret_1; | ||
| 1309 | Tpl.Text txt_0; | ||
| 1310 | |||
| 1311 | case i_o | ||
| 1312 | algorithm | ||
| 1313 | ✗ | txt_0 := varBoxType(Tpl.emptyTxt, i_o); | |
| 1314 | ✗ | ret_1 := Tpl.isEmpty(txt_0); | |
| 1315 | ✗ | txt := fun_89(txt, ret_1, i_o); | |
| 1316 | then txt; | ||
| 1317 | end match; | ||
| 1318 | end for; | ||
| 1319 | end lm_90; | ||
| 1320 | |||
| 1321 | protected function smf_91 | ||
| 1322 | input Tpl.Text in_txt; | ||
| 1323 | input Tpl.Text in_it; | ||
| 1324 | |||
| 1325 | output Tpl.Text out_txt; | ||
| 1326 | algorithm | ||
| 1327 | out_txt := | ||
| 1328 | match(in_txt, in_it) | ||
| 1329 | local | ||
| 1330 | Tpl.Text txt; | ||
| 1331 | Tpl.Text i_it; | ||
| 1332 | |||
| 1333 | case ( txt, | ||
| 1334 | i_it ) | ||
| 1335 | algorithm | ||
| 1336 | ✗ | txt := Tpl.writeText(txt, i_it); | |
| 1337 | ✗ | txt := Tpl.nextIter(txt); | |
| 1338 | then txt; | ||
| 1339 | end match; | ||
| 1340 | end smf_91; | ||
| 1341 | |||
| 1342 | protected function smf_92 | ||
| 1343 | input Tpl.Text in_txt; | ||
| 1344 | input Tpl.Text in_it; | ||
| 1345 | |||
| 1346 | output Tpl.Text out_txt; | ||
| 1347 | algorithm | ||
| 1348 | out_txt := | ||
| 1349 | match(in_txt, in_it) | ||
| 1350 | local | ||
| 1351 | Tpl.Text txt; | ||
| 1352 | Tpl.Text i_it; | ||
| 1353 | |||
| 1354 | case ( txt, | ||
| 1355 | i_it ) | ||
| 1356 | algorithm | ||
| 1357 | ✗ | txt := Tpl.writeText(txt, i_it); | |
| 1358 | ✗ | txt := Tpl.nextIter(txt); | |
| 1359 | then txt; | ||
| 1360 | end match; | ||
| 1361 | end smf_92; | ||
| 1362 | |||
| 1363 | protected function fun_93 | ||
| 1364 | input Tpl.Text in_txt; | ||
| 1365 | input Boolean in_mArg; | ||
| 1366 | input list<MidCode.Var> in_a_outputs; | ||
| 1367 | |||
| 1368 | output Tpl.Text out_txt; | ||
| 1369 | algorithm | ||
| 1370 | out_txt := | ||
| 1371 | match(in_txt, in_mArg, in_a_outputs) | ||
| 1372 | local | ||
| 1373 | Tpl.Text txt; | ||
| 1374 | list<MidCode.Var> a_outputs; | ||
| 1375 | MidCode.Var ret_0; | ||
| 1376 | |||
| 1377 | case ( txt, | ||
| 1378 | false, | ||
| 1379 | a_outputs ) | ||
| 1380 | algorithm | ||
| 1381 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("return out_")); | |
| 1382 | ✗ | ret_0 := listHead(a_outputs); | |
| 1383 | ✗ | txt := genVarName(txt, ret_0); | |
| 1384 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(";")); | |
| 1385 | then txt; | ||
| 1386 | |||
| 1387 | case ( txt, | ||
| 1388 | _, | ||
| 1389 | _ ) | ||
| 1390 | algorithm | ||
| 1391 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("return;")); | |
| 1392 | then txt; | ||
| 1393 | end match; | ||
| 1394 | end fun_93; | ||
| 1395 | |||
| 1396 | public function genBoxPtrFunction | ||
| 1397 | input Tpl.Text in_txt; | ||
| 1398 | input MidCode.Function in_a_fn; | ||
| 1399 | |||
| 1400 | output Tpl.Text out_txt; | ||
| 1401 | algorithm | ||
| 1402 | out_txt := | ||
| 1403 | match(in_txt, in_a_fn) | ||
| 1404 | local | ||
| 1405 | Tpl.Text txt; | ||
| 1406 | Absyn.Path i_name; | ||
| 1407 | list<MidCode.Var> i_inputs; | ||
| 1408 | list<MidCode.Var> i_outputs; | ||
| 1409 | Boolean ret_22; | ||
| 1410 | Tpl.Text txt_20; | ||
| 1411 | list<MidCode.Var> ret_20; | ||
| 1412 | Tpl.Text txt_18; | ||
| 1413 | Boolean ret_18; | ||
| 1414 | Tpl.Text l_boxes; | ||
| 1415 | Tpl.Text txt_15; | ||
| 1416 | list<MidCode.Var> ret_15; | ||
| 1417 | Tpl.Text txt_14; | ||
| 1418 | Tpl.Text l_callvars; | ||
| 1419 | Boolean ret_12; | ||
| 1420 | Tpl.Text l_callretval; | ||
| 1421 | Tpl.Text l_unboxes; | ||
| 1422 | Boolean ret_9; | ||
| 1423 | Tpl.Text l_boxDefs; | ||
| 1424 | Tpl.Text l_callOutDefs; | ||
| 1425 | Tpl.Text l_unboxDefs; | ||
| 1426 | Tpl.Text txt_4; | ||
| 1427 | list<MidCode.Var> ret_4; | ||
| 1428 | Tpl.Text txt_3; | ||
| 1429 | Tpl.Text l_arguments; | ||
| 1430 | Boolean ret_1; | ||
| 1431 | Tpl.Text l_returnType; | ||
| 1432 | |||
| 1433 | case ( txt, | ||
| 1434 | MidCode.FUNCTION(outputs = i_outputs, inputs = i_inputs, name = i_name) ) | ||
| 1435 | algorithm | ||
| 1436 | ✗ | ret_1 := listEmpty(i_outputs); | |
| 1437 | ✗ | l_returnType := fun_65(Tpl.emptyTxt, ret_1); | |
| 1438 | ✗ | txt_3 := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 1439 | ✗ | txt_3 := lm_66(txt_3, i_inputs); | |
| 1440 | ✗ | txt_3 := Tpl.popIter(txt_3); | |
| 1441 | ✗ | ret_4 := List.restOrEmpty(i_outputs); | |
| 1442 | ✗ | txt_4 := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 1443 | ✗ | txt_4 := lm_67(txt_4, ret_4); | |
| 1444 | ✗ | txt_4 := Tpl.popIter(txt_4); | |
| 1445 | ✗ | l_arguments := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING_LIST({ | |
| 1446 | ",\n", | ||
| 1447 | " " | ||
| 1448 | }, false)), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | ||
| 1449 | ✗ | l_arguments := smf_68(l_arguments, Tpl.ST_STRING("threadData_t *threadData")); | |
| 1450 | ✗ | l_arguments := smf_69(l_arguments, txt_3); | |
| 1451 | ✗ | l_arguments := smf_70(l_arguments, txt_4); | |
| 1452 | ✗ | l_arguments := Tpl.popIter(l_arguments); | |
| 1453 | ✗ | l_unboxDefs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 1454 | ✗ | l_unboxDefs := lm_72(l_unboxDefs, i_inputs); | |
| 1455 | ✗ | l_unboxDefs := Tpl.popIter(l_unboxDefs); | |
| 1456 | ✗ | l_callOutDefs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 1457 | ✗ | l_callOutDefs := lm_74(l_callOutDefs, i_outputs); | |
| 1458 | ✗ | l_callOutDefs := Tpl.popIter(l_callOutDefs); | |
| 1459 | ✗ | ret_9 := listEmpty(i_outputs); | |
| 1460 | ✗ | l_boxDefs := fun_75(Tpl.emptyTxt, ret_9, i_outputs); | |
| 1461 | ✗ | l_unboxes := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 1462 | ✗ | l_unboxes := lm_77(l_unboxes, i_inputs); | |
| 1463 | ✗ | l_unboxes := Tpl.popIter(l_unboxes); | |
| 1464 | ✗ | ret_12 := listEmpty(i_outputs); | |
| 1465 | ✗ | l_callretval := fun_79(Tpl.emptyTxt, ret_12, i_outputs); | |
| 1466 | ✗ | txt_14 := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 1467 | ✗ | txt_14 := lm_81(txt_14, i_inputs); | |
| 1468 | ✗ | txt_14 := Tpl.popIter(txt_14); | |
| 1469 | ✗ | ret_15 := List.restOrEmpty(i_outputs); | |
| 1470 | ✗ | txt_15 := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 1471 | ✗ | txt_15 := lm_83(txt_15, ret_15); | |
| 1472 | ✗ | txt_15 := Tpl.popIter(txt_15); | |
| 1473 | ✗ | l_callvars := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING_LIST({ | |
| 1474 | ",\n", | ||
| 1475 | " " | ||
| 1476 | }, false)), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | ||
| 1477 | ✗ | l_callvars := smf_84(l_callvars, Tpl.ST_STRING("threadData")); | |
| 1478 | ✗ | l_callvars := smf_85(l_callvars, txt_14); | |
| 1479 | ✗ | l_callvars := smf_86(l_callvars, txt_15); | |
| 1480 | ✗ | l_callvars := Tpl.popIter(l_callvars); | |
| 1481 | ✗ | ret_18 := listEmpty(i_outputs); | |
| 1482 | ✗ | txt_18 := fun_88(Tpl.emptyTxt, ret_18, i_outputs); | |
| 1483 | ✗ | ret_20 := List.restOrEmpty(i_outputs); | |
| 1484 | ✗ | txt_20 := lm_90(Tpl.emptyTxt, ret_20); | |
| 1485 | ✗ | l_boxes := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_NEW_LINE()), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 1486 | ✗ | l_boxes := smf_91(l_boxes, txt_18); | |
| 1487 | ✗ | l_boxes := smf_92(l_boxes, txt_20); | |
| 1488 | ✗ | l_boxes := Tpl.popIter(l_boxes); | |
| 1489 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("#undef boxptr_")); | |
| 1490 | ✗ | txt := underscorePath(txt, i_name); | |
| 1491 | ✗ | txt := Tpl.softNewLine(txt); | |
| 1492 | ✗ | txt := Tpl.writeText(txt, l_returnType); | |
| 1493 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" boxptr_")); | |
| 1494 | ✗ | txt := underscorePath(txt, i_name); | |
| 1495 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("(")); | |
| 1496 | ✗ | txt := Tpl.writeText(txt, l_arguments); | |
| 1497 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 1498 | ")\n", | ||
| 1499 | "{\n" | ||
| 1500 | }, true)); | ||
| 1501 | ✗ | txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(4)); | |
| 1502 | ✗ | txt := Tpl.writeText(txt, l_unboxDefs); | |
| 1503 | ✗ | txt := Tpl.softNewLine(txt); | |
| 1504 | ✗ | txt := Tpl.writeText(txt, l_callOutDefs); | |
| 1505 | ✗ | txt := Tpl.softNewLine(txt); | |
| 1506 | ✗ | txt := Tpl.writeText(txt, l_boxDefs); | |
| 1507 | ✗ | txt := Tpl.softNewLine(txt); | |
| 1508 | ✗ | txt := Tpl.writeText(txt, l_unboxes); | |
| 1509 | ✗ | txt := Tpl.softNewLine(txt); | |
| 1510 | ✗ | txt := Tpl.writeText(txt, l_callretval); | |
| 1511 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("omc_")); | |
| 1512 | ✗ | txt := underscorePath(txt, i_name); | |
| 1513 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("(")); | |
| 1514 | ✗ | txt := Tpl.writeText(txt, l_callvars); | |
| 1515 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_LINE(");\n")); | |
| 1516 | ✗ | txt := Tpl.writeText(txt, l_boxes); | |
| 1517 | ✗ | txt := Tpl.softNewLine(txt); | |
| 1518 | ✗ | ret_22 := listEmpty(i_outputs); | |
| 1519 | ✗ | txt := fun_93(txt, ret_22, i_outputs); | |
| 1520 | ✗ | txt := Tpl.softNewLine(txt); | |
| 1521 | ✗ | txt := Tpl.popBlock(txt); | |
| 1522 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("}")); | |
| 1523 | then txt; | ||
| 1524 | |||
| 1525 | case ( txt, | ||
| 1526 | _ ) | ||
| 1527 | then txt; | ||
| 1528 | end match; | ||
| 1529 | end genBoxPtrFunction; | ||
| 1530 | |||
| 1531 | protected function lm_95 | ||
| 1532 | input output Tpl.Text txt; | ||
| 1533 | input list<MidCode.Var> items; | ||
| 1534 | input MidCode.Function a_fn; | ||
| 1535 | algorithm | ||
| 1536 | ✗ | for lstElt_95 in items loop | |
| 1537 | txt := match lstElt_95 | ||
| 1538 | local | ||
| 1539 | MidCode.Var i_local; | ||
| 1540 | |||
| 1541 | case i_local | ||
| 1542 | algorithm | ||
| 1543 | ✗ | txt := genLocalDecl(txt, a_fn, i_local); | |
| 1544 | ✗ | txt := Tpl.nextIter(txt); | |
| 1545 | then txt; | ||
| 1546 | end match; | ||
| 1547 | end for; | ||
| 1548 | end lm_95; | ||
| 1549 | |||
| 1550 | protected function lm_96 | ||
| 1551 | input output Tpl.Text txt; | ||
| 1552 | input list<MidCode.VarBuf> items; | ||
| 1553 | input MidCode.Function a_fn; | ||
| 1554 | algorithm | ||
| 1555 | ✗ | for lstElt_96 in items loop | |
| 1556 | txt := match lstElt_96 | ||
| 1557 | local | ||
| 1558 | MidCode.VarBuf i_local; | ||
| 1559 | |||
| 1560 | case i_local | ||
| 1561 | algorithm | ||
| 1562 | ✗ | txt := genLocalBufDecl(txt, a_fn, i_local); | |
| 1563 | ✗ | txt := Tpl.nextIter(txt); | |
| 1564 | then txt; | ||
| 1565 | end match; | ||
| 1566 | end for; | ||
| 1567 | end lm_96; | ||
| 1568 | |||
| 1569 | protected function lm_97 | ||
| 1570 | input output Tpl.Text txt; | ||
| 1571 | input list<MidCode.VarBufPtr> items; | ||
| 1572 | input MidCode.Function a_fn; | ||
| 1573 | algorithm | ||
| 1574 | ✗ | for lstElt_97 in items loop | |
| 1575 | txt := match lstElt_97 | ||
| 1576 | local | ||
| 1577 | MidCode.VarBufPtr i_local; | ||
| 1578 | |||
| 1579 | case i_local | ||
| 1580 | algorithm | ||
| 1581 | ✗ | txt := genLocalBufPtrDecl(txt, a_fn, i_local); | |
| 1582 | ✗ | txt := Tpl.nextIter(txt); | |
| 1583 | then txt; | ||
| 1584 | end match; | ||
| 1585 | end for; | ||
| 1586 | end lm_97; | ||
| 1587 | |||
| 1588 | public function genLocalDecls | ||
| 1589 | input Tpl.Text txt; | ||
| 1590 | input MidCode.Function a_fn; | ||
| 1591 | input list<MidCode.Var> a_locals; | ||
| 1592 | input list<MidCode.VarBuf> a_localBufs; | ||
| 1593 | input list<MidCode.VarBufPtr> a_localBufPtrs; | ||
| 1594 | |||
| 1595 | output Tpl.Text out_txt; | ||
| 1596 | algorithm | ||
| 1597 | ✗ | 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())); | |
| 1598 | ✗ | out_txt := lm_95(out_txt, a_locals, a_fn); | |
| 1599 | ✗ | out_txt := Tpl.popIter(out_txt); | |
| 1600 | ✗ | out_txt := Tpl.softNewLine(out_txt); | |
| 1601 | ✗ | 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())); | |
| 1602 | ✗ | out_txt := lm_96(out_txt, a_localBufs, a_fn); | |
| 1603 | ✗ | out_txt := Tpl.popIter(out_txt); | |
| 1604 | ✗ | out_txt := Tpl.softNewLine(out_txt); | |
| 1605 | ✗ | 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())); | |
| 1606 | ✗ | out_txt := lm_97(out_txt, a_localBufPtrs, a_fn); | |
| 1607 | ✗ | out_txt := Tpl.popIter(out_txt); | |
| 1608 | end genLocalDecls; | ||
| 1609 | |||
| 1610 | protected function fun_99 | ||
| 1611 | input Tpl.Text in_txt; | ||
| 1612 | input MidCode.Var in_a_var; | ||
| 1613 | |||
| 1614 | output Tpl.Text out_txt; | ||
| 1615 | algorithm | ||
| 1616 | out_txt := | ||
| 1617 | match(in_txt, in_a_var) | ||
| 1618 | local | ||
| 1619 | Tpl.Text txt; | ||
| 1620 | |||
| 1621 | case ( txt, | ||
| 1622 | MidCode.VAR(volatile = true) ) | ||
| 1623 | algorithm | ||
| 1624 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("volatile ")); | |
| 1625 | then txt; | ||
| 1626 | |||
| 1627 | case ( txt, | ||
| 1628 | _ ) | ||
| 1629 | then txt; | ||
| 1630 | end match; | ||
| 1631 | end fun_99; | ||
| 1632 | |||
| 1633 | public function genLocalDecl | ||
| 1634 | input Tpl.Text txt; | ||
| 1635 | input MidCode.Function a_fn; | ||
| 1636 | input MidCode.Var a_var; | ||
| 1637 | |||
| 1638 | output Tpl.Text out_txt; | ||
| 1639 | algorithm | ||
| 1640 | ✗ | out_txt := fun_99(txt, a_var); | |
| 1641 | ✗ | out_txt := genVarType(out_txt, a_var); | |
| 1642 | ✗ | out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING(" ")); | |
| 1643 | ✗ | out_txt := genVarName(out_txt, a_var); | |
| 1644 | ✗ | out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING(";")); | |
| 1645 | end genLocalDecl; | ||
| 1646 | |||
| 1647 | public function genLocalBufDecl | ||
| 1648 | input Tpl.Text txt; | ||
| 1649 | input MidCode.Function a_fn; | ||
| 1650 | input MidCode.VarBuf a_var; | ||
| 1651 | |||
| 1652 | output Tpl.Text out_txt; | ||
| 1653 | algorithm | ||
| 1654 | ✗ | out_txt := Tpl.writeTok(txt, Tpl.ST_STRING("jmp_buf ")); | |
| 1655 | ✗ | out_txt := genVarBufName(out_txt, a_var); | |
| 1656 | ✗ | out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING(";")); | |
| 1657 | end genLocalBufDecl; | ||
| 1658 | |||
| 1659 | public function genLocalBufPtrDecl | ||
| 1660 | input Tpl.Text txt; | ||
| 1661 | input MidCode.Function a_fn; | ||
| 1662 | input MidCode.VarBufPtr a_var; | ||
| 1663 | |||
| 1664 | output Tpl.Text out_txt; | ||
| 1665 | algorithm | ||
| 1666 | ✗ | out_txt := Tpl.writeTok(txt, Tpl.ST_STRING("jmp_buf *")); | |
| 1667 | ✗ | out_txt := genVarBufPtrName(out_txt, a_var); | |
| 1668 | ✗ | out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING(";")); | |
| 1669 | end genLocalBufPtrDecl; | ||
| 1670 | |||
| 1671 | public function genEntry | ||
| 1672 | input Tpl.Text in_txt; | ||
| 1673 | input MidCode.Function in_a_fn; | ||
| 1674 | |||
| 1675 | output Tpl.Text out_txt; | ||
| 1676 | algorithm | ||
| 1677 | out_txt := | ||
| 1678 | match(in_txt, in_a_fn) | ||
| 1679 | local | ||
| 1680 | Tpl.Text txt; | ||
| 1681 | Integer i_entryId; | ||
| 1682 | |||
| 1683 | case ( txt, | ||
| 1684 | MidCode.FUNCTION(entryId = i_entryId) ) | ||
| 1685 | algorithm | ||
| 1686 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("goto ")); | |
| 1687 | ✗ | txt := genLabel(txt, i_entryId); | |
| 1688 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(";")); | |
| 1689 | then txt; | ||
| 1690 | |||
| 1691 | case ( txt, | ||
| 1692 | _ ) | ||
| 1693 | then txt; | ||
| 1694 | end match; | ||
| 1695 | end genEntry; | ||
| 1696 | |||
| 1697 | protected function fun_104 | ||
| 1698 | input Tpl.Text in_txt; | ||
| 1699 | input Boolean in_mArg; | ||
| 1700 | input list<MidCode.Var> in_a_outputs; | ||
| 1701 | |||
| 1702 | output Tpl.Text out_txt; | ||
| 1703 | algorithm | ||
| 1704 | out_txt := | ||
| 1705 | match(in_txt, in_mArg, in_a_outputs) | ||
| 1706 | local | ||
| 1707 | Tpl.Text txt; | ||
| 1708 | list<MidCode.Var> a_outputs; | ||
| 1709 | MidCode.Var ret_0; | ||
| 1710 | |||
| 1711 | case ( txt, | ||
| 1712 | false, | ||
| 1713 | a_outputs ) | ||
| 1714 | algorithm | ||
| 1715 | ✗ | ret_0 := listHead(a_outputs); | |
| 1716 | ✗ | txt := genVarName(txt, ret_0); | |
| 1717 | then txt; | ||
| 1718 | |||
| 1719 | case ( txt, | ||
| 1720 | _, | ||
| 1721 | _ ) | ||
| 1722 | then txt; | ||
| 1723 | end match; | ||
| 1724 | end fun_104; | ||
| 1725 | |||
| 1726 | protected function lm_105 | ||
| 1727 | input output Tpl.Text txt; | ||
| 1728 | input list<MidCode.Var> items; | ||
| 1729 | algorithm | ||
| 1730 | ✗ | for lstElt_105 in items loop | |
| 1731 | txt := match lstElt_105 | ||
| 1732 | local | ||
| 1733 | MidCode.Var i_v; | ||
| 1734 | Tpl.Text l_outPtrName; | ||
| 1735 | |||
| 1736 | case i_v | ||
| 1737 | algorithm | ||
| 1738 | ✗ | l_outPtrName := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("outPtr_")); | |
| 1739 | ✗ | l_outPtrName := genVarName(l_outPtrName, i_v); | |
| 1740 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("if (")); | |
| 1741 | ✗ | txt := Tpl.writeText(txt, l_outPtrName); | |
| 1742 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_LINE(" != NULL)\n")); | |
| 1743 | ✗ | txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2)); | |
| 1744 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("*")); | |
| 1745 | ✗ | txt := Tpl.writeText(txt, l_outPtrName); | |
| 1746 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = ")); | |
| 1747 | ✗ | txt := genVarName(txt, i_v); | |
| 1748 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(";")); | |
| 1749 | ✗ | txt := Tpl.popBlock(txt); | |
| 1750 | ✗ | txt := Tpl.nextIter(txt); | |
| 1751 | then txt; | ||
| 1752 | end match; | ||
| 1753 | end for; | ||
| 1754 | end lm_105; | ||
| 1755 | |||
| 1756 | public function genExit | ||
| 1757 | input Tpl.Text in_txt; | ||
| 1758 | input MidCode.Function in_a_fn; | ||
| 1759 | |||
| 1760 | output Tpl.Text out_txt; | ||
| 1761 | algorithm | ||
| 1762 | out_txt := | ||
| 1763 | match(in_txt, in_a_fn) | ||
| 1764 | local | ||
| 1765 | Tpl.Text txt; | ||
| 1766 | Integer i_exitId; | ||
| 1767 | list<MidCode.Var> i_outputs; | ||
| 1768 | list<MidCode.Var> ret_2; | ||
| 1769 | Boolean ret_1; | ||
| 1770 | Tpl.Text l_returnString; | ||
| 1771 | |||
| 1772 | case ( txt, | ||
| 1773 | MidCode.FUNCTION(outputs = i_outputs, exitId = i_exitId) ) | ||
| 1774 | algorithm | ||
| 1775 | ✗ | ret_1 := listEmpty(i_outputs); | |
| 1776 | ✗ | l_returnString := fun_104(Tpl.emptyTxt, ret_1, i_outputs); | |
| 1777 | ✗ | txt := genLabel(txt, i_exitId); | |
| 1778 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_LINE(": // exit block\n")); | |
| 1779 | ✗ | txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2)); | |
| 1780 | ✗ | ret_2 := List.restOrEmpty(i_outputs); | |
| 1781 | ✗ | 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())); | |
| 1782 | ✗ | txt := lm_105(txt, ret_2); | |
| 1783 | ✗ | txt := Tpl.popIter(txt); | |
| 1784 | ✗ | txt := Tpl.softNewLine(txt); | |
| 1785 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("return ")); | |
| 1786 | ✗ | txt := Tpl.writeText(txt, l_returnString); | |
| 1787 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(";")); | |
| 1788 | ✗ | txt := Tpl.popBlock(txt); | |
| 1789 | then txt; | ||
| 1790 | |||
| 1791 | case ( txt, | ||
| 1792 | _ ) | ||
| 1793 | then txt; | ||
| 1794 | end match; | ||
| 1795 | end genExit; | ||
| 1796 | |||
| 1797 | protected function lm_107 | ||
| 1798 | input output Tpl.Text txt; | ||
| 1799 | input list<MidCode.Block> items; | ||
| 1800 | input MidCode.Function a_fn; | ||
| 1801 | algorithm | ||
| 1802 | ✗ | for lstElt_107 in items loop | |
| 1803 | txt := match lstElt_107 | ||
| 1804 | local | ||
| 1805 | MidCode.Block i_block; | ||
| 1806 | |||
| 1807 | case i_block | ||
| 1808 | algorithm | ||
| 1809 | ✗ | txt := genBlock(txt, a_fn, i_block); | |
| 1810 | ✗ | txt := Tpl.nextIter(txt); | |
| 1811 | then txt; | ||
| 1812 | end match; | ||
| 1813 | end for; | ||
| 1814 | end lm_107; | ||
| 1815 | |||
| 1816 | public function genBlocks | ||
| 1817 | input Tpl.Text txt; | ||
| 1818 | input MidCode.Function a_fn; | ||
| 1819 | input list<MidCode.Block> a_body; | ||
| 1820 | |||
| 1821 | output Tpl.Text out_txt; | ||
| 1822 | algorithm | ||
| 1823 | ✗ | 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())); | |
| 1824 | ✗ | out_txt := lm_107(out_txt, a_body, a_fn); | |
| 1825 | ✗ | out_txt := Tpl.popIter(out_txt); | |
| 1826 | end genBlocks; | ||
| 1827 | |||
| 1828 | protected function lm_109 | ||
| 1829 | input output Tpl.Text txt; | ||
| 1830 | input list<MidCode.Stmt> items; | ||
| 1831 | input MidCode.Function a_fn; | ||
| 1832 | algorithm | ||
| 1833 | ✗ | for lstElt_109 in items loop | |
| 1834 | txt := match lstElt_109 | ||
| 1835 | local | ||
| 1836 | MidCode.Stmt i_stmt; | ||
| 1837 | |||
| 1838 | case i_stmt | ||
| 1839 | algorithm | ||
| 1840 | ✗ | txt := genStmt(txt, a_fn, i_stmt); | |
| 1841 | ✗ | txt := Tpl.nextIter(txt); | |
| 1842 | then txt; | ||
| 1843 | end match; | ||
| 1844 | end for; | ||
| 1845 | end lm_109; | ||
| 1846 | |||
| 1847 | protected function fun_110 | ||
| 1848 | input Tpl.Text in_txt; | ||
| 1849 | input MidCode.Block in_a_block; | ||
| 1850 | input MidCode.Function in_a_fn; | ||
| 1851 | |||
| 1852 | output Tpl.Text out_txt; | ||
| 1853 | algorithm | ||
| 1854 | out_txt := | ||
| 1855 | match(in_txt, in_a_block, in_a_fn) | ||
| 1856 | local | ||
| 1857 | Tpl.Text txt; | ||
| 1858 | MidCode.Function a_fn; | ||
| 1859 | MidCode.Terminator i_terminator; | ||
| 1860 | list<MidCode.Stmt> i_stmts; | ||
| 1861 | Integer i_id; | ||
| 1862 | |||
| 1863 | case ( txt, | ||
| 1864 | MidCode.BLOCK(id = i_id, stmts = i_stmts, terminator = i_terminator), | ||
| 1865 | a_fn ) | ||
| 1866 | algorithm | ||
| 1867 | ✗ | txt := genLabel(txt, i_id); | |
| 1868 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_LINE(":\n")); | |
| 1869 | ✗ | txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2)); | |
| 1870 | ✗ | 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())); | |
| 1871 | ✗ | txt := lm_109(txt, i_stmts, a_fn); | |
| 1872 | ✗ | txt := Tpl.popIter(txt); | |
| 1873 | ✗ | txt := Tpl.softNewLine(txt); | |
| 1874 | ✗ | txt := genTerminator(txt, a_fn, i_terminator); | |
| 1875 | ✗ | txt := Tpl.popBlock(txt); | |
| 1876 | then txt; | ||
| 1877 | |||
| 1878 | case ( txt, | ||
| 1879 | _, | ||
| 1880 | _ ) | ||
| 1881 | then txt; | ||
| 1882 | end match; | ||
| 1883 | end fun_110; | ||
| 1884 | |||
| 1885 | public function genBlock | ||
| 1886 | input Tpl.Text txt; | ||
| 1887 | input MidCode.Function a_fn; | ||
| 1888 | input MidCode.Block a_block; | ||
| 1889 | |||
| 1890 | output Tpl.Text out_txt; | ||
| 1891 | algorithm | ||
| 1892 | ✗ | out_txt := fun_110(txt, a_block, a_fn); | |
| 1893 | end genBlock; | ||
| 1894 | |||
| 1895 | public function genLabel | ||
| 1896 | input Tpl.Text txt; | ||
| 1897 | input Integer a_i; | ||
| 1898 | |||
| 1899 | output Tpl.Text out_txt; | ||
| 1900 | algorithm | ||
| 1901 | ✗ | out_txt := Tpl.writeTok(txt, Tpl.ST_STRING("label_")); | |
| 1902 | ✗ | out_txt := Tpl.writeStr(out_txt, intString(a_i)); | |
| 1903 | end genLabel; | ||
| 1904 | |||
| 1905 | public function genVarName | ||
| 1906 | input Tpl.Text in_txt; | ||
| 1907 | input MidCode.Var in_a_v; | ||
| 1908 | |||
| 1909 | output Tpl.Text out_txt; | ||
| 1910 | algorithm | ||
| 1911 | out_txt := | ||
| 1912 | match(in_txt, in_a_v) | ||
| 1913 | local | ||
| 1914 | Tpl.Text txt; | ||
| 1915 | String i_name; | ||
| 1916 | |||
| 1917 | case ( txt, | ||
| 1918 | MidCode.VAR(name = i_name) ) | ||
| 1919 | algorithm | ||
| 1920 | ✗ | txt := Tpl.writeStr(txt, i_name); | |
| 1921 | then txt; | ||
| 1922 | |||
| 1923 | case ( txt, | ||
| 1924 | _ ) | ||
| 1925 | then txt; | ||
| 1926 | end match; | ||
| 1927 | end genVarName; | ||
| 1928 | |||
| 1929 | public function genVarBufName | ||
| 1930 | input Tpl.Text in_txt; | ||
| 1931 | input MidCode.VarBuf in_a_v; | ||
| 1932 | |||
| 1933 | output Tpl.Text out_txt; | ||
| 1934 | algorithm | ||
| 1935 | out_txt := | ||
| 1936 | match(in_txt, in_a_v) | ||
| 1937 | local | ||
| 1938 | Tpl.Text txt; | ||
| 1939 | String i_name; | ||
| 1940 | |||
| 1941 | case ( txt, | ||
| 1942 | MidCode.VARBUF(name = i_name) ) | ||
| 1943 | algorithm | ||
| 1944 | ✗ | txt := Tpl.writeStr(txt, i_name); | |
| 1945 | then txt; | ||
| 1946 | |||
| 1947 | case ( txt, | ||
| 1948 | _ ) | ||
| 1949 | then txt; | ||
| 1950 | end match; | ||
| 1951 | end genVarBufName; | ||
| 1952 | |||
| 1953 | public function genVarBufPtrName | ||
| 1954 | input Tpl.Text in_txt; | ||
| 1955 | input MidCode.VarBufPtr in_a_v; | ||
| 1956 | |||
| 1957 | output Tpl.Text out_txt; | ||
| 1958 | algorithm | ||
| 1959 | out_txt := | ||
| 1960 | match(in_txt, in_a_v) | ||
| 1961 | local | ||
| 1962 | Tpl.Text txt; | ||
| 1963 | String i_name; | ||
| 1964 | |||
| 1965 | case ( txt, | ||
| 1966 | MidCode.VARBUFPTR(name = i_name) ) | ||
| 1967 | algorithm | ||
| 1968 | ✗ | txt := Tpl.writeStr(txt, i_name); | |
| 1969 | then txt; | ||
| 1970 | |||
| 1971 | case ( txt, | ||
| 1972 | _ ) | ||
| 1973 | then txt; | ||
| 1974 | end match; | ||
| 1975 | end genVarBufPtrName; | ||
| 1976 | |||
| 1977 | protected function fun_116 | ||
| 1978 | input Tpl.Text in_txt; | ||
| 1979 | input MidCode.Stmt in_a_stmt; | ||
| 1980 | |||
| 1981 | output Tpl.Text out_txt; | ||
| 1982 | algorithm | ||
| 1983 | out_txt := | ||
| 1984 | match(in_txt, in_a_stmt) | ||
| 1985 | local | ||
| 1986 | Tpl.Text txt; | ||
| 1987 | MidCode.RValue i_rvalue; | ||
| 1988 | String i_dest__name; | ||
| 1989 | |||
| 1990 | case ( txt, | ||
| 1991 | MidCode.NOP() ) | ||
| 1992 | algorithm | ||
| 1993 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("; // NOP")); | |
| 1994 | then txt; | ||
| 1995 | |||
| 1996 | case ( txt, | ||
| 1997 | MidCode.ASSIGN(dest = MidCode.VAR(name = i_dest__name, ty = _), src = i_rvalue) ) | ||
| 1998 | algorithm | ||
| 1999 | ✗ | txt := Tpl.writeStr(txt, i_dest__name); | |
| 2000 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = ")); | |
| 2001 | ✗ | txt := genRValue(txt, i_rvalue); | |
| 2002 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(";")); | |
| 2003 | then txt; | ||
| 2004 | |||
| 2005 | case ( txt, | ||
| 2006 | _ ) | ||
| 2007 | then txt; | ||
| 2008 | end match; | ||
| 2009 | end fun_116; | ||
| 2010 | |||
| 2011 | public function genStmt | ||
| 2012 | input Tpl.Text txt; | ||
| 2013 | input MidCode.Function a_fn; | ||
| 2014 | input MidCode.Stmt a_stmt; | ||
| 2015 | |||
| 2016 | output Tpl.Text out_txt; | ||
| 2017 | algorithm | ||
| 2018 | ✗ | out_txt := fun_116(txt, a_stmt); | |
| 2019 | end genStmt; | ||
| 2020 | |||
| 2021 | protected function fun_118 | ||
| 2022 | input Tpl.Text in_txt; | ||
| 2023 | input Boolean in_a_value; | ||
| 2024 | |||
| 2025 | output Tpl.Text out_txt; | ||
| 2026 | algorithm | ||
| 2027 | out_txt := | ||
| 2028 | match(in_txt, in_a_value) | ||
| 2029 | local | ||
| 2030 | Tpl.Text txt; | ||
| 2031 | |||
| 2032 | case ( txt, | ||
| 2033 | false ) | ||
| 2034 | algorithm | ||
| 2035 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("0")); | |
| 2036 | then txt; | ||
| 2037 | |||
| 2038 | case ( txt, | ||
| 2039 | _ ) | ||
| 2040 | algorithm | ||
| 2041 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("1")); | |
| 2042 | then txt; | ||
| 2043 | end match; | ||
| 2044 | end fun_118; | ||
| 2045 | |||
| 2046 | protected function lm_119 | ||
| 2047 | input output Tpl.Text txt; | ||
| 2048 | input list<MidCode.Var> items; | ||
| 2049 | algorithm | ||
| 2050 | ✗ | for lstElt_119 in items loop | |
| 2051 | txt := match lstElt_119 | ||
| 2052 | local | ||
| 2053 | MidCode.Var i_element; | ||
| 2054 | |||
| 2055 | case i_element | ||
| 2056 | algorithm | ||
| 2057 | ✗ | txt := genVarName(txt, i_element); | |
| 2058 | ✗ | txt := Tpl.nextIter(txt); | |
| 2059 | then txt; | ||
| 2060 | end match; | ||
| 2061 | end for; | ||
| 2062 | end lm_119; | ||
| 2063 | |||
| 2064 | protected function smf_120 | ||
| 2065 | input Tpl.Text in_txt; | ||
| 2066 | input Tpl.Text in_it; | ||
| 2067 | |||
| 2068 | output Tpl.Text out_txt; | ||
| 2069 | algorithm | ||
| 2070 | out_txt := | ||
| 2071 | match(in_txt, in_it) | ||
| 2072 | local | ||
| 2073 | Tpl.Text txt; | ||
| 2074 | Tpl.Text i_it; | ||
| 2075 | |||
| 2076 | case ( txt, | ||
| 2077 | i_it ) | ||
| 2078 | algorithm | ||
| 2079 | ✗ | txt := Tpl.writeText(txt, i_it); | |
| 2080 | ✗ | txt := Tpl.nextIter(txt); | |
| 2081 | then txt; | ||
| 2082 | end match; | ||
| 2083 | end smf_120; | ||
| 2084 | |||
| 2085 | protected function smf_121 | ||
| 2086 | input Tpl.Text in_txt; | ||
| 2087 | input Tpl.Text in_it; | ||
| 2088 | |||
| 2089 | output Tpl.Text out_txt; | ||
| 2090 | algorithm | ||
| 2091 | out_txt := | ||
| 2092 | match(in_txt, in_it) | ||
| 2093 | local | ||
| 2094 | Tpl.Text txt; | ||
| 2095 | Tpl.Text i_it; | ||
| 2096 | |||
| 2097 | case ( txt, | ||
| 2098 | i_it ) | ||
| 2099 | algorithm | ||
| 2100 | ✗ | txt := Tpl.writeText(txt, i_it); | |
| 2101 | ✗ | txt := Tpl.nextIter(txt); | |
| 2102 | then txt; | ||
| 2103 | end match; | ||
| 2104 | end smf_121; | ||
| 2105 | |||
| 2106 | protected function smf_122 | ||
| 2107 | input Tpl.Text in_txt; | ||
| 2108 | input Tpl.Text in_it; | ||
| 2109 | |||
| 2110 | output Tpl.Text out_txt; | ||
| 2111 | algorithm | ||
| 2112 | out_txt := | ||
| 2113 | match(in_txt, in_it) | ||
| 2114 | local | ||
| 2115 | Tpl.Text txt; | ||
| 2116 | Tpl.Text i_it; | ||
| 2117 | |||
| 2118 | case ( txt, | ||
| 2119 | i_it ) | ||
| 2120 | algorithm | ||
| 2121 | ✗ | txt := Tpl.writeText(txt, i_it); | |
| 2122 | ✗ | txt := Tpl.nextIter(txt); | |
| 2123 | then txt; | ||
| 2124 | end match; | ||
| 2125 | end smf_122; | ||
| 2126 | |||
| 2127 | protected function smf_123 | ||
| 2128 | input Tpl.Text in_txt; | ||
| 2129 | input Tpl.Text in_it; | ||
| 2130 | |||
| 2131 | output Tpl.Text out_txt; | ||
| 2132 | algorithm | ||
| 2133 | out_txt := | ||
| 2134 | match(in_txt, in_it) | ||
| 2135 | local | ||
| 2136 | Tpl.Text txt; | ||
| 2137 | Tpl.Text i_it; | ||
| 2138 | |||
| 2139 | case ( txt, | ||
| 2140 | i_it ) | ||
| 2141 | algorithm | ||
| 2142 | ✗ | txt := Tpl.writeText(txt, i_it); | |
| 2143 | ✗ | txt := Tpl.nextIter(txt); | |
| 2144 | then txt; | ||
| 2145 | end match; | ||
| 2146 | end smf_123; | ||
| 2147 | |||
| 2148 | protected function smf_124 | ||
| 2149 | input Tpl.Text in_txt; | ||
| 2150 | input Tpl.Text in_it; | ||
| 2151 | |||
| 2152 | output Tpl.Text out_txt; | ||
| 2153 | algorithm | ||
| 2154 | out_txt := | ||
| 2155 | match(in_txt, in_it) | ||
| 2156 | local | ||
| 2157 | Tpl.Text txt; | ||
| 2158 | Tpl.Text i_it; | ||
| 2159 | |||
| 2160 | case ( txt, | ||
| 2161 | i_it ) | ||
| 2162 | algorithm | ||
| 2163 | ✗ | txt := Tpl.writeText(txt, i_it); | |
| 2164 | ✗ | txt := Tpl.nextIter(txt); | |
| 2165 | then txt; | ||
| 2166 | end match; | ||
| 2167 | end smf_124; | ||
| 2168 | |||
| 2169 | protected function smf_125 | ||
| 2170 | input Tpl.Text in_txt; | ||
| 2171 | input Tpl.Text in_it; | ||
| 2172 | |||
| 2173 | output Tpl.Text out_txt; | ||
| 2174 | algorithm | ||
| 2175 | out_txt := | ||
| 2176 | match(in_txt, in_it) | ||
| 2177 | local | ||
| 2178 | Tpl.Text txt; | ||
| 2179 | Tpl.Text i_it; | ||
| 2180 | |||
| 2181 | case ( txt, | ||
| 2182 | i_it ) | ||
| 2183 | algorithm | ||
| 2184 | ✗ | txt := Tpl.writeText(txt, i_it); | |
| 2185 | ✗ | txt := Tpl.nextIter(txt); | |
| 2186 | then txt; | ||
| 2187 | end match; | ||
| 2188 | end smf_125; | ||
| 2189 | |||
| 2190 | protected function smf_126 | ||
| 2191 | input Tpl.Text in_txt; | ||
| 2192 | input Tpl.Text in_it; | ||
| 2193 | |||
| 2194 | output Tpl.Text out_txt; | ||
| 2195 | algorithm | ||
| 2196 | out_txt := | ||
| 2197 | match(in_txt, in_it) | ||
| 2198 | local | ||
| 2199 | Tpl.Text txt; | ||
| 2200 | Tpl.Text i_it; | ||
| 2201 | |||
| 2202 | case ( txt, | ||
| 2203 | i_it ) | ||
| 2204 | algorithm | ||
| 2205 | ✗ | txt := Tpl.writeText(txt, i_it); | |
| 2206 | ✗ | txt := Tpl.nextIter(txt); | |
| 2207 | then txt; | ||
| 2208 | end match; | ||
| 2209 | end smf_126; | ||
| 2210 | |||
| 2211 | protected function fun_127 | ||
| 2212 | input Tpl.Text in_txt; | ||
| 2213 | input DAE.Type in_a_ty; | ||
| 2214 | input Tpl.Text in_a_elementargs; | ||
| 2215 | input Tpl.Text in_a_metatypeCtor; | ||
| 2216 | input Tpl.Text in_a_metatypeSlots; | ||
| 2217 | |||
| 2218 | output Tpl.Text out_txt; | ||
| 2219 | algorithm | ||
| 2220 | out_txt := | ||
| 2221 | match(in_txt, in_a_ty, in_a_elementargs, in_a_metatypeCtor, in_a_metatypeSlots) | ||
| 2222 | local | ||
| 2223 | Tpl.Text txt; | ||
| 2224 | Tpl.Text a_elementargs; | ||
| 2225 | Tpl.Text a_metatypeCtor; | ||
| 2226 | Tpl.Text a_metatypeSlots; | ||
| 2227 | DAE.Type i_ty; | ||
| 2228 | Tpl.Text txt_2; | ||
| 2229 | Tpl.Text txt_1; | ||
| 2230 | Tpl.Text l_arguments; | ||
| 2231 | |||
| 2232 | case ( txt, | ||
| 2233 | (i_ty as DAE.T_METARECORD(path = _)), | ||
| 2234 | a_elementargs, | ||
| 2235 | a_metatypeCtor, | ||
| 2236 | a_metatypeSlots ) | ||
| 2237 | algorithm | ||
| 2238 | ✗ | txt_1 := Tpl.writeText(Tpl.emptyTxt, a_metatypeSlots); | |
| 2239 | ✗ | txt_1 := Tpl.writeTok(txt_1, Tpl.ST_STRING("+1")); | |
| 2240 | ✗ | txt_2 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("&")); | |
| 2241 | ✗ | txt_2 := genTypeUnderscorePath(txt_2, i_ty); | |
| 2242 | ✗ | txt_2 := Tpl.writeTok(txt_2, Tpl.ST_STRING("__desc")); | |
| 2243 | ✗ | l_arguments := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 2244 | ✗ | l_arguments := smf_120(l_arguments, txt_1); | |
| 2245 | ✗ | l_arguments := smf_121(l_arguments, a_metatypeCtor); | |
| 2246 | ✗ | l_arguments := smf_122(l_arguments, txt_2); | |
| 2247 | ✗ | l_arguments := smf_123(l_arguments, a_elementargs); | |
| 2248 | ✗ | l_arguments := Tpl.popIter(l_arguments); | |
| 2249 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("omc_mk_box(")); | |
| 2250 | ✗ | txt := Tpl.writeText(txt, l_arguments); | |
| 2251 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 2252 | then txt; | ||
| 2253 | |||
| 2254 | case ( txt, | ||
| 2255 | _, | ||
| 2256 | a_elementargs, | ||
| 2257 | a_metatypeCtor, | ||
| 2258 | a_metatypeSlots ) | ||
| 2259 | algorithm | ||
| 2260 | ✗ | l_arguments := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 2261 | ✗ | l_arguments := smf_124(l_arguments, a_metatypeSlots); | |
| 2262 | ✗ | l_arguments := smf_125(l_arguments, a_metatypeCtor); | |
| 2263 | ✗ | l_arguments := smf_126(l_arguments, a_elementargs); | |
| 2264 | ✗ | l_arguments := Tpl.popIter(l_arguments); | |
| 2265 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("omc_mk_box(")); | |
| 2266 | ✗ | txt := Tpl.writeText(txt, l_arguments); | |
| 2267 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 2268 | then txt; | ||
| 2269 | end match; | ||
| 2270 | end fun_127; | ||
| 2271 | |||
| 2272 | public function genRValue | ||
| 2273 | input Tpl.Text in_txt; | ||
| 2274 | input MidCode.RValue in_a_rvalue; | ||
| 2275 | |||
| 2276 | output Tpl.Text out_txt; | ||
| 2277 | algorithm | ||
| 2278 | out_txt := | ||
| 2279 | match(in_txt, in_a_rvalue) | ||
| 2280 | local | ||
| 2281 | Tpl.Text txt; | ||
| 2282 | Integer i_index; | ||
| 2283 | DAE.Type i_ty; | ||
| 2284 | list<MidCode.Var> i_elements; | ||
| 2285 | String i_value_3; | ||
| 2286 | Real i_value_2; | ||
| 2287 | Boolean i_value_1; | ||
| 2288 | Integer i_value; | ||
| 2289 | MidCode.UnaryOp i_op_1; | ||
| 2290 | MidCode.Var i_src; | ||
| 2291 | String i_rsrc__name; | ||
| 2292 | String i_lsrc__name; | ||
| 2293 | MidCode.Var i_rsrc; | ||
| 2294 | MidCode.Var i_lsrc; | ||
| 2295 | MidCode.BinaryOp i_op; | ||
| 2296 | String i_src__name; | ||
| 2297 | Integer ret_5; | ||
| 2298 | Tpl.Text l_elementargs; | ||
| 2299 | Tpl.Text l_metatypeCtor; | ||
| 2300 | Integer ret_2; | ||
| 2301 | Tpl.Text l_metatypeSlots; | ||
| 2302 | String ret_0; | ||
| 2303 | |||
| 2304 | case ( txt, | ||
| 2305 | MidCode.VARIABLE(src = MidCode.VAR(name = i_src__name, ty = _)) ) | ||
| 2306 | algorithm | ||
| 2307 | ✗ | txt := Tpl.writeStr(txt, i_src__name); | |
| 2308 | then txt; | ||
| 2309 | |||
| 2310 | case ( txt, | ||
| 2311 | MidCode.BINARYOP(op = i_op, lsrc = (i_lsrc as MidCode.VAR(name = _, ty = DAE.T_STRING(varLst = _))), rsrc = (i_rsrc as MidCode.VAR(name = _, ty = DAE.T_STRING(varLst = _)))) ) | ||
| 2312 | algorithm | ||
| 2313 | ✗ | txt := genStringBinaryop(txt, i_op, i_lsrc, i_rsrc); | |
| 2314 | then txt; | ||
| 2315 | |||
| 2316 | case ( txt, | ||
| 2317 | MidCode.BINARYOP(op = MidCode.POW(), lsrc = MidCode.VAR(name = i_lsrc__name, ty = _), rsrc = MidCode.VAR(name = i_rsrc__name, ty = _)) ) | ||
| 2318 | algorithm | ||
| 2319 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("pow(")); | |
| 2320 | ✗ | txt := Tpl.writeStr(txt, i_lsrc__name); | |
| 2321 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(", ")); | |
| 2322 | ✗ | txt := Tpl.writeStr(txt, i_rsrc__name); | |
| 2323 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 2324 | then txt; | ||
| 2325 | |||
| 2326 | case ( txt, | ||
| 2327 | MidCode.BINARYOP(op = i_op, lsrc = MidCode.VAR(name = i_lsrc__name, ty = _), rsrc = MidCode.VAR(name = i_rsrc__name, ty = _)) ) | ||
| 2328 | algorithm | ||
| 2329 | ✗ | txt := Tpl.writeStr(txt, i_lsrc__name); | |
| 2330 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" ")); | |
| 2331 | ✗ | txt := binaryopToString(txt, i_op); | |
| 2332 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" ")); | |
| 2333 | ✗ | txt := Tpl.writeStr(txt, i_rsrc__name); | |
| 2334 | then txt; | ||
| 2335 | |||
| 2336 | case ( txt, | ||
| 2337 | MidCode.UNARYOP(op = MidCode.BOX(), src = i_src) ) | ||
| 2338 | algorithm | ||
| 2339 | ✗ | txt := varBox(txt, i_src); | |
| 2340 | then txt; | ||
| 2341 | |||
| 2342 | case ( txt, | ||
| 2343 | MidCode.UNARYOP(op = MidCode.UNBOX(), src = i_src) ) | ||
| 2344 | algorithm | ||
| 2345 | ✗ | txt := varUnbox(txt, i_src); | |
| 2346 | then txt; | ||
| 2347 | |||
| 2348 | case ( txt, | ||
| 2349 | MidCode.UNARYOP(op = i_op_1, src = i_src) ) | ||
| 2350 | algorithm | ||
| 2351 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("(")); | |
| 2352 | ✗ | txt := genVarType(txt, i_src); | |
| 2353 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(") ")); | |
| 2354 | ✗ | txt := unaryopToString(txt, i_op_1); | |
| 2355 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" ")); | |
| 2356 | ✗ | txt := genVarName(txt, i_src); | |
| 2357 | then txt; | ||
| 2358 | |||
| 2359 | case ( txt, | ||
| 2360 | MidCode.LITERALINTEGER(value = i_value) ) | ||
| 2361 | algorithm | ||
| 2362 | ✗ | txt := Tpl.writeStr(txt, intString(i_value)); | |
| 2363 | then txt; | ||
| 2364 | |||
| 2365 | case ( txt, | ||
| 2366 | MidCode.LITERALBOOLEAN(value = i_value_1) ) | ||
| 2367 | algorithm | ||
| 2368 | ✗ | txt := fun_118(txt, i_value_1); | |
| 2369 | then txt; | ||
| 2370 | |||
| 2371 | case ( txt, | ||
| 2372 | MidCode.LITERALREAL(value = i_value_2) ) | ||
| 2373 | algorithm | ||
| 2374 | ✗ | txt := Tpl.writeStr(txt, realString(i_value_2)); | |
| 2375 | then txt; | ||
| 2376 | |||
| 2377 | case ( txt, | ||
| 2378 | MidCode.LITERALSTRING(value = i_value_3) ) | ||
| 2379 | algorithm | ||
| 2380 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("mmc_mk_scon(\"")); | |
| 2381 | ✗ | ret_0 := Util.escapeModelicaStringToCString(i_value_3); | |
| 2382 | ✗ | txt := Tpl.writeStr(txt, ret_0); | |
| 2383 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\")")); | |
| 2384 | then txt; | ||
| 2385 | |||
| 2386 | case ( txt, | ||
| 2387 | MidCode.LITERALMETATYPE(elements = i_elements, ty = i_ty) ) | ||
| 2388 | algorithm | ||
| 2389 | ✗ | ret_2 := listLength(i_elements); | |
| 2390 | ✗ | l_metatypeSlots := Tpl.writeStr(Tpl.emptyTxt, intString(ret_2)); | |
| 2391 | ✗ | l_metatypeCtor := genTypeCtorIndex(Tpl.emptyTxt, i_elements, i_ty); | |
| 2392 | ✗ | l_elementargs := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 2393 | ✗ | l_elementargs := lm_119(l_elementargs, i_elements); | |
| 2394 | ✗ | l_elementargs := Tpl.popIter(l_elementargs); | |
| 2395 | ✗ | txt := fun_127(txt, i_ty, l_elementargs, l_metatypeCtor, l_metatypeSlots); | |
| 2396 | then txt; | ||
| 2397 | |||
| 2398 | case ( txt, | ||
| 2399 | MidCode.METAFIELD(src = i_src, index = i_index, ty = _) ) | ||
| 2400 | algorithm | ||
| 2401 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("OMC_BOX_FIELD(")); | |
| 2402 | ✗ | txt := genVarName(txt, i_src); | |
| 2403 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(", ")); | |
| 2404 | ✗ | ret_5 := intAdd(i_index, 1); | |
| 2405 | ✗ | txt := Tpl.writeStr(txt, intString(ret_5)); | |
| 2406 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 2407 | then txt; | ||
| 2408 | |||
| 2409 | case ( txt, | ||
| 2410 | MidCode.UNIONTYPEVARIANT(src = i_src) ) | ||
| 2411 | algorithm | ||
| 2412 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("(MMC_HDRCTOR(MMC_GETHDR(")); | |
| 2413 | ✗ | txt := genVarName(txt, i_src); | |
| 2414 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")) - 3)")); | |
| 2415 | then txt; | ||
| 2416 | |||
| 2417 | case ( txt, | ||
| 2418 | MidCode.ISSOME(src = i_src) ) | ||
| 2419 | algorithm | ||
| 2420 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("(0==MMC_HDRSLOTS(MMC_GETHDR(")); | |
| 2421 | ✗ | txt := genVarName(txt, i_src); | |
| 2422 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")) ? 0 : 1)")); | |
| 2423 | then txt; | ||
| 2424 | |||
| 2425 | case ( txt, | ||
| 2426 | MidCode.ISCONS(src = i_src) ) | ||
| 2427 | algorithm | ||
| 2428 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("(MMC_GETHDR(")); | |
| 2429 | ✗ | txt := genVarName(txt, i_src); | |
| 2430 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(") == MMC_CONSHDR)")); | |
| 2431 | then txt; | ||
| 2432 | |||
| 2433 | case ( txt, | ||
| 2434 | _ ) | ||
| 2435 | algorithm | ||
| 2436 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("notimplemented")); | |
| 2437 | then txt; | ||
| 2438 | end match; | ||
| 2439 | end genRValue; | ||
| 2440 | |||
| 2441 | public function binaryopToString | ||
| 2442 | input Tpl.Text in_txt; | ||
| 2443 | input MidCode.BinaryOp in_a_op; | ||
| 2444 | |||
| 2445 | output Tpl.Text out_txt; | ||
| 2446 | algorithm | ||
| 2447 | out_txt := | ||
| 2448 | match(in_txt, in_a_op) | ||
| 2449 | local | ||
| 2450 | Tpl.Text txt; | ||
| 2451 | |||
| 2452 | case ( txt, | ||
| 2453 | MidCode.ADD() ) | ||
| 2454 | algorithm | ||
| 2455 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("+")); | |
| 2456 | then txt; | ||
| 2457 | |||
| 2458 | case ( txt, | ||
| 2459 | MidCode.SUB() ) | ||
| 2460 | algorithm | ||
| 2461 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("-")); | |
| 2462 | then txt; | ||
| 2463 | |||
| 2464 | case ( txt, | ||
| 2465 | MidCode.MUL() ) | ||
| 2466 | algorithm | ||
| 2467 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("*")); | |
| 2468 | then txt; | ||
| 2469 | |||
| 2470 | case ( txt, | ||
| 2471 | MidCode.DIV() ) | ||
| 2472 | algorithm | ||
| 2473 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("/")); | |
| 2474 | then txt; | ||
| 2475 | |||
| 2476 | case ( txt, | ||
| 2477 | MidCode.LESS() ) | ||
| 2478 | algorithm | ||
| 2479 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("<")); | |
| 2480 | then txt; | ||
| 2481 | |||
| 2482 | case ( txt, | ||
| 2483 | MidCode.LESSEQ() ) | ||
| 2484 | algorithm | ||
| 2485 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("<=")); | |
| 2486 | then txt; | ||
| 2487 | |||
| 2488 | case ( txt, | ||
| 2489 | MidCode.GREATER() ) | ||
| 2490 | algorithm | ||
| 2491 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(">")); | |
| 2492 | then txt; | ||
| 2493 | |||
| 2494 | case ( txt, | ||
| 2495 | MidCode.GREATEREQ() ) | ||
| 2496 | algorithm | ||
| 2497 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(">=")); | |
| 2498 | then txt; | ||
| 2499 | |||
| 2500 | case ( txt, | ||
| 2501 | MidCode.EQUAL() ) | ||
| 2502 | algorithm | ||
| 2503 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("==")); | |
| 2504 | then txt; | ||
| 2505 | |||
| 2506 | case ( txt, | ||
| 2507 | MidCode.NEQUAL() ) | ||
| 2508 | algorithm | ||
| 2509 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("!=")); | |
| 2510 | then txt; | ||
| 2511 | |||
| 2512 | case ( txt, | ||
| 2513 | _ ) | ||
| 2514 | algorithm | ||
| 2515 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("notimplemented")); | |
| 2516 | then txt; | ||
| 2517 | end match; | ||
| 2518 | end binaryopToString; | ||
| 2519 | |||
| 2520 | public function unaryopToString | ||
| 2521 | input Tpl.Text in_txt; | ||
| 2522 | input MidCode.UnaryOp in_a_op; | ||
| 2523 | |||
| 2524 | output Tpl.Text out_txt; | ||
| 2525 | algorithm | ||
| 2526 | out_txt := | ||
| 2527 | match(in_txt, in_a_op) | ||
| 2528 | local | ||
| 2529 | Tpl.Text txt; | ||
| 2530 | |||
| 2531 | case ( txt, | ||
| 2532 | MidCode.MOVE() ) | ||
| 2533 | then txt; | ||
| 2534 | |||
| 2535 | case ( txt, | ||
| 2536 | MidCode.UMINUS() ) | ||
| 2537 | algorithm | ||
| 2538 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("-")); | |
| 2539 | then txt; | ||
| 2540 | |||
| 2541 | case ( txt, | ||
| 2542 | MidCode.NOT() ) | ||
| 2543 | algorithm | ||
| 2544 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("!")); | |
| 2545 | then txt; | ||
| 2546 | |||
| 2547 | case ( txt, | ||
| 2548 | _ ) | ||
| 2549 | algorithm | ||
| 2550 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("notimplemented")); | |
| 2551 | then txt; | ||
| 2552 | end match; | ||
| 2553 | end unaryopToString; | ||
| 2554 | |||
| 2555 | public function genStringBinaryop | ||
| 2556 | input Tpl.Text in_txt; | ||
| 2557 | input MidCode.BinaryOp in_a_op; | ||
| 2558 | input MidCode.Var in_a_lsrc; | ||
| 2559 | input MidCode.Var in_a_rsrc; | ||
| 2560 | |||
| 2561 | output Tpl.Text out_txt; | ||
| 2562 | algorithm | ||
| 2563 | out_txt := | ||
| 2564 | match(in_txt, in_a_op, in_a_lsrc, in_a_rsrc) | ||
| 2565 | local | ||
| 2566 | Tpl.Text txt; | ||
| 2567 | MidCode.Var a_lsrc; | ||
| 2568 | MidCode.Var a_rsrc; | ||
| 2569 | MidCode.BinaryOp i_op; | ||
| 2570 | |||
| 2571 | case ( txt, | ||
| 2572 | MidCode.ADD(), | ||
| 2573 | a_lsrc, | ||
| 2574 | a_rsrc ) | ||
| 2575 | algorithm | ||
| 2576 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("stringAppend(")); | |
| 2577 | ✗ | txt := genVarName(txt, a_lsrc); | |
| 2578 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(", ")); | |
| 2579 | ✗ | txt := genVarName(txt, a_rsrc); | |
| 2580 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 2581 | then txt; | ||
| 2582 | |||
| 2583 | case ( txt, | ||
| 2584 | i_op, | ||
| 2585 | a_lsrc, | ||
| 2586 | a_rsrc ) | ||
| 2587 | algorithm | ||
| 2588 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("0 ")); | |
| 2589 | ✗ | txt := binaryopToString(txt, i_op); | |
| 2590 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" stringCompare(")); | |
| 2591 | ✗ | txt := genVarName(txt, a_lsrc); | |
| 2592 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(", ")); | |
| 2593 | ✗ | txt := genVarName(txt, a_rsrc); | |
| 2594 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 2595 | then txt; | ||
| 2596 | end match; | ||
| 2597 | end genStringBinaryop; | ||
| 2598 | |||
| 2599 | protected function lm_132 | ||
| 2600 | input output Tpl.Text txt; | ||
| 2601 | input list<tuple<Integer, Integer>> items; | ||
| 2602 | algorithm | ||
| 2603 | ✗ | for lstElt_132 in items loop | |
| 2604 | txt := match lstElt_132 | ||
| 2605 | local | ||
| 2606 | Integer i_to; | ||
| 2607 | Integer i_from; | ||
| 2608 | |||
| 2609 | case (i_from, i_to) | ||
| 2610 | algorithm | ||
| 2611 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("case ")); | |
| 2612 | ✗ | txt := Tpl.writeStr(txt, intString(i_from)); | |
| 2613 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(": goto ")); | |
| 2614 | ✗ | txt := genLabel(txt, i_to); | |
| 2615 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(";")); | |
| 2616 | ✗ | txt := Tpl.nextIter(txt); | |
| 2617 | then txt; | ||
| 2618 | end match; | ||
| 2619 | end for; | ||
| 2620 | end lm_132; | ||
| 2621 | |||
| 2622 | protected function fun_133 | ||
| 2623 | input Tpl.Text in_txt; | ||
| 2624 | input list<MidCode.OutVar> in_a_outputs; | ||
| 2625 | |||
| 2626 | output Tpl.Text out_txt; | ||
| 2627 | algorithm | ||
| 2628 | out_txt := | ||
| 2629 | match(in_txt, in_a_outputs) | ||
| 2630 | local | ||
| 2631 | Tpl.Text txt; | ||
| 2632 | MidCode.Var i_var; | ||
| 2633 | |||
| 2634 | case ( txt, | ||
| 2635 | {} ) | ||
| 2636 | then txt; | ||
| 2637 | |||
| 2638 | case ( txt, | ||
| 2639 | MidCode.OUT_WILD() :: _ ) | ||
| 2640 | then txt; | ||
| 2641 | |||
| 2642 | case ( txt, | ||
| 2643 | MidCode.OUT_VAR(var = i_var) :: _ ) | ||
| 2644 | algorithm | ||
| 2645 | ✗ | txt := genVarName(txt, i_var); | |
| 2646 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" = ")); | |
| 2647 | then txt; | ||
| 2648 | |||
| 2649 | case ( txt, | ||
| 2650 | _ ) | ||
| 2651 | then txt; | ||
| 2652 | end match; | ||
| 2653 | end fun_133; | ||
| 2654 | |||
| 2655 | protected function fun_134 | ||
| 2656 | input Tpl.Text in_txt; | ||
| 2657 | input Boolean in_a_builtin; | ||
| 2658 | |||
| 2659 | output Tpl.Text out_txt; | ||
| 2660 | algorithm | ||
| 2661 | out_txt := | ||
| 2662 | match(in_txt, in_a_builtin) | ||
| 2663 | local | ||
| 2664 | Tpl.Text txt; | ||
| 2665 | |||
| 2666 | case ( txt, | ||
| 2667 | false ) | ||
| 2668 | algorithm | ||
| 2669 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("threadData")); | |
| 2670 | then txt; | ||
| 2671 | |||
| 2672 | case ( txt, | ||
| 2673 | _ ) | ||
| 2674 | then txt; | ||
| 2675 | end match; | ||
| 2676 | end fun_134; | ||
| 2677 | |||
| 2678 | protected function lm_135 | ||
| 2679 | input output Tpl.Text txt; | ||
| 2680 | input list<MidCode.Var> items; | ||
| 2681 | algorithm | ||
| 2682 | ✗ | for lstElt_135 in items loop | |
| 2683 | txt := match lstElt_135 | ||
| 2684 | local | ||
| 2685 | MidCode.Var i_i; | ||
| 2686 | |||
| 2687 | case i_i | ||
| 2688 | algorithm | ||
| 2689 | ✗ | txt := genVarName(txt, i_i); | |
| 2690 | ✗ | txt := Tpl.nextIter(txt); | |
| 2691 | then txt; | ||
| 2692 | end match; | ||
| 2693 | end for; | ||
| 2694 | end lm_135; | ||
| 2695 | |||
| 2696 | protected function fun_136 | ||
| 2697 | input Tpl.Text in_txt; | ||
| 2698 | input MidCode.OutVar in_a_o; | ||
| 2699 | |||
| 2700 | output Tpl.Text out_txt; | ||
| 2701 | algorithm | ||
| 2702 | out_txt := | ||
| 2703 | match(in_txt, in_a_o) | ||
| 2704 | local | ||
| 2705 | Tpl.Text txt; | ||
| 2706 | MidCode.Var i_var; | ||
| 2707 | |||
| 2708 | case ( txt, | ||
| 2709 | MidCode.OUT_VAR(var = i_var) ) | ||
| 2710 | algorithm | ||
| 2711 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("&")); | |
| 2712 | ✗ | txt := genVarName(txt, i_var); | |
| 2713 | then txt; | ||
| 2714 | |||
| 2715 | case ( txt, | ||
| 2716 | _ ) | ||
| 2717 | algorithm | ||
| 2718 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("NULL")); | |
| 2719 | then txt; | ||
| 2720 | end match; | ||
| 2721 | end fun_136; | ||
| 2722 | |||
| 2723 | protected function lm_137 | ||
| 2724 | input output Tpl.Text txt; | ||
| 2725 | input list<MidCode.OutVar> items; | ||
| 2726 | algorithm | ||
| 2727 | ✗ | for lstElt_137 in items loop | |
| 2728 | txt := match lstElt_137 | ||
| 2729 | local | ||
| 2730 | MidCode.OutVar i_o; | ||
| 2731 | |||
| 2732 | case i_o | ||
| 2733 | algorithm | ||
| 2734 | ✗ | txt := fun_136(txt, i_o); | |
| 2735 | ✗ | txt := Tpl.nextIter(txt); | |
| 2736 | then txt; | ||
| 2737 | end match; | ||
| 2738 | end for; | ||
| 2739 | end lm_137; | ||
| 2740 | |||
| 2741 | protected function smf_138 | ||
| 2742 | input Tpl.Text in_txt; | ||
| 2743 | input Tpl.Text in_it; | ||
| 2744 | |||
| 2745 | output Tpl.Text out_txt; | ||
| 2746 | algorithm | ||
| 2747 | out_txt := | ||
| 2748 | match(in_txt, in_it) | ||
| 2749 | local | ||
| 2750 | Tpl.Text txt; | ||
| 2751 | Tpl.Text i_it; | ||
| 2752 | |||
| 2753 | case ( txt, | ||
| 2754 | i_it ) | ||
| 2755 | algorithm | ||
| 2756 | ✗ | txt := Tpl.writeText(txt, i_it); | |
| 2757 | ✗ | txt := Tpl.nextIter(txt); | |
| 2758 | then txt; | ||
| 2759 | end match; | ||
| 2760 | end smf_138; | ||
| 2761 | |||
| 2762 | protected function smf_139 | ||
| 2763 | input Tpl.Text in_txt; | ||
| 2764 | input Tpl.Text in_it; | ||
| 2765 | |||
| 2766 | output Tpl.Text out_txt; | ||
| 2767 | algorithm | ||
| 2768 | out_txt := | ||
| 2769 | match(in_txt, in_it) | ||
| 2770 | local | ||
| 2771 | Tpl.Text txt; | ||
| 2772 | Tpl.Text i_it; | ||
| 2773 | |||
| 2774 | case ( txt, | ||
| 2775 | i_it ) | ||
| 2776 | algorithm | ||
| 2777 | ✗ | txt := Tpl.writeText(txt, i_it); | |
| 2778 | ✗ | txt := Tpl.nextIter(txt); | |
| 2779 | then txt; | ||
| 2780 | end match; | ||
| 2781 | end smf_139; | ||
| 2782 | |||
| 2783 | protected function smf_140 | ||
| 2784 | input Tpl.Text in_txt; | ||
| 2785 | input Tpl.Text in_it; | ||
| 2786 | |||
| 2787 | output Tpl.Text out_txt; | ||
| 2788 | algorithm | ||
| 2789 | out_txt := | ||
| 2790 | match(in_txt, in_it) | ||
| 2791 | local | ||
| 2792 | Tpl.Text txt; | ||
| 2793 | Tpl.Text i_it; | ||
| 2794 | |||
| 2795 | case ( txt, | ||
| 2796 | i_it ) | ||
| 2797 | algorithm | ||
| 2798 | ✗ | txt := Tpl.writeText(txt, i_it); | |
| 2799 | ✗ | txt := Tpl.nextIter(txt); | |
| 2800 | then txt; | ||
| 2801 | end match; | ||
| 2802 | end smf_140; | ||
| 2803 | |||
| 2804 | protected function fun_141 | ||
| 2805 | input Tpl.Text in_txt; | ||
| 2806 | input Boolean in_a_builtin; | ||
| 2807 | input Absyn.Path in_a_func; | ||
| 2808 | |||
| 2809 | output Tpl.Text out_txt; | ||
| 2810 | algorithm | ||
| 2811 | out_txt := | ||
| 2812 | match(in_txt, in_a_builtin, in_a_func) | ||
| 2813 | local | ||
| 2814 | Tpl.Text txt; | ||
| 2815 | Absyn.Path a_func; | ||
| 2816 | |||
| 2817 | case ( txt, | ||
| 2818 | false, | ||
| 2819 | a_func ) | ||
| 2820 | algorithm | ||
| 2821 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("omc_")); | |
| 2822 | ✗ | txt := underscorePath(txt, a_func); | |
| 2823 | then txt; | ||
| 2824 | |||
| 2825 | case ( txt, | ||
| 2826 | _, | ||
| 2827 | a_func ) | ||
| 2828 | algorithm | ||
| 2829 | ✗ | txt := identBuiltinCall(txt, a_func); | |
| 2830 | then txt; | ||
| 2831 | end match; | ||
| 2832 | end fun_141; | ||
| 2833 | |||
| 2834 | protected function fun_142 | ||
| 2835 | input Tpl.Text in_txt; | ||
| 2836 | input MidCode.Terminator in_a_terminator; | ||
| 2837 | input Integer in_a_exitId; | ||
| 2838 | |||
| 2839 | output Tpl.Text out_txt; | ||
| 2840 | algorithm | ||
| 2841 | out_txt := | ||
| 2842 | match(in_txt, in_a_terminator, in_a_exitId) | ||
| 2843 | local | ||
| 2844 | Tpl.Text txt; | ||
| 2845 | Integer a_exitId; | ||
| 2846 | MidCode.VarBuf i_new__buf; | ||
| 2847 | MidCode.VarBufPtr i_old__buf; | ||
| 2848 | Integer i_next; | ||
| 2849 | Absyn.Path i_func; | ||
| 2850 | list<MidCode.Var> i_inputs; | ||
| 2851 | Boolean i_builtin; | ||
| 2852 | list<MidCode.OutVar> i_outputs; | ||
| 2853 | list<tuple<Integer, Integer>> i_cases; | ||
| 2854 | Integer i_labelFalse; | ||
| 2855 | Integer i_labelTrue; | ||
| 2856 | MidCode.Var i_condition; | ||
| 2857 | Integer i_label; | ||
| 2858 | Tpl.Text txt_4; | ||
| 2859 | list<MidCode.OutVar> ret_4; | ||
| 2860 | Tpl.Text txt_3; | ||
| 2861 | Tpl.Text txt_2; | ||
| 2862 | Tpl.Text l_arguments; | ||
| 2863 | Tpl.Text l_returnAssignment; | ||
| 2864 | |||
| 2865 | case ( txt, | ||
| 2866 | MidCode.RETURN(), | ||
| 2867 | a_exitId ) | ||
| 2868 | algorithm | ||
| 2869 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("goto ")); | |
| 2870 | ✗ | txt := genLabel(txt, a_exitId); | |
| 2871 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("; // exit label")); | |
| 2872 | then txt; | ||
| 2873 | |||
| 2874 | case ( txt, | ||
| 2875 | MidCode.GOTO(next = i_label), | ||
| 2876 | _ ) | ||
| 2877 | algorithm | ||
| 2878 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("goto ")); | |
| 2879 | ✗ | txt := genLabel(txt, i_label); | |
| 2880 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(";")); | |
| 2881 | then txt; | ||
| 2882 | |||
| 2883 | case ( txt, | ||
| 2884 | MidCode.BRANCH(condition = i_condition, onTrue = i_labelTrue, onFalse = i_labelFalse), | ||
| 2885 | _ ) | ||
| 2886 | algorithm | ||
| 2887 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("if (")); | |
| 2888 | ✗ | txt := genVarName(txt, i_condition); | |
| 2889 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_LINE(")\n")); | |
| 2890 | ✗ | txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2)); | |
| 2891 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("goto ")); | |
| 2892 | ✗ | txt := genLabel(txt, i_labelTrue); | |
| 2893 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_LINE(";\n")); | |
| 2894 | ✗ | txt := Tpl.popBlock(txt); | |
| 2895 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_LINE("else\n")); | |
| 2896 | ✗ | txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2)); | |
| 2897 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("goto ")); | |
| 2898 | ✗ | txt := genLabel(txt, i_labelFalse); | |
| 2899 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(";")); | |
| 2900 | ✗ | txt := Tpl.popBlock(txt); | |
| 2901 | then txt; | ||
| 2902 | |||
| 2903 | case ( txt, | ||
| 2904 | MidCode.SWITCH(condition = i_condition, cases = i_cases), | ||
| 2905 | _ ) | ||
| 2906 | algorithm | ||
| 2907 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("switch (")); | |
| 2908 | ✗ | txt := genVarName(txt, i_condition); | |
| 2909 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_LINE("){\n")); | |
| 2910 | ✗ | txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(2)); | |
| 2911 | ✗ | 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())); | |
| 2912 | ✗ | txt := lm_132(txt, i_cases); | |
| 2913 | ✗ | txt := Tpl.popIter(txt); | |
| 2914 | ✗ | txt := Tpl.softNewLine(txt); | |
| 2915 | ✗ | txt := Tpl.popBlock(txt); | |
| 2916 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("}")); | |
| 2917 | then txt; | ||
| 2918 | |||
| 2919 | case ( txt, | ||
| 2920 | MidCode.CALL(func = i_func, builtin = i_builtin, inputs = i_inputs, outputs = i_outputs, next = i_next), | ||
| 2921 | _ ) | ||
| 2922 | algorithm | ||
| 2923 | ✗ | l_returnAssignment := fun_133(Tpl.emptyTxt, i_outputs); | |
| 2924 | ✗ | txt_2 := fun_134(Tpl.emptyTxt, i_builtin); | |
| 2925 | ✗ | txt_3 := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 2926 | ✗ | txt_3 := lm_135(txt_3, i_inputs); | |
| 2927 | ✗ | txt_3 := Tpl.popIter(txt_3); | |
| 2928 | ✗ | ret_4 := List.restOrEmpty(i_outputs); | |
| 2929 | ✗ | txt_4 := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(", ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 2930 | ✗ | txt_4 := lm_137(txt_4, ret_4); | |
| 2931 | ✗ | txt_4 := Tpl.popIter(txt_4); | |
| 2932 | ✗ | l_arguments := Tpl.pushIter(Tpl.emptyTxt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING_LIST({ | |
| 2933 | ",\n", | ||
| 2934 | " " | ||
| 2935 | }, false)), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | ||
| 2936 | ✗ | l_arguments := smf_138(l_arguments, txt_2); | |
| 2937 | ✗ | l_arguments := smf_139(l_arguments, txt_3); | |
| 2938 | ✗ | l_arguments := smf_140(l_arguments, txt_4); | |
| 2939 | ✗ | l_arguments := Tpl.popIter(l_arguments); | |
| 2940 | ✗ | txt := Tpl.writeText(txt, l_returnAssignment); | |
| 2941 | ✗ | txt := fun_141(txt, i_builtin, i_func); | |
| 2942 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("(")); | |
| 2943 | ✗ | txt := Tpl.writeText(txt, l_arguments); | |
| 2944 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 2945 | ");\n", | ||
| 2946 | "goto " | ||
| 2947 | }, false)); | ||
| 2948 | ✗ | txt := genLabel(txt, i_next); | |
| 2949 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(";")); | |
| 2950 | then txt; | ||
| 2951 | |||
| 2952 | case ( txt, | ||
| 2953 | MidCode.LONGJMP(), | ||
| 2954 | _ ) | ||
| 2955 | algorithm | ||
| 2956 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("longjmp(*threadData->mmc_jumper,1);")); | |
| 2957 | then txt; | ||
| 2958 | |||
| 2959 | case ( txt, | ||
| 2960 | MidCode.PUSHJMP(old_buf = i_old__buf, new_buf = i_new__buf, next = i_next), | ||
| 2961 | _ ) | ||
| 2962 | algorithm | ||
| 2963 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_LINE("// PUSHJMP\n")); | |
| 2964 | ✗ | txt := genVarBufPtrName(txt, i_old__buf); | |
| 2965 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 2966 | " = threadData->mmc_jumper;\n", | ||
| 2967 | "threadData->mmc_jumper = &" | ||
| 2968 | }, false)); | ||
| 2969 | ✗ | txt := genVarBufName(txt, i_new__buf); | |
| 2970 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 2971 | ";\n", | ||
| 2972 | "setjmp(&" | ||
| 2973 | }, false)); | ||
| 2974 | ✗ | txt := genVarBufName(txt, i_new__buf); | |
| 2975 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 2976 | ");\n", | ||
| 2977 | "goto " | ||
| 2978 | }, false)); | ||
| 2979 | ✗ | txt := genLabel(txt, i_next); | |
| 2980 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(";")); | |
| 2981 | then txt; | ||
| 2982 | |||
| 2983 | case ( txt, | ||
| 2984 | MidCode.POPJMP(old_buf = i_old__buf, next = i_next), | ||
| 2985 | _ ) | ||
| 2986 | algorithm | ||
| 2987 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 2988 | "// POPJMP\n", | ||
| 2989 | "threadData->mmc_jumper = " | ||
| 2990 | }, false)); | ||
| 2991 | ✗ | txt := genVarBufPtrName(txt, i_old__buf); | |
| 2992 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 2993 | ";\n", | ||
| 2994 | "goto " | ||
| 2995 | }, false)); | ||
| 2996 | ✗ | txt := genLabel(txt, i_next); | |
| 2997 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(";")); | |
| 2998 | then txt; | ||
| 2999 | |||
| 3000 | case ( txt, | ||
| 3001 | _, | ||
| 3002 | _ ) | ||
| 3003 | algorithm | ||
| 3004 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("notimplemented")); | |
| 3005 | then txt; | ||
| 3006 | end match; | ||
| 3007 | end fun_142; | ||
| 3008 | |||
| 3009 | public function genTerminator | ||
| 3010 | input Tpl.Text in_txt; | ||
| 3011 | input MidCode.Function in_a_fn; | ||
| 3012 | input MidCode.Terminator in_a_terminator; | ||
| 3013 | |||
| 3014 | output Tpl.Text out_txt; | ||
| 3015 | algorithm | ||
| 3016 | out_txt := | ||
| 3017 | match(in_txt, in_a_fn, in_a_terminator) | ||
| 3018 | local | ||
| 3019 | Tpl.Text txt; | ||
| 3020 | MidCode.Terminator a_terminator; | ||
| 3021 | Integer i_exitId; | ||
| 3022 | |||
| 3023 | case ( txt, | ||
| 3024 | MidCode.FUNCTION(locals = _, inputs = _, outputs = _, body = _, entryId = _, exitId = i_exitId), | ||
| 3025 | a_terminator ) | ||
| 3026 | algorithm | ||
| 3027 | ✗ | txt := fun_142(txt, a_terminator, i_exitId); | |
| 3028 | then txt; | ||
| 3029 | |||
| 3030 | case ( txt, | ||
| 3031 | _, | ||
| 3032 | _ ) | ||
| 3033 | then txt; | ||
| 3034 | end match; | ||
| 3035 | end genTerminator; | ||
| 3036 | |||
| 3037 | protected function fun_144 | ||
| 3038 | input Tpl.Text in_txt; | ||
| 3039 | input DAE.Type in_a_ty; | ||
| 3040 | |||
| 3041 | output Tpl.Text out_txt; | ||
| 3042 | algorithm | ||
| 3043 | out_txt := | ||
| 3044 | match(in_txt, in_a_ty) | ||
| 3045 | local | ||
| 3046 | Tpl.Text txt; | ||
| 3047 | |||
| 3048 | case ( txt, | ||
| 3049 | DAE.T_INTEGER(varLst = _) ) | ||
| 3050 | algorithm | ||
| 3051 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_integer")); | |
| 3052 | then txt; | ||
| 3053 | |||
| 3054 | case ( txt, | ||
| 3055 | DAE.T_ENUMERATION(index = _) ) | ||
| 3056 | algorithm | ||
| 3057 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_integer")); | |
| 3058 | then txt; | ||
| 3059 | |||
| 3060 | case ( txt, | ||
| 3061 | DAE.T_BOOL(varLst = _) ) | ||
| 3062 | algorithm | ||
| 3063 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_boolean")); | |
| 3064 | then txt; | ||
| 3065 | |||
| 3066 | case ( txt, | ||
| 3067 | DAE.T_REAL(varLst = _) ) | ||
| 3068 | algorithm | ||
| 3069 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_real")); | |
| 3070 | then txt; | ||
| 3071 | |||
| 3072 | case ( txt, | ||
| 3073 | DAE.T_STRING(varLst = _) ) | ||
| 3074 | algorithm | ||
| 3075 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_string")); | |
| 3076 | then txt; | ||
| 3077 | |||
| 3078 | case ( txt, | ||
| 3079 | DAE.T_METABOXED(ty = _) ) | ||
| 3080 | algorithm | ||
| 3081 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_metatype")); | |
| 3082 | then txt; | ||
| 3083 | |||
| 3084 | case ( txt, | ||
| 3085 | DAE.T_METARECORD(path = _) ) | ||
| 3086 | algorithm | ||
| 3087 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_metatype")); | |
| 3088 | then txt; | ||
| 3089 | |||
| 3090 | case ( txt, | ||
| 3091 | DAE.T_METATYPE(ty = _) ) | ||
| 3092 | algorithm | ||
| 3093 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_metatype")); | |
| 3094 | then txt; | ||
| 3095 | |||
| 3096 | case ( txt, | ||
| 3097 | DAE.T_METAOPTION(ty = _) ) | ||
| 3098 | algorithm | ||
| 3099 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_metatype")); | |
| 3100 | then txt; | ||
| 3101 | |||
| 3102 | case ( txt, | ||
| 3103 | DAE.T_METAARRAY(ty = _) ) | ||
| 3104 | algorithm | ||
| 3105 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_metatype")); | |
| 3106 | then txt; | ||
| 3107 | |||
| 3108 | case ( txt, | ||
| 3109 | DAE.T_METATUPLE(types = _) ) | ||
| 3110 | algorithm | ||
| 3111 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_metatype")); | |
| 3112 | then txt; | ||
| 3113 | |||
| 3114 | case ( txt, | ||
| 3115 | DAE.T_METAUNIONTYPE(paths = _) ) | ||
| 3116 | algorithm | ||
| 3117 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_metatype")); | |
| 3118 | then txt; | ||
| 3119 | |||
| 3120 | case ( txt, | ||
| 3121 | DAE.T_METALIST(ty = _) ) | ||
| 3122 | algorithm | ||
| 3123 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_metatype")); | |
| 3124 | then txt; | ||
| 3125 | |||
| 3126 | case ( txt, | ||
| 3127 | DAE.T_UNKNOWN() ) | ||
| 3128 | algorithm | ||
| 3129 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("unknown")); | |
| 3130 | then txt; | ||
| 3131 | |||
| 3132 | case ( txt, | ||
| 3133 | DAE.T_METAPOLYMORPHIC(name = _) ) | ||
| 3134 | algorithm | ||
| 3135 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("error_ metapolymorphic")); | |
| 3136 | then txt; | ||
| 3137 | |||
| 3138 | case ( txt, | ||
| 3139 | DAE.T_METAUNIONTYPE(paths = _) ) | ||
| 3140 | algorithm | ||
| 3141 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("error_ metauniontype")); | |
| 3142 | then txt; | ||
| 3143 | |||
| 3144 | case ( txt, | ||
| 3145 | DAE.T_ANYTYPE(anyClassType = _) ) | ||
| 3146 | algorithm | ||
| 3147 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("error_anytype")); | |
| 3148 | then txt; | ||
| 3149 | |||
| 3150 | case ( txt, | ||
| 3151 | DAE.T_TUPLE(types = _) ) | ||
| 3152 | algorithm | ||
| 3153 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("error_tuple")); | |
| 3154 | then txt; | ||
| 3155 | |||
| 3156 | case ( txt, | ||
| 3157 | _ ) | ||
| 3158 | algorithm | ||
| 3159 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("notimplemented")); | |
| 3160 | then txt; | ||
| 3161 | end match; | ||
| 3162 | end fun_144; | ||
| 3163 | |||
| 3164 | public function genVarType | ||
| 3165 | input Tpl.Text in_txt; | ||
| 3166 | input MidCode.Var in_a_var; | ||
| 3167 | |||
| 3168 | output Tpl.Text out_txt; | ||
| 3169 | algorithm | ||
| 3170 | out_txt := | ||
| 3171 | match(in_txt, in_a_var) | ||
| 3172 | local | ||
| 3173 | Tpl.Text txt; | ||
| 3174 | DAE.Type i_ty; | ||
| 3175 | |||
| 3176 | case ( txt, | ||
| 3177 | MidCode.VAR(name = _, ty = i_ty) ) | ||
| 3178 | algorithm | ||
| 3179 | ✗ | txt := fun_144(txt, i_ty); | |
| 3180 | then txt; | ||
| 3181 | |||
| 3182 | case ( txt, | ||
| 3183 | _ ) | ||
| 3184 | then txt; | ||
| 3185 | end match; | ||
| 3186 | end genVarType; | ||
| 3187 | |||
| 3188 | protected function fun_146 | ||
| 3189 | input Tpl.Text in_txt; | ||
| 3190 | input Integer in_mArg; | ||
| 3191 | |||
| 3192 | output Tpl.Text out_txt; | ||
| 3193 | algorithm | ||
| 3194 | out_txt := | ||
| 3195 | match(in_txt, in_mArg) | ||
| 3196 | local | ||
| 3197 | Tpl.Text txt; | ||
| 3198 | |||
| 3199 | case ( txt, | ||
| 3200 | 0 ) | ||
| 3201 | algorithm | ||
| 3202 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("0")); | |
| 3203 | then txt; | ||
| 3204 | |||
| 3205 | case ( txt, | ||
| 3206 | _ ) | ||
| 3207 | algorithm | ||
| 3208 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("1")); | |
| 3209 | then txt; | ||
| 3210 | end match; | ||
| 3211 | end fun_146; | ||
| 3212 | |||
| 3213 | protected function fun_147 | ||
| 3214 | input Tpl.Text in_txt; | ||
| 3215 | input DAE.Type in_a_ty; | ||
| 3216 | input list<MidCode.Var> in_a_elements; | ||
| 3217 | |||
| 3218 | output Tpl.Text out_txt; | ||
| 3219 | algorithm | ||
| 3220 | out_txt := | ||
| 3221 | match(in_txt, in_a_ty, in_a_elements) | ||
| 3222 | local | ||
| 3223 | Tpl.Text txt; | ||
| 3224 | list<MidCode.Var> a_elements; | ||
| 3225 | Integer i_index; | ||
| 3226 | Integer ret_1; | ||
| 3227 | Integer ret_0; | ||
| 3228 | |||
| 3229 | case ( txt, | ||
| 3230 | DAE.T_METARECORD(index = i_index), | ||
| 3231 | _ ) | ||
| 3232 | algorithm | ||
| 3233 | ✗ | ret_0 := intAdd(i_index, 3); | |
| 3234 | ✗ | txt := Tpl.writeStr(txt, intString(ret_0)); | |
| 3235 | then txt; | ||
| 3236 | |||
| 3237 | case ( txt, | ||
| 3238 | DAE.T_METAARRAY(ty = _), | ||
| 3239 | _ ) | ||
| 3240 | algorithm | ||
| 3241 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("2")); | |
| 3242 | then txt; | ||
| 3243 | |||
| 3244 | case ( txt, | ||
| 3245 | DAE.T_METATUPLE(types = _), | ||
| 3246 | _ ) | ||
| 3247 | algorithm | ||
| 3248 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("0")); | |
| 3249 | then txt; | ||
| 3250 | |||
| 3251 | case ( txt, | ||
| 3252 | DAE.T_METAOPTION(ty = _), | ||
| 3253 | _ ) | ||
| 3254 | algorithm | ||
| 3255 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("1")); | |
| 3256 | then txt; | ||
| 3257 | |||
| 3258 | case ( txt, | ||
| 3259 | DAE.T_METALIST(ty = _), | ||
| 3260 | a_elements ) | ||
| 3261 | algorithm | ||
| 3262 | ✗ | ret_1 := listLength(a_elements); | |
| 3263 | ✗ | txt := fun_146(txt, ret_1); | |
| 3264 | then txt; | ||
| 3265 | |||
| 3266 | case ( txt, | ||
| 3267 | _, | ||
| 3268 | _ ) | ||
| 3269 | algorithm | ||
| 3270 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("0")); | |
| 3271 | then txt; | ||
| 3272 | end match; | ||
| 3273 | end fun_147; | ||
| 3274 | |||
| 3275 | public function genTypeCtorIndex | ||
| 3276 | input Tpl.Text txt; | ||
| 3277 | input list<MidCode.Var> a_elements; | ||
| 3278 | input DAE.Type a_ty; | ||
| 3279 | |||
| 3280 | output Tpl.Text out_txt; | ||
| 3281 | algorithm | ||
| 3282 | ✗ | out_txt := fun_147(txt, a_ty, a_elements); | |
| 3283 | end genTypeCtorIndex; | ||
| 3284 | |||
| 3285 | public function genTypeUnderscorePath | ||
| 3286 | input Tpl.Text in_txt; | ||
| 3287 | input DAE.Type in_a_ty; | ||
| 3288 | |||
| 3289 | output Tpl.Text out_txt; | ||
| 3290 | algorithm | ||
| 3291 | out_txt := | ||
| 3292 | match(in_txt, in_a_ty) | ||
| 3293 | local | ||
| 3294 | Tpl.Text txt; | ||
| 3295 | Absyn.Path i_path; | ||
| 3296 | |||
| 3297 | case ( txt, | ||
| 3298 | DAE.T_METARECORD(path = i_path) ) | ||
| 3299 | algorithm | ||
| 3300 | ✗ | txt := underscorePath(txt, i_path); | |
| 3301 | then txt; | ||
| 3302 | |||
| 3303 | case ( txt, | ||
| 3304 | DAE.T_COMPLEX(complexClassType = ClassInf.RECORD(path = i_path), varLst = _) ) | ||
| 3305 | algorithm | ||
| 3306 | ✗ | txt := underscorePath(txt, i_path); | |
| 3307 | then txt; | ||
| 3308 | |||
| 3309 | case ( txt, | ||
| 3310 | _ ) | ||
| 3311 | algorithm | ||
| 3312 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("error: genTypeUnderscorePath")); | |
| 3313 | then txt; | ||
| 3314 | end match; | ||
| 3315 | end genTypeUnderscorePath; | ||
| 3316 | |||
| 3317 | protected function fun_150 | ||
| 3318 | input Tpl.Text in_txt; | ||
| 3319 | input DAE.Type in_a_ty; | ||
| 3320 | |||
| 3321 | output Tpl.Text out_txt; | ||
| 3322 | algorithm | ||
| 3323 | out_txt := | ||
| 3324 | match(in_txt, in_a_ty) | ||
| 3325 | local | ||
| 3326 | Tpl.Text txt; | ||
| 3327 | |||
| 3328 | case ( txt, | ||
| 3329 | DAE.T_INTEGER(varLst = _) ) | ||
| 3330 | algorithm | ||
| 3331 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_metatype")); | |
| 3332 | then txt; | ||
| 3333 | |||
| 3334 | case ( txt, | ||
| 3335 | DAE.T_ENUMERATION(index = _) ) | ||
| 3336 | algorithm | ||
| 3337 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_metatype")); | |
| 3338 | then txt; | ||
| 3339 | |||
| 3340 | case ( txt, | ||
| 3341 | DAE.T_BOOL(varLst = _) ) | ||
| 3342 | algorithm | ||
| 3343 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_metatype")); | |
| 3344 | then txt; | ||
| 3345 | |||
| 3346 | case ( txt, | ||
| 3347 | DAE.T_REAL(varLst = _) ) | ||
| 3348 | algorithm | ||
| 3349 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_metatype")); | |
| 3350 | then txt; | ||
| 3351 | |||
| 3352 | case ( txt, | ||
| 3353 | _ ) | ||
| 3354 | then txt; | ||
| 3355 | end match; | ||
| 3356 | end fun_150; | ||
| 3357 | |||
| 3358 | public function varBoxType | ||
| 3359 | input Tpl.Text in_txt; | ||
| 3360 | input MidCode.Var in_a_var; | ||
| 3361 | |||
| 3362 | output Tpl.Text out_txt; | ||
| 3363 | algorithm | ||
| 3364 | out_txt := | ||
| 3365 | match(in_txt, in_a_var) | ||
| 3366 | local | ||
| 3367 | Tpl.Text txt; | ||
| 3368 | DAE.Type i_ty; | ||
| 3369 | |||
| 3370 | case ( txt, | ||
| 3371 | MidCode.VAR(name = _, ty = i_ty) ) | ||
| 3372 | algorithm | ||
| 3373 | ✗ | txt := fun_150(txt, i_ty); | |
| 3374 | then txt; | ||
| 3375 | |||
| 3376 | case ( txt, | ||
| 3377 | _ ) | ||
| 3378 | then txt; | ||
| 3379 | end match; | ||
| 3380 | end varBoxType; | ||
| 3381 | |||
| 3382 | protected function fun_152 | ||
| 3383 | input Tpl.Text in_txt; | ||
| 3384 | input DAE.Type in_a_ty; | ||
| 3385 | input String in_a_name; | ||
| 3386 | |||
| 3387 | output Tpl.Text out_txt; | ||
| 3388 | algorithm | ||
| 3389 | out_txt := | ||
| 3390 | match(in_txt, in_a_ty, in_a_name) | ||
| 3391 | local | ||
| 3392 | Tpl.Text txt; | ||
| 3393 | String a_name; | ||
| 3394 | |||
| 3395 | case ( txt, | ||
| 3396 | DAE.T_INTEGER(varLst = _), | ||
| 3397 | a_name ) | ||
| 3398 | algorithm | ||
| 3399 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("omc_mk_icon(")); | |
| 3400 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3401 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3402 | then txt; | ||
| 3403 | |||
| 3404 | case ( txt, | ||
| 3405 | DAE.T_ENUMERATION(index = _), | ||
| 3406 | a_name ) | ||
| 3407 | algorithm | ||
| 3408 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("omc_mk_icon(")); | |
| 3409 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3410 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3411 | then txt; | ||
| 3412 | |||
| 3413 | case ( txt, | ||
| 3414 | DAE.T_BOOL(varLst = _), | ||
| 3415 | a_name ) | ||
| 3416 | algorithm | ||
| 3417 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("omc_mk_icon(")); | |
| 3418 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3419 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3420 | then txt; | ||
| 3421 | |||
| 3422 | case ( txt, | ||
| 3423 | DAE.T_REAL(varLst = _), | ||
| 3424 | a_name ) | ||
| 3425 | algorithm | ||
| 3426 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("omc_mk_rcon(")); | |
| 3427 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3428 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3429 | then txt; | ||
| 3430 | |||
| 3431 | case ( txt, | ||
| 3432 | DAE.T_STRING(varLst = _), | ||
| 3433 | a_name ) | ||
| 3434 | algorithm | ||
| 3435 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("omc_mk_string(")); | |
| 3436 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3437 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3438 | then txt; | ||
| 3439 | |||
| 3440 | case ( txt, | ||
| 3441 | DAE.T_COMPLEX(complexClassType = _), | ||
| 3442 | a_name ) | ||
| 3443 | algorithm | ||
| 3444 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("omc_mk_box(")); | |
| 3445 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3446 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3447 | then txt; | ||
| 3448 | |||
| 3449 | case ( txt, | ||
| 3450 | _, | ||
| 3451 | a_name ) | ||
| 3452 | algorithm | ||
| 3453 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3454 | then txt; | ||
| 3455 | end match; | ||
| 3456 | end fun_152; | ||
| 3457 | |||
| 3458 | public function varBox | ||
| 3459 | input Tpl.Text in_txt; | ||
| 3460 | input MidCode.Var in_a_var; | ||
| 3461 | |||
| 3462 | output Tpl.Text out_txt; | ||
| 3463 | algorithm | ||
| 3464 | out_txt := | ||
| 3465 | match(in_txt, in_a_var) | ||
| 3466 | local | ||
| 3467 | Tpl.Text txt; | ||
| 3468 | String i_name; | ||
| 3469 | DAE.Type i_ty; | ||
| 3470 | |||
| 3471 | case ( txt, | ||
| 3472 | MidCode.VAR(name = i_name, ty = i_ty) ) | ||
| 3473 | algorithm | ||
| 3474 | ✗ | txt := fun_152(txt, i_ty, i_name); | |
| 3475 | then txt; | ||
| 3476 | |||
| 3477 | case ( txt, | ||
| 3478 | _ ) | ||
| 3479 | then txt; | ||
| 3480 | end match; | ||
| 3481 | end varBox; | ||
| 3482 | |||
| 3483 | protected function fun_154 | ||
| 3484 | input Tpl.Text in_txt; | ||
| 3485 | input DAE.Type in_a_ty; | ||
| 3486 | input String in_a_name; | ||
| 3487 | |||
| 3488 | output Tpl.Text out_txt; | ||
| 3489 | algorithm | ||
| 3490 | out_txt := | ||
| 3491 | match(in_txt, in_a_ty, in_a_name) | ||
| 3492 | local | ||
| 3493 | Tpl.Text txt; | ||
| 3494 | String a_name; | ||
| 3495 | |||
| 3496 | case ( txt, | ||
| 3497 | DAE.T_METABOXED(ty = DAE.T_INTEGER(varLst = _)), | ||
| 3498 | a_name ) | ||
| 3499 | algorithm | ||
| 3500 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("omc_unbox_integer(")); | |
| 3501 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3502 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3503 | then txt; | ||
| 3504 | |||
| 3505 | case ( txt, | ||
| 3506 | DAE.T_METABOXED(ty = DAE.T_ENUMERATION(index = _)), | ||
| 3507 | a_name ) | ||
| 3508 | algorithm | ||
| 3509 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("omc_unbox_integer(")); | |
| 3510 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3511 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3512 | then txt; | ||
| 3513 | |||
| 3514 | case ( txt, | ||
| 3515 | DAE.T_METABOXED(ty = DAE.T_BOOL(varLst = _)), | ||
| 3516 | a_name ) | ||
| 3517 | algorithm | ||
| 3518 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("omc_unbox_integer(")); | |
| 3519 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3520 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3521 | then txt; | ||
| 3522 | |||
| 3523 | case ( txt, | ||
| 3524 | DAE.T_METABOXED(ty = DAE.T_REAL(varLst = _)), | ||
| 3525 | a_name ) | ||
| 3526 | algorithm | ||
| 3527 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("omc_unbox_real(")); | |
| 3528 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3529 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3530 | then txt; | ||
| 3531 | |||
| 3532 | case ( txt, | ||
| 3533 | DAE.T_STRING(varLst = _), | ||
| 3534 | a_name ) | ||
| 3535 | algorithm | ||
| 3536 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("omc_unbox_string(")); | |
| 3537 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3538 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3539 | then txt; | ||
| 3540 | |||
| 3541 | case ( txt, | ||
| 3542 | _, | ||
| 3543 | a_name ) | ||
| 3544 | algorithm | ||
| 3545 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3546 | then txt; | ||
| 3547 | end match; | ||
| 3548 | end fun_154; | ||
| 3549 | |||
| 3550 | public function varUnbox | ||
| 3551 | input Tpl.Text in_txt; | ||
| 3552 | input MidCode.Var in_a_var; | ||
| 3553 | |||
| 3554 | output Tpl.Text out_txt; | ||
| 3555 | algorithm | ||
| 3556 | out_txt := | ||
| 3557 | match(in_txt, in_a_var) | ||
| 3558 | local | ||
| 3559 | Tpl.Text txt; | ||
| 3560 | String i_name; | ||
| 3561 | DAE.Type i_ty; | ||
| 3562 | |||
| 3563 | case ( txt, | ||
| 3564 | MidCode.VAR(name = i_name, ty = i_ty) ) | ||
| 3565 | algorithm | ||
| 3566 | ✗ | txt := fun_154(txt, i_ty, i_name); | |
| 3567 | then txt; | ||
| 3568 | |||
| 3569 | case ( txt, | ||
| 3570 | _ ) | ||
| 3571 | then txt; | ||
| 3572 | end match; | ||
| 3573 | end varUnbox; | ||
| 3574 | |||
| 3575 | protected function fun_156 | ||
| 3576 | input Tpl.Text in_txt; | ||
| 3577 | input DAE.Type in_a_ty; | ||
| 3578 | input String in_a_name; | ||
| 3579 | |||
| 3580 | output Tpl.Text out_txt; | ||
| 3581 | algorithm | ||
| 3582 | out_txt := | ||
| 3583 | match(in_txt, in_a_ty, in_a_name) | ||
| 3584 | local | ||
| 3585 | Tpl.Text txt; | ||
| 3586 | String a_name; | ||
| 3587 | |||
| 3588 | case ( txt, | ||
| 3589 | DAE.T_INTEGER(varLst = _), | ||
| 3590 | a_name ) | ||
| 3591 | algorithm | ||
| 3592 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("omc_unbox_integer(")); | |
| 3593 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3594 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3595 | then txt; | ||
| 3596 | |||
| 3597 | case ( txt, | ||
| 3598 | DAE.T_ENUMERATION(index = _), | ||
| 3599 | a_name ) | ||
| 3600 | algorithm | ||
| 3601 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("omc_unbox_integer(")); | |
| 3602 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3603 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3604 | then txt; | ||
| 3605 | |||
| 3606 | case ( txt, | ||
| 3607 | DAE.T_BOOL(varLst = _), | ||
| 3608 | a_name ) | ||
| 3609 | algorithm | ||
| 3610 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("omc_unbox_integer(")); | |
| 3611 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3612 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3613 | then txt; | ||
| 3614 | |||
| 3615 | case ( txt, | ||
| 3616 | DAE.T_REAL(varLst = _), | ||
| 3617 | a_name ) | ||
| 3618 | algorithm | ||
| 3619 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("omc_unbox_real(")); | |
| 3620 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3621 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3622 | then txt; | ||
| 3623 | |||
| 3624 | case ( txt, | ||
| 3625 | DAE.T_STRING(varLst = _), | ||
| 3626 | a_name ) | ||
| 3627 | algorithm | ||
| 3628 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("omc_unbox_string(")); | |
| 3629 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3630 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3631 | then txt; | ||
| 3632 | |||
| 3633 | case ( txt, | ||
| 3634 | _, | ||
| 3635 | a_name ) | ||
| 3636 | algorithm | ||
| 3637 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3638 | then txt; | ||
| 3639 | end match; | ||
| 3640 | end fun_156; | ||
| 3641 | |||
| 3642 | public function varUnbox2 | ||
| 3643 | input Tpl.Text in_txt; | ||
| 3644 | input MidCode.Var in_a_var; | ||
| 3645 | |||
| 3646 | output Tpl.Text out_txt; | ||
| 3647 | algorithm | ||
| 3648 | out_txt := | ||
| 3649 | match(in_txt, in_a_var) | ||
| 3650 | local | ||
| 3651 | Tpl.Text txt; | ||
| 3652 | String i_name; | ||
| 3653 | DAE.Type i_ty; | ||
| 3654 | |||
| 3655 | case ( txt, | ||
| 3656 | MidCode.VAR(name = i_name, ty = i_ty) ) | ||
| 3657 | algorithm | ||
| 3658 | ✗ | txt := fun_156(txt, i_ty, i_name); | |
| 3659 | then txt; | ||
| 3660 | |||
| 3661 | case ( txt, | ||
| 3662 | _ ) | ||
| 3663 | then txt; | ||
| 3664 | end match; | ||
| 3665 | end varUnbox2; | ||
| 3666 | |||
| 3667 | protected function fun_158 | ||
| 3668 | input Tpl.Text in_txt; | ||
| 3669 | input DAE.Type in_a_ty; | ||
| 3670 | input String in_a_name; | ||
| 3671 | |||
| 3672 | output Tpl.Text out_txt; | ||
| 3673 | algorithm | ||
| 3674 | out_txt := | ||
| 3675 | match(in_txt, in_a_ty, in_a_name) | ||
| 3676 | local | ||
| 3677 | Tpl.Text txt; | ||
| 3678 | String a_name; | ||
| 3679 | |||
| 3680 | case ( txt, | ||
| 3681 | DAE.T_INTEGER(varLst = _), | ||
| 3682 | a_name ) | ||
| 3683 | algorithm | ||
| 3684 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("read_modelica_integer(&inArgs, &")); | |
| 3685 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3686 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3687 | then txt; | ||
| 3688 | |||
| 3689 | case ( txt, | ||
| 3690 | DAE.T_BOOL(varLst = _), | ||
| 3691 | a_name ) | ||
| 3692 | algorithm | ||
| 3693 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("read_modelica_integer(&inArgs, &")); | |
| 3694 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3695 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3696 | then txt; | ||
| 3697 | |||
| 3698 | case ( txt, | ||
| 3699 | DAE.T_REAL(varLst = _), | ||
| 3700 | a_name ) | ||
| 3701 | algorithm | ||
| 3702 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("read_modelica_real(&inArgs, &")); | |
| 3703 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3704 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3705 | then txt; | ||
| 3706 | |||
| 3707 | case ( txt, | ||
| 3708 | DAE.T_STRING(varLst = _), | ||
| 3709 | a_name ) | ||
| 3710 | algorithm | ||
| 3711 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("read_modelica_string(&inArgs, &")); | |
| 3712 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3713 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3714 | then txt; | ||
| 3715 | |||
| 3716 | case ( txt, | ||
| 3717 | DAE.T_ENUMERATION(index = _), | ||
| 3718 | a_name ) | ||
| 3719 | algorithm | ||
| 3720 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("read_modelica_integer(&inArgs, &")); | |
| 3721 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3722 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3723 | then txt; | ||
| 3724 | |||
| 3725 | case ( txt, | ||
| 3726 | DAE.T_COMPLEX(complexClassType = _), | ||
| 3727 | a_name ) | ||
| 3728 | algorithm | ||
| 3729 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("read_modelica_metatype(&inArgs, &")); | |
| 3730 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3731 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3732 | then txt; | ||
| 3733 | |||
| 3734 | case ( txt, | ||
| 3735 | DAE.T_METAUNIONTYPE(paths = _), | ||
| 3736 | a_name ) | ||
| 3737 | algorithm | ||
| 3738 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("read_modelica_metatype(&inArgs, &")); | |
| 3739 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3740 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3741 | then txt; | ||
| 3742 | |||
| 3743 | case ( txt, | ||
| 3744 | DAE.T_METALIST(ty = _), | ||
| 3745 | a_name ) | ||
| 3746 | algorithm | ||
| 3747 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("read_modelica_metatype(&inArgs, &")); | |
| 3748 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3749 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3750 | then txt; | ||
| 3751 | |||
| 3752 | case ( txt, | ||
| 3753 | DAE.T_METAARRAY(ty = _), | ||
| 3754 | a_name ) | ||
| 3755 | algorithm | ||
| 3756 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("read_modelica_metatype(&inArgs, &")); | |
| 3757 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3758 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3759 | then txt; | ||
| 3760 | |||
| 3761 | case ( txt, | ||
| 3762 | DAE.T_METAOPTION(ty = _), | ||
| 3763 | a_name ) | ||
| 3764 | algorithm | ||
| 3765 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("read_modelica_metatype(&inArgs, &")); | |
| 3766 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3767 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3768 | then txt; | ||
| 3769 | |||
| 3770 | case ( txt, | ||
| 3771 | DAE.T_METATUPLE(types = _), | ||
| 3772 | a_name ) | ||
| 3773 | algorithm | ||
| 3774 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("read_modelica_metatype(&inArgs, &")); | |
| 3775 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3776 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3777 | then txt; | ||
| 3778 | |||
| 3779 | case ( txt, | ||
| 3780 | _, | ||
| 3781 | _ ) | ||
| 3782 | then txt; | ||
| 3783 | end match; | ||
| 3784 | end fun_158; | ||
| 3785 | |||
| 3786 | public function varModelicaRead | ||
| 3787 | input Tpl.Text in_txt; | ||
| 3788 | input MidCode.Var in_a_var; | ||
| 3789 | |||
| 3790 | output Tpl.Text out_txt; | ||
| 3791 | algorithm | ||
| 3792 | out_txt := | ||
| 3793 | match(in_txt, in_a_var) | ||
| 3794 | local | ||
| 3795 | Tpl.Text txt; | ||
| 3796 | String i_name; | ||
| 3797 | DAE.Type i_ty; | ||
| 3798 | |||
| 3799 | case ( txt, | ||
| 3800 | MidCode.VAR(name = i_name, ty = i_ty) ) | ||
| 3801 | algorithm | ||
| 3802 | ✗ | txt := fun_158(txt, i_ty, i_name); | |
| 3803 | then txt; | ||
| 3804 | |||
| 3805 | case ( txt, | ||
| 3806 | _ ) | ||
| 3807 | then txt; | ||
| 3808 | end match; | ||
| 3809 | end varModelicaRead; | ||
| 3810 | |||
| 3811 | protected function fun_160 | ||
| 3812 | input Tpl.Text in_txt; | ||
| 3813 | input DAE.Type in_a_ty; | ||
| 3814 | input String in_a_name; | ||
| 3815 | |||
| 3816 | output Tpl.Text out_txt; | ||
| 3817 | algorithm | ||
| 3818 | out_txt := | ||
| 3819 | match(in_txt, in_a_ty, in_a_name) | ||
| 3820 | local | ||
| 3821 | Tpl.Text txt; | ||
| 3822 | String a_name; | ||
| 3823 | |||
| 3824 | case ( txt, | ||
| 3825 | DAE.T_INTEGER(varLst = _), | ||
| 3826 | a_name ) | ||
| 3827 | algorithm | ||
| 3828 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("write_modelica_integer(outVar, &")); | |
| 3829 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3830 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3831 | then txt; | ||
| 3832 | |||
| 3833 | case ( txt, | ||
| 3834 | DAE.T_BOOL(varLst = _), | ||
| 3835 | a_name ) | ||
| 3836 | algorithm | ||
| 3837 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("write_modelica_integer(outVar, &")); | |
| 3838 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3839 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3840 | then txt; | ||
| 3841 | |||
| 3842 | case ( txt, | ||
| 3843 | DAE.T_REAL(varLst = _), | ||
| 3844 | a_name ) | ||
| 3845 | algorithm | ||
| 3846 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("write_modelica_real(outVar, &")); | |
| 3847 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3848 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3849 | then txt; | ||
| 3850 | |||
| 3851 | case ( txt, | ||
| 3852 | DAE.T_STRING(varLst = _), | ||
| 3853 | a_name ) | ||
| 3854 | algorithm | ||
| 3855 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("write_modelica_string(outVar, &")); | |
| 3856 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3857 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3858 | then txt; | ||
| 3859 | |||
| 3860 | case ( txt, | ||
| 3861 | DAE.T_ENUMERATION(index = _), | ||
| 3862 | a_name ) | ||
| 3863 | algorithm | ||
| 3864 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("write_modelica_integer(outVar, &")); | |
| 3865 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3866 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3867 | then txt; | ||
| 3868 | |||
| 3869 | case ( txt, | ||
| 3870 | DAE.T_COMPLEX(complexClassType = _), | ||
| 3871 | a_name ) | ||
| 3872 | algorithm | ||
| 3873 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("write_modelica_metatype(outVar, &")); | |
| 3874 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3875 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3876 | then txt; | ||
| 3877 | |||
| 3878 | case ( txt, | ||
| 3879 | DAE.T_METAUNIONTYPE(paths = _), | ||
| 3880 | a_name ) | ||
| 3881 | algorithm | ||
| 3882 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("write_modelica_metatype(outVar, &")); | |
| 3883 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3884 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3885 | then txt; | ||
| 3886 | |||
| 3887 | case ( txt, | ||
| 3888 | DAE.T_METALIST(ty = _), | ||
| 3889 | a_name ) | ||
| 3890 | algorithm | ||
| 3891 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("write_modelica_metatype(outVar, &")); | |
| 3892 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3893 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3894 | then txt; | ||
| 3895 | |||
| 3896 | case ( txt, | ||
| 3897 | DAE.T_METAARRAY(ty = _), | ||
| 3898 | a_name ) | ||
| 3899 | algorithm | ||
| 3900 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("write_modelica_metatype(outVar, &")); | |
| 3901 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3902 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3903 | then txt; | ||
| 3904 | |||
| 3905 | case ( txt, | ||
| 3906 | DAE.T_METAOPTION(ty = _), | ||
| 3907 | a_name ) | ||
| 3908 | algorithm | ||
| 3909 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("write_modelica_metatype(outVar, &")); | |
| 3910 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3911 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3912 | then txt; | ||
| 3913 | |||
| 3914 | case ( txt, | ||
| 3915 | DAE.T_METATUPLE(types = _), | ||
| 3916 | a_name ) | ||
| 3917 | algorithm | ||
| 3918 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("write_modelica_metatype(outVar, &")); | |
| 3919 | ✗ | txt := Tpl.writeStr(txt, a_name); | |
| 3920 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 3921 | then txt; | ||
| 3922 | |||
| 3923 | case ( txt, | ||
| 3924 | _, | ||
| 3925 | _ ) | ||
| 3926 | then txt; | ||
| 3927 | end match; | ||
| 3928 | end fun_160; | ||
| 3929 | |||
| 3930 | public function varModelicaWrite | ||
| 3931 | input Tpl.Text in_txt; | ||
| 3932 | input MidCode.Var in_a_var; | ||
| 3933 | |||
| 3934 | output Tpl.Text out_txt; | ||
| 3935 | algorithm | ||
| 3936 | out_txt := | ||
| 3937 | match(in_txt, in_a_var) | ||
| 3938 | local | ||
| 3939 | Tpl.Text txt; | ||
| 3940 | String i_name; | ||
| 3941 | DAE.Type i_ty; | ||
| 3942 | |||
| 3943 | case ( txt, | ||
| 3944 | MidCode.VAR(name = i_name, ty = i_ty) ) | ||
| 3945 | algorithm | ||
| 3946 | ✗ | txt := fun_160(txt, i_ty, i_name); | |
| 3947 | then txt; | ||
| 3948 | |||
| 3949 | case ( txt, | ||
| 3950 | _ ) | ||
| 3951 | then txt; | ||
| 3952 | end match; | ||
| 3953 | end varModelicaWrite; | ||
| 3954 | |||
| 3955 | public function identName | ||
| 3956 | input Tpl.Text in_txt; | ||
| 3957 | input Absyn.Path in_a_path; | ||
| 3958 | |||
| 3959 | output Tpl.Text out_txt; | ||
| 3960 | algorithm | ||
| 3961 | out_txt := | ||
| 3962 | match(in_txt, in_a_path) | ||
| 3963 | local | ||
| 3964 | Tpl.Text txt; | ||
| 3965 | String i_name; | ||
| 3966 | |||
| 3967 | case ( txt, | ||
| 3968 | Absyn.IDENT(name = i_name) ) | ||
| 3969 | algorithm | ||
| 3970 | ✗ | txt := Tpl.writeStr(txt, i_name); | |
| 3971 | then txt; | ||
| 3972 | |||
| 3973 | case ( txt, | ||
| 3974 | _ ) | ||
| 3975 | then txt; | ||
| 3976 | end match; | ||
| 3977 | end identName; | ||
| 3978 | |||
| 3979 | public function identBuiltinCall | ||
| 3980 | input Tpl.Text in_txt; | ||
| 3981 | input Absyn.Path in_a_path; | ||
| 3982 | |||
| 3983 | output Tpl.Text out_txt; | ||
| 3984 | algorithm | ||
| 3985 | out_txt := | ||
| 3986 | match(in_txt, in_a_path) | ||
| 3987 | local | ||
| 3988 | Tpl.Text txt; | ||
| 3989 | String i_name; | ||
| 3990 | |||
| 3991 | case ( txt, | ||
| 3992 | Absyn.IDENT(name = "clock") ) | ||
| 3993 | algorithm | ||
| 3994 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("mmc_clock")); | |
| 3995 | then txt; | ||
| 3996 | |||
| 3997 | case ( txt, | ||
| 3998 | Absyn.IDENT(name = "anyString") ) | ||
| 3999 | algorithm | ||
| 4000 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("mmc_anyString")); | |
| 4001 | then txt; | ||
| 4002 | |||
| 4003 | case ( txt, | ||
| 4004 | Absyn.IDENT(name = "fail") ) | ||
| 4005 | algorithm | ||
| 4006 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("MMC_THROW_INTERNAL")); | |
| 4007 | then txt; | ||
| 4008 | |||
| 4009 | case ( txt, | ||
| 4010 | Absyn.IDENT(name = "intMod") ) | ||
| 4011 | algorithm | ||
| 4012 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("modelica_mod_integer")); | |
| 4013 | then txt; | ||
| 4014 | |||
| 4015 | case ( txt, | ||
| 4016 | Absyn.IDENT(name = i_name) ) | ||
| 4017 | algorithm | ||
| 4018 | ✗ | txt := Tpl.writeStr(txt, i_name); | |
| 4019 | then txt; | ||
| 4020 | |||
| 4021 | case ( txt, | ||
| 4022 | _ ) | ||
| 4023 | then txt; | ||
| 4024 | end match; | ||
| 4025 | end identBuiltinCall; | ||
| 4026 | |||
| 4027 | public function replaceDotAndUnderscore | ||
| 4028 | input Tpl.Text in_txt; | ||
| 4029 | input String in_a_str; | ||
| 4030 | |||
| 4031 | output Tpl.Text out_txt; | ||
| 4032 | algorithm | ||
| 4033 | out_txt := | ||
| 4034 | match(in_txt, in_a_str) | ||
| 4035 | local | ||
| 4036 | Tpl.Text txt; | ||
| 4037 | String i_name; | ||
| 4038 | String ret_4; | ||
| 4039 | String ret_3; | ||
| 4040 | Tpl.Text l_str__underscores; | ||
| 4041 | String ret_1; | ||
| 4042 | Tpl.Text l_str__dots; | ||
| 4043 | |||
| 4044 | case ( txt, | ||
| 4045 | i_name ) | ||
| 4046 | algorithm | ||
| 4047 | ✗ | ret_1 := System.stringReplace(i_name, ".", "_"); | |
| 4048 | ✗ | l_str__dots := Tpl.writeStr(Tpl.emptyTxt, ret_1); | |
| 4049 | ✗ | ret_3 := System.stringReplace(Tpl.textString(l_str__dots), "_", "__"); | |
| 4050 | ✗ | l_str__underscores := Tpl.writeStr(Tpl.emptyTxt, ret_3); | |
| 4051 | ✗ | ret_4 := System.unquoteIdentifier(Tpl.textString(l_str__underscores)); | |
| 4052 | ✗ | txt := Tpl.writeStr(txt, ret_4); | |
| 4053 | then txt; | ||
| 4054 | end match; | ||
| 4055 | end replaceDotAndUnderscore; | ||
| 4056 | |||
| 4057 | public function underscorePath | ||
| 4058 | input Tpl.Text in_txt; | ||
| 4059 | input Absyn.Path in_a_path; | ||
| 4060 | |||
| 4061 | output Tpl.Text out_txt; | ||
| 4062 | algorithm | ||
| 4063 | out_txt := | ||
| 4064 | match(in_txt, in_a_path) | ||
| 4065 | local | ||
| 4066 | Tpl.Text txt; | ||
| 4067 | String i_name_1; | ||
| 4068 | Absyn.Path i_path; | ||
| 4069 | Absyn.Ident i_name; | ||
| 4070 | |||
| 4071 | case ( txt, | ||
| 4072 | Absyn.QUALIFIED(name = i_name, path = i_path) ) | ||
| 4073 | algorithm | ||
| 4074 | ✗ | txt := replaceDotAndUnderscore(txt, i_name); | |
| 4075 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("_")); | |
| 4076 | ✗ | txt := underscorePath(txt, i_path); | |
| 4077 | then txt; | ||
| 4078 | |||
| 4079 | case ( txt, | ||
| 4080 | Absyn.IDENT(name = i_name_1) ) | ||
| 4081 | algorithm | ||
| 4082 | ✗ | txt := replaceDotAndUnderscore(txt, i_name_1); | |
| 4083 | then txt; | ||
| 4084 | |||
| 4085 | case ( txt, | ||
| 4086 | Absyn.FULLYQUALIFIED(path = i_path) ) | ||
| 4087 | algorithm | ||
| 4088 | ✗ | txt := underscorePath(txt, i_path); | |
| 4089 | then txt; | ||
| 4090 | |||
| 4091 | case ( txt, | ||
| 4092 | _ ) | ||
| 4093 | then txt; | ||
| 4094 | end match; | ||
| 4095 | end underscorePath; | ||
| 4096 | |||
| 4097 | annotation(__OpenModelica_Interface="codegen"); | ||
| 4098 | end CodegenMidToC; | ||
| 4099 |