Skip to content

Commit

Permalink
Fix for bug #1207:
Browse files Browse the repository at this point in the history
- Fixed so that iterators in for loops get correct type when the range is of
  enumeration type.
- Added test case mofiles/ForIteratorType and updated mofiles/Enum7.


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@6262 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed Sep 30, 2010
1 parent 43532e8 commit c5c4907
Showing 1 changed file with 1 addition and 28 deletions.
29 changes: 1 addition & 28 deletions Compiler/InstSection.mo
Expand Up @@ -1874,20 +1874,6 @@ algorithm
DAE.Const cnst;
InstanceHierarchy ih;

// Frenkel TUD: handle the case where range is a enumeration!
case (cache,env,ih,pre,{(i,SOME(e as Absyn.CREF(cr)))},sl,info,source,initial_,impl,unrollForLoops)
equation
typePath = Absyn.crefToPath(cr);
/* make sure is an enumeration! */
(_, SCode.CLASS(restriction=SCode.R_ENUMERATION(), classDef=SCode.PARTS(elementLst, {}, {}, {}, {}, _, _, _)), _) =
Lookup.lookupClass(cache, env, typePath, false);
len = listLength(elementLst);
// replace the enumeration with a range
// ToDo do not replace the enumeration use the enumeration literals
(cache,stmts,dae) = instForStatement(cache,env,ih,pre,{(i,SOME(Absyn.RANGE(Absyn.INTEGER(1),NONE(),Absyn.INTEGER(len)) ))},sl,info,source,initial_,impl,unrollForLoops);
then
(cache,stmts,dae);

// adrpo: unroll ALL for loops containing ALG_WHEN... done
case (cache,env,ih,pre,inIterators,sl,info,source,initial_,impl,unrollForLoops)
equation
Expand Down Expand Up @@ -2045,20 +2031,6 @@ algorithm
DAE.Const cnst;
InstanceHierarchy ih;

// Frenkel TUD: handle the case where range is a enumeration!
case (cache,env,ih,pre,{(i,SOME(e as Absyn.CREF(cr)))},sl,info,source,initial_,impl,unrollForLoops)
equation
typePath = Absyn.crefToPath(cr);
/* make sure is an enumeration! */
(_, SCode.CLASS(restriction=SCode.R_ENUMERATION(), classDef=SCode.PARTS(elementLst, {}, {}, {}, {}, _, _, _)), _) =
Lookup.lookupClass(cache, env, typePath, false);
len = listLength(elementLst);
// replace the enumeration with a range
// ToDo do not replace the enumeration use the enumeration literals
(cache,stmts,dae) = instForStatement_dispatch(cache,env,ih,pre,{(i,SOME(Absyn.RANGE(Absyn.INTEGER(1),NONE(),Absyn.INTEGER(len)) ))},sl,info,source,initial_,impl,unrollForLoops);
then
(cache,stmts,dae);

// one iterator
case (cache,env,ih,pre,{(i,SOME(e))},sl,info,source,initial_,impl,unrollForLoops)
equation
Expand All @@ -2072,6 +2044,7 @@ algorithm
dae = DAEUtil.joinDaes(dae1,dae2);
then
(cache,{stmt},dae);

// multiple iterators
case (cache,env,ih,pre,(i,SOME(e))::restIterators,sl,info,source,initial_,impl,unrollForLoops)
equation
Expand Down

0 comments on commit c5c4907

Please sign in to comment.