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

Side by Side Diff: runtime/vm/type_table.h

Issue 2481873005: clang-format runtime/vm (Closed)
Patch Set: Merge Created 4 years, 1 month 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 | « runtime/vm/token_position.cc ('k') | runtime/vm/unibrow.h » ('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 (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_TYPE_TABLE_H_ 5 #ifndef RUNTIME_VM_TYPE_TABLE_H_
6 #define RUNTIME_VM_TYPE_TABLE_H_ 6 #define RUNTIME_VM_TYPE_TABLE_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/hash_table.h" 9 #include "vm/hash_table.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
11 11
12 namespace dart { 12 namespace dart {
13 13
14 class CanonicalTypeKey { 14 class CanonicalTypeKey {
15 public: 15 public:
16 explicit CanonicalTypeKey(const Type& key) : key_(key) { 16 explicit CanonicalTypeKey(const Type& key) : key_(key) {}
17 } 17 bool Matches(const Type& arg) const { return key_.Equals(arg); }
18 bool Matches(const Type& arg) const { 18 uword Hash() const { return key_.Hash(); }
19 return key_.Equals(arg);
20 }
21 uword Hash() const {
22 return key_.Hash();
23 }
24 const Type& key_; 19 const Type& key_;
25 20
26 private: 21 private:
27 DISALLOW_ALLOCATION(); 22 DISALLOW_ALLOCATION();
28 }; 23 };
29 24
30 25
31 // Traits for looking up Canonical Type based on it's hash. 26 // Traits for looking up Canonical Type based on it's hash.
32 class CanonicalTypeTraits { 27 class CanonicalTypeTraits {
33 public: 28 public:
34 static const char* Name() { return "CanonicalTypeTraits"; } 29 static const char* Name() { return "CanonicalTypeTraits"; }
35 static bool ReportStats() { return false; } 30 static bool ReportStats() { return false; }
36 31
37 // Called when growing the table. 32 // Called when growing the table.
38 static bool IsMatch(const Object& a, const Object& b) { 33 static bool IsMatch(const Object& a, const Object& b) {
39 ASSERT(a.IsType() && b.IsType()); 34 ASSERT(a.IsType() && b.IsType());
40 const Type& arg1 = Type::Cast(a); 35 const Type& arg1 = Type::Cast(a);
41 const Type& arg2 = Type::Cast(b); 36 const Type& arg2 = Type::Cast(b);
42 return arg1.Equals(arg2) && (arg1.Hash() == arg2.Hash()); 37 return arg1.Equals(arg2) && (arg1.Hash() == arg2.Hash());
43 } 38 }
44 static bool IsMatch(const CanonicalTypeKey& a, const Object& b) { 39 static bool IsMatch(const CanonicalTypeKey& a, const Object& b) {
45 ASSERT(b.IsType()); 40 ASSERT(b.IsType());
46 return a.Matches(Type::Cast(b)); 41 return a.Matches(Type::Cast(b));
47 } 42 }
48 static uword Hash(const Object& key) { 43 static uword Hash(const Object& key) {
49 ASSERT(key.IsType()); 44 ASSERT(key.IsType());
50 return Type::Cast(key).Hash(); 45 return Type::Cast(key).Hash();
51 } 46 }
52 static uword Hash(const CanonicalTypeKey& key) { 47 static uword Hash(const CanonicalTypeKey& key) { return key.Hash(); }
53 return key.Hash();
54 }
55 static RawObject* NewKey(const CanonicalTypeKey& obj) { 48 static RawObject* NewKey(const CanonicalTypeKey& obj) {
56 return obj.key_.raw(); 49 return obj.key_.raw();
57 } 50 }
58 }; 51 };
59 typedef UnorderedHashSet <CanonicalTypeTraits> CanonicalTypeSet; 52 typedef UnorderedHashSet<CanonicalTypeTraits> CanonicalTypeSet;
60 53
61 54
62 class CanonicalTypeArgumentsKey { 55 class CanonicalTypeArgumentsKey {
63 public: 56 public:
64 explicit CanonicalTypeArgumentsKey(const TypeArguments& key) : key_(key) { 57 explicit CanonicalTypeArgumentsKey(const TypeArguments& key) : key_(key) {}
65 }
66 bool Matches(const TypeArguments& arg) const { 58 bool Matches(const TypeArguments& arg) const {
67 return key_.Equals(arg) && (key_.Hash() == arg.Hash()); 59 return key_.Equals(arg) && (key_.Hash() == arg.Hash());
68 } 60 }
69 uword Hash() const { 61 uword Hash() const { return key_.Hash(); }
70 return key_.Hash();
71 }
72 const TypeArguments& key_; 62 const TypeArguments& key_;
73 63
74 private: 64 private:
75 DISALLOW_ALLOCATION(); 65 DISALLOW_ALLOCATION();
76 }; 66 };
77 67
78 68
79 // Traits for looking up Canonical TypeArguments based on its hash. 69 // Traits for looking up Canonical TypeArguments based on its hash.
80 class CanonicalTypeArgumentsTraits { 70 class CanonicalTypeArgumentsTraits {
81 public: 71 public:
82 static const char* Name() { return "CanonicalTypeArgumentsTraits"; } 72 static const char* Name() { return "CanonicalTypeArgumentsTraits"; }
83 static bool ReportStats() { return false; } 73 static bool ReportStats() { return false; }
84 74
85 // Called when growing the table. 75 // Called when growing the table.
86 static bool IsMatch(const Object& a, const Object& b) { 76 static bool IsMatch(const Object& a, const Object& b) {
87 ASSERT(a.IsTypeArguments() && b.IsTypeArguments()); 77 ASSERT(a.IsTypeArguments() && b.IsTypeArguments());
88 const TypeArguments& arg1 = TypeArguments::Cast(a); 78 const TypeArguments& arg1 = TypeArguments::Cast(a);
89 const TypeArguments& arg2 = TypeArguments::Cast(b); 79 const TypeArguments& arg2 = TypeArguments::Cast(b);
90 return arg1.Equals(arg2) && (arg1.Hash() == arg2.Hash()); 80 return arg1.Equals(arg2) && (arg1.Hash() == arg2.Hash());
91 } 81 }
92 static bool IsMatch(const CanonicalTypeArgumentsKey& a, const Object& b) { 82 static bool IsMatch(const CanonicalTypeArgumentsKey& a, const Object& b) {
93 ASSERT(b.IsTypeArguments()); 83 ASSERT(b.IsTypeArguments());
94 return a.Matches(TypeArguments::Cast(b)); 84 return a.Matches(TypeArguments::Cast(b));
95 } 85 }
96 static uword Hash(const Object& key) { 86 static uword Hash(const Object& key) {
97 ASSERT(key.IsTypeArguments()); 87 ASSERT(key.IsTypeArguments());
98 return TypeArguments::Cast(key).Hash(); 88 return TypeArguments::Cast(key).Hash();
99 } 89 }
100 static uword Hash(const CanonicalTypeArgumentsKey& key) { 90 static uword Hash(const CanonicalTypeArgumentsKey& key) { return key.Hash(); }
101 return key.Hash();
102 }
103 static RawObject* NewKey(const CanonicalTypeArgumentsKey& obj) { 91 static RawObject* NewKey(const CanonicalTypeArgumentsKey& obj) {
104 return obj.key_.raw(); 92 return obj.key_.raw();
105 } 93 }
106 }; 94 };
107 typedef UnorderedHashSet<CanonicalTypeArgumentsTraits> 95 typedef UnorderedHashSet<CanonicalTypeArgumentsTraits>
108 CanonicalTypeArgumentsSet; 96 CanonicalTypeArgumentsSet;
109 97
110 } // namespace dart 98 } // namespace dart
111 99
112 #endif // RUNTIME_VM_TYPE_TABLE_H_ 100 #endif // RUNTIME_VM_TYPE_TABLE_H_
OLDNEW
« no previous file with comments | « runtime/vm/token_position.cc ('k') | runtime/vm/unibrow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698