Skip to content

Commit

Permalink
- Added debug flag to not remove as-bindings from case patterns if th…
Browse files Browse the repository at this point in the history
…ey are unused

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@7652 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Jan 6, 2011
1 parent d8c14bd commit dabab7b
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions Compiler/FrontEnd/Patternm.mo
Expand Up @@ -558,8 +558,7 @@ algorithm
// Do DCE before converting mc to m
matchTy = optimizeContinueToMatch(matchTy,elabCases,info);
elabCases = optimizeContinueJumps(matchTy, elabCases);
exp = DAE.MATCHEXPRESSION(matchTy,elabExps,matchDecls,elabCases,et);
(elabCases,ht) = traverseCases(elabCases, addLocalCref, HashTableStringToPath.emptyHashTable());
ht = getUsedLocalCrefs(RTOpts.debugFlag("patternmSkipFilterUnusedAsBindings"),DAE.MATCHEXPRESSION(matchTy,elabExps,matchDecls,elabCases,et));
(matchDecls,ht) = filterUnusedDecls(matchDecls,ht,{},HashTableStringToPath.emptyHashTable());
elabCases = filterUnusedAsBindings(elabCases,ht);
exp = DAE.MATCHEXPRESSION(matchTy,elabExps,matchDecls,elabCases,et);
Expand All @@ -573,6 +572,25 @@ algorithm
end matchcontinue;
end elabMatchExpression;

protected function getUsedLocalCrefs
input Boolean skipFilterUnusedAsBindings "if true, traverse the whole expression; else only the bodies and results";
input DAE.Exp exp;
output HashTableStringToPath.HashTable ht;
algorithm
ht := match (skipFilterUnusedAsBindings,exp)
local
list<DAE.MatchCase> cases;
case (true,exp)
equation
((_,ht)) = Expression.traverseExp(exp, addLocalCref, HashTableStringToPath.emptyHashTable());
then ht;
case (false,DAE.MATCHEXPRESSION(cases=cases))
equation
(_,ht) = traverseCases(cases, addLocalCref, HashTableStringToPath.emptyHashTable());
then ht;
end match;
end getUsedLocalCrefs;

protected function filterUnusedAsBindings
input list<DAE.MatchCase> cases;
input HashTableStringToPath.HashTable ht;
Expand Down

0 comments on commit dabab7b

Please sign in to comment.