class ElementSet : public Element {
public:
ElementSet(ASTNodeType type, Set *s);
+ virtual ~ElementSet(){}
ElementSet(Set *s);
virtual Element *clone(CSolver *solver, CloneMap *map);
virtual void serialize(Serializer* serializer);
class ElementConst : public ElementSet {
public:
ElementConst(uint64_t value, Set *_set);
+ virtual ~ElementConst(){}
uint64_t value;
virtual void serialize(Serializer* serializer);
virtual void print();
class ElementFunction : public Element {
public:
+ virtual ~ElementFunction(){}
ElementFunction(Function *function, Element **array, uint numArrays, BooleanEdge overflowstatus);
Array<Element *> inputs;
BooleanEdge overflowstatus;
serializer->mywrite(&This, sizeof(Set*));
serializer->mywrite(&type, sizeof(VarType));
serializer->mywrite(&isRange, sizeof(bool));
- serializer->mywrite(&low, sizeof(uint64_t));
- serializer->mywrite(&high, sizeof(uint64_t));
- bool isMutable = isMutableSet();
+ bool isMutable = isMutableSet();
serializer->mywrite(&isMutable, sizeof(bool));
- uint size = members->getSize();
- serializer->mywrite(&size, sizeof(uint));
- for(uint i=0; i<size; i++){
- uint64_t mem = members->get(i);
- serializer->mywrite(&mem, sizeof(uint64_t));
- }
+ if(isRange){
+ serializer->mywrite(&low, sizeof(uint64_t));
+ serializer->mywrite(&high, sizeof(uint64_t));
+ }else {
+ uint size = members->getSize();
+ serializer->mywrite(&size, sizeof(uint));
+ for(uint i=0; i<size; i++){
+ uint64_t mem = members->get(i);
+ serializer->mywrite(&mem, sizeof(uint64_t));
+ }
+ }
}
void Set::print(){
myread(&type, sizeof(VarType));
bool isRange;
myread(&isRange, sizeof(bool));
- uint64_t low;
- myread(&low, sizeof(uint64_t));
- uint64_t high;
- myread(&high, sizeof(uint64_t));
- bool isMutable;
+ bool isMutable;
myread(&isMutable, sizeof(bool));
- Set *set;
- if(isMutable){
- set = new MutableSet(type);
- }
- uint size;
- myread(&size, sizeof(uint));
- Vector<uint64_t> members;
- for(uint i=0; i<size; i++){
- uint64_t mem;
- myread(&mem, sizeof(uint64_t));
- if(isMutable) {
- ((MutableSet*) set)->addElementMSet(mem);
- }else {
- members.push(mem);
- }
- }
- if(!isMutable){
- set = isRange? solver->createRangeSet(type, low, high):
- solver->createSet(type, members.expose(), size);
- }
- map.put(s_ptr, set);
+ if(isRange){
+ uint64_t low;
+ myread(&low, sizeof(uint64_t));
+ uint64_t high;
+ myread(&high, sizeof(uint64_t));
+ map.put(s_ptr, new Set(type, low, high));
+ } else{
+ Set *set;
+ if(isMutable){
+ set = new MutableSet(type);
+ }
+ uint size;
+ myread(&size, sizeof(uint));
+ Vector<uint64_t> members;
+ for(uint i=0; i<size; i++){
+ uint64_t mem;
+ myread(&mem, sizeof(uint64_t));
+ if(isMutable) {
+ ((MutableSet*) set)->addElementMSet(mem);
+ }else {
+ members.push(mem);
+ }
+ }
+ if(!isMutable){
+ set = solver->createSet(type, members.expose(), size);
+ }
+ map.put(s_ptr, set);
+ }
+
}
void Deserializer::deserializeBooleanLogic(){
/** This function tears down the solver and the entire AST */
CSolver::~CSolver() {
+ this->serialize();
uint size = allBooleans.getSize();
for (uint i = 0; i < size; i++) {
delete allBooleans.get(i);
size = allElements.getSize();
for (uint i = 0; i < size; i++) {
- delete allElements.get(i);
+ Element* el = allElements.get(i);
+ model_print("deleting ...%u", i);
+ ASSERT(el != NULL);
+ delete el;
}
size = allTables.getSize();
}
delete it;
}
- model_print("deserializing ...\n");
- {
- Deserializer deserializer("dump");
- deserializer.deserialize();
- }
+// model_print("deserializing ...\n");
+// {
+// Deserializer deserializer("dump");
+// deserializer.deserialize();
+// }
}
Element *CSolver::getElementVar(Set *set) {
Element *element = new ElementSet(set);
+ model_println("%%%%ElementVar:%u", allElements.getSize());
allElements.push(element);
return element;
}
Element *e = elemMap.get(element);
if (e == NULL) {
allSets.push(set);
+ model_println("%%%%ElementConst:%u", allElements.getSize());
allElements.push(element);
elemMap.put(element, element);
return element;
Element *e = elemMap.get(element);
if (e == NULL) {
element->updateParents();
+ model_println("%%%%ElementFunction:%u", allElements.getSize());
allElements.push(element);
elemMap.put(element, element);
return element;