Skip to content

Commit 7d0e021

Browse files
author
Peter Aronsson
committed
-Fixed bug with prefixing of expressions inside subscripts of component references (Bug reported by Hannes Edinger). (testcase in ArrayIndex.mo)
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@5908 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent ce8d339 commit 7d0e021

File tree

5 files changed

+166
-108
lines changed

5 files changed

+166
-108
lines changed

Compiler/ConnectUtil.mo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,7 +1443,7 @@ algorithm
14431443
(_,dimSizesOpt) = Types.flattenArrayTypeOpt(tp);
14441444
dimExps = Util.listMap(dimSizes,Exp.makeIntegerExp);
14451445
(cache,res) = generateZeroflowEquations(cache,xs,env,prefix,deletedComponents);
1446-
cr2 = PrefixUtil.prefixCref(prefix,cr);
1446+
(cache,cr2) = PrefixUtil.prefixCref(cache,env,InnerOuter.emptyInstHierarchy,prefix,cr);
14471447
arrType = DAE.ET_ARRAY(DAE.ET_REAL(),dimSizesOpt);
14481448
dimExps = {DAE.ICONST(0),DAE.ICONST(0),DAE.ICONST(0)};
14491449
res1 = generateZeroflowArrayEquations(cr2, dimSizes, DAE.RCONST(0.0));
@@ -1455,7 +1455,7 @@ algorithm
14551455
(cache,_,tp,_,_,_,_,_,_) = Lookup.lookupVar(cache,env,cr);
14561456
false = Types.isArray(tp); // scalar
14571457
(cache,DAE.DAE(elts,funcs)) = generateZeroflowEquations(cache,xs,env,prefix,deletedComponents);
1458-
cr2 = PrefixUtil.prefixCref(prefix,cr);
1458+
(cache,cr2) = PrefixUtil.prefixCref(cache,env,InnerOuter.emptyInstHierarchy,prefix,cr);
14591459
//print(" Generated flow equation for: " +& Exp.printComponentRefStr(cr2) +& "\n");
14601460
then
14611461
(cache,DAE.DAE(DAE.EQUATION(DAE.CREF(cr2,DAE.ET_REAL()),DAE.RCONST(0.0), DAE.emptyElementSource) :: elts,funcs));

Compiler/InnerOuter.mo

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ algorithm
331331
case(Connect.OUTERCONNECT(scope,cr1,io1,f1,cr2,io2,f2,source)::ocs,repl,sources,targets)
332332
equation
333333
(_,true) = innerOuterBooleans(io1);
334-
cr3 = PrefixUtil.prefixCref(scope,cr1);
334+
(_,cr3) = PrefixUtil.prefixCref(Env.emptyCache(),{},emptyInstHierarchy,scope,cr1);
335335
// adrpo: not needed as the sources/targets are send from up ABOVE :)
336336
src = sources; // VarTransform.replacementSources(repl);
337337
dst = targets; // VarTransform.replacementTargets(repl);
@@ -346,7 +346,7 @@ algorithm
346346
case(Connect.OUTERCONNECT(scope,cr1,io1,f1,cr2,io2,f2,source)::ocs,repl,sources,targets)
347347
equation
348348
(_,true) = innerOuterBooleans(io2);
349-
cr3 = PrefixUtil.prefixCref(scope,cr2);
349+
(_,cr3) = PrefixUtil.prefixCref(Env.emptyCache(),{},emptyInstHierarchy,scope,cr2);
350350
// adrpo: not needed as the sources/targets are send from up ABOVE :)
351351
src = sources; // VarTransform.replacementSources(repl);
352352
dst = targets; // VarTransform.replacementTargets(repl);
@@ -421,7 +421,7 @@ algorithm
421421
case(Connect.OUTERCONNECT(scope,cr1,io1,f1,cr2,io2,f2,source)::ocs)
422422
equation
423423
(_,true) = innerOuterBooleans(io1);
424-
// cr3 = PrefixUtil.prefixCref(scope,cr1);
424+
// (_,cr3) = PrefixUtil.prefixCref(Env.emptyCache(),{},emptyInstHierarchy,scope,cr1);
425425
// ncr1 = cr3;
426426
ncr1 = PrefixUtil.prefixToCref(scope);
427427
// Debug.fprintln("ios", "changeInnerOuterInOuterConnect: changing left: " +&
@@ -436,7 +436,7 @@ algorithm
436436
case(Connect.OUTERCONNECT(scope,cr1,io1,f1,cr2,io2,f2,source)::ocs)
437437
equation
438438
(_,true) = innerOuterBooleans(io2);
439-
// cr3 = PrefixUtil.prefixCref(scope,cr2);
439+
// (_,cr3) = PrefixUtil.prefixCref(Env.emptyCache(),{},emptyInstHierarchy,scope,cr2);
440440
// ncr2 = cr3;
441441
ncr2 = PrefixUtil.prefixToCref(scope);
442442
// Debug.fprintln("ios", "changeInnerOuterInOuterConnect: changing right: " +&
@@ -1225,7 +1225,7 @@ algorithm
12251225
// Debug.fprintln("innerouter", "InnerOuter.lookupInnerInIH : stripping and looking for: " +& PrefixUtil.printPrefixStr(prefix) +& "/" +& name);
12261226

12271227
// put the name as the last prefix
1228-
cref = PrefixUtil.prefixCref(prefix, DAE.CREF_IDENT(name, DAE.ET_OTHER(), {}));
1228+
(_,cref) = PrefixUtil.prefixCref(Env.emptyCache(),{},emptyInstHierarchy,prefix, DAE.CREF_IDENT(name, DAE.ET_OTHER(), {}));
12291229

