X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=action.cc;h=893c812a1f39bd33f60a3b97291ffe9a525ae124;hb=745b71256a4b96ddf4843c7f66b11d0cb3daa3cb;hp=5f83c3f5604524692e88e1c9478db7bb9f7216fc;hpb=a0db445e3ecfedce6a85b7b381416b5c363a0614;p=model-checker.git diff --git a/action.cc b/action.cc index 5f83c3f..893c812 100644 --- a/action.cc +++ b/action.cc @@ -394,7 +394,9 @@ uint64_t ModelAction::get_reads_from_value() const ASSERT(is_read()); if (reads_from) return reads_from->get_write_value(); - return reads_from_promise->get_value(); + else if (reads_from_promise) + return reads_from_promise->get_value(); + return VALUE_NONE; /* Only for new actions with no reads-from */ } /** @@ -611,3 +613,29 @@ unsigned int ModelAction::hash() const hash ^= reads_from->get_seq_number(); return hash; } + +/** + * @brief Checks the NodeStack to see if a ModelAction is in our may-read-from set + * @param write The ModelAction to check for + * @return True if the ModelAction is found; false otherwise + */ +bool ModelAction::may_read_from(const ModelAction *write) const +{ + for (int i = 0; i < node->get_read_from_past_size(); i++) + if (node->get_read_from_past(i) == write) + return true; + return false; +} + +/** + * @brief Checks the NodeStack to see if a Promise is in our may-read-from set + * @param promise The Promise to check for + * @return True if the Promise is found; false otherwise + */ +bool ModelAction::may_read_from(const Promise *promise) const +{ + for (int i = 0; i < node->get_read_from_promise_size(); i++) + if (node->get_read_from_promise(i) == promise) + return true; + return false; +}