diff options
Diffstat (limited to 'build/scope')
-rw-r--r-- | build/scope | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/build/scope b/build/scope index 0fa3025..057fbc1 100644 --- a/build/scope +++ b/build/scope @@ -29,7 +29,18 @@ namespace build src_path () const {return *src_path_;} // Corresponding src path. scope* - parent () const {return parent_;} + parent_scope () const {return parent_;} + + // Root scope of this scope or NULL if this scope is not (yet) + // in any (known) project. Note that if the scope itself is + // root, then this function return this. To get to the outer + // root, query the root scope of the parent. + // + scope* + root_scope () const {return root_;} + + bool + root () const {return root_ == this;} // Variable lookup. Note that this find, not find or insert like // in the variable_map, because we also search in outer scopes. @@ -44,19 +55,6 @@ namespace build const path_type* src_path_ {nullptr}; // Cached src_{root,base} var value. - private: - friend class scope_map; - - typedef path_map<scope>::const_iterator iterator; - - scope (): variables (*this) {} - - void - init (const iterator& i, scope* p) {i_ = i; parent_ = p;} - - void - parent (scope& p) {parent_ = &p;} - public: variable_map variables; prerequisite_set prerequisites; @@ -85,8 +83,14 @@ namespace build std::unordered_map<path_type, trigger_type> triggers; private: + friend class scope_map; + typedef path_map<scope>::const_iterator iterator; + + scope (): variables (*this) {} + iterator i_; scope* parent_; + scope* root_; }; class scope_map: public path_map<scope> @@ -96,10 +100,10 @@ namespace build // of the global scope. // std::pair<scope&, bool> - insert (const path&); + insert (const path&, bool root); scope& - operator[] (const path& p) {return insert (p).first;} + operator[] (const path& p) {return insert (p, false).first;} // Find the most qualified scope that encompasses this path. // |