* .....
*/
+ {
+ ArrType::const_iterator it;
+ if ((it = arrayToIndexToRead.find(arrName)) != arrayToIndexToRead.end())
+ {
+ map<ASTNode, ArrayRead>::const_iterator it2;
+ if ((it2 = it->second.find(readIndex)) != it->second.end())
+ {
+ result = it2->second.ite;
+ break;
+ }
+ }
+ }
+
// Recursively transform read index, which may also contain reads.
ASTNode processedTerm =
nf->CreateTerm(READ, width, arrName, readIndex);
//check if the 'processedTerm' has a corresponding ITE construct
//already. if so, return it. else continue processing.
+ /*
ASTNodeMap::const_iterator it;
if ((it = Arrayread_IteMap->find(processedTerm))
!= Arrayread_IteMap->end())
result = it->second;
break;
}
+ */
+
//Constructing Symbolic variable corresponding to 'processedTerm'
ASTNode CurrentSymbol;
ASTNodeMap::const_iterator it1;
(*Arrayname_ReadindicesMap)[arrName].push_back(readIndex);
//save the ite corresponding to 'processedTerm'
- (*Arrayread_IteMap)[processedTerm] = result;
+ //(*Arrayread_IteMap)[processedTerm] = result;
assert(arrName.GetType() == ARRAY_TYPE);
assert(result.GetValueWidth() == CurrentSymbol.GetValueWidth());
// array reads in the input Read(A,i) and Read(A,j). Then
// Read(A,i) is replaced with a symbolic constant, say v1, and
// Read(A,j) is replaced with the following ITE: ITE(i=j,v1,v2)
- public:
- ASTNodeMap * Arrayread_IteMap;
- private:
+
+ //ASTNodeMap * Arrayread_IteMap;
+
// Memo table used by the transformer while it is transforming the
// formulas and terms
debug_transform(0),
TransformMap(NULL)
{
- Arrayread_IteMap = new ASTNodeMap();
+ //Arrayread_IteMap = new ASTNodeMap();
Arrayname_ReadindicesMap = new ASTNodeToVecMap();
nf = bm->defaultNodeFactory;
// Destructor
~ArrayTransformer()
{
- Arrayread_IteMap->clear();
- delete Arrayread_IteMap;
+ //Arrayread_IteMap->clear();
+ //delete Arrayread_IteMap;
ASTNodeToVecMap::iterator it= Arrayname_ReadindicesMap->begin();
ASTNodeToVecMap::iterator itend= Arrayname_ReadindicesMap->end();
for(;it!=itend;it++)
return symbol;
} //End of ArrayRead_SymbolMap
-
- ASTNode ArrayRead_Ite(const ASTNode& arrread)
- {
- return (*Arrayread_IteMap)[arrread];
- } //End of ArrayRead_Ite
-
-
void ClearAllTables(void)
{
Arrayname_ReadindicesMap->clear();
Arrayread_SymbolMap.clear();
- Arrayread_IteMap->clear();
+ //Arrayread_IteMap->clear();
+ arrayToIndexToRead.clear();
}
}; //end of class Transformer
}
}
- //In this loop, we compute the value of each array read, the
- //corresponding ITE against the counterexample generated above.
- for (ASTNodeMap::const_iterator it =
- ArrayTransform->Arrayread_IteMap->begin(), itend =
- ArrayTransform->Arrayread_IteMap->end(); it != itend; it++)
+ for (ArrayTransformer::ArrType::const_iterator it = ArrayTransform->arrayToIndexToRead.begin(), itend =
+ ArrayTransform->arrayToIndexToRead.end(); it != itend; it++)
{
- //the array read
- const ASTNode& arrayread = it->first;
- const ASTNode& value_ite = it->second;
-
- //convert it to a constant array-read and store it in the
- //counter-example. First convert the index into a constant. then
- //construct the appropriate array-read and store it in the
- //counterexample
- ASTNode arrayread_index = TermToConstTermUsingModel(arrayread[1],false);
- ASTNode key = bm->CreateTerm(READ, arrayread.GetValueWidth(),
- arrayread[0], arrayread_index);
-
- //Get the ITE corresponding to the array-read and convert it
- //to a constant against the model
- ASTNode value = TermToConstTermUsingModel(value_ite);
- //save the result in the counter_example
- if (!simp->CheckSubstitutionMap(key))
- CounterExampleMap[key] = value;
+ const ASTNode& array = it->first;
+ const map<ASTNode, ArrayTransformer::ArrayRead>& mapper = it->second;
+
+ for (map<ASTNode, ArrayTransformer::ArrayRead>::const_iterator it2 = mapper.begin(), it2end = mapper.end(); it2
+ != it2end; it2++)
+ {
+ const ASTNode& index = it2->first;
+ const ASTNode& value_ite = it2->second.ite;
+
+ //convert it to a constant array-read and store it in the
+ //counter-example. First convert the index into a constant. then
+ //construct the appropriate array-read and store it in the
+ //counterexample
+ ASTNode arrayread_index = TermToConstTermUsingModel(index, false);
+ ASTNode key = bm->CreateTerm(READ, array.GetValueWidth(), array, arrayread_index);
+
+ //Get the ITE corresponding to the array-read and convert it
+ //to a constant against the model
+ ASTNode value = TermToConstTermUsingModel(value_ite);
+ //save the result in the counter_example
+ if (!simp->CheckSubstitutionMap(key))
+ CounterExampleMap[key] = value;
+ }
}
} //End of ConstructCounterExample