Skip to content

Commit

Permalink
- Updated Inst.getDerivedEnv - it no longer needs to check for possib…
Browse files Browse the repository at this point in the history
…le infinite recursion since lookupClass does that for us.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@5070 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Mar 3, 2010
1 parent 69c7b3f commit dc17006
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions Compiler/Inst.mo
Expand Up @@ -6329,22 +6329,6 @@ algorithm
then
(cache,Env.FRAME(id,cl,tps,imps,{},crs,enc,defineUnits)::fs,ih);

/* Special case to avoid infinite recursion.
* If in scope A.B and searching for A.B.C.D, look for C.D directly in the scope. Otherwise, A.B
* will be instantiated over and over again, see testcase packages2.mo
*/
case (cache,
(env as (Env.FRAME(id,cl,tps,imps,_,crs,enc,defineUnits) :: fs)),ih,SOME((tp,mod)))
equation
SOME(envpath) = Env.getEnvPath(env);
// print("Inst.getDerivedEnv: case 2 " +& Env.printEnvPathStr(env) +& "\n");
true = Absyn.pathPrefixOf(envpath,tp);
newTp = Absyn.removePrefix(envpath,tp);
(cache,env_2) = Lookup.lookupAndInstantiate(cache,env,newTp,mod,true);
// print("Inst.getDerivedEnv: case 2 end " +& Env.printEnvPathStr(env) +& "\n");
then
(cache,Env.FRAME(id,cl,tps,imps,env_2,crs,enc,defineUnits) :: fs,ih);

/* Base classes are fully qualified names, search from top scope.
* This is needed since the environment can be encapsulated, but inherited classes are not affected
* by this and therefore should search from top scope directly.
Expand All @@ -6353,8 +6337,7 @@ algorithm
(env as (Env.FRAME(id,cl,tps,imps,_,crs,enc,defineUnits) :: fs)),ih,SOME((tp,mod)))
equation
// print("Inst.getDerivedEnv: case 3 " +& Env.printEnvPathStr(env) +& ", " +& Absyn.pathString(tp) +& "\n");
top_frame = Env.topFrame(env);
(cache,env_2) = Lookup.lookupAndInstantiate(cache,{top_frame},tp,mod,true);
(cache,env_2) = Lookup.lookupAndInstantiate(cache,env,tp,mod,true);
// print("Inst.getDerivedEnv: case 3 end " +& Env.printEnvPathStr(env) +& "\n");
then
(cache,Env.FRAME(id,cl,tps,imps,env_2,crs,enc,defineUnits) :: fs,ih);
Expand Down

0 comments on commit dc17006

Please sign in to comment.