@@ -52,6 +52,11 @@ protected import RTOpts;
52
52
protected import Util ;
53
53
54
54
55
+ /** *************************************************/
56
+ /* Generate */
57
+ /** *************************************************/
58
+
59
+
55
60
public function makeCrefIdent
56
61
"@author: adrpo
57
62
This function creates a DAE.CREF_IDENT(ident, identType, subscriptLst)"
@@ -75,31 +80,10 @@ algorithm
75
80
outCrefQual := DAE . CREF_QUAL (ident, identType, subscriptLst, componentRef);
76
81
end makeCrefQual;
77
82
78
- public function crefPrependIdent "prepends (e..g as a suffix) an identifier to a component reference, given the identifier, subscript and the type
79
- author: PA
80
-
81
- Example
82
- crefPrependIdent(a.b,c,{},Real) => a.b.c [Real]
83
- crefPrependIdent(a,c,{1},Integer[1]) => a.c[1] [Integer[1]]
84
-
85
- alternative names: crefAddSuffix, crefAddIdent
86
- "
87
- input DAE . ComponentRef cr;
88
- input String ident;
89
- input list< DAE . Subscript > subs;
90
- input DAE . ExpType tp;
91
- output DAE . ComponentRef newCr;
92
- algorithm
93
- newCr := matchcontinue(cr,ident,subs,tp)
94
- local DAE . ExpType tp1; String id1; list< DAE . Subscript > subs1;
95
- case (DAE . CREF_IDENT (id1,tp1,subs1),ident,subs,tp) then DAE . CREF_QUAL (id1,tp1,subs1,DAE . CREF_IDENT (ident,tp,subs));
96
- case (DAE . CREF_QUAL (id1,tp1,subs1,cr),ident,subs,tp)
97
- equation
98
- cr = crefPrependIdent(cr,ident,subs,tp);
99
- then DAE . CREF_QUAL (id1,tp1,subs1,cr);
100
- end matchcontinue;
101
- end crefPrependIdent;
102
83
84
+ /** *************************************************/
85
+ /* Transform */
86
+ /** *************************************************/
103
87
104
88
public function crefToPath
105
89
"function: crefToPath
@@ -146,6 +130,59 @@ algorithm
146
130
end matchcontinue;
147
131
end pathToCref;
148
132
133
+ public function crefToStr
134
+ "function: crefStr
135
+ This function converts a ComponentRef to a String.
136
+ It is a tail recursive implementation, because of that it
137
+ neads inPreString. Use inNameSeperator to define the
138
+ Separator inbetween and between the namespace names and the name"
139
+ input String inPreString;
140
+ input DAE . ComponentRef inComponentRef "The ComponentReference" ;
141
+ input String inNameSeparator "The Separator between the Names" ;
142
+ output String outString;
143
+ algorithm
144
+ outString:=
145
+ matchcontinue (inPreString,inComponentRef,inNameSeparator)
146
+ local
147
+ DAE . Ident s,ns,s1,ss;
148
+ DAE . ComponentRef n;
149
+ case (inPreString,DAE . CREF_IDENT (ident = s),_)
150
+ equation
151
+ ss = stringAppend(inPreString, s);
152
+ then ss;
153
+ case (inPreString,DAE . CREF_QUAL (ident = s,componentRef = n),inNameSeparator)
154
+ equation
155
+ ns = System . stringAppendList({inPreString, s, inNameSeparator});
156
+ ss = crefToStr(ns,n,inNameSeparator);
157
+ then
158
+ ss;
159
+ end matchcontinue;
160
+ end crefToStr;
161
+
162
+ public function crefStr
163
+ "function: crefStr
164
+ This function simply converts a ComponentRef to a String."
165
+ input DAE . ComponentRef inComponentRef;
166
+ output String outString;
167
+ algorithm
168
+ outString:= crefToStr("" ,inComponentRef,"." );
169
+ end crefStr;
170
+
171
+ public function crefModelicaStr
172
+ "function: crefModelicaStr
173
+ Same as crefStr, but uses _ instead of . "
174
+ input DAE . ComponentRef inComponentRef;
175
+ output String outString;
176
+ algorithm
177
+ outString:= crefToStr("" ,inComponentRef,"_" );
178
+ end crefModelicaStr;
179
+
180
+
181
+ /** *************************************************/
182
+ /* Get Items */
183
+ /** *************************************************/
184
+
185
+
149
186
public function crefLastPath
150
187
"Returns the last identifier of a cref as an Absyn.IDENT."
151
188
input DAE . ComponentRef inComponentRef;
@@ -200,6 +237,72 @@ algorithm
200
237
end matchcontinue;
201
238
end crefLastCref;
202
239
240
+ public function crefSubs "
241
+ function: crefSubs
242
+ Return the all subscripts of a ComponentRef"
243
+ input DAE . ComponentRef inComponentRef;
244
+ output list< DAE . Subscript > outSubscriptLst;
245
+ algorithm
246
+ outSubscriptLst:=
247
+ matchcontinue (inComponentRef)
248
+ local
249
+ DAE . Ident id;
250
+ list< DAE . Subscript > subs,res;
251
+ DAE . ComponentRef cr;
252
+ case (DAE . CREF_IDENT (ident = id,subscriptLst = subs))
253
+ then subs;
254
+ case (DAE . CREF_QUAL (componentRef = cr,subscriptLst= subs))
255
+ equation
256
+ res = crefSubs(cr);
257
+ res = listAppend(subs,res);
258
+ then
259
+ res;
260
+ end matchcontinue;
261
+ end crefSubs;
262
+
263
+ public function crefLastSubs "
264
+ function: crefLastSubs
265
+ Return the last subscripts of a ComponentRef"
266
+ input DAE . ComponentRef inComponentRef;
267
+ output list< DAE . Subscript > outSubscriptLst;
268
+ algorithm
269
+ outSubscriptLst:=
270
+ matchcontinue (inComponentRef)
271
+ local
272
+ DAE . Ident id;
273
+ list< DAE . Subscript > subs,res;
274
+ DAE . ComponentRef cr;
275
+ case (DAE . CREF_IDENT (ident = id,subscriptLst = subs)) then subs;
276
+ case (DAE . CREF_QUAL (componentRef = cr))
277
+ equation
278
+ res = crefLastSubs(cr);
279
+ then
280
+ res;
281
+ end matchcontinue;
282
+ end crefLastSubs;
283
+
284
+ public function crefFirstCref
285
+ "Returns the first part of a component reference, i.e the identifier"
286
+ input DAE . ComponentRef inCr;
287
+ output DAE . ComponentRef outCr;
288
+ algorithm
289
+ outCr := matchcontinue(inCr)
290
+ local
291
+ DAE . Ident id;
292
+ list< DAE . Subscript > subs;
293
+ DAE . ComponentRef cr;
294
+ DAE . ExpType t2;
295
+
296
+ case ( DAE . CREF_QUAL (id,t2,subs,cr)) then DAE . CREF_IDENT (id,t2,{});
297
+ case ( DAE . CREF_IDENT (id,t2,subs)) then DAE . CREF_IDENT (id,t2,{});
298
+ end matchcontinue;
299
+ end crefFirstCref;
300
+
301
+
302
+ /** *************************************************/
303
+ /* Compare */
304
+ /** *************************************************/
305
+
203
306
public function crefLastIdentEqual
204
307
"function: crefLastIdentEqual
205
308
author: Frenkel TUD
@@ -245,52 +348,6 @@ algorithm
245
348
equal := Exp . crefEqual(pcr1,pcr2);
246
349
end crefFirstCrefLastCrefEqual;
247
350
248
-
249
- public function crefSubs "
250
- function: crefSubs
251
- Return the all subscripts of a ComponentRef"
252
- input DAE . ComponentRef inComponentRef;
253
- output list< DAE . Subscript > outSubscriptLst;
254
- algorithm
255
- outSubscriptLst:=
256
- matchcontinue (inComponentRef)
257
- local
258
- DAE . Ident id;
259
- list< DAE . Subscript > subs,res;
260
- DAE . ComponentRef cr;
261
- case (DAE . CREF_IDENT (ident = id,subscriptLst = subs))
262
- then subs;
263
- case (DAE . CREF_QUAL (componentRef = cr,subscriptLst= subs))
264
- equation
265
- res = crefSubs(cr);
266
- res = listAppend(subs,res);
267
- then
268
- res;
269
- end matchcontinue;
270
- end crefSubs;
271
-
272
- public function crefLastSubs "
273
- function: crefLastSubs
274
- Return the last subscripts of a ComponentRef"
275
- input DAE . ComponentRef inComponentRef;
276
- output list< DAE . Subscript > outSubscriptLst;
277
- algorithm
278
- outSubscriptLst:=
279
- matchcontinue (inComponentRef)
280
- local
281
- DAE . Ident id;
282
- list< DAE . Subscript > subs,res;
283
- DAE . ComponentRef cr;
284
- case (DAE . CREF_IDENT (ident = id,subscriptLst = subs)) then subs;
285
- case (DAE . CREF_QUAL (componentRef = cr))
286
- equation
287
- res = crefLastSubs(cr);
288
- then
289
- res;
290
- end matchcontinue;
291
- end crefLastSubs;
292
-
293
-
294
351
public function crefSortFunc "A sorting function (greatherThan) for crefs"
295
352
input DAE . ComponentRef cr1;
296
353
input DAE . ComponentRef cr2;
@@ -299,52 +356,34 @@ algorithm
299
356
greaterThan := System . strcmp(Exp . printComponentRefStr(cr1),Exp . printComponentRefStr(cr2)) > 0 ;
300
357
end crefSortFunc;
301
358
302
- public function crefToStr
303
- "function: crefStr
304
- This function converts a ComponentRef to a String.
305
- It is a tail recursive implementation, because of that it
306
- neads inPreString. Use inNameSeperator to define the
307
- Separator inbetween and between the namespace names and the name"
308
- input String inPreString;
309
- input DAE . ComponentRef inComponentRef "The ComponentReference" ;
310
- input String inNameSeparator "The Separator between the Names" ;
311
- output String outString;
312
- algorithm
313
- outString:=
314
- matchcontinue (inPreString,inComponentRef,inNameSeparator)
315
- local
316
- DAE . Ident s,ns,s1,ss;
317
- DAE . ComponentRef n;
318
- case (inPreString,DAE . CREF_IDENT (ident = s),_)
319
- equation
320
- ss = stringAppend(inPreString, s);
321
- then ss;
322
- case (inPreString,DAE . CREF_QUAL (ident = s,componentRef = n),inNameSeparator)
323
- equation
324
- ns = System . stringAppendList({inPreString, s, inNameSeparator});
325
- ss = crefToStr(ns,n,inNameSeparator);
326
- then
327
- ss;
328
- end matchcontinue;
329
- end crefToStr;
359
+ /** *************************************************/
360
+ /* Change */
361
+ /** *************************************************/
330
362
331
- public function crefStr
332
- "function: crefStr
333
- This function simply converts a ComponentRef to a String."
334
- input DAE . ComponentRef inComponentRef;
335
- output String outString;
336
- algorithm
337
- outString:= crefToStr("" ,inComponentRef,"." );
338
- end crefStr;
363
+ public function crefPrependIdent "prepends (e..g as a suffix) an identifier to a component reference, given the identifier, subscript and the type
364
+ author: PA
339
365
340
- public function crefModelicaStr
341
- "function: crefModelicaStr
342
- Same as crefStr, but uses _ instead of . "
343
- input DAE . ComponentRef inComponentRef;
344
- output String outString;
366
+ Example
367
+ crefPrependIdent(a.b,c,{},Real) => a.b.c [Real]
368
+ crefPrependIdent(a,c,{1},Integer[1]) => a.c[1] [Integer[1]]
369
+
370
+ alternative names: crefAddSuffix, crefAddIdent
371
+ "
372
+ input DAE . ComponentRef cr;
373
+ input String ident;
374
+ input list< DAE . Subscript > subs;
375
+ input DAE . ExpType tp;
376
+ output DAE . ComponentRef newCr;
345
377
algorithm
346
- outString:= crefToStr("" ,inComponentRef,"_" );
347
- end crefModelicaStr;
378
+ newCr := matchcontinue(cr,ident,subs,tp)
379
+ local DAE . ExpType tp1; String id1; list< DAE . Subscript > subs1;
380
+ case (DAE . CREF_IDENT (id1,tp1,subs1),ident,subs,tp) then DAE . CREF_QUAL (id1,tp1,subs1,DAE . CREF_IDENT (ident,tp,subs));
381
+ case (DAE . CREF_QUAL (id1,tp1,subs1,cr),ident,subs,tp)
382
+ equation
383
+ cr = crefPrependIdent(cr,ident,subs,tp);
384
+ then DAE . CREF_QUAL (id1,tp1,subs1,cr);
385
+ end matchcontinue;
386
+ end crefPrependIdent;
348
387
349
388
public function stripCrefIdentSliceSubs "
350
389
Author BZ
@@ -462,23 +501,6 @@ algorithm
462
501
end matchcontinue;
463
502
end crefStripLastIdent;
464
503
465
- public function crefFirstCref
466
- "Returns the first part of a component reference, i.e the identifier"
467
- input DAE . ComponentRef inCr;
468
- output DAE . ComponentRef outCr;
469
- algorithm
470
- outCr := matchcontinue(inCr)
471
- local
472
- DAE . Ident id;
473
- list< DAE . Subscript > subs;
474
- DAE . ComponentRef cr;
475
- DAE . ExpType t2;
476
-
477
- case ( DAE . CREF_QUAL (id,t2,subs,cr)) then DAE . CREF_IDENT (id,t2,{});
478
- case ( DAE . CREF_IDENT (id,t2,subs)) then DAE . CREF_IDENT (id,t2,{});
479
- end matchcontinue;
480
- end crefFirstCref;
481
-
482
504
public function crefStripLastSubs
483
505
"function: crefStripLastSubs
484
506
Strips the last subscripts of a ComponentRef"
0 commit comments