Skip to content

Commit

Permalink
- ComponentReference.printComponentRefStr us match
Browse files Browse the repository at this point in the history
- ExpressionDump.printListStr use stringDelimitList and List.map

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@12191 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Jun 22, 2012
1 parent 395fe12 commit 181efac
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 50 deletions.
42 changes: 15 additions & 27 deletions Compiler/FrontEnd/ComponentReference.mo
Expand Up @@ -529,12 +529,13 @@ public function printComponentRefStr
input DAE.ComponentRef inComponentRef;
output String outString;
algorithm
outString := matchcontinue (inComponentRef)
outString := match (inComponentRef)
local
DAE.Ident s,str,strrest;
DAE.Ident s,str,strrest,strseb;
list<DAE.Subscript> subs;
DAE.ComponentRef cr;
DAE.Type ty;
Boolean b;

// Optimize -- a function call less
case (DAE.CREF_IDENT(ident = s,identType = ty,subscriptLst = {}))
Expand All @@ -548,28 +549,20 @@ algorithm
str;

// Qualified - Modelica output - does not handle names with underscores
case DAE.CREF_QUAL(ident = s,subscriptLst = subs,componentRef = cr)
equation
true = Config.modelicaOutput();
str = printComponentRef2Str(s, subs);
strrest = printComponentRefStr(cr);
str = stringAppendList({str, "__", strrest});
then
str;

// Qualified - non Modelica output
case DAE.CREF_QUAL(ident = s,subscriptLst = subs,componentRef = cr)
equation
false = Config.modelicaOutput();
b = Config.modelicaOutput();
str = printComponentRef2Str(s, subs);
strrest = printComponentRefStr(cr);
str = stringAppendList({str, ".", strrest});
strseb = Util.if_(b,"__",".");
str = stringAppendList({str, strseb, strrest});
then
str;

// Wild
case DAE.WILD() then "_";
end matchcontinue;
end match;
end printComponentRefStr;

public function printComponentRef2Str
Expand All @@ -579,32 +572,27 @@ public function printComponentRef2Str
input list<DAE.Subscript> inSubscriptLst;
output String outString;
algorithm
outString := matchcontinue (inIdent,inSubscriptLst)
outString := match (inIdent,inSubscriptLst)
local
DAE.Ident s,str;
DAE.Ident s,str,strseba,strsebb;
list<DAE.Subscript> l;
Boolean b;

// no subscripts
case (s,{}) then s;

// some subscripts, Modelica output
case (s,l)
equation
true = Config.modelicaOutput();
str = ExpressionDump.printListStr(l, ExpressionDump.printSubscriptStr, ",");
str = stringAppendList({s, "_L", str, "_R"});
then
str;

// some subscripts, non Modelica output
case (s,l)
equation
false = Config.modelicaOutput();
b = Config.modelicaOutput();
str = ExpressionDump.printListStr(l, ExpressionDump.printSubscriptStr, ",");
str = stringAppendList({s, "[", str, "]"});
((strseba,strsebb)) = Util.if_(b,("_L","_R"),("[","]"));
str = stringAppendList({s, strseba, str, strsebb});
then
str;
end matchcontinue;

end match;
end printComponentRef2Str;

public function debugPrintComponentRefTypeStr "Function: debugPrintComponentRefTypeStr
Expand Down
24 changes: 1 addition & 23 deletions Compiler/FrontEnd/ExpressionDump.mo
Expand Up @@ -429,29 +429,7 @@ public function printListStr
output String outString;
end FuncTypeType_aToString;
algorithm
outString := matchcontinue (inTypeALst,inFuncTypeTypeAToString,inString)
local
Ident s,srest,sep;
Type_a h;
FuncTypeType_aToString r;
list<Type_a> t;

case ({},_,_) then "";

case ({h},r,_)
equation
s = r(h);
then
s;

case ((h :: t),r,sep)
equation
s = r(h);
srest = printListStr(t, r, sep);
s = stringAppendList({s, sep, srest});
then
s;
end matchcontinue;
outString := stringDelimitList(List.map(inTypeALst,inFuncTypeTypeAToString),inString);
end printListStr;

public function debugPrintSubscriptStr "
Expand Down

0 comments on commit 181efac

Please sign in to comment.