Skip to content

Commit

Permalink
Fix for #2177:
Browse files Browse the repository at this point in the history
- Fixed some issues with code generation for arrays with enumeration dimensions.


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@16050 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed May 15, 2013
1 parent 43d6be4 commit bfa1eea
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
3 changes: 1 addition & 2 deletions Compiler/FrontEnd/ComponentReference.mo
Expand Up @@ -1291,9 +1291,8 @@ algorithm
case (cr)
equation
((subs as (_ :: _))) = crefLastSubs(cr);
exps = List.map(subs, Expression.subscriptIndexExp);
// fails if any mapped functions returns false
then List.mapAllValueBool(exps, Expression.isOne, true);
then List.mapAllValueBool(subs, Expression.subscriptIsFirst, true);
else false;
end matchcontinue;
end crefIsFirstArrayElt;
Expand Down
16 changes: 16 additions & 0 deletions Compiler/FrontEnd/Expression.mo
Expand Up @@ -1609,6 +1609,22 @@ algorithm
end match;
end subscriptNonExpandedExp;

public function subscriptIsFirst
"Returns true if the given subscript is the first index for a dimension, i.e.
1, false or the first enumeration literal in an enumeration."
input Subscript inSubscript;
output Boolean outIsFirst;
algorithm
outIsFirst := match(inSubscript)
local

case DAE.INDEX(exp = DAE.ICONST(1)) then true;
case DAE.INDEX(exp = DAE.BCONST(false)) then true;
case DAE.INDEX(exp = DAE.ENUM_LITERAL(index = 1)) then true;

end match;
end subscriptIsFirst;

public function nthArrayExp
"function: nthArrayExp
author: PA
Expand Down
1 change: 1 addition & 0 deletions Compiler/Template/CodegenUtil.tpl
Expand Up @@ -72,6 +72,7 @@ template subscriptStr(Subscript subscript)
::=
match subscript
case INDEX(exp=ICONST(integer=i)) then i
case INDEX(exp=ENUM_LITERAL(name=n)) then dotPath(n)
case SLICE(exp=ICONST(integer=i)) then i
case WHOLEDIM(__) then "WHOLEDIM"
else "UNKNOWN_SUBSCRIPT"
Expand Down

0 comments on commit bfa1eea

Please sign in to comment.