From 934f2a9a90c5cad3cdc8a66b50c17827a3ddbcee Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 20 Jan 2018 13:46:11 +0200 Subject: 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. --- build2/operation.hxx | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'build2/operation.hxx') 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 + 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? -- cgit v1.1