Skip to content

Commit

Permalink
- Fixed Env.cacheGetEnv2 so that it searches all branches of the Cach…
Browse files Browse the repository at this point in the history
…eTree when

  looking up qualified names, and not just the first one. This was needed for
	bug #1151.
- Added testcase Lookup10 that tests the fix in Env.cacheGetEnv2.
- Commented out some debug-related lines in Inst.



git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@5118 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed Mar 10, 2010
1 parent fe850cb commit dab774d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
21 changes: 20 additions & 1 deletion Compiler/Env.mo
Expand Up @@ -1359,6 +1359,12 @@ algorithm
//print("found qualified (1) ");print(id);print("\n");
env = cacheGetEnv2(path2,path,CACHETREE(id2,env2,children2));
then env;

// for qualified name, try next.
case (Absyn.QUALIFIED(id, path2), path, CACHETREE(id2, env2, _ :: children))
equation
env = cacheGetEnv2(Absyn.QUALIFIED(id, path2), path, CACHETREE(id2, env2, children));
then env;
end matchcontinue;
end cacheGetEnv2;

Expand Down Expand Up @@ -1653,6 +1659,18 @@ algorithm
Integer rhval,h;
AvlTree t_1,t,right_1,left_1,bt;


case (AVLTREENODE(value = NONE,height=h,left = NONE,right = NONE),key as "lskf",value)
then AVLTREENODE(SOME(AVLTREEVALUE(key,value)),1,NONE,NONE);

/* Replace this node */
case (AVLTREENODE(value = SOME(AVLTREEVALUE(rkey,rval)),height=h,left = left,right = right),key as "lskf",value)
equation
equality(rkey = key);
bt = balance(AVLTREENODE(SOME(AVLTREEVALUE(rkey,value)),h,left,right));
then
bt;

/* empty tree*/
case (AVLTREENODE(value = NONE,height=h,left = NONE,right = NONE),key,value)
then AVLTREENODE(SOME(AVLTREEVALUE(key,value)),1,NONE,NONE);
Expand All @@ -1664,7 +1682,7 @@ algorithm
bt = balance(AVLTREENODE(SOME(AVLTREEVALUE(rkey,value)),h,left,right));
then
bt;

/* Insert to right */
case (AVLTREENODE(value = SOME(AVLTREEVALUE(rkey,rval)),height=h,left = left,right = (right)),key,value)
equation
Expand All @@ -1684,6 +1702,7 @@ algorithm
bt = balance(AVLTREENODE(SOME(AVLTREEVALUE(rkey,rval)),h,SOME(t_1),right));
then
bt;

case (_,_,_)
equation
print("avlTreeAdd failed\n");
Expand Down
8 changes: 4 additions & 4 deletions Compiler/Inst.mo
Expand Up @@ -254,15 +254,15 @@ algorithm
pfunc = Util.listSelect(p, SCode.isFunction);
(cache,env) = Builtin.initialEnv(cache);
// Debug.fprintln("insttr", "Instantiating functions");
pfuncnames = Util.listMap(pfunc, SCode.className);
str1 = Util.stringDelimitList(pfuncnames, ", ");
// pfuncnames = Util.listMap(pfunc, SCode.className);
// str1 = Util.stringDelimitList(pfuncnames, ", ");
// Debug.fprint("insttr", "Instantiating functions: ");
// Debug.fprintln("insttr", str1);
envimpl = Env.extendFrameClasses(env, p) "pfunc" ;
(cache,envimpl_1,oIH1,lfunc) = instProgramImplicit(cache, envimpl, iIH, pfunc);
// Debug.fprint("insttr", "Instantiating other classes: ");
pnofuncnames = Util.listMap(pnofunc, SCode.className);
str2 = Util.stringDelimitList(pnofuncnames, ", ");
// pnofuncnames = Util.listMap(pnofunc, SCode.className);
// str2 = Util.stringDelimitList(pnofuncnames, ", ");
// Debug.fprintln("insttr", str2);
(cache, oIH2, lnofunc) = instProgram(cache, envimpl_1, oIH1, pnofunc);
l = DAEUtil.joinDaes(lfunc, lnofunc);
Expand Down

0 comments on commit dab774d

Please sign in to comment.