OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 VM_PRECOMPILER_H_ | 5 #ifndef VM_PRECOMPILER_H_ |
6 #define VM_PRECOMPILER_H_ | 6 #define VM_PRECOMPILER_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 #include "vm/hash_map.h" | 9 #include "vm/hash_map.h" |
| 10 #include "vm/hash_table.h" |
10 #include "vm/object.h" | 11 #include "vm/object.h" |
11 | 12 |
12 namespace dart { | 13 namespace dart { |
13 | 14 |
14 // Forward declarations. | 15 // Forward declarations. |
15 class Class; | 16 class Class; |
16 class Error; | 17 class Error; |
17 class Field; | 18 class Field; |
18 class Function; | 19 class Function; |
19 class GrowableObjectArray; | 20 class GrowableObjectArray; |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 intptr_t dropped_field_count_; | 250 intptr_t dropped_field_count_; |
250 | 251 |
251 const GrowableObjectArray& libraries_; | 252 const GrowableObjectArray& libraries_; |
252 const GrowableObjectArray& pending_functions_; | 253 const GrowableObjectArray& pending_functions_; |
253 SymbolSet sent_selectors_; | 254 SymbolSet sent_selectors_; |
254 FunctionSet enqueued_functions_; | 255 FunctionSet enqueued_functions_; |
255 FieldSet fields_to_retain_; | 256 FieldSet fields_to_retain_; |
256 Error& error_; | 257 Error& error_; |
257 }; | 258 }; |
258 | 259 |
| 260 |
| 261 class FunctionsTraits { |
| 262 public: |
| 263 static bool IsMatch(const Object& a, const Object& b) { |
| 264 Zone* zone = Thread::Current()->zone(); |
| 265 String& a_s = String::Handle(zone); |
| 266 String& b_s = String::Handle(zone); |
| 267 a_s = a.IsFunction() ? Function::Cast(a).name() : String::Cast(a).raw(); |
| 268 b_s = b.IsFunction() ? Function::Cast(b).name() : String::Cast(b).raw(); |
| 269 ASSERT(a_s.IsSymbol() && b_s.IsSymbol()); |
| 270 return a_s.raw() == b_s.raw(); |
| 271 } |
| 272 static uword Hash(const Object& obj) { |
| 273 if (obj.IsFunction()) { |
| 274 return String::Handle(Function::Cast(obj).name()).Hash(); |
| 275 } else { |
| 276 ASSERT(String::Cast(obj).IsSymbol()); |
| 277 return String::Cast(obj).Hash(); |
| 278 } |
| 279 } |
| 280 static RawObject* NewKey(const Function& function) { |
| 281 return function.raw(); |
| 282 } |
| 283 }; |
| 284 |
| 285 typedef UnorderedHashSet<FunctionsTraits> UniqueFunctionsSet; |
| 286 |
| 287 |
259 } // namespace dart | 288 } // namespace dart |
260 | 289 |
261 #endif // VM_PRECOMPILER_H_ | 290 #endif // VM_PRECOMPILER_H_ |
OLD | NEW |