OMCompiler/Compiler/FrontEnd/SCodeDump.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 SCodeDump | ||
| 37 | " file: SCodeDump.mo | ||
| 38 | package: SCodeDump | ||
| 39 | description: SCodeDump intermediate form | ||
| 40 | |||
| 41 | |||
| 42 | This module functions for printing SCode." | ||
| 43 | |||
| 44 | public import Absyn; | ||
| 45 | public import AbsynUtil; | ||
| 46 | public import SCode; | ||
| 47 | |||
| 48 | protected import Dump; | ||
| 49 | protected import List; | ||
| 50 | protected import SCodeDumpTpl; | ||
| 51 | protected import Tpl; | ||
| 52 | |||
| 53 | |||
| 54 | public uniontype SCodeDumpOptions | ||
| 55 | record OPTIONS | ||
| 56 | Boolean stripAlgorithmSections; | ||
| 57 | Boolean stripProtectedImports; | ||
| 58 | Boolean stripProtectedClasses; | ||
| 59 | Boolean stripProtectedComponents; | ||
| 60 | Boolean stripMetaRecords "The automatically generated records that change scope from uniontype to the package"; | ||
| 61 | Boolean stripGraphicalAnnotations; | ||
| 62 | Boolean stripStringComments; | ||
| 63 | Boolean stripExternalDecl; | ||
| 64 | Boolean stripOutputBindings; | ||
| 65 | end OPTIONS; | ||
| 66 | end SCodeDumpOptions; | ||
| 67 | |||
| 68 | public constant SCodeDumpOptions defaultOptions = OPTIONS(false,false,false,false,true,true,false,false,false); | ||
| 69 | |||
| 70 | function generateOptions | ||
| 71 | input Boolean stripAlgorithmSections = false; | ||
| 72 | input Boolean stripProtectedImports = false; | ||
| 73 | input Boolean stripProtectedClasses = false; | ||
| 74 | input Boolean stripProtectedComponents = false; | ||
| 75 | input Boolean stripMetaRecords = true; | ||
| 76 | input Boolean stripGraphicalAnnotations = true; | ||
| 77 | input Boolean stripStringComments = false; | ||
| 78 | input Boolean stripExternalDecl = false; | ||
| 79 | input Boolean stripOutputBindings = false; | ||
| 80 | output SCodeDumpOptions options; | ||
| 81 | algorithm | ||
| 82 |
9/18✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 31 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 31 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 31 times.
✓ Branch 10 taken 31 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 31 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 31 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 31 times.
✗ Branch 17 not taken.
|
217 | options := OPTIONS(stripAlgorithmSections, stripProtectedImports, stripProtectedClasses, stripProtectedComponents, stripMetaRecords,stripGraphicalAnnotations, stripStringComments, stripExternalDecl, stripOutputBindings); |
| 83 | end generateOptions; | ||
| 84 | |||
| 85 | public function programStr | ||
| 86 | input SCode.Program inProgram; | ||
| 87 | input SCodeDumpOptions options = defaultOptions; | ||
| 88 | output String outString; | ||
| 89 | algorithm | ||
| 90 | 5 | outString := Tpl.tplString2(SCodeDumpTpl.dumpProgram, inProgram, options); | |
| 91 | end programStr; | ||
| 92 | |||
| 93 | public function classDefStr | ||
| 94 | input SCode.ClassDef cd; | ||
| 95 | input SCodeDumpOptions options = defaultOptions; | ||
| 96 | output String outString; | ||
| 97 | algorithm | ||
| 98 | ✗ | outString := Tpl.tplString2(SCodeDumpTpl.dumpClassDef, cd, options); | |
| 99 | end classDefStr; | ||
| 100 | |||
| 101 | public function statementStr | ||
| 102 | input SCode.Statement stmt; | ||
| 103 | input SCodeDumpOptions options = defaultOptions; | ||
| 104 | output String outString; | ||
| 105 | algorithm | ||
| 106 | ✗ | outString := Tpl.tplString2(SCodeDumpTpl.dumpStatement, stmt, options); | |
| 107 | end statementStr; | ||
| 108 | |||
| 109 | public function equationStr | ||
| 110 | input SCode.Equation inEquation; | ||
| 111 | input SCodeDumpOptions options = defaultOptions; | ||
| 112 | output String outString; | ||
| 113 | algorithm | ||
| 114 | 35 | outString := Tpl.tplString2(SCodeDumpTpl.dumpEquation, inEquation, options); | |
| 115 | end equationStr; | ||
| 116 | |||
| 117 | public function printModStr | ||
| 118 | "Prints SCode.Mod to a string." | ||
| 119 | input SCode.Mod inMod; | ||
| 120 | input SCodeDumpOptions options = defaultOptions; | ||
| 121 | output String outString; | ||
| 122 | algorithm | ||
| 123 | 12 | outString := Tpl.tplString2(SCodeDumpTpl.dumpModifier, inMod, options); | |
| 124 | end printModStr; | ||
| 125 | |||
| 126 | public function printCommentAndAnnotationStr | ||
| 127 | "Prints SCode.Comment to a string." | ||
| 128 | input SCode.Comment inComment; | ||
| 129 | input SCodeDumpOptions options = defaultOptions; | ||
| 130 | output String outString; | ||
| 131 | algorithm | ||
| 132 | ✗ | outString := Tpl.tplString2(SCodeDumpTpl.dumpComment, inComment, options); | |
| 133 | end printCommentAndAnnotationStr; | ||
| 134 | |||
| 135 | public function printCommentStr | ||
| 136 | "Prints SCode.Comment.comment to a string." | ||
| 137 | input SCode.Comment inComment; | ||
| 138 | input SCodeDumpOptions options = defaultOptions; | ||
| 139 | output String outString; | ||
| 140 | algorithm | ||
| 141 | outString := match inComment | ||
| 142 | local Option<String> comment; | ||
| 143 | case SCode.COMMENT(comment = comment) | ||
| 144 | 5 | then Tpl.tplString2(SCodeDumpTpl.dumpCommentStr, comment, options); | |
| 145 | else ""; | ||
| 146 | end match; | ||
| 147 | end printCommentStr; | ||
| 148 | |||
| 149 | public function printAnnotationStr | ||
| 150 | "Prints SCode.Comment.annotation to a string." | ||
| 151 | input SCode.Comment inComment; | ||
| 152 | input SCodeDumpOptions options = defaultOptions; | ||
| 153 | output String outString; | ||
| 154 | algorithm | ||
| 155 | outString := match inComment | ||
| 156 | local Option<SCode.Annotation> annotation_; | ||
| 157 | case SCode.COMMENT(annotation_ = annotation_) | ||
| 158 | 5 | then Tpl.tplString2(SCodeDumpTpl.dumpAnnotationOpt, annotation_, options); | |
| 159 | else ""; | ||
| 160 | end match; | ||
| 161 | end printAnnotationStr; | ||
| 162 | |||
| 163 | public function restrString | ||
| 164 | "Prints SCode.Restriction to a string." | ||
| 165 | input SCode.Restriction inRestriction; | ||
| 166 | output String outString; | ||
| 167 | algorithm | ||
| 168 | outString := match inRestriction | ||
| 169 | case SCode.R_CLASS() then "class"; | ||
| 170 | case SCode.R_OPTIMIZATION() then "optimization"; | ||
| 171 | case SCode.R_MODEL() then "model"; | ||
| 172 | case SCode.R_RECORD(false) then "record"; | ||
| 173 | case SCode.R_RECORD(true) then "operator record"; | ||
| 174 | case SCode.R_BLOCK() then "block"; | ||
| 175 | case SCode.R_CONNECTOR(false) then "connector"; | ||
| 176 | case SCode.R_CONNECTOR(true) then "expandable connector"; | ||
| 177 | case SCode.R_OPERATOR() then "operator"; | ||
| 178 | case SCode.R_FUNCTION() | ||
| 179 | then match inRestriction.functionRestriction | ||
| 180 | case SCode.FR_NORMAL_FUNCTION(purity = Absyn.FunctionPurity.PURE()) then "pure function"; | ||
| 181 | case SCode.FR_NORMAL_FUNCTION(purity = Absyn.FunctionPurity.IMPURE()) then "impure function"; | ||
| 182 | case SCode.FR_OPERATOR_FUNCTION() then "operator function"; | ||
| 183 | case SCode.FR_EXTERNAL_FUNCTION(purity = Absyn.FunctionPurity.PURE()) then "pure external function"; | ||
| 184 | case SCode.FR_EXTERNAL_FUNCTION(purity = Absyn.FunctionPurity.IMPURE()) then "impure external function"; | ||
| 185 | case SCode.FR_RECORD_CONSTRUCTOR() then "record constructor"; | ||
| 186 | case SCode.FR_PARALLEL_FUNCTION() then "parallel function"; | ||
| 187 | case SCode.FR_KERNEL_FUNCTION() then "kernel function"; | ||
| 188 | else "function"; | ||
| 189 | end match; | ||
| 190 | case SCode.R_TYPE() then "type"; | ||
| 191 | case SCode.R_PACKAGE() then "package"; | ||
| 192 | case SCode.R_ENUMERATION() then "enumeration"; | ||
| 193 | 22 | case SCode.R_METARECORD() then "metarecord " + AbsynUtil.pathString(inRestriction.name); | |
| 194 | case SCode.R_UNIONTYPE() then "uniontype"; | ||
| 195 | // predefined types | ||
| 196 | case SCode.R_PREDEFINED_INTEGER() then "Integer"; | ||
| 197 | case SCode.R_PREDEFINED_REAL() then "Real"; | ||
| 198 | case SCode.R_PREDEFINED_STRING() then "String"; | ||
| 199 | case SCode.R_PREDEFINED_BOOLEAN() then "Boolean"; | ||
| 200 | // BTH | ||
| 201 | case SCode.R_PREDEFINED_CLOCK() then "Clock"; | ||
| 202 | case SCode.R_PREDEFINED_ENUMERATION() then "enumeration"; | ||
| 203 | end match; | ||
| 204 | end restrString; | ||
| 205 | |||
| 206 | public function restrictionStringPP | ||
| 207 | "Translates a SCode.Restriction to a String." | ||
| 208 | input SCode.Restriction inRestriction; | ||
| 209 | output String outString; | ||
| 210 | algorithm | ||
| 211 | 276 | outString := Tpl.tplString(SCodeDumpTpl.dumpRestriction, inRestriction); | |
| 212 | end restrictionStringPP; | ||
| 213 | |||
| 214 | protected constant String noEachStr = ""; | ||
| 215 | |||
| 216 | public function unparseElementStr | ||
| 217 | "Print SCode.Element to a string." | ||
| 218 | input SCode.Element inElement; | ||
| 219 | input SCodeDumpOptions options = defaultOptions; | ||
| 220 | output String outString; | ||
| 221 | algorithm | ||
| 222 | 68 | outString := Tpl.tplString3(SCodeDumpTpl.dumpElement, inElement, noEachStr, options); | |
| 223 | end unparseElementStr; | ||
| 224 | |||
| 225 | public function shortElementStr | ||
| 226 | "Print SCode.Element to a string." | ||
| 227 | input SCode.Element inElement; | ||
| 228 | output String outString; | ||
| 229 | algorithm | ||
| 230 | outString := match inElement | ||
| 231 | local | ||
| 232 | String str,res,n,ioStr; | ||
| 233 | SCode.Mod mod; | ||
| 234 | Absyn.Path path; | ||
| 235 | Absyn.Import imp; | ||
| 236 | Absyn.InnerOuter io; | ||
| 237 | SCode.Redeclare rdp; | ||
| 238 | SCode.Replaceable rpp; | ||
| 239 | SCode.Partial pp; | ||
| 240 | |||
| 241 | case SCode.EXTENDS(baseClassPath = path,modifications = mod) | ||
| 242 | algorithm | ||
| 243 | ✗ | str := AbsynUtil.pathString(path); | |
| 244 | ✗ | str := str + printModStr(mod,defaultOptions); | |
| 245 | ✗ | res := stringAppendList({"extends ",str,";"}); | |
| 246 | then | ||
| 247 | res; | ||
| 248 | |||
| 249 | case SCode.COMPONENT() | ||
| 250 | algorithm | ||
| 251 | ✗ | res := unparseElementStr(inElement,defaultOptions); | |
| 252 | then | ||
| 253 | res; | ||
| 254 | |||
| 255 | case SCode.CLASS(prefixes = SCode.PREFIXES(), | ||
| 256 | classDef = SCode.DERIVED()) | ||
| 257 | algorithm | ||
| 258 | ✗ | res := unparseElementStr(inElement,defaultOptions); | |
| 259 | then | ||
| 260 | res; | ||
| 261 | |||
| 262 | case SCode.CLASS(name = n, partialPrefix = pp, prefixes = SCode.PREFIXES(innerOuter = io, redeclarePrefix = rdp, replaceablePrefix = rpp), | ||
| 263 | classDef = SCode.CLASS_EXTENDS()) | ||
| 264 | algorithm | ||
| 265 | ✗ | ioStr := Dump.unparseInnerOuterStr(io) + redeclareStr(rdp) + replaceablePrefixStr(rpp) + partialStr(pp); | |
| 266 | ✗ | res := stringAppendList({ioStr, "class extends ",n,";"}); | |
| 267 | then | ||
| 268 | res; | ||
| 269 | |||
| 270 | case SCode.CLASS(name = n, partialPrefix = pp, prefixes = SCode.PREFIXES(innerOuter = io, redeclarePrefix = rdp, replaceablePrefix = rpp), | ||
| 271 | classDef = SCode.ENUMERATION()) | ||
| 272 | algorithm | ||
| 273 | ✗ | ioStr := Dump.unparseInnerOuterStr(io) + redeclareStr(rdp) + replaceablePrefixStr(rpp) + partialStr(pp); | |
| 274 | ✗ | res := stringAppendList({ioStr, "class ",n," enumeration;"}); | |
| 275 | then | ||
| 276 | res; | ||
| 277 | |||
| 278 | case SCode.CLASS(name = n, partialPrefix = pp, prefixes = SCode.PREFIXES(innerOuter = io, redeclarePrefix = rdp, replaceablePrefix = rpp)) | ||
| 279 | algorithm | ||
| 280 | ✗ | ioStr := Dump.unparseInnerOuterStr(io) + redeclareStr(rdp) + replaceablePrefixStr(rpp) + partialStr(pp); | |
| 281 | ✗ | res := stringAppendList({ioStr, "class ",n,";"}); | |
| 282 | then | ||
| 283 | res; | ||
| 284 | |||
| 285 | case SCode.IMPORT(imp = imp) | ||
| 286 | algorithm | ||
| 287 | 2839 | str := "import "+ AbsynUtil.printImportString(imp) + ";"; | |
| 288 | then str; | ||
| 289 | end match; | ||
| 290 | end shortElementStr; | ||
| 291 | |||
| 292 | public function printEnumStr | ||
| 293 | input SCode.Enum en; | ||
| 294 | output String str; | ||
| 295 | algorithm | ||
| 296 | str := match en | ||
| 297 | local | ||
| 298 | String s; | ||
| 299 | case SCode.ENUM(s, _) then s; | ||
| 300 | end match; | ||
| 301 | end printEnumStr; | ||
| 302 | |||
| 303 | public function variabilityString | ||
| 304 | "Print Variability to a string." | ||
| 305 | input SCode.Variability inVariability; | ||
| 306 | output String outString; | ||
| 307 | algorithm | ||
| 308 | outString := match inVariability | ||
| 309 | case SCode.VAR() then "VAR"; | ||
| 310 | case SCode.DISCRETE() then "DISCRETE"; | ||
| 311 | case SCode.PARAM() then "PARAM"; | ||
| 312 | case SCode.CONST() then "CONST"; | ||
| 313 | end match; | ||
| 314 | end variabilityString; | ||
| 315 | |||
| 316 | public function parallelismString | ||
| 317 | "Print parallelism to a string." | ||
| 318 | input SCode.Parallelism inParallelism; | ||
| 319 | output String outString; | ||
| 320 | algorithm | ||
| 321 | outString := match inParallelism | ||
| 322 | case SCode.PARGLOBAL() then "PARGLOBAL"; | ||
| 323 | case SCode.PARLOCAL() then "PARLOCAL"; | ||
| 324 | case SCode.NON_PARALLEL() then "NON_PARALLEL"; | ||
| 325 | end match; | ||
| 326 | end parallelismString; | ||
| 327 | |||
| 328 | public function innerouterString | ||
| 329 | "Print a inner outer info to a string." | ||
| 330 | input Absyn.InnerOuter innerOuter; | ||
| 331 | output String outString; | ||
| 332 | algorithm | ||
| 333 | outString := match innerOuter | ||
| 334 | case Absyn.INNER_OUTER() then "INNER/OUTER"; | ||
| 335 | case Absyn.INNER() then "INNER"; | ||
| 336 | case Absyn.OUTER() then "OUTER"; | ||
| 337 | case Absyn.NOT_INNER_OUTER() then ""; | ||
| 338 | end match; | ||
| 339 | end innerouterString; | ||
| 340 | |||
| 341 | public function unparseVariability | ||
| 342 | "Print Variability to a string." | ||
| 343 | input SCode.Variability inVariability; | ||
| 344 | output String outString; | ||
| 345 | algorithm | ||
| 346 | outString := match inVariability | ||
| 347 | case SCode.VAR() then ""; | ||
| 348 | case SCode.DISCRETE() then "discrete"; | ||
| 349 | case SCode.PARAM() then "parameter"; | ||
| 350 | case SCode.CONST() then "constant"; | ||
| 351 | end match; | ||
| 352 | end unparseVariability; | ||
| 353 | |||
| 354 | public function printInitialStr | ||
| 355 | "prints SCode.Initial to a string" | ||
| 356 | input SCode.Initial initial_; | ||
| 357 | output String str; | ||
| 358 | algorithm | ||
| 359 | str := match initial_ | ||
| 360 | case SCode.INITIAL() then "initial"; | ||
| 361 | case SCode.NON_INITIAL() then "non initial"; | ||
| 362 | end match; | ||
| 363 | end printInitialStr; | ||
| 364 | |||
| 365 | public function connectorTypeStr | ||
| 366 | input SCode.ConnectorType inConnectorType; | ||
| 367 | output String str; | ||
| 368 | algorithm | ||
| 369 | str := match inConnectorType | ||
| 370 | case SCode.POTENTIAL() then ""; | ||
| 371 | case SCode.FLOW() then "flow"; | ||
| 372 | case SCode.STREAM() then "stream"; | ||
| 373 | end match; | ||
| 374 | end connectorTypeStr; | ||
| 375 | |||
| 376 | public function encapsulatedStr | ||
| 377 | input SCode.Encapsulated inEncapsulated; | ||
| 378 | output String str; | ||
| 379 | algorithm | ||
| 380 | str := match inEncapsulated | ||
| 381 | case SCode.ENCAPSULATED() then "encapsulated "; | ||
| 382 | case SCode.NOT_ENCAPSULATED() then ""; | ||
| 383 | end match; | ||
| 384 | end encapsulatedStr; | ||
| 385 | |||
| 386 | public function partialStr | ||
| 387 | input SCode.Partial inPartial; | ||
| 388 | output String str; | ||
| 389 | algorithm | ||
| 390 | str := match inPartial | ||
| 391 | case SCode.PARTIAL() then "partial "; | ||
| 392 | case SCode.NOT_PARTIAL() then ""; | ||
| 393 | end match; | ||
| 394 | end partialStr; | ||
| 395 | |||
| 396 | public function visibilityStr | ||
| 397 | input SCode.Visibility inVisibility; | ||
| 398 | output String str; | ||
| 399 | algorithm | ||
| 400 | str := match inVisibility | ||
| 401 | case SCode.PUBLIC() then "public "; | ||
| 402 | case SCode.PROTECTED() then "protected "; | ||
| 403 | end match; | ||
| 404 | end visibilityStr; | ||
| 405 | |||
| 406 | public function finalStr | ||
| 407 | input SCode.Final inFinal; | ||
| 408 | output String str; | ||
| 409 | algorithm | ||
| 410 | str := match inFinal | ||
| 411 | case SCode.FINAL() then "final "; | ||
| 412 | case SCode.NOT_FINAL() then ""; | ||
| 413 | end match; | ||
| 414 | end finalStr; | ||
| 415 | |||
| 416 | public function eachStr | ||
| 417 | input SCode.Each inEach; | ||
| 418 | output String str; | ||
| 419 | algorithm | ||
| 420 | str := match inEach | ||
| 421 | case SCode.EACH() then "each "; | ||
| 422 | case SCode.NOT_EACH() then ""; | ||
| 423 | end match; | ||
| 424 | end eachStr; | ||
| 425 | |||
| 426 | public function redeclareStr | ||
| 427 | input SCode.Redeclare inRedeclare; | ||
| 428 | output String str; | ||
| 429 | algorithm | ||
| 430 | str := match inRedeclare | ||
| 431 | case SCode.REDECLARE() then "redeclare "; | ||
| 432 | case SCode.NOT_REDECLARE() then ""; | ||
| 433 | end match; | ||
| 434 | end redeclareStr; | ||
| 435 | |||
| 436 | public function replaceableStr | ||
| 437 | input SCode.Replaceable inReplaceable; | ||
| 438 | output String strReplaceable; | ||
| 439 | output String strConstraint; | ||
| 440 | algorithm | ||
| 441 | (strReplaceable, strConstraint) := match inReplaceable | ||
| 442 | local | ||
| 443 | Absyn.Path path; | ||
| 444 | SCode.Mod mod; | ||
| 445 | String path_str, mod_str; | ||
| 446 | |||
| 447 | case SCode.REPLACEABLE(SOME(SCode.CONSTRAINCLASS( | ||
| 448 | constrainingClass = path, modifier = mod))) | ||
| 449 | algorithm | ||
| 450 | ✗ | path_str := AbsynUtil.pathString(path); | |
| 451 | ✗ | mod_str := printModStr(mod,defaultOptions); | |
| 452 | ✗ | then ("replaceable ", path_str + "(" + mod_str + ")"); | |
| 453 | case SCode.REPLACEABLE(NONE()) then ("replaceable ", ""); | ||
| 454 | case SCode.NOT_REPLACEABLE() then ("", ""); | ||
| 455 | end match; | ||
| 456 | end replaceableStr; | ||
| 457 | |||
| 458 | public function replaceablePrefixStr | ||
| 459 | input SCode.Replaceable inReplaceable; | ||
| 460 | output String strReplaceable; | ||
| 461 | algorithm | ||
| 462 | strReplaceable := match inReplaceable | ||
| 463 | case SCode.REPLACEABLE(_) then "replaceable "; | ||
| 464 | case SCode.NOT_REPLACEABLE() then ""; | ||
| 465 | end match; | ||
| 466 | end replaceablePrefixStr; | ||
| 467 | |||
| 468 | public function replaceableConstrainClassStr | ||
| 469 | input SCode.Replaceable inReplaceable; | ||
| 470 | output String strReplaceable; | ||
| 471 | algorithm | ||
| 472 | ✗ | (_, strReplaceable) := replaceableStr(inReplaceable); | |
| 473 | end replaceableConstrainClassStr; | ||
| 474 | |||
| 475 | public function prefixesStr "Returns prefixes as string" | ||
| 476 | input SCode.Prefixes prefixes; | ||
| 477 | output String str; | ||
| 478 | algorithm | ||
| 479 | str := match prefixes | ||
| 480 | local | ||
| 481 | SCode.Visibility v; | ||
| 482 | SCode.Redeclare rd; | ||
| 483 | SCode.Final f; | ||
| 484 | Absyn.InnerOuter io; | ||
| 485 | SCode.Replaceable rpl; | ||
| 486 | String s; | ||
| 487 | |||
| 488 | case SCode.PREFIXES(v,rd,f,io,rpl) | ||
| 489 | algorithm | ||
| 490 | ✗ | s := visibilityStr(v) + | |
| 491 | redeclareStr(rd) + | ||
| 492 | finalStr(f) + | ||
| 493 | Dump.unparseInnerOuterStr(io) + | ||
| 494 | replaceablePrefixStr(rpl); | ||
| 495 | then | ||
| 496 | s; | ||
| 497 | |||
| 498 | end match; | ||
| 499 | end prefixesStr; | ||
| 500 | |||
| 501 | public function filterElements | ||
| 502 | input list<SCode.Element> elements; | ||
| 503 | input SCodeDumpOptions options; | ||
| 504 | output list<SCode.Element> outElements; | ||
| 505 | algorithm | ||
| 506 | 254 | outElements := List.select1(elements,filterElement,options); | |
| 507 | end filterElements; | ||
| 508 | |||
| 509 | protected function filterElement | ||
| 510 | input SCode.Element element; | ||
| 511 | input SCodeDumpOptions options; | ||
| 512 | output Boolean b; | ||
| 513 | algorithm | ||
| 514 | b := match (element,options) | ||
| 515 | case (SCode.IMPORT(visibility=SCode.PROTECTED()),OPTIONS(stripProtectedImports=true)) then false; | ||
| 516 | case (SCode.CLASS(prefixes=SCode.PREFIXES(visibility=SCode.PROTECTED())),OPTIONS(stripProtectedClasses=true)) then false; | ||
| 517 | case (SCode.COMPONENT(prefixes=SCode.PREFIXES(visibility=SCode.PROTECTED())),OPTIONS(stripProtectedComponents=true)) then false; | ||
| 518 | case (SCode.CLASS(restriction=SCode.R_METARECORD(moved = true)),OPTIONS(stripMetaRecords=true)) then false; | ||
| 519 | else true; | ||
| 520 | end match; | ||
| 521 | end filterElement; | ||
| 522 | |||
| 523 | annotation(__OpenModelica_Interface="frontend_dump"); | ||
| 524 | end SCodeDump; | ||
| 525 |