Skip to content

Commit

Permalink
- Do updateCompeltsMods also when doing a partial instantiation (this…
Browse files Browse the repository at this point in the history
… solves some issues in Modelica.Media; some others remain though).

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@5293 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Apr 12, 2010
1 parent 234d69e commit ff0a8e9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
15 changes: 9 additions & 6 deletions Compiler/Inst.mo
Expand Up @@ -4113,6 +4113,8 @@ algorithm
(cache,env3,ih,_/*Skip collecting functions here, since partial */) = addComponentsToEnv(cache, env2, ih, mods, pre, csets, ci_state,
lst_constantEls, lst_constantEls, {},
inst_dims, false);
(cache,env3,ih,lst_constantEls,csets,_) = updateCompeltsMods(cache,env3,ih, pre, lst_constantEls, ci_state, csets, true);

//lst_constantEls = listAppend(extcomps,lst_constantEls);
(cache,env3,ih,_,_,_,ci_state2,_,_) =
instElementList(cache, env3, ih, UnitAbsyn.noStore, mods, pre, csets, ci_state1, lst_constantEls,
Expand Down Expand Up @@ -5186,7 +5188,7 @@ algorithm
DAE.DAElist dae,dae2,fdae,fdae0,fdae1,fdae2,fdae3,fdae4,fdae5,fdae6,fdae7;
DAE.ComponentRef vn;
Absyn.ComponentRef owncref;
list<Absyn.ComponentRef> crefs,crefs2,crefs3,crefs_1,crefs_2;
list<Absyn.ComponentRef> crefs,crefs2,crefs3,crefs4,crefs_1,crefs_2;
SCode.Element comp,el;
SCode.Attributes attr;
list<Absyn.Subscript> ad;
Expand Down Expand Up @@ -5285,7 +5287,7 @@ algorithm
inst_dims,impl,graph)
equation
//print(" instElement: A component: " +& n +& "\n");
//Debug.traceln(" instElement " +& n +& " in s:" +& Env.printEnvPathStr(env) +& " m: " +& SCode.printModStr(m) +& " cm : " +& Mod.printModStr(cmod));
//Debug.fprintln("debug"," instElement " +& n +& " in s:" +& Env.printEnvPathStr(env) +& " m: " +& SCode.printModStr(m) +& " cm : " +& Mod.printModStr(cmod));
m = traverseModAddFinal(m, finalPrefix);
comp = SCode.COMPONENT(n,io,finalPrefix,repl,prot,attr,ts,m,comment,cond,aInfo,cc);
// Fails if multiple decls not identical
Expand Down Expand Up @@ -7077,13 +7079,14 @@ protected function updateComponentsInEnv
output Connect.Sets outSets;
output DAE.DAElist outDae "contain functions";
protected
String myTick;
String myTick, crefsStr;
algorithm
//myTick := intString(tick());
//Debug.traceln("start update comps " +& myTick);
//crefsStr := Util.stringDelimitList(Util.listMap(crefs, Dump.printComponentRefStr),",");
//Debug.fprintln("debug","start update comps " +& myTick +& " # " +& crefsStr);
(outCache,outEnv,outIH,outSets,_,outDae):=
updateComponentsInEnv2(cache,env,inIH,pre,mod,crefs,ci_state,csets,impl,HashTable5.emptyHashTable());
//Debug.traceln("finished update comps" +& myTick);
//Debug.fprintln("debug","finished update comps" +& myTick);
//print("outEnv:");print(Env.printEnvStr(outEnv));print("\n");
end updateComponentsInEnv;

Expand Down Expand Up @@ -7288,7 +7291,7 @@ algorithm
/* The environment is extended with the new variable binding. */
(cache,binding) = makeBinding(cache, env, attr, mod_3, ty);
/* type info present */
//Debug.traceln("VAR " +& name +& " has new type " +& Types.unparseType(ty) +& ", " +& Types.printBindingStr(binding) +& "m:" +& SCode.printModStr(m));
//Debug.fprintln("debug","VAR " +& name +& " has new type " +& Types.unparseType(ty) +& ", " +& Types.printBindingStr(binding) +& "m:" +& SCode.printModStr(m));
env = Env.updateFrameV(env, DAE.TYPES_VAR(name,dattr,prot,ty,binding,NONE()), Env.VAR_TYPED(), compenv);
//updatedComps = HashTable5.delete(cref,updatedComps);

