OLD | NEW |
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 #include "syzygy/refinery/types/type_repository.h" | 15 #include "syzygy/refinery/types/type_repository.h" |
16 | 16 |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "syzygy/refinery/types/type.h" | 18 #include "syzygy/refinery/types/type.h" |
19 | 19 |
20 namespace refinery { | 20 namespace refinery { |
21 | 21 |
22 TypeRepository::TypeRepository() { | 22 TypeRepository::TypeRepository() : is_signature_set_(false) { |
| 23 } |
| 24 |
| 25 TypeRepository::TypeRepository(const pe::PEFile::Signature& signature) |
| 26 : is_signature_set_(true), signature_(signature) { |
23 } | 27 } |
24 | 28 |
25 TypeRepository::~TypeRepository() { | 29 TypeRepository::~TypeRepository() { |
26 } | 30 } |
27 | 31 |
28 TypePtr TypeRepository::GetType(TypeId id) const { | 32 TypePtr TypeRepository::GetType(TypeId id) const { |
29 auto it = types_.find(id); | 33 auto it = types_.find(id); |
30 if (it == types_.end()) | 34 if (it == types_.end()) |
31 return nullptr; | 35 return nullptr; |
32 return it->second; | 36 return it->second; |
(...skipping 17 matching lines...) Expand all Loading... |
50 // Check that the ID is unassigned. | 54 // Check that the ID is unassigned. |
51 if (types_.find(id) != types_.end()) | 55 if (types_.find(id) != types_.end()) |
52 return false; | 56 return false; |
53 | 57 |
54 type->SetRepository(this, id); | 58 type->SetRepository(this, id); |
55 types_[id] = type; | 59 types_[id] = type; |
56 | 60 |
57 return true; | 61 return true; |
58 } | 62 } |
59 | 63 |
| 64 bool TypeRepository::GetModuleSignature(pe::PEFile::Signature* signature) { |
| 65 DCHECK(signature); |
| 66 |
| 67 if (!is_signature_set_) |
| 68 return false; |
| 69 *signature = signature_; |
| 70 return true; |
| 71 } |
| 72 |
60 size_t TypeRepository::size() const { | 73 size_t TypeRepository::size() const { |
61 return types_.size(); | 74 return types_.size(); |
62 } | 75 } |
63 | 76 |
64 TypeRepository::Iterator TypeRepository::begin() const { | 77 TypeRepository::Iterator TypeRepository::begin() const { |
65 return Iterator(types_.begin()); | 78 return Iterator(types_.begin()); |
66 } | 79 } |
67 | 80 |
68 TypeRepository::Iterator TypeRepository::end() const { | 81 TypeRepository::Iterator TypeRepository::end() const { |
69 return Iterator(types_.end()); | 82 return Iterator(types_.end()); |
(...skipping 12 matching lines...) Expand all Loading... |
82 std::vector<TypePtr>* types) const { | 95 std::vector<TypePtr>* types) const { |
83 DCHECK(types); | 96 DCHECK(types); |
84 types->clear(); | 97 types->clear(); |
85 | 98 |
86 auto match = name_index_.equal_range(name); | 99 auto match = name_index_.equal_range(name); |
87 for (auto it = match.first; it != match.second; ++it) | 100 for (auto it = match.first; it != match.second; ++it) |
88 types->push_back(it->second); | 101 types->push_back(it->second); |
89 } | 102 } |
90 | 103 |
91 } // namespace refinery | 104 } // namespace refinery |
OLD | NEW |