Skip to content

Commit be5d1f8

Browse files
committed
- attempt to fix #1963
constant with parameter index -> DO NOT CONSTANT EVALUATE. - i guess a lot of tests will fail, i'll fix them when i get the result from Hudson git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@14187 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent b79b99a commit be5d1f8

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

Compiler/FrontEnd/Static.mo

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10300,14 +10300,26 @@ algorithm
1030010300
then
1030110301
(cache,e,DAE.C_VAR(),attr);
1030210302

10303+
// a constant with parameter subscript
10304+
case (cache,env,cr,attr as DAE.ATTR(variability = SCode.CONST()),DAE.C_PARAM(),_,tt,binding,doVect,Lookup.SPLICEDEXPDATA(_,idTp),_,_,_)
10305+
equation
10306+
cr2 = ComponentReference.crefStripLastSubs(cr);
10307+
subsc = ComponentReference.crefLastSubs(cr);
10308+
(cache,v) = Ceval.cevalCref(cache,env,cr2,false,Ceval.MSG(info));
10309+
e = ValuesUtil.valueExp(v);
10310+
e = Expression.makeASUB(e, List.map(subsc,Expression.subscriptExp));
10311+
then
10312+
(cache,e,DAE.C_PARAM(),attr);
10313+
1030310314
// a constant -> evaluate binding
1030410315
case (cache,env,cr,attr as DAE.ATTR(variability = SCode.CONST()),_,_,tt,binding,doVect,Lookup.SPLICEDEXPDATA(_,idTp),_,_,_)
1030510316
equation
1030610317
true = Types.equivtypes(tt,idTp);
1030710318
(cache,v) = Ceval.cevalCrefBinding(cache,env,cr,binding,false,Ceval.MSG(info));
1030810319
e = ValuesUtil.valueExp(v);
10320+
const = Types.constAnd(DAE.C_CONST(), constSubs);
1030910321
then
10310-
(cache,e,DAE.C_CONST(),attr);
10322+
(cache,e,const,attr);
1031110323

1031210324
// a constant, couldn't evaluate binding, replace with it!
1031310325
case (cache,env,cr,attr as DAE.ATTR(variability = SCode.CONST()),_,_,tt,binding,doVect,Lookup.SPLICEDEXPDATA(_,idTp),_,_,_)
@@ -10317,9 +10329,11 @@ algorithm
1031710329
// constant binding
1031810330
DAE.EQBOUND(exp = e, constant_ = DAE.C_CONST()) = binding;
1031910331
// adrpo: todo -> subscript the binding expression
10320-
// subsc = ComponentReference.crefLastSubs(cr);
10332+
subsc = ComponentReference.crefLastSubs(cr);
10333+
e = Expression.makeASUB(e, List.map(subsc,Expression.subscriptExp));
10334+
const = Types.constAnd(DAE.C_CONST(), constSubs);
1032110335
then
10322-
(cache,e,DAE.C_CONST(),attr);
10336+
(cache,e,const,attr);
1032310337

1032410338
// a constant, couldn't evaluate binding, replace with it!
1032510339
case (cache,env,cr,attr as DAE.ATTR(variability = SCode.CONST()),_,_,tt,binding,doVect,Lookup.SPLICEDEXPDATA(_,idTp),_,_,_)
@@ -10329,8 +10343,11 @@ algorithm
1032910343
// constant binding
1033010344
DAE.VALBOUND(valBound = v) = binding;
1033110345
e = ValuesUtil.valueExp(v);
10346+
subsc = ComponentReference.crefLastSubs(cr);
10347+
e = Expression.makeASUB(e, List.map(subsc,Expression.subscriptExp));
10348+
const = Types.constAnd(DAE.C_CONST(), constSubs);
1033210349
then
10333-
(cache,e,DAE.C_CONST(),attr);
10350+
(cache,e,const,attr);
1033410351

1033510352
// a constant with some for iterator constness -> don't constant evaluate
1033610353
case (cache,env,cr,attr as DAE.ATTR(variability = SCode.CONST()),_,SOME(_),tt,_,doVect,_,_,_,_)

0 commit comments

Comments
 (0)