Skip to content

Commit

Permalink
- Fix RML crap
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund committed Oct 27, 2010
1 parent d1ece24 commit dc792e7
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 108 deletions.
40 changes: 22 additions & 18 deletions Compiler/AbsynDep.mo
Expand Up @@ -449,12 +449,14 @@ protected function doBalance3 "help function to doBalance2"
output AvlTree outBt;
algorithm
outBt := matchcontinue(bt)
local AvlTree rr;
case(bt) equation
true = differenceInHeight(getOption(rightNode(bt))) > 0;
rr = rotateRight(getOption(rightNode(bt)));
bt = setRight(bt,SOME(rr));
then bt;
local
AvlTree rr;
case (bt)
equation
true = differenceInHeight(getOption(rightNode(bt))) > 0;
rr = rotateRight(getOption(rightNode(bt)));
bt = setRight(bt,SOME(rr));
then bt;
case(bt) then bt;
end matchcontinue;
end doBalance3;
Expand Down Expand Up @@ -519,21 +521,23 @@ algorithm
end rightNode;

protected function exchangeLeft "help function to balance"
input AvlTree node;
input AvlTree parent;
output AvlTree outParent "updated parent";
input AvlTree node;
input AvlTree parent;
output AvlTree outParent "updated parent";
algorithm
outParent := matchcontinue(node,parent)
local Option<AvlTreeValue> value;
Integer height ;
AvlTree left,right,bt,leftNode,rightNode;
local
Option<AvlTreeValue> value;
Integer height;
AvlTree bt;

case(node,parent) equation
parent = setRight(parent,leftNode(node));
parent = balance(parent);
node = setLeft(node,SOME(parent));
bt = balance(node);
then bt;
case (node,parent)
equation
parent = setRight(parent,leftNode(node));
parent = balance(parent);
node = setLeft(node,SOME(parent));
bt = balance(node);
then bt;
end matchcontinue;
end exchangeLeft;

Expand Down
13 changes: 7 additions & 6 deletions Compiler/DAEUtil.mo
Expand Up @@ -4583,14 +4583,15 @@ algorithm
end rightNode;

protected function exchangeLeft "help function to balance"
input DAE.AvlTree node;
input DAE.AvlTree parent;
output DAE.AvlTree outParent "updated parent";
input DAE.AvlTree node;
input DAE.AvlTree parent;
output DAE.AvlTree outParent "updated parent";
algorithm
outParent := matchcontinue(node,parent)
local Option<DAE.AvlTreeValue> value;
Integer height ;
DAE.AvlTree left,right,bt,leftNode,rightNode;
local
Option<DAE.AvlTreeValue> value;
Integer height;
DAE.AvlTree bt;

case(node,parent) equation
parent = setRight(parent,leftNode(node));
Expand Down
42 changes: 6 additions & 36 deletions Compiler/Env.mo
Expand Up @@ -1663,37 +1663,15 @@ public function avlTreeAdd "
input AvlKey inKey;
input AvlValue inValue;
output AvlTree outAvlTree;
partial function FuncTypeKeyToInteger
input AvlKey inKey;
output Integer outInteger;
end FuncTypeKeyToInteger;
algorithm
outAvlTree := matchcontinue (inAvlTree,inKey,inValue)
local
partial function FuncTypeStringToInteger
input AvlKey inString;
output Integer outInteger;
end FuncTypeStringToInteger;
AvlKey key,rkey;
AvlValue value,rval;
Option<AvlTree> left,right;
FuncTypeStringToInteger hashfunc;
Integer rhval,h;
AvlTree t_1,t,right_1,left_1,bt;

/* adrpo 2010-10-07: what is this??? WHAT is "lskf" KEY??
// empty tree
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
true = stringEqual(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 Down Expand Up @@ -1957,14 +1935,15 @@ algorithm
end rightNode;

protected function exchangeLeft "help function to balance"
input AvlTree node;
input AvlTree parent;
output AvlTree outParent "updated parent";
input AvlTree node;
input AvlTree parent;
output AvlTree outParent "updated parent";
algorithm
outParent := matchcontinue(node,parent)
local Option<AvlTreeValue> value;
local
Option<AvlTreeValue> value;
Integer height ;
AvlTree left,right,bt,leftNode,rightNode;
AvlTree bt;

case(node,parent) equation
parent = setRight(parent,leftNode(node));
Expand Down Expand Up @@ -2035,22 +2014,13 @@ public function avlTreeGet " Get a value from the binary tree given a key.
input AvlTree inAvlTree;
input AvlKey inKey;
output AvlValue outValue;
partial function FuncTypeKeyToInteger
input AvlKey inKey;
output Integer outInteger;
end FuncTypeKeyToInteger;
algorithm
outValue:=
matchcontinue (inAvlTree,inKey)
local
partial function FuncTypeStringToInteger
input AvlKey inString;
output Integer outInteger;
end FuncTypeStringToInteger;
AvlKey rkey,key;
AvlValue rval,res;
Option<AvlTree> left,right;
FuncTypeStringToInteger hashfunc;
Integer rhval;

// hash func Search to the right
Expand Down

0 comments on commit dc792e7

Please sign in to comment.