#include "ordergraph.h"
DecomposeOrderResolver::DecomposeOrderResolver(OrderGraph* _graph, Vector<Order*>& _orders):
- OrderResolver(_graph),
+ graph(_graph),
orders(_orders.getSize(), _orders.expose())
{
}
delete graph;
}
-HappenedBefore DecomposeOrderResolver::getOrder(OrderNode* from, OrderNode* to){
- ASSERT(from->id == to->id);
- // We should ask this query from the suborder ....
- Order *suborder = NULL;
- suborder = orders.get(from->sccNum);
- ASSERT(suborder != NULL);
- return suborder->encoding.resolver->resolveOrder(from->id, to->id);
+HappenedBefore DecomposeOrderResolver::resolveOrder(uint64_t first, uint64_t second){
+ OrderNode *from = graph->getOrderNodeFromOrderGraph(first, false /*Don't create new node if doesn't exist*/);
+ if(from == NULL){
+ return SATC_UNORDERED;
+ }
+ OrderNode *to = graph->getOrderNodeFromOrderGraph(second, false);
+ if(from == NULL){
+ return SATC_UNORDERED;
+ }
+ if (from->sccNum != to->sccNum) {
+ OrderEdge *edge = graph->getOrderEdgeFromOrderGraph(from, to, false /* Don't create a new edge*/);
+ if (edge != NULL && edge->mustPos){
+ return SATC_FIRST;
+ } else if( edge != NULL && edge->mustNeg){
+ return SATC_SECOND;
+ }else {
+ switch(graph->getOrder()->encoding.type){
+ case SATC_TOTAL:
+ return from->sccNum < to->sccNum? SATC_FIRST: SATC_SECOND;
+ case SATC_PARTIAL:
+ default:
+ ASSERT(0);
+ }
+ }
+ } else {
+ Order *suborder = NULL;
+ // We should ask this query from the suborder ....
+ suborder = orders.get(from->sccNum);
+ ASSERT(suborder != NULL);
+ return suborder->encoding.resolver->resolveOrder(from->id, to->id);
+ }
}
class DecomposeOrderResolver : public OrderResolver{
public:
DecomposeOrderResolver(OrderGraph* graph, Vector<Order *> & orders);
+ HappenedBefore resolveOrder(uint64_t first, uint64_t second);
virtual ~DecomposeOrderResolver();
private:
OrderGraph* graph;
Vector<Order*> orders;
-
- HappenedBefore getOrder(OrderNode* from, OrderNode* to);
};
#endif /* DECOMPOSEORDERRESOLVER_H */
+++ /dev/null
-#include "orderresolver.h"
-#include "ordergraph.h"
-#include "ordernode.h"
-#include "orderedge.h"
-
-OrderResolver::OrderResolver(OrderGraph* _graph)
- :graph(_graph)
-{
-}
-
-OrderResolver::~OrderResolver(){
- delete graph;
-}
-
-HappenedBefore OrderResolver::resolveOrder(uint64_t first, uint64_t second){
- OrderNode *from = graph->getOrderNodeFromOrderGraph(first, false /*Don't create new node if doesn't exist*/);
- if(from == NULL){
- return SATC_UNORDERED;
- }
- OrderNode *to = graph->getOrderNodeFromOrderGraph(second, false);
- if(from == NULL){
- return SATC_UNORDERED;
- }
- if (from->sccNum != to->sccNum) {
- OrderEdge *edge = graph->getOrderEdgeFromOrderGraph(from, to, false /* Don't create a new edge*/);
- if (edge != NULL && edge->mustPos){
- return SATC_FIRST;
- } else if( edge != NULL && edge->mustNeg){
- return SATC_SECOND;
- }else {
- ASSERT(0);
- //It's a case that either there's no edge, or there is an edge
- // but we don't know the value! (This case shouldn't happen)
- //return from->sccNum < to->sccNum? SATC_FIRST: SATC_SECOND;
- }
- } else {
- return getOrder(from, to);
- }
-}
\ No newline at end of file
class OrderResolver {
public:
- OrderResolver(OrderGraph* _graph);
- HappenedBefore resolveOrder(uint64_t first, uint64_t second);
- virtual ~OrderResolver();
+ OrderResolver(){};
+ virtual HappenedBefore resolveOrder(uint64_t first, uint64_t second) = 0;
+ virtual ~OrderResolver(){};
CMEMALLOC;
-protected:
- OrderGraph* graph;
- virtual HappenedBefore getOrder(OrderNode* from, OrderNode* to) = 0;
};
#endif /* ORDERRESOLVER_H */