Skip to content

Commit

Permalink
Fix #2566 in the FrontEnd
Browse files Browse the repository at this point in the history
- report parameter T p(start = value, fixed = true) and use the start value.


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@19014 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Feb 7, 2014
1 parent bca2a79 commit a1772cc
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 4 deletions.
12 changes: 11 additions & 1 deletion Compiler/FrontEnd/InstBinding.mo
Expand Up @@ -621,7 +621,7 @@ algorithm
DAE.Exp e_1,e;
Option<Values.Value> e_val;
DAE.Const c;
String e_tp_str,tp_str,e_str,e_str_1,str;
String e_tp_str,tp_str,e_str,e_str_1,str,s,pre_str;
Env.Cache cache;
DAE.Properties prop;
DAE.Binding binding;
Expand Down Expand Up @@ -655,9 +655,19 @@ algorithm
// and maybe a lot others.
case (cache,_,SCode.ATTR(variability = SCode.PARAM()),DAE.MOD(eqModOption = NONE()),tp,_,_,_)
equation
true = Types.getFixedVarAttributeParameterOrConstant(tp);
// this always succeeds but return NOMOD if there is no (start = x)
startValueModification = Mod.lookupCompModification(inMod, "start");
// make sure is NOT a DAE.NOMOD!
false = Mod.isEmptyMod(startValueModification);
(cache,binding) = makeBinding(cache,inEnv,inAttributes,startValueModification,inType,inPrefix,componentName,inInfo);
binding = DAEUtil.setBindingSource(binding, DAE.BINDING_FROM_START_VALUE());

s = componentName;
pre_str = PrefixUtil.printPrefixStr2(inPrefix);
s = pre_str +& s;
str = DAEUtil.printBindingExpStr(binding);
Error.addSourceMessage(Error.UNBOUND_PARAMETER_WITH_START_VALUE_WARNING, {s,str}, inInfo);
then
(cache,binding);

Expand Down
14 changes: 14 additions & 0 deletions Compiler/FrontEnd/Mod.mo
Expand Up @@ -3392,5 +3392,19 @@ algorithm
end match;
end addEachToSubsIfNeeded;

public function isEmptyMod
"@author: adrpo
returns true if this is an empty modifier"
input DAE.Mod inMod;
output Boolean isEmpty;
algorithm
isEmpty := match(inMod)
case (DAE.NOMOD()) then true;
// That's a NOMOD() if I ever saw one...
case (DAE.MOD(subModLst={},eqModOption=NONE())) then true;
else false;
end match;
end isEmptyMod;

end Mod;

6 changes: 3 additions & 3 deletions Compiler/FrontEnd/Static.mo
Expand Up @@ -10684,7 +10684,7 @@ algorithm
// adrpo: report a warning if the binding came from a start value!
case (cache,env,cr,attr as DAE.ATTR(variability = SCode.PARAM()),_,_,tt,bind as DAE.EQBOUND(source = DAE.BINDING_FROM_START_VALUE()),doVect,_,_,_,_)
equation
true = Types.getFixedVarAttribute(tt);
true = Types.getFixedVarAttributeParameterOrConstant(tt);
s = ComponentReference.printComponentRefStr(cr);
pre_str = PrefixUtil.printPrefixStr2(inPrefix);
s = pre_str +& s;
Expand Down Expand Up @@ -10940,7 +10940,7 @@ algorithm
case (cache,env,cr,attr as DAE.ATTR(variability = SCode.PARAM()),_,NONE()/* not foriter*/,tt,DAE.UNBOUND(),
doVect,InstTypes.SPLICEDEXPDATA(sexp,idTp),_,_,_)
equation
false = Types.getFixedVarAttribute(tt);
false = Types.getFixedVarAttributeParameterOrConstant(tt);
expTy = Types.simplifyType(tt);
expIdTy = Types.simplifyType(idTp);
cr_1 = fillCrefSubscripts(cr, tt);
Expand Down Expand Up @@ -11925,7 +11925,7 @@ algorithm
equation
true = Types.isParameter(inConst);
ty = Types.getPropType(prop);
false = Types.getFixedVarAttribute(ty);
false = Types.getFixedVarAttributeParameterOrConstant(ty);
then
(inCache, inSubscript);

Expand Down
20 changes: 20 additions & 0 deletions Compiler/FrontEnd/Types.mo
Expand Up @@ -2841,6 +2841,26 @@ algorithm
vl_1 := getVars(vl, isOutputVar);
end getOutputVars;

public function getFixedVarAttributeParameterOrConstant
"Returns the value of the fixed attribute of a builtin type.
If there is no fixed in the tyep it returns true"
input DAE.Type tp;
output Boolean fix;
algorithm
fix := matchcontinue(tp)
// there is a fixed!
case (_)
equation
fix = getFixedVarAttribute(tp);
then
fix;

// there is no fixed!
case (_) then true;

end matchcontinue;
end getFixedVarAttributeParameterOrConstant;

public function getFixedVarAttribute "Returns the value of the fixed attribute of a builtin type"
input DAE.Type tp;
output Boolean fixed;
Expand Down

0 comments on commit a1772cc

Please sign in to comment.