/
DAEUtil.mo
5139 lines (4731 loc) · 176 KB
/
DAEUtil.mo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-CurrentYear, Linköping University,
* Department of Computer and Information Science,
* SE-58183 Linköping, Sweden.
*
* All rights reserved.
*
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3
* AND THIS OSMC PUBLIC LICENSE (OSMC-PL).
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S
* ACCEPTANCE OF THE OSMC PUBLIC LICENSE.
*
* The OpenModelica software and the Open Source Modelica
* Consortium (OSMC) Public License (OSMC-PL) are obtained
* from Linköping University, either from the above address,
* from the URLs: http://www.ida.liu.se/projects/OpenModelica or
* http://www.openmodelica.org, and in the OpenModelica distribution.
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
*
* This program is distributed WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS
* OF OSMC-PL.
*
* See the full OSMC Public License conditions for more details.
*
*/
package DAEUtil
" file: DAEUtil.mo
package: DAE
description: DAE management and output
RCS: $Id$
This module exports some helper functions to the DAE AST."
public import Absyn;
public import ClassInf;
public import DAE;
public import Env;
public import SCode;
public import Values;
public constant DAE.AvlTree emptyFuncTree = DAE.AVLTREENODE(NONE(),0,NONE(),NONE());
public constant DAE.DAElist emptyDae = DAE.DAE({},emptyFuncTree);
public function constStr "return the DAE.Const as a string. (VAR|PARAM|CONST)
Used for debugging."
input DAE.Const const;
output String str;
algorithm
str := matchcontinue(const)
case(DAE.C_VAR()) then "VAR";
case(DAE.C_PARAM()) then "PARAM";
case(DAE.C_CONST()) then "CONST";
end matchcontinue;
end constStr;
public function expTypeSimple "returns true if type is simple type"
input DAE.ExpType tp;
output Boolean isSimple;
algorithm
isSimple := matchcontinue(tp)
case(DAE.ET_REAL()) then true;
case(DAE.ET_INT()) then true;
case(DAE.ET_STRING()) then true;
case(DAE.ET_BOOL()) then true;
case(DAE.ET_ENUMERATION(path=_)) then true;
case(_) then false;
end matchcontinue;
end expTypeSimple;
public function expTypeElementType "returns the element type of an array"
input DAE.ExpType tp;
output DAE.ExpType eltTp;
algorithm
eltTp := matchcontinue(tp)
case(DAE.ET_ARRAY(ty=tp)) then expTypeElementType(tp);
case(tp) then tp;
end matchcontinue;
end expTypeElementType;
public function expTypeComplex "returns true if type is complex type"
input DAE.ExpType tp;
output Boolean isComplex;
algorithm
isComplex := matchcontinue(tp)
case(DAE.ET_COMPLEX(name=_)) then true;
case(_) then false;
end matchcontinue;
end expTypeComplex;
public function expTypeArray "returns true if type is array type
Alternative names: isArrayType, isExpTypeArray
"
input DAE.ExpType tp;
output Boolean isArray;
algorithm
isArray := matchcontinue(tp)
case(DAE.ET_ARRAY(ty=_)) then true;
case(_) then false;
end matchcontinue;
end expTypeArray;
public function expTypeArrayDimensions "returns the array dimensions of an ExpType"
input DAE.ExpType tp;
output list<Integer> dims;
algorithm
dims := matchcontinue(tp)
local list<Option<Integer>> optDims;
case(DAE.ET_ARRAY(arrayDimensions=optDims)) equation
dims = Util.listMap(optDims,Util.getOption);
then dims;
end matchcontinue;
end expTypeArrayDimensions;
public function derivativeOrder "
Function to sort derivatives.
Used for Util.sort"
input tuple<Integer,DAE.derivativeCond> e1,e2; //greaterThanFunc
output Boolean b;
Integer i1,i2;
algorithm
b := matchcontinue(e1,e2)
case((i1,_),(i2,_))
then Util.isIntGreater(i1,i2);
end matchcontinue;
end derivativeOrder;
public function getDerivativePaths " collects all paths representing derivative functions for a list of FunctionDefinition's"
input list<DAE.FunctionDefinition> funcDefs;
output list<Absyn.Path> paths;
algorithm
paths := matchcontinue(funcDefs)
local list<Absyn.Path> pLst1,pLst2;
Absyn.Path p1,p2;
case({}) then {};
case(DAE.FUNCTION_DER_MAPPER(derivativeFunction=p1,defaultDerivative=SOME(p2),lowerOrderDerivatives=pLst1)::funcDefs) equation
pLst2 = getDerivativePaths(funcDefs);
paths = Util.listUnion(p1::p2::pLst1,pLst2);
then paths;
case(DAE.FUNCTION_DER_MAPPER(derivativeFunction=p1,defaultDerivative=NONE,lowerOrderDerivatives=pLst1)::funcDefs) equation
pLst2 = getDerivativePaths(funcDefs);
paths = Util.listUnion(p1::pLst1,pLst2);
then paths;
case(_::funcDefs) then getDerivativePaths(funcDefs);
end matchcontinue;
end getDerivativePaths;
public function addEquationBoundString "
Set the optional equationBound value
"
input DAE.Exp bindExp;
input Option<DAE.VariableAttributes> attr;
output Option<DAE.VariableAttributes> oattr;
algorithm oattr :=
matchcontinue (bindExp,attr)
local
Option<DAE.Exp> e1,e2,e3,e4,e5,e6;
tuple<Option<DAE.Exp>, Option<DAE.Exp>> min;
Option<DAE.StateSelect> sSelectOption,sSelectOption2;
Option<Boolean> ip,fn;
String s;
case (bindExp,SOME(DAE.VAR_ATTR_REAL(e1,e2,e3,min,e4,e5,e6,sSelectOption,_,ip,fn)))
then (SOME(DAE.VAR_ATTR_REAL(e1,e2,e3,min,e4,e5,e6,sSelectOption,SOME(bindExp),ip,fn)));
case (bindExp,SOME(DAE.VAR_ATTR_INT(e1,min,e2,e3,_,ip,fn)))
then SOME(DAE.VAR_ATTR_INT(e1,min,e2,e3,SOME(bindExp),ip,fn));
case (bindExp,SOME(DAE.VAR_ATTR_BOOL(e1,e2,e3,_,ip,fn)))
then SOME(DAE.VAR_ATTR_BOOL(e1,e2,e3,SOME(bindExp),ip,fn));
case (bindExp,SOME(DAE.VAR_ATTR_STRING(e1,e2,_,ip,fn)))
then SOME(DAE.VAR_ATTR_STRING(e1,e2,SOME(bindExp),ip,fn));
case (bindExp,SOME(DAE.VAR_ATTR_ENUMERATION(e1,min,e2,e3,_,ip,fn)))
then SOME(DAE.VAR_ATTR_ENUMERATION(e1,min,e2,e3,SOME(bindExp),ip,fn));
case(_,_) equation print("-failure in DAEUtil.addEquationBoundString\n"); then fail();
end matchcontinue;
end addEquationBoundString;
public function getClassList "get list of classes from Var"
input DAE.Element v;
output list<Absyn.Path> lst;
algorithm
lst := matchcontinue(v)
case DAE.VAR(source = DAE.SOURCE(typeLst=lst)) then lst;
case _ then {};
end matchcontinue;
end getClassList;
public function getBoundStartEquation "
Returned bound equation
"
input DAE.VariableAttributes attr;
output DAE.Exp oe;
algorithm oe := matchcontinue(attr)
local DAE.Exp beq;
case (DAE.VAR_ATTR_REAL(equationBound = SOME(beq))) then beq;
case (DAE.VAR_ATTR_INT(equationBound = SOME(beq))) then beq;
case (DAE.VAR_ATTR_BOOL(equationBound = SOME(beq))) then beq;
case (DAE.VAR_ATTR_ENUMERATION(equationBound = SOME(beq))) then beq;
end matchcontinue;
end getBoundStartEquation;
protected import Algorithm;
protected import Ceval;
protected import Debug;
protected import Error;
protected import Exp;
protected import ModUtil;
protected import RTOpts;
protected import System;
protected import Types;
protected import Util;
protected import DAEDump;
public function splitDAEIntoVarsAndEquations
"Splits the DAE into one with vars and no equations and algorithms
and another one which has all the equations and algorithms but no variables.
Note: the functions are copied to both dae's.
"
input DAE.DAElist inDae;
output DAE.DAElist outDaeNoEqAllVars;
output DAE.DAElist outDaeAllEqNoVars;
algorithm
(outDaeNoEqAllVars,outDaeAllEqNoVars) := matchcontinue(inDae)
local
DAE.Element v,e;
list<DAE.Element> elts,elts2,elts22,elts1,elts11,elts3,elts33;
String id;
DAE.ElementSource source "the origin of the element";
DAE.FunctionTree funcs,funcs1,funcs2;
case(DAE.DAE({},funcs)) then (DAE.DAE({},funcs),DAE.DAE({},funcs));
case(DAE.DAE((v as DAE.VAR(componentRef=_))::elts,funcs))
equation
(DAE.DAE(elts2,_),DAE.DAE(elts3,_)) = splitDAEIntoVarsAndEquations(DAE.DAE(elts,funcs));
then (DAE.DAE(v::elts2,funcs),DAE.DAE(elts3,funcs));
// adrpo: TODO! FIXME! a DAE.COMP SHOULD NOT EVER BE HERE!
case(DAE.DAE(DAE.COMP(id,elts1,source)::elts2,funcs))
equation
(DAE.DAE(elts11,_),DAE.DAE(elts3,_)) = splitDAEIntoVarsAndEquations(DAE.DAE(elts1,funcs));
(DAE.DAE(elts22,_),DAE.DAE(elts33,_)) = splitDAEIntoVarsAndEquations(DAE.DAE(elts2,funcs));
elts3 = listAppend(elts3,elts33);
then (DAE.DAE(DAE.COMP(id,elts11,source)::elts22,funcs),DAE.DAE(elts3,funcs));
case(DAE.DAE((e as DAE.EQUATION(exp=_))::elts2,funcs))
equation
(DAE.DAE(elts2,_),DAE.DAE(elts3,_)) = splitDAEIntoVarsAndEquations(DAE.DAE(elts2,funcs));
then (DAE.DAE(elts2,funcs),DAE.DAE(e::elts3,funcs));
case(DAE.DAE((e as DAE.EQUEQUATION(cr1=_))::elts,funcs))
equation
(DAE.DAE(elts2,_),DAE.DAE(elts3,_)) = splitDAEIntoVarsAndEquations(DAE.DAE(elts,funcs));
then (DAE.DAE(elts2,funcs),DAE.DAE(e::elts3,funcs));
case(DAE.DAE((e as DAE.INITIALEQUATION(exp1=_))::elts,funcs))
equation
(DAE.DAE(elts2,_),DAE.DAE(elts3,_)) = splitDAEIntoVarsAndEquations(DAE.DAE(elts,funcs));
then (DAE.DAE(elts2,funcs),DAE.DAE(e::elts3,funcs));
case(DAE.DAE((e as DAE.ARRAY_EQUATION(dimension=_))::elts,funcs))
equation
(DAE.DAE(elts2,_),DAE.DAE(elts3,_)) = splitDAEIntoVarsAndEquations(DAE.DAE(elts,funcs));
then (DAE.DAE(elts2,funcs),DAE.DAE(e::elts3,funcs));
case(DAE.DAE((e as DAE.INITIAL_ARRAY_EQUATION(dimension=_))::elts,funcs))
equation
(DAE.DAE(elts2,_),DAE.DAE(elts3,_)) = splitDAEIntoVarsAndEquations(DAE.DAE(elts,funcs));
then (DAE.DAE(elts2,funcs),DAE.DAE(e::elts3,funcs));
case(DAE.DAE((e as DAE.COMPLEX_EQUATION(lhs=_))::elts,funcs))
equation
(DAE.DAE(elts2,_),DAE.DAE(elts3,_)) = splitDAEIntoVarsAndEquations(DAE.DAE(elts,funcs));
then (DAE.DAE(elts2,funcs),DAE.DAE(e::elts3,funcs));
case(DAE.DAE((e as DAE.INITIAL_COMPLEX_EQUATION(lhs=_))::elts,funcs))
equation
(DAE.DAE(elts2,_),DAE.DAE(elts3,_)) = splitDAEIntoVarsAndEquations(DAE.DAE(elts,funcs));
then (DAE.DAE(elts2,funcs),DAE.DAE(e::elts3,funcs));
case(DAE.DAE((e as DAE.INITIALDEFINE(componentRef=_))::elts,funcs))
equation
(DAE.DAE(elts2,_),DAE.DAE(elts3,_)) = splitDAEIntoVarsAndEquations(DAE.DAE(elts,funcs));
then (DAE.DAE(elts2,funcs),DAE.DAE(e::elts3,funcs));
case(DAE.DAE((e as DAE.DEFINE(componentRef=_))::elts,funcs))
equation
(DAE.DAE(elts2,_),DAE.DAE(elts3,_)) = splitDAEIntoVarsAndEquations(DAE.DAE(elts,funcs));
then (DAE.DAE(elts2,funcs),DAE.DAE(e::elts3,funcs));
case(DAE.DAE((e as DAE.WHEN_EQUATION(condition=_))::elts,funcs))
equation
(DAE.DAE(elts2,_),DAE.DAE(elts3,_)) = splitDAEIntoVarsAndEquations(DAE.DAE(elts,funcs));
then (DAE.DAE(elts2,funcs),DAE.DAE(e::elts3,funcs));
case(DAE.DAE((e as DAE.IF_EQUATION(condition1=_))::elts,funcs))
equation
(DAE.DAE(elts2,_),DAE.DAE(elts3,_)) = splitDAEIntoVarsAndEquations(DAE.DAE(elts,funcs));
then (DAE.DAE(elts2,funcs),DAE.DAE(e::elts3,funcs));
case(DAE.DAE((e as DAE.INITIAL_IF_EQUATION(condition1=_))::elts,funcs))
equation
(DAE.DAE(elts2,_),DAE.DAE(elts3,_)) = splitDAEIntoVarsAndEquations(DAE.DAE(elts,funcs));
then (DAE.DAE(elts2,funcs),DAE.DAE(e::elts3,funcs));
case(DAE.DAE((e as DAE.ALGORITHM(algorithm_=_))::elts,funcs))
equation
(DAE.DAE(elts2,_),DAE.DAE(elts3,_)) = splitDAEIntoVarsAndEquations(DAE.DAE(elts,funcs));
then (DAE.DAE(elts2,funcs),DAE.DAE(e::elts3,funcs));
case(DAE.DAE((e as DAE.INITIALALGORITHM(algorithm_=_))::elts,funcs))
equation
(DAE.DAE(elts2,_),DAE.DAE(elts3,_)) = splitDAEIntoVarsAndEquations(DAE.DAE(elts,funcs));
then (DAE.DAE(elts2,funcs),DAE.DAE(e::elts3,funcs));
// adrpo: TODO! FIXME! why are function calls added to the non-equations DAE??
// PA: are these function CALLS? Do not think so. But they should anyway be in funcs..
case(DAE.DAE((e as DAE.FUNCTION(path=_))::elts,funcs))
equation
(DAE.DAE(elts2,_),DAE.DAE(elts3,_)) = splitDAEIntoVarsAndEquations(DAE.DAE(elts,funcs));
then (DAE.DAE(e::elts2,funcs),DAE.DAE(elts3,funcs));
// adrpo: TODO! FIXME! why are record constructor calls added to the non-equations DAE??
// PA: are these record constructo CALLS? Do not think so. But they should anyway be in funcs..
case(DAE.DAE((e as DAE.RECORD_CONSTRUCTOR(path=_))::elts,funcs))
equation
(DAE.DAE(elts2,_),DAE.DAE(elts3,_)) = splitDAEIntoVarsAndEquations(DAE.DAE(elts,funcs));
then (DAE.DAE(e::elts2,funcs),DAE.DAE(elts3,funcs));
// adrpo: TODO! FIXME! why are external object constructor calls added to the non-equations DAE??
// PA: are these external object constructor CALLS? Do not think so. But they should anyway be in funcs..
case(DAE.DAE((e as DAE.EXTOBJECTCLASS(path=_))::elts,funcs))
equation
(DAE.DAE(elts2,_),DAE.DAE(elts3,_)) = splitDAEIntoVarsAndEquations(DAE.DAE(elts,funcs));
then (DAE.DAE(e::elts2,funcs),DAE.DAE(elts3,funcs));
case(DAE.DAE((e as DAE.ASSERT(condition=_))::elts,funcs))
equation
(DAE.DAE(elts2,_),DAE.DAE(elts3,_)) = splitDAEIntoVarsAndEquations(DAE.DAE(elts,funcs));
then (DAE.DAE(elts2,funcs),DAE.DAE(e::elts3,funcs));
case(DAE.DAE((e as DAE.TERMINATE(message=_))::elts,funcs))
equation
(DAE.DAE(elts2,_),DAE.DAE(elts3,_)) = splitDAEIntoVarsAndEquations(DAE.DAE(elts,funcs));
then (DAE.DAE(elts2,funcs),DAE.DAE(e::elts3,funcs));
case(DAE.DAE((e as DAE.REINIT(componentRef=_))::elts,funcs))
equation
(DAE.DAE(elts2,_),DAE.DAE(elts3,_)) = splitDAEIntoVarsAndEquations(DAE.DAE(elts,funcs));
then (DAE.DAE(elts2,funcs),DAE.DAE(e::elts3,funcs));
// handle also NORETCALL! Connections.root(...)
case(DAE.DAE((e as DAE.NORETCALL(functionName=_))::elts,funcs))
equation
(DAE.DAE(elts2,_),DAE.DAE(elts3,_)) = splitDAEIntoVarsAndEquations(DAE.DAE(elts,funcs));
then (DAE.DAE(elts2,funcs),DAE.DAE(e::elts3,funcs));
case(DAE.DAE(e::elts,funcs))
equation
Debug.fprintln("failtrace", "- DAEUtil.splitDAEIntoVarsAndEquations failed on: " );
then fail();
end matchcontinue;
end splitDAEIntoVarsAndEquations;
public function removeVariables "Remove the variables in the list from the DAE"
input DAE.DAElist dae;
input list<DAE.ComponentRef> vars;
output DAE.DAElist outDae;
algorithm
// adrpo: TODO! FIXME! rather expensive function!
// implement this by walking dae once and check element with each var in the list
// instead of walking the dae once for each var.
// outDae := Util.listFold(vars,removeVariable,dae);
outDae := matchcontinue(dae, vars)
local
list<DAE.Element> elements;
DAE.FunctionTree functions;
case (DAE.DAE(elements, functions), vars)
equation
elements = removeVariablesFromElements(elements, vars);
then
DAE.DAE(elements, functions);
end matchcontinue;
end removeVariables;
protected function removeVariablesFromElements
"@author: adrpo
remove the variables that match for the element list"
input list<DAE.Element> inElements;
input list<DAE.ComponentRef> variableNames;
output list<DAE.Element> outElements;
algorithm
outElements := matchcontinue(inElements,variableNames)
local
DAE.ComponentRef cr;
list<DAE.Element> rest, els, elist;
DAE.Element e,v; String id;
DAE.ElementSource source "the origin of the element";
// empty case
case({},_) then {};
// variable present, remove it
case(DAE.VAR(componentRef = cr)::rest, variableNames)
equation
// variable is in the list! jump over it
_::_ = Util.listSelect1(variableNames, cr, Exp.crefEqual);
els = removeVariablesFromElements(rest, variableNames);
then
els;
// variable not present, keep it
case((v as DAE.VAR(componentRef = cr))::rest, variableNames)
equation
// variable NOT in the list! jump over it
{} = Util.listSelect1(variableNames, cr, Exp.crefEqual);
els = removeVariablesFromElements(rest, variableNames);
then
v::els;
// handle components
case(DAE.COMP(id,elist,source)::rest, variableNames)
equation
elist = removeVariablesFromElements(elist, variableNames);
els = removeVariablesFromElements(rest, variableNames);
then
DAE.COMP(id,elist,source)::els;
// anything else, just keep it
case(v::rest, variableNames)
equation
els = removeVariablesFromElements(rest, variableNames);
then
v::els;
end matchcontinue;
end removeVariablesFromElements;
protected function removeVariable "Remove the variable from the DAE"
input DAE.ComponentRef var;
input DAE.DAElist dae;
output DAE.DAElist outDae;
algorithm
outDae := matchcontinue(var,dae)
local
DAE.ComponentRef cr;
list<DAE.Element> elist,elist2;
DAE.Element e,v; String id;
DAE.ElementSource source "the origin of the element";
DAE.FunctionTree funcs;
case(var,DAE.DAE({},funcs)) then DAE.DAE({},funcs);
case(var,DAE.DAE((v as DAE.VAR(componentRef = cr))::elist,funcs))
equation
true = Exp.crefEqual(var,cr);
then DAE.DAE(elist,funcs);
case(var,DAE.DAE(DAE.COMP(id,elist,source)::elist2,funcs))
equation
DAE.DAE(elist,_) = removeVariable(var,DAE.DAE(elist,funcs));
DAE.DAE(elist2,_) = removeVariable(var,DAE.DAE(elist2,funcs));
then DAE.DAE(DAE.COMP(id,elist,source)::elist2,funcs);
case(var,DAE.DAE(e::elist,funcs))
equation
DAE.DAE(elist,_) = removeVariable(var,DAE.DAE(elist,funcs));
then DAE.DAE(e::elist,funcs);
end matchcontinue;
end removeVariable;
public function removeInnerAttrs "Remove the inner attribute of all vars in list"
input DAE.DAElist dae;
input list<DAE.ComponentRef> vars;
output DAE.DAElist outDae;
algorithm
outDae := Util.listFold(vars,removeInnerAttr,dae);
end removeInnerAttrs;
public function removeInnerAttr "Remove the inner attribute from variable in the DAE"
input DAE.ComponentRef var;
input DAE.DAElist dae;
output DAE.DAElist outDae;
algorithm
outDae := matchcontinue(var,dae)
local
DAE.ComponentRef cr,oldVar,newVar;
list<DAE.Element> elist,elist2,elist3;
DAE.Element e,v,u,o; String id;
DAE.ComponentRef cr; DAE.VarKind kind;
DAE.VarDirection dir; DAE.Type tp;
Option<DAE.Exp> bind; DAE.InstDims dim;
DAE.Flow flow_; list<Absyn.Path> cls;
Option<DAE.VariableAttributes> attr;
Option<SCode.Comment> cmt; Absyn.InnerOuter io,io2;
DAE.VarProtection prot; DAE.Stream st;
DAE.ElementSource source "the origin of the element";
DAE.FunctionTree funcs;
case(var,DAE.DAE({},funcs)) then DAE.DAE({},funcs);
/* When having an inner outer, we declare two variables on the same line.
Since we can not handle this with current instantiation procedure, we create temporary variables in the dae.
These are named uniqly and renamed later in "instClass"
*/
case(var,DAE.DAE(DAE.VAR(oldVar,kind,dir,prot,tp,bind,dim,flow_,st,source,attr,cmt,(io as Absyn.INNEROUTER()))::elist,funcs))
equation
true = compareUniquedVarWithNonUnique(var,oldVar);
newVar = nameInnerouterUniqueCref(oldVar);
o = DAE.VAR(oldVar,kind,dir,prot,tp,NONE,dim,flow_,st,source,attr,cmt,Absyn.OUTER()) "intact";
u = DAE.VAR(newVar,kind,dir,prot,tp,bind,dim,flow_,st,source,attr,cmt,Absyn.UNSPECIFIED()) " unique'ified";
elist3 = u::{o};
elist= listAppend(elist3,elist);
then
DAE.DAE(elist,funcs);
case(var,DAE.DAE(DAE.VAR(cr,kind,dir,prot,tp,bind,dim,flow_,st,source,attr,cmt,io)::elist,funcs))
equation
true = Exp.crefEqual(var,cr);
io2 = removeInnerAttribute(io);
then
DAE.DAE(DAE.VAR(cr,kind,dir,prot,tp,bind,dim,flow_,st,source,attr,cmt,io2)::elist,funcs);
case(var,DAE.DAE(DAE.COMP(id,elist,source)::elist2,funcs))
equation
DAE.DAE(elist,_) = removeInnerAttr(var,DAE.DAE(elist,funcs));
DAE.DAE(elist2,_) = removeInnerAttr(var,DAE.DAE(elist2,funcs));
then DAE.DAE(DAE.COMP(id,elist,source)::elist2,funcs);
case(var,DAE.DAE(e::elist,funcs))
equation
DAE.DAE(elist,funcs)= removeInnerAttr(var,DAE.DAE(elist,funcs));
then DAE.DAE(e::elist,funcs);
end matchcontinue;
end removeInnerAttr;
protected function compareUniquedVarWithNonUnique "
Author: BZ, workaround to get innerouter elements to work.
This function strips the 'unique identifer' from the cref and compares.
"
input DAE.ComponentRef cr1;
input DAE.ComponentRef cr2;
output Boolean equal;
String s1,s2,s3;
algorithm
s1 := Exp.printComponentRefStr(cr1);
s2 := Exp.printComponentRefStr(cr2);
s1 := System.stringReplace(s1, DAE.UNIQUEIO, "");
s2 := System.stringReplace(s2, DAE.UNIQUEIO, "");
equal := stringEqual(s1,s2);
end compareUniquedVarWithNonUnique;
public function nameInnerouterUniqueCref "
Author: BZ, 2008-11
Renames a var to unique name"
input DAE.ComponentRef inCr;
output DAE.ComponentRef outCr;
algorithm outCr := matchcontinue(inCr)
local
DAE.ComponentRef newChild,child;
String id;
DAE.ExpType idt;
list<DAE.Subscript> subs;
case(DAE.CREF_IDENT(id,idt,subs))
equation
id = DAE.UNIQUEIO +& id;
then
DAE.CREF_IDENT(id,idt,subs);
case(DAE.CREF_QUAL(id,idt,subs,child))
equation
newChild = nameInnerouterUniqueCref(child);
then
DAE.CREF_QUAL(id,idt,subs,newChild);
end matchcontinue;
end nameInnerouterUniqueCref;
public function unNameInnerouterUniqueCref "
Function for stripping a cref of its uniqified part.
Remove 'removalString' from the cref if found
"
input DAE.ComponentRef cr;
input String removalString;
output DAE.ComponentRef ocr;
algorithm ocr := matchcontinue(cr,removalString)
local
String str,str2;
DAE.ExpType ty;
DAE.ComponentRef child,child_2;
list<DAE.Subscript> subs;
case(DAE.CREF_IDENT(str,ty,subs),removalString)
equation
str2 = System.stringReplace(str, removalString, "");
then
DAE.CREF_IDENT(str2,ty,subs);
case(DAE.CREF_QUAL(str,ty,subs,child),removalString)
equation
child_2 = unNameInnerouterUniqueCref(child,removalString);
str2 = System.stringReplace(str, removalString, "");
then
DAE.CREF_QUAL(str2,ty,subs,child_2);
case(DAE.WILD(),_) then DAE.WILD();
case(child,_)
equation
print(" failure unNameInnerouterUniqueCref: ");
print(Exp.printComponentRefStr(child) +& "\n");
then fail();
end matchcontinue;
end unNameInnerouterUniqueCref;
protected function getOuterBinding "
Author: BZ, 2008-11
Aquire the binding on the outer/innerouter variable, to transfer to inner variable.
"
input DAE.ComponentRef currVar;
input list<tuple<DAE.ComponentRef, DAE.Exp>> inlst;
output Option<DAE.Exp> binding;
algorithm binding := matchcontinue(currVar,inlst)
local DAE.ComponentRef cr1,cr2; DAE.Exp e;
case(_,{}) then NONE;
case(cr1,(cr2,e)::inlst)
equation
true = Exp.crefEqual(cr1,cr2);
then
SOME(e);
case(cr1,(_,_)::inlst) then getOuterBinding(cr1,inlst);
end matchcontinue;
end getOuterBinding;
protected function removeInnerAttribute "Help function to removeInnerAttr"
input Absyn.InnerOuter io;
output Absyn.InnerOuter ioOut;
algorithm
ioOut := matchcontinue(io)
case(Absyn.INNER()) then Absyn.UNSPECIFIED();
case(Absyn.INNEROUTER()) then Absyn.OUTER();
case(io) then io;
end matchcontinue;
end removeInnerAttribute;
public function varCref " returns the component reference of a variable"
input DAE.Element elt;
output DAE.ComponentRef cr;
algorithm
cr := matchcontinue(elt)
case(DAE.VAR(componentRef = cr)) then cr;
end matchcontinue;
end varCref;
public function getUnitAttr "
Return the unit attribute"
input Option<DAE.VariableAttributes> inVariableAttributesOption;
output DAE.Exp start;
algorithm
start := matchcontinue (inVariableAttributesOption)
local
DAE.Exp u;
case (SOME(DAE.VAR_ATTR_REAL(_,SOME(u),_,_,_,_,_,_,_,_,_))) then u;
case (_) then DAE.SCONST("");
end matchcontinue;
end getUnitAttr;
public function getStartAttrEmpty "
Return the start attribute."
input Option<DAE.VariableAttributes> inVariableAttributesOption;
input DAE.Exp optExp;
output DAE.Exp start;
algorithm
start := matchcontinue (inVariableAttributesOption,optExp)
local
DAE.Exp r;
case (SOME(DAE.VAR_ATTR_REAL(initial_ = SOME(r))),_) then r;
case (SOME(DAE.VAR_ATTR_INT(initial_ = SOME(r))),_) then r;
case (SOME(DAE.VAR_ATTR_BOOL(initial_ = SOME(r))),_) then r;
case (SOME(DAE.VAR_ATTR_STRING(initial_ = SOME(r))),_) then r;
case(_,optExp) then optExp;
end matchcontinue;
end getStartAttrEmpty;
public function getMinMax "
Author: BZ, returns a list of optional exp, {opt<Min> opt<Max} "
input Option<DAE.VariableAttributes> inVariableAttributesOption;
output list<Option<DAE.Exp>> oExps;
algorithm oExps := matchcontinue(inVariableAttributesOption)
local
Option<DAE.Exp> e1,e2;
case(SOME(DAE.VAR_ATTR_ENUMERATION(min = (e1,e2))))
equation
then
e1::{e2};
case(SOME(DAE.VAR_ATTR_INT(min = (e1,e2))))
equation
then
e1::{e2};
case(SOME(DAE.VAR_ATTR_REAL(min = (e1,e2))))
equation
then
e1::{e2};
case(_) then {};
end matchcontinue;
end getMinMax;
public function getStartAttr "
Return the start attribute."
input Option<DAE.VariableAttributes> inVariableAttributesOption;
output DAE.Exp start;
algorithm
start := matchcontinue (inVariableAttributesOption)
local
DAE.Exp r;
case (SOME(DAE.VAR_ATTR_REAL(initial_ = SOME(r)))) then r;
case (SOME(DAE.VAR_ATTR_INT(initial_ = SOME(r)))) then r;
case (SOME(DAE.VAR_ATTR_BOOL(initial_ = SOME(r)))) then r;
case (SOME(DAE.VAR_ATTR_STRING(initial_ = SOME(r)))) then r;
case (_) then DAE.RCONST(0.0);
end matchcontinue;
end getStartAttr;
public function getStartAttrFail "
Return the start attribute. or fails"
input Option<DAE.VariableAttributes> inVariableAttributesOption;
output DAE.Exp start;
algorithm start:= matchcontinue (inVariableAttributesOption)
local
DAE.Exp r;
case (SOME(DAE.VAR_ATTR_REAL(initial_ = SOME(r)))) then r;
case (SOME(DAE.VAR_ATTR_INT(initial_ = SOME(r)))) then r;
case (SOME(DAE.VAR_ATTR_BOOL(initial_ = SOME(r)))) then r;
case (SOME(DAE.VAR_ATTR_STRING(initial_ = SOME(r)))) then r;
end matchcontinue;
end getStartAttrFail;
public function setVariableAttributes "sets the attributes of a DAE.Element that is VAR"
input DAE.Element var;
input Option<DAE.VariableAttributes> varOpt;
output DAE.Element outVar;
algorithm
outVar := matchcontinue(var,varOpt)
local
DAE.ComponentRef cr; DAE.VarKind k;
DAE.VarDirection d ; DAE.VarProtection p;
DAE.Type ty; Option<DAE.Exp> b;
DAE.InstDims dims; DAE.Flow fl; DAE.Stream st;
DAE.ElementSource source "the origin of the element";
Option<SCode.Comment> cmt; Absyn.InnerOuter io;
case(DAE.VAR(cr,k,d,p,ty,b,dims,fl,st,source,_,cmt,io),varOpt)
then DAE.VAR(cr,k,d,p,ty,b,dims,fl,st,source,varOpt,cmt,io);
end matchcontinue;
end setVariableAttributes;
public function setStartAttr "
sets the start attribute. If NONE, assumes Real attributes."
input Option<DAE.VariableAttributes> attr;
input DAE.Exp start;
output Option<DAE.VariableAttributes> outAttr;
algorithm
outAttr:=
matchcontinue (attr,start)
local
Option<DAE.Exp> q,u,du,i,f,n;
tuple<Option<DAE.Exp>, Option<DAE.Exp>> minMax;
Option<DAE.StateSelect> ss;
DAE.Exp r;
Option<DAE.Exp> eb;
Option<Boolean> ip,fn;
case (SOME(DAE.VAR_ATTR_REAL(q,u,du,minMax,_,f,n,ss,eb,ip,fn)),start)
then SOME(DAE.VAR_ATTR_REAL(q,u,du,minMax,SOME(start),f,n,ss,eb,ip,fn));
case (SOME(DAE.VAR_ATTR_INT(q,minMax,_,f,eb,ip,fn)),start)
then SOME(DAE.VAR_ATTR_INT(q,minMax,SOME(start),f,eb,ip,fn));
case (SOME(DAE.VAR_ATTR_BOOL(q,_,f,eb,ip,fn)),start)
then SOME(DAE.VAR_ATTR_BOOL(q,SOME(start),f,eb,ip,fn));
case (SOME(DAE.VAR_ATTR_STRING(q,_,eb,ip,fn)),start)
then SOME(DAE.VAR_ATTR_STRING(q,SOME(start),eb,ip,fn));
case (SOME(DAE.VAR_ATTR_ENUMERATION(q,minMax,u,du,eb,ip,fn)),start)
then SOME(DAE.VAR_ATTR_ENUMERATION(q,minMax,SOME(start),du,eb,ip,fn));
case (NONE,start)
then SOME(DAE.VAR_ATTR_REAL(NONE,NONE,NONE,(NONE,NONE),SOME(start),NONE,NONE,NONE,NONE,NONE,NONE));
end matchcontinue;
end setStartAttr;
public function setUnitAttr "
sets the unit attribute. .
"
input Option<DAE.VariableAttributes> attr;
input DAE.Exp unit;
output Option<DAE.VariableAttributes> outAttr;
algorithm
outAttr:=
matchcontinue (attr,unit)
local
Option<DAE.Exp> q,u,du,i,f,n,s;
tuple<Option<DAE.Exp>, Option<DAE.Exp>> minMax;
Option<DAE.StateSelect> ss;
DAE.Exp r;
Option<DAE.Exp> eb;
Option<Boolean> ip,fn;
case (SOME(DAE.VAR_ATTR_REAL(q,u,du,minMax,s,f,n,ss,eb,ip,fn)),unit)
then SOME(DAE.VAR_ATTR_REAL(q,SOME(unit),du,minMax,s,f,n,ss,eb,ip,fn));
case (NONE,unit)
then SOME(DAE.VAR_ATTR_REAL(NONE,SOME(unit),NONE,(NONE,NONE),NONE,NONE,NONE,NONE,NONE,NONE,NONE));
end matchcontinue;
end setUnitAttr;
public function setProtectedAttr "
sets the start attribute. If NONE, assumes Real attributes.
"
input Option<DAE.VariableAttributes> attr;
input Boolean isProtected;
output Option<DAE.VariableAttributes> outAttr;
algorithm
outAttr:=
matchcontinue (attr,isProtected)
local
Option<DAE.Exp> q,u,du,i,f,n;
tuple<Option<DAE.Exp>, Option<DAE.Exp>> minMax;
Option<DAE.StateSelect> ss;
DAE.Exp r;
Option<DAE.Exp> eb;
Option<Boolean> ip,fn;
case (SOME(DAE.VAR_ATTR_REAL(q,u,du,minMax,i,f,n,ss,eb,_,fn)),isProtected)
then SOME(DAE.VAR_ATTR_REAL(q,u,du,minMax,i,f,n,ss,eb,SOME(isProtected),fn));
case (SOME(DAE.VAR_ATTR_INT(q,minMax,i,f,eb,_,fn)),isProtected)
then SOME(DAE.VAR_ATTR_INT(q,minMax,i,f,eb,SOME(isProtected),fn));
case (SOME(DAE.VAR_ATTR_BOOL(q,i,f,eb,_,fn)),isProtected)
then SOME(DAE.VAR_ATTR_BOOL(q,i,f,eb,SOME(isProtected),fn));
case (SOME(DAE.VAR_ATTR_STRING(q,i,eb,_,fn)),isProtected)
then SOME(DAE.VAR_ATTR_STRING(q,i,eb,SOME(isProtected),fn));
case (SOME(DAE.VAR_ATTR_ENUMERATION(q,minMax,u,du,eb,ip,fn)),isProtected)
then SOME(DAE.VAR_ATTR_ENUMERATION(q,minMax,u,du,eb,SOME(isProtected),fn));
case (NONE,isProtected)
then SOME(DAE.VAR_ATTR_REAL(NONE,NONE,NONE,(NONE,NONE),NONE,NONE,NONE,NONE,NONE,SOME(isProtected),NONE));
end matchcontinue;
end setProtectedAttr;
public function getProtectedAttr "
retrieves the protected attribute form VariableAttributes.
"
input Option<DAE.VariableAttributes> attr;
output Boolean isProtected;
algorithm
isProtected:=
matchcontinue (attr)
case (SOME(DAE.VAR_ATTR_REAL(isProtected=SOME(isProtected)))) then isProtected;
case (SOME(DAE.VAR_ATTR_INT(isProtected=SOME(isProtected)))) then isProtected;
case (SOME(DAE.VAR_ATTR_BOOL(isProtected=SOME(isProtected)))) then isProtected;
case (SOME(DAE.VAR_ATTR_STRING(isProtected=SOME(isProtected)))) then isProtected;
case (SOME(DAE.VAR_ATTR_ENUMERATION(isProtected=SOME(isProtected)))) then isProtected;
case(_) then false;
end matchcontinue;
end getProtectedAttr;
public function setFixedAttr "Function: setFixedAttr
Sets the start attribute:fixed to inputarg
"
input Option<DAE.VariableAttributes> attr;
input Option<DAE.Exp> start;
output Option<DAE.VariableAttributes> outAttr;
algorithm
outAttr:=
matchcontinue (attr,start)
local
Option<DAE.Exp> q,u,du,i,f,n,ini;
tuple<Option<DAE.Exp>, Option<DAE.Exp>> minMax;
Option<DAE.StateSelect> ss;
DAE.Exp r;
Option<DAE.Exp> eb;
Option<Boolean> ip,fn;
case (SOME(DAE.VAR_ATTR_REAL(q,u,du,minMax,ini,_,n,ss,eb,ip,fn)),start)
then SOME(DAE.VAR_ATTR_REAL(q,u,du,minMax,ini,start,n,ss,eb,ip,fn));
case (SOME(DAE.VAR_ATTR_INT(q,minMax,ini,_,eb,ip,fn)),start)
then SOME(DAE.VAR_ATTR_INT(q,minMax,ini,start,eb,ip,fn));
case (SOME(DAE.VAR_ATTR_BOOL(q,ini,_,eb,ip,fn)),start)
then SOME(DAE.VAR_ATTR_BOOL(q,ini,start,eb,ip,fn));
case (SOME(DAE.VAR_ATTR_STRING(q,ini,eb,ip,fn)),start)
then SOME(DAE.VAR_ATTR_STRING(q,ini,eb,ip,fn));
case (SOME(DAE.VAR_ATTR_ENUMERATION(q,minMax,u,_,eb,ip,fn)),start)
then SOME(DAE.VAR_ATTR_ENUMERATION(q,minMax,u,start,eb,ip,fn));
end matchcontinue;
end setFixedAttr;
public function setFinalAttr "
sets the start attribute. If NONE, assumes Real attributes.
"
input Option<DAE.VariableAttributes> attr;
input Boolean finalPrefix;
output Option<DAE.VariableAttributes> outAttr;
algorithm
outAttr:=
matchcontinue (attr,finalPrefix)
local
Option<DAE.Exp> q,u,du,i,f,n;
tuple<Option<DAE.Exp>, Option<DAE.Exp>> minMax;
Option<DAE.StateSelect> ss;
Option<DAE.Exp> eb;
Option<Boolean> ip,fn;
case (SOME(DAE.VAR_ATTR_REAL(q,u,du,minMax,i,f,n,ss,eb,ip,_)),finalPrefix)
then SOME(DAE.VAR_ATTR_REAL(q,u,du,minMax,i,f,n,ss,eb,ip,SOME(finalPrefix)));
case (SOME(DAE.VAR_ATTR_INT(q,minMax,i,f,eb,ip,_)),finalPrefix)
then SOME(DAE.VAR_ATTR_INT(q,minMax,i,f,eb,ip,SOME(finalPrefix)));
case (SOME(DAE.VAR_ATTR_BOOL(q,i,f,eb,ip,_)),finalPrefix)
then SOME(DAE.VAR_ATTR_BOOL(q,i,f,eb,ip,SOME(finalPrefix)));
case (SOME(DAE.VAR_ATTR_STRING(q,i,eb,ip,_)),finalPrefix)
then SOME(DAE.VAR_ATTR_STRING(q,i,eb,ip,SOME(finalPrefix)));
case (SOME(DAE.VAR_ATTR_ENUMERATION(q,minMax,u,du,eb,ip,_)),finalPrefix)
then SOME(DAE.VAR_ATTR_ENUMERATION(q,minMax,u,du,eb,ip,SOME(finalPrefix)));
case (NONE,finalPrefix)
then SOME(DAE.VAR_ATTR_REAL(NONE,NONE,NONE,(NONE,NONE),NONE,NONE,NONE,NONE,NONE,NONE,SOME(finalPrefix)));
end matchcontinue;
end setFinalAttr;
public function boolVarProtection "Function: boolVarProtection
Takes a DAE.varprotection and returns true/false (is_protected / not)
"
input DAE.VarProtection vp;
output Boolean prot;
algorithm
prot := matchcontinue(vp)
case(DAE.PUBLIC()) then false;
case(DAE.PROTECTED()) then true;
case(_) equation print("- DAEUtil.boolVa_Protection failed\n"); then fail();
end matchcontinue;
end boolVarProtection;
public function varHasName "returns true if variable equals name passed as argument"
input DAE.Element var;
input DAE.ComponentRef cr;
output Boolean res;
algorithm
res := matchcontinue(var,cr)
local DAE.ComponentRef cr2;
case(DAE.VAR(componentRef=cr2),cr) equation
res = Exp.crefEqual(cr2,cr);
then res;
end matchcontinue;
end varHasName;
public function hasStartAttr "
Returns true if variable attributes defines a start value.
"
input Option<DAE.VariableAttributes> inVariableAttributesOption;
output Boolean hasStart;
algorithm
hasStart:=
matchcontinue (inVariableAttributesOption)
local
DAE.Exp r;
case (SOME(DAE.VAR_ATTR_REAL(initial_ = SOME(r)))) then true;
case (SOME(DAE.VAR_ATTR_INT(initial_ = SOME(r)))) then true;
case (SOME(DAE.VAR_ATTR_BOOL(initial_ = SOME(r)))) then true;
case (SOME(DAE.VAR_ATTR_STRING(initial_ = SOME(r)))) then true;
case (_) then false;
end matchcontinue;
end hasStartAttr;
public function getStartAttrString "function: getStartAttrString
Return the start attribute as a string.
"
input Option<DAE.VariableAttributes> inVariableAttributesOption;
output String outString;
algorithm
outString:=
matchcontinue (inVariableAttributesOption)
local
String s;
DAE.Exp r;
case (NONE) then "";
case (SOME(DAE.VAR_ATTR_REAL(initial_ = SOME(r))))
equation
s = Exp.printExpStr(r);
then
s;
case (SOME(DAE.VAR_ATTR_INT(initial_ = SOME(r))))
equation
s = Exp.printExpStr(r);
then
s;
case (_) then "";
end matchcontinue;
end getStartAttrString;
protected function stringToString "function: stringToString
Convert a string to a Modelica string, enclosed in citation marks.
"
input String str;
output String str_1;