/
DAE.mo
1416 lines (1150 loc) · 40.5 KB
/
DAE.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 DAE
" file: DAE.mo
package: DAE
description: DAE management and output
RCS: $Id$
This module defines data structures for DAE equations and declarations of
variables and functions. The DAE data structure is the result of flattening,
containing only flat modelica, i.e. equations, algorithms, variables and
functions."
// public imports
public import Absyn;
public import ClassInf;
public import SCode;
public import Values;
public type Ident = String;
public type InstDims = list<Subscript>;
public type StartValue = Option<Exp>;
public constant String UNIQUEIO = "$unique$outer$";
public constant String derivativeNamePrefix="$DER";
public uniontype VarKind
record VARIABLE "variable" end VARIABLE;
record DISCRETE "discrete" end DISCRETE;
record PARAM "parameter" end PARAM;
record CONST "constant" end CONST;
end VarKind;
public uniontype Flow "The Flow of a variable indicates if it is a Flow variable or not, or if
it is not a connector variable at all."
record FLOW end FLOW;
record NON_FLOW end NON_FLOW;
record NON_CONNECTOR end NON_CONNECTOR;
end Flow;
public uniontype Stream "The Stream of a variable indicates if it is a Stream variable or not, or if
it is not a connector variable at all."
record STREAM end STREAM;
record NON_STREAM end NON_STREAM;
record NON_STREAM_CONNECTOR end NON_STREAM_CONNECTOR;
end Stream;
public uniontype VarDirection
record INPUT "input" end INPUT;
record OUTPUT "output" end OUTPUT;
record BIDIR "neither input or output" end BIDIR;
end VarDirection;
public uniontype VarProtection
record PUBLIC "public variables" end PUBLIC;
record PROTECTED "protected variables" end PROTECTED;
end VarProtection;
uniontype ElementSource "gives information about the origin of the element"
record SOURCE
Absyn.Info info "the line and column numbers of the equations and algorithms this element came from";
list<Absyn.Within> partOfLst "the model(s) this element came from";
list<Option<ComponentRef>> instanceOptLst "the instance(s) this element is part of";
list<Option<tuple<ComponentRef, ComponentRef>>> connectEquationOptLst "this element came from this connect(s)";
list<Absyn.Path> typeLst "the classes where the type(s) of the element is defined";
end SOURCE;
end ElementSource;
public constant ElementSource emptyElementSource = SOURCE(Absyn.dummyInfo,{},{},{},{});
public uniontype Element
record VAR
ComponentRef componentRef " The variable name";
VarKind kind "varible kind: variable, constant, parameter, discrete etc." ;
VarDirection direction "input, output or bidir" ;
VarProtection protection "if protected or public";
Type ty "Full type information required";
Option<Exp> binding "Binding expression e.g. for parameters ; value of start attribute" ;
InstDims dims "dimensions";
Flow flowPrefix "Flow of connector variable. Needed for unconnected flow variables" ;
Stream streamPrefix "Stream variables in connectors" ;
ElementSource source "the origins of the component/equation/algorithm";
Option<VariableAttributes> variableAttributesOption;
Option<SCode.Comment> absynCommentOption;
Absyn.InnerOuter innerOuter "inner/outer required to 'change' outer references";
end VAR;
record DEFINE "A solved equation"
ComponentRef componentRef;
Exp exp;
ElementSource source "the origin of the component/equation/algorithm";
end DEFINE;
record INITIALDEFINE " A solved initial equation"
ComponentRef componentRef;
Exp exp;
ElementSource source "the origin of the component/equation/algorithm";
end INITIALDEFINE;
record EQUATION "Scalar equation"
Exp exp;
Exp scalar;
ElementSource source "the origin of the component/equation/algorithm";
end EQUATION;
record EQUEQUATION "effort variable equality"
ComponentRef cr1;
ComponentRef cr2;
ElementSource source "the origin of the component/equation/algorithm";
end EQUEQUATION;
record ARRAY_EQUATION " an array equation"
list<Dimension> dimension "dimension sizes" ;
Exp exp;
Exp array;
ElementSource source "the origin of the component/equation/algorithm";
end ARRAY_EQUATION;
record INITIAL_ARRAY_EQUATION "An initial array equation"
list<Dimension> dimension "dimension sizes";
Exp exp;
Exp array;
ElementSource source "the origin of the component/equation/algorithm";
end INITIAL_ARRAY_EQUATION;
record COMPLEX_EQUATION "an equation of complex type, e.g. record = func(..)"
Exp lhs;
Exp rhs;
ElementSource source "the origin of the component/equation/algorithm";
end COMPLEX_EQUATION;
record INITIAL_COMPLEX_EQUATION "an initial equation of complex type, e.g. record = func(..)"
Exp lhs;
Exp rhs;
ElementSource source "the origin of the component/equation/algorithm";
end INITIAL_COMPLEX_EQUATION;
record WHEN_EQUATION " a when equation"
Exp condition "Condition" ;
list<Element> equations "Equations" ;
Option<Element> elsewhen_ "Elsewhen should be of type WHEN_EQUATION" ;
ElementSource source "the origin of the component/equation/algorithm";
end WHEN_EQUATION;
record IF_EQUATION " an if-equation"
list<Exp> condition1 "Condition" ;
list<list<Element>> equations2 "Equations of true branch" ;
list<Element> equations3 "Equations of false branch" ;
ElementSource source "the origin of the component/equation/algorithm";
end IF_EQUATION;
record INITIAL_IF_EQUATION "An initial if-equation"
list<Exp> condition1 "Condition" ;
list<list<Element>> equations2 "Equations of true branch" ;
list<Element> equations3 "Equations of false branch" ;
ElementSource source "the origin of the component/equation/algorithm";
end INITIAL_IF_EQUATION;
record INITIALEQUATION " An initial equaton"
Exp exp1;
Exp exp2;
ElementSource source "the origin of the component/equation/algorithm";
end INITIALEQUATION;
record ALGORITHM " An algorithm section"
Algorithm algorithm_;
ElementSource source "the origin of the component/equation/algorithm";
end ALGORITHM;
record INITIALALGORITHM " An initial algorithm section"
Algorithm algorithm_;
ElementSource source "the origin of the component/equation/algorithm";
end INITIALALGORITHM;
record COMP
Ident ident;
list<Element> dAElist "a component with subelements, normally only used at top level.";
ElementSource source "the origin of the component/equation/algorithm"; // we might not this here.
Option<SCode.Comment> comment;
end COMP;
record EXTOBJECTCLASS "The 'class' of an external object"
Absyn.Path path "className of external object";
Function constructor "constructor is an EXTFUNCTION";
Function destructor "destructor is an EXTFUNCTION";
ElementSource source "the origin of the component/equation/algorithm";
end EXTOBJECTCLASS;
record ASSERT " The Modelica builtin assert"
Exp condition;
Exp message;
ElementSource source "the origin of the component/equation/algorithm";
end ASSERT;
record TERMINATE " The Modelica builtin terminate(msg)"
Exp message;
ElementSource source "the origin of the component/equation/algorithm";
end TERMINATE;
record REINIT " reinit operator for reinitialization of states"
ComponentRef componentRef;
Exp exp;
ElementSource source "the origin of the component/equation/algorithm";
end REINIT;
record NORETCALL "call with no return value, i.e. no equation.
Typically sideeffect call of external function but also
Connections.* i.e. Connections.root(...) functions."
Absyn.Path functionName;
list<Exp> functionArgs;
ElementSource source "the origin of the component/equation/algorithm";
end NORETCALL;
end Element;
public uniontype Function
record FUNCTION " A Modelica function"
Absyn.Path path;
list<FunctionDefinition> functions "contains the body and an optional function derivative mapping";
Type type_;
Boolean partialPrefix "MetaModelica extension";
InlineType inlineType;
ElementSource source "the origin of the component/equation/algorithm";
end FUNCTION;
record RECORD_CONSTRUCTOR "A Modelica record constructor. The function can be generated from the Path and Type alone."
Absyn.Path path;
Type type_;
ElementSource source "the origin of the component/equation/algorithm";
end RECORD_CONSTRUCTOR;
end Function;
public uniontype InlineType
record NORM_INLINE "Normal inline, inline as soon as possible"
end NORM_INLINE;
record EARLY_INLINE "Inline even earlier than NORM_INLINE. This will display the inlined code in the flattened model and also works for functions calling other functions that should be inlined."
end EARLY_INLINE;
record NO_INLINE "Avoid inline, this is default behaviour but is also possible to set with Inline=false"
end NO_INLINE;
record AFTER_INDEX_RED_INLINE "Try to inline after index reduction"
end AFTER_INDEX_RED_INLINE;
end InlineType;
public uniontype FunctionDefinition
record FUNCTION_DEF "Normal function body"
list<Element> body;
end FUNCTION_DEF;
record FUNCTION_EXT "Normal external function declaration"
list<Element> body;
ExternalDecl externalDecl;
end FUNCTION_EXT;
record FUNCTION_DER_MAPPER "Contains derivatives for function"
Absyn.Path derivedFunction "Function that is derived";
Absyn.Path derivativeFunction "Path to derivative function";
Integer derivativeOrder "in case a function have multiple derivatives, include all";
list<tuple<Integer,derivativeCond>> conditionRefs;
Option<Absyn.Path> defaultDerivative "if conditions fails, use default derivative if exists";
list<Absyn.Path> lowerOrderDerivatives;
end FUNCTION_DER_MAPPER;
end FunctionDefinition;
public
uniontype derivativeCond "Different conditions on derivatives"
record ZERO_DERIVATIVE end ZERO_DERIVATIVE;
record NO_DERIVATIVE Exp binding; end NO_DERIVATIVE;
end derivativeCond;
public
uniontype VariableAttributes
record VAR_ATTR_REAL
Option<Exp> quantity "quantity" ;
Option<Exp> unit "unit" ;
Option<Exp> displayUnit "displayUnit" ;
tuple<Option<Exp>, Option<Exp>> min "min , max" ;
Option<Exp> initial_ "Initial value" ;
Option<Exp> fixed "fixed - true: default for parameter/constant, false - default for other variables" ;
Option<Exp> nominal "nominal" ;
Option<StateSelect> stateSelectOption;
Option<Exp> equationBound;
Option<Boolean> isProtected;
Option<Boolean> finalPrefix;
end VAR_ATTR_REAL;
record VAR_ATTR_INT
Option<Exp> quantity "quantity" ;
tuple<Option<Exp>, Option<Exp>> min "min , max" ;
Option<Exp> initial_ "Initial value" ;
Option<Exp> fixed "fixed - true: default for parameter/constant, false - default for other variables" ;
Option<Exp> equationBound;
Option<Boolean> isProtected; // ,eb,ip
Option<Boolean> finalPrefix;
end VAR_ATTR_INT;
record VAR_ATTR_BOOL
Option<Exp> quantity "quantity" ;
Option<Exp> initial_ "Initial value" ;
Option<Exp> fixed "fixed - true: default for parameter/constant, false - default for other variables" ;
Option<Exp> equationBound;
Option<Boolean> isProtected;
Option<Boolean> finalPrefix;
end VAR_ATTR_BOOL;
record VAR_ATTR_STRING
Option<Exp> quantity "quantity" ;
Option<Exp> initial_ "Initial value" ;
Option<Exp> equationBound;
Option<Boolean> isProtected;
Option<Boolean> finalPrefix;
end VAR_ATTR_STRING;
record VAR_ATTR_ENUMERATION
Option<Exp> quantity "quantity" ;
tuple<Option<Exp>, Option<Exp>> min "min , max" ;
Option<Exp> start "start" ;
Option<Exp> fixed "fixed - true: default for parameter/constant, false - default for other variables" ;
Option<Exp> equationBound;
Option<Boolean> isProtected;
Option<Boolean> finalPrefix;
end VAR_ATTR_ENUMERATION;
end VariableAttributes;
public uniontype StateSelect
record NEVER end NEVER;
record AVOID end AVOID;
record DEFAULT end DEFAULT;
record PREFER end PREFER;
record ALWAYS end ALWAYS;
end StateSelect;
public uniontype ExtArg
record EXTARG
ComponentRef componentRef;
Attributes attributes;
Type type_;
end EXTARG;
record EXTARGEXP
Exp exp;
Type type_;
end EXTARGEXP;
record EXTARGSIZE
ComponentRef componentRef;
Attributes attributes;
Type type_;
Exp exp;
end EXTARGSIZE;
record NOEXTARG end NOEXTARG;
end ExtArg;
public uniontype ExternalDecl
record EXTERNALDECL
Ident ident;
list<ExtArg> external_ "external function name" ;
ExtArg parameters "parameters" ;
String returnType "return type" ;
Option<Absyn.Annotation> language "language e.g. Library" ;
end EXTERNALDECL;
end ExternalDecl;
public uniontype DAElist "A DAElist is a list of Elements. Variables, equations, functions,
algorithms, etc. are all found in this list.
"
record DAE
list<Element> elementLst;
end DAE;
end DAElist;
/* AVLTree for functions */
public type AvlKey = Absyn.Path;
public type AvlValue = Option<Function>;
public type FunctionTree = AvlTree;
public
uniontype AvlTree "The binary tree data structure
"
record AVLTREENODE
Option<AvlTreeValue> value "Value" ;
Integer height "heigth of tree, used for balancing";
Option<AvlTree> left "left subtree" ;
Option<AvlTree> right "right subtree" ;
end AVLTREENODE;
end AvlTree;
public
uniontype AvlTreeValue "Each node in the binary tree can have a value associated with it."
record AVLTREEVALUE
AvlKey key "Key" ;
AvlValue value "Value" ;
end AVLTREEVALUE;
end AvlTreeValue;
/* -- Algorithm.mo -- */
public
uniontype Algorithm "The `Algorithm\' type corresponds to a whole algorithm section.
It is simple a list of algorithm statements."
record ALGORITHM_STMTS
list<Statement> statementLst;
end ALGORITHM_STMTS;
end Algorithm;
public
uniontype Statement "There are four kinds of statements. Assignments (`a := b;\'),
if statements (`if A then B; elseif C; else D;\'), for loops
(`for i in 1:10 loop ...; end for;\') and when statements
(`when E do S; end when;\')."
record STMT_ASSIGN
ExpType type_;
Exp exp1;
Exp exp;
ElementSource source "the origin of the component/equation/algorithm";
end STMT_ASSIGN;
record STMT_TUPLE_ASSIGN
ExpType type_;
list<Exp> expExpLst;
Exp exp;
ElementSource source "the origin of the component/equation/algorithm";
end STMT_TUPLE_ASSIGN;
record STMT_ASSIGN_ARR
ExpType type_;
ComponentRef componentRef;
Exp exp;
ElementSource source "the origin of the component/equation/algorithm";
end STMT_ASSIGN_ARR;
record STMT_ASSIGN_PATTERN "(x,1,ROOT(a as _,false,_)) := rhs; MetaModelica extension"
Pattern lhs;
Exp rhs;
ElementSource source "the origin of the component/equation/algorithm";
end STMT_ASSIGN_PATTERN;
record STMT_IF
Exp exp;
list<Statement> statementLst;
Else else_;
ElementSource source "the origin of the component/equation/algorithm";
end STMT_IF;
record STMT_FOR
ExpType type_ "this is the type of the iterator";
Boolean iterIsArray "True if the iterator has an array type, otherwise false.";
Ident iter "the iterator variable";
Exp range "range for the loop";
list<Statement> statementLst;
ElementSource source "the origin of the component/equation/algorithm";
end STMT_FOR;
record STMT_WHILE
Exp exp;
list<Statement> statementLst;
ElementSource source "the origin of the component/equation/algorithm";
end STMT_WHILE;
record STMT_WHEN
Exp exp;
list<Statement> statementLst;
Option<Statement> elseWhen;
list<Integer> helpVarIndices;
ElementSource source "the origin of the component/equation/algorithm";
end STMT_WHEN;
record STMT_ASSERT "assert(cond,msg)"
Exp cond;
Exp msg;
ElementSource source "the origin of the component/equation/algorithm";
end STMT_ASSERT;
record STMT_TERMINATE "terminate(msg)"
Exp msg;
ElementSource source "the origin of the component/equation/algorithm";
end STMT_TERMINATE;
record STMT_REINIT
Exp var "Variable";
Exp value "Value ";
ElementSource source "the origin of the component/equation/algorithm";
end STMT_REINIT;
record STMT_NORETCALL "call with no return value, i.e. no equation.
Typically sideeffect call of external function."
Exp exp;
ElementSource source "the origin of the component/equation/algorithm";
end STMT_NORETCALL;
record STMT_RETURN
ElementSource source "the origin of the component/equation/algorithm";
end STMT_RETURN;
record STMT_BREAK
ElementSource source "the origin of the component/equation/algorithm";
end STMT_BREAK;
// MetaModelica extension. KS
record STMT_FAILURE
list<Statement> body;
ElementSource source "the origin of the component/equation/algorithm";
end STMT_FAILURE;
record STMT_TRY
list<Statement> tryBody;
ElementSource source "the origin of the component/equation/algorithm";
end STMT_TRY;
record STMT_CATCH
list<Statement> catchBody;
ElementSource source "the origin of the component/equation/algorithm";
end STMT_CATCH;
record STMT_THROW
ElementSource source "the origin of the component/equation/algorithm";
end STMT_THROW;
//-----
end Statement;
public
uniontype Else "An if statements can one or more `elseif\' branches and an
optional `else\' branch."
record NOELSE end NOELSE;
record ELSEIF
Exp exp;
list<Statement> statementLst;
Else else_;
end ELSEIF;
record ELSE
list<Statement> statementLst;
end ELSE;
end Else;
/* -- End Algorithm.mo -- */
/* -- Start Types.mo -- */
public
uniontype Var "- Variables"
record TYPES_VAR
Ident name "name" ;
Attributes attributes "attributes" ;
Boolean protected_ "protected" ;
Type type_ "type" ;
Binding binding "binding ; equation modification" ;
Option<Const> constOfForIteratorRange "the constant-ness of the range if this is a for iterator, NONE() if is NOT a for iterator";
end TYPES_VAR;
end Var;
public
uniontype Attributes "- Attributes"
record ATTR
Boolean flowPrefix "flow" ;
Boolean streamPrefix "stream" ;
SCode.Accessibility accessibility "accessibility" ;
SCode.Variability parameter_ "parameter" ;
Absyn.Direction direction "direction" ;
Absyn.InnerOuter innerOuter "inner, outer, inner outer or unspecified";
end ATTR;
end Attributes;
public uniontype BindingSource "where this binding came from: either default binding or start value"
record BINDING_FROM_DEFAULT_VALUE "the binding came from the default value" end BINDING_FROM_DEFAULT_VALUE;
record BINDING_FROM_START_VALUE "the binding came from the start value" end BINDING_FROM_START_VALUE;
end BindingSource;
public
uniontype Binding "- Binding"
record UNBOUND end UNBOUND;
record EQBOUND
Exp exp "exp";
Option<Values.Value> evaluatedExp "evaluatedExp; evaluated exp";
Const constant_ "constant";
BindingSource source "Used for error reporting: this boolean tells us that the parameter did not had a binding but had a start value that was used instead.";
end EQBOUND;
record VALBOUND
Values.Value valBound "valBound";
BindingSource source "Used for error reporting: this boolean tells us that the parameter did not had a binding but had a start value that was used instead";
end VALBOUND;
end Binding;
public type Type = tuple<TType, Option<Absyn.Path>> "
A Type is a tuple of a TType (containing the actual type) and a optional classname
for the class where the type originates from.
- Type";
public
type EqualityConstraint = Option<tuple<Absyn.Path, Integer, InlineType>>
"contains the path to the equalityConstraint function,
the dimension of the output and the inline type of the function";
public constant Type T_REAL_DEFAULT = (T_REAL({}),NONE());
public constant Type T_INTEGER_DEFAULT = (T_INTEGER({}),NONE());
public constant Type T_STRING_DEFAULT = (T_STRING({}),NONE());
public constant Type T_BOOL_DEFAULT = (T_BOOL({}),NONE());
public constant Type T_ENUMERATION_DEFAULT =
(T_ENUMERATION(NONE(), Absyn.IDENT(""), {}, {}, {}), NONE());
public constant Type T_REAL_BOXED = (T_BOXED((T_REAL({}),NONE())),NONE());
public constant Type T_INTEGER_BOXED = (T_BOXED((T_INTEGER({}),NONE())),NONE());
public constant Type T_STRING_BOXED = (T_BOXED((T_STRING({}),NONE())),NONE());
public constant Type T_BOOL_BOXED = (T_BOXED((T_BOOL({}),NONE())),NONE());
public constant Type T_BOXED_DEFAULT = (T_BOXED((T_NOTYPE(),NONE())),NONE());
public constant Type T_LIST_DEFAULT = (T_LIST((T_NOTYPE(),NONE())),NONE());
public constant Type T_NONE_DEFAULT = (T_METAOPTION((T_NOTYPE(),NONE())),NONE());
public constant Type T_NOTYPE_DEFAULT = (T_NOTYPE(),NONE());
public constant Type T_NORETCALL_DEFAULT = (T_NORETCALL(),NONE());
public uniontype TType "-TType contains the actual type"
record T_INTEGER
list<Var> varLstInt;
end T_INTEGER;
record T_REAL
list<Var> varLstReal;
end T_REAL;
record T_STRING
list<Var> varLstString;
end T_STRING;
record T_BOOL
list<Var> varLstBool;
end T_BOOL;
record T_ENUMERATION "If the list of names is empty, this is the super-enumeration that is the super-class of all enumerations"
Option<Integer> index "the enumeration value index, SOME for element, NONE() for type" ;
Absyn.Path path "enumeration path" ;
list<String> names "names" ;
list<Var> literalVarLst;
list<Var> attributeLst;
end T_ENUMERATION;
record T_ARRAY
Dimension arrayDim "arrayDim" ;
Type arrayType "arrayType" ;
end T_ARRAY;
record T_NORETCALL "For functions not returning any values." end T_NORETCALL;
record T_NOTYPE "Used when type is not yet determined" end T_NOTYPE;
record T_ANYTYPE
Option<ClassInf.State> anyClassType "anyClassType - used for generic types. When class state present the type is assumed to be a complex type which has that restriction." ;
end T_ANYTYPE;
// MetaModelica extensions
record T_LIST "MetaModelica list type"
Type listType "listType";
end T_LIST;
record T_METATUPLE "MetaModelica tuple type"
list<Type> types;
end T_METATUPLE;
record T_METAOPTION "MetaModelica option type"
Type optionType;
end T_METAOPTION;
record T_UNIONTYPE "MetaModelica Uniontype, added by simbj"
list <Absyn.Path> records;
end T_UNIONTYPE;
record T_METARECORD "MetaModelica Record, used by Uniontypes. added by simbj"
Absyn.Path utPath "the path to its uniontype; this is what we match the type against";
// If the metarecord constructor was added to the FunctionTree, this would
// not be needed. They are used to create the datatype in the runtime...
Integer index; //The index in the uniontype
list<Var> fields;
end T_METARECORD;
record T_COMPLEX
ClassInf.State complexClassType "complexClassType ; The type of. a class" ;
list<Var> complexVarLst "complexVarLst ; The variables of a complex type" ;
Option<Type> complexTypeOption "complexTypeOption ; A complex type can be a subtype of another (primitive) type (through extends). In that case the varlist is empty" ;
EqualityConstraint equalityConstraint;
end T_COMPLEX;
record T_FUNCTION
list<FuncArg> funcArg "funcArg" ;
Type funcResultType "funcResultType ; Only single-result" ;
FunctionAttributes functionAttributes;
end T_FUNCTION;
record T_TUPLE
list<Type> tupleType "tupleType ; For functions returning multiple values." ;
end T_TUPLE;
record T_BOXED "Used for MetaModelica generic types"
Type ty;
end T_BOXED;
record T_POLYMORPHIC
String name;
end T_POLYMORPHIC;
record T_META_ARRAY
Type ty;
end T_META_ARRAY;
end TType;
public constant FunctionAttributes FUNCTION_ATTRIBUTES_DEFAULT = FUNCTION_ATTRIBUTES(NO_INLINE(),true);
public constant FunctionAttributes FUNCTION_ATTRIBUTES_IMPURE = FUNCTION_ATTRIBUTES(NO_INLINE(),false);
public
uniontype FunctionAttributes
record FUNCTION_ATTRIBUTES
InlineType inline;
Boolean isPure;
end FUNCTION_ATTRIBUTES;
end FunctionAttributes;
public
uniontype Dimension
record DIM_INTEGER "Dimension given by an integer."
Integer integer;
end DIM_INTEGER;
record DIM_ENUM "Dimension given by an enumeration."
Absyn.Path enumTypeName "The enumeration type name.";
list<String> literals "A list of the literals in the enumeration.";
Integer size "The size of the enumeration.";
end DIM_ENUM;
record DIM_EXP "Dimension given by an expression."
Exp exp;
end DIM_EXP;
record DIM_UNKNOWN "Dimension with unknown size."
//DimensionBinding dimensionBinding "unknown dimension can be bound or unbound";
end DIM_UNKNOWN;
end Dimension;
// adrpo: this is used to bind unknown dimensions to an expression
// and when we do subtyping we add constrains to this expression.
// this should be used for typechecking with unknown dimensions
// when running checkModel. the binding acts like a type variable.
public uniontype DimensionBinding
record DIM_UNBOUND "dimension is not bound"
end DIM_UNBOUND;
record DIM_BOUND "dimension is bound to an expression with constrains"
Exp binding "the dimension is bound to this expression";
list<Dimension> constrains "the bound has these constrains (collected when doing subtyping)";
end DIM_BOUND;
end DimensionBinding;
public
type FuncArg = tuple<Ident, Type> "- Function Argument" ;
public
uniontype Const "The degree of constantness of an expression is determined by the Const
datatype. Variables declared as \'constant\' will get C_CONST constantness.
Variables declared as \'parameter\' will get C_PARAM constantness and
all other variables are not constant and will get C_VAR constantness.
- Variable properties"
record C_CONST end C_CONST;
record C_PARAM "\'constant\'s, should always be evaluated" end C_PARAM;
record C_VAR "\'parameter\'s, evaluated if structural not constants, never evaluated" end C_VAR;
record C_UNKNOWN end C_UNKNOWN;
end Const;
public
uniontype TupleConst "A tuple is added to the Types. This is used by functions whom returns multiple arguments.
Used by split_props
- Tuple constants"
record SINGLE_CONST
Const const;
end SINGLE_CONST;
record TUPLE_CONST
list<TupleConst> tupleConstLst "tupleConstLst" ;
end TUPLE_CONST;
end TupleConst;
public
uniontype Properties "P.R 1.1 for multiple return arguments from functions,
one constant flag for each return argument.
The datatype `Properties\' contain information about an
expression. The properties are created by analyzing the
expressions.
- Expression properties"
record PROP
Type type_ "type" ;
Const constFlag "constFlag; if the type is a tuple, each element
have a const flag." ;
end PROP;
record PROP_TUPLE
Type type_;
TupleConst tupleConst "tupleConst; The elements might be
tuple themselfs." ;
end PROP_TUPLE;
end Properties;
public
uniontype EqMod "To generate the correct set of equations, the translator has to
differentiate between the primitive types `Real\', `Integer\',
`String\', `Boolean\' and types directly derived from then from
other, complex types. For arrays and matrices the type
`T_ARRAY\' is used, with the first argument being the number of
dimensions, and the second being the type of the objects in the
array. The `Type\' type is used to store
information about whether a class is derived from a primitive
type, and whether a variable is of one of these types.
- Modification datatype, was originally in Mod"
record TYPED
Exp modifierAsExp "modifierAsExp ; modifier as expression" ;
Option<Values.Value> modifierAsValue "modifierAsValue ; modifier as Value option" ;
Properties properties "properties" ;
Option<Absyn.Exp> modifierAsAbsynExp "keep the untyped modifier as an absyn expression for modification comparison";
end TYPED;
record UNTYPED
Absyn.Exp exp;
end UNTYPED;
end EqMod;
public
uniontype SubMod "-Sub Modification"
record NAMEMOD "named modification, i.e. (a = 5)"
Ident ident "component name";
Mod mod "modification";
end NAMEMOD;
record IDXMOD "index modification, i.e. (x[2] = {1.0,3.0})"
list<Integer> integerLst "list of indexes";
Mod mod "modification";
end IDXMOD;
end SubMod;
public
uniontype Mod "Modification"
record MOD
Boolean finalPrefix "final" ;
Absyn.Each each_;
list<SubMod> subModLst;
Option<EqMod> eqModOption;
end MOD;
record REDECL
Boolean finalPrefix "final" ;
list<tuple<SCode.Element, Mod>> tplSCodeElementModLst;
end REDECL;
record NOMOD end NOMOD;
end Mod;
/* -- End Types.mo -- */
/* -- Start Expression.mo -- */
public
uniontype ExpType "- Basic types
These types are not used as expression types (see the `Types\'
module for expression types). They are used to parameterize
operators which may work on several simple types and for code generation."
record ET_INT end ET_INT;
record ET_REAL end ET_REAL;
record ET_BOOL end ET_BOOL;
record ET_STRING end ET_STRING;
record ET_ENUMERATION
Absyn.Path path "enumeration path" ;
list<String> names "names" ;
list<ExpVar> varLst "varLst" ;
end ET_ENUMERATION;
record ET_COMPLEX "Complex types"
Absyn.Path name;
list<ExpVar> varLst;
ClassInf.State complexClassType;
end ET_COMPLEX;
record ET_OTHER "e.g. complex types, etc." end ET_OTHER;
record ET_ARRAY
ExpType ty;
list<Dimension> arrayDimensions "arrayDimensions" ;
end ET_ARRAY;
// MetaModelica extension. KS
record ET_LIST
ExpType ty;
end ET_LIST;
record ET_METATUPLE
list<ExpType> ty;
end ET_METATUPLE;
record ET_METAOPTION
ExpType ty;
end ET_METAOPTION;
record ET_FUNCTION_REFERENCE_VAR "MetaModelica Function Reference that is a variable"
end ET_FUNCTION_REFERENCE_VAR;
record ET_FUNCTION_REFERENCE_FUNC "MetaModelica Function Reference that is a direct reference to a function"
Boolean builtin;
end ET_FUNCTION_REFERENCE_FUNC;
record ET_METATYPE "MetaModelica boxed types (any)" end ET_METATYPE;
record ET_BOXED ExpType ty; end ET_BOXED;
record ET_NORETCALL "For functions not returning any values." end ET_NORETCALL;
end ExpType;
uniontype ExpVar "A variable is used to describe a complex type which contains a list of variables. See also DAE.Var "
record COMPLEX_VAR
String name;
ExpType tp;
end COMPLEX_VAR;
end ExpVar;
public
uniontype Exp "Expressions
The `Exp\' datatype closely corresponds to the `Absyn.Exp\'
datatype, but is used for statically analyzed expressions. It
includes explicit type promotions and typed (non-overloaded)
operators. It also contains expression indexing with the `ASUB\'
constructor. Indexing arbitrary array expressions is currently
not supported in Modelica, but it is needed here."
record ICONST
Integer integer "Integer constants" ;
end ICONST;
record RCONST
Real real "Real constants" ;
end RCONST;
record SCONST
String string "String constants" ;
end SCONST;