Skip to content

Commit

Permalink
- Mod.elabModValue now won't try to ceval expression dependent on var…
Browse files Browse the repository at this point in the history
…iables (they should always fail).

  - This makes debugging easier since expressions that aren't meant to be ceval'ed won't appear in failtraces.
- Static.elabExp now generates C_CONST for MetaModelica NONE, NONE() and {}.
- Static.elabExp will generate correct const-ness for SOME(exp) and list(e1,..,,en).


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@4727 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Dec 21, 2009
1 parent 5c5c6ff commit b092bd9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
23 changes: 10 additions & 13 deletions Compiler/Mod.mo
Expand Up @@ -114,7 +114,7 @@ algorithm
equation
(cache,subs_1) = elabSubmods(cache,env, pre, subs, impl);
(cache,e_1,prop,_) = Static.elabExp(cache, env, e, impl, NONE, true);
(cache,e_val) = elabModValue(cache, env, e_1);
(cache,e_val) = elabModValue(cache, env, e_1, prop);
(cache,e_2) = Prefix.prefixExp(cache,env, e_1, pre)
"Bug: will cause elaboration of parameters without value to fail,
But this can be ok, since a modifier is present, giving it a value from outer modifications.." ;
Expand Down Expand Up @@ -239,22 +239,25 @@ protected function elabModValue
input Env.Cache inCache;
input Env.Env inEnv;
input DAE.Exp inExp;
input DAE.Properties inProp;
output Env.Cache outCache;
output Option<Values.Value> outValuesValueOption;
algorithm
(outCache,outValuesValueOption) :=
matchcontinue (inCache,inEnv,inExp)
matchcontinue (inCache,inEnv,inExp,inProp)
local
Values.Value v;
list<Env.Frame> env;
DAE.Exp e;
Env.Cache cache;
case (cache,env,e) /* If ceval fails, it should not print error messages. */
DAE.Properties prop;
case (cache,env,e,prop)
equation
(cache,v,_) = Ceval.ceval(cache,env, e, false, NONE, NONE, Ceval.NO_MSG());
failure(DAE.C_VAR() = Types.propAllConst(prop)) "Don't ceval variables";
(cache,v,_) = Ceval.ceval(cache,env, e, false, NONE, NONE, Ceval.MSG());
then
(cache,SOME(v));
case (cache,_,_) then (cache,NONE);
case (cache,_,_,_) then (cache,NONE);
end matchcontinue;
end elabModValue;

Expand Down Expand Up @@ -412,7 +415,7 @@ algorithm
equation
(cache,subs_1) = updateSubmods(cache,env, pre, subs, impl);
(cache,e_1,prop,_) = Static.elabExp(cache,env, e, impl, NONE,true);
(cache,e_val) = elabModValue(cache,env, e_1);
(cache,e_val) = elabModValue(cache,env,e_1,prop);
(cache,e_2) = Prefix.prefixExp(cache,env, e_1, pre);
Debug.fprint("updmod", "Updated mod: ");
Debug.fcall("updmod", printMod,
Expand All @@ -435,13 +438,7 @@ algorithm
equation
true = RTOpts.debugFlag("failtrace");
str = printModStr(m);
str = Util.stringDelimitList({ str, "\n"}," ");

Print.printBuf("- update_mod failed\n mod:");
Print.printBuf(str);

Debug.fprint("failtrace", "- update_mod failed mod:");
Debug.fprint("failtrace", str);
Debug.traceln("- Mod.updateMod failed mod: " +& str);
then
fail();
end matchcontinue;
Expand Down
15 changes: 9 additions & 6 deletions Compiler/Static.mo
Expand Up @@ -361,7 +361,7 @@ algorithm
equation
true = RTOpts.acceptMetaModelicaGrammar();
e = DAE.META_OPTION(NONE());
prop1 = DAE.PROP((DAE.T_METAOPTION((DAE.T_NOTYPE(),NONE)),NONE()),DAE.C_VAR());
prop1 = DAE.PROP((DAE.T_METAOPTION((DAE.T_NOTYPE(),NONE)),NONE()),DAE.C_CONST());
then
(cache,e,prop1,st);
/*-------------------------------------*/
Expand Down Expand Up @@ -463,7 +463,8 @@ algorithm
(cache,e,prop,st_1) = elabExp(cache,env, e1, impl, st,doVect);
t = Types.getPropType(prop);
e = DAE.META_OPTION(SOME(e));
prop1 = DAE.PROP((DAE.T_METAOPTION(t),NONE()),DAE.C_VAR());
c = Types.propAllConst(prop);
prop1 = DAE.PROP((DAE.T_METAOPTION(t),NONE()),c);
then
(cache,e,prop1,st);

Expand All @@ -472,7 +473,7 @@ algorithm
equation
true = RTOpts.acceptMetaModelicaGrammar();
e = DAE.META_OPTION(NONE());
prop1 = DAE.PROP((DAE.T_METAOPTION((DAE.T_NOTYPE(),NONE)),NONE()),DAE.C_VAR());
prop1 = DAE.PROP((DAE.T_METAOPTION((DAE.T_NOTYPE(),NONE)),NONE()),DAE.C_CONST());
then
(cache,e,prop1,st);

Expand Down Expand Up @@ -707,7 +708,6 @@ algorithm

c = Types.constAnd(c1,c2);
prop = DAE.PROP((DAE.T_LIST(t),NONE()),c);

then (cache,exp,prop,st);

// The Absyn.LIST() node is used for list expressions that are
Expand All @@ -719,20 +719,23 @@ algorithm
DAE.Type t;
equation
t = (DAE.T_LIST((DAE.T_NOTYPE,NONE)),NONE);
prop = DAE.PROP(t,DAE.C_VAR());
prop = DAE.PROP(t,DAE.C_CONST());
then (cache,DAE.LIST(DAE.ET_LIST(DAE.ET_OTHER()),{}),prop,st);

case (cache,env,Absyn.LIST(es),impl,st,doVect)
local
list<DAE.Properties> propList;
list<DAE.Type> typeList;
list<DAE.Const> constList;
Boolean correctTypes;
DAE.Type t;
equation
(cache,es_1,propList,st_2) = elabExpList(cache,env, es, impl, st,doVect);
typeList = Util.listMap(propList, Types.getPropType);
constList = Types.getConstList(propList);
c = Util.listReduce(constList, Types.constAnd) "The case empty list is handled above";
(es_1, t, _) = Types.listMatchSuperType(es_1, typeList, {}, Types.matchTypeRegular, true);
prop = DAE.PROP((DAE.T_LIST(t),NONE()),DAE.C_VAR());
prop = DAE.PROP((DAE.T_LIST(t),NONE()),c);
tp_1 = Types.elabType(t);
then (cache,DAE.LIST(tp_1,es_1),prop,st_2);
// ----------------------------------
Expand Down

0 comments on commit b092bd9

Please sign in to comment.