| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef TOOLS_GN_IMPORT_MANAGER_H_ | 5 #ifndef TOOLS_GN_IMPORT_MANAGER_H_ |
| 6 #define TOOLS_GN_IMPORT_MANAGER_H_ | 6 #define TOOLS_GN_IMPORT_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
| 12 | 13 |
| 13 class Err; | 14 class Err; |
| 14 class ParseNode; | 15 class ParseNode; |
| 15 class Scope; | 16 class Scope; |
| 16 class SourceFile; | 17 class SourceFile; |
| 17 | 18 |
| 18 // Provides a cache of the results of importing scopes so the results can | 19 // Provides a cache of the results of importing scopes so the results can |
| 19 // be re-used rather than running the imported files multiple times. | 20 // be re-used rather than running the imported files multiple times. |
| 20 class ImportManager { | 21 class ImportManager { |
| 21 public: | 22 public: |
| 22 ImportManager(); | 23 ImportManager(); |
| 23 ~ImportManager(); | 24 ~ImportManager(); |
| 24 | 25 |
| 25 // Does an import of the given file into the given scope. On error, sets the | 26 // Does an import of the given file into the given scope. On error, sets the |
| 26 // error and returns false. | 27 // error and returns false. |
| 27 bool DoImport(const SourceFile& file, | 28 bool DoImport(const SourceFile& file, |
| 28 const ParseNode* node_for_err, | 29 const ParseNode* node_for_err, |
| 29 Scope* scope, | 30 Scope* scope, |
| 30 Err* err); | 31 Err* err); |
| 31 | 32 |
| 33 std::vector<SourceFile> GetImportedFiles() const; |
| 34 |
| 32 private: | 35 private: |
| 33 base::Lock lock_; | 36 base::Lock lock_; |
| 34 | 37 |
| 35 // Owning pointers to the scopes. | 38 // Owning pointers to the scopes. |
| 36 typedef std::map<SourceFile, const Scope*> ImportMap; | 39 typedef std::map<SourceFile, const Scope*> ImportMap; |
| 37 ImportMap imports_; | 40 ImportMap imports_; |
| 38 | 41 |
| 39 DISALLOW_COPY_AND_ASSIGN(ImportManager); | 42 DISALLOW_COPY_AND_ASSIGN(ImportManager); |
| 40 }; | 43 }; |
| 41 | 44 |
| 42 #endif // TOOLS_GN_IMPORT_MANAGER_H_ | 45 #endif // TOOLS_GN_IMPORT_MANAGER_H_ |
| OLD | NEW |