Skip to content

Commit

Permalink
Fix for #2995:
Browse files Browse the repository at this point in the history
- Added boolean literals to Expression.isValidSubscript and subscriptContants.


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@23530 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed Nov 24, 2014
1 parent 9b12f9d commit 1af56e0
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions Compiler/FrontEnd/Expression.mo
Expand Up @@ -8829,21 +8829,16 @@ returns true if all subscripts are known (i.e no cref) constant values (no slice
input list<DAE.Subscript> inSubs;
output Boolean areConstant;
algorithm
areConstant := matchcontinue(inSubs)
local list<DAE.Subscript> subs;
case({}) then true;
case(DAE.INDEX(exp = DAE.ICONST()):: subs)
equation
areConstant = subscriptConstants(subs);
then
areConstant;
case(DAE.INDEX(exp = DAE.ENUM_LITERAL()) :: subs)
equation
areConstant = subscriptConstants(subs);
then
areConstant;
else false;
end matchcontinue;
for sub in inSubs loop
areConstant := match(sub)
case DAE.INDEX(exp = DAE.ICONST()) then true;
case DAE.INDEX(exp = DAE.ENUM_LITERAL()) then true;
case DAE.INDEX(exp = DAE.BCONST()) then true;
else false;
end match;

if not areConstant then return; end if;
end for;
end subscriptConstants;

public function isValidSubscript
Expand All @@ -8852,11 +8847,12 @@ public function isValidSubscript
input DAE.Exp inSub;
output Boolean isValid;
algorithm
isValid := matchcontinue(inSub)
isValid := match(inSub)
case DAE.ICONST() then true;
case DAE.ENUM_LITERAL() then true;
case _ then false;
end matchcontinue;
case DAE.BCONST() then true;
else false;
end match;
end isValidSubscript;

public function subscriptContain "This function checks whether sub2 contains sub1 or not(DAE.WHOLEDIM())"
Expand Down

0 comments on commit 1af56e0

Please sign in to comment.