little optimizations motivated by profiling...
[model-checker.git] / nodestack.cc
index 00cc30f8d7efb22cf9e5b110d4628ac83db55e0f..8ffdc3358073d7be220e1ab27aa2019f83cfced1 100644 (file)
@@ -98,6 +98,16 @@ Node::~Node()
 void Node::print() const
 {
        action->print();
+       model_print("          thread status: ");
+       if (enabled_array) {
+               for (int i = 0; i < num_threads; i++) {
+                       char str[20];
+                       enabled_type_to_string(enabled_array[i], str);
+                       model_print("[%d: %s]", i, str);
+               }
+               model_print("\n");
+       } else
+               model_print("(info not available)\n");
        model_print("          backtrack: %s", backtrack_empty() ? "empty" : "non-empty ");
        for (int i = 0; i < (int)backtrack.size(); i++)
                if (backtrack[i] == true)
@@ -458,11 +468,28 @@ void Node::add_read_from_promise(const ModelAction *reader)
  */
 Promise * Node::get_read_from_promise() const
 {
-       if (read_from_promise_idx < 0 || read_from_promise_idx >= ((int)read_from_promises.size()))
-               return NULL;
+       ASSERT(read_from_promise_idx >= 0 && read_from_promise_idx < ((int)read_from_promises.size()));
        return read_from_promises[read_from_promise_idx]->get_reads_from_promise();
 }
 
+/**
+ * Gets a particular 'read-from-promise' form this Node. Only vlaid for a node
+ * where this->action is a 'read'.
+ * @param i The index of the Promise to get
+ * @return The Promise at index i, if the Promise is still available; NULL
+ * otherwise
+ */
+Promise * Node::get_read_from_promise(int i) const
+{
+       return read_from_promises[i]->get_reads_from_promise();
+}
+
+/** @return The size of the read-from-promise set */
+int Node::get_read_from_promise_size() const
+{
+       return read_from_promises.size();
+}
+
 /**
  * Checks whether the read_from_promises set for this node is empty.
  * @return true if the read_from_promises set is empty.