diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-02-10 17:27:55 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-02-13 12:42:42 +0200 |
commit | 1821a11704143a89581b26e285d968230b86a8ac (patch) | |
tree | bee33a148ec205157195fd55fd8a0d24db4fc3d2 /build2/variable | |
parent | dbd30777d1c60bdcdff226b5f97582dba0bba4ba (diff) |
Track variable value modifications
Diffstat (limited to 'build2/variable')
-rw-r--r-- | build2/variable | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/build2/variable b/build2/variable index e78b074..40470fa 100644 --- a/build2/variable +++ b/build2/variable @@ -1047,7 +1047,8 @@ namespace build2 { using value::value; - size_t generation; // load_generation of this value (global only). + size_t version = 0; // Incremented on each modification (override cache). + size_t generation; // load_generation of this value (global state only). }; using map_type = butl::prefix_map<reference_wrapper<const variable>, @@ -1107,7 +1108,20 @@ namespace build2 find (const variable&, bool typed = true) const; value_data* - find (const variable&, bool typed = true); + find_to_modify (const variable&, bool typed = true); + + // Convert a lookup pointing to a value belonging to this variable map + // to its non-const version. Note that this is only safe on the original + // values (see find_original()). + // + value& + modify (const lookup& l) + { + assert (l.vars == this); + value& r (const_cast<value&> (*l.value)); + static_cast<value_data&> (r).version++; + return r; + } // Return a value suitable for assignment. See scope for details. // |