/
Exp.mo
11209 lines (10498 loc) · 313 KB
/
Exp.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-2008, Linköpings University,
* Department of Computer and Information Science,
* SE-58183 Linköping, Sweden.
*
* All rights reserved.
*
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF 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öpings University, either from the above address,
* from the URL: http://www.ida.liu.se/projects/OpenModelica
* and in the OpenModelica distribution.
*
* 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 Exp
"
file: Exp.mo
package: Exp
description: Expressions
RCS: $Id$
This file contains the module `Exp\', which contains data types for
describing expressions, after they have been examined by the
static analyzer in the module `StaticExp\'. There are of course
great similarities with the expression types in the `Absyn\'
module, but there are also several important differences.
No overloading of operators occur, and subscripts have been
checked to see if they are slices. All expressions are also type
consistent, and all implicit type conversions in the AST are made
explicit here.
Some expression simplification and solving is also done here. This is used
for symbolic transformations before simulation, in order to rearrange
equations into a form needed by simulation tools. simplify, solve,
exp_contains, exp_equal are part of this code.
This module also contains functions for printing expressions, to io or to
strings. Also graphviz output is supported."
public import Absyn;
public import Graphviz;
public import SCode;
public import ClassInf;
public
type Ident = String "- Identifiers
Define `Ident\' as an alias for `string\' and use it for all
identifiers in Modelica." ;
public
uniontype Type "- 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 INT end INT;
record REAL end REAL;
record BOOL end BOOL;
record STRING end STRING;
record ENUM end ENUM;
record COMPLEX "Complex types"
String name;
list<Var> varLst;
ClassInf.State complexClassType;
end COMPLEX;
record OTHER "e.g. complex types, etc." end OTHER;
record T_RECORD
Ident name;
end T_RECORD;
record T_ARRAY
Type ty;
list<Option<Integer>> arrayDimensions "arrayDimensions" ;
end T_ARRAY;
// MetaModelica extension. KS
record T_LIST
Type ty;
end T_LIST;
record T_METATUPLE
list<Type> ty;
end T_METATUPLE;
record T_METAOPTION
Type ty;
end T_METAOPTION;
end Type;
uniontype Var "A variable is used to describe a complex type which contains a list of variables. See also Types.Var "
record COMPLEX_VAR
String name;
Type tp;
end COMPLEX_VAR;
end Var;
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;
record BCONST
Boolean bool "Bool constants" ;
end BCONST;
record CREF "component references, e.g. a.b{2}.c{1}"
ComponentRef componentRef;
Type ty;
end CREF;
record BINARY "Binary operations, e.g. a+4"
Exp exp1;
Operator operator;
Exp exp2;
end BINARY;
record UNARY "Unary operations, -(4x)"
Operator operator;
Exp exp;
end UNARY;
record LBINARY "Logical binary operations: and, or"
Exp exp1;
Operator operator;
Exp exp2;
end LBINARY;
record LUNARY "Logical unary operations: not"
Operator operator;
Exp exp;
end LUNARY;
record RELATION "Relation, e.g. a <= 0"
Exp exp1;
Operator operator;
Exp exp2;
end RELATION;
record IFEXP "If expressions"
Exp expCond;
Exp expThen;
Exp expElse;
end IFEXP;
record CALL
Absyn.Path path;
list<Exp> expLst;
Boolean tuple_ "tuple" ;
Boolean builtin "builtin Function call" ;
Type ty "The type of the return value, if several return values this is undefined";
end CALL;
record ARRAY
Type ty;
Boolean scalar "scalar for codegen" ;
list<Exp> array "Array constructor, e.g. {1,3,4}" ;
end ARRAY;
record MATRIX
Type ty;
Integer integer;
list<list<tuple<Exp, Boolean>>> scalar "scalar Matrix constructor. e.g. {1,0;0,1}" ;
end MATRIX;
record RANGE
Type ty;
Exp exp;
Option<Exp> expOption;
Exp range "Range constructor, e.g. 1:0.5:10" ;
end RANGE;
record TUPLE
list<Exp> PR "PR. Tuples, used in func calls returning several
arguments" ;
end TUPLE;
record CAST "Cast operator"
Type ty;
Exp exp;
end CAST;
record ASUB "Array subscripts"
Exp exp;
list<Exp> sub;
end ASUB;
record SIZE "The size operator"
Exp exp;
Option<Exp> sz;
end SIZE;
record CODE "Modelica AST constructor"
Absyn.CodeNode code;
Type ty;
end CODE;
record REDUCTION "e.g. sum(i*i+1) for i in 1:4"
Absyn.Path path "array, sum,..";
Exp expr "expr, e.g i*i+1" ;
Ident ident "e.g. i";
Exp range "range Reduction expression e.g. 1:4" ;
end REDUCTION;
record END "array index to last element, e.g. a{end}:=1;" end END;
record VALUEBLOCK "Valueblock expression"
Type ty;
list<DAEElement> localDecls;
DAEElement body;
Exp result;
end VALUEBLOCK;
/* Part of MetaModelica extension. KS */
record LIST "MetaModelica list"
Type ty;
list<Exp> valList;
end LIST;
record CONS "MetaModelica list cons"
Type ty;
Exp car;
Exp cdr;
end CONS;
record META_TUPLE
list<Exp> listExp;
end META_TUPLE;
record META_OPTION
Option<Exp> exp;
end META_OPTION;
/* --- */
end Exp;
public
uniontype Operator "Operators which are overloaded in the abstract syntax are here
made type-specific. The integer addition operator (`ADD(INT)\')
and the real addition operator (`ADD(REAL)\') are two distinct
operators."
record ADD
Type ty;
end ADD;
record SUB
Type ty;
end SUB;
record MUL
Type ty;
end MUL;
record DIV
Type ty;
end DIV;
record POW
Type ty;
end POW;
record UMINUS
Type ty;
end UMINUS;
record UPLUS
Type ty;
end UPLUS;
record UMINUS_ARR
Type ty;
end UMINUS_ARR;
record UPLUS_ARR
Type ty;
end UPLUS_ARR;
record ADD_ARR
Type ty;
end ADD_ARR;
record SUB_ARR
Type ty;
end SUB_ARR;
record MUL_ARR
Type ty;
end MUL_ARR;
record DIV_ARR
Type ty;
end DIV_ARR;
record MUL_SCALAR_ARRAY
Type ty "a { b, c }" ;
end MUL_SCALAR_ARRAY;
record MUL_ARRAY_SCALAR
Type ty "{a, b} c" ;
end MUL_ARRAY_SCALAR;
record ADD_SCALAR_ARRAY
Type ty "a { b, c }" ;
end ADD_SCALAR_ARRAY;
record ADD_ARRAY_SCALAR
Type ty "{a, b} c" ;
end ADD_ARRAY_SCALAR;
record SUB_SCALAR_ARRAY
Type ty "a { b, c }" ;
end SUB_SCALAR_ARRAY;
record SUB_ARRAY_SCALAR
Type ty "{a, b} c" ;
end SUB_ARRAY_SCALAR;
record MUL_SCALAR_PRODUCT
Type ty "{a, b} {c, d}" ;
end MUL_SCALAR_PRODUCT;
record MUL_MATRIX_PRODUCT
Type ty "{{..},..} {{..},{..}}" ;
end MUL_MATRIX_PRODUCT;
record DIV_ARRAY_SCALAR
Type ty "{a, b} / c" ;
end DIV_ARRAY_SCALAR;
record DIV_SCALAR_ARRAY
Type ty "a { b, c }" ;
end DIV_SCALAR_ARRAY;
record POW_ARRAY_SCALAR
Type ty "{a, b} / c" ;
end POW_ARRAY_SCALAR;
record POW_SCALAR_ARRAY
Type ty "a { b, c }" ;
end POW_SCALAR_ARRAY;
record POW_ARR
Type ty; /*Power of a matrix*/
end POW_ARR;
record POW_ARR2
Type ty; /*Elementwise power of arrays*/
end POW_ARR2;
record AND end AND;
record OR end OR;
record NOT end NOT;
record LESS
Type ty;
end LESS;
record LESSEQ
Type ty;
end LESSEQ;
record GREATER
Type ty;
end GREATER;
record GREATEREQ
Type ty;
end GREATEREQ;
record EQUAL
Type ty;
end EQUAL;
record NEQUAL
Type ty;
end NEQUAL;
record USERDEFINED
Absyn.Path fqName "The FQ name of the overloaded operator function" ;
end USERDEFINED;
end Operator;
public
uniontype ComponentRef "- Component references
CREF_QUAL(...) is used for qualified component names, e.g. a.b.c
CREF_IDENT(..) is used for non-qualifed component names, e.g. x
"
record CREF_QUAL
Ident ident;
Type identType;
list<Subscript> subscriptLst;
ComponentRef componentRef;
end CREF_QUAL;
record CREF_IDENT
Ident ident;
Type identType;
list<Subscript> subscriptLst;
end CREF_IDENT;
record WILD end WILD;
end ComponentRef;
public
uniontype Subscript "The `Subscript\' and `ComponentRef\' datatypes are simple
translations of the corresponding types in the `Absyn\' module."
record WHOLEDIM "a{:,1}" end WHOLEDIM;
record SLICE
Exp exp "a{1:3,1}, a{1:2:10,2}" ;
end SLICE;
record INDEX
Exp exp "a[i+1]" ;
end INDEX;
end Subscript;
//----------------------------------------------------------------------
// From types.mo - Part of a work-around to avoid circular dependencies
// (used by the valueblock expression)
//----------------------------------------------------------------------
public
uniontype VarTypes "- Variables"
record VARTYPES
Ident name "name" ;
AttributesTypes attributes "attributes" ;
Boolean protected_ "protected" ;
TypeTypes type_ "type" ;
BindingTypes binding "binding ; equation modification" ;
end VARTYPES;
end VarTypes;
public
uniontype AttributesTypes "- Attributes"
record ATTRTYPES
Boolean flowPrefix "flow" ;
Boolean streamPrefix "flow" ;
SCode.Accessibility accessibility "accessibility" ;
SCode.Variability parameter_ "parameter" ;
Absyn.Direction direction "direction" ;
end ATTRTYPES;
end AttributesTypes;
public
uniontype BindingTypes "- Binding"
record UNBOUND end UNBOUND;
record EQBOUND
Exp exp "exp" ;
Option<Value> evaluatedExp "evaluatedExp; evaluated exp" ;
ConstTypes constant_ "constant" ;
end EQBOUND;
record VALBOUND
Value valBound "valBound" ;
end VALBOUND;
end BindingTypes;
public
type TypeTypes = tuple<TTypeTypes, 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
uniontype TTypeTypes "-TType contains the actual type"
record T_INTEGERTYPES
list<VarTypes> varLstInt "varLstInt" ;
end T_INTEGERTYPES;
record T_REALTYPES
list<VarTypes> varLstReal "varLstReal" ;
end T_REALTYPES;
record T_STRINGTYPES
list<VarTypes> varLstString "varLstString" ;
end T_STRINGTYPES;
record T_BOOLTYPES
list<VarTypes> varLstBool "varLstBool" ;
end T_BOOLTYPES;
record T_LISTTYPES
TypeTypes listType "listType" ;
end T_LISTTYPES;
record T_METATUPLETYPES
list<TypeTypes> listType "listType" ;
end T_METATUPLETYPES;
record T_METAOPTIONTYPES
TypeTypes listType "listType" ;
end T_METAOPTIONTYPES;
record T_ENUMTYPES end T_ENUMTYPES;
record T_ENUMERATIONTYPES
list<String> names "names" ;
list<VarTypes> varLst "varLst" ;
end T_ENUMERATIONTYPES;
record T_ARRAYTYPES
ArrayDimTypes arrayDim "arrayDim" ;
TypeTypes arrayType "arrayType" ;
end T_ARRAYTYPES;
record T_COMPLEXTYPES
ClassInf.State complexClassType "complexClassType ; The type of. a class" ;
list<VarTypes> complexVarLst "complexVarLst ; The variables of a complex type" ;
Option<TypeTypes> complexTypeOption "complexTypeOption ; A complex type can be a subtype of another (primitive) type (through extends). In that case the varlist is empty" ;
end T_COMPLEXTYPES;
record T_FUNCTIONTYPES
list<FuncArgTypes> funcArg "funcArg" ;
TypeTypes funcResultType "funcResultType ; Only single-result" ;
end T_FUNCTIONTYPES;
record T_NOTYPETYPES "Used when type is not yet determined" end T_NOTYPETYPES;
record T_ANYTYPETYPES
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_ANYTYPETYPES;
end TTypeTypes;
public
uniontype ArrayDimTypes "- Array Dimensions"
record DIM
Option<Integer> integerOption;
end DIM;
end ArrayDimTypes;
public
type FuncArgTypes = tuple<Ident, TypeTypes> "- Function Argument" ;
public
uniontype ConstTypes "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;
end ConstTypes;
// Some aditional uniontypes from Types.mo may have to be added here
//--------------------------------------
//Values, from values.mo. Part of a work-around to avoid circular dependencies
// (used by the valueblock expression)
//--------------------------------------
public
uniontype Value
record INTEGERVAL
Integer integer;
end INTEGERVAL;
record REALVAL
Real real;
end REALVAL;
record STRINGVAL
String string;
end STRINGVAL;
record BOOLVAL
Boolean boolean;
end BOOLVAL;
record LISTVAL
list<Value> valueLst;
end LISTVAL;
record ENUMVAL
ComponentRef value;
end ENUMVAL;
record ARRAYVAL
list<Value> valueLst;
end ARRAYVAL;
record TUPLEVAL
list<Value> valueLst;
end TUPLEVAL;
record RECORDVAL
Absyn.Path record_ "record name" ;
list<Value> orderd "orderd set of values" ;
list<Ident> comp "comp names for each value" ;
end RECORDVAL;
record CODEVAL
Absyn.CodeNode A "A record consist of value Ident pairs" ;
end CODEVAL;
end Value;
// ------------
//---------------------------------------------------
// From DAE.mo Part of a work-around to avoid circular dependencies
// (used by the valueblock expression)
//---------------------------------------------------
public
type InstDims = list<Subscript>;
public
type StartValue = Option<Exp>;
public
uniontype VarKind
record VARIABLE end VARIABLE;
record DISCRETE end DISCRETE;
record PARAM end PARAM;
record CONST end CONST;
end VarKind;
public
uniontype TypeExp
record REALEXP end REALEXP;
record INTEXP end INTEXP;
record BOOLEXP end BOOLEXP;
record STRINGEXP end STRINGEXP;
record LISTEXP end LISTEXP;
record METATUPLEEXP end METATUPLEEXP;
record METAOPTIONEXP end METAOPTIONEXP;
record ENUMEXP end ENUMEXP;
record ENUMERATIONEXP
list<String> stringLst;
end ENUMERATIONEXP;
record EXT_OBJECTEXP
Absyn.Path fullClassName;
end EXT_OBJECTEXP;
end TypeExp;
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 end INPUT;
record OUTPUT end OUTPUT;
record BIDIR end BIDIR;
end VarDirection;
uniontype VarProtection
record PUBLIC "public variables" end PUBLIC;
record PROTECTED "protected variables" end PROTECTED;
end VarProtection;
public
uniontype DAEElement
record VAR
ComponentRef componentRef " The variable name";
VarKind kind "varible kind: variable, constant, parameter, etc." ;
VarDirection direction "input, output or bidir" ;
VarProtection protection "if protected or public";
TypeExp ty "one of the builtin types" ;
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" ;
list<Absyn.Path> pathLst " " ;
Option<VariableAttributes> variableAttributesOption;
Option<Absyn.Comment> absynCommentOption;
Absyn.InnerOuter innerOuter "inner/outer required to 'change' outer references";
TypeTypes fullType "Full type information required to analyze inner/outer elements";
end VAR;
record DEFINE "A solved equation"
ComponentRef componentRef;
Exp exp;
end DEFINE;
record INITIALDEFINE " A solved initial equation"
ComponentRef componentRef;
Exp exp;
end INITIALDEFINE;
record EQUATION "Scalar equation"
Exp exp;
Exp scalar ;
end EQUATION;
record ARRAY_EQUATION " an array equation"
list<Integer> dimension "dimension sizes" ;
Exp exp;
Exp array ;
end ARRAY_EQUATION;
record WHEN_EQUATION " a when equation"
Exp condition "Condition" ;
list<DAEElement> equations "Equations" ;
Option<DAEElement> elsewhen_ "Elsewhen should be of type WHEN_EQUATION" ;
end WHEN_EQUATION;
record IF_EQUATION " an if-equation"
list<Exp> condition1 "Condition" ;
list<list<DAEElement>> equations2 "Equations of true branch" ;
list<DAEElement> equations3 "Equations of false branch" ;
end IF_EQUATION;
record INITIAL_IF_EQUATION "An initial if-equation"
list<Exp> condition1 "Condition" ;
list<list<DAEElement>> equations2 "Equations of true branch" ;
list<DAEElement> equations3 "Equations of false branch" ;
end INITIAL_IF_EQUATION;
record INITIALEQUATION " An initial equaton"
Exp exp1;
Exp exp2;
end INITIALEQUATION;
record ALGORITHM " An algorithm section"
Algorithm algorithm_;
end ALGORITHM;
record INITIALALGORITHM " An initial algorithm section"
Algorithm algorithm_;
end INITIALALGORITHM;
record COMP
Ident ident;
DAElist dAElist "a component with
subelements, normally
only used at top level." ;
end COMP;
record FUNCTION " A Modelica function"
Absyn.Path path;
DAElist dAElist;
TypeTypes type_;
end FUNCTION;
record EXTFUNCTION "An external function"
Absyn.Path path;
DAElist dAElist;
TypeTypes type_;
ExternalDecl externalDecl;
end EXTFUNCTION;
record EXTOBJECTCLASS "The 'class' of an external object"
Absyn.Path path "className of external object";
DAEElement constructor "constructor is an EXTFUNCTION";
DAEElement destructor "destructor is an EXTFUNCTION";
end EXTOBJECTCLASS;
record ASSERT " The Modelica builtin assert"
Exp condition;
Exp message;
end ASSERT;
record REINIT " reinit operator for reinitialization of states"
ComponentRef componentRef;
Exp exp;
end REINIT;
end DAEElement;
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;
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" ;
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" ;
end VAR_ATTR_BOOL;
record VAR_ATTR_STRING
Option<Exp> quantity "quantity" ;
Option<Exp> initial_ "Initial value" ;
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" ;
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;
AttributesTypes attributes;
TypeTypes type_;
end EXTARG;
record EXTARGEXP
Exp exp;
TypeTypes type_;
end EXTARGEXP;
record EXTARGSIZE
ComponentRef componentRef;
AttributesTypes attributes;
TypeTypes 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<DAEElement> elementLst;
end DAE;
end DAElist;
//---------------------------------------------------
//From Algorithm.mo: Part of a work-around to avoid circular dependencies
// (used by the valueblock expression)
//---------------------------------------------------
public
uniontype Algorithm "The `Algorithm\' type corresponds to a whole algorithm section.
It is simple a list of algorithm statements."
record ALGORITHM2
list<Statement> statementLst;
end ALGORITHM2;
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 ASSIGN
Type type_;
Exp exp1;
Exp exp;
end ASSIGN;
record TUPLE_ASSIGN
Type type_;
list<Exp> expExpLst;
Exp exp;
end TUPLE_ASSIGN;
record ASSIGN_ARR
Type type_;
ComponentRef componentRef;
Exp exp;
end ASSIGN_ARR;
record IF
Exp exp;
list<Statement> statementLst;
Else else_;
end IF;
record FOR
Type type_;
Boolean boolean;
Ident ident;
Exp exp;
list<Statement> statementLst;
end FOR;
record WHILE
Exp exp;
list<Statement> statementLst;
end WHILE;
record WHEN