Skip to content

Commit

Permalink
Fix detection of fixed globalKnownVars
Browse files Browse the repository at this point in the history
  • Loading branch information
ptaeuber authored and OpenModelica-Hudson committed Jul 3, 2017
1 parent ade8bc4 commit c617a1f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Compiler/BackEnd/Initialization.mo
Expand Up @@ -836,7 +836,7 @@ algorithm
for i in flatComps loop
v := BackendVariable.getVarAt(globalKnownVars, i);
bindExp := BackendVariable.varBindExpStartValueNoFail(v);
crefs := Expression.getAllCrefs(bindExp);
crefs := Expression.getAllCrefsExpanded(bindExp);

_ := match(v)
// primary parameter
Expand Down
30 changes: 29 additions & 1 deletion Compiler/FrontEnd/Expression.mo
Expand Up @@ -2472,8 +2472,36 @@ algorithm
end if;
end getAllCrefs2;

public function getAllCrefsExpanded "author: ptaeuber
This function extracts all crefs from the input expression (except 'time') and expands arrays and records."
input DAE.Exp inExp;
output list<DAE.ComponentRef> outCrefs;
algorithm
(_, outCrefs) := traverseExpBottomUp(inExp, getAllCrefsExpanded2, {});
end getAllCrefsExpanded;

protected function getAllCrefsExpanded2
input DAE.Exp inExp;
input list<DAE.ComponentRef> inCrefList;
output DAE.Exp outExp = inExp;
output list<DAE.ComponentRef> outCrefList = inCrefList;
protected
DAE.ComponentRef cr;
list<DAE.ComponentRef> crlst;
algorithm
if isCref(inExp) then
DAE.CREF(componentRef=cr) := inExp;
crlst := ComponentReference.expandCref(cr, true);
for c in crlst loop
if not ComponentReference.crefEqual(c, DAE.crefTime) and not listMember(c, inCrefList) then
outCrefList := c::outCrefList;
end if;
end for;
end if;
end getAllCrefsExpanded2;

public function allTerms
"simliar to terms, but also perform expansion of
"similar to terms, but also performs expansion of
multiplications to reveal more terms, like for instance:
allTerms((a+b)*(b+c)) => {a*b,a*c,b*b,b*c}"
input DAE.Exp inExp;
Expand Down

0 comments on commit c617a1f

Please sign in to comment.