Changeset 3c46939 in OpenModelica
- Timestamp:
- 2020-10-21T14:46:11+02:00 (3 years ago)
- Children:
- 8dbe6e6
- Parents:
- feadc57b
- git-author:
- Adrian Pop <adrian.pop@…> (10/09/20 15:08:54)
- git-committer:
- Adrian Pop <adrian.pop@…> (10/21/20 14:46:11)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
OMCompiler/Compiler/FrontEnd/AbsynUtil.mo
r6b807b93 r3c46939 32 32 encapsulated package AbsynUtil 33 33 34 protected import Absyn .*;34 protected import Absyn; 35 35 protected import Dump; 36 36 protected import Error; … … 39 39 protected import Util; 40 40 41 public constant ClassDef dummyParts =PARTS({},{},{},{},NONE());42 public constant Info dummyInfo = SOURCEINFO("",false,0,0,0,0,0.0);43 public constant Program dummyProgram = PROGRAM({},TOP());41 public constant Absyn.ClassDef dummyParts = Absyn.PARTS({},{},{},{},NONE()); 42 public constant Absyn.Info dummyInfo = SOURCEINFO("",false,0,0,0,0,0.0); 43 public constant Absyn.Program dummyProgram = Absyn.PROGRAM({},Absyn.TOP()); 44 44 45 45 replaceable type TypeA subtypeof Any; … … 52 52 "Traverses all subequations of an equation. 53 53 Takes a function and an extra argument passed through the traversal" 54 input Equation inEquation;54 input Absyn.Equation inEquation; 55 55 input FuncTplToTpl inFunc; 56 56 input TypeA inTypeA; 57 output tuple< Equation, TypeA> outTpl;57 output tuple<Absyn.Equation, TypeA> outTpl; 58 58 59 59 partial function FuncTplToTpl 60 input tuple< Equation, TypeA> inTpl;61 output tuple< Equation, TypeA> outTpl;60 input tuple<Absyn.Equation, TypeA> inTpl; 61 output tuple<Absyn.Equation, TypeA> outTpl; 62 62 end FuncTplToTpl; 63 63 … … 66 66 local 67 67 TypeA arg,arg_1,arg_2,arg_3,arg_4; 68 Equation eq,eq_1;68 Absyn.Equation eq,eq_1; 69 69 FuncTplToTpl rel; 70 Exp e,e_1;71 list< EquationItem> eqilst,eqilst1,eqilst2,eqilst_1,eqilst1_1,eqilst2_1;72 list<tuple< Exp, list<EquationItem>>> eeqitlst,eeqitlst_1;73 ForIterators fis,fis_1;74 EquationItem ei,ei_1;75 case(eq as EQ_IF(e,eqilst1,eeqitlst,eqilst2),rel,arg)70 Absyn.Exp e,e_1; 71 list<Absyn.EquationItem> eqilst,eqilst1,eqilst2,eqilst_1,eqilst1_1,eqilst2_1; 72 list<tuple<Absyn.Exp, list<Absyn.EquationItem>>> eeqitlst,eeqitlst_1; 73 Absyn.ForIterators fis,fis_1; 74 Absyn.EquationItem ei,ei_1; 75 case(eq as Absyn.EQ_IF(e,eqilst1,eeqitlst,eqilst2),rel,arg) 76 76 equation 77 77 ((eqilst1_1,arg_1)) = traverseEquationItemList(eqilst1,rel,arg); 78 78 ((eeqitlst_1,arg_2)) = traverseExpEqItemTupleList(eeqitlst,rel,arg_1); 79 79 ((eqilst2_1,arg_3)) = traverseEquationItemList(eqilst2,rel,arg_2); 80 (( EQ_IF(),arg_4)) = rel((eq,arg_3));81 then 82 (( EQ_IF(e,eqilst1_1,eeqitlst_1,eqilst2_1),arg_4));83 case(eq as EQ_FOR(_,eqilst),rel,arg)80 ((Absyn.EQ_IF(),arg_4)) = rel((eq,arg_3)); 81 then 82 ((Absyn.EQ_IF(e,eqilst1_1,eeqitlst_1,eqilst2_1),arg_4)); 83 case(eq as Absyn.EQ_FOR(_,eqilst),rel,arg) 84 84 equation 85 85 ((eqilst_1,arg_1)) = traverseEquationItemList(eqilst,rel,arg); 86 (( EQ_FOR(fis_1,_),arg_2)) = rel((eq,arg_1));87 then 88 (( EQ_FOR(fis_1,eqilst_1),arg_2));89 case(eq as EQ_WHEN_E(_,eqilst,eeqitlst),rel,arg)86 ((Absyn.EQ_FOR(fis_1,_),arg_2)) = rel((eq,arg_1)); 87 then 88 ((Absyn.EQ_FOR(fis_1,eqilst_1),arg_2)); 89 case(eq as Absyn.EQ_WHEN_E(_,eqilst,eeqitlst),rel,arg) 90 90 equation 91 91 ((eqilst_1,arg_1)) = traverseEquationItemList(eqilst,rel,arg); 92 92 ((eeqitlst_1,arg_2)) = traverseExpEqItemTupleList(eeqitlst,rel,arg_1); 93 (( EQ_WHEN_E(e_1,_,_),arg_3)) = rel((eq,arg_2));94 then 95 (( EQ_WHEN_E(e_1,eqilst_1,eeqitlst_1),arg_3));96 case(eq as EQ_FAILURE(ei),rel,arg)93 ((Absyn.EQ_WHEN_E(e_1,_,_),arg_3)) = rel((eq,arg_2)); 94 then 95 ((Absyn.EQ_WHEN_E(e_1,eqilst_1,eeqitlst_1),arg_3)); 96 case(eq as Absyn.EQ_FAILURE(ei),rel,arg) 97 97 equation 98 98 ((ei_1,arg_1)) = traverseEquationItem(ei,rel,arg); 99 (( EQ_FAILURE(),arg_2)) = rel((eq,arg_1));100 then 101 (( EQ_FAILURE(ei_1),arg_2));99 ((Absyn.EQ_FAILURE(),arg_2)) = rel((eq,arg_1)); 100 then 101 ((Absyn.EQ_FAILURE(ei_1),arg_2)); 102 102 case(eq,rel,arg) 103 103 equation … … 111 111 protected function traverseEquationItem 112 112 "Traverses the equation inside an equationitem" 113 input EquationItem inEquationItem;113 input Absyn.EquationItem inEquationItem; 114 114 input FuncTplToTpl inFunc; 115 115 input TypeA inTypeA; 116 output tuple< EquationItem, TypeA> outTpl;116 output tuple<Absyn.EquationItem, TypeA> outTpl; 117 117 partial function FuncTplToTpl 118 input tuple< Equation, TypeA> inTpl;119 output tuple< Equation, TypeA> outTpl;118 input tuple<Absyn.Equation, TypeA> inTpl; 119 output tuple<Absyn.Equation, TypeA> outTpl; 120 120 end FuncTplToTpl; 121 121 algorithm 122 122 outTpl := matchcontinue (inEquationItem,inFunc,inTypeA) 123 123 local 124 EquationItem ei;124 Absyn.EquationItem ei; 125 125 FuncTplToTpl rel; 126 126 TypeA arg,arg_1; 127 Equation eq,eq_1;128 Option< Comment> oc;129 Info info;130 case( EQUATIONITEM(eq,oc,info),rel,arg)127 Absyn.Equation eq,eq_1; 128 Option<Absyn.Comment> oc; 129 Absyn.Info info; 130 case(Absyn.EQUATIONITEM(eq,oc,info),rel,arg) 131 131 equation 132 132 ((eq_1,arg_1)) = traverseEquation(eq,rel,arg); 133 133 then 134 (( EQUATIONITEM(eq_1,oc,info),arg_1));134 ((Absyn.EQUATIONITEM(eq_1,oc,info),arg_1)); 135 135 case(ei,_,arg) then ((ei,arg)); 136 136 end matchcontinue; … … 140 140 public function traverseEquationItemList 141 141 "calls traverseEquationItem on every element of the given list" 142 input list< EquationItem> inEquationItemList;142 input list<Absyn.EquationItem> inEquationItemList; 143 143 input FuncTplToTpl inFunc; 144 144 input TypeA inTypeA; 145 output tuple<list< EquationItem>, TypeA> outTpl;145 output tuple<list<Absyn.EquationItem>, TypeA> outTpl; 146 146 partial function FuncTplToTpl 147 input tuple< Equation, TypeA> inTpl;148 output tuple< Equation, TypeA> outTpl;147 input tuple<Absyn.Equation, TypeA> inTpl; 148 output tuple<Absyn.Equation, TypeA> outTpl; 149 149 end FuncTplToTpl; 150 150 protected … … 153 153 outTpl := (list(match el 154 154 local 155 EquationItem ei,ei_1;155 Absyn.EquationItem ei,ei_1; 156 156 case (ei) equation 157 157 ((ei_1,arg2)) = traverseEquationItem(ei,inFunc,arg2); … … 162 162 // stefan 163 163 public function traverseExpEqItemTupleList 164 "traverses a list of Exp *EquationItem list tuples164 "traverses a list of Absyn.Exp * Absyn.EquationItem list tuples 165 165 mostly used for else-if blocks" 166 input list<tuple< Exp, list<EquationItem>>> inList;166 input list<tuple<Absyn.Exp, list<Absyn.EquationItem>>> inList; 167 167 input FuncTplToTpl inFunc; 168 168 input TypeA inTypeA; 169 output tuple<list<tuple< Exp, list<EquationItem>>>, TypeA> outTpl;169 output tuple<list<tuple<Absyn.Exp, list<Absyn.EquationItem>>>, TypeA> outTpl; 170 170 partial function FuncTplToTpl 171 input tuple< Equation, TypeA> inTpl;172 output tuple< Equation, TypeA> outTpl;171 input tuple<Absyn.Equation, TypeA> inTpl; 172 output tuple<Absyn.Equation, TypeA> outTpl; 173 173 end FuncTplToTpl; 174 174 protected … … 177 177 outTpl := (list(match el 178 178 local 179 Exp e;180 list< EquationItem> eilst,eilst_1;179 Absyn.Exp e; 180 list<Absyn.EquationItem> eilst,eilst_1; 181 181 case (e,eilst) equation 182 182 ((eilst_1,arg2)) = traverseEquationItemList(eilst,inFunc,arg2); … … 189 189 "Traverses all subalgorithms of an algorithm 190 190 Takes a function and an extra argument passed through the traversal" 191 input A lgorithm inAlgorithm;191 input Absyn.Algorithm inAlgorithm; 192 192 input FuncTplToTpl inFunc; 193 193 input TypeA inTypeA; 194 output tuple<A lgorithm, TypeA> outTpl;194 output tuple<Absyn.Algorithm, TypeA> outTpl; 195 195 partial function FuncTplToTpl 196 input tuple<A lgorithm, TypeA> inTpl;197 output tuple<A lgorithm, TypeA> outTpl;196 input tuple<Absyn.Algorithm, TypeA> inTpl; 197 output tuple<Absyn.Algorithm, TypeA> outTpl; 198 198 end FuncTplToTpl; 199 199 algorithm … … 201 201 local 202 202 TypeA arg,arg_1,arg1_1,arg2_1,arg3_1; 203 A lgorithm alg,alg_1,alg1_1,alg2_1,alg3_1;204 list<A lgorithmItem> ailst,ailst1,ailst2,ailst_1,ailst1_1,ailst2_1;205 list<tuple< Exp, list<AlgorithmItem>>> eaitlst,eaitlst_1;203 Absyn.Algorithm alg,alg_1,alg1_1,alg2_1,alg3_1; 204 list<Absyn.AlgorithmItem> ailst,ailst1,ailst2,ailst_1,ailst1_1,ailst2_1; 205 list<tuple<Absyn.Exp, list<Absyn.AlgorithmItem>>> eaitlst,eaitlst_1; 206 206 FuncTplToTpl rel; 207 A lgorithmItem ai,ai_1;208 Exp e,e_1;209 ForIterators fis,fis_1;210 case(alg as A LG_IF(_,ailst1,eaitlst,ailst2),rel,arg)207 Absyn.AlgorithmItem ai,ai_1; 208 Absyn.Exp e,e_1; 209 Absyn.ForIterators fis,fis_1; 210 case(alg as Absyn.ALG_IF(_,ailst1,eaitlst,ailst2),rel,arg) 211 211 equation 212 212 ((ailst1_1,arg1_1)) = traverseAlgorithmItemList(ailst1,rel,arg); 213 213 ((eaitlst_1,arg2_1)) = traverseExpAlgItemTupleList(eaitlst,rel,arg1_1); 214 214 ((ailst2_1,arg3_1)) = traverseAlgorithmItemList(ailst2,rel,arg2_1); 215 ((A LG_IF(e_1,_,_,_),arg_1)) = rel((alg,arg3_1));216 then 217 ((A LG_IF(e_1,ailst1_1,eaitlst_1,ailst2_1),arg_1));218 case(alg as A LG_FOR(_,ailst),rel,arg)215 ((Absyn.ALG_IF(e_1,_,_,_),arg_1)) = rel((alg,arg3_1)); 216 then 217 ((Absyn.ALG_IF(e_1,ailst1_1,eaitlst_1,ailst2_1),arg_1)); 218 case(alg as Absyn.ALG_FOR(_,ailst),rel,arg) 219 219 equation 220 220 ((ailst_1,arg1_1)) = traverseAlgorithmItemList(ailst,rel,arg); 221 ((A LG_FOR(fis_1,_),arg_1)) = rel((alg,arg1_1));222 then 223 ((A LG_FOR(fis_1,ailst_1),arg_1));224 case(alg as A LG_PARFOR(_,ailst),rel,arg)221 ((Absyn.ALG_FOR(fis_1,_),arg_1)) = rel((alg,arg1_1)); 222 then 223 ((Absyn.ALG_FOR(fis_1,ailst_1),arg_1)); 224 case(alg as Absyn.ALG_PARFOR(_,ailst),rel,arg) 225 225 equation 226 226 ((ailst_1,arg1_1)) = traverseAlgorithmItemList(ailst,rel,arg); 227 ((A LG_PARFOR(fis_1,_),arg_1)) = rel((alg,arg1_1));228 then 229 ((A LG_PARFOR(fis_1,ailst_1),arg_1));230 case(alg as A LG_WHILE(_,ailst),rel,arg)227 ((Absyn.ALG_PARFOR(fis_1,_),arg_1)) = rel((alg,arg1_1)); 228 then 229 ((Absyn.ALG_PARFOR(fis_1,ailst_1),arg_1)); 230 case(alg as Absyn.ALG_WHILE(_,ailst),rel,arg) 231 231 equation 232 232 ((ailst_1,arg1_1)) = traverseAlgorithmItemList(ailst,rel,arg); 233 ((A LG_WHILE(e_1,_),arg_1)) = rel((alg,arg1_1));234 then 235 ((A LG_WHILE(e_1,ailst_1),arg_1));236 case(alg as A LG_WHEN_A(_,ailst,eaitlst),rel,arg)233 ((Absyn.ALG_WHILE(e_1,_),arg_1)) = rel((alg,arg1_1)); 234 then 235 ((Absyn.ALG_WHILE(e_1,ailst_1),arg_1)); 236 case(alg as Absyn.ALG_WHEN_A(_,ailst,eaitlst),rel,arg) 237 237 equation 238 238 ((ailst_1,arg1_1)) = traverseAlgorithmItemList(ailst,rel,arg); 239 239 ((eaitlst_1,arg2_1)) = traverseExpAlgItemTupleList(eaitlst,rel,arg1_1); 240 ((A LG_WHEN_A(e_1,_,_),arg_1)) = rel((alg,arg2_1));241 then 242 ((A LG_WHEN_A(e_1,ailst_1,eaitlst_1),arg_1));240 ((Absyn.ALG_WHEN_A(e_1,_,_),arg_1)) = rel((alg,arg2_1)); 241 then 242 ((Absyn.ALG_WHEN_A(e_1,ailst_1,eaitlst_1),arg_1)); 243 243 case(alg,rel,arg) 244 244 equation … … 251 251 // stefan 252 252 public function traverseAlgorithmItem 253 "traverses the A lgorithm contained in anAlgorithmItem, if any253 "traverses the Absyn.Algorithm contained in an Absyn.AlgorithmItem, if any 254 254 see traverseAlgorithm" 255 input A lgorithmItem inAlgorithmItem;255 input Absyn.AlgorithmItem inAlgorithmItem; 256 256 input FuncTplToTpl inFunc; 257 257 input TypeA inTypeA; 258 output tuple<A lgorithmItem, TypeA> outTpl;258 output tuple<Absyn.AlgorithmItem, TypeA> outTpl; 259 259 partial function FuncTplToTpl 260 input tuple<A lgorithm, TypeA> inTpl;261 output tuple<A lgorithm, TypeA> outTpl;260 input tuple<Absyn.Algorithm, TypeA> inTpl; 261 output tuple<Absyn.Algorithm, TypeA> outTpl; 262 262 end FuncTplToTpl; 263 263 algorithm … … 266 266 FuncTplToTpl rel; 267 267 TypeA arg,arg_1; 268 A lgorithm alg,alg_1;269 Option< Comment> oc;270 A lgorithmItem ai;271 Info info;272 case(A LGORITHMITEM(alg,oc,info),rel,arg)268 Absyn.Algorithm alg,alg_1; 269 Option<Absyn.Comment> oc; 270 Absyn.AlgorithmItem ai; 271 Absyn.Info info; 272 case(Absyn.ALGORITHMITEM(alg,oc,info),rel,arg) 273 273 equation 274 274 ((alg_1,arg_1)) = traverseAlgorithm(alg,rel,arg); 275 275 then 276 ((A LGORITHMITEM(alg_1,oc,info),arg_1));276 ((Absyn.ALGORITHMITEM(alg_1,oc,info),arg_1)); 277 277 case(ai,_,arg) then ((ai,arg)); 278 278 end matchcontinue; … … 282 282 public function traverseAlgorithmItemList 283 283 "calls traverseAlgorithmItem on each item in a list of AlgorithmItems" 284 input list<A lgorithmItem> inAlgorithmItemList;284 input list<Absyn.AlgorithmItem> inAlgorithmItemList; 285 285 input FuncTplToTpl inFunc; 286 286 input TypeA inTypeA; 287 output tuple<list<A lgorithmItem>, TypeA> outTpl;287 output tuple<list<Absyn.AlgorithmItem>, TypeA> outTpl; 288 288 partial function FuncTplToTpl 289 input tuple<A lgorithm, TypeA> inTpl;290 output tuple<A lgorithm, TypeA> outTpl;289 input tuple<Absyn.Algorithm, TypeA> inTpl; 290 output tuple<Absyn.Algorithm, TypeA> outTpl; 291 291 end FuncTplToTpl; 292 292 algorithm … … 295 295 FuncTplToTpl rel; 296 296 TypeA arg,arg_1,arg_2; 297 A lgorithmItem ai,ai_1;298 list<A lgorithmItem> cdr,cdr_1;297 Absyn.AlgorithmItem ai,ai_1; 298 list<Absyn.AlgorithmItem> cdr,cdr_1; 299 299 case({},_,arg) then (({},arg)); 300 300 case(ai :: cdr,rel,arg) … … 309 309 // stefan 310 310 public function traverseExpAlgItemTupleList 311 "traverses a list of Exp *AlgorithmItem list tuples311 "traverses a list of Absyn.Exp * Absyn.AlgorithmItem list tuples 312 312 mostly used for else-if blocks" 313 input list<tuple< Exp, list<AlgorithmItem>>> inList;313 input list<tuple<Absyn.Exp, list<Absyn.AlgorithmItem>>> inList; 314 314 input FuncTplToTpl inFunc; 315 315 input TypeA inTypeA; 316 output tuple<list<tuple< Exp, list<AlgorithmItem>>>, TypeA> outTpl;316 output tuple<list<tuple<Absyn.Exp, list<Absyn.AlgorithmItem>>>, TypeA> outTpl; 317 317 partial function FuncTplToTpl 318 input tuple<A lgorithm, TypeA> inTpl;319 output tuple<A lgorithm, TypeA> outTpl;318 input tuple<Absyn.Algorithm, TypeA> inTpl; 319 output tuple<Absyn.Algorithm, TypeA> outTpl; 320 320 end FuncTplToTpl; 321 321 algorithm … … 324 324 FuncTplToTpl rel; 325 325 TypeA arg,arg_1,arg_2; 326 list<tuple< Exp, list<AlgorithmItem>>> cdr,cdr_1;327 Exp e;328 list<A lgorithmItem> ailst,ailst_1;326 list<tuple<Absyn.Exp, list<Absyn.AlgorithmItem>>> cdr,cdr_1; 327 Absyn.Exp e; 328 list<Absyn.AlgorithmItem> ailst,ailst_1; 329 329 case({},_,arg) then (({},arg)); 330 330 case((e,ailst) :: cdr,rel,arg) … … 338 338 339 339 public function traverseExp 340 " Traverses all subexpressions of an Exp expression.340 " Traverses all subexpressions of an Absyn.Exp expression. 341 341 Takes a function and an extra argument passed through the traversal. 342 342 NOTE:This function was copied from Expression.traverseExpression." 343 input Exp inExp;343 input Absyn.Exp inExp; 344 344 input FuncType inFunc; 345 345 input Type_a inArg; 346 output Exp outExp;346 output Absyn.Exp outExp; 347 347 output Type_a outArg; 348 348 partial function FuncType 349 input Exp inExp;349 input Absyn.Exp inExp; 350 350 input Type_a inArg; 351 output Exp outExp;351 output Absyn.Exp outExp; 352 352 output Type_a outArg; 353 353 end FuncType; … … 357 357 358 358 public function traverseExpTopDown 359 " Traverses all subexpressions of an Exp expression.359 " Traverses all subexpressions of an Absyn.Exp expression. 360 360 Takes a function and an extra argument passed through the traversal." 361 input Exp inExp;361 input Absyn.Exp inExp; 362 362 input FuncType inFunc; 363 363 input Type_a inArg; 364 output Exp outExp;364 output Absyn.Exp outExp; 365 365 output Type_a outArg; 366 366 partial function FuncType 367 input Exp inExp;367 input Absyn.Exp inExp; 368 368 input Type_a inArg; 369 output Exp outExp;369 output Absyn.Exp outExp; 370 370 output Type_a outArg; 371 371 end FuncType; … … 376 376 public function traverseExpList 377 377 "calls traverseExp on each element in the given list" 378 input list< Exp> inExpList;378 input list<Absyn.Exp> inExpList; 379 379 input FuncTplToTpl inFunc; 380 380 input Type_a inArg; 381 output list< Exp> outExpList;381 output list<Absyn.Exp> outExpList; 382 382 output Type_a outArg; 383 383 partial function FuncTplToTpl 384 input Exp inExp;384 input Absyn.Exp inExp; 385 385 input Type_a inArg; 386 output Exp outExp;386 output Absyn.Exp outExp; 387 387 output Type_a outArg; 388 388 end FuncTplToTpl; … … 394 394 "Traverses a list of expressions, calling traverseExpBidir on each 395 395 expression." 396 input list< Exp> inExpl;396 input list<Absyn.Exp> inExpl; 397 397 input FuncType enterFunc; 398 398 input FuncType exitFunc; 399 399 input Argument inArg; 400 output list< Exp> outExpl;400 output list<Absyn.Exp> outExpl; 401 401 output Argument outArg; 402 402 partial function FuncType 403 input Exp inExp;403 input Absyn.Exp inExp; 404 404 input Argument inArg; 405 output Exp outExp;405 output Absyn.Exp outExp; 406 406 output Argument outArg; 407 407 end FuncType; … … 418 418 the updated argument. This means that this function is bidirectional, and can 419 419 be used to emulate both top-down and bottom-up traversal." 420 input Exp inExp;420 input Absyn.Exp inExp; 421 421 input FuncType enterFunc; 422 422 input FuncType exitFunc; 423 423 input Argument inArg; 424 output Exp e;424 output Absyn.Exp e; 425 425 output Argument arg; 426 426 427 427 partial function FuncType 428 input Exp inExp;428 input Absyn.Exp inExp; 429 429 input Argument inArg; 430 output Exp outExp;430 output Absyn.Exp outExp; 431 431 output Argument outArg; 432 432 end FuncType; … … 442 442 traverseExpBidir if the option is SOME(), or just returns the input if it's 443 443 NONE()" 444 input Option< Exp> inExp;444 input Option<Absyn.Exp> inExp; 445 445 input FuncType enterFunc; 446 446 input FuncType exitFunc; 447 447 input Argument inArg; 448 output Option< Exp> outExp;448 output Option<Absyn.Exp> outExp; 449 449 output Argument arg; 450 450 451 451 partial function FuncType 452 input Exp inExp;452 input Absyn.Exp inExp; 453 453 input Argument inArg; 454 output Exp outExp;454 output Absyn.Exp outExp; 455 455 output Argument outArg; 456 456 end FuncType; … … 459 459 (outExp, arg) := match(inExp, enterFunc, exitFunc, inArg) 460 460 local 461 Exp e1,e2;461 Absyn.Exp e1,e2; 462 462 tuple<FuncType, FuncType, Argument> tup; 463 463 … … 475 475 "Helper function to traverseExpBidir. Traverses the subexpressions of an 476 476 expression and calls traverseExpBidir on them." 477 input Exp inExp;477 input Absyn.Exp inExp; 478 478 input FuncType enterFunc; 479 479 input FuncType exitFunc; 480 480 input Argument inArg; 481 output Exp e;481 output Absyn.Exp e; 482 482 output Argument arg; 483 483 484 484 partial function FuncType 485 input Exp inExp;485 input Absyn.Exp inExp; 486 486 input Argument inArg; 487 output Exp outExp;487 output Absyn.Exp outExp; 488 488 output Argument outArg; 489 489 end FuncType; … … 492 492 (e, arg) := match (inExp, enterFunc, exitFunc, inArg) 493 493 local 494 Exp e1, e1m, e2, e2m, e3, e3m;495 Option< Exp> oe1, oe1m;494 Absyn.Exp e1, e1m, e2, e2m, e3, e3m; 495 Option<Absyn.Exp> oe1, oe1m; 496 496 tuple<FuncType, FuncType, Argument> tup; 497 Operator op;498 ComponentRef cref, crefm;499 list<tuple< Exp,Exp>> else_ifs1,else_ifs2;500 list< Exp> expl1,expl2;501 list<list< Exp>> mat_expl;502 FunctionArgs fargs1,fargs2;497 Absyn.Operator op; 498 Absyn.ComponentRef cref, crefm; 499 list<tuple<Absyn.Exp, Absyn.Exp>> else_ifs1,else_ifs2; 500 list<Absyn.Exp> expl1,expl2; 501 list<list<Absyn.Exp>> mat_expl; 502 Absyn.FunctionArgs fargs1,fargs2; 503 503 String error_msg; 504 Ident id, enterName, exitName;505 MatchType match_ty;506 list< ElementItem> match_decls;507 list< Case> match_cases;504 Absyn.Ident id, enterName, exitName; 505 Absyn.MatchType match_ty; 506 list<Absyn.ElementItem> match_decls; 507 list<Absyn.Case> match_cases; 508 508 Option<String> cmt; 509 509 510 case ( INTEGER(), _, _, _) then (inExp, inArg);511 case ( REAL(), _, _, _) then (inExp, inArg);512 case ( STRING(), _, _, _) then (inExp, inArg);513 case ( BOOL(), _, _, _) then (inExp, inArg);514 515 case ( CREF(componentRef = cref), _, _, arg)510 case (Absyn.INTEGER(), _, _, _) then (inExp, inArg); 511 case (Absyn.REAL(), _, _, _) then (inExp, inArg); 512 case (Absyn.STRING(), _, _, _) then (inExp, inArg); 513 case (Absyn.BOOL(), _, _, _) then (inExp, inArg); 514 515 case (Absyn.CREF(componentRef = cref), _, _, arg) 516 516 equation 517 517 (crefm, arg) = traverseExpBidirCref(cref, enterFunc, exitFunc, arg); 518 518 then 519 (if referenceEq(cref,crefm) then inExp else CREF(crefm), arg);520 521 case ( BINARY(exp1 = e1, op = op, exp2 = e2), _, _, arg)519 (if referenceEq(cref,crefm) then inExp else Absyn.CREF(crefm), arg); 520 521 case (Absyn.BINARY(exp1 = e1, op = op, exp2 = e2), _, _, arg) 522 522 equation 523 523 (e1m, arg) = traverseExpBidir(e1, enterFunc, exitFunc, arg); 524 524 (e2m, arg) = traverseExpBidir(e2, enterFunc, exitFunc, arg); 525 525 then 526 (if referenceEq(e1,e1m) and referenceEq(e2,e2m) then inExp else BINARY(e1m, op, e2m), arg);527 528 case ( UNARY(op = op, exp = e1), _, _, arg)526 (if referenceEq(e1,e1m) and referenceEq(e2,e2m) then inExp else Absyn.BINARY(e1m, op, e2m), arg); 527 528 case (Absyn.UNARY(op = op, exp = e1), _, _, arg) 529 529 equation 530 530 (e1m, arg) = traverseExpBidir(e1, enterFunc, exitFunc, arg); 531 531 then 532 (if referenceEq(e1,e1m) then inExp else UNARY(op, e1m), arg);533 534 case ( LBINARY(exp1 = e1, op = op, exp2 = e2), _, _, arg)532 (if referenceEq(e1,e1m) then inExp else Absyn.UNARY(op, e1m), arg); 533 534 case (Absyn.LBINARY(exp1 = e1, op = op, exp2 = e2), _, _, arg) 535 535 equation 536 536 (e1m, arg) = traverseExpBidir(e1, enterFunc, exitFunc, arg); 537 537 (e2m, arg) = traverseExpBidir(e2, enterFunc, exitFunc, arg); 538 538 then 539 (if referenceEq(e1,e1m) and referenceEq(e2,e2m) then inExp else LBINARY(e1m, op, e2m), arg);540 541 case ( LUNARY(op = op, exp = e1), _, _, arg)539 (if referenceEq(e1,e1m) and referenceEq(e2,e2m) then inExp else Absyn.LBINARY(e1m, op, e2m), arg); 540 541 case (Absyn.LUNARY(op = op, exp = e1), _, _, arg) 542 542 equation 543 543 (e1m, arg) = traverseExpBidir(e1, enterFunc, exitFunc, arg); 544 544 then 545 (if referenceEq(e1,e1m) then inExp else LUNARY(op, e1m), arg);546 547 case ( RELATION(exp1 = e1, op = op, exp2 = e2), _, _, arg)545 (if referenceEq(e1,e1m) then inExp else Absyn.LUNARY(op, e1m), arg); 546 547 case (Absyn.RELATION(exp1 = e1, op = op, exp2 = e2), _, _, arg) 548 548 equation 549 549 (e1m, arg) = traverseExpBidir(e1, enterFunc, exitFunc, arg); 550 550 (e2m, arg) = traverseExpBidir(e2, enterFunc, exitFunc, arg); 551 551 then 552 (if referenceEq(e1,e1m) and referenceEq(e2,e2m) then inExp else RELATION(e1m, op, e2m), arg);553 554 case ( IFEXP(ifExp = e1, trueBranch = e2, elseBranch = e3,552 (if referenceEq(e1,e1m) and referenceEq(e2,e2m) then inExp else Absyn.RELATION(e1m, op, e2m), arg); 553 554 case (Absyn.IFEXP(ifExp = e1, trueBranch = e2, elseBranch = e3, 555 555 elseIfBranch = else_ifs1), _, _, arg) 556 556 equation … … 560 560 (else_ifs2, arg) = List.map2FoldCheckReferenceEq(else_ifs1, traverseExpBidirElseIf, enterFunc, exitFunc, arg); 561 561 then 562 (if referenceEq(e1,e1m) and referenceEq(e2,e2m) and referenceEq(e3,e3m) and referenceEq(else_ifs1,else_ifs2) then inExp else IFEXP(e1m, e2m, e3m, else_ifs2), arg);563 564 case ( CALL(function_ = cref, functionArgs = fargs1), _, _, arg)562 (if referenceEq(e1,e1m) and referenceEq(e2,e2m) and referenceEq(e3,e3m) and referenceEq(else_ifs1,else_ifs2) then inExp else Absyn.IFEXP(e1m, e2m, e3m, else_ifs2), arg); 563 564 case (Absyn.CALL(function_ = cref, functionArgs = fargs1), _, _, arg) 565 565 equation 566 566 (fargs2, arg) = traverseExpBidirFunctionArgs(fargs1, enterFunc, exitFunc, arg); 567 567 then 568 (if referenceEq(fargs1,fargs2) then inExp else CALL(cref, fargs2), arg);569 570 case ( PARTEVALFUNCTION(function_ = cref, functionArgs = fargs1), _, _, arg)568 (if referenceEq(fargs1,fargs2) then inExp else Absyn.CALL(cref, fargs2), arg); 569 570 case (Absyn.PARTEVALFUNCTION(function_ = cref, functionArgs = fargs1), _, _, arg) 571 571 equation 572 572 (fargs2, arg) = traverseExpBidirFunctionArgs(fargs1, enterFunc, exitFunc, arg); 573 573 then 574 (if referenceEq(fargs1,fargs2) then inExp else PARTEVALFUNCTION(cref, fargs2), arg);575 576 case (A RRAY(arrayExp = expl1), _, _, arg)574 (if referenceEq(fargs1,fargs2) then inExp else Absyn.PARTEVALFUNCTION(cref, fargs2), arg); 575 576 case (Absyn.ARRAY(arrayExp = expl1), _, _, arg) 577 577 equation 578 578 (expl2, arg) = traverseExpListBidir(expl1, enterFunc, exitFunc, arg); 579 579 then 580 (if referenceEq(expl1,expl2) then inExp else A RRAY(expl2), arg);581 582 case ( MATRIX(matrix = mat_expl), _, _, arg)580 (if referenceEq(expl1,expl2) then inExp else Absyn.ARRAY(expl2), arg); 581 582 case (Absyn.MATRIX(matrix = mat_expl), _, _, arg) 583 583 equation 584 584 (mat_expl, arg) = List.map2FoldCheckReferenceEq(mat_expl, traverseExpListBidir, enterFunc, exitFunc, arg); 585 585 then 586 ( MATRIX(mat_expl), arg);587 588 case ( RANGE(start = e1, step = oe1, stop = e2), _, _, arg)586 (Absyn.MATRIX(mat_expl), arg); 587 588 case (Absyn.RANGE(start = e1, step = oe1, stop = e2), _, _, arg) 589 589 equation 590 590 (e1m, arg) = traverseExpBidir(e1, enterFunc, exitFunc, arg); … … 592 592 (e2m, arg) = traverseExpBidir(e2, enterFunc, exitFunc, arg); 593 593 then 594 (if referenceEq(e1,e1m) and referenceEq(e2,e2m) and referenceEq(oe1,oe1m) then inExp else RANGE(e1m, oe1m, e2m), arg);595 596 case ( END(), _, _, _) then (inExp, inArg);597 598 case ( TUPLE(expressions = expl1), _, _, arg)594 (if referenceEq(e1,e1m) and referenceEq(e2,e2m) and referenceEq(oe1,oe1m) then inExp else Absyn.RANGE(e1m, oe1m, e2m), arg); 595 596 case (Absyn.END(), _, _, _) then (inExp, inArg); 597 598 case (Absyn.TUPLE(expressions = expl1), _, _, arg) 599 599 equation 600 600 (expl2, arg) = traverseExpListBidir(expl1, enterFunc, exitFunc, arg); 601 601 then 602 (if referenceEq(expl1,expl2) then inExp else TUPLE(expl2), arg);603 604 case (A S(id = id, exp = e1), _, _, arg)602 (if referenceEq(expl1,expl2) then inExp else Absyn.TUPLE(expl2), arg); 603 604 case (Absyn.AS(id = id, exp = e1), _, _, arg) 605 605 equation 606 606 (e1m, arg) = traverseExpBidir(e1, enterFunc, exitFunc, arg); 607 607 then 608 (if referenceEq(e1,e1m) then inExp else A S(id, e1m), arg);609 610 case ( CONS(head = e1, rest = e2), _, _, arg)608 (if referenceEq(e1,e1m) then inExp else Absyn.AS(id, e1m), arg); 609 610 case (Absyn.CONS(head = e1, rest = e2), _, _, arg) 611 611 equation 612 612 (e1m, arg) = traverseExpBidir(e1, enterFunc, exitFunc, arg); 613 613 (e2m, arg) = traverseExpBidir(e2, enterFunc, exitFunc, arg); 614 614 then 615 (if referenceEq(e1,e1m) and referenceEq(e2,e2m) then inExp else CONS(e1m, e2m), arg);616 617 case ( MATCHEXP(matchTy = match_ty, inputExp = e1, localDecls = match_decls,615 (if referenceEq(e1,e1m) and referenceEq(e2,e2m) then inExp else Absyn.CONS(e1m, e2m), arg); 616 617 case (Absyn.MATCHEXP(matchTy = match_ty, inputExp = e1, localDecls = match_decls, 618 618 cases = match_cases, comment = cmt), _, _, arg) 619 619 equation … … 621 621 (match_cases, arg) = List.map2FoldCheckReferenceEq(match_cases, traverseMatchCase, enterFunc, exitFunc, arg); 622 622 then 623 ( MATCHEXP(match_ty, e1, match_decls, match_cases, cmt), arg);624 625 case ( LIST(exps = expl1), _, _, arg)623 (Absyn.MATCHEXP(match_ty, e1, match_decls, match_cases, cmt), arg); 624 625 case (Absyn.LIST(exps = expl1), _, _, arg) 626 626 equation 627 627 (expl2, arg) = traverseExpListBidir(expl1, enterFunc, exitFunc, arg); 628 628 then 629 (if referenceEq(expl1,expl2) then inExp else LIST(expl2), arg);630 631 case ( CODE(), _, _, _)629 (if referenceEq(expl1,expl2) then inExp else Absyn.LIST(expl2), arg); 630 631 case (Absyn.CODE(), _, _, _) 632 632 then (inExp, inArg); 633 633 634 case ( DOT(), _, _, arg)634 case (Absyn.DOT(), _, _, arg) 635 635 equation 636 636 (e1, arg) = traverseExpBidir(inExp.exp, enterFunc, exitFunc, arg); 637 637 (e2, arg) = traverseExpBidir(inExp.index, enterFunc, exitFunc, arg); 638 638 then 639 (if referenceEq(inExp.exp,e1) and referenceEq(inExp.index,e2) then inExp else DOT(e1, e2), arg);639 (if referenceEq(inExp.exp,e1) and referenceEq(inExp.index,e2) then inExp else Absyn.DOT(e1, e2), arg); 640 640 641 641 else … … 655 655 "Helper function to traverseExpBidirSubExps. Traverses any expressions in a 656 656 component reference (i.e. in it's subscripts)." 657 input ComponentRef inCref;657 input Absyn.ComponentRef inCref; 658 658 input FuncType enterFunc; 659 659 input FuncType exitFunc; 660 660 input Argument inArg; 661 output ComponentRef outCref;661 output Absyn.ComponentRef outCref; 662 662 output Argument arg; 663 663 664 664 partial function FuncType 665 input Exp inExp;665 input Absyn.Exp inExp; 666 666 input Argument inArg; 667 output Exp outExp;667 output Absyn.Exp outExp; 668 668 output Argument outArg; 669 669 end FuncType; … … 672 672 (outCref, arg) := match(inCref, enterFunc, exitFunc, inArg) 673 673 local 674 Ident name;675 ComponentRef cr1,cr2;676 list< Subscript> subs1,subs2;674 Absyn.Ident name; 675 Absyn.ComponentRef cr1,cr2; 676 list<Absyn.Subscript> subs1,subs2; 677 677 tuple<FuncType, FuncType, Argument> tup; 678 678 679 case ( CREF_FULLYQUALIFIED(componentRef = cr1), _, _, arg)679 case (Absyn.CREF_FULLYQUALIFIED(componentRef = cr1), _, _, arg) 680 680 equation 681 681 (cr2, arg) = traverseExpBidirCref(cr1, enterFunc, exitFunc, arg); … … 683 683 (if referenceEq(cr1,cr2) then inCref else crefMakeFullyQualified(cr2), arg); 684 684 685 case ( CREF_QUAL(name = name, subscripts = subs1, componentRef = cr1), _, _, arg)685 case (Absyn.CREF_QUAL(name = name, subscripts = subs1, componentRef = cr1), _, _, arg) 686 686 equation 687 687 (subs2, arg) = List.map2FoldCheckReferenceEq(subs1, traverseExpBidirSubs, enterFunc, exitFunc, arg); 688 688 (cr2, arg) = traverseExpBidirCref(cr1, enterFunc, exitFunc, arg); 689 689 then 690 (if referenceEq(cr1,cr2) and referenceEq(subs1,subs2) then inCref else CREF_QUAL(name, subs2, cr2), arg);691 692 case ( CREF_IDENT(name = name, subscripts = subs1), _, _, arg)690 (if referenceEq(cr1,cr2) and referenceEq(subs1,subs2) then inCref else Absyn.CREF_QUAL(name, subs2, cr2), arg); 691 692 case (Absyn.CREF_IDENT(name = name, subscripts = subs1), _, _, arg) 693 693 equation 694 694 (subs2, arg) = List.map2FoldCheckReferenceEq(subs1, traverseExpBidirSubs, enterFunc, exitFunc, arg); 695 695 then 696 (if referenceEq(subs1,subs2) then inCref else CREF_IDENT(name, subs2), arg);697 698 case (A LLWILD(), _, _, _) then (inCref, inArg);699 case ( WILD(), _, _, _) then (inCref, inArg);696 (if referenceEq(subs1,subs2) then inCref else Absyn.CREF_IDENT(name, subs2), arg); 697 698 case (Absyn.ALLWILD(), _, _, _) then (inCref, inArg); 699 case (Absyn.WILD(), _, _, _) then (inCref, inArg); 700 700 end match; 701 701 end traverseExpBidirCref; … … 704 704 "Helper function to traverseExpBidirCref. Traverses expressions in a 705 705 subscript." 706 input Subscript inSubscript;706 input Absyn.Subscript inSubscript; 707 707 input FuncType enterFunc; 708 708 input FuncType exitFunc; 709 709 input Argument inArg; 710 output Subscript outSubscript;710 output Absyn.Subscript outSubscript; 711 711 output Argument arg; 712 712 713 713 partial function FuncType 714 input Exp inExp;714 input Absyn.Exp inExp; 715 715 input Argument inArg; 716 output Exp outExp;716 output Absyn.Exp outExp; 717 717 output Argument outArg; 718 718 end FuncType; … … 721 721 (outSubscript, arg) := match(inSubscript, enterFunc, exitFunc, inArg) 722 722 local 723 Exp e1,e2;724 725 case ( SUBSCRIPT(subscript = e1), _, _, arg)723 Absyn.Exp e1,e2; 724 725 case (Absyn.SUBSCRIPT(subscript = e1), _, _, arg) 726 726 equation 727 727 (e2, arg) = traverseExpBidir(e1, enterFunc, exitFunc, inArg); 728 728 then 729 (if referenceEq(e1,e2) then inSubscript else SUBSCRIPT(e2), arg);730 731 case ( NOSUB(), _, _, _) then (inSubscript, inArg);729 (if referenceEq(e1,e2) then inSubscript else Absyn.SUBSCRIPT(e2), arg); 730 731 case (Absyn.NOSUB(), _, _, _) then (inSubscript, inArg); 732 732 end match; 733 733 end traverseExpBidirSubs; … … 736 736 "Helper function to traverseExpBidirSubExps. Traverses the expressions in an 737 737 elseif branch." 738 input tuple< Exp,Exp> inElseIf;738 input tuple<Absyn.Exp, Absyn.Exp> inElseIf; 739 739 input FuncType enterFunc; 740 740 input FuncType exitFunc; 741 741 input Argument inArg; 742 output tuple< Exp,Exp> outElseIf;742 output tuple<Absyn.Exp, Absyn.Exp> outElseIf; 743 743 output Argument arg; 744 744 745 745 partial function FuncType 746 input Exp inExp;746 input Absyn.Exp inExp; 747 747 input Argument inArg; 748 output Exp outExp;748 output Absyn.Exp outExp; 749 749 output Argument outArg; 750 750 end FuncType; 751 751 752 752 protected 753 Exp e1, e2;753 Absyn.Exp e1, e2; 754 754 tuple<FuncType, FuncType, Argument> tup; 755 755 algorithm … … 763 763 "Helper function to traverseExpBidirSubExps. Traverses the expressions in a 764 764 list of function argument." 765 input FunctionArgs inArgs;765 input Absyn.FunctionArgs inArgs; 766 766 input FuncType enterFunc; 767 767 input FuncType exitFunc; 768 768 input Argument inArg; 769 output FunctionArgs outArgs;769 output Absyn.FunctionArgs outArgs; 770 770 output Argument outArg; 771 771 772 772 partial function FuncType 773 input Exp inExp;773 input Absyn.Exp inExp; 774 774 input Argument inArg; 775 output Exp outExp;775 output Absyn.Exp outExp; 776 776 output Argument outArg; 777 777 end FuncType; … … 780 780 (outArgs, outArg) := match(inArgs, enterFunc, exitFunc, inArg) 781 781 local 782 Exp e1,e2;783 list< Exp> expl1,expl2;784 list< NamedArg> named_args1,named_args2;785 ForIterators iters1,iters2;782 Absyn.Exp e1,e2; 783 list<Absyn.Exp> expl1,expl2; 784 list<Absyn.NamedArg> named_args1,named_args2; 785 Absyn.ForIterators iters1,iters2; 786 786 Argument arg; 787 ReductionIterType iterType;788 789 case ( FUNCTIONARGS(args = expl1, argNames = named_args1), _, _, arg)787 Absyn.ReductionIterType iterType; 788 789 case (Absyn.FUNCTIONARGS(args = expl1, argNames = named_args1), _, _, arg) 790 790 equation 791 791 (expl2, arg) = traverseExpListBidir(expl1, enterFunc, exitFunc, arg); 792 792 (named_args2, arg) = List.map2FoldCheckReferenceEq(named_args1, traverseExpBidirNamedArg, enterFunc, exitFunc, arg); 793 793 then 794 (if referenceEq(expl1,expl2) and referenceEq(named_args1,named_args2) then inArgs else FUNCTIONARGS(expl2, named_args2), arg);795 796 case ( FOR_ITER_FARG(e1, iterType, iters1), _, _, arg)794 (if referenceEq(expl1,expl2) and referenceEq(named_args1,named_args2) then inArgs else Absyn.FUNCTIONARGS(expl2, named_args2), arg); 795 796 case (Absyn.FOR_ITER_FARG(e1, iterType, iters1), _, _, arg) 797 797 equation 798 798 (e2, arg) = traverseExpBidir(e1, enterFunc, exitFunc, arg); 799 799 (iters2, arg) = List.map2FoldCheckReferenceEq(iters1, traverseExpBidirIterator, enterFunc, exitFunc, arg); 800 800 then 801 (if referenceEq(e1,e2) and referenceEq(iters1,iters2) then inArgs else FOR_ITER_FARG(e2, iterType, iters2), arg);801 (if referenceEq(e1,e2) and referenceEq(iters1,iters2) then inArgs else Absyn.FOR_ITER_FARG(e2, iterType, iters2), arg); 802 802 end match; 803 803 end traverseExpBidirFunctionArgs; … … 806 806 "Helper function to traverseExpBidirFunctionArgs. Traverses the expressions in 807 807 a named function argument." 808 input NamedArg inArg;808 input Absyn.NamedArg inArg; 809 809 input FuncType enterFunc; 810 810 input FuncType exitFunc; 811 811 input Argument inExtra; 812 output NamedArg outArg;812 output Absyn.NamedArg outArg; 813 813 output Argument outExtra; 814 814 815 815 partial function FuncType 816 input Exp inExp;816 input Absyn.Exp inExp; 817 817 input Argument inArg; 818 output Exp outExp;818 output Absyn.Exp outExp; 819 819 output Argument outArg; 820 820 end FuncType; 821 821 822 822 protected 823 Ident name;824 Exp value1,value2;825 algorithm 826 NAMEDARG(name, value1) := inArg;823 Absyn.Ident name; 824 Absyn.Exp value1,value2; 825 algorithm 826 Absyn.NAMEDARG(name, value1) := inArg; 827 827 (value2, outExtra) := traverseExpBidir(value1, enterFunc, exitFunc, inExtra); 828 outArg := if referenceEq(value1,value2) then inArg else NAMEDARG(name, value2);828 outArg := if referenceEq(value1,value2) then inArg else Absyn.NAMEDARG(name, value2); 829 829 end traverseExpBidirNamedArg; 830 830 … … 832 832 "Helper function to traverseExpBidirFunctionArgs. Traverses the expressions in 833 833 an iterator." 834 input ForIterator inIterator;834 input Absyn.ForIterator inIterator; 835 835 input FuncType enterFunc; 836 836 input FuncType exitFunc; 837 837 input Argument inArg; 838 output ForIterator outIterator;838 output Absyn.ForIterator outIterator; 839 839 output Argument outArg; 840 840 841 841 partial function FuncType 842 input Exp inExp;842 input Absyn.Exp inExp; 843 843 input Argument inArg; 844 output Exp outExp;844 output Absyn.Exp outExp; 845 845 output Argument outArg; 846 846 end FuncType; 847 847 848 848 protected 849 Ident name;850 Option< Exp> guardExp1,guardExp2,range1,range2;851 algorithm 852 ITERATOR(name=name, guardExp=guardExp1, range=range1) := inIterator;849 Absyn.Ident name; 850 Option<Absyn.Exp> guardExp1,guardExp2,range1,range2; 851 algorithm 852 Absyn.ITERATOR(name=name, guardExp=guardExp1, range=range1) := inIterator; 853 853 (guardExp2, outArg) := traverseExpOptBidir(guardExp1, enterFunc, exitFunc, inArg); 854 854 (range2, outArg) := traverseExpOptBidir(range1, enterFunc, exitFunc, outArg); 855 outIterator := if referenceEq(guardExp1,guardExp2) and referenceEq(range1,range2) then inIterator else ITERATOR(name, guardExp2, range2);855 outIterator := if referenceEq(guardExp1,guardExp2) and referenceEq(range1,range2) then inIterator else Absyn.ITERATOR(name, guardExp2, range2); 856 856 end traverseExpBidirIterator; 857 857 858 858 public function traverseMatchCase 859 input Case inMatchCase;859 input Absyn.Case inMatchCase; 860 860 input FuncType enterFunc; 861 861 input FuncType exitFunc; 862 862 input Argument inArg; 863 output Case outMatchCase;863 output Absyn.Case outMatchCase; 864 864 output Argument outArg; 865 865 866 866 partial function FuncType 867 input Exp inExp;867 input Absyn.Exp inExp; 868 868 input Argument inArg; 869 output Exp outExp;869 output Absyn.Exp outExp; 870 870 output Argument outArg; 871 871 end FuncType; … … 875 875 local 876 876 Argument arg; 877 Exp pattern, result;878 Info info, resultInfo, pinfo;879 list< ElementItem> ldecls;880 ClassPart cp;877 Absyn.Exp pattern, result; 878 Absyn.Info info, resultInfo, pinfo; 879 list<Absyn.ElementItem> ldecls; 880 Absyn.ClassPart cp; 881 881 Option<String> cmt; 882 Option< Exp> patternGuard;883 884 case ( CASE(pattern, patternGuard, pinfo, ldecls, cp, result, resultInfo, cmt, info), _, _, arg)882 Option<Absyn.Exp> patternGuard; 883 884 case (Absyn.CASE(pattern, patternGuard, pinfo, ldecls, cp, result, resultInfo, cmt, info), _, _, arg) 885 885 equation 886 886 (pattern, arg) = traverseExpBidir(pattern, enterFunc, exitFunc, arg); … … 889 889 (result, arg) = traverseExpBidir(result, enterFunc, exitFunc, arg); 890 890 then 891 ( CASE(pattern, patternGuard, pinfo, ldecls, cp, result, resultInfo, cmt, info), arg);892 893 case ( ELSE(localDecls = ldecls, classPart = cp, result = result, resultInfo = resultInfo,891 (Absyn.CASE(pattern, patternGuard, pinfo, ldecls, cp, result, resultInfo, cmt, info), arg); 892 893 case (Absyn.ELSE(localDecls = ldecls, classPart = cp, result = result, resultInfo = resultInfo, 894 894 comment = cmt, info = info), _, _, arg) 895 895 equation … … 897 897 (result, arg) = traverseExpBidir(result, enterFunc, exitFunc, arg); 898 898 then 899 ( ELSE(ldecls, cp, result, resultInfo, cmt, info), arg);899 (Absyn.ELSE(ldecls, cp, result, resultInfo, cmt, info), arg); 900 900 901 901 end match; … … 903 903 904 904 protected function traverseClassPartBidir 905 input ClassPart cp;905 input Absyn.ClassPart cp; 906 906 input FuncType enterFunc; 907 907 input FuncType exitFunc; 908 908 input Argument inArg; 909 output ClassPart outCp;909 output Absyn.ClassPart outCp; 910 910 output Argument outArg; 911 911 912 912 partial function FuncType 913 input Exp inExp;913 input Absyn.Exp inExp; 914 914 input Argument inArg; 915 output Exp outExp;915 output Absyn.Exp outExp; 916 916 output Argument outArg; 917 917 end FuncType; … … 920 920 (outCp, outArg) := match (cp,enterFunc,exitFunc,inArg) 921 921 local 922 list<A lgorithmItem> algs;923 list< EquationItem> eqs;922 list<Absyn.AlgorithmItem> algs; 923 list<Absyn.EquationItem> eqs; 924 924 Argument arg; 925 case (A LGORITHMS(algs),_,_,arg)925 case (Absyn.ALGORITHMS(algs),_,_,arg) 926 926 equation 927 927 (algs, arg) = List.map2FoldCheckReferenceEq(algs, traverseAlgorithmItemBidir, enterFunc, exitFunc, arg); 928 then (A LGORITHMS(algs),arg);929 case ( EQUATIONS(eqs),_,_,arg)928 then (Absyn.ALGORITHMS(algs),arg); 929 case (Absyn.EQUATIONS(eqs),_,_,arg) 930 930 equation 931 931 (eqs, arg) = List.map2FoldCheckReferenceEq(eqs, traverseEquationItemBidir, enterFunc, exitFunc, arg); 932 then ( EQUATIONS(eqs),arg);932 then (Absyn.EQUATIONS(eqs),arg); 933 933 end match; 934 934 end traverseClassPartBidir; 935 935 936 936 protected function traverseEquationItemListBidir 937 input list< EquationItem> inEquationItems;937 input list<Absyn.EquationItem> inEquationItems; 938 938 input FuncType enterFunc; 939 939 input FuncType exitFunc; 940 940 input Argument inArg; 941 output list< EquationItem> outEquationItems;941 output list<Absyn.EquationItem> outEquationItems; 942 942 output Argument outArg; 943 943 944 944 partial function FuncType 945 input Exp inExp;945 input Absyn.Exp inExp; 946 946 input Argument inArg; 947 output Exp outExp;947 output Absyn.Exp outExp; 948 948 output Argument outArg; 949 949 end FuncType; … … 954 954 955 955 protected function traverseAlgorithmItemListBidir 956 input list<A lgorithmItem> inAlgs;956 input list<Absyn.AlgorithmItem> inAlgs; 957 957 input FuncType enterFunc; 958 958 input FuncType exitFunc; 959 959 input Argument inArg; 960 output list<A lgorithmItem> outAlgs;960 output list<Absyn.AlgorithmItem> outAlgs; 961 961 output Argument outArg; 962 962 963 963 partial function FuncType 964 input Exp inExp;964 input Absyn.Exp inExp; 965 965 input Argument inArg; 966 output Exp outExp;966 output Absyn.Exp outExp; 967 967 output Argument outArg; 968 968 end FuncType; … … 973 973 974 974 protected function traverseAlgorithmItemBidir 975 input A lgorithmItem inAlgorithmItem;975 input Absyn.AlgorithmItem inAlgorithmItem; 976 976 input FuncType enterFunc; 977 977 input FuncType exitFunc; 978 978 input Argument inArg; 979 output A lgorithmItem outAlgorithmItem;979 output Absyn.AlgorithmItem outAlgorithmItem; 980 980 output Argument outArg; 981 981 982 982 partial function FuncType 983 input Exp inExp;983 input Absyn.Exp inExp; 984 984 input Argument inArg; 985 output Exp outExp;985 output Absyn.Exp outExp; 986 986 output Argument outArg; 987 987 end FuncType; … … 991 991 local 992 992 Argument arg; 993 A lgorithm alg;994 Option< Comment> cmt;995 Info info;996 997 case (A LGORITHMITEM(algorithm_ = alg, comment = cmt, info = info), _, _, arg)993 Absyn.Algorithm alg; 994 Option<Absyn.Comment> cmt; 995 Absyn.Info info; 996 997 case (Absyn.ALGORITHMITEM(algorithm_ = alg, comment = cmt, info = info), _, _, arg) 998 998 equation 999 999 (alg, arg) = traverseAlgorithmBidir(alg, enterFunc, exitFunc, arg); 1000 1000 then 1001 (A LGORITHMITEM(alg, cmt, info), arg);1002 1003 case (A LGORITHMITEMCOMMENT(), _, _, _) then (inAlgorithmItem,inArg);1001 (Absyn.ALGORITHMITEM(alg, cmt, info), arg); 1002 1003 case (Absyn.ALGORITHMITEMCOMMENT(), _, _, _) then (inAlgorithmItem,inArg); 1004 1004 end match; 1005 1005 end traverseAlgorithmItemBidir; 1006 1006 1007 1007 protected function traverseEquationItemBidir 1008 input EquationItem inEquationItem;1008 input Absyn.EquationItem inEquationItem; 1009 1009 input FuncType enterFunc; 1010 1010 input FuncType exitFunc; 1011 1011 input Argument inArg; 1012 output EquationItem outEquationItem;1012 output Absyn.EquationItem outEquationItem; 1013 1013 output Argument outArg; 1014 1014 1015 1015 partial function FuncType 1016 input Exp inExp;1016 input Absyn.Exp inExp; 1017 1017 input Argument inArg; 1018 output Exp outExp;1018 output Absyn.Exp outExp; 1019 1019 output Argument outArg; 1020 1020 end FuncType; … … 1024 1024 local 1025 1025 Argument arg; 1026 Equation eq;1027 Option< Comment> cmt;1028 Info info;1029 1030 case ( EQUATIONITEM(equation_ = eq, comment = cmt, info = info), _, _, arg)1026 Absyn.Equation eq; 1027 Option<Absyn.Comment> cmt; 1028 Absyn.Info info; 1029 1030 case (Absyn.EQUATIONITEM(equation_ = eq, comment = cmt, info = info), _, _, arg) 1031 1031 equation 1032 1032 (eq, arg) = traverseEquationBidir(eq, enterFunc, exitFunc, arg); 1033 1033 then 1034 ( EQUATIONITEM(eq, cmt, info), arg);1034 (Absyn.EQUATIONITEM(eq, cmt, info), arg); 1035 1035 1036 1036 end match; … … 1038 1038 1039 1039 public function traverseEquationBidir 1040 input Equation inEquation;1040 input Absyn.Equation inEquation; 1041 1041 input FuncType enterFunc; 1042 1042 input FuncType exitFunc; 1043 1043 input Argument inArg; 1044 output Equation outEquation;1044 output Absyn.Equation outEquation; 1045 1045 output Argument outArg; 1046 1046 1047 1047 partial function FuncType 1048 input Exp inExp;1048 input Absyn.Exp inExp; 1049 1049 input Argument inArg; 1050 output Exp outExp;1050 output Absyn.Exp outExp; 1051 1051 output Argument outArg; 1052 1052 end FuncType; … … 1056 1056 local 1057 1057 Argument arg; 1058 Exp e1, e2;1059 list< EquationItem> eqil1, eqil2;1060 list<tuple< Exp, list<EquationItem>>> else_branch;1061 ComponentRef cref1, cref2;1062 ForIterators iters;1063 FunctionArgs func_args;1064 EquationItem eq;1065 1066 case ( EQ_IF(ifExp = e1, equationTrueItems = eqil1,1058 Absyn.Exp e1, e2; 1059 list<Absyn.EquationItem> eqil1, eqil2; 1060 list<tuple<Absyn.Exp, list<Absyn.EquationItem>>> else_branch; 1061 Absyn.ComponentRef cref1, cref2; 1062 Absyn.ForIterators iters; 1063 Absyn.FunctionArgs func_args; 1064 Absyn.EquationItem eq; 1065 1066 case (Absyn.EQ_IF(ifExp = e1, equationTrueItems = eqil1, 1067 1067 elseIfBranches = else_branch, equationElseItems = eqil2), _, _, arg) 1068 1068 equation … … 1072 1072 (eqil2,arg) = traverseEquationItemListBidir(eqil2, enterFunc, exitFunc, arg); 1073 1073 then 1074 ( EQ_IF(e1, eqil1, else_branch, eqil2), arg);1075 1076 case ( EQ_EQUALS(leftSide = e1, rightSide = e2), _, _, arg)1074 (Absyn.EQ_IF(e1, eqil1, else_branch, eqil2), arg); 1075 1076 case (Absyn.EQ_EQUALS(leftSide = e1, rightSide = e2), _, _, arg) 1077 1077 equation 1078 1078 (e1, arg) = traverseExpBidir(e1, enterFunc, exitFunc, arg); 1079 1079 (e2, arg) = traverseExpBidir(e2, enterFunc, exitFunc, arg); 1080 1080 then 1081 ( EQ_EQUALS(e1, e2), arg);1082 case ( EQ_PDE(leftSide = e1, rightSide = e2, domain = cref1), _, _, arg)1081 (Absyn.EQ_EQUALS(e1, e2), arg); 1082 case (Absyn.EQ_PDE(leftSide = e1, rightSide = e2, domain = cref1), _, _, arg) 1083 1083 equation 1084 1084 (e1, arg) = traverseExpBidir(e1, enterFunc, exitFunc, arg); … … 1086 1086 cref1 = traverseExpBidirCref(cref1, enterFunc, exitFunc, arg); 1087 1087 then 1088 ( EQ_PDE(e1, e2,cref1), arg);1089 1090 case ( EQ_CONNECT(connector1 = cref1, connector2 = cref2), _, _, arg)1088 (Absyn.EQ_PDE(e1, e2,cref1), arg); 1089 1090 case (Absyn.EQ_CONNECT(connector1 = cref1, connector2 = cref2), _, _, arg) 1091 1091 equation 1092 1092 (cref1, arg) = traverseExpBidirCref(cref1, enterFunc, exitFunc, arg); 1093 1093 (cref2, arg) = traverseExpBidirCref(cref2, enterFunc, exitFunc, arg); 1094 1094 then 1095 ( EQ_CONNECT(cref1, cref2), arg);1096 1097 case ( EQ_FOR(iterators = iters, forEquations = eqil1), _, _, arg)1095 (Absyn.EQ_CONNECT(cref1, cref2), arg); 1096 1097 case (Absyn.EQ_FOR(iterators = iters, forEquations = eqil1), _, _, arg) 1098 1098 equation 1099 1099 (iters, arg) = List.map2FoldCheckReferenceEq(iters, traverseExpBidirIterator, enterFunc, exitFunc, arg); 1100 1100 (eqil1, arg) = traverseEquationItemListBidir(eqil1, enterFunc, exitFunc, arg); 1101 1101 then 1102 ( EQ_FOR(iters, eqil1), arg);1103 1104 case ( EQ_WHEN_E(whenExp = e1, whenEquations = eqil1, elseWhenEquations = else_branch), _, _, arg)1102 (Absyn.EQ_FOR(iters, eqil1), arg); 1103 1104 case (Absyn.EQ_WHEN_E(whenExp = e1, whenEquations = eqil1, elseWhenEquations = else_branch), _, _, arg) 1105 1105 equation 1106 1106 (e1, arg) = traverseExpBidir(e1, enterFunc, exitFunc, arg); … … 1108 1108 (else_branch, arg) = List.map2FoldCheckReferenceEq(else_branch, traverseEquationBidirElse, enterFunc, exitFunc, arg); 1109 1109 then 1110 ( EQ_WHEN_E(e1, eqil1, else_branch), arg);1111 1112 case ( EQ_NORETCALL(functionName = cref1, functionArgs = func_args), _, _, arg)1110 (Absyn.EQ_WHEN_E(e1, eqil1, else_branch), arg); 1111 1112 case (Absyn.EQ_NORETCALL(functionName = cref1, functionArgs = func_args), _, _, arg) 1113 1113 equation 1114 1114 (cref1, arg) = traverseExpBidirCref(cref1, enterFunc, exitFunc, arg); 1115 1115 (func_args, arg) = traverseExpBidirFunctionArgs(func_args, enterFunc, exitFunc, arg); 1116 1116 then 1117 ( EQ_NORETCALL(cref1, func_args), arg);1118 1119 case ( EQ_FAILURE(equ = eq), _, _, arg)1117 (Absyn.EQ_NORETCALL(cref1, func_args), arg); 1118 1119 case (Absyn.EQ_FAILURE(equ = eq), _, _, arg) 1120 1120 equation 1121 1121 (eq, arg) = traverseEquationItemBidir(eq, enterFunc, exitFunc, arg); 1122 1122 then 1123 ( EQ_FAILURE(eq), arg);1123 (Absyn.EQ_FAILURE(eq), arg); 1124 1124 1125 1125 end match; … … 1127 1127 1128 1128 protected function traverseEquationBidirElse 1129 input tuple< Exp, list<EquationItem>> inElse;1129 input tuple<Absyn.Exp, list<Absyn.EquationItem>> inElse; 1130 1130 input FuncType enterFunc; 1131 1131 input FuncType exitFunc; 1132 1132 input Argument inArg; 1133 output tuple< Exp, list<EquationItem>> outElse;1133 output tuple<Absyn.Exp, list<Absyn.EquationItem>> outElse; 1134 1134 output Argument arg; 1135 1135 1136 1136 partial function FuncType 1137 input Exp inExp;1137 input Absyn.Exp inExp; 1138 1138 input Argument inArg; 1139 output Exp outExp;1139 output Absyn.Exp outExp; 1140 1140 output Argument outArg; 1141 1141 end FuncType; 1142 1142 1143 1143 protected 1144 Exp e;1145 list< EquationItem> eqil;1144 Absyn.Exp e; 1145 list<Absyn.EquationItem> eqil; 1146 1146 algorithm 1147 1147 (e, eqil) := inElse; … … 1152 1152 1153 1153 protected function traverseAlgorithmBidirElse 1154 input tuple< Exp, list<AlgorithmItem>> inElse;1154 input tuple<Absyn.Exp, list<Absyn.AlgorithmItem>> inElse; 1155 1155 input FuncType enterFunc; 1156 1156 input FuncType exitFunc; 1157 1157 input Argument inArg; 1158 output tuple< Exp, list<AlgorithmItem>> outElse;1158 output tuple<Absyn.Exp, list<Absyn.AlgorithmItem>> outElse; 1159 1159 output Argument arg; 1160 1160 1161 1161 partial function FuncType 1162 input Exp inExp;1162 input Absyn.Exp inExp; 1163 1163 input Argument inArg; 1164 output Exp outExp;1164 output Absyn.Exp outExp; 1165 1165 output Argument outArg; 1166 1166 end FuncType; 1167 1167 1168 1168 protected 1169 Exp e;1170 list<A lgorithmItem> algs;1169 Absyn.Exp e; 1170 list<Absyn.AlgorithmItem> algs; 1171 1171 algorithm 1172 1172 (e, algs) := inElse; … … 1177 1177 1178 1178 protected function traverseAlgorithmBidir 1179 input A lgorithm inAlg;1179 input Absyn.Algorithm inAlg; 1180 1180 input FuncType enterFunc; 1181 1181 input FuncType exitFunc; 1182 1182 input Argument inArg; 1183 output A lgorithm outAlg;1183 output Absyn.Algorithm outAlg; 1184 1184 output Argument outArg; 1185 1185 1186 1186 partial function FuncType 1187 input Exp inExp;1187 input Absyn.Exp inExp; 1188 1188 input Argument inArg; 1189 output Exp outExp;1189 output Absyn.Exp outExp; 1190 1190 output Argument outArg; 1191 1191 end FuncType; … … 1195 1195 local 1196 1196 Argument arg; 1197 Exp e1, e2;1198 list<A lgorithmItem> algs1, algs2;1199 list<tuple< Exp, list<AlgorithmItem>>> else_branch;1200 ComponentRef cref1, cref2;1201 ForIterators iters;1202 FunctionArgs func_args;1203 A lgorithmItem alg;1204 1205 case (A LG_ASSIGN(e1, e2), _, _, arg)1197 Absyn.Exp e1, e2; 1198 list<Absyn.AlgorithmItem> algs1, algs2; 1199 list<tuple<Absyn.Exp, list<Absyn.AlgorithmItem>>> else_branch; 1200 Absyn.ComponentRef cref1, cref2; 1201 Absyn.ForIterators iters; 1202 Absyn.FunctionArgs func_args; 1203 Absyn.AlgorithmItem alg; 1204 1205 case (Absyn.ALG_ASSIGN(e1, e2), _, _, arg) 1206 1206 equation 1207 1207 (e1, arg) = traverseExpBidir(e1, enterFunc, exitFunc, arg); 1208 1208 (e2, arg) = traverseExpBidir(e2, enterFunc, exitFunc, arg); 1209 1209 then 1210 (A LG_ASSIGN(e1, e2), arg);1211 1212 case (A LG_IF(e1, algs1, else_branch, algs2), _, _, arg)1210 (Absyn.ALG_ASSIGN(e1, e2), arg); 1211 1212 case (Absyn.ALG_IF(e1, algs1, else_branch, algs2), _, _, arg) 1213 1213 equation 1214 1214 (e1, arg) = traverseExpBidir(e1, enterFunc, exitFunc, arg); … … 1216 1216 (else_branch, arg) = List.map2FoldCheckReferenceEq(else_branch, traverseAlgorithmBidirElse, enterFunc, exitFunc, arg); 1217 1217 (algs2, arg) = traverseAlgorithmItemListBidir(algs2, enterFunc, exitFunc, arg); 1218 then (A LG_IF(e1, algs1, else_branch, algs2), arg);1219 1220 case (A LG_FOR(iters, algs1), _, _, arg)1218 then (Absyn.ALG_IF(e1, algs1, else_branch, algs2), arg); 1219 1220 case (Absyn.ALG_FOR(iters, algs1), _, _, arg) 1221 1221 equation 1222 1222 (iters, arg) = List.map2FoldCheckReferenceEq(iters, traverseExpBidirIterator, enterFunc, exitFunc, arg); 1223 1223 (algs1, arg) = traverseAlgorithmItemListBidir(algs1, enterFunc, exitFunc, arg); 1224 then (A LG_FOR(iters, algs1), arg);1225 1226 case (A LG_PARFOR(iters, algs1), _, _, arg)1224 then (Absyn.ALG_FOR(iters, algs1), arg); 1225 1226 case (Absyn.ALG_PARFOR(iters, algs1), _, _, arg) 1227 1227 equation 1228 1228 (iters, arg) = List.map2FoldCheckReferenceEq(iters, traverseExpBidirIterator, enterFunc, exitFunc, arg); 1229 1229 (algs1, arg) = traverseAlgorithmItemListBidir(algs1, enterFunc, exitFunc, arg); 1230 then (A LG_PARFOR(iters, algs1), arg);1231 1232 case (A LG_WHILE(e1, algs1), _, _, arg)1230 then (Absyn.ALG_PARFOR(iters, algs1), arg); 1231 1232 case (Absyn.ALG_WHILE(e1, algs1), _, _, arg) 1233 1233 equation 1234 1234 (e1, arg) = traverseExpBidir(e1, enterFunc, exitFunc, arg); 1235 1235 (algs1, arg) = traverseAlgorithmItemListBidir(algs1, enterFunc, exitFunc, arg); 1236 then (A LG_WHILE(e1, algs1), arg);1237 1238 case (A LG_WHEN_A(e1, algs1, else_branch), _, _, arg)1236 then (Absyn.ALG_WHILE(e1, algs1), arg); 1237 1238 case (Absyn.ALG_WHEN_A(e1, algs1, else_branch), _, _, arg) 1239 1239 equation 1240 1240 (e1, arg) = traverseExpBidir(e1, enterFunc, exitFunc, arg); 1241 1241 (algs1, arg) = traverseAlgorithmItemListBidir(algs1, enterFunc, exitFunc, arg); 1242 1242 (else_branch, arg) = List.map2FoldCheckReferenceEq(else_branch, traverseAlgorithmBidirElse, enterFunc, exitFunc, arg); 1243 then (A LG_WHEN_A(e1, algs1, else_branch), arg);1244 1245 case (A LG_NORETCALL(cref1, func_args), _, _, arg)1243 then (Absyn.ALG_WHEN_A(e1, algs1, else_branch), arg); 1244 1245 case (Absyn.ALG_NORETCALL(cref1, func_args), _, _, arg) 1246 1246 equation 1247 1247 (cref1, arg) = traverseExpBidirCref(cref1, enterFunc, exitFunc, arg); 1248 1248 (func_args, arg) = traverseExpBidirFunctionArgs(func_args, enterFunc, exitFunc, arg); 1249 1249 then 1250 (A LG_NORETCALL(cref1, func_args), arg);1251 1252 case (A LG_RETURN(), _, _, arg)1250 (Absyn.ALG_NORETCALL(cref1, func_args), arg); 1251 1252 case (Absyn.ALG_RETURN(), _, _, arg) 1253 1253 then (inAlg, arg); 1254 1254 1255 case (A LG_BREAK(), _, _, arg)1255 case (Absyn.ALG_BREAK(), _, _, arg) 1256 1256 then (inAlg, arg); 1257 1257 1258 case (A LG_CONTINUE(), _, _, arg)1258 case (Absyn.ALG_CONTINUE(), _, _, arg) 1259 1259 then (inAlg, arg); 1260 1260 1261 case (A LG_FAILURE(algs1), _, _, arg)1261 case (Absyn.ALG_FAILURE(algs1), _, _, arg) 1262 1262 equation 1263 1263 (algs1, arg) = traverseAlgorithmItemListBidir(algs1, enterFunc, exitFunc, arg); 1264 1264 then 1265 (A LG_FAILURE(algs1), arg);1266 1267 case (A LG_TRY(algs1, algs2), _, _, arg)1265 (Absyn.ALG_FAILURE(algs1), arg); 1266 1267 case (Absyn.ALG_TRY(algs1, algs2), _, _, arg) 1268 1268 equation 1269 1269 (algs1, arg) = traverseAlgorithmItemListBidir(algs1, enterFunc, exitFunc, arg); 1270 1270 (algs2, arg) = traverseAlgorithmItemListBidir(algs2, enterFunc, exitFunc, arg); 1271 1271 then 1272 (A LG_TRY(algs1, algs2), arg);1272 (Absyn.ALG_TRY(algs1, algs2), arg); 1273 1273 1274 1274 end match; … … 1277 1277 public function makeIdentPathFromString 1278 1278 input String s; 1279 output Path p;1280 algorithm 1281 p := IDENT(s);1279 output Absyn.Path p; 1280 algorithm 1281 p := Absyn.IDENT(s); 1282 1282 annotation(__OpenModelica_EarlyInline = true); 1283 1283 end makeIdentPathFromString; … … 1286 1286 input String s1; 1287 1287 input String s2; 1288 output Path p;1289 algorithm 1290 p := QUALIFIED(s1,IDENT(s2));1288 output Absyn.Path p; 1289 algorithm 1290 p := Absyn.QUALIFIED(s1,Absyn.IDENT(s2)); 1291 1291 annotation(__OpenModelica_EarlyInline = true); 1292 1292 end makeQualifiedPathFromStrings; 1293 1293 1294 public function className "returns the class name of a Class as aPath"1295 input Class cl;1296 output Path name;1294 public function className "returns the class name of a Absyn.Class as a Absyn.Path" 1295 input Absyn.Class cl; 1296 output Absyn.Path name; 1297 1297 protected 1298 1298 String id; 1299 1299 algorithm 1300 CLASS(name = id) := cl;1301 name := IDENT(id);1300 Absyn.CLASS(name = id) := cl; 1301 name := Absyn.IDENT(id); 1302 1302 end className; 1303 1303 1304 1304 public function isClassNamed 1305 1305 input String inName; 1306 input Class inClass;1306 input Absyn.Class inClass; 1307 1307 output Boolean outIsNamed; 1308 1308 algorithm 1309 1309 outIsNamed := match inClass 1310 case CLASS() then inName == inClass.name;1310 case Absyn.CLASS() then inName == inClass.name; 1311 1311 else false; 1312 1312 end match; … … 1314 1314 1315 1315 public function elementSpecName 1316 "The ElementSpec type contains the name of the element, and this function1316 "The Absyn.ElementSpec type contains the name of the element, and this function 1317 1317 extracts this name." 1318 input ElementSpec inElementSpec;1319 output Ident outIdent;1318 input Absyn.ElementSpec inElementSpec; 1319 output Absyn.Ident outIdent; 1320 1320 algorithm 1321 1321 outIdent := match (inElementSpec) 1322 local Ident n;1323 1324 case CLASSDEF(class_ =CLASS(name = n)) then n;1325 case COMPONENTS(components = {COMPONENTITEM(component =COMPONENT(name = n))}) then n;1322 local Absyn.Ident n; 1323 1324 case Absyn.CLASSDEF(class_ = Absyn.CLASS(name = n)) then n; 1325 case Absyn.COMPONENTS(components = {Absyn.COMPONENTITEM(component = Absyn.COMPONENT(name = n))}) then n; 1326 1326 end match; 1327 1327 end elementSpecName; 1328 1328 1329 1329 public function isClassdef 1330 input Element inElement;1330 input Absyn.Element inElement; 1331 1331 output Boolean b; 1332 1332 algorithm 1333 1333 b := match inElement 1334 case ELEMENT(specification=CLASSDEF()) then true;1334 case Absyn.ELEMENT(specification=Absyn.CLASSDEF()) then true; 1335 1335 else false; 1336 1336 end match; … … 1338 1338 1339 1339 public function printImportString 1340 "This function takes a Import and prints it as a flat-string."1341 input Import imp;1340 "This function takes a Absyn.Import and prints it as a flat-string." 1341 input Absyn.Import imp; 1342 1342 output String ostring; 1343 1343 algorithm 1344 1344 ostring := match(imp) 1345 1345 local 1346 Path path;1346 Absyn.Path path; 1347 1347 String name; 1348 1348 1349 case( NAMED_IMPORT(name,_)) then name;1350 case( QUAL_IMPORT(path))1349 case(Absyn.NAMED_IMPORT(name,_)) then name; 1350 case(Absyn.QUAL_IMPORT(path)) 1351 1351 equation 1352 1352 name = pathString(path); 1353 1353 then name; 1354 1354 1355 case( UNQUAL_IMPORT(path))1355 case(Absyn.UNQUAL_IMPORT(path)) 1356 1356 equation 1357 1357 name = pathString(path); … … 1361 1361 1362 1362 public function expString "returns the string of an expression if it is a string constant." 1363 input Exp exp;1363 input Absyn.Exp exp; 1364 1364 output String str; 1365 1365 algorithm 1366 STRING(str) := exp;1366 Absyn.STRING(str) := exp; 1367 1367 end expString; 1368 1368 1369 1369 public function expCref "returns the componentRef of an expression if matches." 1370 input Exp exp;1371 output ComponentRef cr;1372 algorithm 1373 CREF(cr) := exp;1370 input Absyn.Exp exp; 1371 output Absyn.ComponentRef cr; 1372 algorithm 1373 Absyn.CREF(cr) := exp; 1374 1374 end expCref; 1375 1375 1376 1376 public function crefExp "returns the componentRef of an expression if matches." 1377 input ComponentRef cr;1378 output Exp exp;1379 algorithm 1380 exp := CREF(cr);1377 input Absyn.ComponentRef cr; 1378 output Absyn.Exp exp; 1379 algorithm 1380 exp := Absyn.CREF(cr); 1381 1381 annotation(__OpenModelica_EarlyInline = true); 1382 1382 end crefExp; 1383 1383 1384 1384 public function expComponentRefStr 1385 input Exp aexp;1385 input Absyn.Exp aexp; 1386 1386 output String outString; 1387 1387 algorithm … … 1390 1390 1391 1391 public function printComponentRefStr 1392 input ComponentRef cr;1392 input Absyn.ComponentRef cr; 1393 1393 output String ostring; 1394 1394 algorithm … … 1396 1396 local 1397 1397 String s1,s2; 1398 ComponentRef child;1399 case( CREF_IDENT(s1,_)) then s1;1400 case( CREF_QUAL(s1,_,child))1398 Absyn.ComponentRef child; 1399 case(Absyn.CREF_IDENT(s1,_)) then s1; 1400 case(Absyn.CREF_QUAL(s1,_,child)) 1401 1401 equation 1402 1402 s2 = printComponentRefStr(child); 1403 1403 s1 = s1 + "." + s2; 1404 1404 then s1; 1405 case( CREF_FULLYQUALIFIED(child))1405 case(Absyn.CREF_FULLYQUALIFIED(child)) 1406 1406 equation 1407 1407 s2 = printComponentRefStr(child); 1408 1408 s1 = "." + s2; 1409 1409 then s1; 1410 case (A LLWILD()) then "__";1411 case ( WILD()) then "_";1410 case (Absyn.ALLWILD()) then "__"; 1411 case (Absyn.WILD()) then "_"; 1412 1412 end match; 1413 1413 end printComponentRefStr; 1414 1414 1415 1415 public function pathEqual "Returns true if two paths are equal." 1416 input Path inPath1;1417 input Path inPath2;1416 input Absyn.Path inPath1; 1417 input Absyn.Path inPath2; 1418 1418 output Boolean outBoolean; 1419 1419 algorithm … … 1422 1422 String id1,id2; 1423 1423 Boolean res; 1424 Path path1,path2;1424 Absyn.Path path1,path2; 1425 1425 // fully qual vs. path 1426 case ( FULLYQUALIFIED(path1),path2) then pathEqual(path1,path2);1426 case (Absyn.FULLYQUALIFIED(path1),path2) then pathEqual(path1,path2); 1427 1427 // path vs. fully qual 1428 case (path1, FULLYQUALIFIED(path2)) then pathEqual(path1,path2);1428 case (path1,Absyn.FULLYQUALIFIED(path2)) then pathEqual(path1,path2); 1429 1429 // ident vs. ident 1430 case ( IDENT(id1),IDENT(id2))1430 case (Absyn.IDENT(id1),Absyn.IDENT(id2)) 1431 1431 then stringEq(id1, id2); 1432 1432 // qual ident vs. qual ident 1433 case ( QUALIFIED(id1, path1),QUALIFIED(id2, path2))1433 case (Absyn.QUALIFIED(id1, path1),Absyn.QUALIFIED(id2, path2)) 1434 1434 equation 1435 1435 res = if stringEq(id1, id2) then pathEqual(path1, path2) else false; … … 1441 1441 1442 1442 public function pathEqualCaseInsensitive "Returns true if two paths are equal." 1443 input Path inPath1;1444 input Path inPath2;1443 input Absyn.Path inPath1; 1444 input Absyn.Path inPath2; 1445 1445 output Boolean outBoolean; 1446 1446 algorithm … … 1449 1449 String id1,id2; 1450 1450 Boolean res; 1451 Path path1,path2;1451 Absyn.Path path1,path2; 1452 1452 // fully qual vs. path 1453 case ( FULLYQUALIFIED(path1),path2) then pathEqualCaseInsensitive(path1,path2);1453 case (Absyn.FULLYQUALIFIED(path1),path2) then pathEqualCaseInsensitive(path1,path2); 1454 1454 // path vs. fully qual 1455 case (path1, FULLYQUALIFIED(path2)) then pathEqualCaseInsensitive(path1,path2);1455 case (path1,Absyn.FULLYQUALIFIED(path2)) then pathEqualCaseInsensitive(path1,path2); 1456 1456 // ident vs. ident 1457 case ( IDENT(id1),IDENT(id2))1457 case (Absyn.IDENT(id1),Absyn.IDENT(id2)) 1458 1458 then stringEq(System.tolower(id1), System.tolower(id2)); 1459 1459 // qual ident vs. qual ident 1460 case ( QUALIFIED(id1, path1),QUALIFIED(id2, path2))1460 case (Absyn.QUALIFIED(id1, path1),Absyn.QUALIFIED(id2, path2)) 1461 1461 equation 1462 1462 res = if stringEq(System.tolower(id1), System.tolower(id2)) then pathEqualCaseInsensitive(path1, path2) else false; … … 1470 1470 "Author BZ 2009-01 1471 1471 Check whether two type specs are equal or not." 1472 input TypeSpec a,b;1472 input Absyn.TypeSpec a,b; 1473 1473 output Boolean ob; 1474 1474 algorithm 1475 1475 ob := matchcontinue(a,b) 1476 1476 local 1477 Path p1,p2;1478 Option<A rrayDim> oad1,oad2;1479 list< TypeSpec> lst1,lst2;1480 Ident i1, i2;1477 Absyn.Path p1,p2; 1478 Option<Absyn.ArrayDim> oad1,oad2; 1479 list<Absyn.TypeSpec> lst1,lst2; 1480 Absyn.Ident i1, i2; 1481 1481 Integer pos1, pos2; 1482 1482 1483 1483 // first try full equality 1484 case( TPATH(p1,oad1),TPATH(p2,oad2))1484 case(Absyn.TPATH(p1,oad1), Absyn.TPATH(p2,oad2)) 1485 1485 equation 1486 1486 true = pathEqual(p1,p2); … … 1488 1488 then true; 1489 1489 1490 case( TCOMPLEX(p1,lst1,oad1),TCOMPLEX(p2,lst2,oad2))1490 case(Absyn.TCOMPLEX(p1,lst1,oad1),Absyn.TCOMPLEX(p2,lst2,oad2)) 1491 1491 equation 1492 1492 true = pathEqual(p1,p2); … … 1502 1502 "Author BZ 1503 1503 helper function for typeSpecEqual" 1504 input Option<A rrayDim> oad1,oad2;1504 input Option<Absyn.ArrayDim> oad1,oad2; 1505 1505 output Boolean b; 1506 1506 algorithm b:= matchcontinue(oad1,oad2) 1507 1507 local 1508 list< Subscript> ad1,ad2;1508 list<Absyn.Subscript> ad1,ad2; 1509 1509 case(SOME(ad1),SOME(ad2)) 1510 1510 equation … … 1516 1516 end optArrayDimEqual; 1517 1517 1518 public function typeSpecPathString "This function simply converts a Path to a string."1519 input TypeSpec tp;1518 public function typeSpecPathString "This function simply converts a Absyn.Path to a string." 1519 input Absyn.TypeSpec tp; 1520 1520 output String s; 1521 1521 algorithm s := match(tp) 1522 local Path p;1523 case( TCOMPLEX(path = p)) then pathString(p);1524 case( TPATH(path = p)) then pathString(p);1522 local Absyn.Path p; 1523 case(Absyn.TCOMPLEX(path = p)) then pathString(p); 1524 case(Absyn.TPATH(path = p)) then pathString(p); 1525 1525 end match; 1526 1526 end typeSpecPathString; 1527 1527 1528 1528 public function typeSpecPath 1529 "Converts a TypeSpec toPath"1530 input TypeSpec tp;1531 output Path op;1529 "Converts a Absyn.TypeSpec to Absyn.Path" 1530 input Absyn.TypeSpec tp; 1531 output Absyn.Path op; 1532 1532 algorithm 1533 1533 op := match(tp) 1534 local Path p;1535 case( TCOMPLEX(path = p)) then p;1536 case( TPATH(path = p)) then p;1534 local Absyn.Path p; 1535 case(Absyn.TCOMPLEX(path = p)) then p; 1536 case(Absyn.TPATH(path = p)) then p; 1537 1537 end match; 1538 1538 end typeSpecPath; 1539 1539 1540 1540 public function typeSpecDimensions 1541 "Returns the dimensions of a TypeSpec."1542 input TypeSpec inTypeSpec;1543 output A rrayDim outDimensions;1541 "Returns the dimensions of a Absyn.TypeSpec." 1542 input Absyn.TypeSpec inTypeSpec; 1543 output Absyn.ArrayDim outDimensions; 1544 1544 algorithm 1545 1545 outDimensions := match(inTypeSpec) 1546 1546 local 1547 A rrayDim dim;1548 1549 case TPATH(arrayDim = SOME(dim)) then dim;1550 case TCOMPLEX(arrayDim = SOME(dim)) then dim;1547 Absyn.ArrayDim dim; 1548 1549 case Absyn.TPATH(arrayDim = SOME(dim)) then dim; 1550 case Absyn.TCOMPLEX(arrayDim = SOME(dim)) then dim; 1551 1551 else {}; 1552 1552 … … 1554 1554 end typeSpecDimensions; 1555 1555 1556 public function pathString "This function simply converts a Path to a string."1557 input Path path;1556 public function pathString "This function simply converts a Absyn.Path to a string." 1557 input Absyn.Path path; 1558 1558 input String delimiter="."; 1559 1559 input Boolean usefq=true; … … 1561 1561 output String s; 1562 1562 protected 1563 Path p1,p2;1563 Absyn.Path p1,p2; 1564 1564 Integer count=0, len=0, dlen=stringLength(delimiter); 1565 1565 Boolean b; … … 1568 1568 p1 := if usefq then path else makeNotFullyQualified(path); 1569 1569 _ := match p1 1570 case IDENT()1570 case Absyn.IDENT() 1571 1571 algorithm 1572 1572 // Do not allocate memory if we're just going to copy the only identifier … … 1580 1580 while b loop 1581 1581 (p2,len,count,b) := match p2 1582 case IDENT() then (p2,len+1,count+stringLength(p2.name),false);1583 case QUALIFIED() then (p2.path,len+1,count+stringLength(p2.name),true);1584 case FULLYQUALIFIED() then (p2.path,len+1,count,true);1582 case Absyn.IDENT() then (p2,len+1,count+stringLength(p2.name),false); 1583 case Absyn.QUALIFIED() then (p2.path,len+1,count+stringLength(p2.name),true); 1584 case Absyn.FULLYQUALIFIED() then (p2.path,len+1,count,true); 1585 1585 end match; 1586 1586 end while; … … 1591 1591 1592 1592 function pathStringWork 1593 input Path inPath;1593 input Absyn.Path inPath; 1594 1594 input Integer len; 1595 1595 input String delimiter; … … 1598 1598 output String s=""; 1599 1599 protected 1600 Path p=inPath;1600 Absyn.Path p=inPath; 1601 1601 Boolean b=true; 1602 1602 Integer count=0; … … 1607 1607 while b loop 1608 1608 (p,count,b) := match p 1609 case IDENT()1609 case Absyn.IDENT() 1610 1610 algorithm 1611 1611 System.stringAllocatorStringCopy(sb, p.name, if reverse then len-count-stringLength(p.name) else count); 1612 1612 then (p,count+stringLength(p.name),false); 1613 case QUALIFIED()1613 case Absyn.QUALIFIED() 1614 1614 algorithm 1615 1615 System.stringAllocatorStringCopy(sb, p.name, if reverse then len-count-dlen-stringLength(p.name) else count); 1616 1616 System.stringAllocatorStringCopy(sb, delimiter, if reverse then len-count-dlen else count+stringLength(p.name)); 1617 1617 then (p.path,count+stringLength(p.name)+dlen,true); 1618 case FULLYQUALIFIED()1618 case Absyn.FULLYQUALIFIED() 1619 1619 algorithm 1620 1620 System.stringAllocatorStringCopy(sb, delimiter, if reverse then len-count-dlen else count); … … 1631 1631 1632 1632 function pathStringDefault 1633 input Path path;1633 input Absyn.Path path; 1634 1634 output String s = pathString(path); 1635 1635 end pathStringDefault; 1636 1636 1637 1637 public function classNameCompare 1638 input Class c1,c2;1638 input Absyn.Class c1,c2; 1639 1639 output Integer o; 1640 1640 algorithm … … 1643 1643 1644 1644 public function classNameGreater 1645 input Class c1,c2;1645 input Absyn.Class c1,c2; 1646 1646 output Boolean b; 1647 1647 algorithm … … 1650 1650 1651 1651 public function pathCompare 1652 input Path ip1;1653 input Path ip2;1652 input Absyn.Path ip1; 1653 input Absyn.Path ip2; 1654 1654 output Integer o; 1655 1655 algorithm 1656 1656 o := match (ip1,ip2) 1657 1657 local 1658 Path p1,p2;1658 Absyn.Path p1,p2; 1659 1659 String i1,i2; 1660 case ( FULLYQUALIFIED(p1),FULLYQUALIFIED(p2)) then pathCompare(p1,p2);1661 case ( FULLYQUALIFIED(),_) then 1;1662 case (_, FULLYQUALIFIED()) then -1;1663 case ( QUALIFIED(i1,p1),QUALIFIED(i2,p2))1660 case (Absyn.FULLYQUALIFIED(p1),Absyn.FULLYQUALIFIED(p2)) then pathCompare(p1,p2); 1661 case (Absyn.FULLYQUALIFIED(),_) then 1; 1662 case (_,Absyn.FULLYQUALIFIED()) then -1; 1663 case (Absyn.QUALIFIED(i1,p1),Absyn.QUALIFIED(i2,p2)) 1664 1664 equation 1665 1665 o = stringCompare(i1,i2); 1666 1666 o = if o == 0 then pathCompare(p1, p2) else o; 1667 1667 then o; 1668 case ( QUALIFIED(),_) then 1;1669 case (_, QUALIFIED()) then -1;1670 case ( IDENT(i1),IDENT(i2))1668 case (Absyn.QUALIFIED(),_) then 1; 1669 case (_,Absyn.QUALIFIED()) then -1; 1670 case (Absyn.IDENT(i1),Absyn.IDENT(i2)) 1671 1671 then stringCompare(i1,i2); 1672 1672 end match; … … 1674 1674 1675 1675 public function pathCompareNoQual 1676 input Path ip1;1677 input Path ip2;1676 input Absyn.Path ip1; 1677 input Absyn.Path ip2; 1678 1678 output Integer o; 1679 1679 algorithm 1680 1680 o := match (ip1,ip2) 1681 1681 local 1682 Path p1,p2;1682 Absyn.Path p1,p2; 1683 1683 String i1,i2; 1684 case ( FULLYQUALIFIED(p1),p2) then pathCompareNoQual(p1,p2);1685 case (p1, FULLYQUALIFIED(p2)) then pathCompareNoQual(p1,p2);1686 case ( QUALIFIED(i1,p1),QUALIFIED(i2,p2))1684 case (Absyn.FULLYQUALIFIED(p1),p2) then pathCompareNoQual(p1,p2); 1685 case (p1,Absyn.FULLYQUALIFIED(p2)) then pathCompareNoQual(p1,p2); 1686 case (Absyn.QUALIFIED(i1,p1),Absyn.QUALIFIED(i2,p2)) 1687 1687 equation 1688 1688 o = stringCompare(i1,i2); 1689 1689 o = if o == 0 then pathCompare(p1, p2) else o; 1690 1690 then o; 1691 case ( QUALIFIED(),_) then 1;1692 case (_, QUALIFIED()) then -1;1693 case ( IDENT(i1),IDENT(i2))1691 case (Absyn.QUALIFIED(),_) then 1; 1692 case (_,Absyn.QUALIFIED()) then -1; 1693 case (Absyn.IDENT(i1),Absyn.IDENT(i2)) 1694 1694 then stringCompare(i1,i2); 1695 1695 end match; … … 1697 1697 1698 1698 public function pathHashMod "Hashes a path." 1699 input Path path;1699 input Absyn.Path path; 1700 1700 input Integer mod; 1701 1701 output Integer hash; … … 1709 1709 1710 1710 public function pathHashModWork "Hashes a path." 1711 input Path path;1711 input Absyn.Path path; 1712 1712 input Integer acc; 1713 1713 output Integer hash; … … 1715 1715 hash := match (path,acc) 1716 1716 local 1717 Path p;1717 Absyn.Path p; 1718 1718 String s; 1719 1719 Integer i,i2; 1720 case ( FULLYQUALIFIED(p),_) then pathHashModWork(p, acc*31 + 46 /* '.' */);1721 case ( QUALIFIED(s,p),_) equation i = stringHashDjb2(s); i2 = acc*31+46; then pathHashModWork(p, i2*31 + i);1722 case ( IDENT(s),_) equation i = stringHashDjb2(s); i2 = acc*31+46; then i2*31 + i;1720 case (Absyn.FULLYQUALIFIED(p),_) then pathHashModWork(p, acc*31 + 46 /* '.' */); 1721 case (Absyn.QUALIFIED(s,p),_) equation i = stringHashDjb2(s); i2 = acc*31+46; then pathHashModWork(p, i2*31 + i); 1722 case (Absyn.IDENT(s),_) equation i = stringHashDjb2(s); i2 = acc*31+46; then i2*31 + i; 1723 1723 end match; 1724 1724 end pathHashModWork; 1725 1725 1726 1726 public function optPathString "Returns a path converted to string or an empty string if nothing exist" 1727 input Option< Path> inPathOption;1727 input Option<Absyn.Path> inPathOption; 1728 1728 output String outString; 1729 1729 algorithm 1730 1730 outString := match (inPathOption) 1731 1731 local 1732 Ident str;1733 Path p;1732 Absyn.Ident str; 1733 Absyn.Path p; 1734 1734 case (NONE()) then ""; 1735 1735 case (SOME(p)) … … 1747 1747 (Replaces dots with that separator). And also unquotes each ident. 1748 1748 " 1749 input Path inPath;1749 input Absyn.Path inPath; 1750 1750 input String repStr; 1751 1751 output String outString; … … 1764 1764 "Converts a string into a qualified path." 1765 1765 input String str; 1766 output Path qualifiedPath;1766 output Absyn.Path qualifiedPath; 1767 1767 1768 1768 protected … … 1776 1776 "Converts a list of strings into a qualified path." 1777 1777 input list<String> paths; 1778 output Path qualifiedPath;1778 output Absyn.Path qualifiedPath; 1779 1779 algorithm 1780 1780 qualifiedPath := matchcontinue(paths) … … 1782 1782 String str; 1783 1783 list<String> rest_str; 1784 Path p;1784 Absyn.Path p; 1785 1785 case ({}) then fail(); 1786 case (str :: {}) then IDENT(str);1786 case (str :: {}) then Absyn.IDENT(str); 1787 1787 case (str :: rest_str) 1788 1788 equation 1789 1789 p = stringListPath(rest_str); 1790 1790 then 1791 QUALIFIED(str, p);1791 Absyn.QUALIFIED(str, p); 1792 1792 end matchcontinue; 1793 1793 end stringListPath; … … 1797 1797 Ex: {'a', 'b', 'c'} => c.b.a" 1798 1798 input list<String> inStrings; 1799 output Path outPath;1799 output Absyn.Path outPath; 1800 1800 protected 1801 1801 String id; 1802 1802 list<String> rest_str; 1803 Path path;1803 Absyn.Path path; 1804 1804 algorithm 1805 1805 id :: rest_str := inStrings; 1806 path := IDENT(id);1806 path := Absyn.IDENT(id); 1807 1807 outPath := stringListPathReversed2(rest_str, path); 1808 1808 end stringListPathReversed; … … 1810 1810 protected function stringListPathReversed2 1811 1811 input list<String> inStrings; 1812 input Path inAccumPath;1813 output Path outPath;1812 input Absyn.Path inAccumPath; 1813 output Absyn.Path outPath; 1814 1814 algorithm 1815 1815 outPath := match(inStrings, inAccumPath) … … 1817 1817 String id; 1818 1818 list<String> rest_str; 1819 Path path;1819 Absyn.Path path; 1820 1820 1821 1821 case ({}, _) then inAccumPath; … … 1823 1823 case (id :: rest_str, _) 1824 1824 equation 1825 path = QUALIFIED(id, inAccumPath);1825 path = Absyn.QUALIFIED(id, inAccumPath); 1826 1826 then 1827 1827 stringListPathReversed2(rest_str, path); … … 1831 1831 1832 1832 public function pathTwoLastIdents "Returns the two last idents of a path" 1833 input Path inPath;1834 output Path outTwoLast;1833 input Absyn.Path inPath; 1834 output Absyn.Path outTwoLast; 1835 1835 algorithm 1836 1836 outTwoLast := match(inPath) 1837 1837 local 1838 Path p;1839 1840 case QUALIFIED(path =IDENT()) then inPath;1841 case QUALIFIED(path = p) then pathTwoLastIdents(p);1842 case FULLYQUALIFIED(path = p) then pathTwoLastIdents(p);1838 Absyn.Path p; 1839 1840 case Absyn.QUALIFIED(path = Absyn.IDENT()) then inPath; 1841 case Absyn.QUALIFIED(path = p) then pathTwoLastIdents(p); 1842 case Absyn.FULLYQUALIFIED(path = p) then pathTwoLastIdents(p); 1843 1843 end match; 1844 1844 end pathTwoLastIdents; … … 1846 1846 public function pathLastIdent 1847 1847 "Returns the last ident (after last dot) in a path" 1848 input Path inPath;1848 input Absyn.Path inPath; 1849 1849 output String outIdent; 1850 1850 algorithm 1851 1851 outIdent := match(inPath) 1852 1852 local 1853 Ident id;1854 Path p;1855 1856 case QUALIFIED(path = p) then pathLastIdent(p);1857 case IDENT(name = id) then id;1858 case FULLYQUALIFIED(path = p) then pathLastIdent(p);1853 Absyn.Ident id; 1854 Absyn.Path p; 1855 1856 case Absyn.QUALIFIED(path = p) then pathLastIdent(p); 1857 case Absyn.IDENT(name = id) then id; 1858 case Absyn.FULLYQUALIFIED(path = p) then pathLastIdent(p); 1859 1859 end match; 1860 1860 end pathLastIdent; … … 1862 1862 public function pathLast 1863 1863 "Returns the last ident (after last dot) in a path" 1864 input output Path path;1864 input output Absyn.Path path; 1865 1865 algorithm 1866 1866 path := match path 1867 1867 local 1868 Path p;1869 case QUALIFIED(path = p) then pathLast(p);1870 case IDENT() then path;1871 case FULLYQUALIFIED(path = p) then pathLast(p);1868 Absyn.Path p; 1869 case Absyn.QUALIFIED(path = p) then pathLast(p); 1870 case Absyn.IDENT() then path; 1871 case Absyn.FULLYQUALIFIED(path = p) then pathLast(p); 1872 1872 end match; 1873 1873 end pathLast; 1874 1874 1875 1875 public function pathFirstIdent "Returns the first ident (before first dot) in a path" 1876 input Path inPath;1877 output Ident outIdent;1876 input Absyn.Path inPath; 1877 output Absyn.Ident outIdent; 1878 1878 algorithm 1879 1879 outIdent := match (inPath) 1880 1880 local 1881 Ident n;1882 Path p;1883 1884 case ( FULLYQUALIFIED(path = p)) then pathFirstIdent(p);1885 case ( QUALIFIED(name = n)) then n;1886 case ( IDENT(name = n)) then n;1881 Absyn.Ident n; 1882 Absyn.Path p; 1883 1884 case (Absyn.FULLYQUALIFIED(path = p)) then pathFirstIdent(p); 1885 case (Absyn.QUALIFIED(name = n)) then n; 1886 case (Absyn.IDENT(name = n)) then n; 1887 1887 end match; 1888 1888 end pathFirstIdent; 1889 1889 1890 1890 public function pathFirstPath 1891 input Path inPath;1892 output Path outPath;1891 input Absyn.Path inPath; 1892 output Absyn.Path outPath; 1893 1893 algorithm 1894 1894 outPath := match inPath 1895 1895 local 1896 Ident n;1897 1898 case IDENT() then inPath;1899 case QUALIFIED(name = n) thenIDENT(n);1900 case FULLYQUALIFIED(path = outPath) then pathFirstPath(outPath);1896 Absyn.Ident n; 1897 1898 case Absyn.IDENT() then inPath; 1899 case Absyn.QUALIFIED(name = n) then Absyn.IDENT(n); 1900 case Absyn.FULLYQUALIFIED(path = outPath) then pathFirstPath(outPath); 1901 1901 end match; 1902 1902 end pathFirstPath; 1903 1903 1904 1904 public function pathSecondIdent 1905 input Path inPath;1906 output Ident outIdent;1905 input Absyn.Path inPath; 1906 output Absyn.Ident outIdent; 1907 1907 algorithm 1908 1908 outIdent := match(inPath) 1909 1909 local 1910 Ident n;1911 Path p;1912 1913 case QUALIFIED(path =QUALIFIED(name = n)) then n;1914 case QUALIFIED(path =IDENT(name = n)) then n;1915 case FULLYQUALIFIED(path = p) then pathSecondIdent(p);1910 Absyn.Ident n; 1911 Absyn.Path p; 1912 1913 case Absyn.QUALIFIED(path = Absyn.QUALIFIED(name = n)) then n; 1914 case Absyn.QUALIFIED(path = Absyn.IDENT(name = n)) then n; 1915 case Absyn.FULLYQUALIFIED(path = p) then pathSecondIdent(p); 1916 1916 1917 1917 end match; … … 1919 1919 1920 1920 public function pathRest 1921 input Path inPath;1922 output Path outPath;1921 input Absyn.Path inPath; 1922 output Absyn.Path outPath; 1923 1923 algorithm 1924 1924 outPath := match inPath 1925 case QUALIFIED(path = outPath) then outPath;1926 case FULLYQUALIFIED(path = outPath) then pathRest(outPath);1925 case Absyn.QUALIFIED(path = outPath) then outPath; 1926 case Absyn.FULLYQUALIFIED(path = outPath) then pathRest(outPath); 1927 1927 end match; 1928 1928 end pathRest; … … 1936 1936 outPath := matchcontinue(inPath1, inPath2) 1937 1937 local 1938 Ident ident1, ident2;1938 Absyn.Ident ident1, ident2; 1939 1939 Absyn.Path path1, path2; 1940 1940 … … 1955 1955 public function pathPrefix 1956 1956 "Returns the prefix of a path, i.e. this.is.a.path => this.is.a" 1957 input Path path;1958 output Path prefix;1957 input Absyn.Path path; 1958 output Absyn.Path prefix; 1959 1959 algorithm 1960 1960 prefix := matchcontinue(path) 1961 1961 local 1962 Path p;1963 Ident n;1964 1965 case ( FULLYQUALIFIED(path = p)) then pathPrefix(p);1966 case ( QUALIFIED(name = n, path = IDENT())) thenIDENT(n);1967 case ( QUALIFIED(name = n, path = p))1962 Absyn.Path p; 1963 Absyn.Ident n; 1964 1965 case (Absyn.FULLYQUALIFIED(path = p)) then pathPrefix(p); 1966 case (Absyn.QUALIFIED(name = n, path = Absyn.IDENT())) then Absyn.IDENT(n); 1967 case (Absyn.QUALIFIED(name = n, path = p)) 1968 1968 equation 1969 1969 p = pathPrefix(p); 1970 1970 then 1971 QUALIFIED(n, p);1971 Absyn.QUALIFIED(n, p); 1972 1972 end matchcontinue; 1973 1973 end pathPrefix; … … 1975 1975 public function prefixPath 1976 1976 "Prefixes a path with an identifier." 1977 input Ident prefix;1978 input Path path;1979 output Path outPath;1980 algorithm 1981 outPath := QUALIFIED(prefix, path);1977 input Absyn.Ident prefix; 1978 input Absyn.Path path; 1979 output Absyn.Path outPath; 1980 algorithm 1981 outPath := Absyn.QUALIFIED(prefix, path); 1982 1982 end prefixPath; 1983 1983 1984 1984 public function prefixOptPath 1985 1985 "Prefixes an optional path with an identifier." 1986 input Ident prefix;1987 input Option< Path> optPath;1988 output Option< Path> outPath;1986 input Absyn.Ident prefix; 1987 input Option<Absyn.Path> optPath; 1988 output Option<Absyn.Path> outPath; 1989 1989 algorithm 1990 1990 outPath := match(prefix, optPath) 1991 1991 local 1992 Path path;1993 1994 case (_, NONE()) then SOME( IDENT(prefix));1995 case (_, SOME(path)) then SOME( QUALIFIED(prefix, path));1992 Absyn.Path path; 1993 1994 case (_, NONE()) then SOME(Absyn.IDENT(prefix)); 1995 case (_, SOME(path)) then SOME(Absyn.QUALIFIED(prefix, path)); 1996 1996 end match; 1997 1997 end prefixOptPath; … … 2000 2000 "Adds a suffix to a path. Ex: 2001 2001 suffixPath(a.b.c, 'd') => a.b.c.d" 2002 input Path inPath;2003 input Ident inSuffix;2004 output Path outPath;2002 input Absyn.Path inPath; 2003 input Absyn.Ident inSuffix; 2004 output Absyn.Path outPath; 2005 2005 algorithm 2006 2006 outPath := match(inPath, inSuffix) 2007 2007 local 2008 Ident name;2009 Path path;2010 2011 case ( IDENT(name), _)2012 then QUALIFIED(name,IDENT(inSuffix));2013 2014 case ( QUALIFIED(name, path), _)2008 Absyn.Ident name; 2009 Absyn.Path path; 2010 2011 case (Absyn.IDENT(name), _) 2012 then Absyn.QUALIFIED(name, Absyn.IDENT(inSuffix)); 2013 2014 case (Absyn.QUALIFIED(name, path), _) 2015 2015 equation 2016 2016 path = suffixPath(path, inSuffix); 2017 2017 then 2018 QUALIFIED(name, path);2019 2020 case ( FULLYQUALIFIED(path), _)2018 Absyn.QUALIFIED(name, path); 2019 2020 case (Absyn.FULLYQUALIFIED(path), _) 2021 2021 equation 2022 2022 path = suffixPath(path, inSuffix); 2023 2023 then 2024 FULLYQUALIFIED(path);2024 Absyn.FULLYQUALIFIED(path); 2025 2025 2026 2026 end match; … … 2028 2028 2029 2029 public function pathSuffixOf "returns true if suffix_path is a suffix of path" 2030 input Path suffix_path;2031 input Path path;2030 input Absyn.Path suffix_path; 2031 input Absyn.Path path; 2032 2032 output Boolean res; 2033 2033 algorithm 2034 2034 res := matchcontinue(suffix_path,path) 2035 local Path p;2035 local Absyn.Path p; 2036 2036 case(_,_) 2037 2037 equation 2038 2038 true = pathEqual(suffix_path,path); 2039 2039 then true; 2040 case(_, FULLYQUALIFIED(path = p))2040 case(_,Absyn.FULLYQUALIFIED(path = p)) 2041 2041 then pathSuffixOf(suffix_path,p); 2042 case(_, QUALIFIED(path = p))2042 case(_,Absyn.QUALIFIED(path = p)) 2043 2043 then pathSuffixOf(suffix_path,p); 2044 2044 else false; … … 2047 2047 2048 2048 public function pathSuffixOfr "returns true if suffix_path is a suffix of path" 2049 input Path path;2050 input Path suffix_path;2049 input Absyn.Path path; 2050 input Absyn.Path suffix_path; 2051 2051 output Boolean res; 2052 2052 algorithm … … 2055 2055 2056 2056 public function pathToStringList 2057 input Path path;2057 input Absyn.Path path; 2058 2058 output list<String> outPaths; 2059 2059 algorithm … … 2062 2062 2063 2063 protected function pathToStringListWork 2064 input Path path;2064 input Absyn.Path path; 2065 2065 input list<String> acc; 2066 2066 output list<String> outPaths; … … 2069 2069 local 2070 2070 String n; 2071 Path p;2071 Absyn.Path p; 2072 2072 list<String> strings; 2073 2073 2074 case ( IDENT(name = n),_) then n::acc;2075 case ( FULLYQUALIFIED(path = p),_) then pathToStringListWork(p,acc);2076 case ( QUALIFIED(name = n,path = p),_)2074 case (Absyn.IDENT(name = n),_) then n::acc; 2075 case (Absyn.FULLYQUALIFIED(path = p),_) then pathToStringListWork(p,acc); 2076 case (Absyn.QUALIFIED(name = n,path = p),_) 2077 2077 then pathToStringListWork(p,n::acc); 2078 2078 end match; … … 2084 2084 (a, b.c.d) => b.c.d 2085 2085 " 2086 input Path path;2087 input Path replPath;2088 output Path outPath;2086 input Absyn.Path path; 2087 input Absyn.Path replPath; 2088 output Absyn.Path outPath; 2089 2089 algorithm 2090 2090 outPath := match(path,replPath) 2091 2091 local 2092 Path p;2092 Absyn.Path p; 2093 2093 // Should not be possible to replace FQ paths 2094 case ( QUALIFIED(path = p), _) then joinPaths(replPath,p);2095 case ( IDENT(), _) then replPath;2094 case (Absyn.QUALIFIED(path = p), _) then joinPaths(replPath,p); 2095 case (Absyn.IDENT(), _) then replPath; 2096 2096 end match; 2097 2097 end pathReplaceFirstIdent; … … 2099 2099 public function addSubscriptsLast 2100 2100 "Function for appending subscripts at end of last ident" 2101 input ComponentRef icr;2102 input list< Subscript> i;2103 output ComponentRef ocr;2101 input Absyn.ComponentRef icr; 2102 input list<Absyn.Subscript> i; 2103 output Absyn.ComponentRef ocr; 2104 2104 algorithm 2105 2105 ocr := match(icr,i) 2106 2106 local 2107 list< Subscript> subs;2107 list<Absyn.Subscript> subs; 2108 2108 String id; 2109 ComponentRef cr;2110 2111 case ( CREF_IDENT(id,subs),_)2112 then CREF_IDENT(id, listAppend(subs, i));2113 2114 case ( CREF_QUAL(id,subs,cr),_)2109 Absyn.ComponentRef cr; 2110 2111 case (Absyn.CREF_IDENT(id,subs),_) 2112 then Absyn.CREF_IDENT(id, listAppend(subs, i)); 2113 2114 case (Absyn.CREF_QUAL(id,subs,cr),_) 2115 2115 equation 2116 2116 cr = addSubscriptsLast(cr,i); 2117 2117 then 2118 CREF_QUAL(id,subs,cr);2119 case ( CREF_FULLYQUALIFIED(cr),_)2118 Absyn.CREF_QUAL(id,subs,cr); 2119 case (Absyn.CREF_FULLYQUALIFIED(cr),_) 2120 2120 equation 2121 2121 cr = addSubscriptsLast(cr,i); … … 2130 2130 (a[3], b.c.d) => b.c.d[3] 2131 2131 " 2132 input ComponentRef icref;2133 input Path replPath;2134 output ComponentRef outCref;2132 input Absyn.ComponentRef icref; 2133 input Absyn.Path replPath; 2134 output Absyn.ComponentRef outCref; 2135 2135 algorithm 2136 2136 outCref := match(icref,replPath) 2137 2137 local 2138 list< Subscript> subs;2139 ComponentRef cr,cref;2140 case ( CREF_FULLYQUALIFIED(componentRef = cr),_)2138 list<Absyn.Subscript> subs; 2139 Absyn.ComponentRef cr,cref; 2140 case (Absyn.CREF_FULLYQUALIFIED(componentRef = cr),_) 2141 2141 equation 2142 2142 cr = crefReplaceFirstIdent(cr,replPath); 2143 2143 then crefMakeFullyQualified(cr); 2144 case ( CREF_QUAL(componentRef = cr, subscripts = subs),_)2144 case (Absyn.CREF_QUAL(componentRef = cr, subscripts = subs),_) 2145 2145 equation 2146 2146 cref = pathToCref(replPath); 2147 2147 cref = addSubscriptsLast(cref,subs); 2148 2148 then joinCrefs(cref,cr); 2149 case ( CREF_IDENT(subscripts = subs),_)2149 case (Absyn.CREF_IDENT(subscripts = subs),_) 2150 2150 equation 2151 2151 cref = pathToCref(replPath); … … 2157 2157 public function pathPrefixOf 2158 2158 "Returns true if prefixPath is a prefix of path, false otherwise." 2159 input Path prefixPath;2160 input Path path;2159 input Absyn.Path prefixPath; 2160 input Absyn.Path path; 2161 2161 output Boolean isPrefix; 2162 2162 algorithm 2163 2163 isPrefix := matchcontinue(prefixPath, path) 2164 2164 local 2165 Path p, p2;2165 Absyn.Path p, p2; 2166 2166 String id, id2; 2167 case ( FULLYQUALIFIED(p), p2) then pathPrefixOf(p, p2);2168 case (p, FULLYQUALIFIED(p2)) then pathPrefixOf(p, p2);2169 case ( IDENT(id),IDENT(id2)) then stringEq(id, id2);2170 case ( IDENT(id),QUALIFIED(name = id2)) then stringEq(id, id2);2171 case ( QUALIFIED(id, p),QUALIFIED(id2, p2))2167 case (Absyn.FULLYQUALIFIED(p), p2) then pathPrefixOf(p, p2); 2168 case (p, Absyn.FULLYQUALIFIED(p2)) then pathPrefixOf(p, p2); 2169 case (Absyn.IDENT(id), Absyn.IDENT(id2)) then stringEq(id, id2); 2170 case (Absyn.IDENT(id), Absyn.QUALIFIED(name = id2)) then stringEq(id, id2); 2171 case (Absyn.QUALIFIED(id, p), Absyn.QUALIFIED(id2, p2)) 2172 2172 equation 2173 2173 true = stringEq(id, id2); … … 2185 2185 Returns true if prefixCr is a prefix of cr, i.e., false otherwise. 2186 2186 Subscripts are NOT checked." 2187 input ComponentRef prefixCr;2188 input ComponentRef cr;2187 input Absyn.ComponentRef prefixCr; 2188 input Absyn.ComponentRef cr; 2189 2189 output Boolean out; 2190 2190 algorithm … … 2201 2201 2202 2202 public function removePrefix "removes the prefix_path from path, and returns the rest of path" 2203 input Path prefix_path;2204 input Path path;2205 output Path newPath;2203 input Absyn.Path prefix_path; 2204 input Absyn.Path path; 2205 output Absyn.Path newPath; 2206 2206 algorithm 2207 2207 newPath := match(prefix_path,path) 2208 local Path p,p2;Ident id1,id2;2208 local Absyn.Path p,p2; Absyn.Ident id1,id2; 2209 2209 // fullyqual path 2210 case (p, FULLYQUALIFIED(p2)) then removePrefix(p,p2);2210 case (p,Absyn.FULLYQUALIFIED(p2)) then removePrefix(p,p2); 2211 2211 // qual 2212 case ( QUALIFIED(name=id1,path=p),QUALIFIED(name=id2,path=p2))2212 case (Absyn.QUALIFIED(name=id1,path=p),Absyn.QUALIFIED(name=id2,path=p2)) 2213 2213 equation 2214 2214 true = stringEq(id1, id2); … … 2216 2216 removePrefix(p,p2); 2217 2217 // ids 2218 case( IDENT(id1),QUALIFIED(name=id2,path=p2))2218 case(Absyn.IDENT(id1),Absyn.QUALIFIED(name=id2,path=p2)) 2219 2219 equation 2220 2220 true = stringEq(id1, id2); … … 2229 2229 removePartialPrefix(A.B.C, B.C.D.E) => D.E 2230 2230 " 2231 input Path inPrefix;2232 input Path inPath;2233 output Path outPath;2231 input Absyn.Path inPrefix; 2232 input Absyn.Path inPath; 2233 output Absyn.Path outPath; 2234 2234 algorithm 2235 2235 outPath := matchcontinue(inPrefix, inPath) 2236 2236 local 2237 Path p;2237 Absyn.Path p; 2238 2238 2239 2239 case (_, _) … … 2243 2243 p; 2244 2244 2245 case ( QUALIFIED(path = p), _)2245 case (Absyn.QUALIFIED(path = p), _) 2246 2246 equation 2247 2247 p = removePrefix(p, inPath); … … 2249 2249 p; 2250 2250 2251 case ( FULLYQUALIFIED(path = p), _)2251 case (Absyn.FULLYQUALIFIED(path = p), _) 2252 2252 equation 2253 2253 p = removePartialPrefix(p, inPath); … … 2268 2268 otherwise fails. Subscripts are NOT checked. 2269 2269 " 2270 input ComponentRef prefixCr;2271 input ComponentRef cr;2272 output ComponentRef out;2270 input Absyn.ComponentRef prefixCr; 2271 input Absyn.ComponentRef cr; 2272 output Absyn.ComponentRef out; 2273 2273 algorithm 2274 2274 out := match(prefixCr, cr) 2275 2275 local 2276 Ident prefixIdent, ident;2277 ComponentRef prefixRestCr, restCr;2276 Absyn.Ident prefixIdent, ident; 2277 Absyn.ComponentRef prefixRestCr, restCr; 2278 2278 // fqual 2279 case( CREF_FULLYQUALIFIED(componentRef = prefixRestCr),CREF_FULLYQUALIFIED(componentRef = restCr))2279 case(Absyn.CREF_FULLYQUALIFIED(componentRef = prefixRestCr), Absyn.CREF_FULLYQUALIFIED(componentRef = restCr)) 2280 2280 then 2281 2281 crefRemovePrefix(prefixRestCr, restCr); 2282 2282 // qual 2283 case( CREF_QUAL(name = prefixIdent, componentRef = prefixRestCr),CREF_QUAL(name = ident, componentRef = restCr))2283 case(Absyn.CREF_QUAL(name = prefixIdent, componentRef = prefixRestCr), Absyn.CREF_QUAL(name = ident, componentRef = restCr)) 2284 2284 equation 2285 2285 true = stringEq(prefixIdent, ident); … … 2287 2287 crefRemovePrefix(prefixRestCr, restCr); 2288 2288 // id vs. qual 2289 case( CREF_IDENT(name = prefixIdent),CREF_QUAL(name = ident, componentRef = restCr))2289 case(Absyn.CREF_IDENT(name = prefixIdent), Absyn.CREF_QUAL(name = ident, componentRef = restCr)) 2290 2290 equation 2291 2291 true = stringEq(prefixIdent, ident); 2292 2292 then restCr; 2293 2293 // id vs. id 2294 case( CREF_IDENT(name = prefixIdent),CREF_IDENT(name = ident))2294 case(Absyn.CREF_IDENT(name = prefixIdent), Absyn.CREF_IDENT(name = ident)) 2295 2295 equation 2296 2296 true = stringEq(prefixIdent, ident); 2297 then CREF_IDENT("", {});2297 then Absyn.CREF_IDENT("", {}); 2298 2298 end match; 2299 2299 end crefRemovePrefix; … … 2301 2301 public function pathContains 2302 2302 "Author BZ, 2303 checks if one IDENT(..) is contained in path."2304 input Path fullPath;2305 input Path pathId;2303 checks if one Absyn.IDENT(..) is contained in path." 2304 input Absyn.Path fullPath; 2305 input Absyn.Path pathId; 2306 2306 output Boolean b; 2307 2307 algorithm … … 2309 2309 local 2310 2310 String str1,str2; 2311 Path qp;2311 Absyn.Path qp; 2312 2312 Boolean b1,b2; 2313 2313 2314 case( IDENT(str1),IDENT(str2)) then stringEq(str1,str2);2315 2316 case( QUALIFIED(str1,qp),IDENT(str2))2314 case(Absyn.IDENT(str1),Absyn.IDENT(str2)) then stringEq(str1,str2); 2315 2316 case(Absyn.QUALIFIED(str1,qp),Absyn.IDENT(str2)) 2317 2317 equation 2318 2318 b1 = stringEq(str1,str2); … … 2322 2322 b1; 2323 2323 2324 case( FULLYQUALIFIED(qp),_) then pathContains(qp,pathId);2324 case(Absyn.FULLYQUALIFIED(qp),_) then pathContains(qp,pathId); 2325 2325 end match; 2326 2326 end pathContains; … … 2328 2328 public function pathContainsString 2329 2329 "Author OT, 2330 checks if Path contains the given string."2331 input Path p1;2330 checks if Absyn.Path contains the given string." 2331 input Absyn.Path p1; 2332 2332 input String str; 2333 2333 output Boolean b; … … 2336 2336 local 2337 2337 String str1,searchStr; 2338 Path qp;2338 Absyn.Path qp; 2339 2339 Boolean b1,b2,b3; 2340 2340 2341 case( IDENT(str1),searchStr)2341 case(Absyn.IDENT(str1),searchStr) 2342 2342 equation 2343 2343 b1 = System.stringFind(str1,searchStr) <> -1; 2344 2344 then b1; 2345 2345 2346 case( QUALIFIED(str1,qp),searchStr)2346 case(Absyn.QUALIFIED(str1,qp),searchStr) 2347 2347 equation 2348 2348 b1 = System.stringFind(str1, searchStr) <> -1; … … 2352 2352 b3; 2353 2353 2354 case( FULLYQUALIFIED(qp), searchStr) then pathContainsString(qp, searchStr);2354 case(Absyn.FULLYQUALIFIED(qp), searchStr) then pathContainsString(qp, searchStr); 2355 2355 end match; 2356 2356 end pathContainsString; … … 2364 2364 pathContainedIn(A.B.C.D, A.B.C.D) => A.B.C.D 2365 2365 pathContainedIn(B.C,A.B) => A.B.C" 2366 input Path subPath;2367 input Path path;2368 output Path completePath;2366 input Absyn.Path subPath; 2367 input Absyn.Path path; 2368 output Absyn.Path completePath; 2369 2369 algorithm 2370 2370 completePath := matchcontinue(subPath,path) 2371 2371 local 2372 Ident ident;2373 Path newPath,newSubPath;2372 Absyn.Ident ident; 2373 Absyn.Path newPath,newSubPath; 2374 2374 2375 2375 // A suffix, e.g. C.D in A.B.C.D … … 2385 2385 newPath = stripLast(path); 2386 2386 newPath=pathContainedIn(subPath,newPath); 2387 then joinPaths(newPath, IDENT(ident));2387 then joinPaths(newPath,Absyn.IDENT(ident)); 2388 2388 2389 2389 // strip last ident of subpath and recursively check if suffix. … … 2393 2393 newSubPath = stripLast(subPath); 2394 2394 newSubPath=pathContainedIn(newSubPath,path); 2395 then joinPaths(newSubPath, IDENT(ident));2395 then joinPaths(newSubPath,Absyn.IDENT(ident)); 2396 2396 2397 2397 end matchcontinue; … … 2401 2401 "Author BZ 2009-08 2402 2402 Function for getting ComponentRefs out from Subscripts" 2403 input list< Subscript> isubs;2403 input list<Absyn.Subscript> isubs; 2404 2404 input Boolean includeSubs "include crefs from array subscripts"; 2405 2405 input Boolean includeFunctions "note that if you say includeSubs = false then you won't get the functions from array subscripts"; 2406 output list< ComponentRef> crefs;2406 output list<Absyn.ComponentRef> crefs; 2407 2407 algorithm 2408 2408 crefs := match(isubs,includeSubs,includeFunctions) 2409 2409 local 2410 list< ComponentRef> crefs1;2411 Exp exp;2412 list< Subscript> subs;2410 list<Absyn.ComponentRef> crefs1; 2411 Absyn.Exp exp; 2412 list<Absyn.Subscript> subs; 2413 2413 2414 2414 case({},_,_) then {}; 2415 2415 2416 case( NOSUB()::subs,_,_) then getCrefsFromSubs(subs,includeSubs,includeFunctions);2417 2418 case( SUBSCRIPT(exp)::subs,_,_)2416 case(Absyn.NOSUB()::subs,_,_) then getCrefsFromSubs(subs,includeSubs,includeFunctions); 2417 2418 case(Absyn.SUBSCRIPT(exp)::subs,_,_) 2419 2419 equation 2420 2420 crefs1 = getCrefsFromSubs(subs,includeSubs,includeFunctions); … … 2428 2428 "Returns a flattened list of the 2429 2429 component references in an expression" 2430 input Exp inExp;2430 input Absyn.Exp inExp; 2431 2431 input Boolean includeSubs "include crefs from array subscripts"; 2432 2432 input Boolean includeFunctions "note that if you say includeSubs = false then you won't get the functions from array subscripts"; 2433 output list< ComponentRef> outComponentRefLst;2433 output list<Absyn.ComponentRef> outComponentRefLst; 2434 2434 algorithm 2435 2435 outComponentRefLst := match (inExp,includeSubs,includeFunctions) 2436 2436 local 2437 ComponentRef cr;2438 list< ComponentRef> l1,l2,res;2439 ComponentCondition e1,e2,e3;2440 Operator op;2441 list<tuple< ComponentCondition,ComponentCondition>> e4;2442 FunctionArgs farg;2443 list< ComponentCondition> expl;2444 list<list< ComponentCondition>> expll;2445 list< Subscript> subs;2446 list<list< ComponentRef>> lstres1;2447 list<list< ComponentRef>> crefll;2448 2449 case ( INTEGER(),_,_) then {};2450 case ( REAL(),_,_) then {};2451 case ( STRING(),_,_) then {};2452 case ( BOOL(),_,_) then {};2453 case ( CREF(componentRef =ALLWILD()),_,_) then {};2454 case ( CREF(componentRef =WILD()),_,_) then {};2455 case ( CREF(componentRef = cr),false,_) then {cr};2456 2457 case ( CREF(componentRef = (cr)),true,_)2437 Absyn.ComponentRef cr; 2438 list<Absyn.ComponentRef> l1,l2,res; 2439 Absyn.ComponentCondition e1,e2,e3; 2440 Absyn.Operator op; 2441 list<tuple<Absyn.ComponentCondition, Absyn.ComponentCondition>> e4; 2442 Absyn.FunctionArgs farg; 2443 list<Absyn.ComponentCondition> expl; 2444 list<list<Absyn.ComponentCondition>> expll; 2445 list<Absyn.Subscript> subs; 2446 list<list<Absyn.ComponentRef>> lstres1; 2447 list<list<Absyn.ComponentRef>> crefll; 2448 2449 case (Absyn.INTEGER(),_,_) then {}; 2450 case (Absyn.REAL(),_,_) then {}; 2451 case (Absyn.STRING(),_,_) then {}; 2452 case (Absyn.BOOL(),_,_) then {}; 2453 case (Absyn.CREF(componentRef = Absyn.ALLWILD()),_,_) then {}; 2454 case (Absyn.CREF(componentRef = Absyn.WILD()),_,_) then {}; 2455 case (Absyn.CREF(componentRef = cr),false,_) then {cr}; 2456 2457 case (Absyn.CREF(componentRef = (cr)),true,_) 2458 2458 equation 2459 2459 subs = getSubsFromCref(cr,includeSubs,includeFunctions); … … 2461 2461 then cr::l1; 2462 2462 2463 case ( BINARY(exp1 = e1,exp2 = e2),_,_)2463 case (Absyn.BINARY(exp1 = e1,exp2 = e2),_,_) 2464 2464 equation 2465 2465 l1 = getCrefFromExp(e1,includeSubs,includeFunctions); … … 2469 2469 res; 2470 2470 2471 case ( UNARY(exp = e1),_,_)2471 case (Absyn.UNARY(exp = e1),_,_) 2472 2472 equation 2473 2473 res = getCrefFromExp(e1,includeSubs,includeFunctions); … … 2475 2475 res; 2476 2476 2477 case ( LBINARY(exp1 = e1,exp2 = e2),_,_)2477 case (Absyn.LBINARY(exp1 = e1,exp2 = e2),_,_) 2478 2478 equation 2479 2479 l1 = getCrefFromExp(e1,includeSubs,includeFunctions); … … 2483 2483 res; 2484 2484 2485 case ( LUNARY(exp = e1),_,_)2485 case (Absyn.LUNARY(exp = e1),_,_) 2486 2486 equation 2487 2487 res = getCrefFromExp(e1,includeSubs,includeFunctions); … … 2489 2489 res; 2490 2490 2491 case ( RELATION(exp1 = e1,exp2 = e2),_,_)2491 case (Absyn.RELATION(exp1 = e1,exp2 = e2),_,_) 2492 2492 equation 2493 2493 l1 = getCrefFromExp(e1,includeSubs,includeFunctions); … … 2498 2498 2499 2499 // TODO: Handle else if-branches. 2500 case ( IFEXP(ifExp = e1,trueBranch = e2,elseBranch = e3),_,_)2500 case (Absyn.IFEXP(ifExp = e1,trueBranch = e2,elseBranch = e3),_,_) 2501 2501 then List.flatten({ 2502 2502 getCrefFromExp(e1, includeSubs, includeFunctions), … … 2504 2504 getCrefFromExp(e3, includeSubs, includeFunctions)}); 2505 2505 2506 case ( CALL(function_ = cr, functionArgs = farg),_,_)2506 case (Absyn.CALL(function_ = cr, functionArgs = farg),_,_) 2507 2507 equation 2508 2508 res = getCrefFromFarg(farg,includeSubs,includeFunctions); … … 2510 2510 then 2511 2511 res; 2512 case ( PARTEVALFUNCTION(function_ = cr, functionArgs = farg),_,_)2512 case (Absyn.PARTEVALFUNCTION(function_ = cr, functionArgs = farg),_,_) 2513 2513 equation 2514 2514 res = getCrefFromFarg(farg,includeSubs,includeFunctions); … … 2516 2516 then 2517 2517 res; 2518 case (A RRAY(arrayExp = expl),_,_)2518 case (Absyn.ARRAY(arrayExp = expl),_,_) 2519 2519 equation 2520 2520 lstres1 = List.map2(expl, getCrefFromExp, includeSubs, includeFunctions); … … 2522 2522 then 2523 2523 res; 2524 case ( MATRIX(matrix = expll),_,_)2524 case (Absyn.MATRIX(matrix = expll),_,_) 2525 2525 equation 2526 2526 res = List.flatten(List.flatten(List.map2List(expll, getCrefFromExp, includeSubs, includeFunctions))); 2527 2527 then 2528 2528 res; 2529 case ( RANGE(start = e1,step = SOME(e3),stop = e2),_,_)2529 case (Absyn.RANGE(start = e1,step = SOME(e3),stop = e2),_,_) 2530 2530 equation 2531 2531 l1 = getCrefFromExp(e1,includeSubs,includeFunctions); … … 2536 2536 then 2537 2537 res; 2538 case ( RANGE(start = e1,step = NONE(),stop = e2),_,_)2538 case (Absyn.RANGE(start = e1,step = NONE(),stop = e2),_,_) 2539 2539 equation 2540 2540 l1 = getCrefFromExp(e1,includeSubs,includeFunctions); … … 2544 2544 res; 2545 2545 2546 case ( END(),_,_) then {};2547 2548 case ( TUPLE(expressions = expl),_,_)2546 case (Absyn.END(),_,_) then {}; 2547 2548 case (Absyn.TUPLE(expressions = expl),_,_) 2549 2549 equation 2550 2550 crefll = List.map2(expl,getCrefFromExp,includeSubs,includeFunctions); … … 2553 2553 res; 2554 2554 2555 case ( CODE(),_,_) then {};2556 2557 case (A S(exp = e1),_,_) then getCrefFromExp(e1,includeSubs,includeFunctions);2558 2559 case ( CONS(e1,e2),_,_)2555 case (Absyn.CODE(),_,_) then {}; 2556 2557 case (Absyn.AS(exp = e1),_,_) then getCrefFromExp(e1,includeSubs,includeFunctions); 2558 2559 case (Absyn.CONS(e1,e2),_,_) 2560 2560 equation 2561 2561 l1 = getCrefFromExp(e1,includeSubs,includeFunctions); … … 2565 2565 res; 2566 2566 2567 case ( LIST(expl),_,_)2567 case (Absyn.LIST(expl),_,_) 2568 2568 equation 2569 2569 crefll = List.map2(expl,getCrefFromExp,includeSubs,includeFunctions); … … 2572 2572 res; 2573 2573 2574 case ( MATCHEXP(),_,_) then fail();2575 2576 case ( DOT(),_,_)2574 case (Absyn.MATCHEXP(),_,_) then fail(); 2575 2576 case (Absyn.DOT(),_,_) 2577 2577 // inExp.index is only allowed to contain names to index the function call; not crefs that are evaluated in any way 2578 2578 then getCrefFromExp(inExp.exp,includeSubs,includeFunctions); … … 2587 2587 public function getCrefFromFarg "Returns the flattened list of all component references 2588 2588 present in a list of function arguments." 2589 input FunctionArgs inFunctionArgs;2589 input Absyn.FunctionArgs inFunctionArgs; 2590 2590 input Boolean includeSubs "include crefs from array subscripts"; 2591 2591 input Boolean includeFunctions "note that if you say includeSubs = false then you won't get the functions from array subscripts"; 2592 output list< ComponentRef> outComponentRefLst;2592 output list<Absyn.ComponentRef> outComponentRefLst; 2593 2593 algorithm 2594 2594 outComponentRefLst := match (inFunctionArgs,includeSubs,includeFunctions) 2595 2595 local 2596 list<list< ComponentRef>> l1,l2;2597 list< ComponentRef> fl1,fl2,fl3,res;2598 list< ComponentCondition> expl;2599 list< NamedArg> nargl;2600 ForIterators iterators;2601 Exp exp;2602 2603 case ( FUNCTIONARGS(args = expl,argNames = nargl),_,_)2596 list<list<Absyn.ComponentRef>> l1,l2; 2597 list<Absyn.ComponentRef> fl1,fl2,fl3,res; 2598 list<Absyn.ComponentCondition> expl; 2599 list<Absyn.NamedArg> nargl; 2600 Absyn.ForIterators iterators; 2601 Absyn.Exp exp; 2602 2603 case (Absyn.FUNCTIONARGS(args = expl,argNames = nargl),_,_) 2604 2604 equation 2605 2605 l1 = List.map2(expl, getCrefFromExp, includeSubs, includeFunctions); … … 2611 2611 res; 2612 2612 2613 case ( FOR_ITER_FARG(exp,_,iterators),_,_)2613 case (Absyn.FOR_ITER_FARG(exp,_,iterators),_,_) 2614 2614 equation 2615 2615 l1 = List.map2Option(List.map(iterators,iteratorRange),getCrefFromExp,includeSubs,includeFunctions); … … 2626 2626 2627 2627 public function iteratorName 2628 input ForIterator iterator;2628 input Absyn.ForIterator iterator; 2629 2629 output String name; 2630 2630 algorithm 2631 ITERATOR(name=name) := iterator;2631 Absyn.ITERATOR(name=name) := iterator; 2632 2632 end iteratorName; 2633 2633 2634 2634 public function iteratorRange 2635 input ForIterator iterator;2636 output Option< Exp> range;2637 algorithm 2638 ITERATOR(range=range) := iterator;2635 input Absyn.ForIterator iterator; 2636 output Option<Absyn.Exp> range; 2637 algorithm 2638 Absyn.ITERATOR(range=range) := iterator; 2639 2639 end iteratorRange; 2640 2640 2641 2641 public function iteratorGuard 2642 input ForIterator iterator;2643 output Option< Exp> guardExp;2644 algorithm 2645 ITERATOR(guardExp=guardExp) := iterator;2642 input Absyn.ForIterator iterator; 2643 output Option<Absyn.Exp> guardExp; 2644 algorithm 2645 Absyn.ITERATOR(guardExp=guardExp) := iterator; 2646 2646 end iteratorGuard; 2647 2647 … … 2649 2649 public function getNamedFuncArgNamesAndValues 2650 2650 "returns the names from a list of NamedArgs as a string list" 2651 input list< NamedArg> inNamedArgList;2651 input list<Absyn.NamedArg> inNamedArgList; 2652 2652 output list<String> outStringList; 2653 output list< Exp> outExpList;2653 output list<Absyn.Exp> outExpList; 2654 2654 algorithm 2655 2655 (outStringList,outExpList) := match ( inNamedArgList ) 2656 2656 local 2657 list< NamedArg> cdr;2657 list<Absyn.NamedArg> cdr; 2658 2658 String s; 2659 Exp e;2659 Absyn.Exp e; 2660 2660 list<String> slst; 2661 list< Exp> elst;2661 list<Absyn.Exp> elst; 2662 2662 2663 2663 case ({}) then ({},{}); 2664 case ( NAMEDARG(argName=s,argValue=e) :: cdr)2664 case (Absyn.NAMEDARG(argName=s,argValue=e) :: cdr) 2665 2665 equation 2666 2666 (slst,elst) = getNamedFuncArgNamesAndValues(cdr); … … 2672 2672 protected function getCrefFromNarg "Returns the flattened list of all component references 2673 2673 present in a list of named function arguments." 2674 input NamedArg inNamedArg;2674 input Absyn.NamedArg inNamedArg; 2675 2675 input Boolean includeSubs "include crefs from array subscripts"; 2676 2676 input Boolean includeFunctions "note that if you say includeSubs = false then you won't get the functions from array subscripts"; 2677 output list< ComponentRef> outComponentRefLst;2677 output list<Absyn.ComponentRef> outComponentRefLst; 2678 2678 algorithm 2679 2679 outComponentRefLst := match (inNamedArg,includeSubs,includeFunctions) 2680 2680 local 2681 list< ComponentRef> res;2682 ComponentCondition exp;2683 case ( NAMEDARG(argValue = exp),_,_)2681 list<Absyn.ComponentRef> res; 2682 Absyn.ComponentCondition exp; 2683 case (Absyn.NAMEDARG(argValue = exp),_,_) 2684 2684 equation 2685 2685 res = getCrefFromExp(exp,includeSubs,includeFunctions); … … 2690 2690 2691 2691 public function joinPaths "This function joins two paths" 2692 input Path inPath1;2693 input Path inPath2;2694 output Path outPath;2692 input Absyn.Path inPath1; 2693 input Absyn.Path inPath2; 2694 output Absyn.Path outPath; 2695 2695 algorithm 2696 2696 outPath := match (inPath1,inPath2) 2697 2697 local 2698 Ident str;2699 Path p2,p_1,p;2700 case ( IDENT(name = str),p2) thenQUALIFIED(str,p2);2701 case ( QUALIFIED(name = str,path = p),p2)2698 Absyn.Ident str; 2699 Absyn.Path p2,p_1,p; 2700 case (Absyn.IDENT(name = str),p2) then Absyn.QUALIFIED(str,p2); 2701 case (Absyn.QUALIFIED(name = str,path = p),p2) 2702 2702 equation 2703 2703 p_1 = joinPaths(p, p2); 2704 2704 then 2705 QUALIFIED(str,p_1);2706 case( FULLYQUALIFIED(p),p2) then joinPaths(p,p2);2707 case(p, FULLYQUALIFIED(p2)) then joinPaths(p,p2);2705 Absyn.QUALIFIED(str,p_1); 2706 case(Absyn.FULLYQUALIFIED(p),p2) then joinPaths(p,p2); 2707 case(p,Absyn.FULLYQUALIFIED(p2)) then joinPaths(p,p2); 2708 2708 end match; 2709 2709 end joinPaths; 2710 2710 2711 2711 public function joinPathsOpt "This function joins two paths when the first one might be NONE" 2712 input Option< Path> inPath1;2713 input Path inPath2;2714 output Path outPath;2712 input Option<Absyn.Path> inPath1; 2713 input Absyn.Path inPath2; 2714 output Absyn.Path outPath; 2715 2715 algorithm 2716 2716 outPath := match (inPath1,inPath2) 2717 local Path p;2717 local Absyn.Path p; 2718 2718 case (NONE(), _) then inPath2; 2719 2719 case (SOME(p), _) then joinPaths(p, inPath2); … … 2722 2722 2723 2723 public function joinPathsOptSuffix 2724 input Path inPath1;2725 input Option< Path> inPath2;2726 output Path outPath;2724 input Absyn.Path inPath1; 2725 input Option<Absyn.Path> inPath2; 2726 output Absyn.Path outPath; 2727 2727 algorithm 2728 2728 outPath := match(inPath1, inPath2) 2729 2729 local 2730 Path p;2730 Absyn.Path p; 2731 2731 2732 2732 case (_, SOME(p)) then joinPaths(inPath1, p); … … 2738 2738 public function selectPathsOpt "This function selects the second path when the first one 2739 2739 is NONE() otherwise it will select the first one." 2740 input Option< Path> inPath1;2741 input Path inPath2;2742 output Path outPath;2740 input Option<Absyn.Path> inPath1; 2741 input Absyn.Path inPath2; 2742 output Absyn.Path outPath; 2743 2743 algorithm 2744 2744 outPath := match (inPath1,inPath2) 2745 2745 local 2746 Path p;2746 Absyn.Path p; 2747 2747 case (NONE(), p) then p; 2748 2748 case (SOME(p),_) then p; … … 2752 2752 public function pathAppendList "author Lucian 2753 2753 This function joins a path list" 2754 input list< Path> inPathLst;2755 output Path outPath;2754 input list<Absyn.Path> inPathLst; 2755 output Absyn.Path outPath; 2756 2756 algorithm 2757 2757 outPath := match (inPathLst) 2758 2758 local 2759 Path path,res_path,first;2760 list< Path> rest;2761 case ({}) then IDENT("");2759 Absyn.Path path,res_path,first; 2760 list<Absyn.Path> rest; 2761 case ({}) then Absyn.IDENT(""); 2762 2762 case ((path :: {})) then path; 2763 2763 case ((first :: rest)) … … 2772 2772 public function stripLast "Returns the path given as argument to 2773 2773 the function minus the last ident." 2774 input Path inPath;2775 output Path outPath;2774 input Absyn.Path inPath; 2775 output Absyn.Path outPath; 2776 2776 algorithm 2777 2777 outPath := match (inPath) 2778 2778 local 2779 Ident str;2780 Path p;2781 2782 case QUALIFIED(name = str, path =IDENT())2783 then IDENT(str);2784 2785 case QUALIFIED(name = str, path = p)2779 Absyn.Ident str; 2780 Absyn.Path p; 2781 2782 case Absyn.QUALIFIED(name = str, path = Absyn.IDENT()) 2783 then Absyn.IDENT(str); 2784 2785 case Absyn.QUALIFIED(name = str, path = p) 2786 2786 equation 2787 2787 p = stripLast(p); 2788 2788 then 2789 QUALIFIED(str, p);2790 2791 case FULLYQUALIFIED(p)2789 Absyn.QUALIFIED(str, p); 2790 2791 case Absyn.FULLYQUALIFIED(p) 2792 2792 equation 2793 2793 p = stripLast(p); 2794 2794 then 2795 FULLYQUALIFIED(p);2795 Absyn.FULLYQUALIFIED(p); 2796 2796 2797 2797 end match; … … 2799 2799 2800 2800 public function stripLastOpt 2801 input Path inPath;2802 output Option< Path> outPath;2801 input Absyn.Path inPath; 2802 output Option<Absyn.Path> outPath; 2803 2803 algorithm 2804 2804 outPath := match(inPath) 2805 2805 local 2806 Path p;2807 2808 case IDENT() then NONE();2806 Absyn.Path p; 2807 2808 case Absyn.IDENT() then NONE(); 2809 2809 2810 2810 else … … 2819 2819 public function crefStripLast "Returns the path given as argument to 2820 2820 the function minus the last ident." 2821 input ComponentRef inCref;2822 output ComponentRef outCref;2821 input Absyn.ComponentRef inCref; 2822 output Absyn.ComponentRef outCref; 2823 2823 algorithm 2824 2824 outCref := match (inCref) 2825 2825 local 2826 Ident str;2827 ComponentRef c_1, c;2828 list< Subscript> subs;2829 2830 case ( CREF_IDENT()) then fail();2831 case ( CREF_QUAL(name = str,subscripts = subs, componentRef = CREF_IDENT())) thenCREF_IDENT(str,subs);2832 case ( CREF_QUAL(name = str,subscripts = subs,componentRef = c))2826 Absyn.Ident str; 2827 Absyn.ComponentRef c_1, c; 2828 list<Absyn.Subscript> subs; 2829 2830 case (Absyn.CREF_IDENT()) then fail(); 2831 case (Absyn.CREF_QUAL(name = str,subscripts = subs, componentRef = Absyn.CREF_IDENT())) then Absyn.CREF_IDENT(str,subs); 2832 case (Absyn.CREF_QUAL(name = str,subscripts = subs,componentRef = c)) 2833 2833 equation 2834 2834 c_1 = crefStripLast(c); 2835 2835 then 2836 CREF_QUAL(str,subs,c_1);2837 case ( CREF_FULLYQUALIFIED(componentRef = c))2836 Absyn.CREF_QUAL(str,subs,c_1); 2837 case (Absyn.CREF_FULLYQUALIFIED(componentRef = c)) 2838 2838 equation 2839 2839 c_1 = crefStripLast(c); … … 2848 2848 qualified part, and ident part (all_but_last, last); 2849 2849 " 2850 input Path inPath;2851 output Path outPath1;2852 output Path outPath2;2850 input Absyn.Path inPath; 2851 output Absyn.Path outPath1; 2852 output Absyn.Path outPath2; 2853 2853 algorithm (outPath1,outPath2) := match(inPath) 2854 2854 local 2855 Path qPath,curPath,identPath;2855 Absyn.Path qPath,curPath,identPath; 2856 2856 String s1,s2; 2857 2857 2858 case ( QUALIFIED(name = s1, path =IDENT(name = s2)))2859 then ( IDENT(s1),IDENT(s2));2860 2861 case ( QUALIFIED(name = s1, path = qPath))2858 case (Absyn.QUALIFIED(name = s1, path = Absyn.IDENT(name = s2))) 2859 then (Absyn.IDENT(s1), Absyn.IDENT(s2)); 2860 2861 case (Absyn.QUALIFIED(name = s1, path = qPath)) 2862 2862 equation 2863 2863 (curPath, identPath) = splitQualAndIdentPath(qPath); 2864 2864 then 2865 ( QUALIFIED(s1, curPath), identPath);2866 2867 case ( FULLYQUALIFIED(qPath))2865 (Absyn.QUALIFIED(s1, curPath), identPath); 2866 2867 case (Absyn.FULLYQUALIFIED(qPath)) 2868 2868 equation 2869 2869 (curPath, identPath) = splitQualAndIdentPath(qPath); … … 2875 2875 public function stripFirst "Returns the path given as argument 2876 2876 to the function minus the first ident." 2877 input Path inPath;2878 output Path outPath;2877 input Absyn.Path inPath; 2878 output Absyn.Path outPath; 2879 2879 algorithm 2880 2880 outPath:= 2881 2881 match (inPath) 2882 2882 local 2883 Path p;2884 case ( QUALIFIED(path = p)) then p;2885 case( FULLYQUALIFIED(p)) then stripFirst(p);2883 Absyn.Path p; 2884 case (Absyn.QUALIFIED(path = p)) then p; 2885 case(Absyn.FULLYQUALIFIED(p)) then stripFirst(p); 2886 2886 end match; 2887 2887 end stripFirst; 2888 2888 2889 public function crefToPath "This function converts a ComponentRef to aPath, if possible.2889 public function crefToPath "This function converts a Absyn.ComponentRef to a Absyn.Path, if possible. 2890 2890 If the component reference contains subscripts, it will silently fail." 2891 input ComponentRef inComponentRef;2892 output Path outPath;2891 input Absyn.ComponentRef inComponentRef; 2892 output Absyn.Path outPath; 2893 2893 algorithm 2894 2894 outPath:= 2895 2895 match (inComponentRef) 2896 2896 local 2897 Ident i;2898 Path p;2899 ComponentRef c;2900 case CREF_IDENT(name = i,subscripts = {}) thenIDENT(i);2901 case CREF_QUAL(name = i,subscripts = {},componentRef = c)2897 Absyn.Ident i; 2898 Absyn.Path p; 2899 Absyn.ComponentRef c; 2900 case Absyn.CREF_IDENT(name = i,subscripts = {}) then Absyn.IDENT(i); 2901 case Absyn.CREF_QUAL(name = i,subscripts = {},componentRef = c) 2902 2902 equation 2903 2903 p = crefToPath(c); 2904 2904 then 2905 QUALIFIED(i,p);2906 case CREF_FULLYQUALIFIED(componentRef = c)2905 Absyn.QUALIFIED(i,p); 2906 case Absyn.CREF_FULLYQUALIFIED(componentRef = c) 2907 2907 equation 2908 2908 p = crefToPath(c); 2909 2909 then 2910 FULLYQUALIFIED(p);2910 Absyn.FULLYQUALIFIED(p); 2911 2911 end match; 2912 2912 end crefToPath; 2913 2913 2914 public function elementSpecToPath "This function converts a ElementSpec to aPath, if possible.2915 If the ElementSpec is not EXTENDS, it will silently fail."2916 input ElementSpec inElementSpec;2917 output Path outPath;2914 public function elementSpecToPath "This function converts a Absyn.ElementSpec to a Absyn.Path, if possible. 2915 If the Absyn.ElementSpec is not EXTENDS, it will silently fail." 2916 input Absyn.ElementSpec inElementSpec; 2917 output Absyn.Path outPath; 2918 2918 algorithm 2919 2919 outPath:= match (inElementSpec) 2920 2920 local 2921 Path p;2922 case EXTENDS(path = p) then p;2921 Absyn.Path p; 2922 case Absyn.EXTENDS(path = p) then p; 2923 2923 end match; 2924 2924 end elementSpecToPath; 2925 2925 2926 2926 public function crefToPathIgnoreSubs 2927 "Converts a ComponentRef to aPath, ignoring any subscripts."2928 input ComponentRef inComponentRef;2929 output Path outPath;2927 "Converts a Absyn.ComponentRef to a Absyn.Path, ignoring any subscripts." 2928 input Absyn.ComponentRef inComponentRef; 2929 output Absyn.Path outPath; 2930 2930 algorithm 2931 2931 outPath := match(inComponentRef) 2932 2932 local 2933 Ident i;2934 Path p;2935 ComponentRef c;2936 2937 case CREF_IDENT(name = i) thenIDENT(i);2938 2939 case CREF_QUAL(name = i, componentRef = c)2933 Absyn.Ident i; 2934 Absyn.Path p; 2935 Absyn.ComponentRef c; 2936 2937 case Absyn.CREF_IDENT(name = i) then Absyn.IDENT(i); 2938 2939 case Absyn.CREF_QUAL(name = i, componentRef = c) 2940 2940 equation 2941 2941 p = crefToPathIgnoreSubs(c); 2942 2942 then 2943 QUALIFIED(i, p);2944 2945 case CREF_FULLYQUALIFIED(componentRef = c)2943 Absyn.QUALIFIED(i, p); 2944 2945 case Absyn.CREF_FULLYQUALIFIED(componentRef = c) 2946 2946 equation 2947 2947 p = crefToPathIgnoreSubs(c); 2948 2948 then 2949 FULLYQUALIFIED(p);2949 Absyn.FULLYQUALIFIED(p); 2950 2950 end match; 2951 2951 end crefToPathIgnoreSubs; 2952 2952 2953 public function pathToCref "This function converts a Path to aComponentRef."2954 input Path inPath;2955 output ComponentRef outComponentRef;2953 public function pathToCref "This function converts a Absyn.Path to a Absyn.ComponentRef." 2954 input Absyn.Path inPath; 2955 output Absyn.ComponentRef outComponentRef; 2956 2956 algorithm 2957 2957 outComponentRef:= 2958 2958 match (inPath) 2959 2959 local 2960 Ident i;2961 ComponentRef c;2962 Path p;2963 case IDENT(name = i) thenCREF_IDENT(i,{});2964 case QUALIFIED(name = i,path = p)2960 Absyn.Ident i; 2961 Absyn.ComponentRef c; 2962 Absyn.Path p; 2963 case Absyn.IDENT(name = i) then Absyn.CREF_IDENT(i,{}); 2964 case Absyn.QUALIFIED(name = i,path = p) 2965 2965 equation 2966 2966 c = pathToCref(p); 2967 2967 then 2968 CREF_QUAL(i,{},c);2969 case( FULLYQUALIFIED(p))2968 Absyn.CREF_QUAL(i,{},c); 2969 case(Absyn.FULLYQUALIFIED(p)) 2970 2970 equation 2971 2971 c = pathToCref(p); … … 2975 2975 2976 2976 public function pathToCrefWithSubs 2977 "This function converts a Path to aComponentRef, and applies the given2977 "This function converts a Absyn.Path to a Absyn.ComponentRef, and applies the given 2978 2978 subscripts to the last identifier." 2979 input Path inPath;2980 input list< Subscript> inSubs;2981 output ComponentRef outComponentRef;2979 input Absyn.Path inPath; 2980 input list<Absyn.Subscript> inSubs; 2981 output Absyn.ComponentRef outComponentRef; 2982 2982 algorithm 2983 2983 outComponentRef := match(inPath, inSubs) 2984 2984 local 2985 Ident i;2986 ComponentRef c;2987 Path p;2988 2989 case ( IDENT(name = i), _) thenCREF_IDENT(i, inSubs);2990 2991 case ( QUALIFIED(name = i, path = p), _)2985 Absyn.Ident i; 2986 Absyn.ComponentRef c; 2987 Absyn.Path p; 2988 2989 case (Absyn.IDENT(name = i), _) then Absyn.CREF_IDENT(i, inSubs); 2990 2991 case (Absyn.QUALIFIED(name = i, path = p), _) 2992 2992 equation 2993 2993 c = pathToCrefWithSubs(p, inSubs); 2994 2994 then 2995 CREF_QUAL(i, {}, c);2996 2997 case ( FULLYQUALIFIED(p), _)2995 Absyn.CREF_QUAL(i, {}, c); 2996 2997 case (Absyn.FULLYQUALIFIED(p), _) 2998 2998 equation 2999 2999 c = pathToCrefWithSubs(p, inSubs); … … 3005 3005 public function crefLastIdent 3006 3006 "Returns the last identifier in a component reference." 3007 input ComponentRef inComponentRef;3008 output Ident outIdent;3007 input Absyn.ComponentRef inComponentRef; 3008 output Absyn.Ident outIdent; 3009 3009 algorithm 3010 3010 outIdent := match(inComponentRef) 3011 3011 local 3012 ComponentRef cref;3013 Ident id;3014 3015 case CREF_IDENT(name = id) then id;3016 case CREF_QUAL(componentRef = cref) then crefLastIdent(cref);3017 case CREF_FULLYQUALIFIED(componentRef = cref) then crefLastIdent(cref);3012 Absyn.ComponentRef cref; 3013 Absyn.Ident id; 3014 3015 case Absyn.CREF_IDENT(name = id) then id; 3016 case Absyn.CREF_QUAL(componentRef = cref) then crefLastIdent(cref); 3017 case Absyn.CREF_FULLYQUALIFIED(componentRef = cref) then crefLastIdent(cref); 3018 3018 end match; 3019 3019 end crefLastIdent; … … 3022 3022 "Returns the basename of the component reference, but fails if it encounters 3023 3023 any subscripts." 3024 input ComponentRef inCref;3025 output Ident outIdent;3024 input Absyn.ComponentRef inCref; 3025 output Absyn.Ident outIdent; 3026 3026 algorithm 3027 3027 outIdent := match(inCref) 3028 3028 local 3029 Ident id;3030 ComponentRef cr;3031 case CREF_IDENT(name = id, subscripts = {}) then id;3032 case CREF_QUAL(name = id, subscripts = {}) then id;3033 case CREF_FULLYQUALIFIED(componentRef = cr) then crefFirstIdentNoSubs(cr);3029 Absyn.Ident id; 3030 Absyn.ComponentRef cr; 3031 case Absyn.CREF_IDENT(name = id, subscripts = {}) then id; 3032 case Absyn.CREF_QUAL(name = id, subscripts = {}) then id; 3033 case Absyn.CREF_FULLYQUALIFIED(componentRef = cr) then crefFirstIdentNoSubs(cr); 3034 3034 end match; 3035 3035 end crefFirstIdentNoSubs; … … 3037 3037 public function crefIsIdent 3038 3038 "Returns true if the component reference is a simple identifier, otherwise false." 3039 input ComponentRef inComponentRef;3039 input Absyn.ComponentRef inComponentRef; 3040 3040 output Boolean outIsIdent; 3041 3041 algorithm 3042 3042 outIsIdent := match(inComponentRef) 3043 case CREF_IDENT() then true;3043 case Absyn.CREF_IDENT() then true; 3044 3044 else false; 3045 3045 end match; … … 3048 3048 public function crefIsQual 3049 3049 "Returns true if the component reference is a qualified identifier, otherwise false." 3050 input ComponentRef inComponentRef;3050 input Absyn.ComponentRef inComponentRef; 3051 3051 output Boolean outIsQual; 3052 3052 algorithm 3053 3053 outIsQual := match(inComponentRef) 3054 case CREF_QUAL() then true;3055 case CREF_FULLYQUALIFIED() then true;3054 case Absyn.CREF_QUAL() then true; 3055 case Absyn.CREF_FULLYQUALIFIED() then true; 3056 3056 else false; 3057 3057 end match; 3058 3058 end crefIsQual; 3059 3059 3060 public function crefLastSubs "Return the last subscripts of an ComponentRef"3061 input ComponentRef inComponentRef;3062 output list< Subscript> outSubscriptLst;3060 public function crefLastSubs "Return the last subscripts of an Absyn.ComponentRef" 3061 input Absyn.ComponentRef inComponentRef; 3062 output list<Absyn.Subscript> outSubscriptLst; 3063 3063 algorithm 3064 3064 outSubscriptLst:= 3065 3065 match (inComponentRef) 3066 3066 local 3067 Ident id;3068 list< Subscript> subs,res;3069 ComponentRef cr;3070 case ( CREF_IDENT(subscripts= subs)) then subs;3071 case ( CREF_QUAL(componentRef = cr))3067 Absyn.Ident id; 3068 list<Absyn.Subscript> subs,res; 3069 Absyn.ComponentRef cr; 3070 case (Absyn.CREF_IDENT(subscripts= subs)) then subs; 3071 case (Absyn.CREF_QUAL(componentRef = cr)) 3072 3072 equation 3073 3073 res = crefLastSubs(cr); 3074 3074 then 3075 3075 res; 3076 case ( CREF_FULLYQUALIFIED(componentRef = cr))3076 case (Absyn.CREF_FULLYQUALIFIED(componentRef = cr)) 3077 3077 equation 3078 3078 res = crefLastSubs(cr); … … 3083 3083 3084 3084 public function crefSetLastSubs 3085 input ComponentRef inCref;3086 input list< Subscript> inSubscripts;3087 output ComponentRef outCref = inCref;3085 input Absyn.ComponentRef inCref; 3086 input list<Absyn.Subscript> inSubscripts; 3087 output Absyn.ComponentRef outCref = inCref; 3088 3088 algorithm 3089 3089 outCref := match outCref 3090 case CREF_IDENT()3090 case Absyn.CREF_IDENT() 3091 3091 algorithm 3092 3092 outCref.subscripts := inSubscripts; … … 3094 3094 outCref; 3095 3095 3096 case CREF_QUAL()3096 case Absyn.CREF_QUAL() 3097 3097 algorithm 3098 3098 outCref.componentRef := crefSetLastSubs(outCref.componentRef, inSubscripts); … … 3100 3100 outCref; 3101 3101 3102 case CREF_FULLYQUALIFIED()3102 case Absyn.CREF_FULLYQUALIFIED() 3103 3103 algorithm 3104 3104 outCref.componentRef := crefSetLastSubs(outCref.componentRef, inSubscripts); … … 3110 3110 3111 3111 public function crefHasSubscripts "This function finds if a cref has subscripts" 3112 input ComponentRef cref;3112 input Absyn.ComponentRef cref; 3113 3113 output Boolean hasSubscripts; 3114 3114 algorithm 3115 3115 hasSubscripts := match cref 3116 case CREF_IDENT() then not listEmpty(cref.subscripts);3117 case CREF_QUAL(subscripts = {}) then crefHasSubscripts(cref.componentRef);3118 case CREF_FULLYQUALIFIED() then crefHasSubscripts(cref.componentRef);3119 case WILD() then false;3120 case A LLWILD() then false;3116 case Absyn.CREF_IDENT() then not listEmpty(cref.subscripts); 3117 case Absyn.CREF_QUAL(subscripts = {}) then crefHasSubscripts(cref.componentRef); 3118 case Absyn.CREF_FULLYQUALIFIED() then crefHasSubscripts(cref.componentRef); 3119 case Absyn.WILD() then false; 3120 case Absyn.ALLWILD() then false; 3121 3121 else true; 3122 3122 end match; … … 3126 3126 Author: BZ, 2009-09 3127 3127 Extract subscripts of crefs." 3128 input ComponentRef cr;3128 input Absyn.ComponentRef cr; 3129 3129 input Boolean includeSubs "include crefs from array subscripts"; 3130 3130 input Boolean includeFunctions "note that if you say includeSubs = false then you won't get the functions from array subscripts"; 3131 output list< Subscript> subscripts;3131 output list<Absyn.Subscript> subscripts; 3132 3132 algorithm 3133 3133 subscripts := match(cr,includeSubs,includeFunctions) 3134 3134 local 3135 list< Subscript> subs2;3136 ComponentRef child;3137 3138 case( CREF_IDENT(_,subs2), _, _) then subs2;3139 3140 case( CREF_QUAL(_,subs2,child), _, _)3135 list<Absyn.Subscript> subs2; 3136 Absyn.ComponentRef child; 3137 3138 case(Absyn.CREF_IDENT(_,subs2), _, _) then subs2; 3139 3140 case(Absyn.CREF_QUAL(_,subs2,child), _, _) 3141 3141 equation 3142 3142 subscripts = getSubsFromCref(child, includeSubs, includeFunctions); … … 3145 3145 subscripts; 3146 3146 3147 case( CREF_FULLYQUALIFIED(child), _, _)3147 case(Absyn.CREF_FULLYQUALIFIED(child), _, _) 3148 3148 equation 3149 3149 subscripts = getSubsFromCref(child, includeSubs, includeFunctions); … … 3155 3155 // stefan 3156 3156 public function crefGetLastIdent 3157 "Gets the last ident in a ComponentRef"3158 input ComponentRef inComponentRef;3159 output ComponentRef outComponentRef;3157 "Gets the last ident in a Absyn.ComponentRef" 3158 input Absyn.ComponentRef inComponentRef; 3159 output Absyn.ComponentRef outComponentRef; 3160 3160 algorithm 3161 3161 outComponentRef := match (inComponentRef) 3162 3162 local 3163 ComponentRef cref,cref_1;3164 Ident id;3165 list< Subscript> subs;3166 case( CREF_IDENT(id,subs)) thenCREF_IDENT(id,subs);3167 case( CREF_QUAL(_,_,cref))3163 Absyn.ComponentRef cref,cref_1; 3164 Absyn.Ident id; 3165 list<Absyn.Subscript> subs; 3166 case(Absyn.CREF_IDENT(id,subs)) then Absyn.CREF_IDENT(id,subs); 3167 case(Absyn.CREF_QUAL(_,_,cref)) 3168 3168 equation 3169 3169 cref_1 = crefGetLastIdent(cref); 3170 3170 then 3171 3171 cref_1; 3172 case( CREF_FULLYQUALIFIED(cref))3172 case(Absyn.CREF_FULLYQUALIFIED(cref)) 3173 3173 equation 3174 3174 cref_1 = crefGetLastIdent(cref); … … 3178 3178 end crefGetLastIdent; 3179 3179 3180 public function crefStripLastSubs "Strips the last subscripts of a ComponentRef"3181 input ComponentRef inComponentRef;3182 output ComponentRef outComponentRef;3180 public function crefStripLastSubs "Strips the last subscripts of a Absyn.ComponentRef" 3181 input Absyn.ComponentRef inComponentRef; 3182 output Absyn.ComponentRef outComponentRef; 3183 3183 algorithm 3184 3184 outComponentRef:= 3185 3185 match (inComponentRef) 3186 3186 local 3187 Ident id;3188 list< Subscript> subs,s;3189 ComponentRef cr_1,cr;3190 case ( CREF_IDENT(name = id)) thenCREF_IDENT(id,{});3191 case ( CREF_QUAL(name= id,subscripts= s,componentRef = cr))3187 Absyn.Ident id; 3188 list<Absyn.Subscript> subs,s; 3189 Absyn.ComponentRef cr_1,cr; 3190 case (Absyn.CREF_IDENT(name = id)) then Absyn.CREF_IDENT(id,{}); 3191 case (Absyn.CREF_QUAL(name= id,subscripts= s,componentRef = cr)) 3192 3192 equation 3193 3193 cr_1 = crefStripLastSubs(cr); 3194 3194 then 3195 CREF_QUAL(id,s,cr_1);3196 case ( CREF_FULLYQUALIFIED(componentRef = cr))3195 Absyn.CREF_QUAL(id,s,cr_1); 3196 case (Absyn.CREF_FULLYQUALIFIED(componentRef = cr)) 3197 3197 equation 3198 3198 cr_1 = crefStripLastSubs(cr); … … 3203 3203 3204 3204 public function joinCrefs "This function joins two ComponentRefs." 3205 input ComponentRef inComponentRef1;3206 input ComponentRef inComponentRef2;3207 output ComponentRef outComponentRef;3205 input Absyn.ComponentRef inComponentRef1; 3206 input Absyn.ComponentRef inComponentRef2; 3207 output Absyn.ComponentRef outComponentRef; 3208 3208 algorithm 3209 3209 outComponentRef:= 3210 3210 match (inComponentRef1,inComponentRef2) 3211 3211 local 3212 Ident id;3213 list< Subscript> sub;3214 ComponentRef cr2,cr_1,cr;3215 case ( CREF_IDENT(name = id,subscripts = sub),cr2)3216 equation 3217 failure( CREF_FULLYQUALIFIED() = cr2);3218 then CREF_QUAL(id,sub,cr2);3219 case ( CREF_QUAL(name = id,subscripts = sub,componentRef = cr),cr2)3212 Absyn.Ident id; 3213 list<Absyn.Subscript> sub; 3214 Absyn.ComponentRef cr2,cr_1,cr; 3215 case (Absyn.CREF_IDENT(name = id,subscripts = sub),cr2) 3216 equation 3217 failure(Absyn.CREF_FULLYQUALIFIED() = cr2); 3218 then Absyn.CREF_QUAL(id,sub,cr2); 3219 case (Absyn.CREF_QUAL(name = id,subscripts = sub,componentRef = cr),cr2) 3220 3220 equation 3221 3221 cr_1 = joinCrefs(cr, cr2); 3222 3222 then 3223 CREF_QUAL(id,sub,cr_1);3224 case ( CREF_FULLYQUALIFIED(componentRef = cr),cr2)3223 Absyn.CREF_QUAL(id,sub,cr_1); 3224 case (Absyn.CREF_FULLYQUALIFIED(componentRef = cr),cr2) 3225 3225 equation 3226 3226 cr_1 = joinCrefs(cr, cr2); … … 3230 3230 end joinCrefs; 3231 3231 3232 public function crefFirstIdent "Returns first ident from a ComponentRef"3233 input ComponentRef inCref;3234 output Ident outIdent;3232 public function crefFirstIdent "Returns first ident from a Absyn.ComponentRef" 3233 input Absyn.ComponentRef inCref; 3234 output Absyn.Ident outIdent; 3235 3235 algorithm 3236 3236 outIdent := match inCref 3237 case CREF_IDENT() then inCref.name;3238 case CREF_QUAL() then inCref.name;3239 case CREF_FULLYQUALIFIED() then crefFirstIdent(inCref.componentRef);3237 case Absyn.CREF_IDENT() then inCref.name; 3238 case Absyn.CREF_QUAL() then inCref.name; 3239 case Absyn.CREF_FULLYQUALIFIED() then crefFirstIdent(inCref.componentRef); 3240 3240 end match; 3241 3241 end crefFirstIdent; 3242 3242 3243 3243 public function crefSecondIdent 3244 input ComponentRef cref;3245 output Ident ident;3244 input Absyn.ComponentRef cref; 3245 output Absyn.Ident ident; 3246 3246 algorithm 3247 3247 ident := match cref 3248 case CREF_QUAL() then crefFirstIdent(cref.componentRef);3249 case CREF_FULLYQUALIFIED() then crefSecondIdent(cref.componentRef);3248 case Absyn.CREF_QUAL() then crefFirstIdent(cref.componentRef); 3249 case Absyn.CREF_FULLYQUALIFIED() then crefSecondIdent(cref.componentRef); 3250 3250 end match; 3251 3251 end crefSecondIdent; … … 3253 3253 public function crefFirstCref 3254 3254 "Returns the first part of a cref." 3255 input ComponentRef inCref;3256 output ComponentRef outCref;3255 input Absyn.ComponentRef inCref; 3256 output Absyn.ComponentRef outCref; 3257 3257 algorithm 3258 3258 outCref := match inCref 3259 case CREF_QUAL() thenCREF_IDENT(inCref.name, inCref.subscripts);3260 case CREF_FULLYQUALIFIED() then crefFirstCref(inCref.componentRef);3259 case Absyn.CREF_QUAL() then Absyn.CREF_IDENT(inCref.name, inCref.subscripts); 3260 case Absyn.CREF_FULLYQUALIFIED() then crefFirstCref(inCref.componentRef); 3261 3261 else inCref; 3262 3262 end match; 3263 3263 end crefFirstCref; 3264 3264 3265 public function crefStripFirst "Strip the first ident from a ComponentRef"3266 input ComponentRef inComponentRef;3267 output ComponentRef outComponentRef;3265 public function crefStripFirst "Strip the first ident from a Absyn.ComponentRef" 3266 input Absyn.ComponentRef inComponentRef; 3267 output Absyn.ComponentRef outComponentRef; 3268 3268 algorithm 3269 3269 outComponentRef:= 3270 3270 match (inComponentRef) 3271 local ComponentRef cr;3272 case CREF_QUAL(componentRef = cr) then cr;3273 case CREF_FULLYQUALIFIED(componentRef = cr) then crefStripFirst(cr);3271 local Absyn.ComponentRef cr; 3272 case Absyn.CREF_QUAL(componentRef = cr) then cr; 3273 case Absyn.CREF_FULLYQUALIFIED(componentRef = cr) then crefStripFirst(cr); 3274 3274 end match; 3275 3275 end crefStripFirst; 3276 3276 3277 3277 public function crefIsFullyQualified 3278 input ComponentRef inCref;3278 input Absyn.ComponentRef inCref; 3279 3279 output Boolean outIsFullyQualified; 3280 3280 algorithm 3281 3281 outIsFullyQualified := match inCref 3282 case CREF_FULLYQUALIFIED() then true;3282 case Absyn.CREF_FULLYQUALIFIED() then true; 3283 3283 else false; 3284 3284 end match; … … 3287 3287 public function crefMakeFullyQualified 3288 3288 "Makes a component reference fully qualified unless it already is." 3289 input ComponentRef inComponentRef;3290 output ComponentRef outComponentRef;3289 input Absyn.ComponentRef inComponentRef; 3290 output Absyn.ComponentRef outComponentRef; 3291 3291 algorithm 3292 3292 outComponentRef := match(inComponentRef) 3293 case CREF_FULLYQUALIFIED() then inComponentRef;3294 else CREF_FULLYQUALIFIED(inComponentRef);3293 case Absyn.CREF_FULLYQUALIFIED() then inComponentRef; 3294 else Absyn.CREF_FULLYQUALIFIED(inComponentRef); 3295 3295 end match; 3296 3296 end crefMakeFullyQualified; 3297 3297 3298 3298 public function restrString "Maps a class restriction to the corresponding string for printing" 3299 input Restriction inRestriction;3299 input Absyn.Restriction inRestriction; 3300 3300 output String outString; 3301 3301 algorithm 3302 3302 outString:= 3303 3303 match (inRestriction) 3304 case R_CLASS() then "CLASS";3305 case R_OPTIMIZATION() then "OPTIMIZATION";3306 case R_MODEL() then "MODEL";3307 case R_RECORD() then "RECORD";3308 case R_BLOCK() then "BLOCK";3309 case R_CONNECTOR() then "CONNECTOR";3310 case R_EXP_CONNECTOR() then "EXPANDABLE CONNECTOR";3311 case R_TYPE() then "TYPE";3312 case R_PACKAGE() then "PACKAGE";3313 case R_FUNCTION(FR_NORMAL_FUNCTION(PURE())) then "PURE FUNCTION";3314 case R_FUNCTION(FR_NORMAL_FUNCTION(IMPURE())) then "IMPURE FUNCTION";3315 case R_FUNCTION(FR_NORMAL_FUNCTION(NO_PURITY())) then "FUNCTION";3316 case R_FUNCTION(FR_OPERATOR_FUNCTION()) then "OPERATOR FUNCTION";3317 case R_PREDEFINED_INTEGER() then "PREDEFINED_INT";3318 case R_PREDEFINED_REAL() then "PREDEFINED_REAL";3319 case R_PREDEFINED_STRING() then "PREDEFINED_STRING";3320 case R_PREDEFINED_BOOLEAN() then "PREDEFINED_BOOL";3304 case Absyn.R_CLASS() then "CLASS"; 3305 case Absyn.R_OPTIMIZATION() then "OPTIMIZATION"; 3306 case Absyn.R_MODEL() then "MODEL"; 3307 case Absyn.R_RECORD() then "RECORD"; 3308 case Absyn.R_BLOCK() then "BLOCK"; 3309 case Absyn.R_CONNECTOR() then "CONNECTOR"; 3310 case Absyn.R_EXP_CONNECTOR() then "EXPANDABLE CONNECTOR"; 3311 case Absyn.R_TYPE() then "TYPE"; 3312 case Absyn.R_PACKAGE() then "PACKAGE"; 3313 case Absyn.R_FUNCTION(Absyn.FR_NORMAL_FUNCTION(Absyn.PURE())) then "PURE FUNCTION"; 3314 case Absyn.R_FUNCTION(Absyn.FR_NORMAL_FUNCTION(Absyn.IMPURE())) then "IMPURE FUNCTION"; 3315 case Absyn.R_FUNCTION(Absyn.FR_NORMAL_FUNCTION(Absyn.NO_PURITY())) then "FUNCTION"; 3316 case Absyn.R_FUNCTION(Absyn.FR_OPERATOR_FUNCTION()) then "OPERATOR FUNCTION"; 3317 case Absyn.R_PREDEFINED_INTEGER() then "PREDEFINED_INT"; 3318 case Absyn.R_PREDEFINED_REAL() then "PREDEFINED_REAL"; 3319 case Absyn.R_PREDEFINED_STRING() then "PREDEFINED_STRING"; 3320 case Absyn.R_PREDEFINED_BOOLEAN() then "PREDEFINED_BOOL"; 3321 3321 // BTH 3322 case R_PREDEFINED_CLOCK() then "PREDEFINED_CLOCK";3322 case Absyn.R_PREDEFINED_CLOCK() then "PREDEFINED_CLOCK"; 3323 3323 3324 3324 /* MetaModelica restriction */ 3325 case R_UNIONTYPE() then "UNIONTYPE";3325 case Absyn.R_UNIONTYPE() then "UNIONTYPE"; 3326 3326 else "* Unknown restriction *"; 3327 3327 end match; … … 3329 3329 3330 3330 public function lastClassname "Returns the path (=name) of the last class in a program" 3331 input Program inProgram;3332 output Path outPath;3331 input Absyn.Program inProgram; 3332 output Absyn.Path outPath; 3333 3333 protected 3334 list< Class> lst;3335 Ident id;3336 algorithm 3337 PROGRAM(classes = lst) := inProgram;3338 CLASS(name = id) := List.last(lst);3339 outPath := IDENT(id);3334 list<Absyn.Class> lst; 3335 Absyn.Ident id; 3336 algorithm 3337 Absyn.PROGRAM(classes = lst) := inProgram; 3338 Absyn.CLASS(name = id) := List.last(lst); 3339 outPath := Absyn.IDENT(id); 3340 3340 end lastClassname; 3341 3341 3342 3342 public function classFilename 3343 3343 "Retrieves the filename where the class is stored." 3344 input Class inClass;3344 input Absyn.Class inClass; 3345 3345 output String outFilename; 3346 3346 algorithm 3347 CLASS(info = SOURCEINFO(fileName = outFilename)) := inClass;3347 Absyn.CLASS(info = SOURCEINFO(fileName = outFilename)) := inClass; 3348 3348 end classFilename; 3349 3349 3350 3350 public function setClassFilename "Sets the filename where the class is stored." 3351 input Class inClass;3351 input Absyn.Class inClass; 3352 3352 input String fileName; 3353 output Class outClass;3353 output Absyn.Class outClass; 3354 3354 algorithm 3355 3355 outClass := match inClass 3356 3356 local 3357 3357 SourceInfo info; 3358 Class cl;3359 case cl as CLASS(info=info as SOURCEINFO())3358 Absyn.Class cl; 3359 case cl as Absyn.CLASS(info=info as SOURCEINFO()) 3360 3360 equation 3361 3361 info.fileName = fileName; … … 3367 3367 public function setClassName "author: BZ 3368 3368 Sets the name of the class" 3369 input Class inClass;3369 input Absyn.Class inClass; 3370 3370 input String newName; 3371 output Class outClass = inClass;3371 output Absyn.Class outClass = inClass; 3372 3372 algorithm 3373 3373 outClass := match outClass 3374 case CLASS()3374 case Absyn.CLASS() 3375 3375 algorithm 3376 3376 outClass.name := newName; … … 3381 3381 3382 3382 public function setClassBody 3383 input Class inClass;3384 input ClassDef inBody;3385 output Class outClass = inClass;3383 input Absyn.Class inClass; 3384 input Absyn.ClassDef inBody; 3385 output Absyn.Class outClass = inClass; 3386 3386 algorithm 3387 3387 outClass := match outClass 3388 case CLASS()3388 case Absyn.CLASS() 3389 3389 algorithm 3390 3390 outClass.body := inBody; … … 3394 3394 end setClassBody; 3395 3395 3396 public function crefEqual " Checks if the name of a ComponentRef is3397 equal to the name of another ComponentRef, including subscripts.3396 public function crefEqual " Checks if the name of a Absyn.ComponentRef is 3397 equal to the name of another Absyn.ComponentRef, including subscripts. 3398 3398 See also crefEqualNoSubs." 3399 input ComponentRef iCr1;3400 input ComponentRef iCr2;3399 input Absyn.ComponentRef iCr1; 3400 input Absyn.ComponentRef iCr2; 3401 3401 output Boolean outBoolean; 3402 3402 algorithm 3403 3403 outBoolean := matchcontinue (iCr1,iCr2) 3404 3404 local 3405 Ident id,id2;3406 list< Subscript> ss1,ss2;3407 ComponentRef cr1,cr2;3408 3409 case ( CREF_IDENT(name = id,subscripts=ss1),CREF_IDENT(name = id2,subscripts = ss2))3405 Absyn.Ident id,id2; 3406 list<Absyn.Subscript> ss1,ss2; 3407 Absyn.ComponentRef cr1,cr2; 3408 3409 case (Absyn.CREF_IDENT(name = id,subscripts=ss1),Absyn.CREF_IDENT(name = id2,subscripts = ss2)) 3410 3410 equation 3411 3411 true = stringEq(id, id2); … … 3414 3414 true; 3415 3415 3416 case ( CREF_QUAL(name = id,subscripts = ss1, componentRef = cr1),CREF_QUAL(name = id2,subscripts = ss2, componentRef = cr2))3416 case (Absyn.CREF_QUAL(name = id,subscripts = ss1, componentRef = cr1),Absyn.CREF_QUAL(name = id2,subscripts = ss2, componentRef = cr2)) 3417 3417 equation 3418 3418 true = stringEq(id, id2); … … 3422 3422 true; 3423 3423 3424 case ( CREF_FULLYQUALIFIED(componentRef = cr1),CREF_FULLYQUALIFIED(componentRef = cr2))3424 case (Absyn.CREF_FULLYQUALIFIED(componentRef = cr1),Absyn.CREF_FULLYQUALIFIED(componentRef = cr2)) 3425 3425 then 3426 3426 crefEqual(cr1, cr2); … … 3434 3434 a.b, a -> true 3435 3435 b.c, a -> false" 3436 input ComponentRef iCr1;3437 input ComponentRef iCr2;3436 input Absyn.ComponentRef iCr1; 3437 input Absyn.ComponentRef iCr2; 3438 3438 output Boolean outBoolean; 3439 3439 algorithm … … 3442 3442 3443 3443 public function subscriptEqual 3444 input Subscript inSubscript1;3445 input Subscript inSubscript2;3444 input Absyn.Subscript inSubscript1; 3445 input Absyn.Subscript inSubscript2; 3446 3446 output Boolean outIsEqual; 3447 3447 algorithm 3448 3448 outIsEqual := match(inSubscript1, inSubscript2) 3449 3449 local 3450 Exp e1, e2;3451 3452 case ( NOSUB(),NOSUB()) then true;3453 case ( SUBSCRIPT(e1),SUBSCRIPT(e2)) then expEqual(e1, e2);3450 Absyn.Exp e1, e2; 3451 3452 case (Absyn.NOSUB(), Absyn.NOSUB()) then true; 3453 case (Absyn.SUBSCRIPT(e1), Absyn.SUBSCRIPT(e2)) then expEqual(e1, e2); 3454 3454 else false; 3455 3455 end match; … … 3458 3458 public function subscriptsEqual 3459 3459 "Checks if two subscript lists are equal." 3460 input list< Subscript> inSubList1;3461 input list< Subscript> inSubList2;3460 input list<Absyn.Subscript> inSubList1; 3461 input list<Absyn.Subscript> inSubList2; 3462 3462 output Boolean outIsEqual; 3463 3463 algorithm … … 3466 3466 3467 3467 public function crefEqualNoSubs 3468 "Checks if the name of a ComponentRef is equal to the name3469 of another ComponentRef without checking subscripts.3468 "Checks if the name of a Absyn.ComponentRef is equal to the name 3469 of another Absyn.ComponentRef without checking subscripts. 3470 3470 See also crefEqual." 3471 input ComponentRef cr1;3472 input ComponentRef cr2;3471 input Absyn.ComponentRef cr1; 3472 input Absyn.ComponentRef cr2; 3473 3473 output Boolean outBoolean; 3474 3474 algorithm 3475 3475 outBoolean := matchcontinue (cr1,cr2) 3476 3476 local 3477 ComponentRef rest1,rest2;3478 Ident id,id2;3479 case ( CREF_IDENT(name = id),CREF_IDENT(name = id2))3477 Absyn.ComponentRef rest1,rest2; 3478 Absyn.Ident id,id2; 3479 case (Absyn.CREF_IDENT(name = id),Absyn.CREF_IDENT(name = id2)) 3480 3480 equation 3481 3481 true = stringEq(id, id2); 3482 3482 then 3483 3483 true; 3484 case ( CREF_QUAL(name = id,componentRef = rest1),CREF_QUAL(name = id2,componentRef = rest2))3484 case (Absyn.CREF_QUAL(name = id,componentRef = rest1),Absyn.CREF_QUAL(name = id2,componentRef = rest2)) 3485 3485 equation 3486 3486 true = stringEq(id, id2); … … 3488 3488 then 3489 3489 true; 3490 case ( CREF_FULLYQUALIFIED(componentRef = rest1),CREF_FULLYQUALIFIED(componentRef = rest2))3490 case (Absyn.CREF_FULLYQUALIFIED(componentRef = rest1),Absyn.CREF_FULLYQUALIFIED(componentRef = rest2)) 3491 3491 then crefEqualNoSubs(rest1, rest2); 3492 3492 else false; … … 3495 3495 3496 3496 public function isPackageRestriction "checks if the provided parameter is a package or not" 3497 input Restriction inRestriction;3497 input Absyn.Restriction inRestriction; 3498 3498 output Boolean outIsPackage; 3499 3499 algorithm 3500 3500 outIsPackage := match(inRestriction) 3501 case R_PACKAGE() then true;3501 case Absyn.R_PACKAGE() then true; 3502 3502 else false; 3503 3503 end match; … … 3505 3505 3506 3506 public function isFunctionRestriction "checks if restriction is a function or not" 3507 input Restriction inRestriction;3507 input Absyn.Restriction inRestriction; 3508 3508 output Boolean outIsFunction; 3509 3509 algorithm 3510 3510 outIsFunction := match(inRestriction) 3511 case R_FUNCTION() then true;3511 case Absyn.R_FUNCTION() then true; 3512 3512 else false; 3513 3513 end match; … … 3515 3515 3516 3516 public function expEqual "Returns true if two expressions are equal" 3517 input Exp exp1;3518 input Exp exp2;3517 input Absyn.Exp exp1; 3518 input Absyn.Exp exp2; 3519 3519 output Boolean equal; 3520 3520 algorithm … … 3522 3522 local 3523 3523 Boolean b; 3524 Exp x, y;3524 Absyn.Exp x, y; 3525 3525 Integer i; 3526 3526 String r; 3527 3527 3528 3528 // real vs. integer 3529 case ( INTEGER(i),REAL(r))3529 case (Absyn.INTEGER(i), Absyn.REAL(r)) 3530 3530 equation 3531 3531 b = realEq(intReal(i), System.stringReal(r)); 3532 3532 then b; 3533 3533 3534 case ( REAL(r),INTEGER(i))3534 case (Absyn.REAL(r), Absyn.INTEGER(i)) 3535 3535 equation 3536 3536 b = realEq(intReal(i), System.stringReal(r)); … … 3543 3543 3544 3544 public function eachEqual "Returns true if two each attributes are equal" 3545 input Each each1;3546 input Each each2;3545 input Absyn.Each each1; 3546 input Absyn.Each each2; 3547 3547 output Boolean equal; 3548 3548 algorithm 3549 3549 equal := match(each1, each2) 3550 case( NON_EACH(),NON_EACH()) then true;3551 case( EACH(),EACH()) then true;3550 case(Absyn.NON_EACH(), Absyn.NON_EACH()) then true; 3551 case(Absyn.EACH(), Absyn.EACH()) then true; 3552 3552 else false; 3553 3553 end match; 3554 3554 end eachEqual; 3555 3555 3556 protected function functionArgsEqual "Returns true if two FunctionArgs are equal"3557 input FunctionArgs args1;3558 input FunctionArgs args2;3556 protected function functionArgsEqual "Returns true if two Absyn.FunctionArgs are equal" 3557 input Absyn.FunctionArgs args1; 3558 input Absyn.FunctionArgs args2; 3559 3559 output Boolean equal; 3560 3560 algorithm 3561 3561 equal := match(args1,args2) 3562 3562 local 3563 list< Exp> expl1,expl2;3564 3565 case ( FUNCTIONARGS(args = expl1),FUNCTIONARGS(args = expl2))3563 list<Absyn.Exp> expl1,expl2; 3564 3565 case (Absyn.FUNCTIONARGS(args = expl1), Absyn.FUNCTIONARGS(args = expl2)) 3566 3566 then List.isEqualOnTrue(expl1, expl2, expEqual); 3567 3567 … … 3572 3572 public function getClassName "author: adrpo 3573 3573 gets the name of the class." 3574 input Class inClass;3574 input Absyn.Class inClass; 3575 3575 output String outName; 3576 3576 algorithm 3577 CLASS(name=outName) := inClass;3577 Absyn.CLASS(name=outName) := inClass; 3578 3578 end getClassName; 3579 3579 3580 public type IteratorIndexedCref = tuple< ComponentRef, Integer>;3580 public type IteratorIndexedCref = tuple<Absyn.ComponentRef, Integer>; 3581 3581 3582 3582 public function findIteratorIndexedCrefs … … 3584 3584 iterator, and return a list of cref-Integer tuples, where the cref is the 3585 3585 index of the subscript." 3586 input Exp inExp;3586 input Absyn.Exp inExp; 3587 3587 input String inIterator; 3588 3588 input list<IteratorIndexedCref> inCrefs = {}; … … 3598 3598 "Traversal function used by deduceReductionIterationRange. Used to find crefs 3599 3599 which are subscripted by a given iterator." 3600 input Exp inExp;3600 input Absyn.Exp inExp; 3601 3601 input list<IteratorIndexedCref> inCrefs; 3602 3602 input String inIterator; 3603 output Exp outExp = inExp;3603 output Absyn.Exp outExp = inExp; 3604 3604 output list<IteratorIndexedCref> outCrefs; 3605 3605 algorithm 3606 3606 outCrefs := match inExp 3607 3607 local 3608 ComponentRef cref;3609 3610 case CREF(componentRef = cref)3608 Absyn.ComponentRef cref; 3609 3610 case Absyn.CREF(componentRef = cref) 3611 3611 then getIteratorIndexedCrefs(cref, inIterator, inCrefs); 3612 3612 … … 3621 3621 output Boolean outEqual; 3622 3622 protected 3623 ComponentRef cr1, cr2;3623 Absyn.ComponentRef cr1, cr2; 3624 3624 Integer idx1, idx2; 3625 3625 algorithm … … 3636 3636 iterator i: 3637 3637 a[i] => (a, 1), b[1, i] => (b, 2), c[i+1] => (), d[2].e[i] => (d[2].e, 1)" 3638 input ComponentRef inCref;3638 input Absyn.ComponentRef inCref; 3639 3639 input String inIterator; 3640 3640 input list<IteratorIndexedCref> inCrefs; 3641 3641 output list<IteratorIndexedCref> outCrefs = inCrefs; 3642 3642 protected 3643 list<tuple< ComponentRef, Integer>> crefs;3643 list<tuple<Absyn.ComponentRef, Integer>> crefs; 3644 3644 algorithm 3645 3645 outCrefs := match inCref 3646 3646 local 3647 list< Subscript> subs;3647 list<Absyn.Subscript> subs; 3648 3648 Integer idx; 3649 3649 String name, id; 3650 ComponentRef cref;3651 3652 case CREF_IDENT(name = id, subscripts = subs)3650 Absyn.ComponentRef cref; 3651 3652 case Absyn.CREF_IDENT(name = id, subscripts = subs) 3653 3653 algorithm 3654 3654 // For each subscript, check if the subscript consists of only the … … 3657 3657 for sub in subs loop 3658 3658 _ := match sub 3659 case SUBSCRIPT(subscript =CREF(componentRef =3660 CREF_IDENT(name = name, subscripts = {})))3659 case Absyn.SUBSCRIPT(subscript = Absyn.CREF(componentRef = 3660 Absyn.CREF_IDENT(name = name, subscripts = {}))) 3661 3661 algorithm 3662 3662 if name == inIterator then 3663 outCrefs := ( CREF_IDENT(id, {}), idx) :: outCrefs;3663 outCrefs := (Absyn.CREF_IDENT(id, {}), idx) :: outCrefs; 3664 3664 end if; 3665 3665 then … … 3674 3674 outCrefs; 3675 3675 3676 case CREF_QUAL(name = id, subscripts = subs, componentRef = cref)3676 case Absyn.CREF_QUAL(name = id, subscripts = subs, componentRef = cref) 3677 3677 algorithm 3678 3678 crefs := getIteratorIndexedCrefs(cref, inIterator, {}); … … 3682 3682 for cr in crefs loop 3683 3683 (cref, idx) := cr; 3684 outCrefs := ( CREF_QUAL(id, subs, cref), idx) :: outCrefs;3684 outCrefs := (Absyn.CREF_QUAL(id, subs, cref), idx) :: outCrefs; 3685 3685 end for; 3686 3686 then 3687 getIteratorIndexedCrefs( CREF_IDENT(id, subs), inIterator, outCrefs);3688 3689 case CREF_FULLYQUALIFIED(componentRef = cref)3687 getIteratorIndexedCrefs(Absyn.CREF_IDENT(id, subs), inIterator, outCrefs); 3688 3689 case Absyn.CREF_FULLYQUALIFIED(componentRef = cref) 3690 3690 algorithm 3691 3691 crefs := getIteratorIndexedCrefs(cref, inIterator, {}); … … 3694 3694 for cr in crefs loop 3695 3695 (cref, idx) := cr; 3696 outCrefs := ( CREF_FULLYQUALIFIED(cref), idx) :: outCrefs;3696 outCrefs := (Absyn.CREF_FULLYQUALIFIED(cref), idx) :: outCrefs; 3697 3697 end for; 3698 3698 then … … 3704 3704 3705 3705 public function pathReplaceIdent 3706 input Path path;3706 input Absyn.Path path; 3707 3707 input String last; 3708 output Path out;3708 output Absyn.Path out; 3709 3709 algorithm 3710 3710 out := match (path,last) 3711 local Path p; String n,s;3712 case ( FULLYQUALIFIED(p),s) equation p = pathReplaceIdent(p,s); thenFULLYQUALIFIED(p);3713 case ( QUALIFIED(n,p),s) equation p = pathReplaceIdent(p,s); thenQUALIFIED(n,p);3714 case ( IDENT(),s) thenIDENT(s);3711 local Absyn.Path p; String n,s; 3712 case (Absyn.FULLYQUALIFIED(p),s) equation p = pathReplaceIdent(p,s); then Absyn.FULLYQUALIFIED(p); 3713 case (Absyn.QUALIFIED(n,p),s) equation p = pathReplaceIdent(p,s); then Absyn.QUALIFIED(n,p); 3714 case (Absyn.IDENT(),s) then Absyn.IDENT(s); 3715 3715 end match; 3716 3716 end pathReplaceIdent; … … 3725 3725 public function isOuter 3726 3726 "@author: adrpo 3727 this function returns true if the given InnerOuter3728 is one of INNER_OUTER() orOUTER()"3729 input InnerOuter io;3727 this function returns true if the given Absyn.InnerOuter 3728 is one of Absyn.INNER_OUTER() or Absyn.OUTER()" 3729 input Absyn.InnerOuter io; 3730 3730 output Boolean isItAnOuter; 3731 3731 algorithm 3732 3732 isItAnOuter := match(io) 3733 case ( INNER_OUTER()) then true;3734 case ( OUTER()) then true;3733 case (Absyn.INNER_OUTER()) then true; 3734 case (Absyn.OUTER()) then true; 3735 3735 else false; 3736 3736 end match; … … 3739 3739 public function isInner 3740 3740 "@author: adrpo 3741 this function returns true if the given InnerOuter3742 is one of INNER_OUTER() orINNER()"3743 input InnerOuter io;3741 this function returns true if the given Absyn.InnerOuter 3742 is one of Absyn.INNER_OUTER() or Absyn.INNER()" 3743 input Absyn.InnerOuter io; 3744 3744 output Boolean isItAnInner; 3745 3745 algorithm 3746 3746 isItAnInner := match(io) 3747 case ( INNER_OUTER()) then true;3748 case ( INNER()) then true;3747 case (Absyn.INNER_OUTER()) then true; 3748 case (Absyn.INNER()) then true; 3749 3749 else false; 3750 3750 end match; … … 3752 3752 3753 3753 public function isOnlyInner 3754 "Returns true if the InnerOuter isINNER, false otherwise."3755 input InnerOuter inIO;3754 "Returns true if the Absyn.InnerOuter is Absyn.INNER, false otherwise." 3755 input Absyn.InnerOuter inIO; 3756 3756 output Boolean outOnlyInner; 3757 3757 algorithm 3758 3758 outOnlyInner := match(inIO) 3759 case ( INNER()) then true;3759 case (Absyn.INNER()) then true; 3760 3760 else false; 3761 3761 end match; … … 3763 3763 3764 3764 public function isOnlyOuter 3765 "Returns true if the InnerOuter isOUTER, false otherwise."3766 input InnerOuter inIO;3765 "Returns true if the Absyn.InnerOuter is Absyn.OUTER, false otherwise." 3766 input Absyn.InnerOuter inIO; 3767 3767 output Boolean outOnlyOuter; 3768 3768 algorithm 3769 3769 outOnlyOuter := match(inIO) 3770 case ( OUTER()) then true;3770 case (Absyn.OUTER()) then true; 3771 3771 else false; 3772 3772 end match; … … 3774 3774 3775 3775 public function isInnerOuter 3776 input InnerOuter inIO;3776 input Absyn.InnerOuter inIO; 3777 3777 output Boolean outIsInnerOuter; 3778 3778 algorithm 3779 3779 outIsInnerOuter := match(inIO) 3780 case ( INNER_OUTER()) then true;3780 case (Absyn.INNER_OUTER()) then true; 3781 3781 else false; 3782 3782 end match; … … 3784 3784 3785 3785 public function isNotInnerOuter 3786 input InnerOuter inIO;3786 input Absyn.InnerOuter inIO; 3787 3787 output Boolean outIsNotInnerOuter; 3788 3788 algorithm 3789 3789 outIsNotInnerOuter := match(inIO) 3790 case ( NOT_INNER_OUTER()) then true;3790 case (Absyn.NOT_INNER_OUTER()) then true; 3791 3791 else false; 3792 3792 end match; 3793 3793 end isNotInnerOuter; 3794 3794 3795 public function innerOuterEqual "Returns true if two InnerOuter's are equal"3796 input InnerOuter io1;3797 input InnerOuter io2;3795 public function innerOuterEqual "Returns true if two Absyn.InnerOuter's are equal" 3796 input Absyn.InnerOuter io1; 3797 input Absyn.InnerOuter io2; 3798 3798 output Boolean res; 3799 3799 algorithm 3800 3800 res := match(io1,io2) 3801 case( INNER(),INNER()) then true;3802 case( OUTER(),OUTER()) then true;3803 case( INNER_OUTER(),INNER_OUTER()) then true;3804 case( NOT_INNER_OUTER(),NOT_INNER_OUTER()) then true;3801 case(Absyn.INNER(),Absyn.INNER()) then true; 3802 case(Absyn.OUTER(),Absyn.OUTER()) then true; 3803 case(Absyn.INNER_OUTER(),Absyn.INNER_OUTER()) then true; 3804 case(Absyn.NOT_INNER_OUTER(),Absyn.NOT_INNER_OUTER()) then true; 3805 3805 else false; 3806 3806 end match; … … 3809 3809 public function makeFullyQualified 3810 3810 "Makes a path fully qualified unless it already is." 3811 input Path inPath;3812 output Path outPath;3811 input Absyn.Path inPath; 3812 output Absyn.Path outPath; 3813 3813 algorithm 3814 3814 outPath := match(inPath) 3815 case FULLYQUALIFIED() then inPath;3816 else FULLYQUALIFIED(inPath);3815 case Absyn.FULLYQUALIFIED() then inPath; 3816 else Absyn.FULLYQUALIFIED(inPath); 3817 3817 end match; 3818 3818 end makeFullyQualified; … … 3820 3820 public function makeNotFullyQualified 3821 3821 "Makes a path not fully qualified unless it already is." 3822 input Path inPath;3823 output Path outPath;3822 input Absyn.Path inPath; 3823 output Absyn.Path outPath; 3824 3824 algorithm 3825 3825 outPath := match inPath 3826 local Path path;3827 case FULLYQUALIFIED(path) then path;3826 local Absyn.Path path; 3827 case Absyn.FULLYQUALIFIED(path) then path; 3828 3828 else inPath; 3829 3829 end match; … … 3831 3831 3832 3832 public function importEqual "Compares two import elements. " 3833 input Import im1;3834 input Import im2;3833 input Absyn.Import im1; 3834 input Absyn.Import im2; 3835 3835 output Boolean outBoolean; 3836 3836 algorithm 3837 3837 outBoolean := matchcontinue (im1,im2) 3838 3838 local 3839 Ident id,id2;3840 Path p1,p2;3841 case ( NAMED_IMPORT(name = id,path=p1),NAMED_IMPORT(name = id2,path=p2))3839 Absyn.Ident id,id2; 3840 Absyn.Path p1,p2; 3841 case (Absyn.NAMED_IMPORT(name = id,path=p1),Absyn.NAMED_IMPORT(name = id2,path=p2)) 3842 3842 equation 3843 3843 true = stringEq(id, id2); … … 3845 3845 then 3846 3846 true; 3847 case ( QUAL_IMPORT(path=p1),QUAL_IMPORT(path=p2))3847 case (Absyn.QUAL_IMPORT(path=p1),Absyn.QUAL_IMPORT(path=p2)) 3848 3848 equation 3849 3849 true = pathEqual(p1,p2); 3850 3850 then 3851 3851 true; 3852 case ( UNQUAL_IMPORT(path=p1),UNQUAL_IMPORT(path=p2))3852 case (Absyn.UNQUAL_IMPORT(path=p1),Absyn.UNQUAL_IMPORT(path=p2)) 3853 3853 equation 3854 3854 true = pathEqual(p1,p2); … … 3860 3860 3861 3861 public function canonIfExp "Transforms an if-expression to canonical form (without else-if branches)" 3862 input Exp inExp;3863 output Exp outExp;3862 input Absyn.Exp inExp; 3863 output Absyn.Exp outExp; 3864 3864 algorithm 3865 3865 outExp := match inExp 3866 3866 local 3867 Exp cond,tb,eb,ei_cond,ei_tb,e;3868 list<tuple< Exp,Exp>> eib;3869 3870 case IFEXP(elseIfBranch={}) then inExp;3871 case IFEXP(ifExp=cond,trueBranch=tb,elseBranch=eb,elseIfBranch=(ei_cond,ei_tb)::eib)3872 equation 3873 e = canonIfExp( IFEXP(ei_cond,ei_tb,eb,eib));3874 then IFEXP(cond,tb,e,{});3867 Absyn.Exp cond,tb,eb,ei_cond,ei_tb,e; 3868 list<tuple<Absyn.Exp,Absyn.Exp>> eib; 3869 3870 case Absyn.IFEXP(elseIfBranch={}) then inExp; 3871 case Absyn.IFEXP(ifExp=cond,trueBranch=tb,elseBranch=eb,elseIfBranch=(ei_cond,ei_tb)::eib) 3872 equation 3873 e = canonIfExp(Absyn.IFEXP(ei_cond,ei_tb,eb,eib)); 3874 then Absyn.IFEXP(cond,tb,e,{}); 3875 3875 end match; 3876 3876 end canonIfExp; … … 3879 3879 "@author: adrpo 3880 3880 This function checks if a modification only contains literal expressions" 3881 input list< ElementArg> inMod;3881 input list<Absyn.ElementArg> inMod; 3882 3882 output Boolean onlyLiterals; 3883 3883 algorithm 3884 3884 onlyLiterals := matchcontinue(inMod) 3885 3885 local 3886 list< ElementArg> dive, rest;3887 EqMod eqMod;3886 list<Absyn.ElementArg> dive, rest; 3887 Absyn.EqMod eqMod; 3888 3888 Boolean b1, b2, b3, b; 3889 3889 … … 3891 3891 3892 3892 // skip "interaction" annotation! 3893 case ( MODIFICATION(path =IDENT(name = "interaction")) :: rest)3893 case (Absyn.MODIFICATION(path = Absyn.IDENT(name = "interaction")) :: rest) 3894 3894 equation 3895 3895 b = onlyLiteralsInAnnotationMod(rest); … … 3899 3899 3900 3900 // search inside, some(exp) 3901 case ( MODIFICATION(modification = SOME(CLASSMOD(dive, eqMod))) :: rest)3901 case (Absyn.MODIFICATION(modification = SOME(Absyn.CLASSMOD(dive, eqMod))) :: rest) 3902 3902 equation 3903 3903 b1 = onlyLiteralsInEqMod(eqMod); … … 3923 3923 "@author: adrpo 3924 3924 This function checks if an optional expression only contains literal expressions" 3925 input EqMod eqMod;3925 input Absyn.EqMod eqMod; 3926 3926 output Boolean onlyLiterals; 3927 3927 algorithm 3928 3928 onlyLiterals := match (eqMod) 3929 3929 local 3930 Exp exp;3931 list< Exp> lst;3930 Absyn.Exp exp; 3931 list<Absyn.Exp> lst; 3932 3932 Boolean b; 3933 3933 3934 case ( NOMOD()) then true;3934 case (Absyn.NOMOD()) then true; 3935 3935 3936 3936 // search inside, some(exp) 3937 case ( EQMOD(exp=exp))3937 case (Absyn.EQMOD(exp=exp)) 3938 3938 equation 3939 3939 (_, lst::{}) = traverseExpBidir(exp, onlyLiteralsInExpEnter, onlyLiteralsInExpExit, {}::{}); … … 3946 3946 protected function onlyLiteralsInExpEnter 3947 3947 "@author: adrpo 3948 Visitor function for checking if Exp contains only literals, NO CREFS!3948 Visitor function for checking if Absyn.Exp contains only literals, NO CREFS! 3949 3949 It returns an empty list if it doesn't contain any crefs!" 3950 input Exp inExp;3951 input list<list< Exp>> inLst;3952 output Exp outExp;3953 output list<list< Exp>> outLst;3950 input Absyn.Exp inExp; 3951 input list<list<Absyn.Exp>> inLst; 3952 output Absyn.Exp outExp; 3953 output list<list<Absyn.Exp>> outLst; 3954 3954 algorithm 3955 3955 (outExp,outLst) := match (inExp,inLst) 3956 3956 local 3957 3957 Boolean b; 3958 Exp e;3959 ComponentRef cr;3960 list< Exp> lst;3961 list<list< Exp>> rest;3958 Absyn.Exp e; 3959 Absyn.ComponentRef cr; 3960 list<Absyn.Exp> lst; 3961 list<list<Absyn.Exp>> rest; 3962 3962 String name; 3963 FunctionArgs fargs;3963 Absyn.FunctionArgs fargs; 3964 3964 3965 3965 // first handle all graphic enumerations! 3966 3966 // FillPattern.*, Smooth.*, TextAlignment.*, etc! 3967 case (e as CREF(CREF_QUAL(name=name)), lst::rest)3967 case (e as Absyn.CREF(Absyn.CREF_QUAL(name=name)), lst::rest) 3968 3968 equation 3969 3969 b = listMember(name,{ … … 3979 3979 3980 3980 // crefs, add to list 3981 case ( CREF(), lst::rest) then (inExp,(inExp::lst)::rest);3981 case (Absyn.CREF(), lst::rest) then (inExp,(inExp::lst)::rest); 3982 3982 3983 3983 // anything else, return the same! … … 3989 3989 protected function onlyLiteralsInExpExit 3990 3990 "@author: adrpo 3991 Visitor function for checking if Exp contains only literals, NO CREFS!3991 Visitor function for checking if Absyn.Exp contains only literals, NO CREFS! 3992 3992 It returns an empty list if it doesn't contain any crefs!" 3993 input Exp inExp;3994 input list<list< Exp>> inLst;3995 output Exp outExp;3996 output list<list< Exp>> outLst;3993 input Absyn.Exp inExp; 3994 input list<list<Absyn.Exp>> inLst; 3995 output Absyn.Exp outExp; 3996 output list<list<Absyn.Exp>> outLst; 3997 3997 algorithm 3998 3998 (outExp,outLst) := match (inExp,inLst) 3999 3999 local 4000 list<list< Exp>> lst;4000 list<list<Absyn.Exp>> lst; 4001 4001 4002 4002 // first handle DynamicSelect; pop the stack (ignore any crefs inside DynamicSelect) 4003 case ( CALL(function_ =CREF_IDENT(name = "DynamicSelect")), lst)4003 case (Absyn.CALL(function_ = Absyn.CREF_IDENT(name = "DynamicSelect")), lst) 4004 4004 then (inExp, lst); 4005 4005 … … 4011 4011 4012 4012 public function makeCons 4013 input Exp e1;4014 input Exp e2;4015 output Exp e;4016 algorithm 4017 e := CONS(e1,e2);4013 input Absyn.Exp e1; 4014 input Absyn.Exp e2; 4015 output Absyn.Exp e; 4016 algorithm 4017 e := Absyn.CONS(e1,e2); 4018 4018 annotation(__OpenModelica_EarlyInline = true); 4019 4019 end makeCons; 4020 4020 4021 4021 public function crefIdent 4022 input ComponentRef cr;4022 input Absyn.ComponentRef cr; 4023 4023 output String str; 4024 4024 algorithm 4025 CREF_IDENT(str,{}) := cr;4025 Absyn.CREF_IDENT(str,{}) := cr; 4026 4026 end crefIdent; 4027 4027 4028 4028 public function unqotePathIdents 4029 input Path inPath;4030 output Path path;4029 input Absyn.Path inPath; 4030 output Absyn.Path path; 4031 4031 algorithm 4032 4032 path := stringListPath(List.map(pathToStringList(inPath), System.unquoteIdentifier)); … … 4036 4036 "If the given component reference is fully qualified this function removes the 4037 4037 fully qualified qualifier, otherwise does nothing." 4038 input ComponentRef inCref;4039 output ComponentRef outCref;4038 input Absyn.ComponentRef inCref; 4039 output Absyn.ComponentRef outCref; 4040 4040 algorithm 4041 4041 outCref := match(inCref) 4042 4042 local 4043 ComponentRef cref;4044 4045 case CREF_FULLYQUALIFIED(componentRef = cref) then cref;4043 Absyn.ComponentRef cref; 4044 4045 case Absyn.CREF_FULLYQUALIFIED(componentRef = cref) then cref; 4046 4046 else inCref; 4047 4047 end match; … … 4049 4049 4050 4050 public function pathIsFullyQualified 4051 input Path inPath;4051 input Absyn.Path inPath; 4052 4052 output Boolean outIsQualified; 4053 4053 algorithm 4054 4054 outIsQualified := match(inPath) 4055 case FULLYQUALIFIED() then true;4055 case Absyn.FULLYQUALIFIED() then true; 4056 4056 else false; 4057 4057 end match; … … 4059 4059 4060 4060 public function pathIsIdent 4061 input Path inPath;4061 input Absyn.Path inPath; 4062 4062 output Boolean outIsIdent; 4063 4063 algorithm 4064 4064 outIsIdent := match(inPath) 4065 case IDENT() then true;4065 case Absyn.IDENT() then true; 4066 4066 else false; 4067 4067 end match; … … 4069 4069 4070 4070 public function pathIsQual 4071 input Path inPath;4071 input Absyn.Path inPath; 4072 4072 output Boolean outIsQual; 4073 4073 algorithm 4074 4074 outIsQual := match(inPath) 4075 case QUALIFIED() then true;4075 case Absyn.QUALIFIED() then true; 4076 4076 else false; 4077 4077 end match; … … 4079 4079 4080 4080 public function withinEqual 4081 input Within within1;4082 input Within within2;4081 input Absyn.Within within1; 4082 input Absyn.Within within2; 4083 4083 output Boolean b; 4084 4084 algorithm 4085 4085 b := match (within1,within2) 4086 4086 local 4087 Path p1,p2;4088 case ( TOP(),TOP()) then true;4089 case ( WITHIN(p1),WITHIN(p2)) then pathEqual(p1,p2);4087 Absyn.Path p1,p2; 4088 case (Absyn.TOP(),Absyn.TOP()) then true; 4089 case (Absyn.WITHIN(p1),Absyn.WITHIN(p2)) then pathEqual(p1,p2); 4090 4090 else false; 4091 4091 end match; … … 4093 4093 4094 4094 public function withinEqualCaseInsensitive 4095 input Within within1;4096 input Within within2;4095 input Absyn.Within within1; 4096 input Absyn.Within within2; 4097 4097 output Boolean b; 4098 4098 algorithm 4099 4099 b := match (within1,within2) 4100 4100 local 4101 Path p1,p2;4102 case ( TOP(),TOP()) then true;4103 case ( WITHIN(p1),WITHIN(p2)) then pathEqualCaseInsensitive(p1,p2);4101 Absyn.Path p1,p2; 4102 case (Absyn.TOP(),Absyn.TOP()) then true; 4103 case (Absyn.WITHIN(p1),Absyn.WITHIN(p2)) then pathEqualCaseInsensitive(p1,p2); 4104 4104 else false; 4105 4105 end match; … … 4107 4107 4108 4108 public function withinString 4109 input Within w1;4109 input Absyn.Within w1; 4110 4110 output String str; 4111 4111 algorithm 4112 4112 str := match (w1) 4113 4113 local 4114 Path p1;4115 case ( TOP()) then "within ;";4116 case ( WITHIN(p1)) then "within " + pathString(p1) + ";";4114 Absyn.Path p1; 4115 case (Absyn.TOP()) then "within ;"; 4116 case (Absyn.WITHIN(p1)) then "within " + pathString(p1) + ";"; 4117 4117 end match; 4118 4118 end withinString; 4119 4119 4120 4120 public function joinWithinPath 4121 input Within within_;4122 input Path path;4123 output Path outPath;4121 input Absyn.Within within_; 4122 input Absyn.Path path; 4123 output Absyn.Path outPath; 4124 4124 algorithm 4125 4125 outPath := match (within_,path) 4126 4126 local 4127 Path path1;4128 case ( TOP(),_) then path;4129 case ( WITHIN(path1),_) then joinPaths(path1,path);4127 Absyn.Path path1; 4128 case (Absyn.TOP(),_) then path; 4129 case (Absyn.WITHIN(path1),_) then joinPaths(path1,path); 4130 4130 end match; 4131 4131 end joinWithinPath; 4132 4132 4133 4133 public function innerOuterStr 4134 input InnerOuter io;4134 input Absyn.InnerOuter io; 4135 4135 output String str; 4136 4136 algorithm 4137 4137 str := match(io) 4138 case ( INNER_OUTER()) then "inner outer ";4139 case ( INNER()) then "inner ";4140 case ( OUTER()) then "outer ";4141 case ( NOT_INNER_OUTER()) then "";4138 case (Absyn.INNER_OUTER()) then "inner outer "; 4139 case (Absyn.INNER()) then "inner "; 4140 case (Absyn.OUTER()) then "outer "; 4141 case (Absyn.NOT_INNER_OUTER()) then ""; 4142 4142 end match; 4143 4143 end innerOuterStr; 4144 4144 4145 4145 public function subscriptExpOpt 4146 input Subscript inSub;4147 output Option< Exp> outExpOpt;4146 input Absyn.Subscript inSub; 4147 output Option<Absyn.Exp> outExpOpt; 4148 4148 algorithm 4149 4149 outExpOpt := match(inSub) 4150 4150 local 4151 Exp e;4152 4153 case SUBSCRIPT(subscript = e) then SOME(e);4154 case NOSUB() then NONE();4151 Absyn.Exp e; 4152 4153 case Absyn.SUBSCRIPT(subscript = e) then SOME(e); 4154 case Absyn.NOSUB() then NONE(); 4155 4155 end match; 4156 4156 end subscriptExpOpt; 4157 4157 4158 4158 public function crefInsertSubscriptLstLst 4159 input Exp inExp;4160 input list<list< Subscript>> inLst;4161 output Exp outExp;4162 output list<list< Subscript>> outLst;4159 input Absyn.Exp inExp; 4160 input list<list<Absyn.Subscript>> inLst; 4161 output Absyn.Exp outExp; 4162 output list<list<Absyn.Subscript>> outLst; 4163 4163 algorithm 4164 4164 (outExp,outLst) := matchcontinue(inExp,inLst) 4165 4165 local 4166 ComponentRef cref,cref2;4167 list<list< Subscript>> subs;4168 Exp e;4169 case ( CREF(componentRef=cref),subs)4166 Absyn.ComponentRef cref,cref2; 4167 list<list<Absyn.Subscript>> subs; 4168 Absyn.Exp e; 4169 case (Absyn.CREF(componentRef=cref),subs) 4170 4170 equation 4171 4171 cref2 = crefInsertSubscriptLstLst2(cref,subs); 4172 4172 then 4173 ( CREF(cref2),subs);4173 (Absyn.CREF(cref2),subs); 4174 4174 else (inExp,inLst); 4175 4175 end matchcontinue; … … 4178 4178 public function crefInsertSubscriptLstLst2 4179 4179 "Helper function to crefInsertSubscriptLstLst" 4180 input ComponentRef inCref;4181 input list<list< Subscript>> inSubs;4182 output ComponentRef outCref;4180 input Absyn.ComponentRef inCref; 4181 input list<list<Absyn.Subscript>> inSubs; 4182 output Absyn.ComponentRef outCref; 4183 4183 algorithm 4184 4184 outCref := matchcontinue(inCref,inSubs) 4185 4185 local 4186 ComponentRef cref, cref2;4187 Ident n;4188 list<list< Subscript>> subs;4189 list< Subscript> s;4186 Absyn.ComponentRef cref, cref2; 4187 Absyn.Ident n; 4188 list<list<Absyn.Subscript>> subs; 4189 list<Absyn.Subscript> s; 4190 4190 case (cref,{}) 4191 4191 then cref; 4192 case ( CREF_IDENT(name = n), {s})4193 then CREF_IDENT(n,s);4194 case ( CREF_QUAL(name = n, componentRef = cref), s::subs)4192 case (Absyn.CREF_IDENT(name = n), {s}) 4193 then Absyn.CREF_IDENT(n,s); 4194 case (Absyn.CREF_QUAL(name = n, componentRef = cref), s::subs) 4195 4195 equation 4196 4196 cref2 = crefInsertSubscriptLstLst2(cref, subs); 4197 4197 then 4198 CREF_QUAL(n,s,cref2);4199 case ( CREF_FULLYQUALIFIED(componentRef = cref), subs)4198 Absyn.CREF_QUAL(n,s,cref2); 4199 case (Absyn.CREF_FULLYQUALIFIED(componentRef = cref), subs) 4200 4200 equation 4201 4201 cref2 = crefInsertSubscriptLstLst2(cref, subs); … … 4206 4206 4207 4207 public function isCref 4208 input Exp exp;4208 input Absyn.Exp exp; 4209 4209 output Boolean b; 4210 4210 algorithm 4211 4211 b := match exp 4212 case CREF() then true;4212 case Absyn.CREF() then true; 4213 4213 else false; 4214 4214 end match; … … 4216 4216 4217 4217 public function isTuple 4218 input Exp exp;4218 input Absyn.Exp exp; 4219 4219 output Boolean b; 4220 4220 algorithm 4221 4221 b := match exp 4222 case TUPLE(__) then true;4222 case Absyn.TUPLE(__) then true; 4223 4223 else false; 4224 4224 end match; … … 4228 4228 "@author: johti 4229 4229 Returns true if all fields are crefs" 4230 input list< Exp> expLst;4230 input list<Absyn.Exp> expLst; 4231 4231 output Boolean b; 4232 4232 algorithm … … 4238 4238 Returns true if everything contained 4239 4239 in the tuple or a cons cell is a constant reference." 4240 input Exp inExp;4240 input Absyn.Exp inExp; 4241 4241 output Boolean b; 4242 4242 algorithm 4243 4243 b := match inExp 4244 case TUPLE(__) then allFieldsAreCrefs(inExp.expressions);4245 case CONS(__) then complexIsCref(inExp.head) and complexIsCref(inExp.rest);4244 case Absyn.TUPLE(__) then allFieldsAreCrefs(inExp.expressions); 4245 case Absyn.CONS(__) then complexIsCref(inExp.head) and complexIsCref(inExp.rest); 4246 4246 case _ then isCref(inExp); 4247 4247 end match; … … 4249 4249 4250 4250 public function isDerCref 4251 input Exp exp;4251 input Absyn.Exp exp; 4252 4252 output Boolean b; 4253 4253 algorithm 4254 4254 b := match exp 4255 case CALL(CREF_IDENT("der",{}),FUNCTIONARGS({CREF()},{})) then true;4255 case Absyn.CALL(Absyn.CREF_IDENT("der",{}),Absyn.FUNCTIONARGS({Absyn.CREF()},{})) then true; 4256 4256 else false; 4257 4257 end match; … … 4259 4259 4260 4260 public function isDerCrefFail 4261 input Exp exp;4262 algorithm 4263 CALL(CREF_IDENT("der",{}),FUNCTIONARGS({CREF()},{})) := exp;4261 input Absyn.Exp exp; 4262 algorithm 4263 Absyn.CALL(Absyn.CREF_IDENT("der",{}),Absyn.FUNCTIONARGS({Absyn.CREF()},{})) := exp; 4264 4264 end isDerCrefFail; 4265 4265 … … 4268 4268 returns all the expressions from array dimension as a list 4269 4269 also returns if we have unknown dimensions in the array dimension" 4270 input A rrayDim inAd;4270 input Absyn.ArrayDim inAd; 4271 4271 output Boolean hasUnknownDimensions; 4272 output list< Exp> outExps;4272 output list<Absyn.Exp> outExps; 4273 4273 algorithm 4274 4274 (hasUnknownDimensions, outExps) := getExpsFromArrayDim_tail(inAd, {}); … … 4279 4279 returns all the expressions from array dimension as a list 4280 4280 also returns if we have unknown dimensions in the array dimension" 4281 input Option<A rrayDim> inAdO;4281 input Option<Absyn.ArrayDim> inAdO; 4282 4282 output Boolean hasUnknownDimensions; 4283 output list< Exp> outExps;4283 output list<Absyn.Exp> outExps; 4284 4284 algorithm 4285 4285 (hasUnknownDimensions, outExps) := match(inAdO) 4286 local A rrayDim ad;4286 local Absyn.ArrayDim ad; 4287 4287 4288 4288 case (NONE()) then (false, {}); … … 4301 4301 returns all the expressions from array dimension as a list 4302 4302 also returns if we have unknown dimensions in the array dimension" 4303 input A rrayDim inAd;4304 input list< Exp> inAccumulator;4303 input Absyn.ArrayDim inAd; 4304 input list<Absyn.Exp> inAccumulator; 4305 4305 output Boolean hasUnknownDimensions; 4306 output list< Exp> outExps;4306 output list<Absyn.Exp> outExps; 4307 4307 algorithm 4308 4308 (hasUnknownDimensions, outExps) := match(inAd, inAccumulator) 4309 4309 local 4310 list< Subscript> rest;4311 Exp e;4312 list< Exp> exps, acc;4310 list<Absyn.Subscript> rest; 4311 Absyn.Exp e; 4312 list<Absyn.Exp> exps, acc; 4313 4313 Boolean b; 4314 4314 … … 4316 4316 case ({}, acc) then (false, listReverse(acc)); 4317 4317 4318 // handle SUBSCRIPT4319 case ( SUBSCRIPT(e)::rest, acc)4318 // handle Absyn.SUBSCRIPT 4319 case (Absyn.SUBSCRIPT(e)::rest, acc) 4320 4320 equation 4321 4321 (b, exps) = getExpsFromArrayDim_tail(rest, e::acc); … … 4323 4323 (b, exps); 4324 4324 4325 // handle NOSUB4326 case ( NOSUB()::rest, acc)4325 // handle Absyn.NOSUB 4326 case (Absyn.NOSUB()::rest, acc) 4327 4327 equation 4328 4328 (_, exps) = getExpsFromArrayDim_tail(rest, acc); … … 4335 4335 "@author: adrpo 4336 4336 returns true if the given direction is input or output" 4337 input Direction direction;4337 input Absyn.Direction direction; 4338 4338 output Boolean isIorO "input or output only"; 4339 4339 algorithm 4340 4340 isIorO := match(direction) 4341 case ( INPUT()) then true;4342 case ( OUTPUT()) then true;4343 case ( INPUT_OUTPUT()) then true;4344 case ( BIDIR()) then false;4341 case (Absyn.INPUT()) then true; 4342 case (Absyn.OUTPUT()) then true; 4343 case (Absyn.INPUT_OUTPUT()) then true; 4344 case (Absyn.BIDIR()) then false; 4345 4345 end match; 4346 4346 end isInputOrOutput; 4347 4347 4348 4348 public function isInput 4349 input Direction inDirection;4349 input Absyn.Direction inDirection; 4350 4350 output Boolean outIsInput; 4351 4351 algorithm 4352 4352 outIsInput := match(inDirection) 4353 case INPUT() then true;4354 case INPUT_OUTPUT() then true;4353 case Absyn.INPUT() then true; 4354 case Absyn.INPUT_OUTPUT() then true; 4355 4355 else false; 4356 4356 end match; … … 4358 4358 4359 4359 public function isOutput 4360 input Direction inDirection;4360 input Absyn.Direction inDirection; 4361 4361 output Boolean outIsOutput; 4362 4362 algorithm 4363 4363 outIsOutput := match(inDirection) 4364 case OUTPUT() then true;4365 case INPUT_OUTPUT() then true;4364 case Absyn.OUTPUT() then true; 4365 case Absyn.INPUT_OUTPUT() then true; 4366 4366 else false; 4367 4367 end match; … … 4369 4369 4370 4370 public function directionEqual 4371 input Direction inDirection1;4372 input Direction inDirection2;4371 input Absyn.Direction inDirection1; 4372 input Absyn.Direction inDirection2; 4373 4373 output Boolean outEqual; 4374 4374 algorithm 4375 4375 outEqual := match(inDirection1, inDirection2) 4376 case ( BIDIR(),BIDIR()) then true;4377 case ( INPUT(),INPUT()) then true;4378 case ( OUTPUT(),OUTPUT()) then true;4379 case ( INPUT_OUTPUT(),INPUT_OUTPUT()) then true;4376 case (Absyn.BIDIR(), Absyn.BIDIR()) then true; 4377 case (Absyn.INPUT(), Absyn.INPUT()) then true; 4378 case (Absyn.OUTPUT(), Absyn.OUTPUT()) then true; 4379 case (Absyn.INPUT_OUTPUT(), Absyn.INPUT_OUTPUT()) then true; 4380 4380 else false; 4381 4381 end match; … … 4383 4383 4384 4384 public function isFieldEqual 4385 input IsField isField1;4386 input IsField isField2;4385 input Absyn.IsField isField1; 4386 input Absyn.IsField isField2; 4387 4387 output Boolean outEqual; 4388 4388 algorithm 4389 4389 outEqual := match(isField1, isField2) 4390 case ( NONFIELD(),NONFIELD()) then true;4391 case ( FIELD(),FIELD()) then true;4390 case (Absyn.NONFIELD(), Absyn.NONFIELD()) then true; 4391 case (Absyn.FIELD(), Absyn.FIELD()) then true; 4392 4392 else false; 4393 4393 end match; … … 4396 4396 4397 4397 public function pathLt 4398 input Path path1;4399 input Path path2;4398 input Absyn.Path path1; 4399 input Absyn.Path path2; 4400 4400 output Boolean lt; 4401 4401 algorithm … … 4404 4404 4405 4405 public function pathGe 4406 input Path path1;4407 input Path path2;4406 input Absyn.Path path1; 4407 input Absyn.Path path2; 4408 4408 output Boolean ge; 4409 4409 algorithm … … 4412 4412 4413 4413 public function getShortClass "Strips out long class definitions" 4414 input Class cl;4415 output Class o;4414 input Absyn.Class cl; 4415 output Absyn.Class o; 4416 4416 algorithm 4417 4417 o := match cl 4418 4418 local 4419 Ident name;4419 Absyn.Ident name; 4420 4420 Boolean pa, fi, en; 4421 Restriction re;4422 ClassDef body;4423 Info info;4424 case CLASS(body=PARTS()) then fail();4425 case CLASS(body=CLASS_EXTENDS()) then fail();4426 case CLASS(name,pa,fi,en,re,body,info)4421 Absyn.Restriction re; 4422 Absyn.ClassDef body; 4423 Absyn.Info info; 4424 case Absyn.CLASS(body=Absyn.PARTS()) then fail(); 4425 case Absyn.CLASS(body=Absyn.CLASS_EXTENDS()) then fail(); 4426 case Absyn.CLASS(name,pa,fi,en,re,body,info) 4427 4427 equation 4428 4428 body = stripClassDefComment(body); 4429 then CLASS(name,pa,fi,en,re,body,info);4429 then Absyn.CLASS(name,pa,fi,en,re,body,info); 4430 4430 end match; 4431 4431 end getShortClass; … … 4433 4433 protected function stripClassDefComment 4434 4434 "Strips out class definition comments." 4435 input ClassDef cl;4436 output ClassDef o;4435 input Absyn.ClassDef cl; 4436 output Absyn.ClassDef o; 4437 4437 algorithm 4438 4438 o := match cl 4439 4439 local 4440 EnumDef enumLiterals;4441 TypeSpec typeSpec;4442 ElementAttributes attributes;4443 list< ElementArg> arguments;4444 list< Path> functionNames;4445 Path functionName;4446 list< Ident> vars;4440 Absyn.EnumDef enumLiterals; 4441 Absyn.TypeSpec typeSpec; 4442 Absyn.ElementAttributes attributes; 4443 list<Absyn.ElementArg> arguments; 4444 list<Absyn.Path> functionNames; 4445 Absyn.Path functionName; 4446 list<Absyn.Ident> vars; 4447 4447 list<String> typeVars; 4448 Ident baseClassName;4449 list< ElementArg> modifications;4450 list< ClassPart> parts;4451 list< NamedArg> classAttrs;4452 list<A nnotation> ann;4453 case PARTS(typeVars,classAttrs,parts,ann,_) thenPARTS(typeVars,classAttrs,parts,ann,NONE());4454 case CLASS_EXTENDS(baseClassName,modifications,_,parts,ann) thenCLASS_EXTENDS(baseClassName,modifications,NONE(),parts,ann);4455 case DERIVED(typeSpec,attributes,arguments,_) thenDERIVED(typeSpec,attributes,arguments,NONE());4456 case ENUMERATION(enumLiterals,_) thenENUMERATION(enumLiterals,NONE());4457 case OVERLOAD(functionNames,_) thenOVERLOAD(functionNames,NONE());4458 case PDER(functionName,vars,_) thenPDER(functionName,vars,NONE());4448 Absyn.Ident baseClassName; 4449 list<Absyn.ElementArg> modifications; 4450 list<Absyn.ClassPart> parts; 4451 list<Absyn.NamedArg> classAttrs; 4452 list<Absyn.Annotation> ann; 4453 case Absyn.PARTS(typeVars,classAttrs,parts,ann,_) then Absyn.PARTS(typeVars,classAttrs,parts,ann,NONE()); 4454 case Absyn.CLASS_EXTENDS(baseClassName,modifications,_,parts,ann) then Absyn.CLASS_EXTENDS(baseClassName,modifications,NONE(),parts,ann); 4455 case Absyn.DERIVED(typeSpec,attributes,arguments,_) then Absyn.DERIVED(typeSpec,attributes,arguments,NONE()); 4456 case Absyn.ENUMERATION(enumLiterals,_) then Absyn.ENUMERATION(enumLiterals,NONE()); 4457 case Absyn.OVERLOAD(functionNames,_) then Absyn.OVERLOAD(functionNames,NONE()); 4458 case Absyn.PDER(functionName,vars,_) then Absyn.PDER(functionName,vars,NONE()); 4459 4459 else cl; 4460 4460 end match; … … 4462 4462 4463 4463 public function getFunctionInterface "Strips out the parts of a function definition that are not needed for the interface" 4464 input Class cl;4465 output Class o;4464 input Absyn.Class cl; 4465 output Absyn.Class o; 4466 4466 algorithm 4467 4467 o := match cl 4468 4468 local 4469 Ident name;4469 Absyn.Ident name; 4470 4470 Boolean partialPrefix, finalPrefix, encapsulatedPrefix; 4471 Info info;4471 Absyn.Info info; 4472 4472 list<String> typeVars; 4473 list< ClassPart> classParts;4474 list< ElementItem> elts;4475 FunctionRestriction funcRest;4476 list< NamedArg> classAttr;4477 case CLASS(name,partialPrefix,finalPrefix,encapsulatedPrefix,R_FUNCTION(funcRest),PARTS(typeVars,classAttr,classParts,_,_),info)4473 list<Absyn.ClassPart> classParts; 4474 list<Absyn.ElementItem> elts; 4475 Absyn.FunctionRestriction funcRest; 4476 list<Absyn.NamedArg> classAttr; 4477 case Absyn.CLASS(name,partialPrefix,finalPrefix,encapsulatedPrefix,Absyn.R_FUNCTION(funcRest),Absyn.PARTS(typeVars,classAttr,classParts,_,_),info) 4478 4478 equation 4479 4479 (elts as _::_) = List.fold(listReverse(classParts),getFunctionInterfaceParts,{}); 4480 then CLASS(name,partialPrefix,finalPrefix,encapsulatedPrefix,R_FUNCTION(funcRest),PARTS(typeVars,classAttr,PUBLIC(elts)::{},{},NONE()),info);4480 then Absyn.CLASS(name,partialPrefix,finalPrefix,encapsulatedPrefix,Absyn.R_FUNCTION(funcRest),Absyn.PARTS(typeVars,classAttr,Absyn.PUBLIC(elts)::{},{},NONE()),info); 4481 4481 end match; 4482 4482 end getFunctionInterface; 4483 4483 4484 4484 protected function getFunctionInterfaceParts 4485 input ClassPart part;4486 input list< ElementItem> elts;4487 output list< ElementItem> oelts;4485 input Absyn.ClassPart part; 4486 input list<Absyn.ElementItem> elts; 4487 output list<Absyn.ElementItem> oelts; 4488 4488 algorithm 4489 4489 oelts := match (part,elts) 4490 4490 local 4491 list< ElementItem> elts1,elts2;4492 case ( PUBLIC(elts1),elts2)4491 list<Absyn.ElementItem> elts1,elts2; 4492 case (Absyn.PUBLIC(elts1),elts2) 4493 4493 equation 4494 4494 elts1 = List.filterOnTrue(elts1,filterAnnotationItem); … … 4499 4499 4500 4500 protected function filterAnnotationItem 4501 input ElementItem elt;4501 input Absyn.ElementItem elt; 4502 4502 output Boolean outB; 4503 4503 algorithm 4504 4504 outB := match elt 4505 case ELEMENTITEM() then true;4505 case Absyn.ELEMENTITEM() then true; 4506 4506 else false; 4507 4507 end match; … … 4510 4510 public function filterNestedClasses 4511 4511 "Filter outs the nested classes from the class if any." 4512 input Class cl;4513 output Class o;4512 input Absyn.Class cl; 4513 output Absyn.Class o; 4514 4514 algorithm 4515 4515 o := match cl 4516 4516 local 4517 Ident name;4517 Absyn.Ident name; 4518 4518 Boolean partialPrefix, finalPrefix, encapsulatedPrefix; 4519 Restriction restriction;4519 Absyn.Restriction restriction; 4520 4520 list<String> typeVars; 4521 list< NamedArg> classAttrs;4522 list< ClassPart> classParts;4523 list<A nnotation> annotations;4521 list<Absyn.NamedArg> classAttrs; 4522 list<Absyn.ClassPart> classParts; 4523 list<Absyn.Annotation> annotations; 4524 4524 Option<String> comment; 4525 Info info;4526 case CLASS(name,partialPrefix,finalPrefix,encapsulatedPrefix,restriction,PARTS(typeVars,classAttrs,classParts,annotations,comment),info)4525 Absyn.Info info; 4526 case Absyn.CLASS(name,partialPrefix,finalPrefix,encapsulatedPrefix,restriction,Absyn.PARTS(typeVars,classAttrs,classParts,annotations,comment),info) 4527 4527 equation 4528 4528 (classParts as _::_) = List.fold(listReverse(classParts),filterNestedClassesParts,{}); 4529 then CLASS(name,partialPrefix,finalPrefix,encapsulatedPrefix,restriction,PARTS(typeVars,classAttrs,classParts,annotations,comment),info);4529 then Absyn.CLASS(name,partialPrefix,finalPrefix,encapsulatedPrefix,restriction,Absyn.PARTS(typeVars,classAttrs,classParts,annotations,comment),info); 4530 4530 else cl; 4531 4531 end match; … … 4534 4534 protected function filterNestedClassesParts 4535 4535 "Helper funciton for filterNestedClassesParts." 4536 input ClassPart classPart;4537 input list< ClassPart> inClassParts;4538 output list< ClassPart> outClassPart;4536 input Absyn.ClassPart classPart; 4537 input list<Absyn.ClassPart> inClassParts; 4538 output list<Absyn.ClassPart> outClassPart; 4539 4539 algorithm 4540 4540 outClassPart := match (classPart, inClassParts) 4541 4541 local 4542 list< ClassPart> classParts;4543 list< ElementItem> elts;4544 case ( PUBLIC(elts), classParts)4542 list<Absyn.ClassPart> classParts; 4543 list<Absyn.ElementItem> elts; 4544 case (Absyn.PUBLIC(elts), classParts) 4545 4545 equation 4546 4546 classPart.contents = List.filterOnFalse(elts, isElementItemClass); 4547 4547 then classPart::classParts; 4548 case ( PROTECTED(elts), classParts)4548 case (Absyn.PROTECTED(elts), classParts) 4549 4549 equation 4550 4550 classPart.contents = List.filterOnFalse(elts, isElementItemClass); … … 4556 4556 public function getExternalDecl 4557 4557 "@author: adrpo 4558 returns the EXTERNAL form parts if there is any.4558 returns the Absyn.EXTERNAL form parts if there is any. 4559 4559 if there is none, it fails!" 4560 input Class inCls;4561 output ClassPart outExternal;4560 input Absyn.Class inCls; 4561 output Absyn.ClassPart outExternal; 4562 4562 protected 4563 ClassPart cp;4564 list< ClassPart> class_parts;4565 algorithm 4566 CLASS(body =PARTS(classParts = class_parts)) := inCls;4563 Absyn.ClassPart cp; 4564 list<Absyn.ClassPart> class_parts; 4565 algorithm 4566 Absyn.CLASS(body = Absyn.PARTS(classParts = class_parts)) := inCls; 4567 4567 outExternal := List.find(class_parts, isExternalPart); 4568 4568 end getExternalDecl; 4569 4569 4570 4570 protected function isExternalPart 4571 input ClassPart inClassPart;4571 input Absyn.ClassPart inClassPart; 4572 4572 output Boolean outFound; 4573 4573 algorithm 4574 4574 outFound := match inClassPart 4575 case EXTERNAL() then true;4575 case Absyn.EXTERNAL() then true; 4576 4576 else false; 4577 4577 end match; … … 4579 4579 4580 4580 public function isParts 4581 input ClassDef cl;4581 input Absyn.ClassDef cl; 4582 4582 output Boolean b; 4583 4583 algorithm 4584 4584 b := match cl 4585 case PARTS() then true;4585 case Absyn.PARTS() then true; 4586 4586 else false; 4587 4587 end match; 4588 4588 end isParts; 4589 4589 4590 public function makeClassElement "Makes a class into an ElementItem"4591 input Class cl;4592 output ElementItem el;4590 public function makeClassElement "Makes a class into an Absyn.ElementItem" 4591 input Absyn.Class cl; 4592 output Absyn.ElementItem el; 4593 4593 protected 4594 Info info;4594 Absyn.Info info; 4595 4595 Boolean fp; 4596 4596 algorithm 4597 CLASS(finalPrefix = fp, info = info) := cl;4598 el := ELEMENTITEM(ELEMENT(fp,NONE(),NOT_INNER_OUTER(),CLASSDEF(false,cl),info,NONE()));4597 Absyn.CLASS(finalPrefix = fp, info = info) := cl; 4598 el := Absyn.ELEMENTITEM(Absyn.ELEMENT(fp,NONE(),Absyn.NOT_INNER_OUTER(),Absyn.CLASSDEF(false,cl),info,NONE())); 4599 4599 end makeClassElement; 4600 4600 4601 4601 public function componentName 4602 input ComponentItem c;4602 input Absyn.ComponentItem c; 4603 4603 output String name; 4604 4604 algorithm 4605 COMPONENTITEM(component=COMPONENT(name=name)) := c;4605 Absyn.COMPONENTITEM(component=Absyn.COMPONENT(name=name)) := c; 4606 4606 end componentName; 4607 4607 4608 4608 public function pathSetLastIdent 4609 input Path inPath;4610 input Path inLastIdent;4611 output Path outPath;4609 input Absyn.Path inPath; 4610 input Absyn.Path inLastIdent; 4611 output Absyn.Path outPath; 4612 4612 algorithm 4613 4613 outPath := match(inPath, inLastIdent) 4614 4614 local 4615 Path p;4615 Absyn.Path p; 4616 4616 String n; 4617 4617 4618 case ( IDENT(), _) then inLastIdent;4619 4620 case ( QUALIFIED(n, p), _)4618 case (Absyn.IDENT(), _) then inLastIdent; 4619 4620 case (Absyn.QUALIFIED(n, p), _) 4621 4621 equation 4622 4622 p = pathSetLastIdent(p, inLastIdent); 4623 4623 then 4624 QUALIFIED(n, p);4625 4626 case ( FULLYQUALIFIED(p), _)4624 Absyn.QUALIFIED(n, p); 4625 4626 case (Absyn.FULLYQUALIFIED(p), _) 4627 4627 equation 4628 4628 p = pathSetLastIdent(p, inLastIdent); 4629 4629 then 4630 FULLYQUALIFIED(p);4630 Absyn.FULLYQUALIFIED(p); 4631 4631 4632 4632 end match; … … 4636 4636 "@author: 4637 4637 returns true if expression contains initial()" 4638 input Exp inExp;4638 input Absyn.Exp inExp; 4639 4639 output Boolean hasInitial; 4640 4640 algorithm … … 4653 4653 "@author: 4654 4654 returns true if expression is initial()" 4655 input Exp inExp;4655 input Absyn.Exp inExp; 4656 4656 input Boolean inBool; 4657 output Exp outExp;4657 output Absyn.Exp outExp; 4658 4658 output Boolean outBool; 4659 4659 algorithm 4660 4660 (outExp,outBool) := match (inExp,inBool) 4661 local Exp e; Boolean b;4661 local Absyn.Exp e; Boolean b; 4662 4662 4663 4663 // make sure we don't have not initial() 4664 case ( UNARY(NOT(), _) , _) then (inExp,inBool);4664 case (Absyn.UNARY(Absyn.NOT(), _) , _) then (inExp,inBool); 4665 4665 // we have initial 4666 4666 case (e , _) … … 4675 4675 "@author: 4676 4676 returns true if expression is initial()" 4677 input Exp inExp;4677 input Absyn.Exp inExp; 4678 4678 output Boolean hasReinit; 4679 4679 algorithm 4680 4680 hasReinit := match(inExp) 4681 case ( CALL(function_ =CREF_IDENT("initial", _))) then true;4682 case ( CALL(function_ = CREF_FULLYQUALIFIED(CREF_IDENT("initial", _)))) then true;4681 case (Absyn.CALL(function_ = Absyn.CREF_IDENT("initial", _))) then true; 4682 case (Absyn.CALL(function_ = Absyn.CREF_FULLYQUALIFIED(Absyn.CREF_IDENT("initial", _)))) then true; 4683 4683 else false; 4684 4684 end match; … … 4687 4687 public function importPath 4688 4688 "Return the path of the given import." 4689 input Import inImport;4690 output Path outPath;4689 input Absyn.Import inImport; 4690 output Absyn.Path outPath; 4691 4691 algorithm 4692 4692 outPath := match(inImport) 4693 4693 local 4694 Path path;4695 4696 case NAMED_IMPORT(path = path) then path;4697 case QUAL_IMPORT(path = path) then path;4698 case UNQUAL_IMPORT(path = path) then path;4699 case GROUP_IMPORT(prefix = path) then path;4694 Absyn.Path path; 4695 4696 case Absyn.NAMED_IMPORT(path = path) then path; 4697 case Absyn.QUAL_IMPORT(path = path) then path; 4698 case Absyn.UNQUAL_IMPORT(path = path) then path; 4699 case Absyn.GROUP_IMPORT(prefix = path) then path; 4700 4700 4701 4701 end match; … … 4704 4704 public function importName 4705 4705 "Returns the import name of a named or qualified import." 4706 input Import inImport;4707 output Ident outName;4706 input Absyn.Import inImport; 4707 output Absyn.Ident outName; 4708 4708 algorithm 4709 4709 outName := match(inImport) 4710 4710 local 4711 Ident name;4712 Path path;4711 Absyn.Ident name; 4712 Absyn.Path path; 4713 4713 4714 4714 // Named import has a given name, 'import D = A.B.C' => D. 4715 case NAMED_IMPORT(name = name) then name;4715 case Absyn.NAMED_IMPORT(name = name) then name; 4716 4716 // Qualified import uses the last identifier, 'import A.B.C' => C. 4717 case QUAL_IMPORT(path = path) then pathLastIdent(path);4717 case Absyn.QUAL_IMPORT(path = path) then pathLastIdent(path); 4718 4718 4719 4719 end match; … … 4723 4723 " This function takes an old annotation as first argument and a new 4724 4724 annotation as second argument and merges the two. 4725 A nnotation \"parts\" that exist in both the old and the new annotation4725 Absyn.Annotation \"parts\" that exist in both the old and the new annotation 4726 4726 will be changed according to the new definition. For instance, 4727 4727 merge_annotations(annotation(x=1,y=2),annotation(x=3)) 4728 4728 => annotation(x=3,y=2)" 4729 input A nnotation inAnnotation1;4730 input A nnotation inAnnotation2;4731 output A nnotation outAnnotation;4729 input Absyn.Annotation inAnnotation1; 4730 input Absyn.Annotation inAnnotation2; 4731 output Absyn.Annotation outAnnotation; 4732 4732 algorithm 4733 4733 outAnnotation:= 4734 4734 match (inAnnotation1,inAnnotation2) 4735 4735 local 4736 list< ElementArg> oldmods,newmods;4737 A nnotation a;4738 case (A NNOTATION(elementArgs = {}),a) then a;4739 4740 case (A NNOTATION(elementArgs = oldmods),ANNOTATION(elementArgs = newmods))4741 then A NNOTATION(mergeAnnotations2(oldmods, newmods));4736 list<Absyn.ElementArg> oldmods,newmods; 4737 Absyn.Annotation a; 4738 case (Absyn.ANNOTATION(elementArgs = {}),a) then a; 4739 4740 case (Absyn.ANNOTATION(elementArgs = oldmods),Absyn.ANNOTATION(elementArgs = newmods)) 4741 then Absyn.ANNOTATION(mergeAnnotations2(oldmods, newmods)); 4742 4742 end match; 4743 4743 end mergeAnnotations; … … 4746 4746 4747 4747 function mergeAnnotations2 4748 input list< ElementArg> oldmods;4749 input list< ElementArg> newmods;4750 output list< ElementArg> res = listReverse(oldmods);4748 input list<Absyn.ElementArg> oldmods; 4749 input list<Absyn.ElementArg> newmods; 4750 output list<Absyn.ElementArg> res = listReverse(oldmods); 4751 4751 protected 4752 list< ElementArg> mods;4752 list<Absyn.ElementArg> mods; 4753 4753 Boolean b; 4754 Path p;4755 ElementArg mod1,mod2;4754 Absyn.Path p; 4755 Absyn.ElementArg mod1,mod2; 4756 4756 algorithm 4757 4757 for mod in newmods loop 4758 MODIFICATION(path=p) := mod;4758 Absyn.MODIFICATION(path=p) := mod; 4759 4759 try 4760 4760 mod2 := List.find(res, function isModificationOfPath(path=p)); … … 4769 4769 4770 4770 public function mergeCommentAnnotation 4771 "Merges an annotation into a Comment option."4772 input A nnotation inAnnotation;4773 input Option< Comment> inComment;4774 output Option< Comment> outComment;4771 "Merges an annotation into a Absyn.Comment option." 4772 input Absyn.Annotation inAnnotation; 4773 input Option<Absyn.Comment> inComment; 4774 output Option<Absyn.Comment> outComment; 4775 4775 algorithm 4776 4776 outComment := match inComment 4777 4777 local 4778 A nnotation ann;4778 Absyn.Annotation ann; 4779 4779 Option<String> cmt; 4780 4780 4781 4781 // No comment, create a new one. 4782 4782 case NONE() 4783 then SOME( COMMENT(SOME(inAnnotation), NONE()));4783 then SOME(Absyn.COMMENT(SOME(inAnnotation), NONE())); 4784 4784 4785 4785 // A comment without annotation, insert the annotation. 4786 case SOME( COMMENT(annotation_ = NONE(), comment = cmt))4787 then SOME( COMMENT(SOME(inAnnotation), cmt));4786 case SOME(Absyn.COMMENT(annotation_ = NONE(), comment = cmt)) 4787 then SOME(Absyn.COMMENT(SOME(inAnnotation), cmt)); 4788 4788 4789 4789 // A comment with annotation, merge the annotations. 4790 case SOME( COMMENT(annotation_ = SOME(ann), comment = cmt))4791 then SOME( COMMENT(SOME(mergeAnnotations(ann, inAnnotation)), cmt));4790 case SOME(Absyn.COMMENT(annotation_ = SOME(ann), comment = cmt)) 4791 then SOME(Absyn.COMMENT(SOME(mergeAnnotations(ann, inAnnotation)), cmt)); 4792 4792 4793 4793 end match; … … 4796 4796 function isModificationOfPath 4797 4797 "returns true or false if the given path is in the list of modifications" 4798 input ElementArg mod;4799 input Path path;4798 input Absyn.ElementArg mod; 4799 input Absyn.Path path; 4800 4800 output Boolean yes; 4801 4801 algorithm … … 4803 4803 local 4804 4804 String id1,id2; 4805 case ( MODIFICATION(path = IDENT(name = id1)),IDENT(name = id2)) then id1==id2;4805 case (Absyn.MODIFICATION(path = Absyn.IDENT(name = id1)),Absyn.IDENT(name = id2)) then id1==id2; 4806 4806 else false; 4807 4807 end match; … … 4809 4809 4810 4810 function subModsInSameOrder 4811 input ElementArg oldmod;4812 input ElementArg newmod;4813 output ElementArg mod;4811 input Absyn.ElementArg oldmod; 4812 input Absyn.ElementArg newmod; 4813 output Absyn.ElementArg mod; 4814 4814 algorithm 4815 4815 mod := match (oldmod,newmod) 4816 4816 local 4817 list< ElementArg> args1,args2,res;4818 ElementArg arg2;4819 EqMod eq1,eq2;4820 Path p;4817 list<Absyn.ElementArg> args1,args2,res; 4818 Absyn.ElementArg arg2; 4819 Absyn.EqMod eq1,eq2; 4820 Absyn.Path p; 4821 4821 4822 4822 // mod1 or mod2 has no submods 4823 case (_, MODIFICATION(modification=NONE())) then newmod;4824 case ( MODIFICATION(modification=NONE()), _) then newmod;4823 case (_, Absyn.MODIFICATION(modification=NONE())) then newmod; 4824 case (Absyn.MODIFICATION(modification=NONE()), _) then newmod; 4825 4825 // mod1 4826 case ( MODIFICATION(modification=SOME(CLASSMOD(args1,_))), arg2 as MODIFICATION(modification=SOME(CLASSMOD(args2,eq2))))4826 case (Absyn.MODIFICATION(modification=SOME(Absyn.CLASSMOD(args1,_))), arg2 as Absyn.MODIFICATION(modification=SOME(Absyn.CLASSMOD(args2,eq2)))) 4827 4827 algorithm 4828 4828 // Delete all items from args2 that are not in args1 4829 4829 res := {}; 4830 4830 for arg1 in args1 loop 4831 MODIFICATION(path=p) := arg1;4831 Absyn.MODIFICATION(path=p) := arg1; 4832 4832 if List.exist(args2, function isModificationOfPath(path=p)) then 4833 4833 res := arg1::res; … … 4837 4837 // Merge the annotations 4838 4838 res := mergeAnnotations2(res, args2); 4839 arg2.modification := SOME( CLASSMOD(res,eq2));4839 arg2.modification := SOME(Absyn.CLASSMOD(res,eq2)); 4840 4840 then arg2; 4841 4841 end match; … … 4843 4843 4844 4844 public function annotationToElementArgs 4845 input A nnotation ann;4846 output list< ElementArg> args;4847 algorithm 4848 A NNOTATION(args) := ann;4845 input Absyn.Annotation ann; 4846 output list<Absyn.ElementArg> args; 4847 algorithm 4848 Absyn.ANNOTATION(args) := ann; 4849 4849 end annotationToElementArgs; 4850 4850 4851 4851 public function pathToTypeSpec 4852 input Path inPath;4853 output TypeSpec outTypeSpec;4854 algorithm 4855 outTypeSpec := TPATH(inPath, NONE());4852 input Absyn.Path inPath; 4853 output Absyn.TypeSpec outTypeSpec; 4854 algorithm 4855 outTypeSpec := Absyn.TPATH(inPath, NONE()); 4856 4856 end pathToTypeSpec; 4857 4857 4858 4858 public function typeSpecString 4859 input TypeSpec inTs;4859 input Absyn.TypeSpec inTs; 4860 4860 output String outStr; 4861 4861 algorithm … … 4864 4864 4865 4865 public function crefString 4866 input ComponentRef inCr;4866 input Absyn.ComponentRef inCr; 4867 4867 output String outStr; 4868 4868 algorithm … … 4871 4871 4872 4872 public function typeSpecStringNoQualNoDims 4873 input TypeSpec inTs;4873 input Absyn.TypeSpec inTs; 4874 4874 output String outStr; 4875 4875 algorithm 4876 4876 outStr := match (inTs) 4877 4877 local 4878 Ident str,s,str1,str2,str3;4879 Path path;4880 Option<list< Subscript>> adim;4881 list< TypeSpec> typeSpecLst;4882 4883 case ( TPATH(path = path))4878 Absyn.Ident str,s,str1,str2,str3; 4879 Absyn.Path path; 4880 Option<list<Absyn.Subscript>> adim; 4881 list<Absyn.TypeSpec> typeSpecLst; 4882 4883 case (Absyn.TPATH(path = path)) 4884 4884 equation 4885 4885 str = pathString(makeNotFullyQualified(path)); … … 4887 4887 str; 4888 4888 4889 case ( TCOMPLEX(path = path,typeSpecs = typeSpecLst))4889 case (Absyn.TCOMPLEX(path = path,typeSpecs = typeSpecLst)) 4890 4890 equation 4891 4891 str1 = pathString(makeNotFullyQualified(path)); … … 4899 4899 4900 4900 public function typeSpecStringNoQualNoDimsLst 4901 input list< TypeSpec> inTypeSpecLst;4901 input list<Absyn.TypeSpec> inTypeSpecLst; 4902 4902 output String outString; 4903 4903 algorithm … … 4907 4907 4908 4908 public function crefStringIgnoreSubs 4909 input ComponentRef inCr;4909 input Absyn.ComponentRef inCr; 4910 4910 output String outStr; 4911 4911 protected 4912 Path p;4912 Absyn.Path p; 4913 4913 algorithm 4914 4914 p := crefToPathIgnoreSubs(inCr); … … 4917 4917 4918 4918 public function importString 4919 input Import inImp;4919 input Absyn.Import inImp; 4920 4920 output String outStr; 4921 4921 algorithm … … 4925 4925 public function refString 4926 4926 "@author: adrpo 4927 full Ref -> string4927 full Absyn.Ref -> string 4928 4928 cref/path full qualified, type dims, subscripts in crefs" 4929 input Ref inRef;4929 input Absyn.Ref inRef; 4930 4930 output String outStr; 4931 4931 algorithm 4932 4932 outStr := match(inRef) 4933 local ComponentRef cr; TypeSpec ts;Import im;4934 case ( RCR(cr)) then crefString(cr);4935 case ( RTS(ts)) then typeSpecString(ts);4936 case ( RIM(im)) then importString(im);4933 local Absyn.ComponentRef cr; Absyn.TypeSpec ts; Absyn.Import im; 4934 case (Absyn.RCR(cr)) then crefString(cr); 4935 case (Absyn.RTS(ts)) then typeSpecString(ts); 4936 case (Absyn.RIM(im)) then importString(im); 4937 4937 end match; 4938 4938 end refString; … … 4940 4940 public function refStringBrief 4941 4941 "@author: adrpo 4942 brief Ref -> string4942 brief Absyn.Ref -> string 4943 4943 no cref/path full qualified, no type dims, no subscripts in crefs" 4944 input Ref inRef;4944 input Absyn.Ref inRef; 4945 4945 output String outStr; 4946 4946 algorithm 4947 4947 outStr := match(inRef) 4948 local ComponentRef cr; TypeSpec ts;Import im;4949 case ( RCR(cr)) then crefStringIgnoreSubs(cr);4950 case ( RTS(ts)) then typeSpecStringNoQualNoDims(ts);4951 case ( RIM(im)) then importString(im);4948 local Absyn.ComponentRef cr; Absyn.TypeSpec ts; Absyn.Import im; 4949 case (Absyn.RCR(cr)) then crefStringIgnoreSubs(cr); 4950 case (Absyn.RTS(ts)) then typeSpecStringNoQualNoDims(ts); 4951 case (Absyn.RIM(im)) then importString(im); 4952 4952 end match; 4953 4953 end refStringBrief; 4954 4954 4955 4955 public function getArrayDimOptAsList 4956 input Option<A rrayDim> inArrayDim;4957 output A rrayDim outArrayDim;4956 input Option<Absyn.ArrayDim> inArrayDim; 4957 output Absyn.ArrayDim outArrayDim; 4958 4958 algorithm 4959 4959 outArrayDim := match(inArrayDim) 4960 local A rrayDim ad;4960 local Absyn.ArrayDim ad; 4961 4961 case (SOME(ad)) then ad; 4962 4962 else {}; … … 4966 4966 public function removeCrefFromCrefs 4967 4967 "Removes a variable from a variable list" 4968 input list< ComponentRef> inAbsynComponentRefLst;4969 input ComponentRef inComponentRef;4970 output list< ComponentRef> outAbsynComponentRefLst;4968 input list<Absyn.ComponentRef> inAbsynComponentRefLst; 4969 input Absyn.ComponentRef inComponentRef; 4970 output list<Absyn.ComponentRef> outAbsynComponentRefLst; 4971 4971 algorithm 4972 4972 outAbsynComponentRefLst := matchcontinue (inAbsynComponentRefLst,inComponentRef) 4973 4973 local 4974 4974 String n1,n2; 4975 list< ComponentRef> rest_1,rest;4976 ComponentRef cr1,cr2;4975 list<Absyn.ComponentRef> rest_1,rest; 4976 Absyn.ComponentRef cr1,cr2; 4977 4977 case ({},_) then {}; 4978 4978 case ((cr1 :: rest),cr2) 4979 4979 equation 4980 CREF_IDENT(name = n1,subscripts = {}) = cr1;4981 CREF_IDENT(name = n2,subscripts = {}) = cr2;4980 Absyn.CREF_IDENT(name = n1,subscripts = {}) = cr1; 4981 Absyn.CREF_IDENT(name = n2,subscripts = {}) = cr2; 4982 4982 true = stringEq(n1, n2); 4983 4983 rest_1 = removeCrefFromCrefs(rest, cr2); … … 4986 4986 case ((cr1 :: rest),cr2) // If modifier like on comp like: T t(x=t.y) => t.y must be removed 4987 4987 equation 4988 CREF_QUAL(name = n1) = cr1;4989 CREF_IDENT(name = n2) = cr2;4988 Absyn.CREF_QUAL(name = n1) = cr1; 4989 Absyn.CREF_IDENT(name = n2) = cr2; 4990 4990 true = stringEq(n1, n2); 4991 4991 rest_1 = removeCrefFromCrefs(rest, cr2); … … 5002 5002 public function getNamedAnnotationInClass 5003 5003 "Retrieve e.g. the documentation annotation as a string from the class passed as argument." 5004 input Class inClass;5005 input Path id;5004 input Absyn.Class inClass; 5005 input Absyn.Path id; 5006 5006 input ModFunc f; 5007 5007 output Option<TypeA> outString; 5008 5008 partial function ModFunc 5009 input Option< Modification> mod;5009 input Option<Absyn.Modification> mod; 5010 5010 output TypeA docStr; 5011 5011 end ModFunc; … … 5014 5014 local 5015 5015 TypeA str,res; 5016 list< ClassPart> parts;5017 list< ElementArg> annlst;5018 list<A nnotation> ann;5019 5020 case ( CLASS(body =PARTS(ann = ann)),_,_)5016 list<Absyn.ClassPart> parts; 5017 list<Absyn.ElementArg> annlst; 5018 list<Absyn.Annotation> ann; 5019 5020 case (Absyn.CLASS(body = Absyn.PARTS(ann = ann)),_,_) 5021 5021 equation 5022 5022 annlst = List.flatten(List.map(ann,annotationToElementArgs)); … … 5025 5025 SOME(str); 5026 5026 5027 case ( CLASS(body =CLASS_EXTENDS(ann = ann)),_,_)5027 case (Absyn.CLASS(body = Absyn.CLASS_EXTENDS(ann = ann)),_,_) 5028 5028 equation 5029 5029 annlst = List.flatten(List.map(ann,annotationToElementArgs)); … … 5032 5032 SOME(str); 5033 5033 5034 case ( CLASS(body = DERIVED(comment = SOME(COMMENT(SOME(ANNOTATION(annlst)),_)))),_,_)5034 case (Absyn.CLASS(body = Absyn.DERIVED(comment = SOME(Absyn.COMMENT(SOME(Absyn.ANNOTATION(annlst)),_)))),_,_) 5035 5035 equation 5036 5036 SOME(res) = getNamedAnnotationStr(annlst,id,f); … … 5038 5038 SOME(res); 5039 5039 5040 case ( CLASS(body = ENUMERATION(comment = SOME(COMMENT(SOME(ANNOTATION(annlst)),_)))),_,_)5040 case (Absyn.CLASS(body = Absyn.ENUMERATION(comment = SOME(Absyn.COMMENT(SOME(Absyn.ANNOTATION(annlst)),_)))),_,_) 5041 5041 equation 5042 5042 SOME(res) = getNamedAnnotationStr(annlst,id,f); … … 5044 5044 SOME(res); 5045 5045 5046 case ( CLASS(body = OVERLOAD(comment = SOME(COMMENT(SOME(ANNOTATION(annlst)),_)))),_,_)5046 case (Absyn.CLASS(body = Absyn.OVERLOAD(comment = SOME(Absyn.COMMENT(SOME(Absyn.ANNOTATION(annlst)),_)))),_,_) 5047 5047 equation 5048 5048 SOME(res) = getNamedAnnotationStr(annlst,id,f); … … 5057 5057 protected function getNamedAnnotationStr 5058 5058 "Helper function to getNamedAnnotationInElementitemlist." 5059 input list< ElementArg> inAbsynElementArgLst;5060 input Path id;5059 input list<Absyn.ElementArg> inAbsynElementArgLst; 5060 input Absyn.Path id; 5061 5061 input ModFunc f; 5062 5062 output Option<TypeA> outString; 5063 5063 partial function ModFunc 5064 input Option< Modification> mod;5064 input Option<Absyn.Modification> mod; 5065 5065 output TypeA docStr; 5066 5066 end ModFunc; … … 5069 5069 local 5070 5070 TypeA str; 5071 ElementArg ann;5072 Option< Modification> mod;5073 list< ElementArg> xs;5074 Ident id1,id2;5075 Path rest;5076 5077 case ((( MODIFICATION(path = IDENT(name = id1),modification = mod)) :: _),IDENT(id2),_)5071 Absyn.ElementArg ann; 5072 Option<Absyn.Modification> mod; 5073 list<Absyn.ElementArg> xs; 5074 Absyn.Ident id1,id2; 5075 Absyn.Path rest; 5076 5077 case (((Absyn.MODIFICATION(path = Absyn.IDENT(name = id1),modification = mod)) :: _),Absyn.IDENT(id2),_) 5078 5078 equation 5079 5079 true = stringEq(id1, id2); … … 5082 5082 SOME(str); 5083 5083 5084 case ((( MODIFICATION(path = IDENT(name = id1),modification = SOME(CLASSMOD(elementArgLst=xs)))) :: _),QUALIFIED(name=id2,path=rest),_)5084 case (((Absyn.MODIFICATION(path = Absyn.IDENT(name = id1),modification = SOME(Absyn.CLASSMOD(elementArgLst=xs)))) :: _),Absyn.QUALIFIED(name=id2,path=rest),_) 5085 5085 equation 5086 5086 true = stringEq(id1, id2); … … 5094 5094 "This function splits each part of a cref into CREF_IDENTs and applies the 5095 5095 given function to each part. If the given cref is a qualified cref then the 5096 map function is expected to also return CREF_IDENT, so that the split cref5096 map function is expected to also return Absyn.CREF_IDENT, so that the split cref 5097 5097 can be reconstructed. Otherwise the map function is free to return whatever 5098 5098 it wants." 5099 input ComponentRef inCref;5099 input Absyn.ComponentRef inCref; 5100 5100 input MapFunc inMapFunc; 5101 output ComponentRef outCref;5101 output Absyn.ComponentRef outCref; 5102 5102 5103 5103 partial function MapFunc 5104 input ComponentRef inCref;5105 output ComponentRef outCref;5104 input Absyn.ComponentRef inCref; 5105 output Absyn.ComponentRef outCref; 5106 5106 end MapFunc; 5107 5107 algorithm 5108 5108 outCref := match(inCref, inMapFunc) 5109 5109 local 5110 Ident name;5111 list< Subscript> subs;5112 ComponentRef rest_cref;5113 ComponentRef cref;5114 5115 case ( CREF_QUAL(name, subs, rest_cref), _)5116 equation 5117 cref = CREF_IDENT(name, subs);5118 CREF_IDENT(name, subs) = inMapFunc(cref);5110 Absyn.Ident name; 5111 list<Absyn.Subscript> subs; 5112 Absyn.ComponentRef rest_cref; 5113 Absyn.ComponentRef cref; 5114 5115 case (Absyn.CREF_QUAL(name, subs, rest_cref), _) 5116 equation 5117 cref = Absyn.CREF_IDENT(name, subs); 5118 Absyn.CREF_IDENT(name, subs) = inMapFunc(cref); 5119 5119 rest_cref = mapCrefParts(rest_cref, inMapFunc); 5120 5120 then 5121 CREF_QUAL(name, subs, rest_cref);5122 5123 case ( CREF_FULLYQUALIFIED(cref), _)5121 Absyn.CREF_QUAL(name, subs, rest_cref); 5122 5123 case (Absyn.CREF_FULLYQUALIFIED(cref), _) 5124 5124 equation 5125 5125 cref = mapCrefParts(cref, inMapFunc); 5126 5126 then 5127 CREF_FULLYQUALIFIED(cref);5127 Absyn.CREF_FULLYQUALIFIED(cref); 5128 5128 5129 5129 else … … 5137 5137 5138 5138 public function opEqual 5139 input Operator op1;5140 input Operator op2;5139 input Absyn.Operator op1; 5140 input Absyn.Operator op2; 5141 5141 output Boolean isEqual; 5142 5142 algorithm … … 5145 5145 5146 5146 public function opIsElementWise 5147 input Operator op;5147 input Absyn.Operator op; 5148 5148 output Boolean isElementWise; 5149 5149 algorithm 5150 5150 isElementWise := match op 5151 case A DD_EW() then true;5152 case SUB_EW() then true;5153 case MUL_EW() then true;5154 case DIV_EW() then true;5155 case POW_EW() then true;5156 case UPLUS_EW() then true;5157 case UMINUS_EW() then true;5151 case Absyn.ADD_EW() then true; 5152 case Absyn.SUB_EW() then true; 5153 case Absyn.MUL_EW() then true; 5154 case Absyn.DIV_EW() then true; 5155 case Absyn.POW_EW() then true; 5156 case Absyn.UPLUS_EW() then true; 5157 case Absyn.UMINUS_EW() then true; 5158 5158 else false; 5159 5159 end match; … … 5161 5161 5162 5162 protected function dummyTraverseExp 5163 input Exp inExp;5163 input Absyn.Exp inExp; 5164 5164 input Arg inArg; 5165 output Exp outExp;5165 output Absyn.Exp outExp; 5166 5166 output Arg outArg; 5167 5167 algorithm … … 5171 5171 5172 5172 public function getDefineUnitsInElements "retrives defineunit definitions in elements" 5173 input list< ElementItem> elts;5174 output list< Element> outElts;5173 input list<Absyn.ElementItem> elts; 5174 output list<Absyn.Element> outElts; 5175 5175 algorithm 5176 5176 outElts := matchcontinue(elts) 5177 5177 local 5178 Element e;5179 list< ElementItem> rest;5178 Absyn.Element e; 5179 list<Absyn.ElementItem> rest; 5180 5180 case {} then {}; 5181 case ( ELEMENTITEM(e asDEFINEUNIT())::rest)5181 case (Absyn.ELEMENTITEM(e as Absyn.DEFINEUNIT())::rest) 5182 5182 equation 5183 5183 outElts = getDefineUnitsInElements(rest); … … 5190 5190 public function getElementItemsInClass 5191 5191 "Returns the public and protected elements in a class." 5192 input Class inClass;5193 output list< ElementItem> outElements;5192 input Absyn.Class inClass; 5193 output list<Absyn.ElementItem> outElements; 5194 5194 algorithm 5195 5195 outElements := match(inClass) 5196 5196 local 5197 list< ClassPart> parts;5198 5199 case CLASS(body =PARTS(classParts = parts))5197 list<Absyn.ClassPart> parts; 5198 5199 case Absyn.CLASS(body = Absyn.PARTS(classParts = parts)) 5200 5200 then List.mapFlat(parts, getElementItemsInClassPart); 5201 5201 5202 case CLASS(body =CLASS_EXTENDS(parts = parts))5202 case Absyn.CLASS(body = Absyn.CLASS_EXTENDS(parts = parts)) 5203 5203 then List.mapFlat(parts, getElementItemsInClassPart); 5204 5204 … … 5210 5210 public function getElementItemsInClassPart 5211 5211 "Returns the public and protected elements in a class part." 5212 input ClassPart inClassPart;5213 output list< ElementItem> outElements;5212 input Absyn.ClassPart inClassPart; 5213 output list<Absyn.ElementItem> outElements; 5214 5214 algorithm 5215 5215 outElements := match(inClassPart) 5216 5216 local 5217 list< ElementItem> elts;5218 5219 case PUBLIC(contents = elts) then elts;5220 case PROTECTED(contents = elts) then elts;5217 list<Absyn.ElementItem> elts; 5218 5219 case Absyn.PUBLIC(contents = elts) then elts; 5220 case Absyn.PROTECTED(contents = elts) then elts; 5221 5221 else {}; 5222 5222 end match; … … 5224 5224 5225 5225 public function traverseClassComponents<ArgT> 5226 input Class inClass;5226 input Absyn.Class inClass; 5227 5227 input FuncType inFunc; 5228 5228 input ArgT inArg; 5229 output Class outClass = inClass;5229 output Absyn.Class outClass = inClass; 5230 5230 output ArgT outArg; 5231 5231 5232 5232 partial function FuncType 5233 input list< ComponentItem> inComponents;5233 input list<Absyn.ComponentItem> inComponents; 5234 5234 input ArgT inArg; 5235 output list< ComponentItem> outComponents;5235 output list<Absyn.ComponentItem> outComponents; 5236 5236 output ArgT outArg; 5237 5237 output Boolean outContinue; … … 5240 5240 outClass := match(outClass) 5241 5241 local 5242 ClassDef body;5243 5244 case CLASS()5242 Absyn.ClassDef body; 5243 5244 case Absyn.CLASS() 5245 5245 algorithm 5246 5246 (body, outArg) := traverseClassDef(outClass.body, … … 5290 5290 5291 5291 protected function traverseClassPartComponents<ArgT> 5292 input ClassPart inClassPart;5292 input Absyn.ClassPart inClassPart; 5293 5293 input FuncType inFunc; 5294 5294 input ArgT inArg; 5295 output ClassPart outClassPart = inClassPart;5295 output Absyn.ClassPart outClassPart = inClassPart; 5296 5296 output ArgT outArg = inArg; 5297 5297 output Boolean outContinue = true; 5298 5298 5299 5299 partial function FuncType 5300 input list< ComponentItem> inComponents;5300 input list<Absyn.ComponentItem> inComponents; 5301 5301 input ArgT inArg; 5302 output list< ComponentItem> outComponents;5302 output list<Absyn.ComponentItem> outComponents; 5303 5303 output ArgT outArg; 5304 5304 output Boolean outContinue; … … 5307 5307 _ := match(outClassPart) 5308 5308 local 5309 list< ElementItem> items;5310 5311 case PUBLIC()5309 list<Absyn.ElementItem> items; 5310 5311 case Absyn.PUBLIC() 5312 5312 algorithm 5313 5313 (items, outArg, outContinue) := … … 5318 5318 (); 5319 5319 5320 case PROTECTED()5320 case Absyn.PROTECTED() 5321 5321 algorithm 5322 5322 (items, outArg, outContinue) := … … 5332 5332 5333 5333 protected function traverseElementItemComponents<ArgT> 5334 input ElementItem inItem;5334 input Absyn.ElementItem inItem; 5335 5335 input FuncType inFunc; 5336 5336 input ArgT inArg; 5337 output ElementItem outItem;5337 output Absyn.ElementItem outItem; 5338 5338 output ArgT outArg; 5339 5339 output Boolean outContinue; 5340 5340 5341 5341 partial function FuncType 5342 input list< ComponentItem> inComponents;5342 input list<Absyn.ComponentItem> inComponents; 5343 5343 input ArgT inArg; 5344 output list< ComponentItem> outComponents;5344 output list<Absyn.ComponentItem> outComponents; 5345 5345 output ArgT outArg; 5346 5346 output Boolean outContinue; … … 5349 5349 (outItem, outArg, outContinue) := match(inItem) 5350 5350 local 5351 Element elem;5352 5353 case ELEMENTITEM()5351 Absyn.Element elem; 5352 5353 case Absyn.ELEMENTITEM() 5354 5354 algorithm 5355 5355 (elem, outArg, outContinue) := traverseElementComponents(inItem.element, 5356 5356 inFunc, inArg); 5357 outItem := if referenceEq(elem, inItem.element) then inItem else ELEMENTITEM(elem);5357 outItem := if referenceEq(elem, inItem.element) then inItem else Absyn.ELEMENTITEM(elem); 5358 5358 then 5359 5359 (outItem, outArg, outContinue); … … 5364 5364 5365 5365 protected function traverseElementComponents<ArgT> 5366 input Element inElement;5366 input Absyn.Element inElement; 5367 5367 input FuncType inFunc; 5368 5368 input ArgT inArg; 5369 output Element outElement = inElement;5369 output Absyn.Element outElement = inElement; 5370 5370 output ArgT outArg; 5371 5371 output Boolean outContinue; 5372 5372 5373 5373 partial function FuncType 5374 input list< ComponentItem> inComponents;5374 input list<Absyn.ComponentItem> inComponents; 5375 5375 input ArgT inArg; 5376 output list< ComponentItem> outComponents;5376 output list<Absyn.ComponentItem> outComponents; 5377 5377 output ArgT outArg; 5378 5378 output Boolean outContinue; … … 5381 5381 (outElement, outArg, outContinue) := match(outElement) 5382 5382 local 5383 ElementSpec spec;5384 5385 case ELEMENT()5383 Absyn.ElementSpec spec; 5384 5385 case Absyn.ELEMENT() 5386 5386 algorithm 5387 5387 (spec, outArg, outContinue) := traverseElementSpecComponents( … … 5399 5399 5400 5400 protected function traverseElementSpecComponents<ArgT> 5401 input ElementSpec inSpec;5401 input Absyn.ElementSpec inSpec; 5402 5402 input FuncType inFunc; 5403 5403 input ArgT inArg; 5404 output ElementSpec outSpec = inSpec;5404 output Absyn.ElementSpec outSpec = inSpec; 5405 5405 output ArgT outArg; 5406 5406 output Boolean outContinue; 5407 5407 5408 5408 partial function FuncType 5409 input list< ComponentItem> inComponents;5409 input list<Absyn.ComponentItem> inComponents; 5410 5410 input ArgT inArg; 5411 output list< ComponentItem> outComponents;5411 output list<Absyn.ComponentItem> outComponents; 5412 5412 output ArgT outArg; 5413 5413 output Boolean outContinue; … … 5416 5416 (outSpec, outArg, outContinue) := match(outSpec) 5417 5417 local 5418 Class cls;5419 list< ComponentItem> comps;5420 5421 case COMPONENTS()5418 Absyn.Class cls; 5419 list<Absyn.ComponentItem> comps; 5420 5421 case Absyn.COMPONENTS() 5422 5422 algorithm 5423 5423 (comps, outArg, outContinue) := inFunc(outSpec.components, inArg); … … 5433 5433 5434 5434 protected function traverseClassDef<ArgT> 5435 input ClassDef inClassDef;5435 input Absyn.ClassDef inClassDef; 5436 5436 input FuncType inFunc; 5437 5437 input ArgT inArg; 5438 output ClassDef outClassDef = inClassDef;5438 output Absyn.ClassDef outClassDef = inClassDef; 5439 5439 output ArgT outArg = inArg; 5440 5440 output Boolean outContinue = true; 5441 5441 5442 5442 partial function FuncType 5443 input ClassPart inPart;5443 input Absyn.ClassPart inPart; 5444 5444 input ArgT inArg; 5445 output ClassPart outPart;5445 output Absyn.ClassPart outPart; 5446 5446 output ArgT outArg; 5447 5447 output Boolean outContinue; … … 5450 5450 _ := match(outClassDef) 5451 5451 local 5452 list< ClassPart> parts;5453 5454 case PARTS()5452 list<Absyn.ClassPart> parts; 5453 5454 case Absyn.PARTS() 5455 5455 algorithm 5456 5456 (parts, outArg, outContinue) := … … 5460 5460 (); 5461 5461 5462 case CLASS_EXTENDS()5462 case Absyn.CLASS_EXTENDS() 5463 5463 algorithm 5464 5464 (parts, outArg, outContinue) := … … 5473 5473 5474 5474 public function isEmptyMod 5475 input Modification inMod;5475 input Absyn.Modification inMod; 5476 5476 output Boolean outIsEmpty; 5477 5477 algorithm 5478 5478 outIsEmpty := match inMod 5479 case CLASSMOD({},NOMOD()) then true;5480 case CLASSMOD({}, EQMOD(exp =TUPLE(expressions = {}))) then true;5479 case Absyn.CLASSMOD({}, Absyn.NOMOD()) then true; 5480 case Absyn.CLASSMOD({}, Absyn.EQMOD(exp = Absyn.TUPLE(expressions = {}))) then true; 5481 5481 else false; 5482 5482 end match; … … 5484 5484 5485 5485 public function isEmptySubMod 5486 input ElementArg inSubMod;5486 input Absyn.ElementArg inSubMod; 5487 5487 output Boolean outIsEmpty; 5488 5488 algorithm 5489 5489 outIsEmpty := match inSubMod 5490 5490 local 5491 Modification mod;5492 5493 case MODIFICATION(modification = NONE()) then true;5494 case MODIFICATION(modification = SOME(mod)) then isEmptyMod(mod);5491 Absyn.Modification mod; 5492 5493 case Absyn.MODIFICATION(modification = NONE()) then true; 5494 case Absyn.MODIFICATION(modification = SOME(mod)) then isEmptyMod(mod); 5495 5495 end match; 5496 5496 end isEmptySubMod; 5497 5497 5498 5498 public function elementArgName 5499 input ElementArg inArg;5500 output Path outName;5499 input Absyn.ElementArg inArg; 5500 output Absyn.Path outName; 5501 5501 algorithm 5502 5502 outName := match(inArg) 5503 5503 local 5504 ElementSpec e;5505 case MODIFICATION(path = outName) then outName;5506 case REDECLARATION(elementSpec = e) then makeIdentPathFromString(elementSpecName(e));5504 Absyn.ElementSpec e; 5505 case Absyn.MODIFICATION(path = outName) then outName; 5506 case Absyn.REDECLARATION(elementSpec = e) then makeIdentPathFromString(elementSpecName(e)); 5507 5507 end match; 5508 5508 end elementArgName; 5509 5509 5510 5510 public function elementArgEqualName 5511 input ElementArg inArg1;5512 input ElementArg inArg2;5511 input Absyn.ElementArg inArg1; 5512 input Absyn.ElementArg inArg2; 5513 5513 output Boolean outEqual; 5514 5514 protected 5515 Path name1, name2;5515 Absyn.Path name1, name2; 5516 5516 algorithm 5517 5517 outEqual := match(inArg1, inArg2) 5518 case ( MODIFICATION(path = name1),MODIFICATION(path = name2))5518 case (Absyn.MODIFICATION(path = name1), Absyn.MODIFICATION(path = name2)) 5519 5519 then pathEqual(name1, name2); 5520 5520 … … 5524 5524 5525 5525 public function optMsg 5526 "Creates a Msg based on a boolean value."5526 "Creates a Absyn.Msg based on a boolean value." 5527 5527 input Boolean inShowMessage; 5528 5528 input SourceInfo inInfo; 5529 output Msg outMsg;5530 algorithm 5531 outMsg := if inShowMessage then MSG(inInfo) elseNO_MSG();5529 output Absyn.Msg outMsg; 5530 algorithm 5531 outMsg := if inShowMessage then Absyn.MSG(inInfo) else Absyn.NO_MSG(); 5532 5532 annotation(__OpenModelica_EarlyInline = true); 5533 5533 end optMsg; 5534 5534 5535 5535 public function makeSubscript 5536 input Exp inExp;5537 output Subscript outSubscript;5538 algorithm 5539 outSubscript := SUBSCRIPT(inExp);5536 input Absyn.Exp inExp; 5537 output Absyn.Subscript outSubscript; 5538 algorithm 5539 outSubscript := Absyn.SUBSCRIPT(inExp); 5540 5540 end makeSubscript; 5541 5541 5542 5542 public function crefExplode 5543 5543 "Splits a cref into parts." 5544 input ComponentRef inCref;5545 input list< ComponentRef> inAccum = {};5546 output list< ComponentRef> outCrefParts;5544 input Absyn.ComponentRef inCref; 5545 input list<Absyn.ComponentRef> inAccum = {}; 5546 output list<Absyn.ComponentRef> outCrefParts; 5547 5547 algorithm 5548 5548 outCrefParts := match inCref 5549 case CREF_QUAL() then crefExplode(inCref.componentRef, crefFirstCref(inCref) :: inAccum);5550 case CREF_FULLYQUALIFIED() then crefExplode(inCref.componentRef, inAccum);5549 case Absyn.CREF_QUAL() then crefExplode(inCref.componentRef, crefFirstCref(inCref) :: inAccum); 5550 case Absyn.CREF_FULLYQUALIFIED() then crefExplode(inCref.componentRef, inAccum); 5551 5551 else listReverse(inCref :: inAccum); 5552 5552 end match; … … 5556 5556 "Calls the given function on each subexpression (non-recursively) of the given 5557 5557 expression, sending in the extra argument to each call." 5558 input Exp inExp;5558 input Absyn.Exp inExp; 5559 5559 input ArgT inArg; 5560 5560 input FuncT inFunc; 5561 output Exp outExp = inExp;5561 output Absyn.Exp outExp = inExp; 5562 5562 5563 5563 partial function FuncT 5564 input Exp inExp;5564 input Absyn.Exp inExp; 5565 5565 input ArgT inArg; 5566 output Exp outExp;5566 output Absyn.Exp outExp; 5567 5567 end FuncT; 5568 5568 algorithm 5569 5569 _ := match outExp 5570 5570 local 5571 Exp e1, e2;5572 5573 case BINARY()5571 Absyn.Exp e1, e2; 5572 5573 case Absyn.BINARY() 5574 5574 algorithm 5575 5575 outExp.exp1 := inFunc(outExp.exp1, inArg); … … 5578 5578 (); 5579 5579 5580 case UNARY()5580 case Absyn.UNARY() 5581 5581 algorithm 5582 5582 outExp.exp := inFunc(outExp.exp, inArg); … … 5584 5584 (); 5585 5585 5586 case LBINARY()5586 case Absyn.LBINARY() 5587 5587 algorithm 5588 5588 outExp.exp1 := inFunc(outExp.exp1, inArg); … … 5591 5591 (); 5592 5592 5593 case LUNARY()5593 case Absyn.LUNARY() 5594 5594 algorithm 5595 5595 outExp.exp := inFunc(outExp.exp, inArg); … … 5597 5597 (); 5598 5598 5599 case RELATION()5599 case Absyn.RELATION() 5600 5600 algorithm 5601 5601 outExp.exp1 := inFunc(outExp.exp1, inArg); … … 5604 5604 (); 5605 5605 5606 case IFEXP()5606 case Absyn.IFEXP() 5607 5607 algorithm 5608 5608 outExp.ifExp := inFunc(outExp.ifExp, inArg); … … 5614 5614 (); 5615 5615 5616 case CALL()5616 case Absyn.CALL() 5617 5617 algorithm 5618 5618 outExp.functionArgs := traverseExpShallowFuncArgs(outExp.functionArgs, … … 5621 5621 (); 5622 5622 5623 case PARTEVALFUNCTION()5623 case Absyn.PARTEVALFUNCTION() 5624 5624 algorithm 5625 5625 outExp.functionArgs := traverseExpShallowFuncArgs(outExp.functionArgs, … … 5628 5628 (); 5629 5629 5630 case A RRAY()5630 case Absyn.ARRAY() 5631 5631 algorithm 5632 5632 outExp.arrayExp := list(inFunc(e, inArg) for e in outExp.arrayExp); … … 5634 5634 (); 5635 5635 5636 case MATRIX()5636 case Absyn.MATRIX() 5637 5637 algorithm 5638 5638 outExp.matrix := list(list(inFunc(e, inArg) for e in lst) for lst in … … 5641 5641 (); 5642 5642 5643 case RANGE()5643 case Absyn.RANGE() 5644 5644 algorithm 5645 5645 outExp.start := inFunc(outExp.start, inArg); … … 5649 5649 (); 5650 5650 5651 case TUPLE()5651 case Absyn.TUPLE() 5652 5652 algorithm 5653 5653 outExp.expressions := list(inFunc(e, inArg) for e in outExp.expressions); … … 5655 5655 (); 5656 5656 5657 case A S()5657 case Absyn.AS() 5658 5658 algorithm 5659 5659 outExp.exp := inFunc(outExp.exp, inArg); … … 5661 5661 (); 5662 5662 5663 case CONS()5663 case Absyn.CONS() 5664 5664 algorithm 5665 5665 outExp.head := inFunc(outExp.head, inArg); … … 5668 5668 (); 5669 5669 5670 case LIST()5670 case Absyn.LIST() 5671 5671 algorithm 5672 5672 outExp.exps := list(inFunc(e, inArg) for e in outExp.exps); … … 5674 5674 (); 5675 5675 5676 case DOT()5676 case Absyn.DOT() 5677 5677 algorithm 5678 5678 outExp.exp := inFunc(outExp.exp, inArg); … … 5686 5686 5687 5687 protected function traverseExpShallowFuncArgs<ArgT> 5688 input FunctionArgs inArgs;5688 input Absyn.FunctionArgs inArgs; 5689 5689 input ArgT inArg; 5690 5690 input FuncT inFunc; 5691 output FunctionArgs outArgs = inArgs;5691 output Absyn.FunctionArgs outArgs = inArgs; 5692 5692 5693 5693 partial function FuncT 5694 input Exp inExp;5694 input Absyn.Exp inExp; 5695 5695 input ArgT inArg; 5696 output Exp outExp;5696 output Absyn.Exp outExp; 5697 5697 end FuncT; 5698 5698 algorithm 5699 5699 outArgs := match outArgs 5700 case FUNCTIONARGS()5700 case Absyn.FUNCTIONARGS() 5701 5701 algorithm 5702 5702 outArgs.args := list(inFunc(arg, inArg) for arg in outArgs.args); … … 5704 5704 outArgs; 5705 5705 5706 case FOR_ITER_FARG()5706 case Absyn.FOR_ITER_FARG() 5707 5707 algorithm 5708 5708 outArgs.exp := inFunc(outArgs.exp, inArg); … … 5716 5716 5717 5717 protected function traverseExpShallowIterator<ArgT> 5718 input ForIterator inIterator;5718 input Absyn.ForIterator inIterator; 5719 5719 input ArgT inArg; 5720 5720 input FuncT inFunc; 5721 output ForIterator outIterator;5721 output Absyn.ForIterator outIterator; 5722 5722 5723 5723 partial function FuncT 5724 input Exp inExp;5724 input Absyn.Exp inExp; 5725 5725 input ArgT inArg; 5726 output Exp outExp;5726 output Absyn.Exp outExp; 5727 5727 end FuncT; 5728 5728 protected 5729 5729 String name; 5730 Option< Exp> guard_exp, range_exp;5731 algorithm 5732 ITERATOR(name, guard_exp, range_exp) := inIterator;5730 Option<Absyn.Exp> guard_exp, range_exp; 5731 algorithm 5732 Absyn.ITERATOR(name, guard_exp, range_exp) := inIterator; 5733 5733 guard_exp := Util.applyOption1(guard_exp, inFunc, inArg); 5734 5734 range_exp := Util.applyOption1(range_exp, inFunc, inArg); 5735 outIterator := ITERATOR(name, guard_exp, range_exp);5735 outIterator := Absyn.ITERATOR(name, guard_exp, range_exp); 5736 5736 end traverseExpShallowIterator; 5737 5737 5738 5738 public function isElementItemClass 5739 input ElementItem inElement;5739 input Absyn.ElementItem inElement; 5740 5740 output Boolean outIsClass; 5741 5741 algorithm 5742 5742 outIsClass := match inElement 5743 case ELEMENTITEM(element = ELEMENT(specification =CLASSDEF())) then true;5743 case Absyn.ELEMENTITEM(element = Absyn.ELEMENT(specification = Absyn.CLASSDEF())) then true; 5744 5744 else false; 5745 5745 end match; … … 5747 5747 5748 5748 public function isElementItem 5749 input ElementItem inElement;5749 input Absyn.ElementItem inElement; 5750 5750 output Boolean outIsClass; 5751 5751 algorithm 5752 5752 outIsClass := match inElement 5753 case ELEMENTITEM() then true;5753 case Absyn.ELEMENTITEM() then true; 5754 5754 else false; 5755 5755 end match; … … 5757 5757 5758 5758 public function isAlgorithmItem 5759 input A lgorithmItem inAlg;5759 input Absyn.AlgorithmItem inAlg; 5760 5760 output Boolean outIsClass; 5761 5761 algorithm 5762 5762 outIsClass := match inAlg 5763 case A LGORITHMITEM() then true;5763 case Absyn.ALGORITHMITEM() then true; 5764 5764 else false; 5765 5765 end match; … … 5768 5768 public function isElementItemClassNamed 5769 5769 input String inName; 5770 input ElementItem inElement;5770 input Absyn.ElementItem inElement; 5771 5771 output Boolean outIsNamed; 5772 5772 algorithm … … 5775 5775 String name; 5776 5776 5777 case ELEMENTITEM(element = ELEMENT(specification =CLASSDEF(5778 class_ = CLASS(name = name)))) then name == inName;5777 case Absyn.ELEMENTITEM(element = Absyn.ELEMENT(specification = Absyn.CLASSDEF( 5778 class_ = Absyn.CLASS(name = name)))) then name == inName; 5779 5779 else false; 5780 5780 end match; … … 5782 5782 5783 5783 public function isEmptyClassPart 5784 input ClassPart inClassPart;5784 input Absyn.ClassPart inClassPart; 5785 5785 output Boolean outIsEmpty; 5786 5786 algorithm 5787 5787 outIsEmpty := match inClassPart 5788 case PUBLIC(contents = {}) then true;5789 case PROTECTED(contents = {}) then true;5790 case CONSTRAINTS(contents = {}) then true;5791 case EQUATIONS(contents = {}) then true;5792 case INITIALEQUATIONS(contents = {}) then true;5793 case A LGORITHMS(contents = {}) then true;5794 case INITIALALGORITHMS(contents = {}) then true;5788 case Absyn.PUBLIC(contents = {}) then true; 5789 case Absyn.PROTECTED(contents = {}) then true; 5790 case Absyn.CONSTRAINTS(contents = {}) then true; 5791 case Absyn.EQUATIONS(contents = {}) then true; 5792 case Absyn.INITIALEQUATIONS(contents = {}) then true; 5793 case Absyn.ALGORITHMS(contents = {}) then true; 5794 case Absyn.INITIALALGORITHMS(contents = {}) then true; 5795 5795 else false; 5796 5796 end match; … … 5805 5805 end if; 5806 5806 b := match e 5807 case INTEGER() then true;5808 case REAL() then true;5809 case STRING() then true;5810 case BOOL() then true;5811 case BINARY() then true;5812 case UNARY() then true;5813 case LBINARY() then true;5814 case LUNARY() then true;5815 case RELATION() then true;5816 case IFEXP() then true;5817 // case CREF(CREF_FULLYQUALIFIED()) then true;5818 case CALL(function_=CREF_FULLYQUALIFIED()) then true;5819 case PARTEVALFUNCTION(function_=CREF_FULLYQUALIFIED()) then true;5820 case A RRAY() then true;5821 case MATRIX() then true;5822 case RANGE() then true;5823 case CONS() then true;5824 case LIST() then true;5807 case Absyn.INTEGER() then true; 5808 case Absyn.REAL() then true; 5809 case Absyn.STRING() then true; 5810 case Absyn.BOOL() then true; 5811 case Absyn.BINARY() then true; 5812 case Absyn.UNARY() then true; 5813 case Absyn.LBINARY() then true; 5814 case Absyn.LUNARY() then true; 5815 case Absyn.RELATION() then true; 5816 case Absyn.IFEXP() then true; 5817 // case Absyn.CREF(Absyn.CREF_FULLYQUALIFIED()) then true; 5818 case Absyn.CALL(function_=Absyn.CREF_FULLYQUALIFIED()) then true; 5819 case Absyn.PARTEVALFUNCTION(function_=Absyn.CREF_FULLYQUALIFIED()) then true; 5820 case Absyn.ARRAY() then true; 5821 case Absyn.MATRIX() then true; 5822 case Absyn.RANGE() then true; 5823 case Absyn.CONS() then true; 5824 case Absyn.LIST() then true; 5825 5825 else false; 5826 5826 end match; … … 5829 5829 function pathPartCount 5830 5830 "Returns the number of parts a path consists of, e.g. A.B.C gives 3." 5831 input Path path;5831 input Absyn.Path path; 5832 5832 input Integer partsAccum = 0; 5833 5833 output Integer parts; 5834 5834 algorithm 5835 5835 parts := match path 5836 case Path.IDENT() then partsAccum + 1;5837 case Path.QUALIFIED() then pathPartCount(path.path, partsAccum + 1);5838 case Path.FULLYQUALIFIED() then pathPartCount(path.path, partsAccum);5836 case Absyn.IDENT() then partsAccum + 1; 5837 case Absyn.QUALIFIED() then pathPartCount(path.path, partsAccum + 1); 5838 case Absyn.FULLYQUALIFIED() then pathPartCount(path.path, partsAccum); 5839 5839 end match; 5840 5840 end pathPartCount; 5841 5841 5842 5842 public function getAnnotationsFromConstraintClass 5843 input Option< ConstrainClass> inCC;5844 output list< ElementArg> outElArgLst;5843 input Option<Absyn.ConstrainClass> inCC; 5844 output list<Absyn.ElementArg> outElArgLst; 5845 5845 algorithm 5846 5846 outElArgLst := match(inCC) 5847 local list< ElementArg> elementArgs;5848 case SOME( CONSTRAINCLASS(comment = SOME(COMMENT(annotation_ = SOME(ANNOTATION(elementArgs))))))5847 local list<Absyn.ElementArg> elementArgs; 5848 case SOME(Absyn.CONSTRAINCLASS(comment = SOME(Absyn.COMMENT(annotation_ = SOME(Absyn.ANNOTATION(elementArgs)))))) 5849 5849 then elementArgs; 5850 5850 else {}; … … 5853 5853 5854 5854 public function getAnnotationsFromItems 5855 input list< ComponentItem> inComponentItems;5856 input list< ElementArg> ccAnnotations;5857 output list<list< ElementArg>> outLst = {};5855 input list<Absyn.ComponentItem> inComponentItems; 5856 input list<Absyn.ElementArg> ccAnnotations; 5857 output list<list<Absyn.ElementArg>> outLst = {}; 5858 5858 protected 5859 5859 list<Absyn.ElementArg> annotations; … … 5874 5874 5875 5875 public function stripGraphicsAndInteractionModification 5876 " This function strips out the `graphics\' modification from an ElementArg5876 " This function strips out the `graphics\' modification from an Absyn.ElementArg 5877 5877 list and return two lists, one with the other modifications and the 5878 5878 second with the `graphics\' modification" … … 6341 6341 public function getTypeSpecFromElementItemOpt 6342 6342 "@auhtor: johti 6343 Get the typespec path in an ElementItem if it has one"6343 Get the typespec path in an Absyn.ElementItem if it has one" 6344 6344 input Absyn.ElementItem inElementItem; 6345 6345 output Option<Absyn.TypeSpec> outTypeSpec; … … 6362 6362 public function getElementSpecificationFromElementItemOpt 6363 6363 "@auhtor: johti 6364 Get a ComponentItem from anElementItem if it has one"6364 Get a Absyn.ComponentItem from an Absyn.ElementItem if it has one" 6365 6365 input Absyn.ElementItem inElementItem; 6366 6366 output Option<Absyn.ElementSpec> outSpec; … … 6406 6406 public function getDirection 6407 6407 "@author johti 6408 Get the direction if one exists otherwise returns BIDIR()"6408 Get the direction if one exists otherwise returns Absyn.BIDIR()" 6409 6409 input Absyn.ElementItem elementItem; 6410 output Direction oDirection;6410 output Absyn.Direction oDirection; 6411 6411 algorithm 6412 6412 oDirection:= matchcontinue elementItem 6413 local Element element;6414 case ELEMENTITEM(element = element) then match element6415 local ElementSpec specification;6416 case ELEMENT(specification=specification) then match specification6417 local ElementAttributes attributes;6418 case COMPONENTS(attributes=attributes) then match attributes6419 local Direction direction;6420 case A TTR(direction=direction) then direction;6413 local Absyn.Element element; 6414 case Absyn.ELEMENTITEM(element = element) then match element 6415 local Absyn.ElementSpec specification; 6416 case Absyn.ELEMENT(specification=specification) then match specification 6417 local Absyn.ElementAttributes attributes; 6418 case Absyn.COMPONENTS(attributes=attributes) then match attributes 6419 local Absyn.Direction direction; 6420 case Absyn.ATTR(direction=direction) then direction; 6421 6421 end match; 6422 6422 end match; 6423 6423 end match; 6424 else BIDIR();6424 else Absyn.BIDIR(); 6425 6425 end matchcontinue; 6426 6426 end getDirection; … … 6432 6432 algorithm 6433 6433 res := match path 6434 case IDENT() then path.name == name;6434 case Absyn.IDENT() then path.name == name; 6435 6435 else false; 6436 6436 end match; … … 6444 6444 algorithm 6445 6445 b := match cls.restriction 6446 case R_UNIONTYPE(__) then true;6446 case Absyn.R_UNIONTYPE(__) then true; 6447 6447 else false; 6448 6448 end match; … … 6450 6450 6451 6451 public function traverseClassElements<ArgT> 6452 input Class inClass;6452 input Absyn.Class inClass; 6453 6453 input FuncType inFunc; 6454 6454 input ArgT inArg; 6455 output Class outClass = inClass;6455 output Absyn.Class outClass = inClass; 6456 6456 output ArgT outArg; 6457 6457 6458 6458 partial function FuncType 6459 input Element inElement;6459 input Absyn.Element inElement; 6460 6460 input ArgT inArg; 6461 output Element outElement;6461 output Absyn.Element outElement; 6462 6462 output ArgT outArg; 6463 6463 output Boolean outContinue; … … 6466 6466 outClass := match(outClass) 6467 6467 local 6468 ClassDef body;6469 6470 case CLASS()6468 Absyn.ClassDef body; 6469 6470 case Absyn.CLASS() 6471 6471 algorithm 6472 6472 (body, outArg) := traverseClassDef(outClass.body, … … 6480 6480 6481 6481 protected function traverseClassPartElements<ArgT> 6482 input ClassPart inClassPart;6482 input Absyn.ClassPart inClassPart; 6483 6483 input FuncType inFunc; 6484 6484 input ArgT inArg; 6485 output ClassPart outClassPart = inClassPart;6485 output Absyn.ClassPart outClassPart = inClassPart; 6486 6486 output ArgT outArg = inArg; 6487 6487 output Boolean outContinue = true; 6488 6488 6489 6489 partial function FuncType 6490 input Element inElement;6490 input Absyn.Element inElement; 6491 6491 input ArgT inArg; 6492 output Element outElement;6492 output Absyn.Element outElement; 6493 6493 output ArgT outArg; 6494 6494 output Boolean outContinue; … … 6497 6497 _ := match(outClassPart) 6498 6498 local 6499 list< ElementItem> items;6500 6501 case PUBLIC()6499 list<Absyn.ElementItem> items; 6500 6501 case Absyn.PUBLIC() 6502 6502 algorithm 6503 6503 (items, outArg, outContinue) := … … 6508 6508 (); 6509 6509 6510 case PROTECTED()6510 case Absyn.PROTECTED() 6511 6511 algorithm 6512 6512 (items, outArg, outContinue) := … … 6522 6522 6523 6523 protected function traverseElementItem<ArgT> 6524 input ElementItem inItem;6524 input Absyn.ElementItem inItem; 6525 6525 input FuncType inFunc; 6526 6526 input ArgT inArg; 6527 output ElementItem outItem;6527 output Absyn.ElementItem outItem; 6528 6528 output ArgT outArg; 6529 6529 output Boolean outContinue; 6530 6530 6531 6531 partial function FuncType 6532 input Element inElement;6532 input Absyn.Element inElement; 6533 6533 input ArgT inArg; 6534 output Element outElement;6534 output Absyn.Element outElement; 6535 6535 output ArgT outArg; 6536 6536 output Boolean outContinue; … … 6539 6539 (outItem, outArg, outContinue) := match(inItem) 6540 6540 local 6541 Element elem;6542 6543 case ELEMENTITEM()6541 Absyn.Element elem; 6542 6543 case Absyn.ELEMENTITEM() 6544 6544 algorithm 6545 6545 (elem, outArg, outContinue) := inFunc(inItem.element, inArg); 6546 outItem := if referenceEq(elem, inItem.element) then inItem else ELEMENTITEM(elem);6546 outItem := if referenceEq(elem, inItem.element) then inItem else Absyn.ELEMENTITEM(elem); 6547 6547 then 6548 6548 (outItem, outArg, outContinue); … … 6553 6553 6554 6554 public function elementSpec 6555 input Element el;6556 output ElementSpec elSpec;6557 algorithm 6558 ELEMENT(specification = elSpec) := el;6555 input Absyn.Element el; 6556 output Absyn.ElementSpec elSpec; 6557 algorithm 6558 Absyn.ELEMENT(specification = elSpec) := el; 6559 6559 end elementSpec; 6560 6560 6561 6561 public function isClassOrComponentElementSpec 6562 "The ElementSpec type contains the name of the element, and this function6562 "The Absyn.ElementSpec type contains the name of the element, and this function 6563 6563 extracts this name." 6564 input ElementSpec inElementSpec;6564 input Absyn.ElementSpec inElementSpec; 6565 6565 output Boolean yes = false; 6566 6566 algorithm 6567 6567 yes := match (inElementSpec) 6568 case CLASSDEF(class_ =CLASS()) then true;6569 case COMPONENTS(components = {COMPONENTITEM()}) then true;6568 case Absyn.CLASSDEF(class_ = Absyn.CLASS()) then true; 6569 case Absyn.COMPONENTS(components = {Absyn.COMPONENTITEM()}) then true; 6570 6570 else false; 6571 6571 end match;
Note: See TracChangeset
for help on using the changeset viewer.