12301230
// search in instance hierarchy
12311231
(instInner as INST_INNER(innerPrefix, _, io, _, _)) = get(cref, ht);
@@ -1249,7 +1249,7 @@ algorithm
12491249
// Debug.fprintln("innerouter", "InnerOuter.lookupInnerInIH : stripping and looking for: " +& PrefixUtil.printPrefixStr(prefix) +& "/" +& name);
12501250

12511251
// put the name as the last prefix
1252-
cref = PrefixUtil.prefixCref(prefix, DAE.CREF_IDENT(name, DAE.ET_OTHER(), {}));
1252+
(_,cref) = PrefixUtil.prefixCref(Env.emptyCache(),{},emptyInstHierarchy,prefix, DAE.CREF_IDENT(name, DAE.ET_OTHER(), {}));
12531253

12541254
// search in instance hierarchy we had a failure
12551255
failure(instInner = get(cref, ht));
@@ -1353,7 +1353,7 @@ public function switchInnerToOuterAndPrefix
13531353
absynCommentOption = comment,
13541354
innerOuter=Absyn.INNER()) :: r),io,pre)
13551355
equation
1356-
cr = PrefixUtil.prefixCref(pre, cr);
1356+
(_,cr) = PrefixUtil.prefixCref(Env.emptyCache(),{},emptyInstHierarchy,pre, cr);
13571357
r_1 = switchInnerToOuterAndPrefix(r, io, pre);
13581358
then
13591359
(DAE.VAR(cr,vk,dir,prot,t,e,id,flowPrefix,streamPrefix,source,dae_var_attr,comment,io) :: r_1);
@@ -1427,7 +1427,7 @@ public function prefixOuterDaeVars
14271427
absynCommentOption = comment,
14281428
innerOuter=io) :: r),crefPrefix)
14291429
equation
1430-
cr = PrefixUtil.prefixCref(crefPrefix, cr);
1430+
(_,cr) = PrefixUtil.prefixCref(Env.emptyCache(),{},emptyInstHierarchy,crefPrefix, cr);
14311431
r_1 = prefixOuterDaeVars(r, crefPrefix);
14321432
then
14331433
(DAE.VAR(cr,vk,dir,prot,t,e,id,flowPrefix,streamPrefix,source,dae_var_attr,comment,io) :: r_1);
@@ -1685,7 +1685,7 @@ algorithm
16851685
equation
16861686
false = Absyn.isInner(inInnerOuter);
16871687
// prefix the name!
1688-
cref = PrefixUtil.prefixCref(inPrefix, DAE.CREF_IDENT(name, DAE.ET_OTHER(), {}));
1688+
(_,cref) = PrefixUtil.prefixCref(Env.emptyCache(),{},emptyInstHierarchy,inPrefix, DAE.CREF_IDENT(name, DAE.ET_OTHER(), {}));
16891689
// print ("InnerOuter.updateInstHierarchy jumping over non-inner: " +& Exp.printComponentRefStr(cref) +& "\n");
16901690
then
16911691
ih;*/
@@ -1705,7 +1705,7 @@ algorithm
17051705
inInstInner as INST_INNER(_, name, io, _, _))
17061706
equation
17071707
// prefix the name!
1708-
cref = PrefixUtil.prefixCref(inPrefix, DAE.CREF_IDENT(name, DAE.ET_OTHER(), {}));
1708+
(_,cref) = PrefixUtil.prefixCref(Env.emptyCache(),{},emptyInstHierarchy,inPrefix, DAE.CREF_IDENT(name, DAE.ET_OTHER(), {}));
17091709
// add to hashtable!
17101710
// Debug.fprintln("innerouter", "InnerOuter.updateInstHierarchy adding: " +&
17111711
// PrefixUtil.printPrefixStr(inPrefix) +& "/" +& name +& " to IH");
@@ -1717,7 +1717,7 @@ algorithm
17171717
case(ih,inPrefix,inInnerOuter,inInstInner as INST_INNER(_, name, io, _, _))
17181718
equation
17191719
// prefix the name!
1720-
cref = PrefixUtil.prefixCref(inPrefix, DAE.CREF_IDENT("UNKNOWN", DAE.ET_OTHER(), {}));
1720+
(_,cref) = PrefixUtil.prefixCref(Env.emptyCache(),{},emptyInstHierarchy,inPrefix, DAE.CREF_IDENT("UNKNOWN", DAE.ET_OTHER(), {}));
17211721
// Debug.fprintln("innerouter", "InnerOuter.updateInstHierarchy failure for: " +&
17221722
// PrefixUtil.printPrefixStr(inPrefix) +& "/" +& name);
17231723
then
@@ -1801,7 +1801,7 @@ algorithm
18011801
// we have some outer references, search for our prefix + cref in them
18021802
case ({TOP_INSTANCE(_, _, outerPrefixes)}, inOuterComponentRef, inPrefix)
18031803
equation
1804-
fullCref = PrefixUtil.prefixCref(inPrefix, inOuterComponentRef);
1804+
(_,fullCref) = PrefixUtil.prefixCref(Env.emptyCache(),{},emptyInstHierarchy,inPrefix, inOuterComponentRef);
18051805

18061806
// this will fail if we don't find it so prefixing can happen in the calling function
18071807
(outerCrefPrefix, innerCrefPrefix) = searchForInnerPrefix(fullCref, outerPrefixes);

0 commit comments

Comments
 (0)