Skip to content

Commit

Permalink
- Susan does not generate unreachable match cases for map expressions…
Browse files Browse the repository at this point in the history
… (a clean-up)

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@15196 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
pavolpr committed Feb 16, 2013
1 parent 28bec13 commit fa49e9f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 480 deletions.
66 changes: 0 additions & 66 deletions Compiler/Template/AbsynDumpTpl.mo
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,6 @@ algorithm
txt = Tpl.nextIter(txt);
txt = lm_6(txt, rest);
then txt;

case ( txt,
_ :: rest )
equation
txt = lm_6(txt, rest);
then txt;
end match;
end lm_6;

Expand Down Expand Up @@ -206,12 +200,6 @@ algorithm
txt = Tpl.nextIter(txt);
txt = lm_9(txt, rest);
then txt;

case ( txt,
_ :: rest )
equation
txt = lm_9(txt, rest);
then txt;
end match;
end lm_9;

Expand Down Expand Up @@ -299,12 +287,6 @@ algorithm
txt = Tpl.nextIter(txt);
txt = lm_12(txt, rest);
then txt;

case ( txt,
_ :: rest )
equation
txt = lm_12(txt, rest);
then txt;
end match;
end lm_12;

Expand Down Expand Up @@ -332,12 +314,6 @@ algorithm
txt = Tpl.nextIter(txt);
txt = lm_13(txt, rest);
then txt;

case ( txt,
_ :: rest )
equation
txt = lm_13(txt, rest);
then txt;
end match;
end lm_13;

Expand Down Expand Up @@ -367,12 +343,6 @@ algorithm
txt = Tpl.nextIter(txt);
txt = lm_14(txt, rest);
then txt;

case ( txt,
_ :: rest )
equation
txt = lm_14(txt, rest);
then txt;
end match;
end lm_14;

Expand Down Expand Up @@ -400,12 +370,6 @@ algorithm
txt = Tpl.nextIter(txt);
txt = lm_15(txt, rest);
then txt;

case ( txt,
_ :: rest )
equation
txt = lm_15(txt, rest);
then txt;
end match;
end lm_15;

Expand Down Expand Up @@ -433,12 +397,6 @@ algorithm
txt = Tpl.nextIter(txt);
txt = lm_16(txt, rest);
then txt;

case ( txt,
_ :: rest )
equation
txt = lm_16(txt, rest);
then txt;
end match;
end lm_16;

Expand Down Expand Up @@ -822,12 +780,6 @@ algorithm
txt = Tpl.nextIter(txt);
txt = lm_21(txt, rest);
then txt;

case ( txt,
_ :: rest )
equation
txt = lm_21(txt, rest);
then txt;
end match;
end lm_21;

Expand Down Expand Up @@ -1093,12 +1045,6 @@ algorithm
txt = Tpl.nextIter(txt);
txt = lm_26(txt, rest);
then txt;

case ( txt,
_ :: rest )
equation
txt = lm_26(txt, rest);
then txt;
end match;
end lm_26;

Expand Down Expand Up @@ -1126,12 +1072,6 @@ algorithm
txt = Tpl.nextIter(txt);
txt = lm_27(txt, rest);
then txt;

case ( txt,
_ :: rest )
equation
txt = lm_27(txt, rest);
then txt;
end match;
end lm_27;

Expand Down Expand Up @@ -1209,12 +1149,6 @@ algorithm
txt = Tpl.nextIter(txt);
txt = lm_30(txt, rest);
then txt;

case ( txt,
_ :: rest )
equation
txt = lm_30(txt, rest);
then txt;
end match;
end lm_30;

Expand Down
30 changes: 0 additions & 30 deletions Compiler/Template/NFInstDumpTpl.mo
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,6 @@ algorithm
txt = Tpl.nextIter(txt);
txt = lm_13(txt, rest);
then txt;

case ( txt,
_ :: rest )
equation
txt = lm_13(txt, rest);
then txt;
end match;
end lm_13;

Expand Down Expand Up @@ -267,12 +261,6 @@ algorithm
txt = Tpl.nextIter(txt);
txt = lm_14(txt, rest);
then txt;

case ( txt,
_ :: rest )
equation
txt = lm_14(txt, rest);
then txt;
end match;
end lm_14;

Expand Down Expand Up @@ -300,12 +288,6 @@ algorithm
txt = Tpl.nextIter(txt);
txt = lm_15(txt, rest);
then txt;

case ( txt,
_ :: rest )
equation
txt = lm_15(txt, rest);
then txt;
end match;
end lm_15;

Expand Down Expand Up @@ -532,12 +514,6 @@ algorithm
txt = Tpl.nextIter(txt);
txt = lm_23(txt, rest);
then txt;

case ( txt,
_ :: rest )
equation
txt = lm_23(txt, rest);
then txt;
end match;
end lm_23;

Expand Down Expand Up @@ -861,12 +837,6 @@ algorithm
txt = Tpl.nextIter(txt);
txt = lm_29(txt, rest);
then txt;

case ( txt,
_ :: rest )
equation
txt = lm_29(txt, rest);
then txt;
end match;
end lm_29;

Expand Down
26 changes: 25 additions & 1 deletion Compiler/Template/TplAbsyn.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2687,13 +2687,20 @@ algorithm
mmFailCons = makeMMMatchCase(
(LIST_CONS_MATCH(REST_MATCH(), BIND_MATCH("rest")), encodedExtargs, {mmRecCall}),
encodedExtargs, oargs);
mmmcases = Util.if_(isAlwaysMatchedBool(mexp), { mmmcEmptyList, mmmcCons },
{ mmmcEmptyList, mmmcCons, mmFailCons });
// listAppend({ mmmcEmptyList, mmmcCons },
// { makeMMMatchCase(
// (LIST_CONS_MATCH(REST_MATCH(), BIND_MATCH("rest")), encodedExtargs, {mmRecCall}),
// encodedExtargs, oargs) } );

mapctx = MAP_CONTEXT(ofbind, mapexp, iopts, hasIndexIdentOpt, useiter);
maplocals = listAppend(encodedExtargs, maplocals);
maplocals = imlicitTxtArg :: ("rest",argtype) :: maplocals;

// make fun
mmFun = MM_FUN(false,fname, iargs, oargs, maplocals,
{ MM_MATCH( { mmmcEmptyList, mmmcCons, mmFailCons } ) },
{ MM_MATCH( mmmcases /*{ mmmcEmptyList, mmmcCons, mmFailCons } */ ) },
GI_MAP_FUN(argtype, mapctx)
);

Expand Down Expand Up @@ -4043,6 +4050,23 @@ algorithm
end match;
end isAlwaysMatched;

public function isAlwaysMatchedBool "function isAlwaysMatched
Takes a MatchingExp and fails when it is not a rest case for sure (statically tested)."
//TODO: evaluation when there are two cases with {} and (always :: _) ... or NONE() and SOME(always)
input MatchingExp inMatchingExp;
output Boolean isAlwaysMatched;
algorithm
isAlwaysMatched := matchcontinue (inMatchingExp)
local
MatchingExp mexp;
case (mexp)
equation
isAlwaysMatched(mexp);
then true;

else false;
end matchcontinue;
end isAlwaysMatchedBool;

public function adaptTextToString
input tuple<MMExp, TypeSignature, SourceInfo> inArgValue;
Expand Down

0 comments on commit fa49e9f

Please sign in to comment.