Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- Check lhs patterns for new variables that are bound, enable checks for MetaModelica (match excluded)


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@12720 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Aug 29, 2012
1 parent 4de9d27 commit 7197c1f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
29 changes: 28 additions & 1 deletion Compiler/FrontEnd/Inst.mo
Expand Up @@ -145,6 +145,7 @@ protected import Interactive;
protected import List;
protected import Lookup;
protected import MetaUtil;
protected import Patternm;
protected import PrefixUtil;
protected import SCodeUtil;
protected import Static;
Expand Down Expand Up @@ -11327,7 +11328,7 @@ algorithm
partialPrefixBool = SCode.partialBool(partialPrefix);

daeElts = optimizeFunctionCheckForLocals(fpath,daeElts,NONE(),{},{},{});
Debug.bcall2(not Config.acceptMetaModelicaGrammar(),checkFunctionDefUse,daeElts,info);
checkFunctionDefUse(daeElts,info);
cmt = extractClassDefComment(cache, env, cd);
/* Not working 100% yet... Also, a lot of code has unused inputs :( */
Debug.bcall3(false and Config.acceptMetaModelicaGrammar() and not instFunctionTypeOnly,checkFunctionInputUsed,daeElts,NONE(),Absyn.pathString(fpath));
Expand Down Expand Up @@ -17921,16 +17922,42 @@ algorithm
list<String> unbound;
DAE.ComponentRef cr;
DAE.Exp exp;
DAE.Pattern pattern;
case (DAE.CREF(componentRef=DAE.WILD()),_) then inUnbound;
case (DAE.CREF(componentRef=cr),unbound)
equation
unbound = List.filter1OnTrue(unbound,Util.stringNotEqual,ComponentReference.crefFirstIdent(cr));
then unbound;
case (DAE.ASUB(exp=exp),unbound) then crefFiltering(exp,unbound);
case (DAE.PATTERN(pattern=pattern),unbound)
equation
((_,unbound)) = Patternm.traversePattern((pattern,unbound),patternFiltering);
then unbound;
else inUnbound;
end match;
end crefFiltering;

protected function patternFiltering
input tuple<DAE.Pattern,list<String>> inTpl;
output tuple<DAE.Pattern,list<String>> outTpl;
algorithm
outTpl := match inTpl
local
list<String> unbound;
String id;
DAE.Pattern pattern;
case ((pattern as DAE.PAT_AS(id=id),unbound))
equation
unbound = List.filter1OnTrue(unbound,Util.stringNotEqual,id);
then ((pattern,unbound));
case ((pattern as DAE.PAT_AS_FUNC_PTR(id=id),unbound))
equation
unbound = List.filter1OnTrue(unbound,Util.stringNotEqual,id);
then ((pattern,unbound));
else inTpl;
end match;
end patternFiltering;

protected function traverseCrefSubs
input DAE.Exp exp;
input Absyn.Info info;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/FrontEnd/Patternm.mo
Expand Up @@ -1136,7 +1136,7 @@ algorithm
end match;
end traversePatternList;

protected function traversePattern
public function traversePattern
input tuple<DAE.Pattern,TypeA> inTpl;
input Func func;
output tuple<DAE.Pattern,TypeA> outTpl;
Expand Down

0 comments on commit 7197c1f

Please sign in to comment.