aboutsummaryrefslogtreecommitdiff
path: root/build2/operation.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-01-20 13:46:11 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-02-03 14:35:45 +0200
commit934f2a9a90c5cad3cdc8a66b50c17827a3ddbcee (patch)
treef35f106e5369e98350327c79080c571195234c0b /build2/operation.hxx
parent280f4a5bf787587227ca193cd59c6bd74091db70 (diff)
Get rid of action rule override semantics
Instead we now have two more or less separate match states for outer and inner parts of an action.
Diffstat (limited to 'build2/operation.hxx')
-rw-r--r--build2/operation.hxx35
1 files changed, 18 insertions, 17 deletions
diff --git a/build2/operation.hxx b/build2/operation.hxx
index a65fc3d..8c9818e 100644
--- a/build2/operation.hxx
+++ b/build2/operation.hxx
@@ -52,9 +52,6 @@ namespace build2
{
action (): inner_id (0), outer_id (0) {} // Invalid action.
- bool
- valid () const {return inner_id != 0;}
-
// If this is not a nested operation, then outer should be 0.
//
action (meta_operation_id m, operation_id inner, operation_id outer = 0)
@@ -70,6 +67,9 @@ namespace build2
operation_id
outer_operation () const {return outer_id & 0xF;}
+ bool inner () const {return outer_id == 0;}
+ bool outer () const {return outer_id != 0;}
+
// Implicit conversion operator to action_id for the switch() statement,
// etc. Most places only care about the inner operation.
//
@@ -88,24 +88,25 @@ namespace build2
inline bool
operator!= (action x, action y) {return !(x == y);}
- // This is an "overrides" comparison, i.e., it returns true if the recipe
- // for x overrides recipe for y. The idea is that for the same inner
- // operation, action with an outer operation is "weaker" than the one
- // without.
- //
- inline bool
- operator> (action x, action y)
- {
- return x.inner_id != y.inner_id ||
- (x.outer_id != y.outer_id && y.outer_id != 0);
- }
-
- inline bool
- operator>= (action x, action y) {return x == y || x > y;}
+ bool operator> (action, action) = delete;
+ bool operator< (action, action) = delete;
+ bool operator>= (action, action) = delete;
+ bool operator<= (action, action) = delete;
ostream&
operator<< (ostream&, action);
+ // Inner/outer operation state container.
+ //
+ template <typename T>
+ struct action_state
+ {
+ T states[2]; // [0] -- inner, [1] -- outer.
+
+ T& operator[] (action a) {return states[a.inner () ? 0 : 1];}
+ const T& operator[] (action a) const {return states[a.inner () ? 0 : 1];}
+ };
+
// Id constants for build-in and pre-defined meta/operations.
//
const meta_operation_id noop_id = 1; // nomop?