Skip to content

Commit 12afbe8

Browse files
author
Jens Frenkel
committed
- continue to copy all functions do something with a ComponentRef from Exp into ComponentReference
- DAELowUtil.mo - finish check of BackendDAE object Bug 1302 - Exp.mo - add function traverseExpTopDown, used for check of BackendDAE git-svn-id: https://openmodelica.org/svn/OpenModelica/branches/sjoelund-functiontree@6565 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent ed2acad commit 12afbe8

File tree

10 files changed

+2022
-1740
lines changed

10 files changed

+2022
-1740
lines changed

Compiler/BackendVarTransform.mo

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ package BackendVarTransform
4141

4242
public import BackendDAE;
4343
public import DAE;
44-
public import DAELow;
4544
public import VarTransform;
4645

4746
protected import Absyn;

Compiler/ComponentReference.mo

Lines changed: 152 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ protected import RTOpts;
5252
protected import Util;
5353

5454

55+
/***************************************************/
56+
/* Generate */
57+
/***************************************************/
58+
59+
5560
public function makeCrefIdent
5661
"@author: adrpo
5762
This function creates a DAE.CREF_IDENT(ident, identType, subscriptLst)"
@@ -75,31 +80,10 @@ algorithm
7580
outCrefQual := DAE.CREF_QUAL(ident, identType, subscriptLst, componentRef);
7681
end makeCrefQual;
7782

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;
10283

84+
/***************************************************/
85+
/* Transform */
86+
/***************************************************/
10387

10488
public function crefToPath
10589
"function: crefToPath
@@ -146,6 +130,59 @@ algorithm
146130
end matchcontinue;
147131
end pathToCref;
148132

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+
149186
public function crefLastPath
150187
"Returns the last identifier of a cref as an Absyn.IDENT."
151188
input DAE.ComponentRef inComponentRef;
@@ -200,6 +237,72 @@ algorithm
200237
end matchcontinue;
201238
end crefLastCref;
202239

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+
203306
public function crefLastIdentEqual
204307
"function: crefLastIdentEqual
205308
author: Frenkel TUD
@@ -245,52 +348,6 @@ algorithm
245348
equal := Exp.crefEqual(pcr1,pcr2);
246349
end crefFirstCrefLastCrefEqual;
247350

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-
294351
public function crefSortFunc "A sorting function (greatherThan) for crefs"
295352
input DAE.ComponentRef cr1;
296353
input DAE.ComponentRef cr2;
@@ -299,52 +356,34 @@ algorithm
299356
greaterThan := System.strcmp(Exp.printComponentRefStr(cr1),Exp.printComponentRefStr(cr2)) > 0;
300357
end crefSortFunc;
301358

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+
/***************************************************/
330362

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
339365

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;
345377
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;
348387

349388
public function stripCrefIdentSliceSubs "
350389
Author BZ
@@ -462,23 +501,6 @@ algorithm
462501
end matchcontinue;
463502
end crefStripLastIdent;
464503

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-
482504
public function crefStripLastSubs
483505
"function: crefStripLastSubs
484506
Strips the last subscripts of a ComponentRef"

0 commit comments

Comments
 (0)