Skip to content

Commit

Permalink
- fix code generation for OpenTURNS (Uncertainties) which was broken …
Browse files Browse the repository at this point in the history
…since r22958 (bad assert).

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@25024 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Mar 11, 2015
1 parent 3e4a58a commit 76e956b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
6 changes: 4 additions & 2 deletions Compiler/BackEnd/OpenTURNS.mo
Expand Up @@ -380,7 +380,7 @@ algorithm
varLst := BackendDAEUtil.getAllVarLst(dae2);
varLst := List.select(varLst,BackendVariable.varHasDistributionAttribute);

Error.assertion(List.isEmpty(varLst), "OpenTURNS.generateDistributions: No variable in the DAE has the distribution attribute! Check your model ...", Absyn.dummyInfo);
Error.assertion(not List.isEmpty(varLst), "OpenTURNS.generateDistributions: No variable in the DAE has the distribution attribute! Check your model ...", Absyn.dummyInfo);
dists := List.map(varLst,BackendVariable.varDistribution);
(sLst,distributionVarLst) := List.map1_2(List.threadTuple(dists,List.map(varLst,BackendVariable.varCref)),generateDistributionVariable,dae2);

Expand Down Expand Up @@ -633,8 +633,10 @@ protected
DAE.Exp val;
String valStr;
Integer p1,p2,plow,phigh;
Absyn.Path fpath;
algorithm
DAE.CALL(path = Absyn.IDENT("Correlation"),expLst = {DAE.CREF(cr1,_),DAE.CREF(cr2,_),val}) := exp;
DAE.CALL(path = fpath,expLst = {DAE.CREF(cr1,_),DAE.CREF(cr2,_),val}) := exp;
Absyn.IDENT("Correlation") := Absyn.makeNotFullyQualified(fpath);
valStr := ExpressionDump.printExpStr(val);
p1 := List.position(ComponentReference.crefStr(cr1),uncertainVars)-1 "TODO: remove shift if possible";
p2 := List.position(ComponentReference.crefStr(cr2),uncertainVars)-1 "TODO: remove shift if possible";
Expand Down
21 changes: 15 additions & 6 deletions Compiler/FrontEnd/Expression.mo
Expand Up @@ -8804,7 +8804,7 @@ algorithm
local
Integer i;
DAE.Exp cr,c1,c2,e1,e2,e,c,t,f,cref;
String s,str;
String s,str,s1,s2;
Boolean res,res1,res2,res3;
list<Boolean> reslist;
list<DAE.Exp> explist,args;
Expand Down Expand Up @@ -8842,9 +8842,9 @@ algorithm
then
res;

case ((DAE.CREF()),_ ) then false;
case ((DAE.CREF()), _) then false;

case (DAE.BINARY(exp1 = e1,exp2 = e2),cr )
case (DAE.BINARY(exp1 = e1,exp2 = e2),cr)
equation
res1 = expContains(e1, cr);
res2 = expContains(e2, cr);
Expand Down Expand Up @@ -8916,6 +8916,14 @@ algorithm
then
res;

/*/ record constructors
case (DAE.RECORD(exps = args),(cr as DAE.CREF()))
equation
reslist = List.map1(args, expContains, cr);
res = Util.boolOrList(reslist);
then
res; */

case (DAE.CAST(ty = DAE.T_REAL(),exp = DAE.ICONST()),_ ) then false;

case (DAE.CAST(ty = DAE.T_REAL(),exp = e),cr )
Expand All @@ -8939,12 +8947,13 @@ algorithm
then
res;

case (e,_)
case (_,_)
equation
true = Flags.isSet(Flags.FAILTRACE);
Debug.trace("- Expression.expContains failed\n");
s = ExpressionDump.printExpStr(e);
str = stringAppendList({"exp = ",s});
s1 = ExpressionDump.printExpStr(inExp1);
s2 = ExpressionDump.printExpStr(inExp2);
str = stringAppendList({"exp = ", s1," subexp = ", s2});
Debug.traceln(str);
then
fail();
Expand Down

0 comments on commit 76e956b

Please sign in to comment.