Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- Partial fix to make final modifications work on redeclares. Now passes front-end, but loses some modifications. Possibly related to #1922.


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@13890 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Nov 14, 2012
1 parent 5b79e8d commit 0c9491b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
29 changes: 13 additions & 16 deletions Compiler/FrontEnd/Mod.mo
Expand Up @@ -1724,12 +1724,14 @@ algorithm
local
DAE.Mod m;
list<DAE.SubMod> submods;
String strPrefix, s;
String strPrefix, s1, s2, s3, s4;
Option<Absyn.Path> p;

case (DAE.NOMOD(),DAE.NOMOD(),_,_) then DAE.NOMOD();
case (DAE.NOMOD(),m,_,_) then m;
case (m,DAE.NOMOD(),_,_) then m;
/* That's a NOMOD() if I ever saw one... */
case (m,DAE.MOD(subModLst={},eqModOption=NONE()),_,_) then m;

case(_,_,_,_)
equation
Expand All @@ -1739,9 +1741,10 @@ algorithm
case(_,_,_,_)
equation
true = modSubsetOrEqualOrNonOverlap(inModOuter,inModInner);
then doMerge(inModOuter,inModInner,inEnv,inPrefix);
m = doMerge(inModOuter,inModInner,inEnv,inPrefix);
then m;

// two exactly the same redeclares, return just one!
// two exactly the same mod, return just one! (used when it is REDECL or a submod is REDECL)
case(DAE.REDECL(finalPrefix = _),DAE.REDECL(finalPrefix = _),_,_)
equation
true = valueEq(inModOuter,inModInner);
Expand All @@ -1753,17 +1756,11 @@ algorithm
false = merge2(inModInner);
false = modSubsetOrEqualOrNonOverlap(inModOuter,inModInner);
p = Env.getEnvPath(inEnv);
s = Absyn.optPathString(p);
// put both modifiers in one big modifier
strPrefix = PrefixUtil.printPrefixStrIgnoreNoPre(inPrefix);
submods = {DAE.NAMEMOD("", inModOuter), DAE.NAMEMOD("", inModInner)};
m = DAE.MOD(SCode.NOT_FINAL(), SCode.NOT_EACH(), submods, NONE());
s = s +& "\n\tby using modifiers: " +& strPrefix +& printSubsStr(submods, true) +&
" that do not agree.";

Error.addMessage(Error.FINAL_OVERRIDE, {s}); // having a string there incase we
// print(" final override: " +& s +& "\n ");
// print("trying to override final while merging mod1:\n" +& printModStr(inModOuter) +& " with mod2(final):\n" +& printModStr(inModInner) +& "\n");
s1 = PrefixUtil.printPrefixStrIgnoreNoPre(inPrefix);
s2 = Absyn.optPathString(p);
s3 = printModStr(inModOuter);
s4 = printModStr(inModInner);
Error.addMessage(Error.FINAL_OVERRIDE, {s1,s2,s3,s4});
then fail();
end matchcontinue;
end merge;
Expand Down Expand Up @@ -2124,7 +2121,7 @@ algorithm
then
true;
case(DAE.REDECL(_,_,_),DAE.REDECL(_,_,_))
then false;
then valueEq(mod1,mod2);
case(DAE.NOMOD(),DAE.NOMOD()) then true;
case (_,_) then false;
case(_, _)
Expand Down Expand Up @@ -2262,7 +2259,7 @@ algorithm
then
true;

case(DAE.REDECL(_,_,_),DAE.REDECL(_,_,_)) then false;
case(DAE.REDECL(_,_,_),DAE.REDECL(_,_,_)) then valueEq(mod1,mod2);
case(DAE.NOMOD(),DAE.NOMOD()) then true;

// adrpo: do not fail, return false!
Expand Down
2 changes: 1 addition & 1 deletion Compiler/Util/Error.mo
Expand Up @@ -583,7 +583,7 @@ public constant Message SETTING_FIXED_ATTRIBUTE = MESSAGE(503, TRANSLATION(), WA
public constant Message FAILED_TO_EVALUATE_FUNCTION = MESSAGE(506, TRANSLATION(), ERROR(),
Util.gettext("Failed to evaluate function: %s"));
public constant Message FINAL_OVERRIDE = MESSAGE(508, TRANSLATION(), ERROR(),
Util.gettext("trying to override final variable in class: %s"));
Util.gettext("Trying to override final variable in component %s and scope %s by using modifiers: %s and %s that do not agree."));
public constant Message WARNING_RELATION_ON_REAL = MESSAGE(509, TRANSLATION(), WARNING(),
Util.gettext("In component %s, in relation %s, %s on Reals is only allowed inside functions."));
public constant Message OUTER_MODIFICATION = MESSAGE(512, TRANSLATION(), WARNING(),
Expand Down

0 comments on commit 0c9491b

Please sign in to comment.