Expand Down
7 changes: 5 additions & 2 deletions Compiler/InstExtends.mo
Expand Up @@ -111,6 +111,7 @@ algorithm
ClassInf.State new_ci_state;
InstanceHierarchy ih;
HashTableStringToPath.HashTable ht;
Integer tmp;
/* instantiate a base class */
case (cache,env,ih,mod,(SCode.EXTENDS(baseClassPath = tp,modifications = emod) :: rest),ci_state,className,impl,isPartialInst)
equation
Expand Down Expand Up @@ -148,11 +149,13 @@ algorithm
ht = getLocalIdentList(cdefelts,ht,getLocalIdentElement);
ht = getLocalIdentList(importelts,ht,getLocalIdentElement);

//tmp = tick(); Debug.traceln("try fix local idents " +& intString(tmp));
(cache,compelts1) = fixLocalIdents(cache,cenv1,compelts1,ht);
(cache,eq1_1) = fixList(cache,cenv1,eq1_1,ht,fixEquation);
(cache,ieq1_1) = fixList(cache,cenv1,ieq1_1,ht,fixEquation);
(cache,alg1_1) = fixList(cache,cenv1,alg1_1,ht,fixAlgorithm);
(cache,ialg1_1) = fixList(cache,cenv1,ialg1_1,ht,fixAlgorithm);
//Debug.traceln("fixed local idents " +& intString(tmp));

(env,ih) = Inst.addClassdefsToEnv(env,ih,cdefelts,impl,NONE);
(cache,env2,ih,mods_1,compelts2,eq3,ieq3,alg3,ialg3) = instExtendsList(cache,env,ih,mod,rest,ci_state,className,impl,isPartialInst)
Expand Down Expand Up @@ -240,9 +243,11 @@ public function instExtendsAndClassExtendsList "
protected
list<tuple<SCode.Element, DAE.Mod, Boolean>> outTplSCodeElementModLstTpl3;
algorithm
//Debug.fprintln("debug","instExtendsAndClassExtendsList: " +& inClassName);
(outCache,outEnv,outIH,outMod,outTplSCodeElementModLstTpl3,outSCodeNormalEquationLst,outSCodeInitialEquationLst,outSCodeNormalAlgorithmLst,outSCodeInitialAlgorithmLst):=
instExtendsAndClassExtendsList2(inCache,inEnv,inIH,inMod,inExtendsElementLst,inClassExtendsElementLst,inState,inClassName,inImpl,isPartialInst);
outTplSCodeElementModLst := Util.listMap(outTplSCodeElementModLstTpl3, Util.tuple312);
//Debug.fprintln("debug","instExtendsAndClassExtendsList: " +& inClassName +& " done");
end instExtendsAndClassExtendsList;

protected function instExtendsAndClassExtendsList2 "
Expand Down Expand Up @@ -270,11 +275,9 @@ protected function instExtendsAndClassExtendsList2 "
output list<SCode.Algorithm> outSCodeNormalAlgorithmLst;
output list<SCode.Algorithm> outSCodeInitialAlgorithmLst;
algorithm
//Debug.traceln("instExtendsAndClassExtendsList: " +& inClassName);
(outCache,outEnv,outIH,outMod,outTplSCodeElementModLst,outSCodeNormalEquationLst,outSCodeInitialEquationLst,outSCodeNormalAlgorithmLst,outSCodeInitialAlgorithmLst):=
instExtendsList(inCache,inEnv,inIH,inMod,inExtendsElementLst,inState,inClassName,inImpl,isPartialInst);
(outMod,outTplSCodeElementModLst):=instClassExtendsList(outMod,inClassExtendsElementLst,outTplSCodeElementModLst);
//Debug.traceln("instExtendsAndClassExtendsList: " +& inClassName +& " done");
end instExtendsAndClassExtendsList2;

protected function instClassExtendsList
Expand Down

0 comments on commit ff0a8e9

Please sign in to comment.