OMCompiler/Compiler/Util/Config.mo
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * This file is part of OpenModelica. | ||
| 3 | * | ||
| 4 | * Copyright (c) 1998-2026, Open Source Modelica Consortium (OSMC), | ||
| 5 | * c/o Linköpings universitet, Department of Computer and Information Science, | ||
| 6 | * SE-58183 Linköping, Sweden. | ||
| 7 | * | ||
| 8 | * All rights reserved. | ||
| 9 | * | ||
| 10 | * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF AGPL VERSION 3 LICENSE OR | ||
| 11 | * THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.8. | ||
| 12 | * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES | ||
| 13 | * RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GNU AGPL | ||
| 14 | * VERSION 3, ACCORDING TO RECIPIENTS CHOICE. | ||
| 15 | * | ||
| 16 | * The OpenModelica software and the OSMC (Open Source Modelica Consortium) | ||
| 17 | * Public License (OSMC-PL) are obtained from OSMC, either from the above | ||
| 18 | * address, from the URLs: | ||
| 19 | * http://www.openmodelica.org or | ||
| 20 | * https://github.com/OpenModelica/ or | ||
| 21 | * http://www.ida.liu.se/projects/OpenModelica, | ||
| 22 | * and in the OpenModelica distribution. | ||
| 23 | * | ||
| 24 | * GNU AGPL version 3 is obtained from: | ||
| 25 | * https://www.gnu.org/licenses/licenses.html#GPL | ||
| 26 | * | ||
| 27 | * This program is distributed WITHOUT ANY WARRANTY; without | ||
| 28 | * even the implied warranty of MERCHANTABILITY or FITNESS | ||
| 29 | * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH | ||
| 30 | * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL. | ||
| 31 | * | ||
| 32 | * See the full OSMC Public License conditions for more details. | ||
| 33 | * | ||
| 34 | */ | ||
| 35 | |||
| 36 | encapsulated package Config | ||
| 37 | " file: Config.mo | ||
| 38 | package: Config | ||
| 39 | description: Functions for configurating the compiler. | ||
| 40 | |||
| 41 | |||
| 42 | This module contains functions which are mostly just wrappers for the Flags | ||
| 43 | module, which makes it easier to manipulate the configuration of the compiler." | ||
| 44 | |||
| 45 | public import Flags; | ||
| 46 | protected | ||
| 47 | |||
| 48 | import Autoconf; | ||
| 49 | import Error; | ||
| 50 | import FlagsUtil; | ||
| 51 | import StringUtil; | ||
| 52 | import System; | ||
| 53 | |||
| 54 | public | ||
| 55 | |||
| 56 | type LanguageStandard = enumeration(_1_x, _2_x, _3_0, _3_1, _3_2, _3_3, _3_4, _3_5, _3_6, _3_7, latest, experimental) | ||
| 57 | "Defines the various modelica language versions that OMC can use."; | ||
| 58 | |||
| 59 | public function typeinfo "+t" | ||
| 60 | output Boolean outBoolean; | ||
| 61 | algorithm | ||
| 62 | 3056730 | outBoolean := Flags.getConfigBool(Flags.TYPE_INFO); | |
| 63 | end typeinfo; | ||
| 64 | |||
| 65 | public function splitArrays | ||
| 66 | output Boolean outBoolean; | ||
| 67 | algorithm | ||
| 68 | 2178553 | outBoolean := not Flags.getConfigBool(Flags.KEEP_ARRAYS); | |
| 69 | end splitArrays; | ||
| 70 | |||
| 71 | public function modelicaOutput | ||
| 72 | output Boolean outBoolean; | ||
| 73 | algorithm | ||
| 74 | 1281047 | outBoolean := Flags.getConfigBool(Flags.MODELICA_OUTPUT); | |
| 75 | end modelicaOutput; | ||
| 76 | |||
| 77 | public function noProc | ||
| 78 | output Integer outInteger; | ||
| 79 | algorithm | ||
| 80 | 2137 | outInteger := noProcWork(Flags.getConfigInt(Flags.NUM_PROC)); | |
| 81 | end noProc; | ||
| 82 | |||
| 83 | protected function noProcWork | ||
| 84 | input Integer inProc; | ||
| 85 | output Integer outInteger; | ||
| 86 | algorithm | ||
| 87 | outInteger := match inProc | ||
| 88 | 2120 | case 0 then System.numProcessors(); | |
| 89 | else inProc; | ||
| 90 | end match; | ||
| 91 | end noProcWork; | ||
| 92 | |||
| 93 | public function simulationCg | ||
| 94 | output Boolean outBoolean; | ||
| 95 | algorithm | ||
| 96 | 1262 | outBoolean := Flags.getConfigBool(Flags.SIMULATION_CG); | |
| 97 | end simulationCg; | ||
| 98 | |||
| 99 | public function simulation | ||
| 100 | output Boolean outBoolean; | ||
| 101 | algorithm | ||
| 102 | 1262 | outBoolean := Flags.getConfigBool(Flags.SIMULATION); | |
| 103 | end simulation; | ||
| 104 | |||
| 105 | public function simulationCodeTarget | ||
| 106 | "@author: adrpo | ||
| 107 | returns: 'gcc' or 'msvc' | ||
| 108 | usage: omc [+target=gcc|msvc], default to 'gcc'." | ||
| 109 | output String outCodeTarget; | ||
| 110 | algorithm | ||
| 111 | 1633 | outCodeTarget := Flags.getConfigString(Flags.TARGET); | |
| 112 | end simulationCodeTarget; | ||
| 113 | |||
| 114 | public function classToInstantiate | ||
| 115 | output String modelName; | ||
| 116 | algorithm | ||
| 117 | 1265 | modelName := Flags.getConfigString(Flags.INST_CLASS); | |
| 118 | end classToInstantiate; | ||
| 119 | |||
| 120 | public function silent | ||
| 121 | output Boolean outBoolean; | ||
| 122 | algorithm | ||
| 123 | 1352 | outBoolean := Flags.getConfigBool(Flags.SILENT); | |
| 124 | end silent; | ||
| 125 | |||
| 126 | public function versionRequest | ||
| 127 | output Boolean outBoolean; | ||
| 128 | algorithm | ||
| 129 | 2677 | outBoolean := Flags.getConfigBool(Flags.SHOW_VERSION); | |
| 130 | end versionRequest; | ||
| 131 | |||
| 132 | public function helpRequest | ||
| 133 | output Boolean outBoolean; | ||
| 134 | algorithm | ||
| 135 | ✗ | outBoolean := not stringEq(Flags.getConfigString(Flags.HELP), ""); | |
| 136 | end helpRequest; | ||
| 137 | |||
| 138 | public function acceptedGrammar | ||
| 139 | "returns: the flag number representing the accepted grammer. Instead of using | ||
| 140 | booleans. This way more extensions can be added easily. | ||
| 141 | usage: omc [-g=Modelica|MetaModelica|ParModelica|Optimica], default to 'Modelica'." | ||
| 142 | output Integer outGrammer; | ||
| 143 | algorithm | ||
| 144 | 1262863 | outGrammer := Flags.getConfigEnum(Flags.GRAMMAR); | |
| 145 | end acceptedGrammar; | ||
| 146 | |||
| 147 | public function acceptMetaModelicaGrammar | ||
| 148 | "returns: true if MetaModelica grammar is accepted or false otherwise | ||
| 149 | usage: omc [-g=Modelica|MetaModelica|ParModelica|Optimica], default to 'Modelica'." | ||
| 150 | output Boolean outBoolean; | ||
| 151 | algorithm | ||
| 152 | 8314461 | outBoolean := intEq(Flags.getConfigEnum(Flags.GRAMMAR), Flags.METAMODELICA); | |
| 153 | end acceptMetaModelicaGrammar; | ||
| 154 | |||
| 155 | public function acceptParModelicaGrammar | ||
| 156 | "returns: true if ParModelica grammar is accepted or false otherwise | ||
| 157 | usage: omc [-g=Modelica|MetaModelica|ParModelica|Optimica], default to 'Modelica'." | ||
| 158 | output Boolean outBoolean; | ||
| 159 | algorithm | ||
| 160 | 676506 | outBoolean := intEq(Flags.getConfigEnum(Flags.GRAMMAR), Flags.PARMODELICA); | |
| 161 | end acceptParModelicaGrammar; | ||
| 162 | |||
| 163 | public function acceptOptimicaGrammar | ||
| 164 | "returns: true if Optimica grammar is accepted or false otherwise | ||
| 165 | usage: omc [-g=Modelica|MetaModelica|ParModelica|Optimica], default to 'Modelica'." | ||
| 166 | output Boolean outBoolean; | ||
| 167 | algorithm | ||
| 168 | 10197 | outBoolean := intEq(Flags.getConfigEnum(Flags.GRAMMAR), Flags.OPTIMICA); | |
| 169 | end acceptOptimicaGrammar; | ||
| 170 | |||
| 171 | public function acceptPDEModelicaGrammar | ||
| 172 | "returns: true if Optimica grammar is accepted or false otherwise | ||
| 173 | usage: omc [-g=Modelica|MetaModelica|ParModelica|Optimica], default to 'Modelica'." | ||
| 174 | output Boolean outBoolean; | ||
| 175 | algorithm | ||
| 176 | ✗ | outBoolean := intEq(Flags.getConfigEnum(Flags.GRAMMAR), Flags.PDEMODELICA); | |
| 177 | end acceptPDEModelicaGrammar; | ||
| 178 | |||
| 179 | public function getAnnotationVersion | ||
| 180 | "returns what flag was given at start | ||
| 181 | omc [+annotationVersion=3.x] | ||
| 182 | or via the API | ||
| 183 | setAnnotationVersion(\"3.x\"); | ||
| 184 | for annotations: 1.x or 2.x or 3.x" | ||
| 185 | output String annotationVersion; | ||
| 186 | algorithm | ||
| 187 | 3754 | annotationVersion := Flags.getConfigString(Flags.ANNOTATION_VERSION); | |
| 188 | end getAnnotationVersion; | ||
| 189 | |||
| 190 | public function setAnnotationVersion | ||
| 191 | "setAnnotationVersion(\"3.x\"); | ||
| 192 | for annotations: 1.x or 2.x or 3.x" | ||
| 193 | input String annotationVersion; | ||
| 194 | algorithm | ||
| 195 | ✗ | FlagsUtil.setConfigString(Flags.ANNOTATION_VERSION, annotationVersion); | |
| 196 | end setAnnotationVersion; | ||
| 197 | |||
| 198 | public function getNoSimplify | ||
| 199 | "returns what flag was given at start | ||
| 200 | omc [+noSimplify] | ||
| 201 | or via the API | ||
| 202 | setNoSimplify(true|false);" | ||
| 203 | output Boolean noSimplify; | ||
| 204 | algorithm | ||
| 205 | 4148211 | noSimplify := Flags.getConfigBool(Flags.NO_SIMPLIFY); | |
| 206 | end getNoSimplify; | ||
| 207 | |||
| 208 | public function setNoSimplify | ||
| 209 | input Boolean noSimplify; | ||
| 210 | algorithm | ||
| 211 | ✗ | FlagsUtil.setConfigBool(Flags.NO_SIMPLIFY, noSimplify); | |
| 212 | end setNoSimplify; | ||
| 213 | |||
| 214 | public function vectorizationLimit | ||
| 215 | "Returns the vectorization limit that is used to determine how large an array | ||
| 216 | can be before it no longer is expanded by Static.crefVectorize." | ||
| 217 | output Integer limit; | ||
| 218 | algorithm | ||
| 219 | 68457 | limit := Flags.getConfigInt(Flags.VECTORIZATION_LIMIT); | |
| 220 | end vectorizationLimit; | ||
| 221 | |||
| 222 | public function setVectorizationLimit | ||
| 223 | "Sets the vectorization limit, see vectorizationLimit above." | ||
| 224 | input Integer limit; | ||
| 225 | algorithm | ||
| 226 | ✗ | FlagsUtil.setConfigInt(Flags.VECTORIZATION_LIMIT, limit); | |
| 227 | end setVectorizationLimit; | ||
| 228 | |||
| 229 | public function getDefaultOpenCLDevice | ||
| 230 | "Returns the id for the default OpenCL device to be used." | ||
| 231 | output Integer defdevid; | ||
| 232 | algorithm | ||
| 233 | ✗ | defdevid := Flags.getConfigInt(Flags.DEFAULT_OPENCL_DEVICE); | |
| 234 | end getDefaultOpenCLDevice; | ||
| 235 | |||
| 236 | public function setDefaultOpenCLDevice | ||
| 237 | "Sets the default OpenCL device to be used." | ||
| 238 | input Integer defdevid; | ||
| 239 | algorithm | ||
| 240 | ✗ | FlagsUtil.setConfigInt(Flags.DEFAULT_OPENCL_DEVICE, defdevid); | |
| 241 | end setDefaultOpenCLDevice; | ||
| 242 | |||
| 243 | public function showAnnotations | ||
| 244 | output Boolean show; | ||
| 245 | algorithm | ||
| 246 | 6345 | show := Flags.getConfigBool(Flags.SHOW_ANNOTATIONS); | |
| 247 | end showAnnotations; | ||
| 248 | |||
| 249 | public function setShowAnnotations | ||
| 250 | input Boolean show; | ||
| 251 | algorithm | ||
| 252 | ✗ | FlagsUtil.setConfigBool(Flags.SHOW_ANNOTATIONS, show); | |
| 253 | end setShowAnnotations; | ||
| 254 | |||
| 255 | public function showStructuralAnnotations | ||
| 256 | output Boolean show; | ||
| 257 | algorithm | ||
| 258 | 5828 | show := Flags.getConfigBool(Flags.SHOW_STRUCTURAL_ANNOTATIONS); | |
| 259 | end showStructuralAnnotations; | ||
| 260 | |||
| 261 | public function showStartOrigin | ||
| 262 | output Boolean show; | ||
| 263 | algorithm | ||
| 264 | 14547 | show := Flags.isSet(Flags.SHOW_START_ORIGIN); | |
| 265 | end showStartOrigin; | ||
| 266 | |||
| 267 | public function getEvaluateParametersInAnnotations | ||
| 268 | "@author: adrpo | ||
| 269 | flag to tell us if we should evaluate parameters in annotations" | ||
| 270 | output Boolean shouldEvaluate; | ||
| 271 | algorithm | ||
| 272 | 54010 | shouldEvaluate := Flags.getConfigBool(Flags.EVAL_PARAMS_IN_ANNOTATIONS); | |
| 273 | end getEvaluateParametersInAnnotations; | ||
| 274 | |||
| 275 | public function setEvaluateParametersInAnnotations | ||
| 276 | "@author: adrpo | ||
| 277 | flag to tell us if we should evaluate parameters in annotations" | ||
| 278 | input Boolean shouldEvaluate; | ||
| 279 | algorithm | ||
| 280 | 496 | FlagsUtil.setConfigBool(Flags.EVAL_PARAMS_IN_ANNOTATIONS, shouldEvaluate); | |
| 281 | end setEvaluateParametersInAnnotations; | ||
| 282 | |||
| 283 | public function getGraphicsExpMode | ||
| 284 | "flag to tell us if we should ignore some errors (when evaluating icons)" | ||
| 285 | output Boolean graphicsExpMode; | ||
| 286 | algorithm | ||
| 287 | 717336 | graphicsExpMode := Flags.getConfigBool(Flags.GRAPHICS_EXP_MODE); | |
| 288 | end getGraphicsExpMode; | ||
| 289 | |||
| 290 | public function setGraphicsExpMode | ||
| 291 | "flag to tell us if we should ignore some errors (when evaluating icons)" | ||
| 292 | input Boolean graphicsExpMode; | ||
| 293 | algorithm | ||
| 294 | 70 | FlagsUtil.setConfigBool(Flags.GRAPHICS_EXP_MODE, graphicsExpMode); | |
| 295 | end setGraphicsExpMode; | ||
| 296 | |||
| 297 | public function orderConnections | ||
| 298 | output Boolean show; | ||
| 299 | algorithm | ||
| 300 | 57354 | show := Flags.getConfigBool(Flags.ORDER_CONNECTIONS); | |
| 301 | end orderConnections; | ||
| 302 | |||
| 303 | public function setOrderConnections | ||
| 304 | input Boolean show; | ||
| 305 | algorithm | ||
| 306 | ✗ | FlagsUtil.setConfigBool(Flags.ORDER_CONNECTIONS, show); | |
| 307 | end setOrderConnections; | ||
| 308 | |||
| 309 | public function getPreOptModules | ||
| 310 | output list<String> outStringLst; | ||
| 311 | algorithm | ||
| 312 | 1176 | outStringLst := Flags.getConfigStringList(Flags.PRE_OPT_MODULES); | |
| 313 | end getPreOptModules; | ||
| 314 | |||
| 315 | public function getPostOptModules | ||
| 316 | output list<String> outStringLst; | ||
| 317 | algorithm | ||
| 318 | 1089 | outStringLst := Flags.getConfigStringList(Flags.POST_OPT_MODULES); | |
| 319 | end getPostOptModules; | ||
| 320 | |||
| 321 | public function getPostOptModulesDAE | ||
| 322 | output list<String> outStringLst; | ||
| 323 | algorithm | ||
| 324 | 9 | outStringLst := Flags.getConfigStringList(Flags.POST_OPT_MODULES_DAE); | |
| 325 | end getPostOptModulesDAE; | ||
| 326 | |||
| 327 | public function getInitOptModules | ||
| 328 | output list<String> outStringLst; | ||
| 329 | algorithm | ||
| 330 | 1120 | outStringLst := Flags.getConfigStringList(Flags.INIT_OPT_MODULES); | |
| 331 | end getInitOptModules; | ||
| 332 | |||
| 333 | public function setPreOptModules | ||
| 334 | input list<String> inStringLst; | ||
| 335 | algorithm | ||
| 336 | ✗ | FlagsUtil.setConfigStringList(Flags.PRE_OPT_MODULES, inStringLst); | |
| 337 | end setPreOptModules; | ||
| 338 | |||
| 339 | public function setPostOptModules | ||
| 340 | input list<String> inStringLst; | ||
| 341 | algorithm | ||
| 342 | ✗ | FlagsUtil.setConfigStringList(Flags.POST_OPT_MODULES, inStringLst); | |
| 343 | end setPostOptModules; | ||
| 344 | |||
| 345 | public function getIndexReductionMethod | ||
| 346 | output String outString; | ||
| 347 | algorithm | ||
| 348 | 71992 | outString := Flags.getConfigString(Flags.INDEX_REDUCTION_METHOD); | |
| 349 | end getIndexReductionMethod; | ||
| 350 | |||
| 351 | public function setIndexReductionMethod | ||
| 352 | input String inString; | ||
| 353 | algorithm | ||
| 354 | ✗ | FlagsUtil.setConfigString(Flags.INDEX_REDUCTION_METHOD, inString); | |
| 355 | end setIndexReductionMethod; | ||
| 356 | |||
| 357 | public function getCheapMatchingAlgorithm | ||
| 358 | output Integer outInteger; | ||
| 359 | algorithm | ||
| 360 | 119387 | outInteger := Flags.getConfigInt(Flags.CHEAPMATCHING_ALGORITHM); | |
| 361 | end getCheapMatchingAlgorithm; | ||
| 362 | |||
| 363 | public function setCheapMatchingAlgorithm | ||
| 364 | input Integer inInteger; | ||
| 365 | algorithm | ||
| 366 | ✗ | FlagsUtil.setConfigInt(Flags.CHEAPMATCHING_ALGORITHM, inInteger); | |
| 367 | end setCheapMatchingAlgorithm; | ||
| 368 | |||
| 369 | public function getMatchingAlgorithm | ||
| 370 | output String outString; | ||
| 371 | algorithm | ||
| 372 | 10401 | outString := Flags.getConfigString(Flags.MATCHING_ALGORITHM); | |
| 373 | end getMatchingAlgorithm; | ||
| 374 | |||
| 375 | public function setMatchingAlgorithm | ||
| 376 | input String inString; | ||
| 377 | algorithm | ||
| 378 | ✗ | FlagsUtil.setConfigString(Flags.MATCHING_ALGORITHM, inString); | |
| 379 | end setMatchingAlgorithm; | ||
| 380 | |||
| 381 | public function getTearingMethod | ||
| 382 | output String outString; | ||
| 383 | algorithm | ||
| 384 | 3938 | outString := Flags.getConfigString(Flags.TEARING_METHOD); | |
| 385 | end getTearingMethod; | ||
| 386 | |||
| 387 | public function setTearingMethod | ||
| 388 | input String inString; | ||
| 389 | algorithm | ||
| 390 | ✗ | FlagsUtil.setConfigString(Flags.TEARING_METHOD, inString); | |
| 391 | end setTearingMethod; | ||
| 392 | |||
| 393 | public function getTearingHeuristic | ||
| 394 | output String outString; | ||
| 395 | algorithm | ||
| 396 | 3314 | outString := Flags.getConfigString(Flags.TEARING_HEURISTIC); | |
| 397 | end getTearingHeuristic; | ||
| 398 | |||
| 399 | public function setTearingHeuristic | ||
| 400 | input String inString; | ||
| 401 | algorithm | ||
| 402 | ✗ | FlagsUtil.setConfigString(Flags.TEARING_HEURISTIC, inString); | |
| 403 | end setTearingHeuristic; | ||
| 404 | |||
| 405 | public function simCodeTarget "Default is set by +simCodeTarget=C. | ||
| 406 | \"C.old\" generates the same sources as \"C\" and differs only in what the | ||
| 407 | makefile links and defines, so every code generator sees \"C\"." | ||
| 408 | output String target; | ||
| 409 | algorithm | ||
| 410 | 1841611 | target := Flags.getConfigString(Flags.SIMCODE_TARGET); | |
| 411 |
3/4✓ Branch 0 taken 1841580 times.
✓ Branch 1 taken 31 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 31 times.
|
1841611 | if target == "C.old" then |
| 412 | target := "C"; | ||
| 413 | end if; | ||
| 414 | end simCodeTarget; | ||
| 415 | |||
| 416 | public function targetTriple | ||
| 417 | "The lib/<triple>/omc holding the runtime --target builds against. Autoconf.triple | ||
| 418 | is omc's own build, which is the same only while one toolchain is shipped." | ||
| 419 | output String triple; | ||
| 420 | protected | ||
| 421 | String target; | ||
| 422 | algorithm | ||
| 423 | if Autoconf.os <> "Windows_NT" then | ||
| 424 | triple := Autoconf.triple; | ||
| 425 | 2880 | return; | |
| 426 | end if; | ||
| 427 | target := Flags.getConfigString(Flags.TARGET); | ||
| 428 | triple := listHead(System.strtok(Autoconf.triple, "-")) + | ||
| 429 | (if StringUtil.startsWith(target, "msvc") or target == "debugrt" then "-windows-msvc" else "-windows-gnu"); | ||
| 430 | end targetTriple; | ||
| 431 | |||
| 432 | public function simCodeRustRuntime "+simCodeTarget=C links libSimulationRuntimeRust, +simCodeTarget=C.old libSimulationRuntimeC." | ||
| 433 | output Boolean rust; | ||
| 434 | algorithm | ||
| 435 |
3/4✓ Branch 1 taken 2411 times.
✓ Branch 2 taken 46 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2411 times.
|
2457 | rust := Flags.getConfigString(Flags.SIMCODE_TARGET) == "C"; |
| 436 | end simCodeRustRuntime; | ||
| 437 | |||
| 438 | public function setsimCodeTarget | ||
| 439 | input String inString; | ||
| 440 | algorithm | ||
| 441 | ✗ | FlagsUtil.setConfigString(Flags.SIMCODE_TARGET, inString); | |
| 442 | end setsimCodeTarget; | ||
| 443 | |||
| 444 | public function getLanguageStandard | ||
| 445 | output LanguageStandard outStandard; | ||
| 446 | algorithm | ||
| 447 | 441817 | outStandard := intLanguageStandard(Flags.getConfigEnum(Flags.LANGUAGE_STANDARD)); | |
| 448 | end getLanguageStandard; | ||
| 449 | |||
| 450 | public function setLanguageStandard | ||
| 451 | input LanguageStandard inStandard; | ||
| 452 | algorithm | ||
| 453 | 448 | FlagsUtil.setConfigEnum(Flags.LANGUAGE_STANDARD, languageStandardInt(inStandard)); | |
| 454 | end setLanguageStandard; | ||
| 455 | |||
| 456 | public function languageStandardAtLeast | ||
| 457 | input LanguageStandard inStandard; | ||
| 458 | output Boolean outRes; | ||
| 459 | protected | ||
| 460 | LanguageStandard std; | ||
| 461 | algorithm | ||
| 462 | 17724 | std := getLanguageStandard(); | |
| 463 | 17724 | outRes := intGe(languageStandardInt(std), languageStandardInt(inStandard)); | |
| 464 | end languageStandardAtLeast; | ||
| 465 | |||
| 466 | public function languageStandardAtMost | ||
| 467 | input LanguageStandard inStandard; | ||
| 468 | output Boolean outRes; | ||
| 469 | protected | ||
| 470 | LanguageStandard std; | ||
| 471 | algorithm | ||
| 472 | 4848 | std := getLanguageStandard(); | |
| 473 | 4848 | outRes := intLe(languageStandardInt(std), languageStandardInt(inStandard)); | |
| 474 | end languageStandardAtMost; | ||
| 475 | |||
| 476 | protected function languageStandardInt | ||
| 477 | input LanguageStandard inStandard; | ||
| 478 | output Integer outValue; | ||
| 479 | protected | ||
| 480 | constant array<Integer> lookup = MetaModelica.Dangerous.listArrayLiteral({10, 20, 30, 31, 32, 33, 34, 35, 36, 37, 1000, 9999}); | ||
| 481 | algorithm | ||
| 482 | 45592 | outValue := arrayGet(lookup, Integer(inStandard)); | |
| 483 | end languageStandardInt; | ||
| 484 | |||
| 485 | protected function intLanguageStandard | ||
| 486 | input Integer inValue; | ||
| 487 | output LanguageStandard outStandard; | ||
| 488 | algorithm | ||
| 489 | outStandard := match inValue | ||
| 490 | case 10 then LanguageStandard._1_x; | ||
| 491 | case 20 then LanguageStandard._2_x; | ||
| 492 | case 30 then LanguageStandard._3_0; | ||
| 493 | case 31 then LanguageStandard._3_1; | ||
| 494 | case 32 then LanguageStandard._3_2; | ||
| 495 | case 33 then LanguageStandard._3_3; | ||
| 496 | case 34 then LanguageStandard._3_4; | ||
| 497 | case 35 then LanguageStandard._3_5; | ||
| 498 | case 36 then LanguageStandard._3_6; | ||
| 499 | case 37 then LanguageStandard._3_7; | ||
| 500 | case 1000 then LanguageStandard.latest; | ||
| 501 | case 9999 then LanguageStandard.experimental; | ||
| 502 | end match; | ||
| 503 | end intLanguageStandard; | ||
| 504 | |||
| 505 | public function languageStandardString | ||
| 506 | input LanguageStandard inStandard; | ||
| 507 | output String outString; | ||
| 508 | protected | ||
| 509 | constant array<String> lookup = MetaModelica.Dangerous.listArrayLiteral({"1.x","2.x","3.0","3.1","3.2","3.3","3.4","3.5","3.6","3.7","3.7","experimental" /*Change this to latest version if you add more versions!*/}); | ||
| 510 | algorithm | ||
| 511 | ✗ | outString := arrayGet(lookup, Integer(inStandard)); | |
| 512 | end languageStandardString; | ||
| 513 | |||
| 514 | public function setLanguageStandardFromMSL | ||
| 515 | input String inLibraryName; | ||
| 516 | input Boolean force = false "Set the standard even if it was already set"; | ||
| 517 | protected | ||
| 518 | LanguageStandard current_std; | ||
| 519 | algorithm | ||
| 520 | 1464 | current_std := getLanguageStandard(); | |
| 521 |
2/2✓ Branch 0 taken 978 times.
✓ Branch 1 taken 486 times.
|
1464 | if not force and current_std <> LanguageStandard.latest then |
| 522 | // If we selected an MSL version manually, we respect that choice. | ||
| 523 | 978 | return; | |
| 524 | end if; | ||
| 525 | |||
| 526 | () := matchcontinue inLibraryName | ||
| 527 | local | ||
| 528 | String version; | ||
| 529 | LanguageStandard new_std; | ||
| 530 | |||
| 531 | case _ | ||
| 532 | algorithm | ||
| 533 |
5/8✗ Branch 1 not taken.
✓ Branch 2 taken 486 times.
✓ Branch 3 taken 448 times.
✓ Branch 4 taken 38 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 448 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 448 times.
|
486 | "Modelica" :: version :: _ := System.strtok(inLibraryName, " "); |
| 534 | 448 | new_std := versionStringToStd(version); | |
| 535 | |||
| 536 |
1/2✓ Branch 0 taken 448 times.
✗ Branch 1 not taken.
|
448 | if new_std <> current_std then |
| 537 | 448 | setLanguageStandard(new_std); | |
| 538 | |||
| 539 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 448 times.
|
448 | if hasLanguageStandardChanged(current_std) then |
| 540 | ✗ | Error.addMessage(Error.CHANGED_STD_VERSION, | |
| 541 | {languageStandardString(new_std), version}); | ||
| 542 | end if; | ||
| 543 | end if; | ||
| 544 | then (); | ||
| 545 | |||
| 546 | else (); | ||
| 547 | end matchcontinue; | ||
| 548 | end setLanguageStandardFromMSL; | ||
| 549 | |||
| 550 | protected function hasLanguageStandardChanged | ||
| 551 | input LanguageStandard inOldStandard; | ||
| 552 | output Boolean outHasChanged; | ||
| 553 | algorithm | ||
| 554 | // If the old standard wasn't set by the user, then we consider it to have | ||
| 555 | // changed only if the new standard is 3.0 or less. This is to avoid | ||
| 556 | // printing a notice if the user loads e.g. MSL 3.1. | ||
| 557 | 448 | outHasChanged := languageStandardAtMost(LanguageStandard._3_0); | |
| 558 | end hasLanguageStandardChanged; | ||
| 559 | |||
| 560 | public function versionStringToStd | ||
| 561 | input String inVersion; | ||
| 562 | output LanguageStandard outStandard; | ||
| 563 | protected | ||
| 564 | list<String> version; | ||
| 565 | algorithm | ||
| 566 | 448 | version := System.strtok(inVersion, "."); | |
| 567 | 448 | outStandard := versionStringToStd2(version); | |
| 568 | end versionStringToStd; | ||
| 569 | |||
| 570 | protected function versionStringToStd2 | ||
| 571 | input list<String> inVersion; | ||
| 572 | output LanguageStandard outStandard; | ||
| 573 | algorithm | ||
| 574 | outStandard := match inVersion | ||
| 575 | case "1" :: _ then LanguageStandard._1_x; | ||
| 576 | case "2" :: _ then LanguageStandard._2_x; | ||
| 577 | case "3" :: "0" :: _ then LanguageStandard._3_0; | ||
| 578 | case "3" :: "1" :: _ then LanguageStandard._3_1; | ||
| 579 | case "3" :: _ then LanguageStandard._3_2; | ||
| 580 | case "4" :: "0" :: _ then LanguageStandard._3_4; | ||
| 581 | case "4" :: "1" :: _ then LanguageStandard._3_6; | ||
| 582 | case _ then LanguageStandard.latest; | ||
| 583 | end match; | ||
| 584 | end versionStringToStd2; | ||
| 585 | |||
| 586 | public function showErrorMessages | ||
| 587 | output Boolean outShowErrorMessages; | ||
| 588 | algorithm | ||
| 589 | ✗ | outShowErrorMessages := Flags.getConfigBool(Flags.SHOW_ERROR_MESSAGES); | |
| 590 | end showErrorMessages; | ||
| 591 | |||
| 592 | public function scalarizeMinMax | ||
| 593 | output Boolean outScalarizeMinMax; | ||
| 594 | algorithm | ||
| 595 | 879 | outScalarizeMinMax := Flags.getConfigBool(Flags.SCALARIZE_MINMAX); | |
| 596 | end scalarizeMinMax; | ||
| 597 | |||
| 598 | public function scalarizeBindings | ||
| 599 | output Boolean outScalarizeBindings; | ||
| 600 | algorithm | ||
| 601 | 638583 | outScalarizeBindings := Flags.getConfigBool(Flags.SCALARIZE_BINDINGS); | |
| 602 | end scalarizeBindings; | ||
| 603 | |||
| 604 | public function intEnumConversion | ||
| 605 | output Boolean outIntEnumConversion; | ||
| 606 | algorithm | ||
| 607 | 8 | outIntEnumConversion := Flags.getConfigBool(Flags.INT_ENUM_CONVERSION); | |
| 608 | end intEnumConversion; | ||
| 609 | |||
| 610 | public function profileSome | ||
| 611 | output Boolean outBoolean; | ||
| 612 | algorithm | ||
| 613 | 7456 | outBoolean := 0==System.strncmp(Flags.getConfigString(Flags.PROFILING_LEVEL), "blocks", 6); | |
| 614 | end profileSome; | ||
| 615 | |||
| 616 | public function profileAll | ||
| 617 | output Boolean outBoolean; | ||
| 618 | algorithm | ||
| 619 |
1/4✗ Branch 1 not taken.
✓ Branch 2 taken 472219 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
|
472219 | outBoolean := stringEq(Flags.getConfigString(Flags.PROFILING_LEVEL), "all"); |
| 620 | end profileAll; | ||
| 621 | |||
| 622 | public function profileHtml | ||
| 623 | output Boolean outBoolean; | ||
| 624 | algorithm | ||
| 625 |
3/4✓ Branch 1 taken 1 time.
✓ Branch 2 taken 1121 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 time.
|
1122 | outBoolean := stringEq(Flags.getConfigString(Flags.PROFILING_LEVEL), "blocks+html"); |
| 626 | end profileHtml; | ||
| 627 | |||
| 628 | public function profileFunctions | ||
| 629 | output Boolean outBoolean; | ||
| 630 | algorithm | ||
| 631 |
3/4✓ Branch 1 taken 33999 times.
✓ Branch 2 taken 18 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 33999 times.
|
34017 | outBoolean := not stringEq(Flags.getConfigString(Flags.PROFILING_LEVEL), "none"); |
| 632 | end profileFunctions; | ||
| 633 | |||
| 634 | public function dynamicTearing | ||
| 635 | output String outString; | ||
| 636 | algorithm | ||
| 637 | 2188 | outString := Flags.getConfigString(Flags.DYNAMIC_TEARING); | |
| 638 | end dynamicTearing; | ||
| 639 | |||
| 640 | public function ignoreCommandLineOptionsAnnotation | ||
| 641 | output Boolean outBoolean; | ||
| 642 | algorithm | ||
| 643 | 2722 | outBoolean := Flags.getConfigBool(Flags.IGNORE_COMMAND_LINE_OPTIONS_ANNOTATION); | |
| 644 | end ignoreCommandLineOptionsAnnotation; | ||
| 645 | |||
| 646 | public function globalHomotopy | ||
| 647 | output Boolean outBoolean; | ||
| 648 | algorithm | ||
| 649 | outBoolean := match Flags.getConfigString(Flags.HOMOTOPY_APPROACH) | ||
| 650 | case "equidistantLocal" then false; | ||
| 651 | case "adaptiveLocal" then false; | ||
| 652 | case "equidistantGlobal" then true; | ||
| 653 | case "adaptiveGlobal" then true; | ||
| 654 | end match; | ||
| 655 | end globalHomotopy; | ||
| 656 | |||
| 657 | public function adaptiveHomotopy | ||
| 658 | output Boolean outBoolean; | ||
| 659 | algorithm | ||
| 660 | outBoolean := match Flags.getConfigString(Flags.HOMOTOPY_APPROACH) | ||
| 661 | case "equidistantLocal" then false; | ||
| 662 | case "adaptiveLocal" then true; | ||
| 663 | case "equidistantGlobal" then false; | ||
| 664 | case "adaptiveGlobal" then true; | ||
| 665 | end match; | ||
| 666 | end adaptiveHomotopy; | ||
| 667 | |||
| 668 | public function replacedHomotopy | ||
| 669 | output Boolean outBoolean; | ||
| 670 | protected | ||
| 671 | String replaceHomotopy; | ||
| 672 | algorithm | ||
| 673 | 1204 | replaceHomotopy := Flags.getConfigString(Flags.REPLACE_HOMOTOPY); | |
| 674 |
2/8✗ Branch 0 not taken.
✓ Branch 1 taken 1204 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1204 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
|
1204 | outBoolean := replaceHomotopy == "actual" or replaceHomotopy == "simplified"; |
| 675 | end replacedHomotopy; | ||
| 676 | |||
| 677 | public function synchronousFeaturesAllowed | ||
| 678 | "@autor: adrpo | ||
| 679 | checks returns true if language standard is above or equal to Modelica 3.3" | ||
| 680 | output Boolean outRes = getLanguageStandard() >= LanguageStandard._3_3; | ||
| 681 | end synchronousFeaturesAllowed; | ||
| 682 | |||
| 683 | public function flatModelica | ||
| 684 | output Boolean value; | ||
| 685 | algorithm | ||
| 686 | 1364 | value := Flags.getConfigBool(Flags.BASE_MODELICA); | |
| 687 | |||
| 688 | // Ignore the flag unless the new frontend is enabled, otherwise it won't work. | ||
| 689 |
3/4✓ Branch 0 taken 1331 times.
✓ Branch 1 taken 33 times.
✓ Branch 3 taken 33 times.
✗ Branch 4 not taken.
|
1364 | if value and not Flags.isSet(Flags.SCODE_INST) then |
| 690 | ✗ | Error.addMessage(Error.INVALID_FLAG_CONDITION, | |
| 691 | {"-f", "flat modelica requires flag -d=newInst to be set"}); | ||
| 692 | value := false; | ||
| 693 | end if; | ||
| 694 | end flatModelica; | ||
| 695 | |||
| 696 | annotation(__OpenModelica_Interface="util"); | ||
| 697 | end Config; | ||
| 698 |