From: Brian Norris Date: Tue, 16 Apr 2013 00:53:11 +0000 (-0700) Subject: promise: add Promise::get_index function X-Git-Tag: oopsla2013~74 X-Git-Url: http://demsky.eecs.uci.edu/git/?p=model-checker.git;a=commitdiff_plain;h=cb7d648c3c1c3d916c7fc60a7cb332eb2b52d510 promise: add Promise::get_index function --- diff --git a/action.cc b/action.cc index 76f18dd..8384101 100644 --- a/action.cc +++ b/action.cc @@ -618,7 +618,7 @@ void ModelAction::print() const if (reads_from) model_print(" Rf: %-3d", reads_from->get_seq_number()); else if (reads_from_promise) { - int idx = model->get_promise_number(reads_from_promise); + int idx = reads_from_promise->get_index(); if (idx >= 0) model_print(" Rf: P%-2d", idx); else @@ -648,7 +648,7 @@ unsigned int ModelAction::hash() const if (reads_from) hash ^= reads_from->get_seq_number(); else if (reads_from_promise) - hash ^= model->get_promise_number(reads_from_promise); + hash ^= reads_from_promise->get_index(); hash ^= get_reads_from_value(); } return hash; diff --git a/cyclegraph.cc b/cyclegraph.cc index 77c0b68..0ec95b0 100644 --- a/cyclegraph.cc +++ b/cyclegraph.cc @@ -314,7 +314,7 @@ static void print_node(FILE *file, const CycleNode *node, int label) { if (node->is_promise()) { const Promise *promise = node->getPromise(); - int idx = model->get_promise_number(promise); + int idx = promise->get_index(); fprintf(file, "P%u", idx); if (label) { int first = 1; diff --git a/promise.cc b/promise.cc index 26a1095..29e261f 100644 --- a/promise.cc +++ b/promise.cc @@ -166,3 +166,9 @@ bool Promise::same_location(const ModelAction *act) const { return get_reader(0)->same_var(act); } + +/** @brief Get this Promise's index within the execution's promise array */ +int Promise::get_index() const +{ + return model->get_promise_number(this); +} diff --git a/promise.h b/promise.h index 90ec1d2..e8c233c 100644 --- a/promise.h +++ b/promise.h @@ -43,6 +43,8 @@ class Promise { uint64_t get_value() const { return fv.value; } struct future_value get_fv() const { return fv; } + int get_index() const; + void print() const; bool equals(const Promise *x) const { return this == x; }