/
InstTypes.mo
423 lines (356 loc) · 11 KB
/
InstTypes.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
/*
* 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.
*
*/
encapsulated package InstTypes
" file: InstTypes.mo
package: InstTypes
description: Types used by SCodeInst.
RCS: $Id$
Types used by SCodeInst.
"
public import Absyn;
public import Connect2;
public import DAE;
public import SCode;
public import SCodeEnv;
public uniontype Prefix
record EMPTY_PREFIX
Option<Absyn.Path> classPath "The path of the class the prefix originates from.";
end EMPTY_PREFIX;
record PREFIX
String name;
DAE.Dimensions dims;
Prefix restPrefix;
end PREFIX;
end Prefix;
public constant Prefix emptyPrefix = EMPTY_PREFIX(NONE());
public constant Prefix functionPrefix = EMPTY_PREFIX(NONE());
public uniontype Element
record ELEMENT
Component component;
Class cls;
end ELEMENT;
record CONDITIONAL_ELEMENT
Component component;
end CONDITIONAL_ELEMENT;
record EXTENDED_ELEMENTS
Absyn.Path baseClass;
Class cls;
DAE.Type ty;
end EXTENDED_ELEMENTS;
end Element;
public uniontype Class
record COMPLEX_CLASS
Absyn.Path name;
list<Element> components;
list<Equation> equations;
list<Equation> initialEquations;
list<list<Statement>> algorithms;
list<list<Statement>> initialAlgorithms;
end COMPLEX_CLASS;
record BASIC_TYPE
Absyn.Path name;
end BASIC_TYPE;
end Class;
public uniontype Function
record FUNCTION "A function has inputs,output and locals without binding. These are resolved to statements in the algorithm section"
Absyn.Path path;
list<Element> inputs;
list<Element> outputs;
list<Element> locals;
list<Statement> algorithms "TODO: Add default bindings";
end FUNCTION;
record RECORD "A record has locals with bindings"
Absyn.Path path;
list<Element> components;
list<Statement> algorithms "TODO: Add default bindings";
end RECORD;
end Function;
public uniontype Dimension
record UNTYPED_DIMENSION
DAE.Dimension dimension;
Boolean isProcessing;
end UNTYPED_DIMENSION;
record TYPED_DIMENSION
DAE.Dimension dimension;
end TYPED_DIMENSION;
end Dimension;
public uniontype Binding
record UNBOUND end UNBOUND;
record RAW_BINDING
Absyn.Exp bindingExp;
SCodeEnv.Env env;
Prefix prefix;
Integer propagatedDims "See SCodeMod.propagateMod.";
Absyn.Info info;
end RAW_BINDING;
record UNTYPED_BINDING
DAE.Exp bindingExp;
Boolean isProcessing;
Integer propagatedDims "See SCodeMod.propagateMod.";
Absyn.Info info;
end UNTYPED_BINDING;
record TYPED_BINDING
DAE.Exp bindingExp;
DAE.Type bindingType;
Integer propagatedDims "See SCodeMod.propagateMod.";
Absyn.Info info;
end TYPED_BINDING;
end Binding;
public uniontype Component
record UNTYPED_COMPONENT
Absyn.Path name;
DAE.Type baseType;
array<Dimension> dimensions;
Prefixes prefixes;
ParamType paramType;
Binding binding;
Absyn.Info info;
end UNTYPED_COMPONENT;
record TYPED_COMPONENT
Absyn.Path name;
DAE.Type ty;
Option<Component> parent; //NO_COMPONENT?
DaePrefixes prefixes;
Binding binding;
Absyn.Info info;
end TYPED_COMPONENT;
record CONDITIONAL_COMPONENT
Absyn.Path name;
DAE.Exp condition;
SCode.Element element;
Modifier modifier;
Prefixes prefixes;
SCodeEnv.Env env;
Prefix prefix;
Absyn.Info info;
end CONDITIONAL_COMPONENT;
record DELETED_COMPONENT
Absyn.Path name;
end DELETED_COMPONENT;
record OUTER_COMPONENT
Absyn.Path name;
Option<Absyn.Path> innerName;
end OUTER_COMPONENT;
record PACKAGE
Absyn.Path name;
Option<Component> parent; //NO_COMPONENT?
end PACKAGE;
record COMPONENT_ALIAS
Absyn.Path componentName;
end COMPONENT_ALIAS;
end Component;
public uniontype Condition
record SINGLE_CONDITION
Boolean condition;
end SINGLE_CONDITION;
record ARRAY_CONDITION
list<Condition> conditions;
end ARRAY_CONDITION;
end Condition;
public uniontype ParamType
record NON_PARAM "Not a parameter." end NON_PARAM;
record NON_STRUCT_PARAM "A non-structural parameter." end NON_STRUCT_PARAM;
record STRUCT_PARAM "A structural parameter." end STRUCT_PARAM;
end ParamType;
public uniontype Modifier
record MODIFIER
String name;
SCode.Final finalPrefix;
SCode.Each eachPrefix;
Binding binding;
list<Modifier> subModifiers;
Absyn.Info info;
end MODIFIER;
record REDECLARE
SCode.Final finalPrefix;
SCode.Each eachPrefix;
SCode.Element element;
end REDECLARE;
record NOMOD end NOMOD;
end Modifier;
public uniontype Prefixes
record NO_PREFIXES end NO_PREFIXES;
record PREFIXES
SCode.Visibility visibility;
SCode.Variability variability;
SCode.Final finalPrefix;
Absyn.InnerOuter innerOuter;
tuple<Absyn.Direction, Absyn.Info> direction;
tuple<SCode.ConnectorType, Absyn.Info> connectorType;
VarArgs varArgs;
end PREFIXES;
end Prefixes;
public constant Prefixes DEFAULT_PROTECTED_PREFIXES = PREFIXES(
SCode.PROTECTED(), SCode.VAR(), SCode.NOT_FINAL(), Absyn.NOT_INNER_OUTER(),
(Absyn.BIDIR(), Absyn.dummyInfo), (SCode.POTENTIAL(), Absyn.dummyInfo), NO_VARARG());
public uniontype VarArgs
record NO_VARARG end NO_VARARG;
record IS_VARARG end IS_VARARG;
end VarArgs;
public uniontype DaePrefixes
record NO_DAE_PREFIXES end NO_DAE_PREFIXES;
record DAE_PREFIXES
DAE.VarVisibility visibility;
DAE.VarKind variability;
SCode.Final finalPrefix;
Absyn.InnerOuter innerOuter;
DAE.VarDirection direction;
DAE.ConnectorType connectorType;
end DAE_PREFIXES;
end DaePrefixes;
public constant DaePrefixes DEFAULT_CONST_DAE_PREFIXES = DAE_PREFIXES(
DAE.PUBLIC(), DAE.CONST(), SCode.NOT_FINAL(), Absyn.NOT_INNER_OUTER(),
DAE.BIDIR(), DAE.NON_CONNECTOR());
public uniontype Equation
record EQUALITY_EQUATION
DAE.Exp lhs "The left hand side expression.";
DAE.Exp rhs "The right hand side expression.";
Absyn.Info info;
end EQUALITY_EQUATION;
record CONNECT_EQUATION
DAE.ComponentRef lhs "The left hand side component.";
Connect2.Face lhsFace "The face of the lhs component, inside or outside.";
DAE.Type lhsType "The type of the lhs component.";
DAE.ComponentRef rhs "The right hand side component.";
Connect2.Face rhsFace "The face of the rhs component, inside or outside.";
DAE.Type rhsType "The type of the rhs component.";
Prefix prefix;
Absyn.Info info;
end CONNECT_EQUATION;
record FOR_EQUATION
String name "The name of the iterator variable.";
Integer index "The index of the iterator variable.";
DAE.Type indexType "The type of the index/iterator variable.";
Option<DAE.Exp> range "The range expression to loop over.";
list<Equation> body "The body of the for loop.";
Absyn.Info info;
end FOR_EQUATION;
record IF_EQUATION
list<tuple<DAE.Exp, list<Equation>>> branches
"List of branches, where each branch is a tuple of a condition and a body.";
Absyn.Info info;
end IF_EQUATION;
record WHEN_EQUATION
list<tuple<DAE.Exp, list<Equation>>> branches
"List of branches, where each branch is a tuple of a condition and a body.";
Absyn.Info info;
end WHEN_EQUATION;
record ASSERT_EQUATION
DAE.Exp condition "The assert condition.";
DAE.Exp message "The message to display if the assert fails.";
DAE.Exp level "Error or warning";
Absyn.Info info;
end ASSERT_EQUATION;
record TERMINATE_EQUATION
DAE.Exp message "The message to display if the terminate triggers.";
Absyn.Info info;
end TERMINATE_EQUATION;
record REINIT_EQUATION
DAE.ComponentRef cref "The variable to reinitialize.";
DAE.Exp reinitExp "The new value of the variable.";
Absyn.Info info;
end REINIT_EQUATION;
record NORETCALL_EQUATION
DAE.Exp exp;
Absyn.Info info;
end NORETCALL_EQUATION;
end Equation;
public uniontype Statement
record ASSIGN_STMT
DAE.Exp lhs "The asignee";
DAE.Exp rhs "The expression";
Absyn.Info info;
end ASSIGN_STMT;
record FUNCTION_ARRAY_INIT "Used to mark in which order local array variables in functions should be initialized"
String name;
DAE.Type ty;
Absyn.Info info;
end FUNCTION_ARRAY_INIT;
record FOR_STMT
String name "The name of the iterator variable.";
Integer index "The index of the scope of the iterator variable.";
DAE.Type indexType "The type of the index/iterator variable.";
Option<DAE.Exp> range "The range expression to loop over.";
list<Statement> body "The body of the for loop.";
Absyn.Info info;
end FOR_STMT;
record IF_STMT
list<tuple<DAE.Exp, list<Statement>>> branches
"List of branches, where each branch is a tuple of a condition and a body.";
Absyn.Info info;
end IF_STMT;
record WHEN_STMT
list<tuple<DAE.Exp, list<Statement>>> branches
"List of branches, where each branch is a tuple of a condition and a body.";
Absyn.Info info;
end WHEN_STMT;
record ASSERT_STMT
DAE.Exp condition "The assert condition.";
DAE.Exp message "The message to display if the assert fails.";
Absyn.Info info;
end ASSERT_STMT;
record TERMINATE_STMT
DAE.Exp message "The message to display if the terminate triggers.";
Absyn.Info info;
end TERMINATE_STMT;
record REINIT_STMT
DAE.ComponentRef cref "The variable to reinitialize.";
DAE.Exp reinitExp "The new value of the variable.";
Absyn.Info info;
end REINIT_STMT;
record NORETCALL_STMT
DAE.Exp exp;
Absyn.Info info;
end NORETCALL_STMT;
record WHILE_STMT
DAE.Exp exp;
list<Statement> statementLst;
Absyn.Info info;
end WHILE_STMT;
record RETURN_STMT
Absyn.Info info;
end RETURN_STMT;
record BREAK_STMT
Absyn.Info info;
end BREAK_STMT;
record FAILURE_STMT
list<Statement> body;
Absyn.Info info;
end FAILURE_STMT;
end Statement;
public uniontype FunctionSlot
record SLOT
String name;
Option<DAE.Exp> arg;
Option<DAE.Exp> defaultValue;
end SLOT;
end FunctionSlot;
end InstTypes;