Skip to content

Commit 1625165

Browse files
committed
- Changed structure for storing the result from SCodeInst from lists to a tree.
- Added new phase, SCodeExpand, which expands the result from SCodeInst into a DAE.DAElist. - Implemented inner/outer support in SCodeInst, not complete yet. git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@11188 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent d3b5a74 commit 1625165

File tree

7 files changed

+1395
-394
lines changed

7 files changed

+1395
-394
lines changed

Compiler/FrontEnd/Absyn.mo

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2810,6 +2810,43 @@ algorithm
28102810
end matchcontinue;
28112811
end stringListPath;
28122812

2813+
public function stringListPathReversed
2814+
"Converts a list of strings into a qualified path, in reverse order.
2815+
Ex: {'a', 'b', 'c'} => c.b.a"
2816+
input list<String> inStrings;
2817+
output Path outPath;
2818+
protected
2819+
String id;
2820+
list<String> rest_str;
2821+
Path path;
2822+
algorithm
2823+
id :: rest_str := inStrings;
2824+
path := IDENT(id);
2825+
outPath := stringListPathReversed2(rest_str, path);
2826+
end stringListPathReversed;
2827+
2828+
protected function stringListPathReversed2
2829+
input list<String> inStrings;
2830+
input Path inAccumPath;
2831+
output Path outPath;
2832+
algorithm
2833+
outPath := match(inStrings, inAccumPath)
2834+
local
2835+
String id;
2836+
list<String> rest_str;
2837+
Path path;
2838+
2839+
case ({}, _) then inAccumPath;
2840+
2841+
case (id :: rest_str, _)
2842+
equation
2843+
path = QUALIFIED(id, inAccumPath);
2844+
then
2845+
stringListPathReversed2(rest_str, path);
2846+
2847+
end match;
2848+
end stringListPathReversed2;
2849+
28132850
public function pathTwoLastIdents "Returns the two last idents of a path"
28142851
input Path p;
28152852
output Path twoLast;

Compiler/FrontEnd/ComponentReference.mo

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,5 +2186,30 @@ algorithm
21862186
end match;
21872187
end replaceWholeDimSubscript2;
21882188

2189+
public function splitCrefLast
2190+
"Splits a cref at the end, e.g. a.b.c.d => {a.b.c, d}."
2191+
input DAE.ComponentRef inCref;
2192+
output DAE.ComponentRef outPrefixCref;
2193+
output DAE.ComponentRef outLastCref;
2194+
algorithm
2195+
(outPrefixCref, outLastCref) := match(inCref)
2196+
local
2197+
DAE.Ident id;
2198+
DAE.Type ty;
2199+
list<DAE.Subscript> subs;
2200+
DAE.ComponentRef prefix, last;
2201+
2202+
case DAE.CREF_QUAL(id, ty, subs, last as DAE.CREF_IDENT(ident = _))
2203+
then (DAE.CREF_IDENT(id, ty, subs), last);
2204+
2205+
case DAE.CREF_QUAL(id, ty, subs, last)
2206+
equation
2207+
(prefix, last) = splitCrefLast(last);
2208+
then
2209+
(DAE.CREF_QUAL(id, ty, subs, prefix), last);
2210+
2211+
end match;
2212+
end splitCrefLast;
2213+
21892214
end ComponentReference;
21902215

Compiler/FrontEnd/SCode.mo

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3814,5 +3814,23 @@ algorithm
38143814
outElement := COMPONENT(name, pf, attr, ty, mod, cmt, NONE(), info);
38153815
end removeComponentCondition;
38163816

3817+
public function isInnerComponent
3818+
"Returns true if the given element is an element with the inner prefix,
3819+
otherwise false."
3820+
input Element inElement;
3821+
output Boolean outIsInner;
3822+
algorithm
3823+
outIsInner := match(inElement)
3824+
local
3825+
Absyn.InnerOuter io;
3826+
3827+
case COMPONENT(prefixes = PREFIXES(innerOuter = io))
3828+
then Absyn.isInner(io);
3829+
3830+
else false;
3831+
3832+
end match;
3833+
end isInnerComponent;
3834+
38173835
end SCode;
38183836

0 commit comments

Comments
 (0)