Skip to content

Commit

Permalink
- Added extra checks in all HashTables, as was done for HashTable5 in…
Browse files Browse the repository at this point in the history
… revision 5498.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@5503 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed May 11, 2010
1 parent 28228a8 commit 8d5cd09
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 36 deletions.
13 changes: 8 additions & 5 deletions Compiler/HashTable.mo
Expand Up @@ -380,14 +380,15 @@ algorithm
Value v;
list<tuple<Key,Integer>>[:] hashvec;
ValueArray varr;
Key key2;
Key k;
case (key,(hashTable as HASHTABLE(hashvec,varr,bsize,n)))
equation
hval = hashFunc(key);
hashindx = intMod(hval, bsize);
indexes = hashvec[hashindx + 1];
indx = get2(key, indexes);
v = valueArrayNth(varr, indx);
(k, v) = valueArrayNth(varr, indx);
true = keyEqual(k, key);
then
(v,indx);
end matchcontinue;
Expand Down Expand Up @@ -631,21 +632,23 @@ public function valueArrayNth "function: valueArrayNth
"
input ValueArray valueArray;
input Integer pos;
output Key key;
output Value value;
algorithm
value:=
(key, value) :=
matchcontinue (valueArray,pos)
local
Key k;
Value v;
Integer n,pos,len;
Option<tuple<Key,Value>>[:] arr;
String ps,lens,ns;
case (VALUE_ARRAY(numberOfElements = n,valueArray = arr),pos)
equation
(pos < n) = true;
SOME((_,v)) = arr[pos + 1];
SOME((k,v)) = arr[pos + 1];
then
v;
(k, v);
case (VALUE_ARRAY(numberOfElements = n,valueArray = arr),pos)
equation
(pos < n) = true;
Expand Down
13 changes: 8 additions & 5 deletions Compiler/HashTable2.mo
Expand Up @@ -248,14 +248,15 @@ algorithm
Value v;
list<tuple<Key,Integer>>[:] hashvec;
ValueArray varr;
Key key2;
Key k;
case (key,(hashTable as HASHTABLE(hashvec,varr,bsize,n)))
equation
hval = hashFunc(key);
hashindx = intMod(hval, bsize);
indexes = hashvec[hashindx + 1];
indx = get2(key, indexes);
v = valueArrayNth(varr, indx);
(k, v) = valueArrayNth(varr, indx);
true = keyEqual(k, key);
then
(v,indx);
end matchcontinue;
Expand Down Expand Up @@ -520,21 +521,23 @@ public function valueArrayNth "function: valueArrayNth
"
input ValueArray valueArray;
input Integer pos;
output Key key;
output Value value;
algorithm
value:=
(key, value) :=
matchcontinue (valueArray,pos)
local
Key k;
Value v;
Integer n,pos,len;
Option<tuple<Key,Value>>[:] arr;
String ps,lens,ns;
case (VALUE_ARRAY(numberOfElements = n,valueArray = arr),pos)
equation
(pos <= n) = true;
SOME((_,v)) = arr[pos + 1];
SOME((k,v)) = arr[pos + 1];
then
v;
(k, v);
case (VALUE_ARRAY(numberOfElements = n,valueArray = arr),pos)
equation
(pos <= n) = true;
Expand Down
13 changes: 8 additions & 5 deletions Compiler/HashTable3.mo
Expand Up @@ -209,14 +209,15 @@ algorithm
Value v;
list<tuple<Key,Integer>>[:] hashvec;
ValueArray varr;
Key key2;
Key k;
case (key,(hashTable as HASHTABLE(hashvec,varr,bsize,n)))
equation
hval = hashFunc(key);
hashindx = intMod(hval, bsize);
indexes = hashvec[hashindx + 1];
indx = get2(key, indexes);
v = valueArrayNth(varr, indx);
(k, v) = valueArrayNth(varr, indx);
true = keyEqual(k, key);
then
(v,indx);
end matchcontinue;
Expand Down Expand Up @@ -460,21 +461,23 @@ public function valueArrayNth "function: valueArrayNth
"
input ValueArray valueArray;
input Integer pos;
output Key key;
output Value value;
algorithm
value:=
(key, value) :=
matchcontinue (valueArray,pos)
local
Key k;
Value v;
Integer n,pos,len;
Option<tuple<Key,Value>>[:] arr;
String ps,lens,ns;
case (VALUE_ARRAY(numberOfElements = n,valueArray = arr),pos)
equation
(pos < n) = true;
SOME((_,v)) = arr[pos + 1];
SOME((k,v)) = arr[pos + 1];
then
v;
(k, v);
case (VALUE_ARRAY(numberOfElements = n,valueArray = arr),pos)
equation
(pos < n) = true;
Expand Down
13 changes: 8 additions & 5 deletions Compiler/HashTable4.mo
Expand Up @@ -280,14 +280,15 @@ algorithm
Value v;
list<tuple<Key,Integer>>[:] hashvec;
ValueArray varr;
Key key2;
Key k;
case (key,(hashTable as HASHTABLE(hashvec,varr,bsize,n)))
equation
hval = hashFunc(key);
hashindx = intMod(hval, bsize);
indexes = hashvec[hashindx + 1];
indx = get2(key, indexes);
v = valueArrayNth(varr, indx);
(k, v) = valueArrayNth(varr, indx);
true = keyEqual(k, key);
then
(v,indx);
end matchcontinue;
Expand Down Expand Up @@ -531,21 +532,23 @@ public function valueArrayNth "function: valueArrayNth
"
input ValueArray valueArray;
input Integer pos;
output Key key;
output Value value;
algorithm
value:=
(key, value) :=
matchcontinue (valueArray,pos)
local
Key k;
Value v;
Integer n,pos,len;
Option<tuple<Key,Value>>[:] arr;
String ps,lens,ns;
case (VALUE_ARRAY(numberOfElements = n,valueArray = arr),pos)
equation
(pos < n) = true;
SOME((_,v)) = arr[pos + 1];
SOME((k,v)) = arr[pos + 1];
then
v;
(k, v);
case (VALUE_ARRAY(numberOfElements = n,valueArray = arr),pos)
equation
(pos < n) = true;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/HashTable5.mo
Expand Up @@ -542,7 +542,7 @@ public function valueArrayNth "function: valueArrayNth
output Key key;
output Value value;
algorithm
value:=
(key, value) :=
matchcontinue (valueArray,pos)
local
Key k;
Expand Down
13 changes: 8 additions & 5 deletions Compiler/HashTable6.mo
Expand Up @@ -351,14 +351,15 @@ algorithm
Value v;
list<tuple<Key,Integer>>[:] hashvec;
ValueArray varr;
Key key2;
Key k;
case (key,(hashTable as HASHTABLE(hashvec,varr,bsize,n)))
equation
hval = hashFunc(key);
hashindx = intMod(hval, bsize);
indexes = hashvec[hashindx + 1];
indx = get2(key, indexes);
v = valueArrayNth(varr, indx);
(k, v) = valueArrayNth(varr, indx);
true = keyEqual(k, key);
then
(v,indx);
end matchcontinue;
Expand Down Expand Up @@ -602,21 +603,23 @@ public function valueArrayNth "function: valueArrayNth
"
input ValueArray valueArray;
input Integer pos;
output Key key;
output Value value;
algorithm
value:=
(key, value) :=
matchcontinue (valueArray,pos)
local
Key k;
Value v;
Integer n,pos,len;
Option<tuple<Key,Value>>[:] arr;
String ps,lens,ns;
case (VALUE_ARRAY(numberOfElements = n,valueArray = arr),pos)
equation
(pos < n) = true;
SOME((_,v)) = arr[pos + 1];
SOME((k,v)) = arr[pos + 1];
then
v;
(k, v);
case (VALUE_ARRAY(numberOfElements = n,valueArray = arr),pos)
equation
(pos < n) = true;
Expand Down
13 changes: 8 additions & 5 deletions Compiler/HashTableCG.mo
Expand Up @@ -243,14 +243,15 @@ algorithm
Value v;
list<tuple<Key,Integer>>[:] hashvec;
ValueArray varr;
Key key2;
Key k;
case (key,(hashTable as HASHTABLE(hashvec,varr,bsize,n)))
equation
hval = hashFunc(key);
hashindx = intMod(hval, bsize);
indexes = hashvec[hashindx + 1];
indx = get2(key, indexes);
v = valueArrayNth(varr, indx);
(k, v) = valueArrayNth(varr, indx);
true = keyEqual(k, key);
/*print("HashTableGC.get(");
print(Exp.printComponentRefStr(key));
print(") = ");
Expand Down Expand Up @@ -496,21 +497,23 @@ public function valueArrayNth "function: valueArrayNth
"
input ValueArray valueArray;
input Integer pos;
output Key key;
output Value value;
algorithm
value:=
(key, value) :=
matchcontinue (valueArray,pos)
local
Key k;
Value v;
Integer n,pos,len;
Option<tuple<Key,Value>>[:] arr;
String ps,lens,ns;
case (VALUE_ARRAY(numberOfElements = n,valueArray = arr),pos)
equation
(pos <= n) = true;
SOME((_,v)) = arr[pos + 1];
SOME((k,v)) = arr[pos + 1];
then
v;
(k, v);
case (VALUE_ARRAY(numberOfElements = n,valueArray = arr),pos)
equation
(pos <= n) = true;
Expand Down
13 changes: 8 additions & 5 deletions Compiler/HashTableStringToPath.mo
Expand Up @@ -345,14 +345,15 @@ algorithm
Value v;
list<tuple<Key,Integer>>[:] hashvec;
ValueArray varr;
Key key2;
Key k;
case (key,(hashTable as HASHTABLE(hashvec,varr,bsize,n)))
equation
hval = hashFunc(key);
hashindx = intMod(hval, bsize);
indexes = hashvec[hashindx + 1];
indx = get2(key, indexes);
v = valueArrayNth(varr, indx);
(k, v) = valueArrayNth(varr, indx);
true = keyEqual(k, key);
then
(v,indx);
end matchcontinue;
Expand Down Expand Up @@ -596,21 +597,23 @@ public function valueArrayNth "function: valueArrayNth
"
input ValueArray valueArray;
input Integer pos;
output Key key;
output Value value;
algorithm
value:=
(key, value) :=
matchcontinue (valueArray,pos)
local
Key k;
Value v;
Integer n,pos,len;
Option<tuple<Key,Value>>[:] arr;
String ps,lens,ns;
case (VALUE_ARRAY(numberOfElements = n,valueArray = arr),pos)
equation
(pos < n) = true;
SOME((_,v)) = arr[pos + 1];
SOME((k,v)) = arr[pos + 1];
then
v;
(k, v);
case (VALUE_ARRAY(numberOfElements = n,valueArray = arr),pos)
equation
(pos < n) = true;
Expand Down

0 comments on commit 8d5cd09

Please sign in to comment.