Skip to content

Commit 4a75005

Browse files
committed
- fixes for bug: #1953
Static.mo - handle Tuple op nonTuple - handle op Tuple - test for it: testsuite/flattening/modelica/operators/OperatorsTuples.mo Inst.mo - workaround for Modelica MSL bug: https://trac.modelica.org/Modelica/ticket/627 - remove when fixed git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@14067 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 7e0a299 commit 4a75005

File tree

2 files changed

+69
-11
lines changed

2 files changed

+69
-11
lines changed

Compiler/FrontEnd/Inst.mo

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7314,7 +7314,7 @@ algorithm
73147314
local
73157315
SCode.Element oldElt,newElt;
73167316
DAE.Mod oldMod,newMod;
7317-
String s1,s2;
7317+
String s1,s2,s;
73187318
SCode.Mod smod1, smod2;
73197319
Env.Env env, env1, env2;
73207320
Env.Cache cache;
@@ -7327,6 +7327,7 @@ algorithm
73277327
String n1, n2;
73287328
Option<Absyn.ArrayDim> ad1, ad2;
73297329
Option<Absyn.Exp> cond1, cond2;
7330+
Boolean b;
73307331

73317332
// try equality first!
73327333
case(cache,env,(oldElt,oldMod),(newElt,newMod))
@@ -7362,6 +7363,34 @@ algorithm
73627363
Error.addSourceMessage(Error.DUPLICATE_ELEMENTS_NOT_SYNTACTICALLY_IDENTICAL,{s1,s2}, aInfo);
73637364
then ();
73647365

7366+
// adrpo: handle bug: https://trac.modelica.org/Modelica/ticket/627
7367+
// TODO! FIXME! REMOVE! remove when the bug is fixed!
7368+
case (cache,env,(oldElt as SCode.COMPONENT(n1, prefixes1, attr1, tp1 as Absyn.TPATH(tpath1, ad1), smod1, _, cond1, aInfo),oldMod),
7369+
(newElt as SCode.COMPONENT(n2, prefixes2, attr2, tp2 as Absyn.TPATH(tpath2, ad2), smod2, _, cond2, _),newMod))
7370+
equation
7371+
// see if the most stuff is the same!
7372+
true = stringEq(n1, n2);
7373+
true = stringEq(n1, "m_flow");
7374+
true = SCode.prefixesEqual(prefixes1, prefixes2);
7375+
true = SCode.attributesEqual(attr1, attr2);
7376+
false = SCode.modEqual(smod1, smod2);
7377+
equality(ad1 = ad2);
7378+
equality(cond1 = cond2);
7379+
// if we lookup tpath1 and tpath2 and reach the same class, we're fine!
7380+
(_, c1, env1) = Lookup.lookupClass(cache, env, tpath1, false);
7381+
(_, c2, env2) = Lookup.lookupClass(cache, env, tpath2, false);
7382+
// the class has the same environment
7383+
true = stringEq(Env.printEnvPathStr(env1), Env.printEnvPathStr(env2));
7384+
// the classes are the same!
7385+
true = SCode.elementEqual(c1, c2);
7386+
// add a warning and let it continue!
7387+
s1 = SCodeDump.unparseElementStr(oldElt);
7388+
s2 = SCodeDump.unparseElementStr(newElt);
7389+
s = "Inherited elements are not identical: bug: https://trac.modelica.org/Modelica/ticket/627\n\tfirst: " +&
7390+
s1 +& "\n\tsecond: " +& s2 +& "\nContinue ....";
7391+
Error.addSourceMessage(Error.COMPILER_WARNING, {s}, aInfo);
7392+
then ();
7393+
73657394
// fail baby and add a source message!
73667395
case (cache, env, (oldElt as SCode.COMPONENT(info=aInfo),oldMod),(newElt,newMod))
73677396
equation

Compiler/FrontEnd/Static.mo

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12590,7 +12590,6 @@ algorithm
1259012590
end match;
1259112591
end isOpElemWise;
1259212592

12593-
1259412593
public function isFuncWithArrayInput
1259512594
input DAE.Type inType;
1259612595
output Boolean outBool;
@@ -12912,16 +12911,36 @@ algorithm
1291212911
local
1291312912
Env.Cache cache;
1291412913
Env.Env env;
12915-
list<tuple<DAE.Operator, list<DAE.Type>, DAE.Type>> opList;
12914+
list<tuple<DAE.Operator, list<DAE.Type>, DAE.Type>> opList;
1291612915
DAE.Type type1,type2, otype;
1291712916
DAE.Exp exp1,exp2,exp;
1291812917
DAE.Const const1,const2, const;
1291912918
DAE.Operator oper;
1292012919
Absyn.Operator aboper;
12921-
DAE.Properties prop;
12920+
DAE.Properties prop, props1, props2;
1292212921
Absyn.Exp absexp1, absexp2;
12923-
Boolean lastRound;
12922+
Boolean lastRound;
1292412923

