Adding decomposeOrderTransform to transformer
authorHamed <hamed.gorjiara@gmail.com>
Thu, 31 Aug 2017 17:44:04 +0000 (10:44 -0700)
committerHamed <hamed.gorjiara@gmail.com>
Thu, 31 Aug 2017 17:44:04 +0000 (10:44 -0700)
src/ASTTransform/decomposeordertransform.cc
src/ASTTransform/decomposeordertransform.h
src/ASTTransform/transformer.cc
src/ASTTransform/transformer.h

index d458b2f..f90a666 100644 (file)
@@ -15,9 +15,8 @@
 #include "csolver.h"
 
 
-DecomposeOrderTransform::DecomposeOrderTransform(CSolver* _solver, Order* _order)
-       :Transform(_solver),
-       order(_order)
+DecomposeOrderTransform::DecomposeOrderTransform(CSolver* _solver)
+       :Transform(_solver)
 {
 }
 
@@ -25,20 +24,20 @@ DecomposeOrderTransform::~DecomposeOrderTransform() {
 }
 
 bool DecomposeOrderTransform::canExecuteTransform(){
-       return canExecutePass(solver, order->type, DECOMPOSEORDER, &onoff);
+       return canExecutePass(solver, currOrder->type, DECOMPOSEORDER, &onoff);
 }
 
 void DecomposeOrderTransform::doTransform(){
        Vector<Order *> ordervec;
        Vector<Order *> partialcandidatevec;
-       uint size = order->constraints.getSize();
+       uint size = currOrder->constraints.getSize();
        for (uint i = 0; i < size; i++) {
-               BooleanOrder *orderconstraint = order->constraints.get(i);
-               OrderNode *from = graph->getOrderNodeFromOrderGraph(orderconstraint->first);
-               OrderNode *to = graph->getOrderNodeFromOrderGraph(orderconstraint->second);
+               BooleanOrder *orderconstraint = currOrder->constraints.get(i);
+               OrderNode *from = currGraph->getOrderNodeFromOrderGraph(orderconstraint->first);
+               OrderNode *to = currGraph->getOrderNodeFromOrderGraph(orderconstraint->second);
                model_print("from->sccNum:%u\tto->sccNum:%u\n", from->sccNum, to->sccNum);
                if (from->sccNum != to->sccNum) {
-                       OrderEdge *edge = graph->getOrderEdgeFromOrderGraph(from, to);
+                       OrderEdge *edge = currGraph->getOrderEdgeFromOrderGraph(from, to);
                        if (edge->polPos) {
                                solver->replaceBooleanWithTrue(orderconstraint);
                        } else if (edge->polNeg) {
@@ -53,10 +52,10 @@ void DecomposeOrderTransform::doTransform(){
                        if (ordervec.getSize() > from->sccNum)
                                neworder = ordervec.get(from->sccNum);
                        if (neworder == NULL) {
-                               MutableSet *set = solver->createMutableSet(order->set->getType());
-                               neworder = solver->createOrder(order->type, set);
+                               MutableSet *set = solver->createMutableSet(currOrder->set->getType());
+                               neworder = solver->createOrder(currOrder->type, set);
                                ordervec.setExpand(from->sccNum, neworder);
-                               if (order->type == SATC_PARTIAL)
+                               if (currOrder->type == SATC_PARTIAL)
                                        partialcandidatevec.setExpand(from->sccNum, neworder);
                                else
                                        partialcandidatevec.setExpand(from->sccNum, NULL);
@@ -69,8 +68,8 @@ void DecomposeOrderTransform::doTransform(){
                                to->status = SATC_ADDEDTOSET;
                                ((MutableSet *)neworder->set)->addElementMSet(to->id);
                        }
-                       if (order->type == SATC_PARTIAL) {
-                               OrderEdge *edge = graph->getOrderEdgeFromOrderGraph(from, to);
+                       if (currOrder->type == SATC_PARTIAL) {
+                               OrderEdge *edge = currGraph->getOrderEdgeFromOrderGraph(from, to);
                                if (edge->polNeg)
                                        partialcandidatevec.setExpand(from->sccNum, NULL);
                        }
index 1fe7356..84b17f3 100644 (file)
 
 class DecomposeOrderTransform : public Transform {
 public:
-       DecomposeOrderTransform(CSolver* _solver, Order* order);
+       DecomposeOrderTransform(CSolver* _solver);
        virtual ~DecomposeOrderTransform();
        void doTransform();
        void setOrderGraph(OrderGraph* _graph){
-               graph = _graph;
+               currGraph = _graph;
        }
+       void setCurrentOrder(Order* _current) { currOrder = _current;}
        bool canExecuteTransform();
 private:
-       Order* order;
-       OrderGraph* graph;
+       Order* currOrder;
+       OrderGraph* currGraph;
 };
 
 #endif /* ORDERTRANSFORM_H */
index b22b87d..54dad59 100644 (file)
 
 Transformer::Transformer(CSolver *_solver):
        integerEncoding(new IntegerEncodingTransform(_solver)),
+       decomposeOrder(new DecomposeOrderTransform(_solver)),
        solver(_solver)
 {
 }
 
 Transformer::~Transformer(){
        delete integerEncoding;
+       delete decomposeOrder;
 }
 
 void Transformer::orderAnalysis() {
@@ -31,9 +33,8 @@ void Transformer::orderAnalysis() {
        uint size = orders->getSize();
        for (uint i = 0; i < size; i++) {
                Order *order = orders->get(i);
-               DecomposeOrderTransform* decompose = new DecomposeOrderTransform(solver, order);
-               if (!decompose->canExecuteTransform()){
-                       delete decompose;
+               decomposeOrder->setCurrentOrder(order);
+               if (!decomposeOrder->canExecuteTransform()){
                        continue;
                }
 
@@ -69,9 +70,8 @@ void Transformer::orderAnalysis() {
 
                //This is needed for splitorder
                computeStronglyConnectedComponentGraph(graph);
-               decompose->setOrderGraph(graph);
-               decompose->doTransform();
-               delete decompose;
+               decomposeOrder->setOrderGraph(graph);
+               decomposeOrder->doTransform();
                delete graph;
 
                integerEncoding->setCurrentOrder(order);
index 24922d0..68e64b1 100644 (file)
@@ -11,6 +11,7 @@
 #include "structs.h"
 #include "transform.h"
 #include "integerencoding.h"
+#include "decomposeordertransform.h"
 
 class Transformer{
 public:
@@ -21,7 +22,7 @@ public:
 private:
        //For now we can just add transforms here, but in future we may want take a smarter approach.
        IntegerEncodingTransform* integerEncoding;
-       
+       DecomposeOrderTransform* decomposeOrder;
        
        CSolver* solver;
 };