Skip to content

Commit

Permalink
- Changed HashTable implementations to use the new BaseHashTable.mo
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund committed Oct 26, 2010
1 parent 6114143 commit 33e72d4
Show file tree
Hide file tree
Showing 19 changed files with 406 additions and 3,874 deletions.
7 changes: 3 additions & 4 deletions Compiler/BaseHashTable.mo
@@ -1,4 +1,4 @@
package BaseHashTable "
encapsulated package BaseHashTable "
This file is an extension to OpenModelica.

Copyright (c) 2007 MathCore Engineering AB
Expand Down Expand Up @@ -26,7 +26,6 @@ keyEqual - A comparison function between two keys, returns true if equal.

/* HashTable instance specific code */

protected import System;
protected import Util;

/* Generic hashtable code below!! */
Expand All @@ -40,8 +39,8 @@ public function emptyHashTableWork
list<Option<tuple<Key,Value>>> lst;
array<Option<tuple<Key,Value>>> emptyarr;

type Key = DAE.ComponentRef;
type Value = DAE.Value;
replaceable type Key subtypeof Any;
replaceable type Value subtypeof Any;
type HashTable = tuple<HashVector, ValueArray, Integer, Integer, FuncsTuple>;
type HashVector = array<list<tuple<Key,Integer>>>;
type ValueArray = tuple<Integer,Integer,array<Option<tuple<Key,Value>>>>;
Expand Down
7 changes: 7 additions & 0 deletions Compiler/ComponentReference.mo
Expand Up @@ -1841,5 +1841,12 @@ algorithm
end matchcontinue;
end printComponentRef2;

public function printComponentRefListStr
input list<DAE.ComponentRef> crs;
output String res;
algorithm
res := "{" +& Util.stringDelimitList(Util.listMap(crs, printComponentRefStr), ",") +& "}";
end printComponentRefListStr;

end ComponentReference;

9 changes: 5 additions & 4 deletions Compiler/ConnectionGraph.mo
Expand Up @@ -325,6 +325,7 @@ end addConnection;
// ********* protected section ********* //
// ************************************* //

protected import BaseHashTable;
protected import Exp;
protected import Debug;
protected import DAEDump;
Expand All @@ -350,12 +351,12 @@ algorithm

case (partition, ref)
equation
parent = HashTableCG.get(ref, partition);
parent = BaseHashTable.get(ref, partition);
parentCanonical = canonical(partition, parent);
//Debug.fprintln("cgraph",
// "- ConnectionGraph.canonical_case1(" +& ComponentReference.printComponentRefStr(ref) +& ") = " +&
// ComponentReference.printComponentRefStr(parentCanonical));
//partition2 = HashTableCG.add((ref, parentCanonical), partition);
//partition2 = BaseHashTable.add((ref, parentCanonical), partition);
then parentCanonical;

case (partition,ref)
Expand Down Expand Up @@ -758,7 +759,7 @@ algorithm
// not the same, add it
case(partition,ref1,ref2)
equation
partition = HashTableCG.add((ref1,ref2), partition);
partition = BaseHashTable.add((ref1,ref2), partition);
then (partition, true);
end matchcontinue;
end connectCanonicalComponents;
Expand All @@ -778,7 +779,7 @@ algorithm

case(table, (root::tail), firstRoot)
equation
table = HashTableCG.add((root,firstRoot), table);
table = BaseHashTable.add((root,firstRoot), table);
table = addRootsToTable(table, tail, firstRoot);
then table;
case(table, {}, _) then table;
Expand Down
1 change: 0 additions & 1 deletion Compiler/DAELow.mo
Expand Up @@ -76,7 +76,6 @@ protected import RTOpts;
protected import System;
protected import Util;
protected import DAEDump;
protected import Inline;
protected import ValuesUtil;
protected import VarTransform;
protected import BackendDAEUtil;
Expand Down
3 changes: 2 additions & 1 deletion Compiler/DAEUtil.mo
Expand Up @@ -216,6 +216,7 @@ end matchcontinue;
end getBoundStartEquation;

protected import Algorithm;
protected import BaseHashTable;
protected import Ceval;
protected import Debug;
protected import Error;
Expand Down Expand Up @@ -5099,7 +5100,7 @@ algorithm
DAE.BINARY(exp,DAE.SUB(DAE.ET_REAL()),DAE.CREF(cref_1,DAE.ET_REAL())),
DAE.DIV(DAE.ET_REAL()),
DAE.CREF(cref_2,DAE.ET_REAL()));
crs1 = HashTable.add((cr,0),crs0);
crs1 = BaseHashTable.add((cr,0),crs0);
then (exp,crs1);
case (exp,crs0) then (exp,crs0);
end matchcontinue;
Expand Down

0 comments on commit 33e72d4

Please sign in to comment.