Skip to content

Commit

Permalink
- More match, less continue
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@7609 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Jan 1, 2011
1 parent 3908403 commit 82d4aa1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 29 deletions.
47 changes: 23 additions & 24 deletions Compiler/FrontEnd/SCodeUtil.mo
Expand Up @@ -171,14 +171,13 @@ public function translateRestriction
input Absyn.Restriction inRestriction;
output SCode.Restriction outRestriction;
algorithm
outRestriction := matchcontinue (inClass,inRestriction)
outRestriction := match (inClass,inRestriction)
local
Absyn.Class d;
Absyn.Path name;
Integer index;

case (d,Absyn.R_FUNCTION()) equation true = containsExternalFuncDecl(d); then SCode.R_EXT_FUNCTION();
case (d,Absyn.R_FUNCTION()) equation false = containsExternalFuncDecl(d); then SCode.R_FUNCTION();
case (d,Absyn.R_FUNCTION()) then Util.if_(containsExternalFuncDecl(d),SCode.R_EXT_FUNCTION(),SCode.R_FUNCTION());
case (_,Absyn.R_CLASS()) then SCode.R_CLASS();
case (_,Absyn.R_OPTIMIZATION()) then SCode.R_OPTIMIZATION();
case (_,Absyn.R_MODEL()) then SCode.R_MODEL();
Expand All @@ -204,7 +203,7 @@ algorithm
then SCode.R_METARECORD(name,index);
case (_,Absyn.R_UNIONTYPE()) then SCode.R_UNIONTYPE(); /*MetaModelica extension added by x07simbj */

end matchcontinue;
end match;
end translateRestriction;

protected function containsExternalFuncDecl
Expand All @@ -213,7 +212,7 @@ protected function containsExternalFuncDecl
input Absyn.Class inClass;
output Boolean outBoolean;
algorithm
outBoolean := matchcontinue (inClass)
outBoolean := match (inClass)
local
Boolean res,b,c,d;
String a;
Expand All @@ -238,8 +237,8 @@ algorithm
res = containsExternalFuncDecl(Absyn.CLASS(a,b,c,d,e,Absyn.PARTS(rest,cmt),file_info));
then
res;
case (_) then false;
end matchcontinue;
else false;
end match;
end containsExternalFuncDecl;

protected function translateClassdef
Expand All @@ -253,7 +252,7 @@ protected function translateClassdef
input Absyn.ClassDef inClassDef;
output SCode.ClassDef outClassDef;
algorithm
outClassDef := matchcontinue (inClassDef)
outClassDef := match (inClassDef)
local
SCode.Mod mod;
Absyn.TypeSpec t;
Expand Down Expand Up @@ -340,7 +339,7 @@ algorithm
scodeCmt = translateComment(cmt);
then
SCode.PDER(path,vars,scodeCmt);
end matchcontinue;
end match;
end translateClassdef;

protected function translateAlternativeExternalAnnotation
Expand Down Expand Up @@ -427,7 +426,7 @@ protected function translateClassdefElements
input list<Absyn.ClassPart> inAbsynClassPartLst;
output list<SCode.Element> outElementLst;
algorithm
outElementLst := matchcontinue (inAbsynClassPartLst)
outElementLst := match (inAbsynClassPartLst)
local
list<SCode.Element> els,es_1,els_1;
list<Absyn.ElementItem> es;
Expand All @@ -451,7 +450,7 @@ algorithm
els_1;
case (_ :: rest) /* ignore all other than PUBLIC and PROTECTED, i.e. elements */
then translateClassdefElements(rest);
end matchcontinue;
end match;
end translateClassdefElements;

// stefan
Expand All @@ -461,7 +460,7 @@ protected function translateClassdefAnnotations
input list<Absyn.ClassPart> inClassPartList;
output list<SCode.Annotation> outAnnotationList;
algorithm
outAnnotationList := matchcontinue(inClassPartList)
outAnnotationList := match (inClassPartList)
local
list<SCode.Annotation> anns,anns1,anns2;
list<Absyn.ElementItem> eilst;
Expand Down Expand Up @@ -517,7 +516,7 @@ algorithm
anns = translateClassdefAnnotations(cdr);
then
anns;
end matchcontinue;
end match;
end translateClassdefAnnotations;

