build_cmake/OMCompiler/Compiler/generated-mo/Template/CodegenUtil.mo
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | encapsulated package CodegenUtil | ||
| 2 | " | ||
| 3 | file: CodegenUtil.mo | ||
| 4 | package: CodegenUtil | ||
| 5 | description: Generated by Susan. | ||
| 6 | " | ||
| 7 | |||
| 8 | public import Tpl; | ||
| 9 | |||
| 10 | public import SimCodeVar; | ||
| 11 | public import HashTableCrefSimVar; | ||
| 12 | public import SimCode; | ||
| 13 | public import SimCodeFunction; | ||
| 14 | public import SimCodeCodegenUtil; | ||
| 15 | public import SimCodeFunctionUtil; | ||
| 16 | public import BackendDAE; | ||
| 17 | public import System; | ||
| 18 | public import Autoconf; | ||
| 19 | protected import Absyn; | ||
| 20 | protected import AbsynUtil; | ||
| 21 | public import MMath; | ||
| 22 | public import DAE; | ||
| 23 | public import ClassInf; | ||
| 24 | public import ClassInfUtil; | ||
| 25 | protected import SCode; | ||
| 26 | protected import SCodeDump; | ||
| 27 | public import StringUtil; | ||
| 28 | public import Util; | ||
| 29 | public import List; | ||
| 30 | public import ComponentReferenceBasics; | ||
| 31 | public import ComponentReference; | ||
| 32 | public import Expression; | ||
| 33 | protected import ExpressionDump; | ||
| 34 | public import ExpressionBasics; | ||
| 35 | public import Config; | ||
| 36 | public import Testsuite; | ||
| 37 | public import Flags; | ||
| 38 | public import FlagsUtil; | ||
| 39 | public import Settings; | ||
| 40 | public import Patternm; | ||
| 41 | public import Error; | ||
| 42 | public import Values; | ||
| 43 | public import ValuesUtil; | ||
| 44 | public import DAEDump; | ||
| 45 | public import Algorithm; | ||
| 46 | protected import ElementSource; | ||
| 47 | public import DAEUtil; | ||
| 48 | public import TypesDump; | ||
| 49 | public import Types; | ||
| 50 | public import HashTableCrIListArray; | ||
| 51 | public import ExpressionDumpTpl; | ||
| 52 | |||
| 53 | public function symbolName | ||
| 54 | input Tpl.Text txt; | ||
| 55 | input String a_modelNamePrefix; | ||
| 56 | input String a_symbolName; | ||
| 57 | |||
| 58 | output Tpl.Text out_txt; | ||
| 59 | algorithm | ||
| 60 | 757134 | out_txt := Tpl.writeStr(txt, a_modelNamePrefix); | |
| 61 | 757134 | out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("_")); | |
| 62 | 757134 | out_txt := Tpl.writeStr(out_txt, a_symbolName); | |
| 63 | end symbolName; | ||
| 64 | |||
| 65 | protected function fun_45 | ||
| 66 | input Tpl.Text in_txt; | ||
| 67 | input Boolean in_mArg; | ||
| 68 | input String in_a_str; | ||
| 69 | |||
| 70 | output Tpl.Text out_txt; | ||
| 71 | algorithm | ||
| 72 | out_txt := | ||
| 73 | match(in_txt, in_mArg, in_a_str) | ||
| 74 | local | ||
| 75 | Tpl.Text txt; | ||
| 76 | String a_str; | ||
| 77 | String ret_0; | ||
| 78 | |||
| 79 | case ( txt, | ||
| 80 | false, | ||
| 81 | a_str ) | ||
| 82 | algorithm | ||
| 83 | 911044 | ret_0 := System.stringReplace(a_str, ".", "_"); | |
| 84 | 911044 | txt := Tpl.writeStr(txt, ret_0); | |
| 85 | then txt; | ||
| 86 | |||
| 87 | case ( txt, | ||
| 88 | _, | ||
| 89 | a_str ) | ||
| 90 | algorithm | ||
| 91 | 754 | txt := Tpl.writeStr(txt, a_str); | |
| 92 | then txt; | ||
| 93 | end match; | ||
| 94 | end fun_45; | ||
| 95 | |||
| 96 | public function replaceDotAndUnderscore | ||
| 97 | input Tpl.Text txt; | ||
| 98 | input String a_str; | ||
| 99 | |||
| 100 | output Tpl.Text out_txt; | ||
| 101 | protected | ||
| 102 | String ret_5; | ||
| 103 | String ret_4; | ||
| 104 | Tpl.Text l_str__underscores; | ||
| 105 | Boolean ret_2; | ||
| 106 | String ret_1; | ||
| 107 | Tpl.Text l_str__dots; | ||
| 108 | algorithm | ||
| 109 | 911798 | ret_1 := substring(a_str, 1, 1); | |
| 110 |
3/4✓ Branch 0 taken 911798 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 911044 times.
✓ Branch 4 taken 754 times.
|
911798 | ret_2 := stringEq(ret_1, "\'"); |
| 111 | 911798 | l_str__dots := fun_45(Tpl.emptyTxt, ret_2, a_str); | |
| 112 | 911798 | ret_4 := System.stringReplace(Tpl.textString(l_str__dots), "_", "__"); | |
| 113 | 911798 | l_str__underscores := Tpl.writeStr(Tpl.emptyTxt, ret_4); | |
| 114 | 911798 | ret_5 := System.unquoteIdentifier(Tpl.textString(l_str__underscores)); | |
| 115 | 911798 | out_txt := Tpl.writeStr(txt, ret_5); | |
| 116 | end replaceDotAndUnderscore; | ||
| 117 | |||
| 118 | public function getGeneralTarget | ||
| 119 | input Tpl.Text in_txt; | ||
| 120 | input String in_a_str; | ||
| 121 | |||
| 122 | output Tpl.Text out_txt; | ||
| 123 | algorithm | ||
| 124 | out_txt := | ||
| 125 | match(in_txt, in_a_str) | ||
| 126 | local | ||
| 127 | Tpl.Text txt; | ||
| 128 | String i_str; | ||
| 129 | |||
| 130 | case ( txt, | ||
| 131 | "msvc10" ) | ||
| 132 | algorithm | ||
| 133 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("msvc")); | |
| 134 | then txt; | ||
| 135 | |||
| 136 | case ( txt, | ||
| 137 | "msvc12" ) | ||
| 138 | algorithm | ||
| 139 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("msvc")); | |
| 140 | then txt; | ||
| 141 | |||
| 142 | case ( txt, | ||
| 143 | "msvc13" ) | ||
| 144 | algorithm | ||
| 145 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("msvc")); | |
| 146 | then txt; | ||
| 147 | |||
| 148 | case ( txt, | ||
| 149 | "msvc15" ) | ||
| 150 | algorithm | ||
| 151 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("msvc")); | |
| 152 | then txt; | ||
| 153 | |||
| 154 | case ( txt, | ||
| 155 | "msvc19" ) | ||
| 156 | algorithm | ||
| 157 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("msvc")); | |
| 158 | then txt; | ||
| 159 | |||
| 160 | case ( txt, | ||
| 161 | i_str ) | ||
| 162 | algorithm | ||
| 163 | 1404 | txt := Tpl.writeStr(txt, i_str); | |
| 164 | then txt; | ||
| 165 | end match; | ||
| 166 | end getGeneralTarget; | ||
| 167 | |||
| 168 | public function underscorePath | ||
| 169 | input Tpl.Text in_txt; | ||
| 170 | input Absyn.Path in_a_path; | ||
| 171 | |||
| 172 | output Tpl.Text out_txt; | ||
| 173 | algorithm | ||
| 174 | out_txt := | ||
| 175 | match(in_txt, in_a_path) | ||
| 176 | local | ||
| 177 | Tpl.Text txt; | ||
| 178 | String i_name_1; | ||
| 179 | Absyn.Path i_path; | ||
| 180 | Absyn.Ident i_name; | ||
| 181 | |||
| 182 | case ( txt, | ||
| 183 | Absyn.QUALIFIED(name = i_name, path = i_path) ) | ||
| 184 | algorithm | ||
| 185 | 693993 | txt := replaceDotAndUnderscore(txt, i_name); | |
| 186 | 693993 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("_")); | |
| 187 | 693993 | txt := underscorePath(txt, i_path); | |
| 188 | then txt; | ||
| 189 | |||
| 190 | case ( txt, | ||
| 191 | Absyn.IDENT(name = i_name_1) ) | ||
| 192 | algorithm | ||
| 193 | 217805 | txt := replaceDotAndUnderscore(txt, i_name_1); | |
| 194 | then txt; | ||
| 195 | |||
| 196 | case ( txt, | ||
| 197 | Absyn.FULLYQUALIFIED(path = i_path) ) | ||
| 198 | algorithm | ||
| 199 | 55220 | txt := underscorePath(txt, i_path); | |
| 200 | then txt; | ||
| 201 | |||
| 202 | case ( txt, | ||
| 203 | _ ) | ||
| 204 | then txt; | ||
| 205 | end match; | ||
| 206 | end underscorePath; | ||
| 207 | |||
| 208 | public function crefStr | ||
| 209 | input Tpl.Text in_txt; | ||
| 210 | input DAE.ComponentRef in_a_cr; | ||
| 211 | |||
| 212 | output Tpl.Text out_txt; | ||
| 213 | algorithm | ||
| 214 | out_txt := | ||
| 215 | match(in_txt, in_a_cr) | ||
| 216 | local | ||
| 217 | Tpl.Text txt; | ||
| 218 | DAE.ComponentRef i_componentRef; | ||
| 219 | list<DAE.Subscript> i_subscriptLst; | ||
| 220 | DAE.Ident i_ident; | ||
| 221 | String ret_1; | ||
| 222 | String ret_0; | ||
| 223 | |||
| 224 | case ( txt, | ||
| 225 | DAE.CREF_IDENT(ident = i_ident, subscriptLst = i_subscriptLst) ) | ||
| 226 | algorithm | ||
| 227 | 377012 | ret_0 := System.unquoteIdentifier(i_ident); | |
| 228 | 377012 | txt := Tpl.writeStr(txt, ret_0); | |
| 229 | 377012 | txt := subscriptsStr(txt, i_subscriptLst); | |
| 230 | then txt; | ||
| 231 | |||
| 232 | case ( txt, | ||
| 233 | DAE.CREF_QUAL(ident = "$DER", componentRef = i_componentRef) ) | ||
| 234 | algorithm | ||
| 235 | 1167 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("der(")); | |
| 236 | 1167 | txt := crefStr(txt, i_componentRef); | |
| 237 | 1167 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 238 | then txt; | ||
| 239 | |||
| 240 | case ( txt, | ||
| 241 | DAE.CREF_QUAL(ident = "$CLKPRE", componentRef = i_componentRef) ) | ||
| 242 | algorithm | ||
| 243 | 132 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("previous(")); | |
| 244 | 132 | txt := crefStr(txt, i_componentRef); | |
| 245 | 132 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 246 | then txt; | ||
| 247 | |||
| 248 | case ( txt, | ||
| 249 | DAE.CREF_QUAL(ident = i_ident, subscriptLst = i_subscriptLst, componentRef = i_componentRef) ) | ||
| 250 | algorithm | ||
| 251 | 48950 | ret_1 := System.unquoteIdentifier(i_ident); | |
| 252 | 48950 | txt := Tpl.writeStr(txt, ret_1); | |
| 253 | 48950 | txt := subscriptsStr(txt, i_subscriptLst); | |
| 254 | 48950 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("._")); | |
| 255 | 48950 | txt := crefStr(txt, i_componentRef); | |
| 256 | then txt; | ||
| 257 | |||
| 258 | case ( txt, | ||
| 259 | _ ) | ||
| 260 | algorithm | ||
| 261 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("CREF_NOT_IDENT_OR_QUAL")); | |
| 262 | then txt; | ||
| 263 | end match; | ||
| 264 | end crefStr; | ||
| 265 | |||
| 266 | public function crefStrNoUnderscore | ||
| 267 | input Tpl.Text in_txt; | ||
| 268 | input DAE.ComponentRef in_a_cr; | ||
| 269 | |||
| 270 | output Tpl.Text out_txt; | ||
| 271 | algorithm | ||
| 272 | out_txt := | ||
| 273 | match(in_txt, in_a_cr) | ||
| 274 | local | ||
| 275 | Tpl.Text txt; | ||
| 276 | DAE.ComponentRef i_componentRef; | ||
| 277 | list<DAE.Subscript> i_subscriptLst; | ||
| 278 | DAE.Ident i_ident; | ||
| 279 | |||
| 280 | case ( txt, | ||
| 281 | DAE.CREF_IDENT(ident = i_ident, subscriptLst = i_subscriptLst) ) | ||
| 282 | algorithm | ||
| 283 | 1083733 | txt := Tpl.writeStr(txt, i_ident); | |
| 284 | 1083733 | txt := subscriptsStr(txt, i_subscriptLst); | |
| 285 | then txt; | ||
| 286 | |||
| 287 | case ( txt, | ||
| 288 | DAE.CREF_QUAL(ident = "$DER", componentRef = i_componentRef) ) | ||
| 289 | algorithm | ||
| 290 | 65253 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("der(")); | |
| 291 | 65253 | txt := crefStrNoUnderscore(txt, i_componentRef); | |
| 292 | 65253 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 293 | then txt; | ||
| 294 | |||
| 295 | case ( txt, | ||
| 296 | DAE.CREF_QUAL(ident = "$CLKPRE", componentRef = i_componentRef) ) | ||
| 297 | algorithm | ||
| 298 | 601 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("previous(")); | |
| 299 | 601 | txt := crefStrNoUnderscore(txt, i_componentRef); | |
| 300 | 601 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 301 | then txt; | ||
| 302 | |||
| 303 | case ( txt, | ||
| 304 | DAE.CREF_QUAL(ident = i_ident, subscriptLst = i_subscriptLst, componentRef = i_componentRef) ) | ||
| 305 | algorithm | ||
| 306 | 2152382 | txt := Tpl.writeStr(txt, i_ident); | |
| 307 | 2152382 | txt := subscriptsStr(txt, i_subscriptLst); | |
| 308 | 2152382 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(".")); | |
| 309 | 2152382 | txt := crefStrNoUnderscore(txt, i_componentRef); | |
| 310 | then txt; | ||
| 311 | |||
| 312 | case ( txt, | ||
| 313 | _ ) | ||
| 314 | algorithm | ||
| 315 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("CREF_NOT_IDENT_OR_QUAL")); | |
| 316 | then txt; | ||
| 317 | end match; | ||
| 318 | end crefStrNoUnderscore; | ||
| 319 | |||
| 320 | protected function lm_51 | ||
| 321 | input output Tpl.Text txt; | ||
| 322 | input list<DAE.Subscript> items; | ||
| 323 | algorithm | ||
| 324 |
2/2✓ Branch 0 taken 714206 times.
✓ Branch 1 taken 627900 times.
|
1342106 | for lstElt_51 in items loop |
| 325 | txt := match lstElt_51 | ||
| 326 | local | ||
| 327 | DAE.Subscript i_s; | ||
| 328 | |||
| 329 | case i_s | ||
| 330 | algorithm | ||
| 331 | 714206 | txt := subscriptStr(txt, i_s); | |
| 332 | 714206 | txt := Tpl.nextIter(txt); | |
| 333 | then txt; | ||
| 334 | end match; | ||
| 335 | end for; | ||
| 336 | end lm_51; | ||
| 337 | |||
| 338 | public function subscriptsStr | ||
| 339 | input Tpl.Text in_txt; | ||
| 340 | input list<DAE.Subscript> in_a_subscripts; | ||
| 341 | |||
| 342 | output Tpl.Text out_txt; | ||
| 343 | algorithm | ||
| 344 | out_txt := | ||
| 345 | match(in_txt, in_a_subscripts) | ||
| 346 | local | ||
| 347 | Tpl.Text txt; | ||
| 348 | list<DAE.Subscript> i_subscripts; | ||
| 349 | |||
| 350 | case ( txt, | ||
| 351 | {} ) | ||
| 352 | then txt; | ||
| 353 | |||
| 354 | case ( txt, | ||
| 355 | i_subscripts ) | ||
| 356 | algorithm | ||
| 357 | 627900 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("[")); | |
| 358 | 627900 | txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(",")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 359 | 627900 | txt := lm_51(txt, i_subscripts); | |
| 360 | 627900 | txt := Tpl.popIter(txt); | |
| 361 | 627900 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("]")); | |
| 362 | then txt; | ||
| 363 | end match; | ||
| 364 | end subscriptsStr; | ||
| 365 | |||
| 366 | public function crefStrMatlabSafe | ||
| 367 | input Tpl.Text in_txt; | ||
| 368 | input DAE.ComponentRef in_a_cr; | ||
| 369 | |||
| 370 | output Tpl.Text out_txt; | ||
| 371 | algorithm | ||
| 372 | out_txt := | ||
| 373 | match(in_txt, in_a_cr) | ||
| 374 | local | ||
| 375 | Tpl.Text txt; | ||
| 376 | DAE.ComponentRef i_componentRef; | ||
| 377 | list<DAE.Subscript> i_subscriptLst; | ||
| 378 | DAE.Ident i_ident; | ||
| 379 | |||
| 380 | case ( txt, | ||
| 381 | DAE.CREF_IDENT(ident = i_ident, subscriptLst = i_subscriptLst) ) | ||
| 382 | algorithm | ||
| 383 | ✗ | txt := Tpl.writeStr(txt, i_ident); | |
| 384 | ✗ | txt := subscriptsStrMatlabSafe(txt, i_subscriptLst); | |
| 385 | then txt; | ||
| 386 | |||
| 387 | case ( txt, | ||
| 388 | DAE.CREF_QUAL(ident = "$DER", componentRef = i_componentRef) ) | ||
| 389 | algorithm | ||
| 390 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("der_")); | |
| 391 | ✗ | txt := crefStrMatlabSafe(txt, i_componentRef); | |
| 392 | then txt; | ||
| 393 | |||
| 394 | case ( txt, | ||
| 395 | DAE.CREF_QUAL(ident = "$CLKPRE", componentRef = i_componentRef) ) | ||
| 396 | algorithm | ||
| 397 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("pre_")); | |
| 398 | ✗ | txt := crefStrMatlabSafe(txt, i_componentRef); | |
| 399 | then txt; | ||
| 400 | |||
| 401 | case ( txt, | ||
| 402 | DAE.CREF_QUAL(ident = i_ident, subscriptLst = i_subscriptLst, componentRef = i_componentRef) ) | ||
| 403 | algorithm | ||
| 404 | ✗ | txt := Tpl.writeStr(txt, i_ident); | |
| 405 | ✗ | txt := subscriptsStrMatlabSafe(txt, i_subscriptLst); | |
| 406 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("_")); | |
| 407 | ✗ | txt := crefStrMatlabSafe(txt, i_componentRef); | |
| 408 | then txt; | ||
| 409 | |||
| 410 | case ( txt, | ||
| 411 | _ ) | ||
| 412 | algorithm | ||
| 413 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("CREF_NOT_IDENT_OR_QUAL")); | |
| 414 | then txt; | ||
| 415 | end match; | ||
| 416 | end crefStrMatlabSafe; | ||
| 417 | |||
| 418 | protected function lm_54 | ||
| 419 | input output Tpl.Text txt; | ||
| 420 | input list<DAE.Subscript> items; | ||
| 421 | algorithm | ||
| 422 | ✗ | for lstElt_54 in items loop | |
| 423 | txt := match lstElt_54 | ||
| 424 | local | ||
| 425 | DAE.Subscript i_s; | ||
| 426 | |||
| 427 | case i_s | ||
| 428 | algorithm | ||
| 429 | ✗ | txt := subscriptStr(txt, i_s); | |
| 430 | ✗ | txt := Tpl.nextIter(txt); | |
| 431 | then txt; | ||
| 432 | end match; | ||
| 433 | end for; | ||
| 434 | end lm_54; | ||
| 435 | |||
| 436 | public function subscriptsStrMatlabSafe | ||
| 437 | input Tpl.Text in_txt; | ||
| 438 | input list<DAE.Subscript> in_a_subscripts; | ||
| 439 | |||
| 440 | output Tpl.Text out_txt; | ||
| 441 | algorithm | ||
| 442 | out_txt := | ||
| 443 | match(in_txt, in_a_subscripts) | ||
| 444 | local | ||
| 445 | Tpl.Text txt; | ||
| 446 | list<DAE.Subscript> i_subscripts; | ||
| 447 | |||
| 448 | case ( txt, | ||
| 449 | {} ) | ||
| 450 | then txt; | ||
| 451 | |||
| 452 | case ( txt, | ||
| 453 | i_subscripts ) | ||
| 454 | algorithm | ||
| 455 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("(")); | |
| 456 | ✗ | txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(",")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 457 | ✗ | txt := lm_54(txt, i_subscripts); | |
| 458 | ✗ | txt := Tpl.popIter(txt); | |
| 459 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 460 | then txt; | ||
| 461 | end match; | ||
| 462 | end subscriptsStrMatlabSafe; | ||
| 463 | |||
| 464 | public function subscriptStr | ||
| 465 | input Tpl.Text in_txt; | ||
| 466 | input DAE.Subscript in_a_subscript; | ||
| 467 | |||
| 468 | output Tpl.Text out_txt; | ||
| 469 | algorithm | ||
| 470 | out_txt := | ||
| 471 | match(in_txt, in_a_subscript) | ||
| 472 | local | ||
| 473 | Tpl.Text txt; | ||
| 474 | DAE.Exp i_exp; | ||
| 475 | Absyn.Path i_n; | ||
| 476 | Boolean i_i_1; | ||
| 477 | Integer i_i; | ||
| 478 | String ret_2; | ||
| 479 | String ret_1; | ||
| 480 | String ret_0; | ||
| 481 | |||
| 482 | case ( txt, | ||
| 483 | DAE.INDEX(exp = DAE.ICONST(integer = i_i)) ) | ||
| 484 | algorithm | ||
| 485 | 711975 | txt := Tpl.writeStr(txt, intString(i_i)); | |
| 486 | then txt; | ||
| 487 | |||
| 488 | case ( txt, | ||
| 489 | DAE.INDEX(exp = DAE.BCONST(bool = i_i_1)) ) | ||
| 490 | algorithm | ||
| 491 | ✗ | txt := Tpl.writeStr(txt, Tpl.booleanString(i_i_1)); | |
| 492 | then txt; | ||
| 493 | |||
| 494 | case ( txt, | ||
| 495 | DAE.INDEX(exp = DAE.ENUM_LITERAL(name = i_n)) ) | ||
| 496 | algorithm | ||
| 497 | 303 | txt := dotPath(txt, i_n); | |
| 498 | then txt; | ||
| 499 | |||
| 500 | case ( txt, | ||
| 501 | DAE.INDEX(exp = (i_exp as DAE.CREF(componentRef = _))) ) | ||
| 502 | algorithm | ||
| 503 | 810 | ret_0 := ExpressionBasics.printExpStr(i_exp); | |
| 504 | 810 | txt := Tpl.writeStr(txt, ret_0); | |
| 505 | then txt; | ||
| 506 | |||
| 507 | case ( txt, | ||
| 508 | DAE.SLICE(exp = DAE.ICONST(integer = i_i)) ) | ||
| 509 | algorithm | ||
| 510 | ✗ | txt := Tpl.writeStr(txt, intString(i_i)); | |
| 511 | then txt; | ||
| 512 | |||
| 513 | case ( txt, | ||
| 514 | DAE.INDEX(exp = i_exp) ) | ||
| 515 | algorithm | ||
| 516 | 724 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("UNKNOWN_SUBSCRIPT /* ")); | |
| 517 | 724 | ret_1 := ExpressionBasics.printExpStr(i_exp); | |
| 518 | 724 | txt := escapeCComments(txt, ret_1); | |
| 519 | 724 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" */")); | |
| 520 | then txt; | ||
| 521 | |||
| 522 | case ( txt, | ||
| 523 | DAE.SLICE(exp = i_exp) ) | ||
| 524 | algorithm | ||
| 525 | 80 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("UNKNOWN_SUBSCRIPT /* ")); | |
| 526 | 80 | ret_2 := ExpressionBasics.printExpStr(i_exp); | |
| 527 | 80 | txt := escapeCComments(txt, ret_2); | |
| 528 | 80 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" */")); | |
| 529 | then txt; | ||
| 530 | |||
| 531 | case ( txt, | ||
| 532 | DAE.WHOLEDIM() ) | ||
| 533 | algorithm | ||
| 534 | 314 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("WHOLEDIM")); | |
| 535 | then txt; | ||
| 536 | |||
| 537 | case ( txt, | ||
| 538 | DAE.WHOLE_NONEXP() ) | ||
| 539 | algorithm | ||
| 540 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("WHOLE_NONEXP")); | |
| 541 | then txt; | ||
| 542 | |||
| 543 | case ( txt, | ||
| 544 | _ ) | ||
| 545 | algorithm | ||
| 546 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("UNKNOWN_SUBSCRIPT")); | |
| 547 | then txt; | ||
| 548 | end match; | ||
| 549 | end subscriptStr; | ||
| 550 | |||
| 551 | public function escapeCComments | ||
| 552 | input Tpl.Text txt; | ||
| 553 | input String a_stringWithCComments; | ||
| 554 | |||
| 555 | output Tpl.Text out_txt; | ||
| 556 | protected | ||
| 557 | String ret_1; | ||
| 558 | String ret_0; | ||
| 559 | algorithm | ||
| 560 | 1464753 | ret_0 := System.stringReplace(a_stringWithCComments, "/*", "(*"); | |
| 561 | 1464753 | ret_1 := System.stringReplace(ret_0, "*/", "*)"); | |
| 562 | 1464753 | out_txt := Tpl.writeStr(txt, ret_1); | |
| 563 | end escapeCComments; | ||
| 564 | |||
| 565 | protected function fun_58 | ||
| 566 | input Tpl.Text in_txt; | ||
| 567 | input Boolean in_mArg; | ||
| 568 | input String in_a_vName; | ||
| 569 | |||
| 570 | output Tpl.Text out_txt; | ||
| 571 | algorithm | ||
| 572 | out_txt := | ||
| 573 | match(in_txt, in_mArg, in_a_vName) | ||
| 574 | local | ||
| 575 | Tpl.Text txt; | ||
| 576 | String a_vName; | ||
| 577 | |||
| 578 | case ( txt, | ||
| 579 | false, | ||
| 580 | _ ) | ||
| 581 | algorithm | ||
| 582 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("OBFUSCATED")); | |
| 583 | then txt; | ||
| 584 | |||
| 585 | case ( txt, | ||
| 586 | _, | ||
| 587 | a_vName ) | ||
| 588 | algorithm | ||
| 589 | 2548 | txt := escapeCComments(txt, a_vName); | |
| 590 | then txt; | ||
| 591 | end match; | ||
| 592 | end fun_58; | ||
| 593 | |||
| 594 | protected function fun_59 | ||
| 595 | input Tpl.Text in_txt; | ||
| 596 | input Boolean in_mArg; | ||
| 597 | input String in_a_vName; | ||
| 598 | |||
| 599 | output Tpl.Text out_txt; | ||
| 600 | algorithm | ||
| 601 | out_txt := | ||
| 602 | match(in_txt, in_mArg, in_a_vName) | ||
| 603 | local | ||
| 604 | Tpl.Text txt; | ||
| 605 | String a_vName; | ||
| 606 | |||
| 607 | case ( txt, | ||
| 608 | false, | ||
| 609 | a_vName ) | ||
| 610 | algorithm | ||
| 611 | 23364 | txt := escapeCComments(txt, a_vName); | |
| 612 | then txt; | ||
| 613 | |||
| 614 | case ( txt, | ||
| 615 | _, | ||
| 616 | _ ) | ||
| 617 | algorithm | ||
| 618 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("OBFUSCATED")); | |
| 619 | then txt; | ||
| 620 | end match; | ||
| 621 | end fun_59; | ||
| 622 | |||
| 623 | public function crefCComment | ||
| 624 | input Tpl.Text in_txt; | ||
| 625 | input SimCodeVar.SimVar in_a_v; | ||
| 626 | input String in_a_vName; | ||
| 627 | |||
| 628 | output Tpl.Text out_txt; | ||
| 629 | algorithm | ||
| 630 | out_txt := | ||
| 631 | match(in_txt, in_a_v, in_a_vName) | ||
| 632 | local | ||
| 633 | Tpl.Text txt; | ||
| 634 | String a_vName; | ||
| 635 | Boolean ret_3; | ||
| 636 | String ret_2; | ||
| 637 | Boolean ret_1; | ||
| 638 | String ret_0; | ||
| 639 | |||
| 640 | case ( txt, | ||
| 641 | SimCodeVar.SIMVAR(isProtected = true), | ||
| 642 | a_vName ) | ||
| 643 | algorithm | ||
| 644 | 2548 | ret_0 := Flags.getConfigString(Flags.OBFUSCATE); | |
| 645 |
2/4✓ Branch 0 taken 2548 times.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 2548 times.
|
2548 | ret_1 := stringEq(ret_0, "none"); |
| 646 | 2548 | txt := fun_58(txt, ret_1, a_vName); | |
| 647 | then txt; | ||
| 648 | |||
| 649 | case ( txt, | ||
| 650 | SimCodeVar.SIMVAR(name = _), | ||
| 651 | a_vName ) | ||
| 652 | algorithm | ||
| 653 | 23364 | ret_2 := Flags.getConfigString(Flags.OBFUSCATE); | |
| 654 |
2/4✓ Branch 0 taken 23364 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 23364 times.
✗ Branch 4 not taken.
|
23364 | ret_3 := stringEq(ret_2, "full"); |
| 655 | 23364 | txt := fun_59(txt, ret_3, a_vName); | |
| 656 | then txt; | ||
| 657 | |||
| 658 | case ( txt, | ||
| 659 | _, | ||
| 660 | _ ) | ||
| 661 | then txt; | ||
| 662 | end match; | ||
| 663 | end crefCComment; | ||
| 664 | |||
| 665 | protected function fun_61 | ||
| 666 | input Tpl.Text in_txt; | ||
| 667 | input Boolean in_mArg; | ||
| 668 | input BackendDAE.VarKind in_a_varKind; | ||
| 669 | input DAE.ComponentRef in_a_name; | ||
| 670 | |||
| 671 | output Tpl.Text out_txt; | ||
| 672 | algorithm | ||
| 673 | out_txt := | ||
| 674 | match(in_txt, in_mArg, in_a_varKind, in_a_name) | ||
| 675 | local | ||
| 676 | Tpl.Text txt; | ||
| 677 | BackendDAE.VarKind a_varKind; | ||
| 678 | DAE.ComponentRef a_name; | ||
| 679 | Tpl.Text txt_0; | ||
| 680 | |||
| 681 | case ( txt, | ||
| 682 | false, | ||
| 683 | _, | ||
| 684 | _ ) | ||
| 685 | then txt; | ||
| 686 | |||
| 687 | case ( txt, | ||
| 688 | _, | ||
| 689 | a_varKind, | ||
| 690 | a_name ) | ||
| 691 | algorithm | ||
| 692 | 188604 | txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(1)); | |
| 693 | 188604 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("/* ")); | |
| 694 | 188604 | txt_0 := crefStrNoUnderscore(Tpl.emptyTxt, a_name); | |
| 695 | 188604 | txt := escapeCComments(txt, Tpl.textString(txt_0)); | |
| 696 | 188604 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" ")); | |
| 697 | 188604 | txt := variabilityString(txt, a_varKind); | |
| 698 | 188604 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" */")); | |
| 699 | 188604 | txt := Tpl.popBlock(txt); | |
| 700 | then txt; | ||
| 701 | end match; | ||
| 702 | end fun_61; | ||
| 703 | |||
| 704 | protected function fun_62 | ||
| 705 | input Tpl.Text in_txt; | ||
| 706 | input Boolean in_mArg; | ||
| 707 | input BackendDAE.VarKind in_a_varKind; | ||
| 708 | input DAE.ComponentRef in_a_name; | ||
| 709 | |||
| 710 | output Tpl.Text out_txt; | ||
| 711 | algorithm | ||
| 712 | out_txt := | ||
| 713 | match(in_txt, in_mArg, in_a_varKind, in_a_name) | ||
| 714 | local | ||
| 715 | Tpl.Text txt; | ||
| 716 | BackendDAE.VarKind a_varKind; | ||
| 717 | DAE.ComponentRef a_name; | ||
| 718 | Tpl.Text txt_0; | ||
| 719 | |||
| 720 | case ( txt, | ||
| 721 | false, | ||
| 722 | a_varKind, | ||
| 723 | a_name ) | ||
| 724 | algorithm | ||
| 725 | 800052 | txt := Tpl.pushBlock(txt, Tpl.BT_INDENT(1)); | |
| 726 | 800052 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("/* ")); | |
| 727 | 800052 | txt_0 := crefStrNoUnderscore(Tpl.emptyTxt, a_name); | |
| 728 | 800052 | txt := escapeCComments(txt, Tpl.textString(txt_0)); | |
| 729 | 800052 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" ")); | |
| 730 | 800052 | txt := variabilityString(txt, a_varKind); | |
| 731 | 800052 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(" */")); | |
| 732 | 800052 | txt := Tpl.popBlock(txt); | |
| 733 | then txt; | ||
| 734 | |||
| 735 | case ( txt, | ||
| 736 | _, | ||
| 737 | _, | ||
| 738 | _ ) | ||
| 739 | then txt; | ||
| 740 | end match; | ||
| 741 | end fun_62; | ||
| 742 | |||
| 743 | public function crefCCommentWithVariability | ||
| 744 | input Tpl.Text in_txt; | ||
| 745 | input SimCodeVar.SimVar in_a_v; | ||
| 746 | |||
| 747 | output Tpl.Text out_txt; | ||
| 748 | algorithm | ||
| 749 | out_txt := | ||
| 750 | match(in_txt, in_a_v) | ||
| 751 | local | ||
| 752 | Tpl.Text txt; | ||
| 753 | BackendDAE.VarKind i_varKind; | ||
| 754 | DAE.ComponentRef i_name; | ||
| 755 | Boolean ret_3; | ||
| 756 | String ret_2; | ||
| 757 | Boolean ret_1; | ||
| 758 | String ret_0; | ||
| 759 | |||
| 760 | case ( txt, | ||
| 761 | SimCodeVar.SIMVAR(isProtected = true, name = i_name, varKind = i_varKind) ) | ||
| 762 | algorithm | ||
| 763 | 188604 | ret_0 := Flags.getConfigString(Flags.OBFUSCATE); | |
| 764 |
2/4✓ Branch 0 taken 188604 times.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 188604 times.
|
188604 | ret_1 := stringEq(ret_0, "none"); |
| 765 | 188604 | txt := fun_61(txt, ret_1, i_varKind, i_name); | |
| 766 | then txt; | ||
| 767 | |||
| 768 | case ( txt, | ||
| 769 | SimCodeVar.SIMVAR(name = i_name, varKind = i_varKind) ) | ||
| 770 | algorithm | ||
| 771 | 800052 | ret_2 := Flags.getConfigString(Flags.OBFUSCATE); | |
| 772 |
2/4✓ Branch 0 taken 800052 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 800052 times.
✗ Branch 4 not taken.
|
800052 | ret_3 := stringEq(ret_2, "full"); |
| 773 | 800052 | txt := fun_62(txt, ret_3, i_varKind, i_name); | |
| 774 | then txt; | ||
| 775 | |||
| 776 | case ( txt, | ||
| 777 | _ ) | ||
| 778 | then txt; | ||
| 779 | end match; | ||
| 780 | end crefCCommentWithVariability; | ||
| 781 | |||
| 782 | public function escapeSingleQuoteIdent | ||
| 783 | input Tpl.Text txt; | ||
| 784 | input String a_ident; | ||
| 785 | |||
| 786 | output Tpl.Text out_txt; | ||
| 787 | protected | ||
| 788 | String ret_1; | ||
| 789 | String ret_0; | ||
| 790 | algorithm | ||
| 791 | 240 | ret_0 := System.stringReplace(a_ident, "\\\'", "\\\\\'"); | |
| 792 | 240 | ret_1 := System.stringReplace(ret_0, "\'", "\\\'"); | |
| 793 | 240 | out_txt := Tpl.writeStr(txt, ret_1); | |
| 794 | end escapeSingleQuoteIdent; | ||
| 795 | |||
| 796 | public function initDefaultValXml | ||
| 797 | input Tpl.Text in_txt; | ||
| 798 | input DAE.Type in_a_type__; | ||
| 799 | |||
| 800 | output Tpl.Text out_txt; | ||
| 801 | algorithm | ||
| 802 | out_txt := | ||
| 803 | match(in_txt, in_a_type__) | ||
| 804 | local | ||
| 805 | Tpl.Text txt; | ||
| 806 | DAE.Type i_type__; | ||
| 807 | Tpl.Text txt_0; | ||
| 808 | String ret_0; | ||
| 809 | |||
| 810 | case ( txt, | ||
| 811 | DAE.T_INTEGER(varLst = _) ) | ||
| 812 | algorithm | ||
| 813 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("0")); | |
| 814 | then txt; | ||
| 815 | |||
| 816 | case ( txt, | ||
| 817 | DAE.T_REAL(varLst = _) ) | ||
| 818 | algorithm | ||
| 819 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("0.0")); | |
| 820 | then txt; | ||
| 821 | |||
| 822 | case ( txt, | ||
| 823 | DAE.T_BOOL(varLst = _) ) | ||
| 824 | algorithm | ||
| 825 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("false")); | |
| 826 | then txt; | ||
| 827 | |||
| 828 | case ( txt, | ||
| 829 | DAE.T_STRING(varLst = _) ) | ||
| 830 | then txt; | ||
| 831 | |||
| 832 | case ( txt, | ||
| 833 | DAE.T_ENUMERATION(index = _) ) | ||
| 834 | algorithm | ||
| 835 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("0")); | |
| 836 | then txt; | ||
| 837 | |||
| 838 | case ( txt, | ||
| 839 | i_type__ ) | ||
| 840 | algorithm | ||
| 841 | ✗ | txt_0 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("initial value of unknown type: ")); | |
| 842 | ✗ | ret_0 := TypesDump.unparseType(i_type__); | |
| 843 | ✗ | txt_0 := Tpl.writeStr(txt_0, ret_0); | |
| 844 | ✗ | txt := error(txt, Tpl.sourceInfo("CodegenUtil.tpl", 254, 14), Tpl.textString(txt_0)); | |
| 845 | then txt; | ||
| 846 | end match; | ||
| 847 | end initDefaultValXml; | ||
| 848 | |||
| 849 | protected function lm_66 | ||
| 850 | input output Tpl.Text txt; | ||
| 851 | input list<DAE.Exp> items; | ||
| 852 | input String a_stringQuotes; | ||
| 853 | algorithm | ||
| 854 | ✗ | for lstElt_66 in items loop | |
| 855 | txt := match lstElt_66 | ||
| 856 | local | ||
| 857 | DAE.Exp i_elem; | ||
| 858 | |||
| 859 | case i_elem | ||
| 860 | algorithm | ||
| 861 | ✗ | txt := initValXml(txt, i_elem, a_stringQuotes); | |
| 862 | ✗ | txt := Tpl.nextIter(txt); | |
| 863 | then txt; | ||
| 864 | end match; | ||
| 865 | end for; | ||
| 866 | end lm_66; | ||
| 867 | |||
| 868 | protected function fun_67 | ||
| 869 | input Tpl.Text in_txt; | ||
| 870 | input Boolean in_mArg; | ||
| 871 | input String in_a_stringQuotes; | ||
| 872 | input DAE.Exp in_a_expr; | ||
| 873 | |||
| 874 | output Tpl.Text out_txt; | ||
| 875 | algorithm | ||
| 876 | out_txt := | ||
| 877 | match(in_txt, in_mArg, in_a_stringQuotes, in_a_expr) | ||
| 878 | local | ||
| 879 | Tpl.Text txt; | ||
| 880 | String a_stringQuotes; | ||
| 881 | DAE.Exp a_expr; | ||
| 882 | |||
| 883 | case ( txt, | ||
| 884 | false, | ||
| 885 | _, | ||
| 886 | _ ) | ||
| 887 | then txt; | ||
| 888 | |||
| 889 | case ( txt, | ||
| 890 | _, | ||
| 891 | a_stringQuotes, | ||
| 892 | a_expr ) | ||
| 893 | algorithm | ||
| 894 | ✗ | txt := initValXml(txt, a_expr, a_stringQuotes); | |
| 895 | then txt; | ||
| 896 | end match; | ||
| 897 | end fun_67; | ||
| 898 | |||
| 899 | public function initValXml | ||
| 900 | input Tpl.Text in_txt; | ||
| 901 | input DAE.Exp in_a_exp; | ||
| 902 | input String in_a_stringQuotes; | ||
| 903 | |||
| 904 | output Tpl.Text out_txt; | ||
| 905 | algorithm | ||
| 906 | out_txt := | ||
| 907 | match(in_txt, in_a_exp, in_a_stringQuotes) | ||
| 908 | local | ||
| 909 | Tpl.Text txt; | ||
| 910 | String a_stringQuotes; | ||
| 911 | DAE.Exp i_exp; | ||
| 912 | Integer i_index; | ||
| 913 | DAE.Exp i_expr; | ||
| 914 | list<DAE.Exp> i_array; | ||
| 915 | Boolean i_bool; | ||
| 916 | String i_string; | ||
| 917 | Real i_real; | ||
| 918 | Integer i_integer; | ||
| 919 | Tpl.Text txt_2; | ||
| 920 | Boolean ret_1; | ||
| 921 | String ret_0; | ||
| 922 | |||
| 923 | case ( txt, | ||
| 924 | DAE.ICONST(integer = i_integer), | ||
| 925 | _ ) | ||
| 926 | algorithm | ||
| 927 | 1249 | txt := Tpl.writeStr(txt, intString(i_integer)); | |
| 928 | then txt; | ||
| 929 | |||
| 930 | case ( txt, | ||
| 931 | DAE.RCONST(real = i_real), | ||
| 932 | _ ) | ||
| 933 | algorithm | ||
| 934 | 9859 | txt := Tpl.writeStr(txt, realString(i_real)); | |
| 935 | then txt; | ||
| 936 | |||
| 937 | case ( txt, | ||
| 938 | DAE.SCONST(string = i_string), | ||
| 939 | a_stringQuotes ) | ||
| 940 | algorithm | ||
| 941 | 77 | txt := Tpl.writeStr(txt, a_stringQuotes); | |
| 942 | 77 | ret_0 := Util.escapeModelicaStringToXmlString(i_string); | |
| 943 | 77 | txt := Tpl.writeStr(txt, ret_0); | |
| 944 | 77 | txt := Tpl.writeStr(txt, a_stringQuotes); | |
| 945 | then txt; | ||
| 946 | |||
| 947 | case ( txt, | ||
| 948 | DAE.BCONST(bool = i_bool), | ||
| 949 | _ ) | ||
| 950 | algorithm | ||
| 951 | 461 | txt := Tpl.writeStr(txt, Tpl.booleanString(i_bool)); | |
| 952 | then txt; | ||
| 953 | |||
| 954 | case ( txt, | ||
| 955 | DAE.ARRAY(array = i_array), | ||
| 956 | a_stringQuotes ) | ||
| 957 | algorithm | ||
| 958 | ✗ | txt := Tpl.pushIter(txt, Tpl.ITER_OPTIONS(0, NONE(), SOME(Tpl.ST_STRING(" ")), 0, 0, Tpl.ST_NEW_LINE(), 0, Tpl.ST_NEW_LINE())); | |
| 959 | ✗ | txt := lm_66(txt, i_array, a_stringQuotes); | |
| 960 | ✗ | txt := Tpl.popIter(txt); | |
| 961 | then txt; | ||
| 962 | |||
| 963 | case ( txt, | ||
| 964 | DAE.REDUCTION(expr = i_expr), | ||
| 965 | a_stringQuotes ) | ||
| 966 | algorithm | ||
| 967 | ✗ | ret_1 := Expression.isSimpleLiteralValue(i_expr, true); | |
| 968 | ✗ | txt := fun_67(txt, ret_1, a_stringQuotes, i_expr); | |
| 969 | then txt; | ||
| 970 | |||
| 971 | case ( txt, | ||
| 972 | DAE.ENUM_LITERAL(index = i_index), | ||
| 973 | _ ) | ||
| 974 | algorithm | ||
| 975 | 303 | txt := Tpl.writeStr(txt, intString(i_index)); | |
| 976 | then txt; | ||
| 977 | |||
| 978 | case ( txt, | ||
| 979 | i_exp, | ||
| 980 | _ ) | ||
| 981 | algorithm | ||
| 982 | ✗ | txt_2 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("initial value of unknown type: ")); | |
| 983 | ✗ | txt_2 := ExpressionDumpTpl.dumpExp(txt_2, i_exp, "\""); | |
| 984 | ✗ | txt := error(txt, Tpl.sourceInfo("CodegenUtil.tpl", 267, 14), Tpl.textString(txt_2)); | |
| 985 | then txt; | ||
| 986 | end match; | ||
| 987 | end initValXml; | ||
| 988 | |||
| 989 | public function getVariablity | ||
| 990 | input Tpl.Text in_txt; | ||
| 991 | input BackendDAE.VarKind in_a_varKind; | ||
| 992 | |||
| 993 | output Tpl.Text out_txt; | ||
| 994 | algorithm | ||
| 995 | out_txt := | ||
| 996 | match(in_txt, in_a_varKind) | ||
| 997 | local | ||
| 998 | Tpl.Text txt; | ||
| 999 | |||
| 1000 | case ( txt, | ||
| 1001 | BackendDAE.DISCRETE() ) | ||
| 1002 | algorithm | ||
| 1003 | 1283 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("discrete")); | |
| 1004 | then txt; | ||
| 1005 | |||
| 1006 | case ( txt, | ||
| 1007 | BackendDAE.PARAM() ) | ||
| 1008 | algorithm | ||
| 1009 | 2668 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("parameter")); | |
| 1010 | then txt; | ||
| 1011 | |||
| 1012 | case ( txt, | ||
| 1013 | BackendDAE.CONST() ) | ||
| 1014 | algorithm | ||
| 1015 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("constant")); | |
| 1016 | then txt; | ||
| 1017 | |||
| 1018 | case ( txt, | ||
| 1019 | _ ) | ||
| 1020 | algorithm | ||
| 1021 | 7919 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("continuous")); | |
| 1022 | then txt; | ||
| 1023 | end match; | ||
| 1024 | end getVariablity; | ||
| 1025 | |||
| 1026 | public function variabilityString | ||
| 1027 | input Tpl.Text in_txt; | ||
| 1028 | input BackendDAE.VarKind in_a_varKind; | ||
| 1029 | |||
| 1030 | output Tpl.Text out_txt; | ||
| 1031 | algorithm | ||
| 1032 | out_txt := | ||
| 1033 | match(in_txt, in_a_varKind) | ||
| 1034 | local | ||
| 1035 | Tpl.Text txt; | ||
| 1036 | Absyn.Path i_fullClassName; | ||
| 1037 | DAE.ComponentRef i_dcr; | ||
| 1038 | Integer i_index; | ||
| 1039 | |||
| 1040 | case ( txt, | ||
| 1041 | BackendDAE.VARIABLE() ) | ||
| 1042 | algorithm | ||
| 1043 | 336730 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("variable")); | |
| 1044 | then txt; | ||
| 1045 | |||
| 1046 | case ( txt, | ||
| 1047 | BackendDAE.STATE(derName = NONE(), index = i_index) ) | ||
| 1048 | algorithm | ||
| 1049 | 119718 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("STATE(")); | |
| 1050 | 119718 | txt := Tpl.writeStr(txt, intString(i_index)); | |
| 1051 | 119718 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 1052 | then txt; | ||
| 1053 | |||
| 1054 | case ( txt, | ||
| 1055 | BackendDAE.STATE(derName = SOME(i_dcr), index = i_index) ) | ||
| 1056 | algorithm | ||
| 1057 | 12411 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("STATE(")); | |
| 1058 | 12411 | txt := Tpl.writeStr(txt, intString(i_index)); | |
| 1059 | 12411 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(",")); | |
| 1060 | 12411 | txt := crefStrNoUnderscore(txt, i_dcr); | |
| 1061 | 12411 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(")")); | |
| 1062 | then txt; | ||
| 1063 | |||
| 1064 | case ( txt, | ||
| 1065 | BackendDAE.STATE_DER() ) | ||
| 1066 | algorithm | ||
| 1067 | 20020 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("STATE_DER")); | |
| 1068 | then txt; | ||
| 1069 | |||
| 1070 | case ( txt, | ||
| 1071 | BackendDAE.DUMMY_DER() ) | ||
| 1072 | algorithm | ||
| 1073 | 29775 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("DUMMY_DER")); | |
| 1074 | then txt; | ||
| 1075 | |||
| 1076 | case ( txt, | ||
| 1077 | BackendDAE.DUMMY_STATE() ) | ||
| 1078 | algorithm | ||
| 1079 | 94775 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("DUMMY_STATE")); | |
| 1080 | then txt; | ||
| 1081 | |||
| 1082 | case ( txt, | ||
| 1083 | BackendDAE.CLOCKED_STATE(previousName = _) ) | ||
| 1084 | algorithm | ||
| 1085 | 900 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("CLOCKED_STATE")); | |
| 1086 | then txt; | ||
| 1087 | |||
| 1088 | case ( txt, | ||
| 1089 | BackendDAE.DISCRETE() ) | ||
| 1090 | algorithm | ||
| 1091 | 31281 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("DISCRETE")); | |
| 1092 | then txt; | ||
| 1093 | |||
| 1094 | case ( txt, | ||
| 1095 | BackendDAE.PARAM() ) | ||
| 1096 | algorithm | ||
| 1097 | 280788 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("PARAM")); | |
| 1098 | then txt; | ||
| 1099 | |||
| 1100 | case ( txt, | ||
| 1101 | BackendDAE.CONST() ) | ||
| 1102 | algorithm | ||
| 1103 | 3 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("CONST")); | |
| 1104 | then txt; | ||
| 1105 | |||
| 1106 | case ( txt, | ||
| 1107 | BackendDAE.EXTOBJ(fullClassName = i_fullClassName) ) | ||
| 1108 | algorithm | ||
| 1109 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("EXTOBJ: ")); | |
| 1110 | ✗ | txt := dotPath(txt, i_fullClassName); | |
| 1111 | then txt; | ||
| 1112 | |||
| 1113 | case ( txt, | ||
| 1114 | BackendDAE.JAC_VAR() ) | ||
| 1115 | algorithm | ||
| 1116 | 6113 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("JACOBIAN_VAR")); | |
| 1117 | then txt; | ||
| 1118 | |||
| 1119 | case ( txt, | ||
| 1120 | BackendDAE.JAC_TMP_VAR() ) | ||
| 1121 | algorithm | ||
| 1122 | 27794 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("JACOBIAN_TMP_VAR")); | |
| 1123 | then txt; | ||
| 1124 | |||
| 1125 | case ( txt, | ||
| 1126 | BackendDAE.SEED_VAR() ) | ||
| 1127 | algorithm | ||
| 1128 | 19788 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("SEED_VAR")); | |
| 1129 | then txt; | ||
| 1130 | |||
| 1131 | case ( txt, | ||
| 1132 | BackendDAE.OPT_CONSTR() ) | ||
| 1133 | algorithm | ||
| 1134 | 242 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("OPT_CONSTR")); | |
| 1135 | then txt; | ||
| 1136 | |||
| 1137 | case ( txt, | ||
| 1138 | BackendDAE.OPT_FCONSTR() ) | ||
| 1139 | algorithm | ||
| 1140 | 88 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("OPT_FCONSTR")); | |
| 1141 | then txt; | ||
| 1142 | |||
| 1143 | case ( txt, | ||
| 1144 | BackendDAE.OPT_INPUT_WITH_DER() ) | ||
| 1145 | algorithm | ||
| 1146 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("OPT_INPUT_WITH_DER")); | |
| 1147 | then txt; | ||
| 1148 | |||
| 1149 | case ( txt, | ||
| 1150 | BackendDAE.OPT_INPUT_DER() ) | ||
| 1151 | algorithm | ||
| 1152 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("OPT_INPUT_DER")); | |
| 1153 | then txt; | ||
| 1154 | |||
| 1155 | case ( txt, | ||
| 1156 | BackendDAE.OPT_TGRID() ) | ||
| 1157 | algorithm | ||
| 1158 | 276 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("OPT_TGRID")); | |
| 1159 | then txt; | ||
| 1160 | |||
| 1161 | case ( txt, | ||
| 1162 | BackendDAE.OPT_LOOP_INPUT(replaceExp = _) ) | ||
| 1163 | algorithm | ||
| 1164 | 48 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("OPT_LOOP_INPUT")); | |
| 1165 | then txt; | ||
| 1166 | |||
| 1167 | case ( txt, | ||
| 1168 | BackendDAE.ALG_STATE() ) | ||
| 1169 | algorithm | ||
| 1170 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("ALG_STATE")); | |
| 1171 | then txt; | ||
| 1172 | |||
| 1173 | case ( txt, | ||
| 1174 | BackendDAE.DAE_RESIDUAL_VAR() ) | ||
| 1175 | algorithm | ||
| 1176 | 7494 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("DAE_RESIDUAL_VAR")); | |
| 1177 | then txt; | ||
| 1178 | |||
| 1179 | case ( txt, | ||
| 1180 | BackendDAE.DAE_AUX_VAR() ) | ||
| 1181 | algorithm | ||
| 1182 | 412 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("DAE_AUX_VAR")); | |
| 1183 | then txt; | ||
| 1184 | |||
| 1185 | case ( txt, | ||
| 1186 | BackendDAE.LOOP_ITERATION() ) | ||
| 1187 | algorithm | ||
| 1188 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("LOOP_ITERATION")); | |
| 1189 | then txt; | ||
| 1190 | |||
| 1191 | case ( txt, | ||
| 1192 | BackendDAE.LOOP_SOLVED() ) | ||
| 1193 | algorithm | ||
| 1194 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("LOOP_SOLVED")); | |
| 1195 | then txt; | ||
| 1196 | |||
| 1197 | case ( txt, | ||
| 1198 | _ ) | ||
| 1199 | algorithm | ||
| 1200 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("#UNKNOWN_VARKIND")); | |
| 1201 | then txt; | ||
| 1202 | end match; | ||
| 1203 | end variabilityString; | ||
| 1204 | |||
| 1205 | public function getAliasVar | ||
| 1206 | input Tpl.Text in_txt; | ||
| 1207 | input SimCodeVar.AliasVariable in_a_aliasvar; | ||
| 1208 | |||
| 1209 | output Tpl.Text out_txt; | ||
| 1210 | algorithm | ||
| 1211 | out_txt := | ||
| 1212 | match(in_txt, in_a_aliasvar) | ||
| 1213 | local | ||
| 1214 | Tpl.Text txt; | ||
| 1215 | DAE.ComponentRef i_varName; | ||
| 1216 | |||
| 1217 | case ( txt, | ||
| 1218 | SimCodeVar.NOALIAS() ) | ||
| 1219 | algorithm | ||
| 1220 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"noAlias\"")); | |
| 1221 | then txt; | ||
| 1222 | |||
| 1223 | case ( txt, | ||
| 1224 | SimCodeVar.ALIAS(varName = i_varName) ) | ||
| 1225 | algorithm | ||
| 1226 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"alias\" aliasVariable=\"")); | |
| 1227 | ✗ | txt := crefStrNoUnderscore(txt, i_varName); | |
| 1228 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"")); | |
| 1229 | then txt; | ||
| 1230 | |||
| 1231 | case ( txt, | ||
| 1232 | SimCodeVar.NEGATEDALIAS(varName = i_varName) ) | ||
| 1233 | algorithm | ||
| 1234 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"negatedAlias\" aliasVariable=\"")); | |
| 1235 | ✗ | txt := crefStrNoUnderscore(txt, i_varName); | |
| 1236 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"")); | |
| 1237 | then txt; | ||
| 1238 | |||
| 1239 | case ( txt, | ||
| 1240 | _ ) | ||
| 1241 | algorithm | ||
| 1242 | ✗ | txt := Tpl.writeTok(txt, Tpl.ST_STRING("\"noAlias\"")); | |
| 1243 | then txt; | ||
| 1244 | end match; | ||
| 1245 | end getAliasVar; | ||
| 1246 | |||
| 1247 | public function dotPath | ||
| 1248 | input Tpl.Text in_txt; | ||
| 1249 | input Absyn.Path in_a_path; | ||
| 1250 | |||
| 1251 | output Tpl.Text out_txt; | ||
| 1252 | algorithm | ||
| 1253 | out_txt := | ||
| 1254 | match(in_txt, in_a_path) | ||
| 1255 | local | ||
| 1256 | Tpl.Text txt; | ||
| 1257 | String i_name_1; | ||
| 1258 | Absyn.Path i_path; | ||
| 1259 | Absyn.Ident i_name; | ||
| 1260 | |||
| 1261 | case ( txt, | ||
| 1262 | Absyn.QUALIFIED(name = i_name, path = i_path) ) | ||
| 1263 | algorithm | ||
| 1264 | 55705 | txt := Tpl.writeStr(txt, i_name); | |
| 1265 | 55705 | txt := Tpl.writeTok(txt, Tpl.ST_STRING(".")); | |
| 1266 | 55705 | txt := dotPath(txt, i_path); | |
| 1267 | then txt; | ||
| 1268 | |||
| 1269 | case ( txt, | ||
| 1270 | Absyn.IDENT(name = i_name_1) ) | ||
| 1271 | algorithm | ||
| 1272 | 24499 | txt := Tpl.writeStr(txt, i_name_1); | |
| 1273 | then txt; | ||
| 1274 | |||
| 1275 | case ( txt, | ||
| 1276 | Absyn.FULLYQUALIFIED(path = i_path) ) | ||
| 1277 | algorithm | ||
| 1278 | 2867 | txt := dotPath(txt, i_path); | |
| 1279 | then txt; | ||
| 1280 | |||
| 1281 | case ( txt, | ||
| 1282 | _ ) | ||
| 1283 | then txt; | ||
| 1284 | end match; | ||
| 1285 | end dotPath; | ||
| 1286 | |||
| 1287 | public function error | ||
| 1288 | input Tpl.Text txt; | ||
| 1289 | input SourceInfo a_srcInfo; | ||
| 1290 | input String a_errMessage; | ||
| 1291 | |||
| 1292 | output Tpl.Text out_txt; | ||
| 1293 | protected | ||
| 1294 | String ret_0; | ||
| 1295 | algorithm | ||
| 1296 | ✗ | Tpl.addSourceTemplateError(a_errMessage, a_srcInfo); | |
| 1297 | ✗ | out_txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 1298 | "\n", | ||
| 1299 | "#error \"" | ||
| 1300 | }, false)); | ||
| 1301 | ✗ | ret_0 := Error.infoStr(a_srcInfo); | |
| 1302 | ✗ | out_txt := Tpl.writeStr(out_txt, ret_0); | |
| 1303 | ✗ | out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING(" ")); | |
| 1304 | ✗ | out_txt := Tpl.writeStr(out_txt, a_errMessage); | |
| 1305 | ✗ | out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("\"")); | |
| 1306 | ✗ | out_txt := Tpl.writeTok(out_txt, Tpl.ST_NEW_LINE()); | |
| 1307 | end error; | ||
| 1308 | |||
| 1309 | public function errorMsg | ||
| 1310 | input Tpl.Text txt; | ||
| 1311 | input String a_errMessage; | ||
| 1312 | |||
| 1313 | output Tpl.Text out_txt; | ||
| 1314 | algorithm | ||
| 1315 | ✗ | Tpl.addTemplateError(a_errMessage); | |
| 1316 | ✗ | out_txt := Tpl.writeTok(txt, Tpl.ST_STRING_LIST({ | |
| 1317 | "\n", | ||
| 1318 | "#error \"" | ||
| 1319 | }, false)); | ||
| 1320 | ✗ | out_txt := Tpl.writeStr(out_txt, a_errMessage); | |
| 1321 | ✗ | out_txt := Tpl.writeTok(out_txt, Tpl.ST_STRING("\"")); | |
| 1322 | ✗ | out_txt := Tpl.writeTok(out_txt, Tpl.ST_NEW_LINE()); | |
| 1323 | end errorMsg; | ||
| 1324 | |||
| 1325 | protected function fun_75 | ||
| 1326 | input Tpl.Text in_txt; | ||
| 1327 | input String in_a_language; | ||
| 1328 | input String in_a_name; | ||
| 1329 | |||
| 1330 | output Tpl.Text out_txt; | ||
| 1331 | algorithm | ||
| 1332 | out_txt := | ||
| 1333 | match(in_txt, in_a_language, in_a_name) | ||
| 1334 | local | ||
| 1335 | Tpl.Text txt; | ||
| 1336 | String a_name; | ||
| 1337 | String i_language; | ||
| 1338 | Tpl.Text txt_0; | ||
| 1339 | |||
| 1340 | case ( txt, | ||
| 1341 | "BUILTIN", | ||
| 1342 | a_name ) | ||
| 1343 | algorithm | ||
| 1344 | 3 | txt := Tpl.writeStr(txt, a_name); | |
| 1345 | then txt; | ||
| 1346 | |||
| 1347 | case ( txt, | ||
| 1348 | "C", | ||
| 1349 | a_name ) | ||
| 1350 | algorithm | ||
| 1351 | 540 | txt := Tpl.writeStr(txt, a_name); | |
| 1352 | then txt; | ||
| 1353 | |||
| 1354 | case ( txt, | ||
| 1355 | "FORTRAN 77", | ||
| 1356 | a_name ) | ||
| 1357 | algorithm | ||
| 1358 | 12 | txt := Tpl.writeStr(txt, a_name); | |
| 1359 | 12 | txt := Tpl.writeTok(txt, Tpl.ST_STRING("_")); | |
| 1360 | then txt; | ||
| 1361 | |||
| 1362 | case ( txt, | ||
| 1363 | i_language, | ||
| 1364 | _ ) | ||
| 1365 | algorithm | ||
| 1366 | ✗ | txt_0 := Tpl.writeTok(Tpl.emptyTxt, Tpl.ST_STRING("Unsupported external language: ")); | |
| 1367 | ✗ | txt_0 := Tpl.writeStr(txt_0, i_language); | |
| 1368 | ✗ | txt := error(txt, Tpl.sourceInfo("CodegenUtil.tpl", 380, 14), Tpl.textString(txt_0)); | |
| 1369 | then txt; | ||
| 1370 | end match; | ||
| 1371 | end fun_75; | ||
| 1372 | |||
| 1373 | public function extFunctionName | ||
| 1374 | input Tpl.Text txt; | ||
| 1375 | input String a_name; | ||
| 1376 | input String a_language; | ||
| 1377 | |||
| 1378 | output Tpl.Text out_txt; | ||
| 1379 | algorithm | ||
| 1380 | 555 | out_txt := fun_75(txt, a_language, a_name); | |
| 1381 | end extFunctionName; | ||
| 1382 | |||
| 1383 | annotation(__OpenModelica_Interface="codegen_util"); | ||
| 1384 | end CodegenUtil; | ||
| 1385 |