/
SimCodeTV.mo
2647 lines (2294 loc) · 68.6 KB
/
SimCodeTV.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
interface package SimCodeTV
package builtin
function listReverse
replaceable type TypeVar subtypeof Any;
input list<TypeVar> lst;
output list<TypeVar> result;
end listReverse;
function listLength "Return the length of the list"
replaceable type TypeVar subtypeof Any;
input list<TypeVar> lst;
output Integer result;
end listLength;
function listNth
replaceable type TypeVar subtypeof Any;
input list<TypeVar> lst;
input Integer ix;
output TypeVar result;
end listNth;
function intAdd
input Integer a;
input Integer b;
output Integer c;
end intAdd;
function boolAnd
input Boolean b1;
input Boolean b2;
output Boolean b;
end boolAnd;
function boolOr
input Boolean a;
input Boolean b;
output Boolean c;
end boolOr;
function boolNot
input Boolean b;
output Boolean nb;
end boolNot;
function intSub
input Integer a;
input Integer b;
output Integer c;
end intSub;
function intMul
input Integer a;
input Integer b;
output Integer c;
end intMul;
function intDiv
input Integer a;
input Integer b;
output Integer c;
end intDiv;
function intEq
input Integer a;
input Integer b;
output Boolean c;
end intEq;
function arrayList
replaceable type TypeVar subtypeof Any;
input TypeVar[:] arr;
output list<TypeVar> lst;
end arrayList;
function stringEq
input String s1;
input String s2;
output Boolean b;
end stringEq;
end builtin;
package SimCode
type ExtConstructor = tuple<DAE.ComponentRef, String, list<DAE.Exp>>;
type ExtDestructor = tuple<String, DAE.ComponentRef>;
type ExtAlias = tuple<DAE.ComponentRef, DAE.ComponentRef>;
type HelpVarInfo = tuple<Integer, DAE.Exp, Integer>;
type SampleCondition = tuple<DAE.Exp,Integer>; // helpvarindex, expression,
type JacobianColumn = tuple<list<SimEqSystem>, list<SimVar>, String>; // column equations, column vars, column length
type JacobianMatrix = tuple<list<JacobianColumn>, // column
list<SimVar>, // seed vars
String, // matrix name
list<list<Integer>>, // sparse pattern
list<Integer>, // colored cols
Integer>; // max color used
uniontype SimCode
record SIMCODE
ModelInfo modelInfo;
list<DAE.Exp> literals;
list<RecordDeclaration> recordDecls;
list<String> externalFunctionIncludes;
list<SimEqSystem> allEquations;
list<list<SimEqSystem>> odeEquations;
list<SimEqSystem> algebraicEquations;
list<SimEqSystem> residualEquations;
list<SimEqSystem> startValueEquations;
list<SimEqSystem> parameterEquations;
list<SimEqSystem> removedEquations;
list<SimEqSystem> algorithmAndEquationAsserts;
//list<DAE.Statement> algorithmAndEquationAsserts;
list<DAE.Constraint> constraints;
list<BackendDAE.ZeroCrossing> zeroCrossings;
list<list<SimVar>> zeroCrossingsNeedSave;
list<SampleCondition> sampleConditions;
list<SimEqSystem> sampleEquations;
list<HelpVarInfo> helpVarInfo;
list<SimWhenClause> whenClauses;
list<DAE.ComponentRef> discreteModelVars;
ExtObjInfo extObjInfo;
MakefileParams makefileParams;
DelayedExpression delayedExps;
list<JacobianMatrix> jacobianMatrixes;
Option<SimulationSettings> simulationSettingsOpt;
String fileNamePrefix;
end SIMCODE;
end SimCode;
uniontype DelayedExpression
record DELAYED_EXPRESSIONS
list<tuple<Integer, DAE.Exp>> delayedExps;
Integer maxDelayedIndex;
end DELAYED_EXPRESSIONS;
end DelayedExpression;
uniontype FunctionCode
record FUNCTIONCODE
String name;
Option<Function> mainFunction;
list<Function> functions;
list<DAE.Exp> literals;
list<String> externalFunctionIncludes;
MakefileParams makefileParams;
list<RecordDeclaration> extraRecordDecls;
end FUNCTIONCODE;
end FunctionCode;
uniontype MakefileParams
record MAKEFILE_PARAMS
String ccompiler;
String cxxcompiler;
String linker;
String exeext;
String dllext;
String omhome;
String cflags;
String ldflags;
String runtimelibs;
list<String> includes;
list<String> libs;
String platform;
end MAKEFILE_PARAMS;
end MakefileParams;
uniontype SimulationSettings
record SIMULATION_SETTINGS
Real startTime;
Real stopTime;
Integer numberOfIntervals;
Real stepSize;
Real tolerance;
String method;
String options;
String outputFormat;
String variableFilter;
Boolean measureTime;
String cflags;
end SIMULATION_SETTINGS;
end SimulationSettings;
uniontype Context
record SIMULATION
Boolean genDiscrete;
end SIMULATION;
record FUNCTION_CONTEXT
end FUNCTION_CONTEXT;
record ALGLOOP_CONTEXT
end ALGLOOP_CONTEXT;
record OTHER
end OTHER;
record INLINE_CONTEXT
end INLINE_CONTEXT;
record PARALLEL_FUNCTION_CONTEXT
end PARALLEL_FUNCTION_CONTEXT;
end Context;
uniontype Variable
record VARIABLE
DAE.ComponentRef name;
DAE.Type ty;
Option<DAE.Exp> value;
list<DAE.Exp> instDims;
DAE.VarParallelism parallelism;
end VARIABLE;
record FUNCTION_PTR
String name;
list<DAE.Type> tys;
list<Variable> args;
end FUNCTION_PTR;
end Variable;
uniontype Statement
record ALGORITHM
list<DAE.Statement> statementLst;
end ALGORITHM;
end Statement;
uniontype ExtObjInfo
record EXTOBJINFO
list<SimVar> vars;
list<ExtAlias> aliases;
end EXTOBJINFO;
end ExtObjInfo;
uniontype SimEqSystem
record SES_RESIDUAL
Integer index;
DAE.Exp exp;
DAE.ElementSource source;
end SES_RESIDUAL;
record SES_SIMPLE_ASSIGN
Integer index;
DAE.ComponentRef cref;
DAE.Exp exp;
DAE.ElementSource source;
end SES_SIMPLE_ASSIGN;
record SES_ARRAY_CALL_ASSIGN
Integer index;
DAE.ComponentRef componentRef;
DAE.Exp exp;
DAE.ElementSource source;
end SES_ARRAY_CALL_ASSIGN;
record SES_ALGORITHM
Integer index;
list<DAE.Statement> statements;
end SES_ALGORITHM;
record SES_LINEAR
Integer index;
Boolean partOfMixed;
list<SimVar> vars;
list<DAE.Exp> beqs;
list<tuple<Integer, Integer, SimEqSystem>> simJac;
end SES_LINEAR;
record SES_NONLINEAR
Integer index;
list<SimEqSystem> eqs;
list<DAE.ComponentRef> crefs;
end SES_NONLINEAR;
record SES_MIXED
Integer index;
SimEqSystem cont;
list<SimVar> discVars;
list<SimEqSystem> discEqs;
list<Integer> values;
list<Integer> value_dims;
end SES_MIXED;
record SES_WHEN
Integer index;
DAE.ComponentRef left;
DAE.Exp right;
list<tuple<DAE.Exp, Integer>> conditions;
Option<SimEqSystem> elseWhen;
DAE.ElementSource source;
end SES_WHEN;
end SimEqSystem;
uniontype SimWhenClause
record SIM_WHEN_CLAUSE
list<DAE.ComponentRef> conditionVars;
list<BackendDAE.WhenOperator> reinits;
Option<BackendDAE.WhenEquation> whenEq;
list<tuple<DAE.Exp, Integer>> conditions;
end SIM_WHEN_CLAUSE;
end SimWhenClause;
uniontype ModelInfo
record MODELINFO
Absyn.Path name;
String directory;
VarInfo varInfo;
SimVars vars;
list<Function> functions;
list<String> labels;
end MODELINFO;
end ModelInfo;
uniontype FunctionInfo
record FUNCTIONINFO
Absyn.Path name;
Absyn.Info info;
end FUNCTIONINFO;
end FunctionInfo;
uniontype VarInfo
record VARINFO
Integer numHelpVars;
Integer numZeroCrossings;
Integer numTimeEvents;
Integer numStateVars;
Integer numAlgVars;
Integer numIntAlgVars;
Integer numBoolAlgVars;
Integer numAlgAliasVars;
Integer numIntAliasVars;
Integer numBoolAliasVars;
Integer numParams;
Integer numIntParams;
Integer numBoolParams;
Integer numOutVars;
Integer numInVars;
Integer numInitialEquations;
Integer numInitialAlgorithms;
Integer numInitialResiduals;
Integer numExternalObjects;
Integer numStringAlgVars;
Integer numStringParamVars;
Integer numStringAliasVars;
Integer numJacobianVars;
Option <Integer> dimODE1stOrder;
Option <Integer> dimODE2ndOrder;
end VARINFO;
end VarInfo;
uniontype SimVars
record SIMVARS
list<SimVar> stateVars;
list<SimVar> derivativeVars;
list<SimVar> algVars;
list<SimVar> intAlgVars;
list<SimVar> boolAlgVars;
list<SimVar> inputVars;
list<SimVar> outputVars;
list<SimVar> aliasVars;
list<SimVar> intAliasVars;
list<SimVar> boolAliasVars;
list<SimVar> paramVars;
list<SimVar> intParamVars;
list<SimVar> boolParamVars;
list<SimVar> stringAlgVars;
list<SimVar> stringParamVars;
list<SimVar> stringAliasVars;
list<SimVar> extObjVars;
list<SimVar> jacobianVars; //all vars for the matrices A,B,C,D
list<SimVar> constVars;
list<SimVar> intConstVars;
list<SimVar> boolConstVars;
list<SimVar> stringConstVars;
end SIMVARS;
end SimVars;
uniontype SimVar
record SIMVAR
DAE.ComponentRef name;
BackendDAE.VarKind varKind;
String comment;
String unit;
String displayUnit;
Integer index;
Option<DAE.Exp> minValue;
Option<DAE.Exp> maxValue;
Option<DAE.Exp> initialValue;
Option<DAE.Exp> nominalValue;
Boolean isFixed;
DAE.Type type_;
Boolean isDiscrete;
Option<DAE.ComponentRef> arrayCref;
AliasVariable aliasvar;
DAE.ElementSource source;
Causality causality;
Option<Integer> variable_index;
list<String> numArrayElement;
end SIMVAR;
end SimVar;
uniontype AliasVariable
record NOALIAS end NOALIAS;
record ALIAS
DAE.ComponentRef varName;
end ALIAS;
record NEGATEDALIAS
DAE.ComponentRef varName;
end NEGATEDALIAS;
end AliasVariable;
uniontype Causality
record NONECAUS end NONECAUS;
record INTERNAL end INTERNAL;
record OUTPUT end OUTPUT;
record INPUT end INPUT;
end Causality;
uniontype Function
record FUNCTION
Absyn.Path name;
list<Variable> outVars;
list<Variable> functionArguments;
list<Variable> variableDeclarations;
list<Statement> body;
Absyn.Info info;
end FUNCTION;
record PARALLEL_FUNCTION
Absyn.Path name;
list<Variable> outVars;
list<Variable> functionArguments;
list<Variable> variableDeclarations;
list<Statement> body;
Absyn.Info info;
end PARALLEL_FUNCTION;
record KERNEL_FUNCTION
Absyn.Path name;
list<Variable> outVars;
list<Variable> functionArguments;
list<Variable> variableDeclarations;
list<Statement> body;
Absyn.Info info;
end KERNEL_FUNCTION;
record EXTERNAL_FUNCTION
Absyn.Path name;
String extName;
list<Variable> funArgs;
list<SimExtArg> extArgs;
SimExtArg extReturn;
list<Variable> inVars;
list<Variable> outVars;
list<Variable> biVars;
list<String> libs;
String language;
Absyn.Info info;
Boolean dynamicLoad;
end EXTERNAL_FUNCTION;
record RECORD_CONSTRUCTOR
Absyn.Path name;
list<Variable> funArgs;
Absyn.Info info;
end RECORD_CONSTRUCTOR;
end Function;
uniontype RecordDeclaration
record RECORD_DECL_FULL
String name;
Absyn.Path defPath;
list<Variable> variables;
end RECORD_DECL_FULL;
record RECORD_DECL_DEF
Absyn.Path path;
list<String> fieldNames;
end RECORD_DECL_DEF;
end RecordDeclaration;
uniontype SimExtArg
record SIMEXTARG
DAE.ComponentRef cref;
Boolean isInput;
Integer outputIndex;
Boolean isArray;
Boolean hasBinding;
DAE.Type type_;
end SIMEXTARG;
record SIMEXTARGEXP
DAE.Exp exp;
DAE.Type type_;
end SIMEXTARGEXP;
record SIMEXTARGSIZE
DAE.ComponentRef cref;
Boolean isInput;
Integer outputIndex;
DAE.Type type_;
DAE.Exp exp;
end SIMEXTARGSIZE;
record SIMNOEXTARG end SIMNOEXTARG;
end SimExtArg;
constant Context contextSimulationNonDiscrete;
constant Context contextSimulationDiscrete;
constant Context contextInlineSolver;
constant Context contextFunction;
constant Context contextOther;
constant Context contextAlgloop;
constant Context contextParallelFunction;
constant list<DAE.Exp> listExpLength1;
end SimCode;
package SimCodeUtil
function elementVars
input list<DAE.Element> ld;
output list<SimCode.Variable> vars;
end elementVars;
function crefSubIsScalar
input DAE.ComponentRef cref;
output Boolean isScalar;
end crefSubIsScalar;
function crefNoSub
input DAE.ComponentRef cref;
output Boolean noSub;
end crefNoSub;
function crefIsScalar
input DAE.ComponentRef cref;
input SimCode.Context context;
output Boolean isScalar;
end crefIsScalar;
function buildCrefExpFromAsub
input DAE.Exp cref;
input list<DAE.Exp> subs;
output DAE.Exp cRefOut;
end buildCrefExpFromAsub;
function incrementInt
input Integer inInt;
input Integer increment;
output Integer outInt;
end incrementInt;
function decrementInt
input Integer inInt;
input Integer decrement;
output Integer outInt;
end decrementInt;
function makeCrefRecordExp
input DAE.ComponentRef inCRefRecord;
input DAE.Var inVar;
output DAE.Exp outExp;
end makeCrefRecordExp;
function cref2simvar
input DAE.ComponentRef cref;
input SimCode.SimCode simCode;
output SimCode.SimVar outSimVar;
end cref2simvar;
function derComponentRef
input DAE.ComponentRef inCref;
output DAE.ComponentRef derCref;
end derComponentRef;
function hackArrayReverseToCref
input DAE.Exp inExp;
input SimCode.Context context;
output DAE.Exp outExp;
end hackArrayReverseToCref;
function hackGetFirstExternalFunctionLib
input list<String> libs;
output String outFirstLib;
end hackGetFirstExternalFunctionLib;
function hackMatrixReverseToCref
input DAE.Exp inExp;
input SimCode.Context context;
output DAE.Exp outExp;
end hackMatrixReverseToCref;
function createArray
input Integer size;
output DAE.Exp outArray;
end createArray;
function createAssertforSqrt
input DAE.Exp inExp;
output DAE.Exp outExp;
end createAssertforSqrt;
function appendAllequations
input list<SimCode.JacobianMatrix> inJacobianMatrix;
output list<SimCode.SimEqSystem> eqn;
end appendAllequations;
function appendLists
input list<SimCode.SimEqSystem> inEqn1;
input list<SimCode.SimEqSystem> inEqn2;
output list<SimCode.SimEqSystem> outEqn;
end appendLists;
function createDAEString
input String inString;
output DAE.Exp outExp;
end createDAEString;
function isBoxedFunction
input SimCode.Function fn;
output Boolean b;
end isBoxedFunction;
function functionInfo
input SimCode.Function fn;
output Absyn.Info info;
end functionInfo;
function twodigit
input Integer i;
output String s;
end twodigit;
function countDynamicExternalFunctions
input list<SimCode.Function> inFncLst;
output Integer outDynLoadFuncs;
end countDynamicExternalFunctions;
function eqInfo
input SimCode.SimEqSystem eq;
output Absyn.Info info;
end eqInfo;
function varName
input SimCode.SimVar var;
output DAE.ComponentRef cr;
end varName;
end SimCodeUtil;
package BackendDAE
uniontype VarKind "- Variabile kind"
record VARIABLE end VARIABLE;
record STATE end STATE;
record STATE_DER end STATE_DER;
record DUMMY_DER end DUMMY_DER;
record DUMMY_STATE end DUMMY_STATE;
record DISCRETE end DISCRETE;
record PARAM end PARAM;
record CONST end CONST;
record EXTOBJ Absyn.Path fullClassName; end EXTOBJ;
end VarKind;
uniontype ZeroCrossing
record ZERO_CROSSING
DAE.Exp relation_;
list<Integer> occurEquLst;
list<Integer> occurWhenLst;
end ZERO_CROSSING;
end ZeroCrossing;
uniontype WhenOperator "- Reinit Statement"
record REINIT
DAE.ComponentRef stateVar "State variable to reinit" ;
DAE.Exp value "Value after reinit" ;
DAE.ElementSource source "origin of equation";
end REINIT;
record ASSERT
DAE.Exp condition;
DAE.Exp message;
DAE.ElementSource source "the origin of the component/equation/algorithm";
end ASSERT;
record TERMINATE " The Modelica builtin terminate(msg)"
DAE.Exp message;
DAE.ElementSource source "the origin of the component/equation/algorithm";
end TERMINATE;
end WhenOperator;
uniontype WhenEquation
record WHEN_EQ
Integer index;
DAE.ComponentRef left;
DAE.Exp right;
Option<WhenEquation> elsewhenPart;
end WHEN_EQ;
end WhenEquation;
end BackendDAE;
package System
function stringReplace
input String str;
input String source;
input String target;
output String res;
end stringReplace;
function tmpTick
output Integer tickNo;
end tmpTick;
function tmpTickReset
input Integer start;
end tmpTickReset;
function tmpTickIndex
input Integer index;
output Integer tickNo;
end tmpTickIndex;
function parForTick
"returns a tick that can be reset. used to uniquely identify parallel for loops.
parfor loops are generated in two rounds. We need to match them."
output Integer tickNo;
end parForTick;
function parForTickReset
"Resets parfor loop id for second round"
input Integer start;
end parForTickReset;
function tmpTickIndexReserve
input Integer index;
input Integer reserve;
output Integer tickNo;
end tmpTickIndexReserve;
function tmpTickResetIndex
input Integer start;
input Integer index;
end tmpTickResetIndex;
function getCurrentTimeStr
output String timeStr;
end getCurrentTimeStr;
function getUUIDStr
output String uuidStr;
end getUUIDStr;
function unescapedStringLength "Return the length of a C string literal"
input String s;
output Integer result;
end unescapedStringLength;
function stringHashDjb2Mod
input String str;
input Integer mod;
output Integer hash;
end stringHashDjb2Mod;
function escapedString
input String unescapedString;
input Boolean unescapeNewline;
output String escapedString;
end escapedString;
function unquoteIdentifier
input String str;
output String outStr;
end unquoteIdentifier;
function os
output String str;
end os;
end System;
package Tpl
function textFile
input Text inText;
input String inFileName;
end textFile;
//we do not import Error.addSourceMessage() directly
//because of list creation in Susan is not possible (yet by design)
function addSourceTemplateError
"Wraps call to Error.addSourceMessage() funtion with Error.TEMPLATE_ERROR and one MessageToken."
input String inErrMsg;
input Absyn.Info inInfo;
end addSourceTemplateError;
//for completeness; although the addSourceTemplateError() above is preferable
function addTemplateError
"Wraps call to Error.addMessage() funtion with Error.TEMPLATE_ERROR and one MessageToken."
input String inErrMsg;
end addTemplateError;
end Tpl;
package Absyn
type Ident = String;
uniontype Path
record QUALIFIED
Ident name;
Path path;
end QUALIFIED;
record IDENT
String name;
end IDENT;
record FULLYQUALIFIED
Path path;
end FULLYQUALIFIED;
end Path;
uniontype Info
record INFO
String fileName;
Boolean isReadOnly;
Integer lineNumberStart;
Integer columnNumberStart;
Integer lineNumberEnd;
Integer columnNumberEnd;
end INFO;
end Info;
uniontype Within "Within Clauses"
record WITHIN "the within clause"
Path path "the path for within";
end WITHIN;
record TOP end TOP;
end Within;
constant Info dummyInfo;
end Absyn;
package DAE
type Ident = String;
uniontype VarKind
record VARIABLE "variable" end VARIABLE;
record DISCRETE "discrete" end DISCRETE;
record PARAM "parameter" end PARAM;
record CONST "constant" end CONST;
// back-end dae variable kinds
record STATE end STATE;
record STATE_DER end STATE_DER;
record DUMMY_DER end DUMMY_DER;
record DUMMY_STATE end DUMMY_STATE;
record EXTOBJ Absyn.Path fullClassName; end EXTOBJ;
end VarKind;
uniontype Exp
record ICONST
Integer integer;
end ICONST;
record RCONST
Real real;
end RCONST;
record SCONST
String string;
end SCONST;
record BCONST
Boolean bool;
end BCONST;
record ENUM_LITERAL
Absyn.Path name;
Integer index;
end ENUM_LITERAL;
record CREF
ComponentRef componentRef;
Type ty;
end CREF;
record BINARY
Exp exp1;
Operator operator;
Exp exp2;
end BINARY;
record UNARY
Operator operator;
Exp exp;
end UNARY;
record LBINARY
Exp exp1;
Operator operator;
Exp exp2;
end LBINARY;
record LUNARY
Operator operator;
Exp exp;
end LUNARY;
record RELATION
Exp exp1;
Operator operator;
Exp exp2;
Integer index;
Option<tuple<DAE.Exp,Integer,Integer>> optionExpisASUB;
end RELATION;
record IFEXP
Exp expCond;
Exp expThen;
Exp expElse;
end IFEXP;
record CALL
Absyn.Path path;
list<Exp> expLst;
CallAttributes attr;
end CALL;
record ARRAY
Type ty;
Boolean scalar;
list<Exp> array;
end ARRAY;
record MATRIX
Type ty;
Integer integer;
list<list<Exp>> matrix;
end MATRIX;
record RANGE
Type ty;
Exp start;
Option<Exp> step;
Exp stop;
end RANGE;
record TUPLE
list<Exp> PR;
end TUPLE;
record CAST
Type ty;
Exp exp;
end CAST;
record ASUB
Exp exp;
list<Exp> sub;
end ASUB;
record TSUB
Exp exp;
Integer index;
Type ty;
end TSUB;
record SIZE
Exp exp;
Option<Exp> sz;
end SIZE;
record CODE
Absyn.CodeNode code;
Type ty;
end CODE;
record REDUCTION
ReductionInfo reductionInfo;
Exp expr;
ReductionIterators iterators;
end REDUCTION;
record LIST
list<Exp> valList;
end LIST;
record CONS
Exp car;
Exp cdr;
end CONS;
record META_TUPLE
list<Exp> listExp;
end META_TUPLE;
record META_OPTION
Option<Exp> exp;
end META_OPTION;
record METARECORDCALL
Absyn.Path path;
list<Exp> args;
list<String> fieldNames;
Integer index;
end METARECORDCALL;
record MATCHEXPRESSION
DAE.MatchType matchType;
list<Exp> inputs;
list<Element> localDecls;
list<MatchCase> cases;
Type et;
end MATCHEXPRESSION;
record BOX
Exp exp;
end BOX;
record UNBOX
Exp exp;
Type ty;
end UNBOX;
record SHARED_LITERAL
Integer index;
Type ty;
end SHARED_LITERAL;
record PATTERN
Pattern pattern;
end PATTERN;
end Exp;
uniontype CallAttributes
record CALL_ATTR
Type ty "The type of the return value, if several return values this is undefined";
Boolean tuple_ "tuple" ;
Boolean builtin "builtin Function call" ;
InlineType inlineType;
TailCall tailCall "Input variables of the function if the call is tail-recursive";
end CALL_ATTR;
end CallAttributes;