protected function translateClassdefEquations
Expand Down Expand Up @@ -580,7 +579,7 @@ protected function translateClassdefAlgorithms
input list<Absyn.ClassPart> inAbsynClassPartLst;
output list<SCode.AlgorithmSection> outAlgorithmLst;
algorithm
outAlgorithmLst := matchcontinue (inAbsynClassPartLst)
outAlgorithmLst := match (inAbsynClassPartLst)
local
list<SCode.AlgorithmSection> als,als_1;
list<SCode.Statement> al_1;
Expand All @@ -605,7 +604,7 @@ algorithm
equation
Debug.fprintln("failtrace", "- SCodeUtil.translateClassdefAlgorithms failed");
then fail();
end matchcontinue;
end match;
end translateClassdefAlgorithms;

protected function translateClassdefInitialalgorithms
Expand All @@ -614,7 +613,7 @@ protected function translateClassdefInitialalgorithms
input list<Absyn.ClassPart> inAbsynClassPartLst;
output list<SCode.AlgorithmSection> outAlgorithmLst;
algorithm
outAlgorithmLst := matchcontinue (inAbsynClassPartLst)
outAlgorithmLst := match (inAbsynClassPartLst)
local
list<SCode.AlgorithmSection> als,als_1;
list<SCode.Statement> stmts;
Expand All @@ -633,7 +632,7 @@ algorithm
als = translateClassdefInitialalgorithms(rest);
then
als;
end matchcontinue;
end match;
end translateClassdefInitialalgorithms;

public function translateClassdefAlgorithmitems
Expand Down Expand Up @@ -779,7 +778,7 @@ protected function translateClassdefExternaldecls
input list<Absyn.ClassPart> inAbsynClassPartLst;
output Option<Absyn.ExternalDecl> outAbsynExternalDeclOption;
algorithm
outAbsynExternalDeclOption := matchcontinue (inAbsynClassPartLst)
outAbsynExternalDeclOption := match (inAbsynClassPartLst)
local
Absyn.ExternalDecl decl;
Option<Absyn.ExternalDecl> res;
Expand All @@ -791,7 +790,7 @@ algorithm
then
res;
case ({}) then NONE();
end matchcontinue;
end match;
end translateClassdefExternaldecls;

public function translateEitemlist
Expand All @@ -803,7 +802,7 @@ public function translateEitemlist
input Boolean inBoolean;
output list<SCode.Element> outElementLst;
algorithm
outElementLst := matchcontinue (inAbsynElementItemLst,inBoolean)
outElementLst := match (inAbsynElementItemLst,inBoolean)
local
list<SCode.Element> l,e_1,es_1;
list<Absyn.ElementItem> es;
Expand All @@ -823,7 +822,7 @@ algorithm
l = listAppend(e_1, es_1);
then
l;
end matchcontinue;
end match;
end translateEitemlist;

// stefan
Expand Down Expand Up @@ -1163,11 +1162,11 @@ protected function translateRedeclarekeywords
input Option<Absyn.RedeclareKeywords> inAbsynRedeclareKeywordsOption;
output Boolean outBoolean;
algorithm
outBoolean := matchcontinue (inAbsynRedeclareKeywordsOption)
outBoolean := match (inAbsynRedeclareKeywordsOption)
case (SOME(Absyn.REPLACEABLE())) then true;
case (SOME(Absyn.REDECLARE_REPLACEABLE())) then true;
case (_) then false;
end matchcontinue;
else false;
end match;
end translateRedeclarekeywords;

protected function translateVariability
Expand Down
9 changes: 4 additions & 5 deletions Compiler/Util/Util.mo
Expand Up @@ -842,7 +842,7 @@ public function listFlatten_tail
output list<Type_a> outTypeALst;
replaceable type Type_a subtypeof Any;
algorithm
outTypeALst := matchcontinue (inTypeALstLst, accTypeALst)
outTypeALst := match (inTypeALstLst, accTypeALst)
local
list<Type_a> r_1,l,f;
list<list<Type_a>> r;
Expand All @@ -853,7 +853,7 @@ algorithm
l = listFlatten_tail(r, r_1);
then
l;
end matchcontinue;
end match;
end listFlatten_tail;


Expand Down Expand Up @@ -957,8 +957,7 @@ public function listApplyAndFold
output Type_b outElement;
end FuncType_a2Type_b;
algorithm
result :=
matchcontinue (lst,foldFunc,typeA2typeB,accumulator)
result := match (lst,foldFunc,typeA2typeB,accumulator)
local
list<Type_b> foldArg1, foldArg2;
list<Type_a> rest;
Expand All @@ -970,7 +969,7 @@ algorithm
foldArg2 = listApplyAndFold(rest, foldFunc, typeA2typeB, foldArg1);
then
foldArg2;
end matchcontinue;
end match;
end listApplyAndFold;

public function arrayMapNoCopy "Takes an array and a function over the elements of the array, which is applied for each element.
Expand Down

0 comments on commit 82d4aa1

Please sign in to comment.