OMCompiler/Compiler/Script/Refactor.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 Refactor | ||
| 37 | " file: Refactor.mo | ||
| 38 | package: Refactor | ||
| 39 | description: Refactoring package | ||
| 40 | |||
| 41 | |||
| 42 | This module contains functions for refactoring of Modelica/MetaModelica code. | ||
| 43 | Right now there is support for old-style annotation refactoring to new-style | ||
| 44 | annotations." | ||
| 45 | |||
| 46 | |||
| 47 | public import Absyn; | ||
| 48 | import ProgramUtil; | ||
| 49 | public import AbsynUtil; | ||
| 50 | |||
| 51 | protected import List; | ||
| 52 | protected import Interactive; | ||
| 53 | protected import Inst; | ||
| 54 | protected import FCore; | ||
| 55 | protected import System; // stringReal | ||
| 56 | |||
| 57 | public function refactorGraphicalAnnotation "This function refactors the graphical annotations of a class to the modelica standard. | ||
| 58 | " | ||
| 59 | input Absyn.Program wholeAST; //AST | ||
| 60 | input Absyn.Class classToRefactor; | ||
| 61 | output Absyn.Class changedClass; //Manipulerad AST | ||
| 62 | algorithm | ||
| 63 | 1 | changedClass := match classToRefactor | |
| 64 | local | ||
| 65 | Absyn.Class c; | ||
| 66 | case _ | ||
| 67 | algorithm | ||
| 68 | c := refactorGraphAnnInClass(classToRefactor,wholeAST,Absyn.IDENT("")); | ||
| 69 | then | ||
| 70 | c; | ||
| 71 | |||
| 72 | end match; | ||
| 73 | end refactorGraphicalAnnotation; | ||
| 74 | |||
| 75 | protected function refactorGraphAnnInClass "Helper function to refactorGraphicalAnnotation. Part of the AST traverse. | ||
| 76 | " | ||
| 77 | input Absyn.Class inClass; | ||
| 78 | input Absyn.Program inProgram; | ||
| 79 | input Absyn.Path classPath; | ||
| 80 | output Absyn.Class outClass; | ||
| 81 | |||
| 82 | algorithm | ||
| 83 | outClass:= matchcontinue (inClass,inProgram,classPath) | ||
| 84 | local | ||
| 85 | Absyn.Program p; | ||
| 86 | Absyn.ClassDef resultClassDef; | ||
| 87 | String n; | ||
| 88 | Absyn.ClassDef d; | ||
| 89 | Absyn.Path cPath; | ||
| 90 | Interactive.GraphicEnvCache env; | ||
| 91 | |||
| 92 | case (outClass as Absyn.CLASS(name = n, body = d),p,Absyn.IDENT(name = "")) | ||
| 93 | algorithm | ||
| 94 | //debug_print("Refactoring Class1:", n); | ||
| 95 | 1 | cPath := Absyn.IDENT(n); | |
| 96 | 1 | env := Interactive.getClassEnv(p,cPath); | |
| 97 | 1 | resultClassDef := refactorGraphAnnInClassDef(d,p,cPath,env); | |
| 98 | 1 | outClass.body := resultClassDef; | |
| 99 | then | ||
| 100 | outClass; | ||
| 101 | |||
| 102 | case (outClass as Absyn.CLASS(name = n, body = d),p,cPath) | ||
| 103 | algorithm | ||
| 104 | // debug_print("Refactoring Class:", n); | ||
| 105 | ✗ | cPath := AbsynUtil.joinPaths(cPath,Absyn.IDENT(n)); | |
| 106 | ✗ | env := Interactive.getClassEnv(p,cPath); | |
| 107 | ✗ | refactorGraphAnnInClassDef(d,p,cPath,env); | |
| 108 | then | ||
| 109 | outClass; | ||
| 110 | |||
| 111 | end matchcontinue; | ||
| 112 | |||
| 113 | end refactorGraphAnnInClass; | ||
| 114 | |||
| 115 | protected function refactorGraphAnnInClassDef "Helper function to refactorGraphAnnInClass. Part of AST traverse. | ||
| 116 | " | ||
| 117 | input Absyn.ClassDef inDef; | ||
| 118 | input Absyn.Program inProgram; | ||
| 119 | input Absyn.Path classPath; | ||
| 120 | input Interactive.GraphicEnvCache inClassEnv; | ||
| 121 | output Absyn.ClassDef outDef; | ||
| 122 | algorithm | ||
| 123 | outDef := matchcontinue (inDef,inProgram,classPath,inClassEnv) | ||
| 124 | local | ||
| 125 | Absyn.Program p; | ||
| 126 | list<Absyn.ClassPart> cp,resultPart; | ||
| 127 | list<Absyn.Annotation> ann; | ||
| 128 | Option<String> cmt; | ||
| 129 | Absyn.ElementAttributes attrs; | ||
| 130 | list<Absyn.ElementArg> args,annList,resAnnList; | ||
| 131 | Absyn.TypeSpec ts; | ||
| 132 | Absyn.Path cPath; | ||
| 133 | Interactive.GraphicEnvCache env; | ||
| 134 | list<String> typeVars; | ||
| 135 | list<Absyn.NamedArg> classAttrs; | ||
| 136 | |||
| 137 | case(Absyn.PARTS(typeVars = typeVars, classAttrs = classAttrs, classParts = cp, ann = ann, comment = cmt),p,cPath,env) | ||
| 138 | algorithm | ||
| 139 | 1 | resultPart := refactorGraphAnnInClassParts(cp,p,cPath,env); | |
| 140 | 1 | then | |
| 141 | Absyn.PARTS(typeVars,classAttrs,resultPart,ann,cmt); | ||
| 142 | |||
| 143 | case(Absyn.DERIVED(typeSpec = ts, attributes = attrs,arguments = args, comment = SOME(Absyn.COMMENT(annotation_=SOME(Absyn.ANNOTATION(elementArgs = annList)),comment = cmt))),p,_,_) | ||
| 144 | algorithm | ||
| 145 | ✗ | resAnnList := transformClassAnnList(annList,{"Class"},{},p); | |
| 146 | ✗ | then | |
| 147 | Absyn.DERIVED(ts,attrs,args,SOME(Absyn.COMMENT(SOME(Absyn.ANNOTATION(resAnnList)),cmt))); | ||
| 148 | |||
| 149 | else inDef; | ||
| 150 | |||
| 151 | end matchcontinue; | ||
| 152 | |||
| 153 | end refactorGraphAnnInClassDef; | ||
| 154 | |||
| 155 | protected function refactorGraphAnnInClassParts "Helper function to refactorGraphAnnInClassDef. Part of the AST traverse. | ||
| 156 | " | ||
| 157 | input list<Absyn.ClassPart> inParts; | ||
| 158 | input Absyn.Program inProgram; | ||
| 159 | input Absyn.Path classPath; | ||
| 160 | input Interactive.GraphicEnvCache env; | ||
| 161 | output list<Absyn.ClassPart> outParts; | ||
| 162 | algorithm | ||
| 163 | outParts := match (inParts, inProgram, classPath) | ||
| 164 | local | ||
| 165 | Absyn.Program p; | ||
| 166 | list<Absyn.ClassPart> restParts,resParts; | ||
| 167 | Absyn.ClassPart firstPart,resultPart; | ||
| 168 | Absyn.Path cPath; | ||
| 169 | case({}, _, _) then {}; | ||
| 170 | case(firstPart :: restParts, p, cPath) | ||
| 171 | algorithm | ||
| 172 | 1 | resultPart := refactorGraphAnnInClassPart(firstPart,p,cPath,env); | |
| 173 | 1 | resParts := refactorGraphAnnInClassParts(restParts,p,cPath,env); | |
| 174 | then | ||
| 175 | resultPart :: resParts; | ||
| 176 | end match; | ||
| 177 | end refactorGraphAnnInClassParts; | ||
| 178 | |||
| 179 | protected function refactorGraphAnnInClassPart"Helper function to refactorGraphAnnInClassParts. Part of the AST traverse. | ||
| 180 | " | ||
| 181 | input Absyn.ClassPart inPart; | ||
| 182 | input Absyn.Program inProgram; | ||
| 183 | input Absyn.Path classPath; | ||
| 184 | input Interactive.GraphicEnvCache inClassEnv; | ||
| 185 | output Absyn.ClassPart outPart; | ||
| 186 | |||
| 187 | algorithm | ||
| 188 | |||
| 189 | outPart := matchcontinue (inPart,inProgram,classPath,inClassEnv) | ||
| 190 | |||
| 191 | local | ||
| 192 | |||
| 193 | Absyn.Program p; | ||
| 194 | list<Absyn.ElementItem> elContent,resultElContent; | ||
| 195 | list<Absyn.EquationItem> eqContent,resultEqContent; | ||
| 196 | list<Absyn.AlgorithmItem> algContent,resultAlgContent; | ||
| 197 | Absyn.Path cPath; | ||
| 198 | Interactive.GraphicEnvCache env; | ||
| 199 | |||
| 200 | case(Absyn.PUBLIC(contents = elContent),p,cPath,env) | ||
| 201 | algorithm | ||
| 202 | 1 | resultElContent := refactorGraphAnnInContentList(elContent,refactorGraphAnnInElItem,p,cPath,env); | |
| 203 | 1 | then | |
| 204 | Absyn.PUBLIC(resultElContent); | ||
| 205 | |||
| 206 | case(Absyn.PROTECTED(contents = elContent),p,cPath,env) | ||
| 207 | algorithm | ||
| 208 | ✗ | resultElContent := refactorGraphAnnInContentList(elContent,refactorGraphAnnInElItem,p,cPath,env); | |
| 209 | ✗ | then | |
| 210 | Absyn.PROTECTED(resultElContent); | ||
| 211 | |||
| 212 | case(Absyn.EQUATIONS(contents = eqContent),p,cPath,env) | ||
| 213 | algorithm | ||
| 214 | ✗ | resultEqContent := refactorGraphAnnInContentList(eqContent,refactorGraphAnnInEqItem,p,cPath,env); | |
| 215 | ✗ | then | |
| 216 | Absyn.EQUATIONS(resultEqContent); | ||
| 217 | |||
| 218 | case(Absyn.ALGORITHMS(contents = algContent),p,cPath,env) | ||
| 219 | algorithm | ||
| 220 | ✗ | resultAlgContent := refactorGraphAnnInContentList(algContent,refactorGraphAnnInAlgItem,p,cPath,env); | |
| 221 | ✗ | then | |
| 222 | Absyn.ALGORITHMS(resultAlgContent); | ||
| 223 | |||
| 224 | case(Absyn.INITIALEQUATIONS(contents = eqContent),p,cPath,env) | ||
| 225 | algorithm | ||
| 226 | ✗ | resultEqContent := refactorGraphAnnInContentList(eqContent,refactorGraphAnnInEqItem,p,cPath,env); | |
| 227 | ✗ | then | |
| 228 | Absyn.INITIALEQUATIONS(resultEqContent); | ||
| 229 | |||
| 230 | case(Absyn.INITIALALGORITHMS(contents = algContent),p,cPath,env) | ||
| 231 | algorithm | ||
| 232 | ✗ | resultAlgContent := refactorGraphAnnInContentList(algContent,refactorGraphAnnInAlgItem,p,cPath,env); | |
| 233 | ✗ | then | |
| 234 | Absyn.INITIALALGORITHMS(resultAlgContent); | ||
| 235 | |||
| 236 | else inPart; | ||
| 237 | end matchcontinue; | ||
| 238 | end refactorGraphAnnInClassPart; | ||
| 239 | |||
| 240 | |||
| 241 | protected function refactorGraphAnnInContentList"Helper function to refactorGraphAnnInClassPart. Part of the AST traverse. | ||
| 242 | " | ||
| 243 | input list<contentType> inList; | ||
| 244 | input refactorGraphAnnInContent refactorGraphAnnInItem; | ||
| 245 | input Absyn.Program inProgram; | ||
| 246 | input Absyn.Path classPath; | ||
| 247 | input Interactive.GraphicEnvCache inClassEnv; | ||
| 248 | output list<contentType> outList; | ||
| 249 | public | ||
| 250 | replaceable type contentType subtypeof Any; | ||
| 251 | partial function refactorGraphAnnInContent | ||
| 252 | input contentType inItem; | ||
| 253 | input Absyn.Program inProgram; | ||
| 254 | input Absyn.Path classPath; | ||
| 255 | input Interactive.GraphicEnvCache inClassEnv; | ||
| 256 | output contentType outItem; | ||
| 257 | end refactorGraphAnnInContent; | ||
| 258 | algorithm | ||
| 259 | outList := match (inList, inProgram, classPath, inClassEnv) | ||
| 260 | local | ||
| 261 | Absyn.Program p; | ||
| 262 | list<contentType> restList,resList; | ||
| 263 | contentType firstItem,resultItem; | ||
| 264 | Absyn.Path cPath; | ||
| 265 | Interactive.GraphicEnvCache env; | ||
| 266 | case({}, _, _, _) then {}; | ||
| 267 | case(firstItem :: restList, p, cPath, env) | ||
| 268 | algorithm | ||
| 269 | ✗ | resultItem := refactorGraphAnnInItem(firstItem,p,cPath,env); | |
| 270 | ✗ | resList := refactorGraphAnnInContentList(restList,refactorGraphAnnInItem,p,cPath,env); | |
| 271 | then | ||
| 272 | resultItem :: resList; | ||
| 273 | end match; | ||
| 274 | end refactorGraphAnnInContentList; | ||
| 275 | |||
| 276 | protected function refactorGraphAnnInElItem"Helper function to refactorGraphAnnInClassPart. Part of the AST traverse. | ||
| 277 | " | ||
| 278 | input Absyn.ElementItem inItem; | ||
| 279 | input Absyn.Program inProgram; | ||
| 280 | input Absyn.Path classPath; | ||
| 281 | input Interactive.GraphicEnvCache inClassEnv; | ||
| 282 | output Absyn.ElementItem outItem; | ||
| 283 | algorithm | ||
| 284 | outItem := match (inItem,inProgram,classPath,inClassEnv) | ||
| 285 | local | ||
| 286 | Absyn.Program p; | ||
| 287 | Absyn.Element el,resultElement; | ||
| 288 | Absyn.Path cPath; | ||
| 289 | Interactive.GraphicEnvCache env; | ||
| 290 | |||
| 291 | case(Absyn.ELEMENTITEM(element = el) ,p,cPath,env) | ||
| 292 | algorithm | ||
| 293 | ✗ | resultElement := refactorGraphAnnInElement(el,p,cPath,env); | |
| 294 | ✗ | then | |
| 295 | Absyn.ELEMENTITEM(resultElement); | ||
| 296 | end match; | ||
| 297 | end refactorGraphAnnInElItem; | ||
| 298 | |||
| 299 | protected function refactorGraphAnnInEqItem"Helper function to refactorGraphAnnInClassPart. Part of the AST traverse. | ||
| 300 | " | ||
| 301 | input Absyn.EquationItem inItem; | ||
| 302 | input Absyn.Program inProgram; | ||
| 303 | input Absyn.Path classPath; | ||
| 304 | input Interactive.GraphicEnvCache inClassEnv; | ||
| 305 | output Absyn.EquationItem outItem; | ||
| 306 | |||
| 307 | algorithm | ||
| 308 | |||
| 309 | outItem := matchcontinue (inItem, inProgram) | ||
| 310 | |||
| 311 | local | ||
| 312 | Absyn.Program p; | ||
| 313 | Absyn.Equation e; | ||
| 314 | Option<String> com; | ||
| 315 | list<Absyn.ElementArg> annList; | ||
| 316 | SourceInfo info; | ||
| 317 | |||
| 318 | case(Absyn.EQUATIONITEM(equation_ = e, info = info, comment = | ||
| 319 | SOME(Absyn.COMMENT(annotation_ = SOME(Absyn.ANNOTATION(elementArgs = annList)),comment = com))), p) | ||
| 320 | algorithm | ||
| 321 | ✗ | annList := transformConnectAnnList(annList,{"Connect"},{},p); //Connectannotation | |
| 322 | ✗ | then | |
| 323 | Absyn.EQUATIONITEM(e,SOME(Absyn.COMMENT(SOME(Absyn.ANNOTATION(annList)),com)),info); | ||
| 324 | else inItem; | ||
| 325 | end matchcontinue; | ||
| 326 | end refactorGraphAnnInEqItem; | ||
| 327 | |||
| 328 | protected function refactorGraphAnnInAlgItem"Helper function to refactorGraphAnnInClassPart. Part of the AST traverse. | ||
| 329 | " | ||
| 330 | input Absyn.AlgorithmItem inItem; | ||
| 331 | input Absyn.Program inProgram; | ||
| 332 | input Absyn.Path classPath; | ||
| 333 | input Interactive.GraphicEnvCache inClassEnv; | ||
| 334 | output Absyn.AlgorithmItem outItem; | ||
| 335 | algorithm | ||
| 336 | outItem := match inItem | ||
| 337 | local | ||
| 338 | Absyn.Algorithm alg; | ||
| 339 | Option<String> com; | ||
| 340 | list<Absyn.ElementArg> annList; | ||
| 341 | SourceInfo info; | ||
| 342 | case Absyn.ALGORITHMITEM(algorithm_ = alg, info = info, comment = | ||
| 343 | SOME(Absyn.COMMENT(SOME(Absyn.ANNOTATION(annList)),com))) | ||
| 344 | algorithm | ||
| 345 | // a = transformGraphAnn(a,p); whut? | ||
| 346 | |||
| 347 | ✗ | then | |
| 348 | Absyn.ALGORITHMITEM(alg,SOME(Absyn.COMMENT(SOME(Absyn.ANNOTATION(annList)),com)),info); | ||
| 349 | |||
| 350 | else inItem; | ||
| 351 | |||
| 352 | end match; | ||
| 353 | |||
| 354 | end refactorGraphAnnInAlgItem; | ||
| 355 | |||
| 356 | protected function refactorGraphAnnInElement" | ||
| 357 | Helper function to refactorGraphAnnInElItem. Part of the AST traverse. | ||
| 358 | |||
| 359 | " | ||
| 360 | input Absyn.Element inElement; | ||
| 361 | input Absyn.Program inProgram; | ||
| 362 | input Absyn.Path classPath; | ||
| 363 | input Interactive.GraphicEnvCache inClassEnv; | ||
| 364 | output Absyn.Element outElement; | ||
| 365 | |||
| 366 | algorithm | ||
| 367 | |||
| 368 | outElement := match (inElement,inProgram,classPath,inClassEnv) | ||
| 369 | |||
| 370 | local | ||
| 371 | |||
| 372 | Absyn.Program p; | ||
| 373 | Boolean f; | ||
| 374 | Option<Absyn.RedeclareKeywords> rdk; | ||
| 375 | Absyn.InnerOuter io; | ||
| 376 | Absyn.ElementSpec es,resultSpec; | ||
| 377 | SourceInfo i; | ||
| 378 | Option<Absyn.ConstrainClass> cc; | ||
| 379 | Absyn.Path cPath; | ||
| 380 | Interactive.GraphicEnvCache env; | ||
| 381 | |||
| 382 | case(Absyn.ELEMENT(finalPrefix = f, redeclareKeywords = rdk, | ||
| 383 | innerOuter = io, specification = es, info = i, constrainClass = cc),p,cPath,env) | ||
| 384 | |||
| 385 | algorithm | ||
| 386 | |||
| 387 | ✗ | cc := refactorConstrainClass(cc,p,cPath,env); | |
| 388 | ✗ | resultSpec := refactorGraphAnnInElSpec(es,p,cPath,env); | |
| 389 | |||
| 390 | ✗ | then | |
| 391 | Absyn.ELEMENT(f,rdk,io,resultSpec,i,cc); | ||
| 392 | |||
| 393 | end match; | ||
| 394 | |||
| 395 | end refactorGraphAnnInElement; | ||
| 396 | |||
| 397 | protected function refactorConstrainClass " | ||
| 398 | Helper function to refactorGraphAnnInElItem. Part of the AST traverse. | ||
| 399 | |||
| 400 | " | ||
| 401 | input Option<Absyn.ConstrainClass> inCC; | ||
| 402 | input Absyn.Program inProgram; | ||
| 403 | input Absyn.Path classPath; | ||
| 404 | input Interactive.GraphicEnvCache inClassEnv; | ||
| 405 | output Option<Absyn.ConstrainClass> outCC; | ||
| 406 | |||
| 407 | algorithm | ||
| 408 | |||
| 409 | outCC := match (inCC,inProgram,classPath,inClassEnv) | ||
| 410 | |||
| 411 | local | ||
| 412 | Absyn.Program p; | ||
| 413 | Absyn.ElementSpec es,resultSpec; | ||
| 414 | Option<Absyn.Comment> com; | ||
| 415 | Absyn.Path cPath; | ||
| 416 | Interactive.GraphicEnvCache env; | ||
| 417 | |||
| 418 | case(SOME(Absyn.CONSTRAINCLASS(elementSpec = es, comment = com)),p,cPath,env) | ||
| 419 | |||
| 420 | algorithm | ||
| 421 | ✗ | resultSpec := refactorGraphAnnInElSpec(es,p,cPath,env); | |
| 422 | |||
| 423 | ✗ | then | |
| 424 | SOME(Absyn.CONSTRAINCLASS(resultSpec,com)); | ||
| 425 | case(NONE(),_,_,_) | ||
| 426 | then NONE(); | ||
| 427 | end match; | ||
| 428 | end refactorConstrainClass; | ||
| 429 | |||
| 430 | protected function refactorGraphAnnInElSpec" | ||
| 431 | Helper function to refactorGraphAnnInElement Part of the AST traverse. | ||
| 432 | |||
| 433 | " | ||
| 434 | input Absyn.ElementSpec inSpec; | ||
| 435 | input Absyn.Program inProgram; | ||
| 436 | input Absyn.Path classPath; | ||
| 437 | input Interactive.GraphicEnvCache inClassEnv; | ||
| 438 | output Absyn.ElementSpec outSpec; | ||
| 439 | |||
| 440 | algorithm | ||
| 441 | |||
| 442 | outSpec := matchcontinue (inSpec,inProgram,classPath,inClassEnv) | ||
| 443 | |||
| 444 | local | ||
| 445 | |||
| 446 | Absyn.Program p; | ||
| 447 | Absyn.ElementAttributes at; | ||
| 448 | Absyn.Path path,cPath; | ||
| 449 | Absyn.ComponentItem firstComp,resultComp; | ||
| 450 | list<Absyn.ComponentItem> restCompList,resCompList; | ||
| 451 | Absyn.Class cl,cl1; | ||
| 452 | Boolean r; | ||
| 453 | Interactive.GraphicEnvCache env; | ||
| 454 | Option<Absyn.ArrayDim> z; | ||
| 455 | |||
| 456 | case(Absyn.CLASSDEF(replaceable_ = r, class_ = cl),p,cPath,_) | ||
| 457 | |||
| 458 | algorithm | ||
| 459 | |||
| 460 | ✗ | cl1 := refactorGraphAnnInClass(cl,p,cPath); | |
| 461 | |||
| 462 | ✗ | then | |
| 463 | Absyn.CLASSDEF(r,cl1); | ||
| 464 | |||
| 465 | case(Absyn.COMPONENTS(at,Absyn.TPATH(path,z),firstComp :: restCompList),p,cPath,env) | ||
| 466 | algorithm | ||
| 467 | ✗ | resultComp := refactorGraphAnnInComponentItem(firstComp,cPath,path,p,env); | |
| 468 | ✗ | Absyn.COMPONENTS(at,Absyn.TPATH(path,z),resCompList) := | |
| 469 | refactorGraphAnnInElSpec(Absyn.COMPONENTS(at,Absyn.TPATH(path,z),restCompList),p,cPath,env); | ||
| 470 | //resultCompList = resultComp :: resCompList; | ||
| 471 | |||
| 472 | ✗ | then | |
| 473 | Absyn.COMPONENTS(at,Absyn.TPATH(path,z), resultComp :: resCompList); //resultCompList); | ||
| 474 | |||
| 475 | else inSpec; | ||
| 476 | |||
| 477 | end matchcontinue; | ||
| 478 | |||
| 479 | end refactorGraphAnnInElSpec; | ||
| 480 | |||
| 481 | |||
| 482 | |||
| 483 | protected function refactorGraphAnnInComponentItem" | ||
| 484 | Helper function to refactorGraphAnnInElSpec Part of the AST traverse. | ||
| 485 | |||
| 486 | " | ||
| 487 | input Absyn.ComponentItem inCom; | ||
| 488 | input Absyn.Path classPath; | ||
| 489 | input Absyn.Path inPath; | ||
| 490 | input Absyn.Program inProgram; | ||
| 491 | input Interactive.GraphicEnvCache inClassEnv; | ||
| 492 | output Absyn.ComponentItem outCom; | ||
| 493 | |||
| 494 | algorithm | ||
| 495 | |||
| 496 | outCom := matchcontinue (inCom,classPath,inPath,inProgram,inClassEnv) | ||
| 497 | |||
| 498 | local | ||
| 499 | |||
| 500 | Absyn.Program p; | ||
| 501 | Absyn.Path path,cPath; | ||
| 502 | Option<Absyn.ComponentCondition> con; | ||
| 503 | Absyn.Component comp; | ||
| 504 | list<Absyn.ElementArg> annList; | ||
| 505 | Option<String> str; | ||
| 506 | Interactive.GraphicEnvCache env; | ||
| 507 | |||
| 508 | case(Absyn.COMPONENTITEM(component = comp, condition = con, | ||
| 509 | comment = SOME(Absyn.COMMENT(annotation_ = SOME(Absyn.ANNOTATION(elementArgs = annList)), comment = str))), | ||
| 510 | cPath,path,p,env) | ||
| 511 | algorithm | ||
| 512 | ✗ | annList := transformComponentAnnList(annList,{"Component"},{},cPath,path,p,env); | |
| 513 | |||
| 514 | ✗ | then | |
| 515 | Absyn.COMPONENTITEM(comp,con,SOME(Absyn.COMMENT(SOME(Absyn.ANNOTATION(annList)),str))/*NONE*/); | ||
| 516 | |||
| 517 | else inCom; | ||
| 518 | |||
| 519 | end matchcontinue; | ||
| 520 | |||
| 521 | end refactorGraphAnnInComponentItem; | ||
| 522 | |||
| 523 | |||
| 524 | protected function transformComponentAnnList " | ||
| 525 | This function transforms old component annotations to new ones | ||
| 526 | " | ||
| 527 | |||
| 528 | input list<Absyn.ElementArg> inArgs; | ||
| 529 | input Context inCon; | ||
| 530 | input list<Absyn.ElementArg> resultList; | ||
| 531 | input Absyn.Path classPath; | ||
| 532 | input Absyn.Path inPath; | ||
| 533 | input Absyn.Program inProgram; | ||
| 534 | input Interactive.GraphicEnvCache inClassEnv; | ||
| 535 | output list<Absyn.ElementArg> outArgs; | ||
| 536 | |||
| 537 | algorithm | ||
| 538 | |||
| 539 | outArgs := matchcontinue (inArgs,inCon,resultList,classPath,inPath,inProgram,inClassEnv) | ||
| 540 | |||
| 541 | local | ||
| 542 | Absyn.Program p; | ||
| 543 | Absyn.Path path,cPath; | ||
| 544 | Absyn.Exp x1,x2,y1,y2; | ||
| 545 | list<Absyn.ElementArg> rest,res,trans; | ||
| 546 | Absyn.ElementArg arg,iconTrans,diagramTrans; | ||
| 547 | Context context; | ||
| 548 | Boolean fi; | ||
| 549 | Absyn.Each e; | ||
| 550 | Option<String> com; | ||
| 551 | Option<Real> rot; | ||
| 552 | Interactive.GraphicEnvCache env; | ||
| 553 | SourceInfo info; | ||
| 554 | |||
| 555 | |||
| 556 | case({},_,res,_,_,_,_) then res ; | ||
| 557 | |||
| 558 | case(Absyn.MODIFICATION( | ||
| 559 | finalPrefix = fi, | ||
| 560 | eachPrefix = e, | ||
| 561 | path = | ||
| 562 | Absyn.IDENT(name = "extent"), | ||
| 563 | modification = | ||
| 564 | SOME(Absyn.CLASSMOD(eqMod = Absyn.EQMOD(exp=Absyn.MATRIX(matrix = {{x1,y1},{x2,y2}} )))), | ||
| 565 | comment = com, info = info) :: rest,context as ("Component" :: _),res,cPath,path,p,env) | ||
| 566 | algorithm | ||
| 567 | ✗ | Absyn.R_CONNECTOR() := getRestrictionFromPath(cPath,path,p,env)"Fails the case if we shouldn't have a iconTransformation"; | |
| 568 | ✗ | rot := getRotationDegree(listAppend(res,rest)); | |
| 569 | ✗ | iconTrans := getIconTransformation(x1,y1,x2,y2,rot,cPath,path,p,env); | |
| 570 | ✗ | diagramTrans := getDiagramTransformation(x1,y1,x2,y2,rot,cPath,path,p,env); | |
| 571 | trans := {diagramTrans,iconTrans}; | ||
| 572 | ✗ | res := transformComponentAnnList(rest,context,res,cPath,path,p,env); | |
| 573 | ✗ | res := {Absyn.MODIFICATION(fi, e, Absyn.IDENT("Placement"), SOME(Absyn.CLASSMOD(trans,Absyn.NOMOD())),/*NONE,*/com, info)};//:: res; //SOME(Absyn.ARRAY({Absyn.ARRAY({x1,y1} ),Absyn.ARRAY({x2,y2})})) | |
| 574 | then res; | ||
| 575 | |||
| 576 | case(Absyn.MODIFICATION(finalPrefix = fi, eachPrefix = e, path = Absyn.IDENT(name = "extent"), modification = SOME(Absyn.CLASSMOD(eqMod = Absyn.EQMOD(exp=Absyn.MATRIX(matrix = {{x1,y1},{x2,y2}} )))), comment = com, info = info) :: rest, | ||
| 577 | context as ("Component" :: _),res,cPath,path,p,env) | ||
| 578 | algorithm | ||
| 579 | ✗ | rot := getRotationDegree(listAppend(res,rest)); | |
| 580 | ✗ | diagramTrans := getDiagramTransformation(x1,y1,x2,y2,rot,cPath,path,p,env); | |
| 581 | ✗ | res := transformComponentAnnList(rest,context,res,cPath,path,p,env); | |
| 582 | ✗ | res := {Absyn.MODIFICATION(fi, e, Absyn.IDENT("Placement"), SOME(Absyn.CLASSMOD({diagramTrans},Absyn.NOMOD()))/*NONE*/,com, info)};//:: res; /*SOME(Absyn.ARRAY({Absyn.ARRAY({x1,y1} ),Absyn.ARRAY({x2,y2})}))*/ | |
| 583 | then res; | ||
| 584 | |||
| 585 | case(arg :: rest,context,res,cPath,path,p,env) | ||
| 586 | algorithm | ||
| 587 | res := arg :: res; | ||
| 588 | ✗ | res := transformComponentAnnList(rest,context,res,cPath,path,p,env); | |
| 589 | then res; | ||
| 590 | end matchcontinue; | ||
| 591 | |||
| 592 | end transformComponentAnnList; | ||
| 593 | |||
| 594 | protected function getRestrictionFromPath" | ||
| 595 | Helper function to transformComponentAnnList. This function takes a path and a program | ||
| 596 | as arguments and then returns the class restriction to that path. | ||
| 597 | " | ||
| 598 | input Absyn.Path classPath; | ||
| 599 | input Absyn.Path inPath; | ||
| 600 | input Absyn.Program inProgram; | ||
| 601 | input Interactive.GraphicEnvCache inClassEnv; | ||
| 602 | output Absyn.Restriction outRestriction; | ||
| 603 | algorithm | ||
| 604 | outRestriction := matchcontinue(classPath,inPath,inProgram, inClassEnv) | ||
| 605 | local | ||
| 606 | Absyn.Class cdef; | ||
| 607 | Absyn.Program p; | ||
| 608 | Absyn.Path fullPath,path,cPath; | ||
| 609 | Absyn.Restriction restriction; | ||
| 610 | Interactive.GraphicEnvCache env; | ||
| 611 | |||
| 612 | case(cPath,path,p, _) // try directly first | ||
| 613 | algorithm | ||
| 614 | ✗ | fullPath := fixPaths(cPath, path); | |
| 615 | // debug_print("getRestrictionFromPath: TryingLookingUp:", AbsynUtil.pathString(fullPath)); | ||
| 616 | ✗ | cdef := ProgramUtil.getPathedClassInProgram(fullPath,p); | |
| 617 | ✗ | restriction := getRestrictionInClass(cdef); | |
| 618 | then | ||
| 619 | restriction; | ||
| 620 | |||
| 621 | case(_,path,p, env) // if it fails try the hard way | ||
| 622 | algorithm | ||
| 623 | ✗ | (_,fullPath) := Interactive.mkFullyQual(env,path); | |
| 624 | // debug_print("getRestrictionFromPath: LookingUp:", AbsynUtil.pathString(fullPath)); | ||
| 625 | ✗ | cdef := ProgramUtil.getPathedClassInProgram(fullPath,p); | |
| 626 | ✗ | restriction := getRestrictionInClass(cdef); | |
| 627 | then | ||
| 628 | restriction; | ||
| 629 | |||
| 630 | else | ||
| 631 | algorithm | ||
| 632 | // debug_print("\ngetPathedClassInProgram:", "failed!"); | ||
| 633 | then fail(); | ||
| 634 | end matchcontinue; | ||
| 635 | end getRestrictionFromPath; | ||
| 636 | |||
| 637 | protected function getRestrictionInClass" | ||
| 638 | Helper function to getRestrictionInPath. This function takes a class as | ||
| 639 | argument and then returns the restriction to that class. | ||
| 640 | " | ||
| 641 | |||
| 642 | input Absyn.Class inClass; | ||
| 643 | output Absyn.Restriction outRestriction; | ||
| 644 | algorithm | ||
| 645 | outRestriction := match inClass | ||
| 646 | local | ||
| 647 | Absyn.Restriction restriction; | ||
| 648 | case Absyn.CLASS(restriction = restriction) then restriction; | ||
| 649 | end match; | ||
| 650 | end getRestrictionInClass; | ||
| 651 | |||
| 652 | protected function getRotationDegree" | ||
| 653 | Helper function to transformComponentAnnList. This function checks if there's a rotation | ||
| 654 | annotation in the ElementArg list and then returns the degree of rotation. | ||
| 655 | " | ||
| 656 | |||
| 657 | input list<Absyn.ElementArg> inList; | ||
| 658 | output Option<Real> degrees; | ||
| 659 | algorithm | ||
| 660 | degrees := matchcontinue inList | ||
| 661 | local | ||
| 662 | Real rot; | ||
| 663 | Absyn.Exp ex; | ||
| 664 | list<Absyn.ElementArg> rest; | ||
| 665 | Option<Real> res; | ||
| 666 | |||
| 667 | case {} then NONE(); | ||
| 668 | |||
| 669 | case Absyn.MODIFICATION(path = Absyn.IDENT(name = "rotation"), modification = SOME(Absyn.CLASSMOD(eqMod = Absyn.EQMOD(exp=ex)))) :: _ | ||
| 670 | algorithm | ||
| 671 | ✗ | rot := (getValueFromExp(ex)); | |
| 672 | ✗ | then | |
| 673 | SOME(rot); | ||
| 674 | |||
| 675 | case _ :: rest | ||
| 676 | algorithm | ||
| 677 | ✗ | res := getRotationDegree(rest); | |
| 678 | then | ||
| 679 | res; | ||
| 680 | end matchcontinue; | ||
| 681 | end getRotationDegree; | ||
| 682 | |||
| 683 | protected function getIconTransformation" | ||
| 684 | Helper function to transformComponentAnnList. This function calculates and returns the iconTransformation | ||
| 685 | annotation. | ||
| 686 | " | ||
| 687 | |||
| 688 | input Absyn.Exp ax1; | ||
| 689 | input Absyn.Exp ay1; | ||
| 690 | input Absyn.Exp ax2; | ||
| 691 | input Absyn.Exp ay2; | ||
| 692 | input Option<Real> inRotation; | ||
| 693 | input Absyn.Path classPath; | ||
| 694 | input Absyn.Path inPath; | ||
| 695 | input Absyn.Program inProg; | ||
| 696 | input Interactive.GraphicEnvCache inClassEnv; | ||
| 697 | output Absyn.ElementArg iconTrans; | ||
| 698 | |||
| 699 | algorithm | ||
| 700 | |||
| 701 | iconTrans := match(ax1,ay1,ax2,ay2,inRotation,classPath,inPath,inProg,inClassEnv) | ||
| 702 | |||
| 703 | local | ||
| 704 | |||
| 705 | Real rcx1,rcy1,rcx2,rcy2,rax1,ray1,rax2,ray2,rot; | ||
| 706 | Absyn.ElementArg scale,aspectRatio,x,y,flipHorizontal,flipVertical,rotation; | ||
| 707 | Absyn.Path path,cPath; | ||
| 708 | Absyn.Program p; | ||
| 709 | Absyn.Exp x1,x2,y1,y2; | ||
| 710 | Interactive.GraphicEnvCache env; | ||
| 711 | |||
| 712 | case(x1,y1,x2,y2,NONE(),cPath,path,p,env) | ||
| 713 | algorithm | ||
| 714 | ✗ | rax1 := getValueFromExp(x1); | |
| 715 | ✗ | ray1 := getValueFromExp(y1); | |
| 716 | ✗ | rax2 := getValueFromExp(x2); | |
| 717 | ✗ | ray2 := getValueFromExp(y2); | |
| 718 | |||
| 719 | ✗ | (x1,y1,x2,y2) := getCoordsInPath(cPath,path,p,{"Icon"}, env); | |
| 720 | ✗ | rcx1 := getValueFromExp(x1); | |
| 721 | ✗ | rcy1 := getValueFromExp(y1); | |
| 722 | ✗ | rcx2 := getValueFromExp(x2); | |
| 723 | ✗ | rcy2 := getValueFromExp(y2); | |
| 724 | |||
| 725 | ✗ | aspectRatio := getAspectRatioAnn(rax1,rax2,ray1,ray2,rcx1,rcy1,rcx2,rcy2); | |
| 726 | ✗ | x := getXYAnn(rax1,rax2,"x"); | |
| 727 | ✗ | y := getXYAnn(ray1,ray2,"y"); | |
| 728 | ✗ | scale := getScaleAnn(rax1,rax2,rcx1,rcx2); | |
| 729 | ✗ | flipHorizontal := getFlipAnn(rax1,rax2,"flipHorizontal"); | |
| 730 | ✗ | flipVertical := getFlipAnn(ray1,ray2,"flipVertical"); | |
| 731 | ✗ | then Absyn.MODIFICATION(false,Absyn.NON_EACH(),Absyn.IDENT("iconTransformation"),SOME(Absyn.CLASSMOD({x,y,scale,aspectRatio,flipHorizontal,flipVertical},Absyn.NOMOD())),NONE(),Absyn.dummyInfo); | |
| 732 | |||
| 733 | case(x1,y1,x2,y2,SOME(rot),cPath,path,p, env) | ||
| 734 | algorithm | ||
| 735 | ✗ | rax1 := getValueFromExp(x1); | |
| 736 | ✗ | ray1 := getValueFromExp(y1); | |
| 737 | ✗ | rax2 := getValueFromExp(x2); | |
| 738 | ✗ | ray2 := getValueFromExp(y2); | |
| 739 | ✗ | (x1,y1,x2,y2) := getCoordsInPath(cPath,path,p,{"Icon"}, env); | |
| 740 | ✗ | rcx1 := getValueFromExp(x1); | |
| 741 | ✗ | rcy1 := getValueFromExp(y1); | |
| 742 | ✗ | rcx2 := getValueFromExp(x2); | |
| 743 | ✗ | rcy2 := getValueFromExp(y2); | |
| 744 | ✗ | aspectRatio := getAspectRatioAnn(rax1,rax2,ray1,ray2,rcx1,rcy1,rcx2,rcy2); | |
| 745 | ✗ | x := getXYAnn(rax1,rax2,"x"); | |
| 746 | ✗ | y := getXYAnn(ray1,ray2,"y"); | |
| 747 | ✗ | scale := getScaleAnn(rax1,rax2,rcx1,rcx2); | |
| 748 | ✗ | flipHorizontal := getFlipAnn(rax1,rax2,"flipHorizontal"); | |
| 749 | ✗ | flipVertical := getFlipAnn(ray1,ray2,"flipVertical"); | |
| 750 | ✗ | rotation := getRotationAnn(rot); | |
| 751 | ✗ | then Absyn.MODIFICATION(false,Absyn.NON_EACH(),Absyn.IDENT("iconTransformation"),SOME(Absyn.CLASSMOD({x,y,scale,aspectRatio,flipHorizontal,flipVertical,rotation},Absyn.NOMOD())),NONE(),Absyn.dummyInfo); | |
| 752 | |||
| 753 | end match; | ||
| 754 | end getIconTransformation; | ||
| 755 | |||
| 756 | protected function getDiagramTransformation" | ||
| 757 | Helper function to transformComponentAnnList. This function calculates and returns the transformation | ||
| 758 | annotation. | ||
| 759 | " | ||
| 760 | |||
| 761 | input Absyn.Exp ax1; | ||
| 762 | input Absyn.Exp ay1; | ||
| 763 | input Absyn.Exp ax2; | ||
| 764 | input Absyn.Exp ay2; | ||
| 765 | input Option<Real> inRotation; | ||
| 766 | input Absyn.Path classPath; | ||
| 767 | input Absyn.Path inPath; | ||
| 768 | input Absyn.Program inProg; | ||
| 769 | input Interactive.GraphicEnvCache inClassEnv; | ||
| 770 | output Absyn.ElementArg trans; | ||
| 771 | |||
| 772 | algorithm | ||
| 773 | |||
| 774 | trans := match(ax1,ay1,ax2,ay2,inRotation,classPath,inPath,inProg, inClassEnv) | ||
| 775 | |||
| 776 | local | ||
| 777 | |||
| 778 | Real rcx1,rcy1,rcx2,rcy2,rax1,ray1,rax2,ray2,rot; | ||
| 779 | Absyn.ElementArg scale,aspectRatio,x,y,flipHorizontal,flipVertical,rotation; | ||
| 780 | Absyn.Path path,cPath; | ||
| 781 | Absyn.Program p; | ||
| 782 | Absyn.Exp x1,x2,y1,y2; | ||
| 783 | Interactive.GraphicEnvCache env; | ||
| 784 | |||
| 785 | case(x1,y1,x2,y2,NONE(),cPath,path,p, env) | ||
| 786 | |||
| 787 | algorithm | ||
| 788 | |||
| 789 | ✗ | rax1 := getValueFromExp(x1); | |
| 790 | ✗ | ray1 := getValueFromExp(y1); | |
| 791 | ✗ | rax2 := getValueFromExp(x2); | |
| 792 | ✗ | ray2 := getValueFromExp(y2); | |
| 793 | ✗ | (x1,y1,x2,y2) := getCoordsInPath(cPath,path,p,{"Diagram"}, env); | |
| 794 | ✗ | rcx1 := getValueFromExp(x1); | |
| 795 | ✗ | rcy1 := getValueFromExp(y1); | |
| 796 | ✗ | rcx2 := getValueFromExp(x2); | |
| 797 | ✗ | rcy2 := getValueFromExp(y2); | |
| 798 | |||
| 799 | // (x1,y1,x2,y2) = getCoordsInPath(cPath,path,p,{"Diagram"}, env); | ||
| 800 | ✗ | aspectRatio := getAspectRatioAnn(rax1,rax2,ray1,ray2,rcx1,rcy1,rcx2,rcy2); | |
| 801 | ✗ | x := getXYAnn(rax1,rax2,"x"); | |
| 802 | ✗ | y := getXYAnn(ray1,ray2,"y"); | |
| 803 | ✗ | scale := getScaleAnn(rax1,rax2,rcx1,rcx2); | |
| 804 | ✗ | flipHorizontal := getFlipAnn(rax1,rax2,"flipHorizontal"); | |
| 805 | ✗ | flipVertical := getFlipAnn(ray1,ray2,"flipVertical"); | |
| 806 | |||
| 807 | ✗ | then Absyn.MODIFICATION(false,Absyn.NON_EACH(),Absyn.IDENT("transformation"),SOME(Absyn.CLASSMOD({x,y,scale,aspectRatio,flipHorizontal,flipVertical},Absyn.NOMOD())),NONE(),Absyn.dummyInfo); | |
| 808 | |||
| 809 | case(x1,y1,x2,y2,SOME(rot),cPath,path,p, env) | ||
| 810 | |||
| 811 | algorithm | ||
| 812 | |||
| 813 | ✗ | rax1 := getValueFromExp(x1); | |
| 814 | ✗ | ray1 := getValueFromExp(y1); | |
| 815 | ✗ | rax2 := getValueFromExp(x2); | |
| 816 | ✗ | ray2 := getValueFromExp(y2); | |
| 817 | |||
| 818 | ✗ | (x1,y1,x2,y2) := getCoordsInPath(cPath,path,p,{"Diagram"}, env); | |
| 819 | ✗ | rcx1 := getValueFromExp(x1); | |
| 820 | ✗ | rcy1 := getValueFromExp(y1); | |
| 821 | ✗ | rcx2 := getValueFromExp(x2); | |
| 822 | ✗ | rcy2 := getValueFromExp(y2); | |
| 823 | ✗ | aspectRatio := getAspectRatioAnn(rax1,rax2,ray1,ray2,rcx1,rcy1,rcx2,rcy2); | |
| 824 | ✗ | x := getXYAnn(rax1,rax2,"x"); | |
| 825 | ✗ | y := getXYAnn(ray1,ray2,"y"); | |
| 826 | ✗ | scale := getScaleAnn(rax1,rax2,rcx1,rcx2); | |
| 827 | ✗ | flipHorizontal := getFlipAnn(rax1,rax2,"flipHorizontal"); | |
| 828 | ✗ | flipVertical := getFlipAnn(ray1,ray2,"flipVertical"); | |
| 829 | ✗ | rotation := getRotationAnn(rot); | |
| 830 | |||
| 831 | ✗ | then | |
| 832 | Absyn.MODIFICATION(false,Absyn.NON_EACH(),Absyn.IDENT("transformation"),SOME(Absyn.CLASSMOD({x,y,scale,aspectRatio,flipHorizontal,flipVertical,rotation},Absyn.NOMOD())),NONE(),Absyn.dummyInfo); | ||
| 833 | |||
| 834 | end match; | ||
| 835 | end getDiagramTransformation; | ||
| 836 | |||
| 837 | protected function getAspectRatioAnn" | ||
| 838 | Helper function to getIconTransformation and getDiagramTransformation. This function calculates and returns the aspect ratio | ||
| 839 | annotation. | ||
| 840 | " | ||
| 841 | input Real x1; | ||
| 842 | input Real x2; | ||
| 843 | input Real y1; | ||
| 844 | input Real y2; | ||
| 845 | input Real cx1; | ||
| 846 | input Real cy1; | ||
| 847 | input Real cx2; | ||
| 848 | input Real cy2; | ||
| 849 | output Absyn.ElementArg aspectRatio; | ||
| 850 | algorithm | ||
| 851 | aspectRatio := match (x1,x2,y1,y2,cx1,cy1,cx2,cy2) | ||
| 852 | local | ||
| 853 | Real aspect,crx1,cry1,crx2,cry2,rx1,rx2,ry1,ry2; | ||
| 854 | String s; | ||
| 855 | |||
| 856 | case(rx1,rx2,ry1,ry2,crx1,cry1,crx2,cry2) | ||
| 857 | algorithm | ||
| 858 | ✗ | aspect := (realAbs(ry2 - ry1) * (realAbs(cry2 - cry1))) / (realAbs(rx2 - rx1) * (realAbs(crx2 - crx1))); | |
| 859 | ✗ | s := realString(aspect); | |
| 860 | ✗ | then | |
| 861 | Absyn.MODIFICATION(false,Absyn.NON_EACH(),Absyn.IDENT("aspectRatio"),SOME(Absyn.CLASSMOD({},Absyn.EQMOD(Absyn.REAL(s),Absyn.dummyInfo))),NONE(),Absyn.dummyInfo); | ||
| 862 | |||
| 863 | end match; | ||
| 864 | end getAspectRatioAnn; | ||
| 865 | |||
| 866 | protected function getXYAnn " | ||
| 867 | Helper function to getIconTransformation and getDiagramTransformation. This function calculates and returns the X or Y | ||
| 868 | annotation. | ||
| 869 | " | ||
| 870 | input Real val1; | ||
| 871 | input Real val2; | ||
| 872 | input Absyn.Ident name; | ||
| 873 | output Absyn.ElementArg res; | ||
| 874 | algorithm | ||
| 875 | res := match(val1,val2,name) | ||
| 876 | local | ||
| 877 | Real x1,x2; | ||
| 878 | Real value; | ||
| 879 | Absyn.Ident n; | ||
| 880 | String s; | ||
| 881 | case(x1,x2,n) | ||
| 882 | algorithm | ||
| 883 | ✗ | value := (x1 + x2) / 2.0; | |
| 884 | ✗ | s := realString(value); | |
| 885 | ✗ | then | |
| 886 | Absyn.MODIFICATION(false,Absyn.NON_EACH(),Absyn.IDENT(n),SOME(Absyn.CLASSMOD({},Absyn.EQMOD(Absyn.REAL(s),Absyn.dummyInfo))),NONE(),Absyn.dummyInfo); | ||
| 887 | end match; | ||
| 888 | end getXYAnn; | ||
| 889 | |||
| 890 | protected function getScaleAnn " | ||
| 891 | Helper function to getIconTransformation and getDiagramTransformation. This function calculates and returns the scale | ||
| 892 | annotation. | ||
| 893 | " | ||
| 894 | input Real ax1; | ||
| 895 | input Real ax2; | ||
| 896 | input Real cx1; | ||
| 897 | input Real cx2; | ||
| 898 | output Absyn.ElementArg scale; | ||
| 899 | algorithm | ||
| 900 | scale := match(ax1,ax2,cx1,cx2) | ||
| 901 | local | ||
| 902 | Real arx1,arx2,crx1,crx2,scaleFac; | ||
| 903 | String s; | ||
| 904 | case(arx1,arx2,crx1,crx2) | ||
| 905 | algorithm | ||
| 906 | ✗ | scaleFac := (realAbs(arx1 - arx2)) / (realAbs(crx1 - crx2)); | |
| 907 | ✗ | s := realString(scaleFac); | |
| 908 | ✗ | then | |
| 909 | Absyn.MODIFICATION(false,Absyn.NON_EACH(),Absyn.IDENT("scale"),SOME(Absyn.CLASSMOD({},Absyn.EQMOD(Absyn.REAL(s),Absyn.dummyInfo))),NONE(),Absyn.dummyInfo); | ||
| 910 | |||
| 911 | end match; | ||
| 912 | end getScaleAnn; | ||
| 913 | |||
| 914 | protected function getFlipAnn" | ||
| 915 | Helper function to getIconTransformation and getDiagramTransformation. This function calculates and returns the flip | ||
| 916 | annotations. | ||
| 917 | " | ||
| 918 | |||
| 919 | input Real val1; | ||
| 920 | input Real val2; | ||
| 921 | input Absyn.Ident name; | ||
| 922 | output Absyn.ElementArg flip; | ||
| 923 | protected | ||
| 924 | Boolean value; | ||
| 925 | |||
| 926 | algorithm | ||
| 927 | |||
| 928 | value := val1 > val2; | ||
| 929 | ✗ | flip := Absyn.MODIFICATION(false,Absyn.NON_EACH(),Absyn.IDENT(name),SOME(Absyn.CLASSMOD({},Absyn.EQMOD(Absyn.BOOL(value),Absyn.dummyInfo))),NONE(),Absyn.dummyInfo); | |
| 930 | |||
| 931 | end getFlipAnn; | ||
| 932 | |||
| 933 | protected function getRotationAnn"Helper function to getIconTransformation and getDiagramTransformation. | ||
| 934 | This function calculates and returns the rotation annotation." | ||
| 935 | input Real rot; | ||
| 936 | output Absyn.ElementArg rotation; | ||
| 937 | protected | ||
| 938 | Real r; | ||
| 939 | String s; | ||
| 940 | algorithm | ||
| 941 | ✗ | r := rot * (-1.0); | |
| 942 | ✗ | s := realString(r); | |
| 943 | ✗ | rotation := Absyn.MODIFICATION(false,Absyn.NON_EACH(),Absyn.IDENT("rotation"),SOME(Absyn.CLASSMOD({},Absyn.EQMOD(Absyn.REAL(s),Absyn.dummyInfo))),NONE(),Absyn.dummyInfo); | |
| 944 | end getRotationAnn; | ||
| 945 | |||
| 946 | |||
| 947 | protected function getCoordsInPath"Helper function to transformComponentAnnList. This function takes a path and a program | ||
| 948 | as arguments and then returns the diagram or icon coordinates in that path. | ||
| 949 | " | ||
| 950 | input Absyn.Path classPath; | ||
| 951 | input Absyn.Path inPath; | ||
| 952 | input Absyn.Program inProgram; | ||
| 953 | input Context contextToGetCoordsFrom; | ||
| 954 | input Interactive.GraphicEnvCache inClassEnv; | ||
| 955 | output Absyn.Exp posX1; | ||
| 956 | output Absyn.Exp posY1; | ||
| 957 | output Absyn.Exp posX2; | ||
| 958 | output Absyn.Exp posY2; | ||
| 959 | |||
| 960 | algorithm | ||
| 961 | |||
| 962 | (posX1,posY1,posX2,posY2) := matchcontinue (classPath,inPath,inProgram,contextToGetCoordsFrom, inClassEnv) | ||
| 963 | |||
| 964 | local | ||
| 965 | Absyn.Class cdef; | ||
| 966 | Absyn.Exp x1,y1,x2,y2; | ||
| 967 | Absyn.Path path,fullPath,cPath; | ||
| 968 | Absyn.Program p; | ||
| 969 | Context context; | ||
| 970 | |||
| 971 | |||
| 972 | Interactive.GraphicEnvCache env; | ||
| 973 | |||
| 974 | case(cPath,path,p,context, _) // try directly first | ||
| 975 | algorithm | ||
| 976 | ✗ | fullPath := fixPaths(cPath, path); | |
| 977 | // debug_print("getCoordsInPath: TryingLookingUp:", AbsynUtil.pathString(fullPath)); | ||
| 978 | ✗ | cdef := ProgramUtil.getPathedClassInProgram(fullPath,p); | |
| 979 | ✗ | (x1,y1,x2,y2) := getCoordsInClass(cdef,context); | |
| 980 | then | ||
| 981 | (x1,y1,x2,y2); | ||
| 982 | |||
| 983 | case(_,path,p,context, env) // if it doesn't work, try the hard way | ||
| 984 | algorithm | ||
| 985 | // p_1 = AbsynToSCode.translateAbsyn2SCode(p); | ||
| 986 | // (_,env) = Inst.makeEnvFromProgram(FCore.emptyCache,p_1, Absyn.IDENT("")); | ||
| 987 | ✗ | (_, fullPath) := Interactive.mkFullyQual(env, path); | |
| 988 | // print("env:\n");print(FGraph.printGraphStr(env)); | ||
| 989 | //str = AbsynUtil.pathString(cPath); | ||
| 990 | //print("\npath = "); | ||
| 991 | //print(str); | ||
| 992 | // debug_print("getCoordsInPath: LookingUp:", AbsynUtil.pathString(fullPath)); | ||
| 993 | ✗ | cdef := ProgramUtil.getPathedClassInProgram(fullPath,p); | |
| 994 | ✗ | (x1,y1,x2,y2) := getCoordsInClass(cdef,context); | |
| 995 | then | ||
| 996 | (x1,y1,x2,y2);//(Absyn.REAL(-100.0),Absyn.REAL(-100.0),Absyn.REAL(100.0),Absyn.REAL(100.0)); | ||
| 997 | |||
| 998 | else // if it doesn't work, try the hard way | ||
| 999 | algorithm | ||
| 1000 | // debug_print("\ngetPathedClassInProgram:", "failed!"); | ||
| 1001 | then fail(); | ||
| 1002 | |||
| 1003 | end matchcontinue; | ||
| 1004 | |||
| 1005 | end getCoordsInPath; | ||
| 1006 | |||
| 1007 | protected function getCoordsInClass " | ||
| 1008 | Helper function to getCoordsInPath. This function takes a class and a program | ||
| 1009 | as arguments and then returns the diagram or icon coordinates in that class. | ||
| 1010 | " | ||
| 1011 | input Absyn.Class inClass; | ||
| 1012 | input Context contextToGetCoordsFrom; | ||
| 1013 | output Absyn.Exp x1; | ||
| 1014 | output Absyn.Exp y1; | ||
| 1015 | output Absyn.Exp x2; | ||
| 1016 | output Absyn.Exp y2; | ||
| 1017 | algorithm | ||
| 1018 | (x1,y1,x2,y2) := match (inClass,contextToGetCoordsFrom) | ||
| 1019 | local | ||
| 1020 | list<Absyn.Annotation> ann; | ||
| 1021 | list<Absyn.ElementArg> annlst; | ||
| 1022 | Context context; | ||
| 1023 | |||
| 1024 | case(Absyn.CLASS(body = Absyn.PARTS(ann = ann)),context) | ||
| 1025 | algorithm | ||
| 1026 | ✗ | annlst := List.flatten(List.map(ann,AbsynUtil.annotationToElementArgs)); | |
| 1027 | ✗ | (x1,y1,x2,y2) := getCoordsInAnnList(annlst,context); | |
| 1028 | then | ||
| 1029 | (x1,y1,x2,y2); | ||
| 1030 | |||
| 1031 | case(Absyn.CLASS(body = Absyn.DERIVED(comment = SOME(Absyn.COMMENT(annotation_ = SOME(Absyn.ANNOTATION(elementArgs = annlst)))))),context) | ||
| 1032 | algorithm | ||
| 1033 | ✗ | (x1,y1,x2,y2) := getCoordsInAnnList(annlst,context); | |
| 1034 | then | ||
| 1035 | (x1,y1,x2,y2); | ||
| 1036 | |||
| 1037 | end match; | ||
| 1038 | end getCoordsInClass; | ||
| 1039 | |||
| 1040 | protected function getCoordsInAnnList" | ||
| 1041 | Helper function to getCoordsFromEqns,elts,algs. | ||
| 1042 | " | ||
| 1043 | input list<Absyn.ElementArg> inAnns; | ||
| 1044 | input Context contextToGetCoordsFrom; | ||
| 1045 | output Absyn.Exp x1; | ||
| 1046 | output Absyn.Exp y1; | ||
| 1047 | output Absyn.Exp x2; | ||
| 1048 | output Absyn.Exp y2; | ||
| 1049 | algorithm | ||
| 1050 | (x1,y1,x2,y2) := matchcontinue(inAnns,contextToGetCoordsFrom) | ||
| 1051 | local | ||
| 1052 | list<Absyn.ElementArg> rest,args; | ||
| 1053 | Context context; | ||
| 1054 | |||
| 1055 | ✗ | case({},_) then (Absyn.REAL("-100.0"),Absyn.REAL("-100.0"),Absyn.REAL("100.0"),Absyn.REAL("100.0"))/*If coordsys is not explicit defined, old implicit standard is [-100,-100;100,100]*/; | |
| 1056 | case(Absyn.MODIFICATION(path = Absyn.IDENT(name = "Coordsys"), modification = SOME(Absyn.CLASSMOD(elementArgLst = args)))::_,_) | ||
| 1057 | algorithm | ||
| 1058 | ✗ | (x1,y1,x2,y2) := getCoordsFromCoordSysArgs(args); | |
| 1059 | then | ||
| 1060 | (x1,y1,x2,y2); | ||
| 1061 | |||
| 1062 | case(Absyn.MODIFICATION(path = Absyn.IDENT(name = "Icon"), modification = SOME(Absyn.CLASSMOD(elementArgLst = args)))::_,"Icon" :: _) | ||
| 1063 | algorithm | ||
| 1064 | ✗ | (x1,y1,x2,y2) := getCoordsFromLayerArgs(args); | |
| 1065 | then | ||
| 1066 | (x1,y1,x2,y2); | ||
| 1067 | |||
| 1068 | case(Absyn.MODIFICATION(path = Absyn.IDENT(name = "Diagram"), modification = SOME(Absyn.CLASSMOD(elementArgLst = args)))::_,"Diagram" :: _) | ||
| 1069 | algorithm | ||
| 1070 | ✗ | (x1,y1,x2,y2) := getCoordsFromLayerArgs(args); | |
| 1071 | then | ||
| 1072 | (x1,y1,x2,y2); | ||
| 1073 | |||
| 1074 | case(_ :: rest,context) | ||
| 1075 | algorithm | ||
| 1076 | ✗ | (x1,y1,x2,y2) := getCoordsInAnnList(rest,context); | |
| 1077 | then | ||
| 1078 | (x1,y1,x2,y2); | ||
| 1079 | end matchcontinue; | ||
| 1080 | end getCoordsInAnnList; | ||
| 1081 | |||
| 1082 | protected function getCoordsFromCoordSysArgs" | ||
| 1083 | Helper function to getCoordsInAnnList. | ||
| 1084 | " | ||
| 1085 | input list<Absyn.ElementArg> inAnns; | ||
| 1086 | output Absyn.Exp x1; | ||
| 1087 | output Absyn.Exp y1; | ||
| 1088 | output Absyn.Exp x2; | ||
| 1089 | output Absyn.Exp y2; | ||
| 1090 | algorithm | ||
| 1091 | (x1,y1,x2,y2) := match inAnns | ||
| 1092 | local | ||
| 1093 | list<Absyn.ElementArg> rest; | ||
| 1094 | |||
| 1095 | case Absyn.MODIFICATION(path = Absyn.IDENT(name = "extent"), modification = SOME(Absyn.CLASSMOD(eqMod = Absyn.EQMOD(exp=Absyn.MATRIX(matrix = {{x1,y1},{x2,y2}} ))))) :: _ | ||
| 1096 | then | ||
| 1097 | (x1,y1,x2,y2); | ||
| 1098 | |||
| 1099 | case _ :: rest | ||
| 1100 | algorithm | ||
| 1101 | ✗ | (x1,y1,x2,y2) := getCoordsFromCoordSysArgs(rest); | |
| 1102 | then | ||
| 1103 | (x1,y1,x2,y2); | ||
| 1104 | |||
| 1105 | end match; | ||
| 1106 | end getCoordsFromCoordSysArgs; | ||
| 1107 | |||
| 1108 | protected function getExtentModification | ||
| 1109 | input list<Absyn.ElementArg> elementArgLst; | ||
| 1110 | output Absyn.Exp x1; | ||
| 1111 | output Absyn.Exp y1; | ||
| 1112 | output Absyn.Exp x2; | ||
| 1113 | output Absyn.Exp y2; | ||
| 1114 | algorithm | ||
| 1115 | (x1,y1,x2,y2) := match elementArgLst | ||
| 1116 | local list<Absyn.ElementArg> rest; | ||
| 1117 | case Absyn.MODIFICATION( | ||
| 1118 | path = Absyn.IDENT(name = "extent"), | ||
| 1119 | modification = SOME(Absyn.CLASSMOD(eqMod = Absyn.EQMOD(exp=Absyn.ARRAY({Absyn.ARRAY({x1,y1} ),Absyn.ARRAY({x2,y2})}))) )):: _ | ||
| 1120 | algorithm | ||
| 1121 | then (x1,y1,x2,y2); | ||
| 1122 | |||
| 1123 | case _:: rest | ||
| 1124 | algorithm | ||
| 1125 | ✗ | (x1,y1,x2,y2) := getExtentModification(rest); | |
| 1126 | then (x1,y1,x2,y2); | ||
| 1127 | end match; | ||
| 1128 | end getExtentModification; | ||
| 1129 | |||
| 1130 | protected function getCoordsFromLayerArgs | ||
| 1131 | "Helper function to getCoordsInAnnList." | ||
| 1132 | input list<Absyn.ElementArg> inAnns; | ||
| 1133 | output Absyn.Exp x1; | ||
| 1134 | output Absyn.Exp y1; | ||
| 1135 | output Absyn.Exp x2; | ||
| 1136 | output Absyn.Exp y2; | ||
| 1137 | algorithm | ||
| 1138 | (x1,y1,x2,y2) := matchcontinue inAnns | ||
| 1139 | local | ||
| 1140 | list<Absyn.ElementArg> rest,args; | ||
| 1141 | |||
| 1142 | case Absyn.MODIFICATION(path = Absyn.IDENT(name = "coordinateSystem"), modification = SOME(Absyn.CLASSMOD(elementArgLst = args)))::_ | ||
| 1143 | algorithm | ||
| 1144 | ✗ | (x1,y1,x2,y2) := getExtentModification(args); | |
| 1145 | then | ||
| 1146 | (x1,y1,x2,y2); | ||
| 1147 | |||
| 1148 | case _ :: rest | ||
| 1149 | algorithm | ||
| 1150 | ✗ | (x1,y1,x2,y2) := getCoordsFromLayerArgs(rest); | |
| 1151 | then | ||
| 1152 | (x1,y1,x2,y2); | ||
| 1153 | |||
| 1154 | end matchcontinue; | ||
| 1155 | end getCoordsFromLayerArgs; | ||
| 1156 | |||
| 1157 | protected function transformConnectAnnList " | ||
| 1158 | This function transforms old connect annotations to new ones | ||
| 1159 | " | ||
| 1160 | |||
| 1161 | input list<Absyn.ElementArg> inArgs; | ||
| 1162 | input Context inCon; | ||
| 1163 | input list<Absyn.ElementArg> resultList; | ||
| 1164 | input Absyn.Program inProgram; | ||
| 1165 | |||
| 1166 | output list<Absyn.ElementArg> outArgs; | ||
| 1167 | |||
| 1168 | algorithm | ||
| 1169 | |||
| 1170 | outArgs := matchcontinue (inArgs,inCon,resultList,inProgram) | ||
| 1171 | |||
| 1172 | local | ||
| 1173 | Absyn.Program p; | ||
| 1174 | list<list<Absyn.Exp>> expMatrix; | ||
| 1175 | list<Absyn.Exp> expLst; | ||
| 1176 | Integer x,color1,color2,color3; | ||
| 1177 | String val,val1,val2,s; | ||
| 1178 | list<String> arrows; | ||
| 1179 | Real thick; | ||
| 1180 | list<Absyn.ElementArg> args,rest,res; | ||
| 1181 | Absyn.ElementArg arg; | ||
| 1182 | Context context; | ||
| 1183 | Boolean fi; | ||
| 1184 | Absyn.Each e; | ||
| 1185 | Option<String> com; | ||
| 1186 | Absyn.EqMod eqMod; | ||
| 1187 | SourceInfo info, mod_info; | ||
| 1188 | |||
| 1189 | case({},_,res,_) then res ; | ||
| 1190 | |||
| 1191 | case(Absyn.MODIFICATION(finalPrefix = fi, eachPrefix = e, path = Absyn.IDENT(name = "points"), modification = SOME(Absyn.CLASSMOD( eqMod = Absyn.EQMOD(Absyn.MATRIX(matrix = expMatrix),info) )), comment = com, info = mod_info) :: rest,context as ("Connect" :: _),res,p) | ||
| 1192 | algorithm | ||
| 1193 | ✗ | context := addContext(context,"Line"); | |
| 1194 | ✗ | expLst := List.map(expMatrix,matrixToArray); | |
| 1195 | ✗ | res := transformConnectAnnList(rest,context,res,p); | |
| 1196 | ✗ | then {Absyn.MODIFICATION(fi,e,Absyn.IDENT("Line"), SOME(Absyn.CLASSMOD(Absyn.MODIFICATION(false,Absyn.NON_EACH(),Absyn.IDENT("points"),SOME(Absyn.CLASSMOD({},Absyn.EQMOD(Absyn.ARRAY(expLst),info))),NONE(),mod_info) :: res,Absyn.NOMOD())),com,mod_info)};//res; | |
| 1197 | |||
| 1198 | case(Absyn.MODIFICATION(finalPrefix = fi, eachPrefix = e, path = Absyn.IDENT(name = "points"), modification = SOME(Absyn.CLASSMOD( eqMod = Absyn.EQMOD(Absyn.MATRIX(matrix = expMatrix),info) )), comment = com, info = mod_info) :: rest,context as ("Line" :: _),res,p) | ||
| 1199 | algorithm | ||
| 1200 | ✗ | expLst := List.map(expMatrix,matrixToArray); | |
| 1201 | ✗ | res := transformConnectAnnList(rest,context,res,p); | |
| 1202 | ✗ | then Absyn.MODIFICATION(fi,e,Absyn.IDENT("points"),SOME(Absyn.CLASSMOD({},Absyn.EQMOD(Absyn.ARRAY(expLst),info))),com,mod_info) :: res; //res; | |
| 1203 | |||
| 1204 | case(Absyn.MODIFICATION(finalPrefix = fi, eachPrefix = e, path = Absyn.IDENT(name = "style"), modification = SOME(Absyn.CLASSMOD( elementArgLst = args , eqMod = eqMod)), comment = com, info = mod_info) :: rest,context as ("Connect" :: _),res,p) | ||
| 1205 | algorithm | ||
| 1206 | ✗ | context := addContext(context,"Line"); | |
| 1207 | ✗ | args := cleanStyleAttrs(args,{},context); | |
| 1208 | ✗ | rest := listAppend(args,rest); | |
| 1209 | ✗ | res := transformConnectAnnList(rest,context,res,p); | |
| 1210 | ✗ | then {Absyn.MODIFICATION(fi,e,Absyn.IDENT("Line"),SOME(Absyn.CLASSMOD(res,eqMod)),com,mod_info)}; | |
| 1211 | |||
| 1212 | case(Absyn.MODIFICATION(path = Absyn.IDENT(name = "style"), modification = SOME(Absyn.CLASSMOD( elementArgLst = args))) :: rest,context as ("Line" :: _),res,p) | ||
| 1213 | algorithm | ||
| 1214 | ✗ | args := cleanStyleAttrs(args,{},context); | |
| 1215 | ✗ | rest := listAppend(args,rest); | |
| 1216 | ✗ | res := transformConnectAnnList(rest,context,res,p); | |
| 1217 | then res; | ||
| 1218 | |||
| 1219 | |||
| 1220 | case(Absyn.MODIFICATION(finalPrefix = fi, eachPrefix = e, path = Absyn.IDENT(name = "color"), modification = SOME(Absyn.CLASSMOD( elementArgLst = args ,eqMod = Absyn.EQMOD(Absyn.INTEGER(value = x),info))), comment = com, info = mod_info) :: rest,context as ("Line" :: _),res,p) | ||
| 1221 | algorithm | ||
| 1222 | ✗ | (color1,color2,color3) := getMappedColor(x); | |
| 1223 | ✗ | res := transformConnectAnnList(rest,context,res,p); | |
| 1224 | ✗ | then Absyn.MODIFICATION(fi,e,Absyn.IDENT("color"), SOME(Absyn.CLASSMOD(args,Absyn.EQMOD(Absyn.ARRAY({Absyn.INTEGER(color1),Absyn.INTEGER(color2),Absyn.INTEGER(color3)}),info))),com,mod_info):: res; | |
| 1225 | |||
| 1226 | case(Absyn.MODIFICATION(finalPrefix = fi, eachPrefix = e, path = Absyn.IDENT(name = "pattern"), modification = SOME(Absyn.CLASSMOD( elementArgLst = args ,eqMod = Absyn.EQMOD(exp=Absyn.INTEGER(value = x)))), comment = com, info = mod_info) :: rest,context as ("Line" :: _),res,p) | ||
| 1227 | algorithm | ||
| 1228 | ✗ | val := listGet(patternMapList,x+1); | |
| 1229 | ✗ | res := transformConnectAnnList(rest,context,res,p); | |
| 1230 | ✗ | then Absyn.MODIFICATION(fi,e,Absyn.IDENT("pattern"), SOME(Absyn.CLASSMOD(args,Absyn.EQMOD(Absyn.CREF(Absyn.CREF_QUAL("LinePattern", {},Absyn.CREF_IDENT(val, {}))),Absyn.dummyInfo))),com, mod_info):: res; | |
| 1231 | |||
| 1232 | case(Absyn.MODIFICATION(finalPrefix = fi, eachPrefix = e, path = Absyn.IDENT(name = "thickness"), modification = SOME(Absyn.CLASSMOD( elementArgLst = args ,eqMod = Absyn.EQMOD(exp=Absyn.INTEGER(value = x)))), comment = com, info = mod_info) :: rest,context as ("Line" :: _),res,p) | ||
| 1233 | algorithm | ||
| 1234 | ✗ | thick := listGet(thicknessMapList,x); | |
| 1235 | ✗ | res := transformConnectAnnList(rest,context,res,p); | |
| 1236 | ✗ | s := realString(thick); | |
| 1237 | ✗ | then Absyn.MODIFICATION(fi,e,Absyn.IDENT("thickness"), SOME(Absyn.CLASSMOD(args,Absyn.EQMOD(Absyn.REAL(s),Absyn.dummyInfo))),com,mod_info):: res; | |
| 1238 | |||
| 1239 | case(Absyn.MODIFICATION(finalPrefix = fi, eachPrefix = e, path = Absyn.IDENT(name = "smooth"), modification = SOME(Absyn.CLASSMOD( elementArgLst = args , eqMod = eqMod)), comment = com, info = mod_info) :: rest,context as ("Line" :: _),res,p) | ||
| 1240 | algorithm | ||
| 1241 | ✗ | res := transformConnectAnnList(rest,context,res,p); then Absyn.MODIFICATION(fi,e,Absyn.IDENT("smooth"), SOME(Absyn.CLASSMOD(args,eqMod)),com, mod_info):: res; | |
| 1242 | |||
| 1243 | case(Absyn.MODIFICATION(finalPrefix = fi, eachPrefix = e, path = Absyn.IDENT(name = "arrow"), modification = SOME(Absyn.CLASSMOD( elementArgLst = args ,eqMod = Absyn.EQMOD(exp=Absyn.INTEGER(value = x)))), comment = com, info = mod_info) :: rest,context as ("Line" :: _),res,p) | ||
| 1244 | algorithm | ||
| 1245 | ✗ | arrows := listGet(arrowMapList,x+1); | |
| 1246 | ✗ | val1 := listGet(arrows,1); | |
| 1247 | ✗ | val2 := listGet(arrows,2); | |
| 1248 | ✗ | res := transformConnectAnnList(rest,context,res,p); | |
| 1249 | ✗ | then Absyn.MODIFICATION(fi,e,Absyn.IDENT("arrow"), SOME(Absyn.CLASSMOD(args,Absyn.EQMOD(Absyn.ARRAY({Absyn.CREF(Absyn.CREF_QUAL("Arrow", {},Absyn.CREF_IDENT(val1, {}))),Absyn.CREF(Absyn.CREF_QUAL("Arrow",{},Absyn.CREF_IDENT(val2,{})))}),Absyn.dummyInfo))),com, mod_info):: res; | |
| 1250 | |||
| 1251 | case(arg :: rest,context,res,p) | ||
| 1252 | algorithm | ||
| 1253 | ✗ | res := transformConnectAnnList(rest,context,res,p); | |
| 1254 | then arg :: res; | ||
| 1255 | |||
| 1256 | end matchcontinue; | ||
| 1257 | end transformConnectAnnList; | ||
| 1258 | |||
| 1259 | protected function transformClassAnnList " | ||
| 1260 | This function transforms old graphical class annotations (i.e Icon/Diagram layers) | ||
| 1261 | to new ones. | ||
| 1262 | " | ||
| 1263 | |||
| 1264 | input list<Absyn.ElementArg> inArgs; | ||
| 1265 | input Context inCon; | ||
| 1266 | input list<Absyn.ElementArg> resultList; | ||
| 1267 | input Absyn.Program inProgram; | ||
| 1268 | |||
| 1269 | output list<Absyn.ElementArg> outArgs; | ||
| 1270 | |||
| 1271 | algorithm | ||
| 1272 | |||
| 1273 | outArgs := matchcontinue (inArgs,inCon,resultList,inProgram) | ||
| 1274 | |||
| 1275 | local | ||
| 1276 | |||
| 1277 | Absyn.Program p; | ||
| 1278 | Absyn.Exp x1,x2,y1,y2; | ||
| 1279 | list<Absyn.ElementArg> args,rest,res; | ||
| 1280 | list<Absyn.Exp> argRes; | ||
| 1281 | Absyn.ElementArg coord,arg; | ||
| 1282 | Context context, c; | ||
| 1283 | Boolean fi; | ||
| 1284 | Absyn.Each e; | ||
| 1285 | Option<String> com; | ||
| 1286 | Absyn.EqMod eqMod; | ||
| 1287 | SourceInfo info, mod_info; | ||
| 1288 | |||
| 1289 | case({},_,res,_) then res ; | ||
| 1290 | |||
| 1291 | case(Absyn.MODIFICATION(finalPrefix = fi, eachPrefix = e, path = Absyn.IDENT(name = "Icon"), modification = SOME(Absyn.CLASSMOD(elementArgLst = args, eqMod = eqMod)), comment = com, info = mod_info) :: rest,context as ("Class" :: c),res,p) | ||
| 1292 | algorithm | ||
| 1293 | ✗ | c := addContext(context,"Layer"); | |
| 1294 | ✗ | argRes := transAnnLstToCalls(args,c); | |
| 1295 | ✗ | coord := getCoordSysAnn(listAppend(res,rest),p); | |
| 1296 | ✗ | res := transformClassAnnList(rest,context,res,p); | |
| 1297 | ✗ | then Absyn.MODIFICATION(fi, e, Absyn.IDENT("Icon"), SOME(Absyn.CLASSMOD({coord,Absyn.MODIFICATION(false, Absyn.NON_EACH(), Absyn.IDENT("graphics"),SOME(Absyn.CLASSMOD({}, Absyn.EQMOD(Absyn.ARRAY(argRes),Absyn.dummyInfo) )),NONE(),mod_info)}, eqMod)),com,mod_info) :: res ; | |
| 1298 | |||
| 1299 | case(Absyn.MODIFICATION(finalPrefix = fi, eachPrefix = e, path = Absyn.IDENT(name = "Diagram"), modification = SOME(Absyn.CLASSMOD(elementArgLst = args, eqMod = eqMod)), comment = com, info = mod_info) :: rest,context as ("Class" :: c),res,p) | ||
| 1300 | algorithm | ||
| 1301 | ✗ | c := addContext(context,"Layer"); | |
| 1302 | ✗ | argRes := transAnnLstToCalls(args,c); | |
| 1303 | ✗ | coord := getCoordSysAnn(listAppend(res,rest),p); | |
| 1304 | ✗ | res := transformClassAnnList(rest,context,res,p); | |
| 1305 | ✗ | then Absyn.MODIFICATION(fi, e, Absyn.IDENT("Diagram"), SOME(Absyn.CLASSMOD({coord,Absyn.MODIFICATION(false, Absyn.NON_EACH(), Absyn.IDENT("graphics"),SOME(Absyn.CLASSMOD({}, Absyn.EQMOD(Absyn.ARRAY(argRes),Absyn.dummyInfo) )),NONE(),mod_info)}, eqMod)),com,mod_info) :: res; | |
| 1306 | |||
| 1307 | case(Absyn.MODIFICATION(finalPrefix = fi, eachPrefix = e, path = Absyn.IDENT(name = "Coordsys"), modification = SOME(Absyn.CLASSMOD(elementArgLst = args, eqMod = eqMod)), comment = com, info = mod_info) :: rest,context,res,p) | ||
| 1308 | algorithm | ||
| 1309 | ✗ | true := isLayerAnnInList(listAppend(res,rest))/*Fails the case if we have a coordsys without a layer definition*/; | |
| 1310 | ✗ | res := Absyn.MODIFICATION(fi, e, Absyn.IDENT("Coordsys"), SOME(Absyn.CLASSMOD(args, eqMod)),com,mod_info) :: res; | |
| 1311 | ✗ | res := transformClassAnnList(rest,context,res,p); | |
| 1312 | ✗ | res := List.deleteMemberOnTrue(Absyn.MODIFICATION(fi, e, Absyn.IDENT("Coordsys"), SOME(Absyn.CLASSMOD(args, eqMod)),com,mod_info), res, valueEq); | |
| 1313 | then res; | ||
| 1314 | |||
| 1315 | case(Absyn.MODIFICATION(finalPrefix = fi, eachPrefix = e, path = Absyn.IDENT(name = "Coordsys"), modification = SOME(Absyn.CLASSMOD(elementArgLst = args, eqMod = eqMod)), comment = com, info = mod_info) :: rest,context,res,p) | ||
| 1316 | algorithm | ||
| 1317 | ✗ | res := Absyn.MODIFICATION(fi, e, Absyn.IDENT("Coordsys"), SOME(Absyn.CLASSMOD(args, eqMod)),com,mod_info) :: res; | |
| 1318 | ✗ | coord := getCoordSysAnn(listAppend(res,rest),p); | |
| 1319 | ✗ | res := Absyn.MODIFICATION(false, Absyn.NON_EACH(), Absyn.IDENT("Diagram"), SOME(Absyn.CLASSMOD({coord},Absyn.NOMOD())),NONE(),mod_info) | |
| 1320 | :: Absyn.MODIFICATION(false, Absyn.NON_EACH(), Absyn.IDENT("Icon"), SOME(Absyn.CLASSMOD({coord},Absyn.NOMOD())),NONE(),mod_info) :: res; | ||
| 1321 | ✗ | res := transformClassAnnList(rest,context,res,p); | |
| 1322 | ✗ | res := List.deleteMemberOnTrue(Absyn.MODIFICATION(fi, e, Absyn.IDENT("Coordsys"), SOME(Absyn.CLASSMOD(args, eqMod)),com,mod_info), res, valueEq); | |
| 1323 | then res; | ||
| 1324 | |||
| 1325 | case(Absyn.MODIFICATION(finalPrefix = fi, eachPrefix = e, path = Absyn.IDENT(name = "extent"), modification = SOME(Absyn.CLASSMOD(elementArgLst = args, eqMod = Absyn.EQMOD(Absyn.MATRIX(matrix = {{x1,y1},{x2,y2}} ),info))), comment = com, info = mod_info) :: rest,context as ("Coordsys" :: _),res,p) | ||
| 1326 | algorithm | ||
| 1327 | ✗ | res := Absyn.MODIFICATION(fi, e, Absyn.IDENT("extent"), SOME(Absyn.CLASSMOD(args, Absyn.EQMOD(Absyn.ARRAY({Absyn.ARRAY({x1,y1}),Absyn.ARRAY({x2,y2})}),info))),com,mod_info) :: res; | |
| 1328 | ✗ | res := transformClassAnnList(rest,context,res,p); | |
| 1329 | then res; | ||
| 1330 | |||
| 1331 | case(Absyn.MODIFICATION(path = Absyn.IDENT(name = "grid")) :: rest,context ,res,p) | ||
| 1332 | algorithm | ||
| 1333 | ✗ | res := transformClassAnnList(rest,context,res,p); | |
| 1334 | then res; | ||
| 1335 | |||
| 1336 | case(Absyn.MODIFICATION(path = Absyn.IDENT(name = "component")) :: rest,context ,res,p) | ||
| 1337 | algorithm | ||
| 1338 | ✗ | res := transformClassAnnList(rest,context,res,p); | |
| 1339 | then res; | ||
| 1340 | |||
| 1341 | case(Absyn.MODIFICATION(path = Absyn.IDENT(name = "Window")) :: rest,context ,res,p) | ||
| 1342 | algorithm | ||
| 1343 | ✗ | res := transformClassAnnList(rest,context,res,p); | |
| 1344 | then res; | ||
| 1345 | |||
| 1346 | case(Absyn.MODIFICATION(path = Absyn.IDENT(name = "Terminal")) :: rest,context ,res,p) | ||
| 1347 | algorithm | ||
| 1348 | ✗ | res := transformClassAnnList(rest,context,res,p); | |
| 1349 | then res; | ||
| 1350 | |||
| 1351 | case(arg :: rest,context,res,p) | ||
| 1352 | algorithm | ||
| 1353 | ✗ | res := transformClassAnnList(rest,context,res,p); | |
| 1354 | then arg :: res; | ||
| 1355 | end matchcontinue; | ||
| 1356 | end transformClassAnnList; | ||
| 1357 | |||
| 1358 | protected function isLayerAnnInList" | ||
| 1359 | Helper function to transformClassAnnList. Returns true if a icon or diagram annotation | ||
| 1360 | is in the list, false otherwise. | ||
| 1361 | " | ||
| 1362 | input list<Absyn.ElementArg> inList; | ||
| 1363 | output Boolean result; | ||
| 1364 | algorithm | ||
| 1365 | result := match inList | ||
| 1366 | local | ||
| 1367 | list<Absyn.ElementArg> rest; | ||
| 1368 | Boolean res; | ||
| 1369 | |||
| 1370 | case {} then false; | ||
| 1371 | case Absyn.MODIFICATION(path = Absyn.IDENT(name = "Diagram")) :: _ | ||
| 1372 | then | ||
| 1373 | true; | ||
| 1374 | case Absyn.MODIFICATION(path = Absyn.IDENT(name = "Icon")) :: _ | ||
| 1375 | then | ||
| 1376 | true; | ||
| 1377 | case _ :: rest | ||
| 1378 | algorithm | ||
| 1379 | ✗ | res := isLayerAnnInList(rest); | |
| 1380 | then | ||
| 1381 | res; | ||
| 1382 | end match; | ||
| 1383 | end isLayerAnnInList; | ||
| 1384 | |||
| 1385 | protected function getCoordSysAnn " | ||
| 1386 | Helper function to transformClassAnnList. Fetches an old coordinate system | ||
| 1387 | annotations and returns it. If none it returns the default system for the old | ||
| 1388 | standard ([{-100,-100}{100,100}]). | ||
| 1389 | " | ||
| 1390 | |||
| 1391 | input list<Absyn.ElementArg> inArgs; | ||
| 1392 | input Absyn.Program inProgram; | ||
| 1393 | output Absyn.ElementArg coordSys; | ||
| 1394 | |||
| 1395 | algorithm | ||
| 1396 | coordSys := matchcontinue (inArgs,inProgram) | ||
| 1397 | local | ||
| 1398 | Absyn.Program p; | ||
| 1399 | list<Absyn.ElementArg> args,rest; | ||
| 1400 | Absyn.ElementArg res; | ||
| 1401 | Boolean fi; | ||
| 1402 | Absyn.Each e; | ||
| 1403 | Option<String> com; | ||
| 1404 | Absyn.EqMod eqMod; | ||
| 1405 | SourceInfo info; | ||
| 1406 | |||
| 1407 | case ({},_) | ||
| 1408 | then | ||
| 1409 | Absyn.MODIFICATION(false, Absyn.NON_EACH(), Absyn.IDENT("coordinateSystem"), SOME(Absyn.CLASSMOD({Absyn.MODIFICATION(false, Absyn.NON_EACH(), Absyn.IDENT("extent"), SOME(Absyn.CLASSMOD({}, | ||
| 1410 | Absyn.EQMOD(Absyn.ARRAY({Absyn.ARRAY({Absyn.INTEGER(-100),Absyn.INTEGER(-100)}),Absyn.ARRAY({Absyn.INTEGER(100),Absyn.INTEGER(100)})}),Absyn.dummyInfo))), | ||
| 1411 | NONE(),Absyn.dummyInfo)},Absyn.NOMOD())),NONE(),Absyn.dummyInfo)/*Create default*/; | ||
| 1412 | |||
| 1413 | case(Absyn.MODIFICATION(finalPrefix = fi, eachPrefix = e, path = Absyn.IDENT(name = "Coordsys"), modification = SOME(Absyn.CLASSMOD(elementArgLst = args, eqMod = eqMod)), comment = com, info = info) :: _,p) | ||
| 1414 | algorithm | ||
| 1415 | ✗ | args := transformClassAnnList(args,"Coordsys"::{},{},p); | |
| 1416 | ✗ | then | |
| 1417 | Absyn.MODIFICATION(fi, e, Absyn.IDENT("coordinateSystem"), SOME(Absyn.CLASSMOD(args, eqMod)), com, info); | ||
| 1418 | |||
| 1419 | case(_ :: rest,p) | ||
| 1420 | algorithm | ||
| 1421 | ✗ | res := getCoordSysAnn(rest,p); | |
| 1422 | then res; | ||
| 1423 | end matchcontinue; | ||
| 1424 | end getCoordSysAnn; | ||
| 1425 | |||
| 1426 | |||
| 1427 | protected function transAnnLstToCalls " | ||
| 1428 | Helper function to transformClassAnnList. Some graphical annotations | ||
| 1429 | have abstract syntax as CALLS in the new standard | ||
| 1430 | " | ||
| 1431 | |||
| 1432 | input list<Absyn.ElementArg> inArgs; | ||
| 1433 | input Context inCon; | ||
| 1434 | output list<Absyn.Exp> outArgs; | ||
| 1435 | |||
| 1436 | algorithm | ||
| 1437 | |||
| 1438 | outArgs := matchcontinue (inArgs,inCon) | ||
| 1439 | |||
| 1440 | local | ||
| 1441 | |||
| 1442 | list<Absyn.ElementArg> args,rest; | ||
| 1443 | list<Absyn.Exp> res,restRes; | ||
| 1444 | list<Absyn.NamedArg> argRes; | ||
| 1445 | Absyn.Ident n; | ||
| 1446 | Context context, c; | ||
| 1447 | |||
| 1448 | case({},_) then {} ; | ||
| 1449 | |||
| 1450 | /* Special case for Line, need to add default color={0,0,255} if no color given */ | ||
| 1451 | case(Absyn.MODIFICATION(path = Absyn.IDENT(name = "Line"), modification = SOME(Absyn.CLASSMOD(elementArgLst = args))) :: rest,context as ("Layer" :: c)) | ||
| 1452 | |||
| 1453 | algorithm | ||
| 1454 | ✗ | c := addContext(context,"Line"); | |
| 1455 | ✗ | argRes := transAnnLstToNamedArgs(args,c); | |
| 1456 | ✗ | {} := List.select1(argRes,nameArgWithName, "color"); | |
| 1457 | ✗ | restRes := transAnnLstToCalls(rest,context); | |
| 1458 | ✗ | then | |
| 1459 | Absyn.CALL(Absyn.CREF_IDENT("Line",{}), Absyn.FUNCTIONARGS({}, | ||
| 1460 | Absyn.NAMEDARG("color",Absyn.ARRAY({Absyn.INTEGER(0),Absyn.INTEGER(0),Absyn.INTEGER(255)}))::argRes),{}) :: restRes; | ||
| 1461 | |||
| 1462 | /* Special case for Rectangle Ellipse, Polygon, Text, need to add default lineColor={0,0,255} if no color given */ | ||
| 1463 | case(Absyn.MODIFICATION(path = Absyn.IDENT(name = n), modification = SOME(Absyn.CLASSMOD(elementArgLst = args))) :: rest,context as ("Layer" :: c)) | ||
| 1464 | |||
| 1465 | algorithm | ||
| 1466 | ✗ | c := addContext(context,n); | |
| 1467 | ✗ | true := isLinebasedGraphic(c); | |
| 1468 | ✗ | argRes := transAnnLstToNamedArgs(args,c); | |
| 1469 | ✗ | {} := List.select1(argRes,nameArgWithName, "lineColor"); | |
| 1470 | ✗ | restRes := transAnnLstToCalls(rest,context); | |
| 1471 | ✗ | then | |
| 1472 | Absyn.CALL(Absyn.CREF_IDENT(n,{}), Absyn.FUNCTIONARGS({}, | ||
| 1473 | Absyn.NAMEDARG("lineColor",Absyn.ARRAY({Absyn.INTEGER(0),Absyn.INTEGER(0),Absyn.INTEGER(255)}))::argRes),{}) :: restRes; | ||
| 1474 | |||
| 1475 | |||
| 1476 | case(Absyn.MODIFICATION(path = Absyn.IDENT(name = n), modification = SOME(Absyn.CLASSMOD(elementArgLst = args))) :: rest,context as ("Layer" :: c)) | ||
| 1477 | |||
| 1478 | algorithm | ||
| 1479 | ✗ | c := addContext(context,n); | |
| 1480 | ✗ | argRes := transAnnLstToNamedArgs(args,c); | |
| 1481 | ✗ | restRes := transAnnLstToCalls(rest,context); | |
| 1482 | |||
| 1483 | ✗ | then | |
| 1484 | Absyn.CALL(Absyn.CREF_IDENT(n,{}), Absyn.FUNCTIONARGS({},argRes),{}) :: restRes; | ||
| 1485 | |||
| 1486 | case(_ :: rest,context) | ||
| 1487 | |||
| 1488 | algorithm | ||
| 1489 | |||
| 1490 | ✗ | res := transAnnLstToCalls(rest,context); | |
| 1491 | |||
| 1492 | then res; | ||
| 1493 | |||
| 1494 | end matchcontinue; | ||
| 1495 | |||
| 1496 | end transAnnLstToCalls; | ||
| 1497 | |||
| 1498 | protected function nameArgWithName | ||
| 1499 | input Absyn.NamedArg narg; | ||
| 1500 | input String argName; | ||
| 1501 | output Boolean res; | ||
| 1502 | algorithm | ||
| 1503 | res := match narg | ||
| 1504 | local String name; | ||
| 1505 | case Absyn.NAMEDARG(name,_) algorithm | ||
| 1506 | ✗ | res := (name == argName); | |
| 1507 | then res; | ||
| 1508 | end match; | ||
| 1509 | end nameArgWithName; | ||
| 1510 | |||
| 1511 | protected function transAnnLstToNamedArgs " | ||
| 1512 | Helper function to transformClassAnnList. Some graphical annotations | ||
| 1513 | have abstract syntax as Absyn.NamedArg in the new standard | ||
| 1514 | " | ||
| 1515 | |||
| 1516 | input list<Absyn.ElementArg> inArgs; | ||
| 1517 | input Context inCon; | ||
| 1518 | output list<Absyn.NamedArg> outArgs; | ||
| 1519 | |||
| 1520 | algorithm | ||
| 1521 | |||
| 1522 | outArgs := matchcontinue (inArgs,inCon) | ||
| 1523 | |||
| 1524 | local | ||
| 1525 | |||
| 1526 | list<list<Absyn.Exp>> expMatrix; | ||
| 1527 | list<Absyn.Exp> expLst; | ||
| 1528 | Absyn.Exp exp; | ||
| 1529 | |||
| 1530 | list<Absyn.ElementArg> args, rest; | ||
| 1531 | list<Absyn.NamedArg> res,restRes,argRes; | ||
| 1532 | Context context; | ||
| 1533 | list<String> arrows; | ||
| 1534 | Absyn.Exp x1,x2,y1,y2; | ||
| 1535 | Integer color1,color2,color3,x; | ||
| 1536 | String val,val1,val2,s; | ||
| 1537 | Real thick; | ||
| 1538 | |||
| 1539 | case({},_) then {} ; | ||
| 1540 | |||
| 1541 | case(Absyn.MODIFICATION(path = Absyn.IDENT(name = "extent"), modification = SOME(Absyn.CLASSMOD(eqMod = Absyn.EQMOD(exp=Absyn.MATRIX(matrix = {{x1,y1},{x2,y2}} ))))) :: rest,context) | ||
| 1542 | algorithm | ||
| 1543 | ✗ | restRes := transAnnLstToNamedArgs(rest,context); | |
| 1544 | ✗ | then Absyn.NAMEDARG("extent",Absyn.ARRAY({Absyn.ARRAY({x1,y1} ),Absyn.ARRAY({x2,y2})})) :: restRes;//res; | |
| 1545 | |||
| 1546 | case(Absyn.MODIFICATION(path = Absyn.IDENT(name = "style"), modification = SOME(Absyn.CLASSMOD(elementArgLst = args))) :: rest,context) | ||
| 1547 | algorithm | ||
| 1548 | ✗ | restRes := transAnnLstToNamedArgs(rest,context); | |
| 1549 | ✗ | args := cleanStyleAttrs(args,{},context); //Styleregler | |
| 1550 | ✗ | argRes := transAnnLstToNamedArgs(args,context); | |
| 1551 | ✗ | res := listAppend(argRes,restRes); | |
| 1552 | then res; | ||
| 1553 | |||
| 1554 | case(Absyn.MODIFICATION(path = Absyn.IDENT(name = "color"), modification = SOME(Absyn.CLASSMOD(eqMod = Absyn.EQMOD(exp=Absyn.INTEGER(value = x))))) :: rest, context as ("Text" :: _)) | ||
| 1555 | algorithm | ||
| 1556 | ✗ | (color1,color2,color3) := getMappedColor(x); | |
| 1557 | ✗ | restRes := transAnnLstToNamedArgs(rest,context); | |
| 1558 | ✗ | then Absyn.NAMEDARG("fillColor", Absyn.ARRAY({Absyn.INTEGER(color1),Absyn.INTEGER(color2),Absyn.INTEGER(color3)})) :: restRes;//res; | |
| 1559 | |||
| 1560 | case(Absyn.MODIFICATION(path = Absyn.IDENT(name = "color"), modification = SOME(Absyn.CLASSMOD(eqMod = Absyn.EQMOD(exp=Absyn.INTEGER(value = x))))) :: rest, context as ("Line" :: _)) | ||
| 1561 | algorithm | ||
| 1562 | ✗ | (color1,color2,color3) := getMappedColor(x); | |
| 1563 | ✗ | restRes := transAnnLstToNamedArgs(rest,context); | |
| 1564 | ✗ | then Absyn.NAMEDARG("color", Absyn.ARRAY({Absyn.INTEGER(color1),Absyn.INTEGER(color2),Absyn.INTEGER(color3)})) :: restRes; | |
| 1565 | |||
| 1566 | case(Absyn.MODIFICATION(path = Absyn.IDENT(name = "color"), modification = SOME(Absyn.CLASSMOD(eqMod = Absyn.EQMOD(exp=Absyn.INTEGER(value = x))))) :: rest, context ) | ||
| 1567 | algorithm | ||
| 1568 | ✗ | (color1,color2,color3) := getMappedColor(x); | |
| 1569 | ✗ | restRes := transAnnLstToNamedArgs(rest,context); | |
| 1570 | ✗ | then Absyn.NAMEDARG("lineColor",Absyn.ARRAY({Absyn.INTEGER(color1),Absyn.INTEGER(color2),Absyn.INTEGER(color3)})) :: restRes; | |
| 1571 | |||
| 1572 | case(Absyn.MODIFICATION(path = Absyn.IDENT(name = "fillColor"), modification = SOME(Absyn.CLASSMOD(eqMod = Absyn.EQMOD(exp=Absyn.INTEGER(value = x)) ))) :: rest,context ) | ||
| 1573 | algorithm | ||
| 1574 | ✗ | (color1,color2,color3) := getMappedColor(x); | |
| 1575 | ✗ | restRes := transAnnLstToNamedArgs(rest,context); | |
| 1576 | ✗ | then Absyn.NAMEDARG("fillColor", Absyn.ARRAY({Absyn.INTEGER(color1),Absyn.INTEGER(color2),Absyn.INTEGER(color3)})) :: restRes; | |
| 1577 | |||
| 1578 | case(Absyn.MODIFICATION(path = Absyn.IDENT(name = "pattern"), modification = SOME(Absyn.CLASSMOD(eqMod = Absyn.EQMOD(exp=Absyn.INTEGER(value = x)) ))) :: rest,context ) | ||
| 1579 | algorithm | ||
| 1580 | ✗ | val := listGet(patternMapList,x+1); | |
| 1581 | ✗ | restRes := transAnnLstToNamedArgs(rest,context); | |
| 1582 | ✗ | then Absyn.NAMEDARG("pattern",Absyn.CREF(Absyn.CREF_QUAL("LinePattern", {},Absyn.CREF_IDENT(val, {})))) :: restRes; | |
| 1583 | |||
| 1584 | case(Absyn.MODIFICATION(path = Absyn.IDENT(name = "fillPattern"), modification = SOME(Absyn.CLASSMOD(eqMod = Absyn.EQMOD(exp=Absyn.INTEGER(value = x)) ))) :: rest,context ) | ||
| 1585 | algorithm | ||
| 1586 | ✗ | val := listGet(fillPatternMapList,x+1); | |
| 1587 | ✗ | restRes := transAnnLstToNamedArgs(rest,context); | |
| 1588 | ✗ | then Absyn.NAMEDARG("fillPattern",Absyn.CREF(Absyn.CREF_QUAL("FillPattern", {},Absyn.CREF_IDENT(val, {})))) :: restRes; | |
| 1589 | |||
| 1590 | case(Absyn.MODIFICATION(path = Absyn.IDENT(name = "thickness"), modification = SOME(Absyn.CLASSMOD(eqMod = Absyn.EQMOD(exp=Absyn.INTEGER(value = x)) ))) :: rest,context as ("Line" :: _)) | ||
| 1591 | algorithm | ||
| 1592 | ✗ | thick := listGet(thicknessMapList,x); | |
| 1593 | ✗ | restRes := transAnnLstToNamedArgs(rest,context); | |
| 1594 | ✗ | s := realString(thick); | |
| 1595 | ✗ | then Absyn.NAMEDARG("thickness",Absyn.REAL(s)) :: restRes; | |
| 1596 | |||
| 1597 | case(Absyn.MODIFICATION(path = Absyn.IDENT(name = "thickness"), modification = SOME(Absyn.CLASSMOD(eqMod = Absyn.EQMOD(exp=Absyn.INTEGER(value = x)) ))) :: rest,context ) | ||
| 1598 | algorithm | ||
| 1599 | ✗ | thick := listGet(thicknessMapList,x); | |
| 1600 | ✗ | restRes := transAnnLstToNamedArgs(rest,context); | |
| 1601 | ✗ | s := realString(thick); | |
| 1602 | ✗ | then Absyn.NAMEDARG("lineThickness",Absyn.REAL(s)) :: restRes; | |
| 1603 | |||
| 1604 | case(Absyn.MODIFICATION(path = Absyn.IDENT(name = "gradient"), modification = SOME(Absyn.CLASSMOD(eqMod = Absyn.EQMOD(exp=Absyn.INTEGER(value = x)) ))) :: rest,context) | ||
| 1605 | algorithm | ||
| 1606 | ✗ | val := listGet(gradientMapList,x+1); | |
| 1607 | ✗ | restRes := transAnnLstToNamedArgs(rest,context); | |
| 1608 | ✗ | then Absyn.NAMEDARG("fillPattern",Absyn.CREF(Absyn.CREF_QUAL("FillPattern", {},Absyn.CREF_IDENT(val, {})))) :: restRes ; | |
| 1609 | |||
| 1610 | case(Absyn.MODIFICATION(path = Absyn.IDENT(name = "smooth"), modification = SOME(Absyn.CLASSMOD(eqMod = Absyn.EQMOD(exp=exp)))) :: rest,context) | ||
| 1611 | algorithm | ||
| 1612 | ✗ | restRes := transAnnLstToNamedArgs(rest,context); | |
| 1613 | ✗ | then Absyn.NAMEDARG("smooth",exp) :: restRes; | |
| 1614 | |||
| 1615 | case(Absyn.MODIFICATION(path = Absyn.IDENT(name = "arrow"), modification = SOME(Absyn.CLASSMOD(eqMod = Absyn.EQMOD(exp=Absyn.INTEGER(value = x)) ))) :: rest,context) | ||
| 1616 | algorithm | ||
| 1617 | ✗ | arrows := listGet(arrowMapList,x+1); | |
| 1618 | ✗ | val1 := listGet(arrows,1); | |
| 1619 | ✗ | val2 := listGet(arrows,2); | |
| 1620 | ✗ | restRes := transAnnLstToNamedArgs(rest,context); | |
| 1621 | ✗ | then Absyn.NAMEDARG("arrow",Absyn.ARRAY({Absyn.CREF(Absyn.CREF_QUAL("Arrow", {},Absyn.CREF_IDENT(val1, {}))),Absyn.CREF(Absyn.CREF_QUAL("Arrow",{},Absyn.CREF_IDENT(val2,{})))})):: restRes ; | |
| 1622 | |||
| 1623 | case(Absyn.MODIFICATION(path = Absyn.IDENT(name = "textStyle"), modification = SOME(Absyn.CLASSMOD(eqMod = Absyn.EQMOD(exp=exp) ))) :: rest,context as ("Text" :: _)) | ||
| 1624 | algorithm | ||
| 1625 | ✗ | restRes := transAnnLstToNamedArgs(rest,context); | |
| 1626 | ✗ | then Absyn.NAMEDARG("textStyle",exp) :: restRes; | |
| 1627 | |||
| 1628 | case(Absyn.MODIFICATION(path = Absyn.IDENT(name = "font"), modification = SOME(Absyn.CLASSMOD(eqMod = Absyn.EQMOD(exp=exp)))) :: rest,context as ("Text" :: _)) | ||
| 1629 | algorithm | ||
| 1630 | ✗ | restRes := transAnnLstToNamedArgs(rest,context); | |
| 1631 | ✗ | then Absyn.NAMEDARG("font",exp) :: restRes; | |
| 1632 | |||
| 1633 | case(Absyn.MODIFICATION(path = Absyn.IDENT(name = "string"), modification = SOME(Absyn.CLASSMOD(eqMod = Absyn.EQMOD(exp=exp)))) :: rest,context as ("Text" :: _)) | ||
| 1634 | algorithm | ||
| 1635 | ✗ | restRes := transAnnLstToNamedArgs(rest,context); | |
| 1636 | ✗ | then Absyn.NAMEDARG("textString",exp) :: restRes; | |
| 1637 | |||
| 1638 | case(Absyn.MODIFICATION(path = Absyn.IDENT(name = "name"), modification = SOME(Absyn.CLASSMOD(eqMod = Absyn.EQMOD(exp=exp)))) :: rest,context as ("Bitmap" :: _)) | ||
| 1639 | algorithm | ||
| 1640 | ✗ | restRes := transAnnLstToNamedArgs(rest,context); | |
| 1641 | ✗ | then Absyn.NAMEDARG("fileName",exp) :: restRes; | |
| 1642 | |||
| 1643 | case(Absyn.MODIFICATION(path = Absyn.IDENT(name = "points"), modification = SOME(Absyn.CLASSMOD(eqMod = Absyn.EQMOD(exp=Absyn.MATRIX(matrix = expMatrix )) ))) :: rest,context) | ||
| 1644 | algorithm | ||
| 1645 | ✗ | expLst := List.map(expMatrix,matrixToArray); | |
| 1646 | ✗ | restRes := transAnnLstToNamedArgs(rest,context); | |
| 1647 | ✗ | then Absyn.NAMEDARG("points",Absyn.ARRAY(expLst)) :: restRes; | |
| 1648 | |||
| 1649 | case(_ :: rest,context) | ||
| 1650 | algorithm | ||
| 1651 | ✗ | res := transAnnLstToNamedArgs(rest,context); | |
| 1652 | then res; | ||
| 1653 | end matchcontinue; | ||
| 1654 | end transAnnLstToNamedArgs; | ||
| 1655 | |||
| 1656 | protected function cleanStyleAttrs " | ||
| 1657 | Helperfunction to the transform functions. The old style attribute and it's | ||
| 1658 | contents needs to be adjusted according to priorities before beeing transformed. | ||
| 1659 | See also cleanStyleAttrs2. | ||
| 1660 | " | ||
| 1661 | |||
| 1662 | input list<Absyn.ElementArg> inArgs; | ||
| 1663 | input list<Absyn.ElementArg > resultList; | ||
| 1664 | input Context inCon; | ||
| 1665 | output list<Absyn.ElementArg> outArgs; | ||
| 1666 | |||
| 1667 | algorithm | ||
| 1668 | outArgs := matchcontinue inCon | ||
| 1669 | local Context context; | ||
| 1670 | |||
| 1671 | /* If is Rectangle, Ellipse, Polygon or Text and no color attribute, set default to lineColor={0,0,255} */ | ||
| 1672 | case context | ||
| 1673 | algorithm | ||
| 1674 | ✗ | true := isLinebasedGraphic(context); | |
| 1675 | ✗ | {} := List.select(inArgs,isLineColorModifier); | |
| 1676 | ✗ | outArgs := cleanStyleAttrs2(Absyn.MODIFICATION(false,Absyn.NON_EACH(),Absyn.IDENT("lineColor"), | |
| 1677 | SOME(Absyn.CLASSMOD({},Absyn.EQMOD(Absyn.ARRAY({Absyn.INTEGER(0),Absyn.INTEGER(0),Absyn.INTEGER(255)}),Absyn.dummyInfo))),NONE(),Absyn.dummyInfo)::inArgs,resultList,context); | ||
| 1678 | then outArgs; | ||
| 1679 | |||
| 1680 | /* If is Line and no color attribute, set default to color={0,0,255} */ | ||
| 1681 | case context | ||
| 1682 | algorithm | ||
| 1683 | ✗ | true := isLineGraphic(context); | |
| 1684 | ✗ | {} := List.select(inArgs,isLineColorModifier); | |
| 1685 | ✗ | outArgs := cleanStyleAttrs2(Absyn.MODIFICATION(false,Absyn.NON_EACH(),Absyn.IDENT("color"), | |
| 1686 | SOME(Absyn.CLASSMOD({},Absyn.EQMOD(Absyn.ARRAY({Absyn.INTEGER(0),Absyn.INTEGER(0),Absyn.INTEGER(255)}),Absyn.dummyInfo))),NONE(),Absyn.dummyInfo)::inArgs,resultList,context); | ||
| 1687 | then outArgs; | ||
| 1688 | |||
| 1689 | else | ||
| 1690 | algorithm | ||
| 1691 | ✗ | outArgs := cleanStyleAttrs2(inArgs,resultList,inCon); | |
| 1692 | then outArgs; | ||
| 1693 | end matchcontinue; | ||
| 1694 | end cleanStyleAttrs; | ||
| 1695 | |||
| 1696 | protected function isLineColorModifier | ||
| 1697 | input Absyn.ElementArg arg; | ||
| 1698 | output Boolean res; | ||
| 1699 | algorithm | ||
| 1700 | res := match arg | ||
| 1701 | case Absyn.MODIFICATION(path = Absyn.IDENT("color"), | ||
| 1702 | modification = SOME(Absyn.CLASSMOD(_,_))) | ||
| 1703 | then true; | ||
| 1704 | else false; | ||
| 1705 | end match; | ||
| 1706 | end isLineColorModifier; | ||
| 1707 | |||
| 1708 | protected function isStyleModifier | ||
| 1709 | input Absyn.ElementArg arg; | ||
| 1710 | output Boolean res; | ||
| 1711 | algorithm | ||
| 1712 | res := match arg | ||
| 1713 | case Absyn.MODIFICATION(path = Absyn.IDENT("style")) then true; | ||
| 1714 | else false; | ||
| 1715 | end match; | ||
| 1716 | end isStyleModifier; | ||
| 1717 | |||
| 1718 | protected function isLinebasedGraphic "Returns true if context string is a line based graphic" | ||
| 1719 | input Context context; | ||
| 1720 | output Boolean res; | ||
| 1721 | algorithm | ||
| 1722 | res := match context | ||
| 1723 | case "Rectangle"::_ then true; | ||
| 1724 | case "Ellipse"::_ then true; | ||
| 1725 | case "Polygon"::_ then true; | ||
| 1726 | case "Text"::_ then true; | ||
| 1727 | else false; | ||
| 1728 | end match; | ||
| 1729 | end isLinebasedGraphic; | ||
| 1730 | |||
| 1731 | protected function isLineGraphic "Returns true if context string is a Line" | ||
| 1732 | input Context context; | ||
| 1733 | output Boolean res; | ||
| 1734 | algorithm | ||
| 1735 | res := match context | ||
| 1736 | case "Line"::_ then true; | ||
| 1737 | else false; | ||
| 1738 | end match; | ||
| 1739 | end isLineGraphic; | ||
| 1740 | |||
| 1741 | |||
| 1742 | protected function cleanStyleAttrs2 " | ||
| 1743 | Helperfunction to the transform functions. The old style attribute and it's | ||
| 1744 | contents needs to be adjusted according to priorities before beeing transformed." | ||
| 1745 | input list<Absyn.ElementArg> inArgs; | ||
| 1746 | input list<Absyn.ElementArg> inResultList; | ||
| 1747 | input Context inCon; | ||
| 1748 | output list<Absyn.ElementArg> outArgs; | ||
| 1749 | algorithm | ||
| 1750 | outArgs := match (inArgs,inResultList,inCon) | ||
| 1751 | local | ||
| 1752 | list<Absyn.ElementArg> outList,rest; | ||
| 1753 | Absyn.ElementArg arg; | ||
| 1754 | Context context; | ||
| 1755 | list<Absyn.ElementArg> resultList; | ||
| 1756 | |||
| 1757 | case({},resultList,_) then resultList; | ||
| 1758 | |||
| 1759 | case((arg as Absyn.MODIFICATION(path = Absyn.IDENT(name = "color"))) :: rest, resultList,context ) | ||
| 1760 | algorithm | ||
| 1761 | ✗ | resultList := List.appendElt(arg,resultList); | |
| 1762 | ✗ | outList := cleanStyleAttrs2(rest,resultList,context); | |
| 1763 | then outList; | ||
| 1764 | |||
| 1765 | case((arg as Absyn.MODIFICATION(path = Absyn.IDENT(name = "fillColor"))) :: rest, resultList,context as ("Rectangle"::_)) | ||
| 1766 | guard | ||
| 1767 | //If fillColor is specified but not fillPattern or Gradient we need to insert a FillPattern | ||
| 1768 | not isGradientInList(listAppend(rest,resultList)) and | ||
| 1769 | not isFillPatternInList(listAppend(rest,resultList)) | ||
| 1770 | algorithm | ||
| 1771 | ✗ | resultList := insertFillPatternInList(resultList); | |
| 1772 | ✗ | resultList := List.appendElt(arg,resultList); | |
| 1773 | ✗ | outList := cleanStyleAttrs2(rest,resultList,context); | |
| 1774 | then outList; | ||
| 1775 | |||
| 1776 | case((arg as Absyn.MODIFICATION(path = Absyn.IDENT(name = "fillColor"))) :: rest, resultList,context as ("Ellipse"::_)) | ||
| 1777 | guard | ||
| 1778 | //If fillColor is specified but not fillPattern or Gradient we need to insert a FillPattern | ||
| 1779 | not isGradientInList(listAppend(rest,resultList)) and | ||
| 1780 | not isFillPatternInList(listAppend(rest,resultList)) | ||
| 1781 | algorithm | ||
| 1782 | ✗ | resultList := insertFillPatternInList(resultList); | |
| 1783 | ✗ | resultList := List.appendElt(arg,resultList); | |
| 1784 | ✗ | outList := cleanStyleAttrs2(rest,resultList,context); | |
| 1785 | then outList; | ||
| 1786 | |||
| 1787 | case((arg as Absyn.MODIFICATION(path = Absyn.IDENT(name = "fillColor"))) :: rest, resultList,context as ("Polygon"::_)) | ||
| 1788 | |||
| 1789 | guard | ||
| 1790 | //If fillColor is specified but not fillPattern or Gradient we need to insert a FillPattern | ||
| 1791 | not isGradientInList(listAppend(rest,resultList)) and | ||
| 1792 | not isFillPatternInList(listAppend(rest,resultList)) | ||
| 1793 | algorithm | ||
| 1794 | ✗ | resultList := insertFillPatternInList(resultList); | |
| 1795 | ✗ | resultList := List.appendElt(arg,resultList); | |
| 1796 | ✗ | outList := cleanStyleAttrs2(rest,resultList,context); | |
| 1797 | then outList; | ||
| 1798 | |||
| 1799 | case((arg as Absyn.MODIFICATION(path = Absyn.IDENT(name = "fillColor"))) :: rest, resultList,context as ("Rectangle"::_)) | ||
| 1800 | algorithm | ||
| 1801 | ✗ | resultList := List.appendElt(arg,resultList); | |
| 1802 | ✗ | outList := cleanStyleAttrs2(rest,resultList,context); | |
| 1803 | then outList; | ||
| 1804 | |||
| 1805 | case((arg as Absyn.MODIFICATION(path = Absyn.IDENT(name = "fillColor"))) :: rest, resultList,context as ("Ellipse"::_)) | ||
| 1806 | algorithm | ||
| 1807 | ✗ | resultList := List.appendElt(arg,resultList); | |
| 1808 | ✗ | outList := cleanStyleAttrs2(rest,resultList,context); | |
| 1809 | then outList; | ||
| 1810 | |||
| 1811 | case((arg as Absyn.MODIFICATION(path = Absyn.IDENT(name = "fillColor"))) :: rest, resultList,context as ("Polygon"::_)) | ||
| 1812 | algorithm | ||
| 1813 | ✗ | resultList := List.appendElt(arg,resultList); | |
| 1814 | ✗ | outList := cleanStyleAttrs2(rest,resultList,context); | |
| 1815 | then outList; | ||
| 1816 | |||
| 1817 | case((arg as Absyn.MODIFICATION(path = Absyn.IDENT(name = "pattern"))) :: rest, resultList,context as ("Rectangle" :: _)) | ||
| 1818 | algorithm | ||
| 1819 | ✗ | resultList := List.appendElt(arg,resultList); | |
| 1820 | ✗ | outList := cleanStyleAttrs2(rest,resultList,context); | |
| 1821 | then outList; | ||
| 1822 | |||
| 1823 | case((arg as Absyn.MODIFICATION(path = Absyn.IDENT(name = "pattern"))) :: rest, resultList,context as ("Ellipse" :: _)) | ||
| 1824 | algorithm | ||
| 1825 | ✗ | resultList := List.appendElt(arg,resultList); | |
| 1826 | ✗ | outList := cleanStyleAttrs2(rest,resultList,context); | |
| 1827 | then outList; | ||
| 1828 | |||
| 1829 | case((arg as Absyn.MODIFICATION(path = Absyn.IDENT(name = "pattern"))) :: rest, resultList,context as ("Polygon" :: _)) | ||
| 1830 | algorithm | ||
| 1831 | ✗ | resultList := List.appendElt(arg,resultList); | |
| 1832 | ✗ | outList := cleanStyleAttrs2(rest,resultList,context); | |
| 1833 | then outList; | ||
| 1834 | |||
| 1835 | case((arg as Absyn.MODIFICATION(path = Absyn.IDENT(name = "pattern"))) :: rest, resultList,context as ("Line" :: _)) | ||
| 1836 | algorithm | ||
| 1837 | ✗ | resultList := List.appendElt(arg,resultList); | |
| 1838 | ✗ | outList := cleanStyleAttrs2(rest,resultList,context); | |
| 1839 | then outList; | ||
| 1840 | |||
| 1841 | case((arg as Absyn.MODIFICATION(path = Absyn.IDENT(name = "fillPattern"))) :: rest, resultList,context as("Rectangle" :: _)) | ||
| 1842 | algorithm | ||
| 1843 | ✗ | resultList := List.appendElt(arg,resultList); | |
| 1844 | ✗ | outList := cleanStyleAttrs2(rest,resultList,context); | |
| 1845 | then outList; | ||
| 1846 | |||
| 1847 | case((arg as Absyn.MODIFICATION(path = Absyn.IDENT(name = "fillPattern"))) :: rest, resultList,context as("Ellipse" :: _)) | ||
| 1848 | algorithm | ||
| 1849 | ✗ | resultList := List.appendElt(arg,resultList); | |
| 1850 | ✗ | outList := cleanStyleAttrs2(rest,resultList,context); | |
| 1851 | then outList; | ||
| 1852 | |||
| 1853 | case((arg as Absyn.MODIFICATION(path = Absyn.IDENT(name = "fillPattern"))) :: rest, resultList,context as("Polygon" :: _)) | ||
| 1854 | algorithm | ||
| 1855 | ✗ | resultList := List.appendElt(arg,resultList); | |
| 1856 | ✗ | outList := cleanStyleAttrs2(rest,resultList,context); | |
| 1857 | then outList; | ||
| 1858 | |||
| 1859 | case((Absyn.MODIFICATION(path = Absyn.IDENT(name = "thickness"))) :: rest, resultList,context as("Bitmap" :: _)) | ||
| 1860 | algorithm | ||
| 1861 | //Filter away, bitmaps can have no thickness. | ||
| 1862 | ✗ | outList := cleanStyleAttrs2(rest,resultList,context); | |
| 1863 | then outList; | ||
| 1864 | |||
| 1865 | case((arg as Absyn.MODIFICATION(path = Absyn.IDENT(name = "thickness"))) :: rest, resultList,context) | ||
| 1866 | algorithm | ||
| 1867 | ✗ | resultList := List.appendElt(arg,resultList); | |
| 1868 | ✗ | outList := cleanStyleAttrs2(rest,resultList,context); | |
| 1869 | then outList; | ||
| 1870 | |||
| 1871 | case((Absyn.MODIFICATION(path = Absyn.IDENT(name = "gradient"), modification = SOME(Absyn.CLASSMOD(eqMod = Absyn.EQMOD(exp=Absyn.INTEGER(value = 0)))))) :: rest, resultList,context) | ||
| 1872 | //Filter away | ||
| 1873 | algorithm | ||
| 1874 | ✗ | outList := cleanStyleAttrs2(rest,resultList,context); | |
| 1875 | then outList; | ||
| 1876 | |||
| 1877 | case((arg as Absyn.MODIFICATION(path = Absyn.IDENT(name = "gradient"))) :: rest, resultList,context as ("Rectangle" :: _)) | ||
| 1878 | algorithm | ||
| 1879 | ✗ | rest := removeFillPatternInList(rest) /*If we have a old gradient any old fillPattern should be removed.*/; | |
| 1880 | ✗ | resultList := removeFillPatternInList(resultList) /*If we have a old gradient any old fillPattern should be removed.*/; | |
| 1881 | ✗ | rest := setDefaultLineInList(rest) /*If Gradient is set the line around the figure should be default*/; | |
| 1882 | ✗ | resultList := setDefaultLineInList(resultList) /*If Gradient is set the line around the figure should be default*/; | |
| 1883 | ✗ | (rest,resultList) := setDefaultFillColor(rest,resultList) /*If gradient is specificed but no fillColor, fillColor needs to be set to it's default dymola value.*/; | |
| 1884 | ✗ | resultList := List.appendElt(arg,resultList); | |
| 1885 | ✗ | outList := cleanStyleAttrs2(rest,resultList,context); | |
| 1886 | then outList; | ||
| 1887 | |||
| 1888 | case((arg as Absyn.MODIFICATION(path = Absyn.IDENT(name = "gradient"))) :: rest, resultList,context as ("Ellipse" :: _)) | ||
| 1889 | algorithm | ||
| 1890 | ✗ | rest := removeFillPatternInList(rest) /*If we have a old gradient any old fillPattern should be removed.*/; | |
| 1891 | ✗ | resultList := removeFillPatternInList(resultList) /*If we have a old gradient any old fillPattern should be removed.*/; | |
| 1892 | ✗ | rest := setDefaultLineInList(rest) /*If Gradient is set the line around the figure should be default*/; | |
| 1893 | ✗ | resultList := setDefaultLineInList(resultList) /*If Gradient is set the line around the figure should be default*/; | |
| 1894 | ✗ | (rest,resultList) := setDefaultFillColor(rest,resultList) /*If gradient is specificed but no fillColor, fillColor needs to be set to it's default dymola value.*/; | |
| 1895 | ✗ | resultList := List.appendElt(arg,resultList); | |
| 1896 | ✗ | outList := cleanStyleAttrs2(rest,resultList,context); | |
| 1897 | then outList; | ||
| 1898 | |||
| 1899 | case((arg as Absyn.MODIFICATION(path = Absyn.IDENT(name = "smooth"))) :: rest, resultList,context as("Polygon" :: _)) | ||
| 1900 | algorithm | ||
| 1901 | ✗ | resultList := List.appendElt(arg,resultList); | |
| 1902 | ✗ | outList := cleanStyleAttrs2(rest,resultList,context); | |
| 1903 | then outList; | ||
| 1904 | |||
| 1905 | case((arg as Absyn.MODIFICATION(path = Absyn.IDENT(name = "smooth"))) :: rest, resultList,context as("Line" :: _)) | ||
| 1906 | algorithm | ||
| 1907 | ✗ | resultList := List.appendElt(arg,resultList); | |
| 1908 | ✗ | outList := cleanStyleAttrs2(rest,resultList,context); | |
| 1909 | then outList; | ||
| 1910 | |||
| 1911 | case((arg as Absyn.MODIFICATION(path = Absyn.IDENT(name = "arrow"))) :: rest, resultList,context as("Line" :: _)) | ||
| 1912 | algorithm | ||
| 1913 | ✗ | resultList := List.appendElt(arg,resultList); | |
| 1914 | ✗ | outList := cleanStyleAttrs2(rest,resultList,context); | |
| 1915 | then outList; | ||
| 1916 | |||
| 1917 | case((arg as Absyn.MODIFICATION(path = Absyn.IDENT(name = "textStyle"))) :: rest, resultList,context as("Text" :: _)) | ||
| 1918 | algorithm | ||
| 1919 | ✗ | resultList := List.appendElt(arg,resultList); | |
| 1920 | ✗ | outList := cleanStyleAttrs2(rest,resultList,context); | |
| 1921 | then outList; | ||
| 1922 | |||
| 1923 | case((arg as Absyn.MODIFICATION(path = Absyn.IDENT(name = "font"))) :: rest, resultList,context as("Text" :: _)) | ||
| 1924 | algorithm | ||
| 1925 | ✗ | resultList := List.appendElt(arg,resultList); | |
| 1926 | ✗ | outList := cleanStyleAttrs2(rest,resultList,context); | |
| 1927 | then outList; | ||
| 1928 | |||
| 1929 | /* case((arg as Absyn.MODIFICATION(finalPrefix = fi, eachPrefix = e, path = Absyn.IDENT(name = "string"), modification = m, comment = com)) :: rest, resultList,context as("Text" :: c)) | ||
| 1930 | algorithm | ||
| 1931 | resultList = List.appendElt(arg,resultList); | ||
| 1932 | outList = cleanStyleAttrs(rest,resultList,context); | ||
| 1933 | then outList; | ||
| 1934 | |||
| 1935 | */ | ||
| 1936 | case(_ :: rest, resultList,context) | ||
| 1937 | algorithm | ||
| 1938 | //Filter away unwanted trash | ||
| 1939 | ✗ | outList := cleanStyleAttrs2(rest,resultList,context); | |
| 1940 | then outList; | ||
| 1941 | end match; | ||
| 1942 | end cleanStyleAttrs2; | ||
| 1943 | |||
| 1944 | protected function insertFillPatternInList "Helperfunction to cleanStyleAttrs. Inserts a fillPattern attribute in a list | ||
| 1945 | of annotations. | ||
| 1946 | " | ||
| 1947 | |||
| 1948 | input list<Absyn.ElementArg> inArgs; | ||
| 1949 | output list<Absyn.ElementArg> outArgs; | ||
| 1950 | algorithm | ||
| 1951 | outArgs := match inArgs | ||
| 1952 | local | ||
| 1953 | list<Absyn.ElementArg> lst; | ||
| 1954 | |||
| 1955 | case lst | ||
| 1956 | algorithm | ||
| 1957 | lst := Absyn.MODIFICATION(false, Absyn.NON_EACH(), | ||
| 1958 | Absyn.IDENT("fillPattern"), SOME(Absyn.CLASSMOD({},Absyn.EQMOD(Absyn.INTEGER(1),Absyn.dummyInfo))),NONE(),Absyn.dummyInfo) :: lst; | ||
| 1959 | then lst; | ||
| 1960 | end match; | ||
| 1961 | end insertFillPatternInList; | ||
| 1962 | |||
| 1963 | protected function isGradientInList " | ||
| 1964 | Helperfunction to cleanStyle attrs. Returns true if a Gradient is found in a list | ||
| 1965 | of Absyn.ElementArg. | ||
| 1966 | " | ||
| 1967 | input list<Absyn.ElementArg> inArgs; | ||
| 1968 | output Boolean result; | ||
| 1969 | algorithm | ||
| 1970 | result := match inArgs | ||
| 1971 | local | ||
| 1972 | list<Absyn.ElementArg> rest; | ||
| 1973 | Boolean res; | ||
| 1974 | |||
| 1975 | case {} then false; | ||
| 1976 | |||
| 1977 | case Absyn.MODIFICATION(path = Absyn.IDENT(name = "gradient")):: _ | ||
| 1978 | then true; | ||
| 1979 | |||
| 1980 | case _ :: rest | ||
| 1981 | algorithm | ||
| 1982 | ✗ | res := isGradientInList(rest); | |
| 1983 | then res; | ||
| 1984 | end match; | ||
| 1985 | end isGradientInList; | ||
| 1986 | |||
| 1987 | protected function isFillPatternInList " | ||
| 1988 | Helperfunction to cleanStyleAttrs. Returns true if a fillPattern attribute is | ||
| 1989 | found in a list of Absyn.ElementArg. | ||
| 1990 | " | ||
| 1991 | |||
| 1992 | input list<Absyn.ElementArg> inArgs; | ||
| 1993 | output Boolean result; | ||
| 1994 | |||
| 1995 | algorithm | ||
| 1996 | result := match inArgs | ||
| 1997 | local | ||
| 1998 | list<Absyn.ElementArg> rest; | ||
| 1999 | Boolean res; | ||
| 2000 | |||
| 2001 | case {} then false; | ||
| 2002 | |||
| 2003 | case Absyn.MODIFICATION(path = Absyn.IDENT(name = "fillPattern")):: _ | ||
| 2004 | then true; | ||
| 2005 | |||
| 2006 | case _ :: rest | ||
| 2007 | algorithm | ||
| 2008 | ✗ | res := isFillPatternInList(rest); | |
| 2009 | then res; | ||
| 2010 | end match; | ||
| 2011 | end isFillPatternInList; | ||
| 2012 | |||
| 2013 | protected function removeFillPatternInList " | ||
| 2014 | Helperfunction to cleanStyleAttrs. Removes a fillPattern attribute if present in a list | ||
| 2015 | of Absyn.ElementArg. | ||
| 2016 | " | ||
| 2017 | input list<Absyn.ElementArg> inList; | ||
| 2018 | output list<Absyn.ElementArg> outList; | ||
| 2019 | algorithm | ||
| 2020 | outList := match inList | ||
| 2021 | local | ||
| 2022 | list<Absyn.ElementArg> rest,lst; | ||
| 2023 | Absyn.ElementArg arg; | ||
| 2024 | |||
| 2025 | case {} then {}; | ||
| 2026 | |||
| 2027 | case Absyn.MODIFICATION(path = Absyn.IDENT(name = "fillPattern")) :: rest | ||
| 2028 | |||
| 2029 | then rest; | ||
| 2030 | |||
| 2031 | case arg::rest | ||
| 2032 | algorithm | ||
| 2033 | ✗ | lst := removeFillPatternInList(rest); | |
| 2034 | then (arg::lst); | ||
| 2035 | end match; | ||
| 2036 | end removeFillPatternInList; | ||
| 2037 | |||
| 2038 | protected function setDefaultFillColor " | ||
| 2039 | Helperfunction to cleanStyleAttrs. Sets a fillColor default value according to dymola | ||
| 2040 | standard. Used in case of gradient beeing specified but no fillColor. | ||
| 2041 | " | ||
| 2042 | |||
| 2043 | input list<Absyn.ElementArg> oldList; | ||
| 2044 | input list<Absyn.ElementArg> transformedList; | ||
| 2045 | |||
| 2046 | output list<Absyn.ElementArg> oList; | ||
| 2047 | output list<Absyn.ElementArg> tList; | ||
| 2048 | algorithm | ||
| 2049 | oList := oldList; | ||
| 2050 | tList := transformedList; | ||
| 2051 | ✗ | if not isFillColorInList(listAppend(oldList,transformedList)) then | |
| 2052 | tList := Absyn.MODIFICATION(false,Absyn.NON_EACH(),Absyn.IDENT("fillColor"), SOME(Absyn.CLASSMOD({},Absyn.EQMOD(Absyn.INTEGER(3),Absyn.dummyInfo))),NONE(),Absyn.dummyInfo)::tList; | ||
| 2053 | end if; | ||
| 2054 | end setDefaultFillColor; | ||
| 2055 | |||
| 2056 | protected function isFillColorInList " | ||
| 2057 | Helperfunction to setDefaultFillColor. Returns true if a fillColor attribute is found | ||
| 2058 | in a list of Absyn.ElementArg. | ||
| 2059 | " | ||
| 2060 | input list<Absyn.ElementArg> inList; | ||
| 2061 | output Boolean outBoolean; | ||
| 2062 | algorithm | ||
| 2063 | outBoolean := match inList | ||
| 2064 | local | ||
| 2065 | list<Absyn.ElementArg> rest; | ||
| 2066 | case {} | ||
| 2067 | then false; | ||
| 2068 | case Absyn.MODIFICATION(path = Absyn.IDENT(name = "fillColor")):: _ | ||
| 2069 | then true; | ||
| 2070 | case _::rest | ||
| 2071 | ✗ | then isFillColorInList(rest); | |
| 2072 | end match; | ||
| 2073 | end isFillColorInList; | ||
| 2074 | |||
| 2075 | |||
| 2076 | protected function setDefaultLineInList "Helperfunction to cleanStyleAttrs. Sets the line annotation to defualt values." | ||
| 2077 | input list<Absyn.ElementArg> inList; | ||
| 2078 | output list<Absyn.ElementArg> outList; | ||
| 2079 | algorithm | ||
| 2080 | outList := match inList | ||
| 2081 | local | ||
| 2082 | list<Absyn.ElementArg> rest,lst,args; | ||
| 2083 | Absyn.ElementArg arg; | ||
| 2084 | Boolean fi; | ||
| 2085 | Absyn.Each e; | ||
| 2086 | Option<String> com; | ||
| 2087 | SourceInfo info; | ||
| 2088 | |||
| 2089 | case {} then {}; | ||
| 2090 | case Absyn.MODIFICATION(path = Absyn.IDENT(name = "thickness"), modification = SOME(Absyn.CLASSMOD())) :: rest | ||
| 2091 | algorithm | ||
| 2092 | ✗ | lst := setDefaultLineInList(rest); | |
| 2093 | then lst; //filtered | ||
| 2094 | |||
| 2095 | case Absyn.MODIFICATION(path = Absyn.IDENT(name = "pattern"), modification = SOME(Absyn.CLASSMOD())) :: rest | ||
| 2096 | algorithm | ||
| 2097 | ✗ | lst := setDefaultLineInList(rest); | |
| 2098 | then lst; //filtered | ||
| 2099 | |||
| 2100 | case Absyn.MODIFICATION(finalPrefix = fi, eachPrefix = e, path = Absyn.IDENT(name = "color"), modification = SOME(Absyn.CLASSMOD(elementArgLst= args)), comment = com, info = info) :: rest | ||
| 2101 | algorithm | ||
| 2102 | ✗ | lst := setDefaultLineInList(rest); | |
| 2103 | ✗ | then Absyn.MODIFICATION(fi, e, Absyn.IDENT("color"), SOME(Absyn.CLASSMOD(args,Absyn.EQMOD(Absyn.INTEGER(0),Absyn.dummyInfo))), com, info) :: lst; | |
| 2104 | |||
| 2105 | case arg::rest | ||
| 2106 | algorithm | ||
| 2107 | ✗ | lst := setDefaultLineInList(rest); | |
| 2108 | then (arg::lst); | ||
| 2109 | end match; | ||
| 2110 | end setDefaultLineInList; | ||
| 2111 | |||
| 2112 | protected function getMappedColor " | ||
| 2113 | Helperfunction during the transformation. Takes a old color representation as input | ||
| 2114 | and returns the three RGB representations for that color. | ||
| 2115 | " | ||
| 2116 | input Integer inColor "color to be mapped"; | ||
| 2117 | output Integer color1; | ||
| 2118 | output Integer color2; | ||
| 2119 | output Integer color3; | ||
| 2120 | algorithm | ||
| 2121 | (color1,color2,color3) := match inColor | ||
| 2122 | local | ||
| 2123 | rgbColor rcol; | ||
| 2124 | Integer color; | ||
| 2125 | case color | ||
| 2126 | algorithm | ||
| 2127 | ✗ | rcol := listGet(colorMapList,color+1); | |
| 2128 | ✗ | color1 := listGet(rcol,1); | |
| 2129 | ✗ | color2 := listGet(rcol,2); | |
| 2130 | ✗ | color3 := listGet(rcol,3); | |
| 2131 | then | ||
| 2132 | (color1,color2,color3); | ||
| 2133 | end match; | ||
| 2134 | end getMappedColor; | ||
| 2135 | |||
| 2136 | protected function matrixToArray "" | ||
| 2137 | input list<Absyn.Exp> inLst; | ||
| 2138 | output Absyn.Exp outExp; | ||
| 2139 | algorithm | ||
| 2140 | ✗ | outExp := Absyn.ARRAY(inLst); | |
| 2141 | end matrixToArray; | ||
| 2142 | /* | ||
| 2143 | protected function getValueFromIntExp | ||
| 2144 | |||
| 2145 | input Absyn.Exp intExpr; | ||
| 2146 | output Integer value; | ||
| 2147 | algorithm | ||
| 2148 | value := match(intExpr) | ||
| 2149 | local | ||
| 2150 | Integer val; | ||
| 2151 | case(Absyn.INTEGER(value = val)) | ||
| 2152 | then val; | ||
| 2153 | |||
| 2154 | case(Absyn.UNARY(exp = Absyn.INTEGER(value = val))) | ||
| 2155 | then (-val); | ||
| 2156 | end match; | ||
| 2157 | end getValueFromIntExp; | ||
| 2158 | |||
| 2159 | protected function getValueFromRealExp | ||
| 2160 | input Absyn.Exp realExpr; | ||
| 2161 | output Real value; | ||
| 2162 | algorithm | ||
| 2163 | value := match(realExpr) | ||
| 2164 | local | ||
| 2165 | Real val; | ||
| 2166 | case(Absyn.REAL(value = val)) | ||
| 2167 | then val; | ||
| 2168 | case(Absyn.UNARY(exp = Absyn.REAL(value = val))) | ||
| 2169 | then -val; | ||
| 2170 | end match; | ||
| 2171 | end getValueFromRealExp; */ | ||
| 2172 | |||
| 2173 | protected function getValueFromExp | ||
| 2174 | input Absyn.Exp expr; | ||
| 2175 | output Real value; | ||
| 2176 | algorithm | ||
| 2177 | value := match expr | ||
| 2178 | local | ||
| 2179 | String realVal; | ||
| 2180 | Integer intVal; | ||
| 2181 | case Absyn.REAL(value = realVal) | ||
| 2182 | ✗ | then stringReal(realVal); | |
| 2183 | |||
| 2184 | case Absyn.UNARY(exp = Absyn.REAL(value = realVal)) | ||
| 2185 | ✗ | then - stringReal(realVal); | |
| 2186 | |||
| 2187 | case Absyn.INTEGER(value = intVal) | ||
| 2188 | ✗ | then intReal(intVal); | |
| 2189 | |||
| 2190 | case Absyn.UNARY(exp = Absyn.INTEGER(value = intVal)) | ||
| 2191 | ✗ | then - intReal(intVal); | |
| 2192 | end match; | ||
| 2193 | end getValueFromExp; | ||
| 2194 | |||
| 2195 | protected function addContext "" | ||
| 2196 | input list<String> inList; | ||
| 2197 | input String newCon; | ||
| 2198 | output list<String> outList; | ||
| 2199 | algorithm | ||
| 2200 | outList := match(inList,newCon) | ||
| 2201 | local | ||
| 2202 | String str; | ||
| 2203 | list<String> strLst; | ||
| 2204 | case(strLst,str) | ||
| 2205 | then str :: strLst; | ||
| 2206 | end match; | ||
| 2207 | end addContext; | ||
| 2208 | |||
| 2209 | type Context = list<String>; | ||
| 2210 | type rgbColor = list<Integer>; | ||
| 2211 | type rgbColorMapList = list<rgbColor>; | ||
| 2212 | |||
| 2213 | constant rgbColorMapList colorMapList = { | ||
| 2214 | {0,0,0},{255,0,0},{0,255,0},{0,0,255},{0,255,255},{255,0,255},{255,255,0},{255,255,255},{192,192,192},{160,160,160}, | ||
| 2215 | {128,128,128},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}, | ||
| 2216 | {0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{235,235,235},{240,255,255},{0,0,0}, | ||
| 2217 | {0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{255,0,0},{191,0,0},{255,127,127}, | ||
| 2218 | {223,159,159},{255,127,0},{191,95,0},{255,191,127},{223,191,159},{255,255,0},{191,191,0},{255,255,127}, | ||
| 2219 | {223,223,159},{127,255,0},{95,191,0},{191,255,127},{191,223,159},{0,255,0},{0,191,0},{127,255,127}, | ||
| 2220 | {159,223,159},{0,255,127},{0,191,95},{127,255,191},{159,223,191},{0,255,255},{0,191,191},{127,255,255}, | ||
| 2221 | {159,223,223},{0,127,255},{0,95,191},{127,191,255},{159,191,223},{0,0,255},{0,0,191},{127,127,255}, | ||
| 2222 | {159,159,223},{127,0,255},{95,0,191},{191,127,255},{191,159,223},{255,0,255},{191,0,191},{255,127,255}, | ||
| 2223 | {223,159,223},{255,0,127},{191,0,95},{255,127,191},{223,159,191} | ||
| 2224 | }; | ||
| 2225 | |||
| 2226 | constant String None = "None"; | ||
| 2227 | constant String Solid = "Solid"; | ||
| 2228 | constant String Horizontal = "Horizontal"; | ||
| 2229 | constant String Vertical = "Vertical"; | ||
| 2230 | constant String Cross = "Cross"; | ||
| 2231 | constant String Forward = "Forward"; | ||
| 2232 | constant String Backward = "Backward"; | ||
| 2233 | constant String CrossDiag = "CrossDiag"; | ||
| 2234 | |||
| 2235 | constant String HorizontalCylinder = "HorizontalCylinder"; | ||
| 2236 | constant String VerticalCylinder = "VerticalCylinder"; | ||
| 2237 | constant String Sphere = "Sphere"; | ||
| 2238 | |||
| 2239 | constant String Dash = "Dash"; | ||
| 2240 | constant String Dot = "Dot"; | ||
| 2241 | constant String DashDot = "DashDot"; | ||
| 2242 | constant String DashDotDot = "DashDotDot"; | ||
| 2243 | constant String Filled = "Filled"; | ||
| 2244 | constant String Half = "Half"; | ||
| 2245 | |||
| 2246 | constant list<String> fillPatternMapList = { | ||
| 2247 | None,Solid,None,None,None,Horizontal, | ||
| 2248 | Vertical,Forward,Backward,Cross,CrossDiag | ||
| 2249 | }; | ||
| 2250 | |||
| 2251 | constant list<String> gradientMapList = { | ||
| 2252 | None,VerticalCylinder,HorizontalCylinder,Sphere | ||
| 2253 | }; | ||
| 2254 | constant list<String> patternMapList = { | ||
| 2255 | None,Solid,Dash,Dot,DashDot,DashDotDot | ||
| 2256 | }; | ||
| 2257 | constant list<Real> thicknessMapList = { | ||
| 2258 | 0.25,0.5,0.0,1.0 | ||
| 2259 | }; | ||
| 2260 | constant list<list<String>> arrowMapList = { | ||
| 2261 | {None,None}, {None,Filled}, {Filled,None}, {Filled,Filled}, {None,Half} | ||
| 2262 | }; | ||
| 2263 | |||
| 2264 | protected function fixPaths | ||
| 2265 | "@author adrpo | ||
| 2266 | this function takes a path1: X.Y.Z.K.L and a path2: Z.U.M | ||
| 2267 | and returns a path X.Y.Z.U.M | ||
| 2268 | " | ||
| 2269 | input Absyn.Path inPath1; | ||
| 2270 | input Absyn.Path inPath2; | ||
| 2271 | output Absyn.Path outPath; | ||
| 2272 | algorithm | ||
| 2273 | outPath := matchcontinue (inPath1, inPath2) | ||
| 2274 | local | ||
| 2275 | Absyn.Path ip1, ip2, p1; | ||
| 2276 | String str1, str2; | ||
| 2277 | Absyn.Path out; | ||
| 2278 | case (ip1, ip2) | ||
| 2279 | algorithm | ||
| 2280 | ✗ | str1 := AbsynUtil.pathLastIdent(ip1); | |
| 2281 | ✗ | str2 := AbsynUtil.pathFirstIdent(ip2); | |
| 2282 | ✗ | false := stringEq(str1, str2); | |
| 2283 | ✗ | p1 := AbsynUtil.stripLast(ip1); | |
| 2284 | ✗ | out := fixPaths(p1, ip2); | |
| 2285 | then | ||
| 2286 | out; | ||
| 2287 | |||
| 2288 | case (ip1, ip2) | ||
| 2289 | algorithm | ||
| 2290 | ✗ | str1 := AbsynUtil.pathLastIdent(ip1); | |
| 2291 | ✗ | str2 := AbsynUtil.pathFirstIdent(ip2); | |
| 2292 | ✗ | true := stringEq(str1, str2); | |
| 2293 | ✗ | p1 := AbsynUtil.stripLast(ip1); | |
| 2294 | ✗ | out := AbsynUtil.joinPaths(p1, ip2); | |
| 2295 | then | ||
| 2296 | out; | ||
| 2297 | |||
| 2298 | else inPath2; // if everything else fails, return inPath2 | ||
| 2299 | |||
| 2300 | end matchcontinue; | ||
| 2301 | end fixPaths; | ||
| 2302 | |||
| 2303 | annotation(__OpenModelica_Interface="backend_main"); | ||
| 2304 | end Refactor; | ||
| 2305 |