Skip to content

Commit

Permalink
- bug #1963 cannot be fixed right now as the fix is breaking too many…
Browse files Browse the repository at this point in the history
… models.

- to fix this bug we need to know in Static which parameters are final and we have no way of knowing that right now.


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@14189 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Dec 2, 2012
1 parent 305e07a commit ab9238b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
8 changes: 8 additions & 0 deletions Compiler/FrontEnd/Inst.mo
Expand Up @@ -5007,12 +5007,20 @@ algorithm

case ({}) then {};

// constants
case ((el as SCode.COMPONENT(attributes=attr, comment = cmt))::els)
equation
true = SCode.isConstant(SCode.attrVariability(attr)); // or SCode.getEvaluateAnnotation(cmt);
els1 = constantEls(els);
then (el::els1);

/*/ final parameters
case ((el as SCode.COMPONENT(prefixes = SCode.PREFIXES(finalPrefix = SCode.FINAL()), attributes=attr))::els)
equation
true = SCode.isParameterOrConst(SCode.attrVariability(attr));
els1 = constantEls(els);
then (el::els1);*/

case (_::els)
equation
els1 = constantEls(els);
Expand Down
30 changes: 17 additions & 13 deletions Compiler/FrontEnd/Static.mo
Expand Up @@ -9718,7 +9718,7 @@ algorithm
// attr = DAEUtil.setAttrVariability(attr, variability);
// get the binding if is a constant
(cache,exp,constCref,attr) = elabCref2(cache, env, c_1, attr, constSubs, forIteratorConstOpt, t, binding, doVect, splicedExpData, pre, evalCref, info);
const = Types.constAnd(constCref, constSubs); // constCref
const = constCref; // Types.constAnd(constCref, constSubs);
exp = makeASUBArrayAdressing(c,cache,env,impl,exp,splicedExpData,doVect,pre,info);
t = fixEnumerationType(t);
(exp,const) = evaluateEmptyVariable(hasZeroSizeDim and evalCref,exp,t,const);
Expand All @@ -9737,7 +9737,7 @@ algorithm
// attr = DAEUtil.setAttrVariability(attr, variability);
// get the binding if is a constant
(cache,exp,constCref,attr) = elabCref2(cache, env, c_1, attr, constSubs, forIteratorConstOpt, t, binding, doVect, splicedExpData, pre, evalCref, info);
const = Types.constAnd(constCref, constSubs); // constCref
const = constCref; // Types.constAnd(constCref, constSubs);
exp = makeASUBArrayAdressing(c,cache,env,impl,exp,splicedExpData,doVect,pre,info);
t = fixEnumerationType(t);
(exp,const) = evaluateEmptyVariable(hasZeroSizeDim and evalCref,exp,t,const);
Expand Down Expand Up @@ -10329,9 +10329,9 @@ algorithm
// constant binding
DAE.EQBOUND(exp = e, constant_ = DAE.C_CONST()) = binding;
// adrpo: todo -> subscript the binding expression
subsc = ComponentReference.crefLastSubs(cr);
e = Expression.makeASUB(e, List.map(subsc,Expression.subscriptExp));
const = Types.constAnd(DAE.C_CONST(), constSubs);
// subsc = ComponentReference.crefLastSubs(cr);
// e = Expression.makeASUB(e, List.map(subsc,Expression.subscriptExp));
const = DAE.C_CONST(); // const = Types.constAnd(DAE.C_CONST(), constSubs);
then
(cache,e,const,attr);

Expand All @@ -10343,9 +10343,11 @@ algorithm
// constant binding
DAE.VALBOUND(valBound = v) = binding;
e = ValuesUtil.valueExp(v);
subsc = ComponentReference.crefLastSubs(cr);
e = Expression.makeASUB(e, List.map(subsc,Expression.subscriptExp));
const = Types.constAnd(DAE.C_CONST(), constSubs);
// adrpo: todo -> subscript the binding expression
// subsc = ComponentReference.crefLastSubs(cr);
// e = Expression.makeASUB(e, List.map(subsc,Expression.subscriptExp));
// const = Types.constAnd(DAE.C_CONST(), constSubs);
const = DAE.C_CONST();
then
(cache,e,const,attr);

Expand Down Expand Up @@ -11494,27 +11496,29 @@ algorithm
then
(inCache, inSubscript);

// Keep parameters as they are
/*/ Keep parameters as they are:
// adrpo 2012-12-02 this does not work as we need to evaluate final parameters!
// and we have now way yet of knowing which ones those are
case (_, _, _, _, _, _, _, _)
equation
true = Types.isParameter(inConst);
then
(inCache, inSubscript);
(inCache, inSubscript);*/

// If the subscript contains a const then it should be evaluated to
// the value.
case (_, _, _, _, _, _, _, _)
equation
int_dim = Expression.dimensionSize(inDimension);
true = Types.isConstant(inConst); // Types.isParameterOrConstant(inConst);
true = Types.isParameterOrConstant(inConst);
(cache, sub) = Ceval.cevalSubscript(inCache, inEnv, inSubscript,
int_dim, inImpl, Ceval.MSG(inInfo));
then
(cache, sub);

case (_, _, _, DAE.DIM_EXP(exp=e), _, _, _, _)
equation
true = Types.isConstant(inConst); // Types.isParameterOrConstant(inConst);
true = Types.isParameterOrConstant(inConst);
(cache, Values.INTEGER(integer=int_dim), _) = Ceval.ceval(inCache,inEnv,e,true,NONE(),Ceval.MSG(inInfo));
(cache, sub) = Ceval.cevalSubscript(inCache, inEnv, inSubscript,
int_dim, inImpl, Ceval.MSG(inInfo));
Expand All @@ -11534,7 +11538,7 @@ algorithm
case (_, _, _, _, _, _, _, _)
equation
true = Expression.dimensionKnown(inDimension);
false = Types.isConstant(inConst);
false = Types.isParameterOrConstant(inConst);
then
(inCache, inSubscript);

Expand Down

0 comments on commit ab9238b

Please sign in to comment.