Skip to content

Commit

Permalink
Handle the case when we do not need to match against any pattern
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@20444 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed May 7, 2014
1 parent ff310c7 commit 6b73953
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Compiler/FrontEnd/Patternm.mo
Expand Up @@ -868,12 +868,26 @@ algorithm
patternMatrix = List.transposeList(List.map(cases,getCasePatterns));
(true,outInputs,outAliases,patternMatrix) = filterUnusedPatterns2(inputs,inAliases,patternMatrix,false,{},{},{});
patternMatrix = List.transposeList(patternMatrix);
cases = List.threadMap(cases,patternMatrix,setCasePatterns);
cases = setCasePatternsCheckZero(cases,patternMatrix);
then (outInputs,outAliases,cases);
else (inputs,inAliases,inCases);
end matchcontinue;
end filterUnusedPatterns;

protected function setCasePatternsCheckZero
"Handles the case when the pattern matrix becomes empty because no input is matched"
input list<DAE.MatchCase> inCases;
input list<list<DAE.Pattern>> patternMatrix;
output list<DAE.MatchCase> outCases;
algorithm
outCases := match (inCases,patternMatrix)
case ({},{}) then inCases;
case (_,{})
then List.map1(inCases,setCasePatterns,{});
else List.threadMap(inCases,patternMatrix,setCasePatterns);
end match;
end setCasePatternsCheckZero;

protected function filterUnusedPatterns2
"case (1,_,_) then ...; case (2,_,_) then ...; =>"
input list<DAE.Exp> inInputs "We can only remove inputs that are free from side-effects";
Expand Down

0 comments on commit 6b73953

Please sign in to comment.