Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: syzygy/refinery/types/type_repository.h

Issue 1475083002: [Refinery] Introduce TypePropagatorAnalyzer - pointer types. (Closed) Base URL: https://github.com/google/syzygy.git@master
Patch Set: Final nit Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « syzygy/refinery/symbols/symbol_provider.h ('k') | syzygy/refinery/types/type_repository.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 Google Inc. All Rights Reserved. 1 // Copyright 2015 Google Inc. All Rights Reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #ifndef SYZYGY_REFINERY_TYPES_TYPE_REPOSITORY_H_ 15 #ifndef SYZYGY_REFINERY_TYPES_TYPE_REPOSITORY_H_
16 #define SYZYGY_REFINERY_TYPES_TYPE_REPOSITORY_H_ 16 #define SYZYGY_REFINERY_TYPES_TYPE_REPOSITORY_H_
17 17
18 #include <iterator> 18 #include <iterator>
19 #include <map> 19 #include <map>
20 #include <vector> 20 #include <vector>
21 21
22 #include "base/macros.h" 22 #include "base/macros.h"
23 #include "base/containers/hash_tables.h" 23 #include "base/containers/hash_tables.h"
24 #include "base/memory/ref_counted.h" 24 #include "base/memory/ref_counted.h"
25 #include "syzygy/pe/pe_file.h"
25 26
26 namespace refinery { 27 namespace refinery {
27 28
28 typedef size_t TypeId; 29 typedef size_t TypeId;
29 class Type; 30 class Type;
30 using TypePtr = scoped_refptr<Type>; 31 using TypePtr = scoped_refptr<Type>;
31 32
32 // Keeps type instances, assigns them an ID and vends them out by ID on demand. 33 // Keeps type instances, assigns them an ID and vends them out by ID on demand.
33 // TODO(manzagop): cleave the interface so as to obtain something immutable. 34 // TODO(manzagop): cleave the interface so as to obtain something immutable.
35 // TODO(manzagop): abstract the module id away from a pe file signature.
34 class TypeRepository : public base::RefCounted<TypeRepository> { 36 class TypeRepository : public base::RefCounted<TypeRepository> {
35 public: 37 public:
36 class Iterator; 38 class Iterator;
37 39
40 // TODO(manzagop): make it mandatory to provide a module signature.
38 TypeRepository(); 41 TypeRepository();
42 explicit TypeRepository(const pe::PEFile::Signature& signature);
39 43
40 // Retrieve a type by @p id. 44 // Retrieve a type by @p id.
41 TypePtr GetType(TypeId id) const; 45 TypePtr GetType(TypeId id) const;
42 46
43 // Add @p type and get its assigned id. 47 // Add @p type and get its assigned id.
44 // @pre @p type must not be in any repository. 48 // @pre @p type must not be in any repository.
45 TypeId AddType(TypePtr type); 49 TypeId AddType(TypePtr type);
46 50
47 // Add @p type and with @p id if the give id is free. 51 // Add @p type and with @p id if the give id is free.
48 // @pre @p type must not be in any repository and @p id must be free. 52 // @pre @p type must not be in any repository and @p id must be free.
49 // @returns true on success, failure typically means id is already taken. 53 // @returns true on success, failure typically means id is already taken.
50 bool AddTypeWithId(TypePtr type, TypeId id); 54 bool AddTypeWithId(TypePtr type, TypeId id);
51 55
56
57 // Get the signature for the module this type represents.
58 bool GetModuleSignature(pe::PEFile::Signature* signature);
59
52 // @name Accessors. 60 // @name Accessors.
53 // @{ 61 // @{
54 size_t size() const; 62 size_t size() const;
55 Iterator begin() const; 63 Iterator begin() const;
56 Iterator end() const; 64 Iterator end() const;
57 // @} 65 // @}
58 66
59 private: 67 private:
60 friend class base::RefCounted<TypeRepository>; 68 friend class base::RefCounted<TypeRepository>;
61 ~TypeRepository(); 69 ~TypeRepository();
62 70
71 bool is_signature_set_;
72 pe::PEFile::Signature signature_;
63 base::hash_map<TypeId, TypePtr> types_; 73 base::hash_map<TypeId, TypePtr> types_;
64 74
65 DISALLOW_COPY_AND_ASSIGN(TypeRepository); 75 DISALLOW_COPY_AND_ASSIGN(TypeRepository);
66 }; 76 };
67 77
68 class TypeRepository::Iterator 78 class TypeRepository::Iterator
69 : public std::iterator<std::input_iterator_tag, TypePtr> { 79 : public std::iterator<std::input_iterator_tag, TypePtr> {
70 public: 80 public:
71 Iterator() {} 81 Iterator() {}
72 const TypePtr& operator*() const { return it_->second; } 82 const TypePtr& operator*() const { return it_->second; }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 private: 117 private:
108 friend class base::RefCounted<TypeNameIndex>; 118 friend class base::RefCounted<TypeNameIndex>;
109 ~TypeNameIndex(); 119 ~TypeNameIndex();
110 120
111 std::multimap<base::string16, TypePtr> name_index_; 121 std::multimap<base::string16, TypePtr> name_index_;
112 }; 122 };
113 123
114 } // namespace refinery 124 } // namespace refinery
115 125
116 #endif // SYZYGY_REFINERY_TYPES_TYPE_REPOSITORY_H_ 126 #endif // SYZYGY_REFINERY_TYPES_TYPE_REPOSITORY_H_
OLDNEW
« no previous file with comments | « syzygy/refinery/symbols/symbol_provider.h ('k') | syzygy/refinery/types/type_repository.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698