12924+
// handle tuple op non_tuple
12925+
case (_, _, aboper, props1 as DAE.PROP_TUPLE(type_ = _), exp1, props2 as DAE.PROP(type_ = _), exp2, _, _, _, _, _, _, _)
12926+
equation
12927+
false = Config.acceptMetaModelicaGrammar();
12928+
(prop as DAE.PROP(type1, const1)) = Types.propTupleFirstProp(props1);
12929+
exp = DAE.TSUB(inExp1, 1, type1);
12930+
(cache, exp, prop) = operatorDeoverloadBinary(inCache, inEnv, inOperator1, prop, exp, inProp2, inExp2, AbExp, AbExp1, AbExp2, inImpl, inSymTab, inPre, inInfo);
12931+
then
12932+
(inCache, exp, prop);
12933+
12934+
// handle non_tuple op tuple
12935+
case (_, _, aboper, props1 as DAE.PROP(type_ = _), exp1, props2 as DAE.PROP_TUPLE(type_ = _), exp2, _, _, _, _, _, _, _)
12936+
equation
12937+
false = Config.acceptMetaModelicaGrammar();
12938+
(prop as DAE.PROP(type2, const2)) = Types.propTupleFirstProp(props2);
12939+
exp = DAE.TSUB(inExp2, 1, type2);
12940+
(cache, exp, prop) = operatorDeoverloadBinary(inCache, inEnv, inOperator1, inProp1, inExp1, prop, exp, AbExp, AbExp1, AbExp2, inImpl, inSymTab, inPre, inInfo);
12941+
then
12942+
(inCache, exp, prop);
12943+
1292512944
case (_, _, aboper, DAE.PROP(type1,const1), exp1, DAE.PROP(type2,const2), exp2, _, _, _, _, _, _, _)
1292612945
equation
1292712946
false = typeIsRecord(Types.arrayElementType(type1));
@@ -12934,7 +12953,7 @@ algorithm
1293412953
prop = DAE.PROP(otype,const);
1293512954
warnUnsafeRelations(inEnv,AbExp,const, type1,type2,exp1,exp2,oper,inPre);
1293612955
then
12937-
(inCache,exp, prop);
12956+
(inCache,exp, prop);
1293812957

1293912958
// The order of this two cases determines the priority given to operators
1294012959
// Now left has priority for all.
@@ -12950,17 +12969,17 @@ algorithm
1295012969
// If the right side is not record then (lastRound is true) which means we should print errors on this round (last one:).
1295112970
lastRound = not typeIsRecord(Types.arrayElementType(type2));
1295212971

12953-
(cache, exp , prop) = userDefOperatorDeoverloadBinary(cache,env,aboper,absexp1,absexp2,type1,type2,inImpl,inSymTab,inPre,inInfo,lastRound /**/);
12954-
(exp,_) = ExpressionSimplify.simplify(exp);
12972+
(cache, exp , prop) = userDefOperatorDeoverloadBinary(cache,env,aboper,absexp1,absexp2,type1,type2,inImpl,inSymTab,inPre,inInfo,lastRound /**/);
12973+
(exp,_) = ExpressionSimplify.simplify(exp);
1295512974
then
1295612975
(cache, exp, prop);
1295712976

1295812977
// if we have a record on the right side check for overloaded operators
1295912978
case(cache, env, aboper, DAE.PROP(type1, const1), exp1, DAE.PROP(type2, const2), exp2, _, absexp1, absexp2, _, _, _, _)
1296012979
equation
1296112980
true = typeIsRecord(Types.arrayElementType(type2));
12962-
(cache, exp , prop) = userDefOperatorDeoverloadBinary(cache,env,aboper,absexp2,absexp1,type2,type1,inImpl,inSymTab,inPre,inInfo, true); /*we have tried left side*/
12963-
(exp,_) = ExpressionSimplify.simplify(exp);
12981+
(cache, exp , prop) = userDefOperatorDeoverloadBinary(cache,env,aboper,absexp2,absexp1,type2,type1,inImpl,inSymTab,inPre,inInfo, true); /*we have tried left side*/
12982+
(exp,_) = ExpressionSimplify.simplify(exp);
1296412983
then
1296512984
(cache, exp, prop);
1296612985

@@ -13008,7 +13027,17 @@ algorithm
1300813027
Absyn.Operator aboper;
1300913028
DAE.Properties prop;
1301013029
Absyn.Exp absexp1;
13011-
13030+
13031+
// handle op tuple
13032+
case (_, _, aboper, DAE.PROP_TUPLE(type_ = _), exp1, _, _, _, _, _, _)
13033+
equation
13034+
false = Config.acceptMetaModelicaGrammar();
13035+
(prop as DAE.PROP(type1, const)) = Types.propTupleFirstProp(inProp1);
13036+
exp = DAE.TSUB(exp1, 1, type1);
13037+
(cache, exp, prop) = operatorDeoverloadUnary(inCache, inEnv, inOperator1, prop, exp, AbExp, AbExp1, inImpl, inSymTab, inPre, inInfo);
13038+
then
13039+
(cache, exp, prop);
13040+
1301213041
case (_, _, aboper, DAE.PROP(type1,const), exp1, _, _, _, _, _, _)
1301313042
equation
1301413043
false = typeIsRecord(Types.arrayElementType(type1));

0 commit comments

Comments
 (0)