memoize timeouts
[satune.git] / src / AST / element.h
index 8277b42b018159b57d896e3234c15217144ba0fb..91d677fc2b8726ff67aedcbda69338ac2b35c6ad 100644 (file)
@@ -14,46 +14,60 @@ public:
        virtual ~Element() {}
        Vector<ASTNode *> parents;
        ElementEncoding encoding;
+       inline ElementEncoding *getElementEncoding() { return &encoding; }
        virtual Element *clone(CSolver *solver, CloneMap *map) {ASSERT(0); return NULL;};
-       
-       MEMALLOC;
+       virtual void serialize(Serializer *serializer) = 0;
+       virtual void print() = 0;
+       virtual void updateParents() {}
+       virtual Set *getRange() = 0;
+       CMEMALLOC;
+       bool anyValue;
 };
 
-class ElementConst : public Element {
+class ElementSet : public Element {
 public:
-       ElementConst(uint64_t value, VarType type, Set *_set);
+       ElementSet(ASTNodeType type, Set *s);
+       virtual ~ElementSet() {}
+       ElementSet(Set *s);
+       virtual Element *clone(CSolver *solver, CloneMap *map);
+       virtual void serialize(Serializer *serializer);
+       virtual void print();
+       CMEMALLOC;
+       Set *getRange() {return set;}
+protected:
        Set *set;
-       uint64_t value;
-       Element *clone(CSolver *solver, CloneMap *map);
-       MEMALLOC;
+       friend class ElementOpt;
 };
 
-class ElementSet : public Element {
+class ElementConst : public ElementSet {
 public:
-       ElementSet(Set *s);
-       Set *set;
+       ElementConst(uint64_t value, Set *_set);
+       virtual ~ElementConst() {}
+       uint64_t value;
+       virtual void serialize(Serializer *serializer);
+       virtual void print();
        Element *clone(CSolver *solver, CloneMap *map);
-       MEMALLOC;
+       CMEMALLOC;
 };
 
 class ElementFunction : public Element {
 public:
-       ElementFunction(Function *function, Element **array, uint numArrays, Boolean *overflowstatus);
-       Function *function;
+       virtual ~ElementFunction() {}
+       ElementFunction(Function *function, Element **array, uint numArrays, BooleanEdge overflowstatus);
        Array<Element *> inputs;
-       Boolean *overflowstatus;
+       BooleanEdge overflowstatus;
        FunctionEncoding functionencoding;
        Element *clone(CSolver *solver, CloneMap *map);
-       MEMALLOC;
+       virtual void serialize(Serializer *serializer);
+       virtual void print();
+       Set *getRange();
+       void updateParents();
+       Function *getFunction() {return function;}
+       inline FunctionEncoding *getElementFunctionEncoding() {return &functionencoding;}
+       CMEMALLOC;
+private:
+       Function *function;
 };
 
-Set *getElementSet(Element *This);
-
-static inline ElementEncoding *getElementEncoding(Element *e) {
-       return &e->encoding;
-}
 
-static inline FunctionEncoding *getElementFunctionEncoding(ElementFunction *func) {
-       return &func->functionencoding;
-}
 #endif