OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef RUNTIME_VM_KERNEL_READER_H_ | 5 #ifndef RUNTIME_VM_KERNEL_READER_H_ |
6 #define RUNTIME_VM_KERNEL_READER_H_ | 6 #define RUNTIME_VM_KERNEL_READER_H_ |
7 | 7 |
8 #if !defined(DART_PRECOMPILED_RUNTIME) | 8 #if !defined(DART_PRECOMPILED_RUNTIME) |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 virtual RawClass* LookupClassByKernelClass(Class* klass); | 27 virtual RawClass* LookupClassByKernelClass(Class* klass); |
28 | 28 |
29 private: | 29 private: |
30 KernelReader* reader_; | 30 KernelReader* reader_; |
31 }; | 31 }; |
32 | 32 |
33 template <typename KernelType, typename VmType> | 33 template <typename KernelType, typename VmType> |
34 class Mapping { | 34 class Mapping { |
35 public: | 35 public: |
36 bool Lookup(KernelType* node, VmType** handle) { | 36 bool Lookup(KernelType* node, VmType** handle) { |
37 typename MapType::iterator value = map_.find(node); | 37 typename MapType::Pair* pair = map_.LookupPair(node); |
38 if (value != map_.end()) { | 38 if (pair != NULL) { |
39 *handle = value->second; | 39 *handle = pair->value; |
40 return true; | 40 return true; |
41 } | 41 } |
42 return false; | 42 return false; |
43 } | 43 } |
44 | 44 |
45 void Insert(KernelType* node, VmType* object) { map_[node] = object; } | 45 void Insert(KernelType* node, VmType* object) { map_.Insert(node, object); } |
46 | 46 |
47 private: | 47 private: |
48 typedef typename std::map<KernelType*, VmType*> MapType; | 48 typedef MallocMap<KernelType, VmType*> MapType; |
49 MapType map_; | 49 MapType map_; |
50 }; | 50 }; |
51 | 51 |
52 class KernelReader { | 52 class KernelReader { |
53 public: | 53 public: |
54 explicit KernelReader(Program* program); | 54 explicit KernelReader(Program* program); |
55 | 55 |
56 // Returns either a library or a failure object. | 56 // Returns either a library or a failure object. |
57 dart::Object& ReadProgram(); | 57 dart::Object& ReadProgram(); |
58 | 58 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 109 |
110 Mapping<Library, dart::Library> libraries_; | 110 Mapping<Library, dart::Library> libraries_; |
111 Mapping<Class, dart::Class> classes_; | 111 Mapping<Class, dart::Class> classes_; |
112 }; | 112 }; |
113 | 113 |
114 } // namespace kernel | 114 } // namespace kernel |
115 } // namespace dart | 115 } // namespace dart |
116 | 116 |
117 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 117 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
118 #endif // RUNTIME_VM_KERNEL_READER_H_ | 118 #endif // RUNTIME_VM_KERNEL_READER_H_ |
OLD | NEW |