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

Side by Side Diff: pkg/compiler/lib/src/js_backend/namer_names.dart

Issue 1859343004: dartfmt pkg/compiler (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 months 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
OLDNEW
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 part of js_backend; 5 part of js_backend;
6 6
7 abstract class _NamerName extends jsAst.Name { 7 abstract class _NamerName extends jsAst.Name {
8 int get _kind; 8 int get _kind;
9 _NamerName get _target => this; 9 _NamerName get _target => this;
10 10
11 String toString() { 11 String toString() {
12 if (DEBUG_MODE) { 12 if (DEBUG_MODE) {
13 return 'Name($key)'; 13 return 'Name($key)';
14 } 14 }
15 throw new UnsupportedError("Cannot convert a name to a string"); 15 throw new UnsupportedError("Cannot convert a name to a string");
16 } 16 }
17 } 17 }
18 18
19 enum _NamerNameKinds { 19 enum _NamerNameKinds { StringBacked, Getter, Setter, Async, Compound, Token }
20 StringBacked,
21 Getter,
22 Setter,
23 Async,
24 Compound,
25 Token
26 }
27 20
28 class StringBackedName extends _NamerName { 21 class StringBackedName extends _NamerName {
29 final String name; 22 final String name;
30 int get _kind => _NamerNameKinds.StringBacked.index; 23 int get _kind => _NamerNameKinds.StringBacked.index;
31 24
32 StringBackedName(this.name); 25 StringBackedName(this.name);
33 26
34 String get key => name; 27 String get key => name;
35 28
36 operator==(other) { 29 operator ==(other) {
37 if (other is _NameReference) other = other._target; 30 if (other is _NameReference) other = other._target;
38 if (identical(this, other)) return true; 31 if (identical(this, other)) return true;
39 return (other is StringBackedName) && other.name == name; 32 return (other is StringBackedName) && other.name == name;
40 } 33 }
41 34
42 int get hashCode => name.hashCode; 35 int get hashCode => name.hashCode;
43 36
44 int compareTo(_NamerName other) { 37 int compareTo(_NamerName other) {
45 other = other._target; 38 other = other._target;
46 if (other._kind != _kind) return other._kind - _kind; 39 if (other._kind != _kind) return other._kind - _kind;
47 return name.compareTo(other.name); 40 return name.compareTo(other.name);
48 } 41 }
49 } 42 }
50 43
51 abstract class _PrefixedName extends _NamerName implements jsAst.AstContainer { 44 abstract class _PrefixedName extends _NamerName implements jsAst.AstContainer {
52 final jsAst.Name prefix; 45 final jsAst.Name prefix;
53 final jsAst.Name base; 46 final jsAst.Name base;
54 int get _kind; 47 int get _kind;
55 48
56 Iterable<jsAst.Node> get containedNodes => [prefix, base]; 49 Iterable<jsAst.Node> get containedNodes => [prefix, base];
57 50
58 _PrefixedName(this.prefix, this.base); 51 _PrefixedName(this.prefix, this.base);
59 52
60 String get name => prefix.name + base.name; 53 String get name => prefix.name + base.name;
61 54
62 String get key => prefix.key + base.key; 55 String get key => prefix.key + base.key;
63 56
64 bool operator==(other) { 57 bool operator ==(other) {
65 if (other is _NameReference) other = other._target; 58 if (other is _NameReference) other = other._target;
66 if (identical(this, other)) return true; 59 if (identical(this, other)) return true;
67 if (other is! _PrefixedName) return false; 60 if (other is! _PrefixedName) return false;
68 return other.base == base && other.prefix == prefix; 61 return other.base == base && other.prefix == prefix;
69 } 62 }
70 63
71 int get hashCode => base.hashCode * 13 + prefix.hashCode; 64 int get hashCode => base.hashCode * 13 + prefix.hashCode;
72 65
73 int compareTo(_NamerName other) { 66 int compareTo(_NamerName other) {
74 other = other._target; 67 other = other._target;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 111
119 String get name { 112 String get name {
120 if (_cachedName == null) { 113 if (_cachedName == null) {
121 _cachedName = _parts.map((jsAst.Name name) => name.name).join(); 114 _cachedName = _parts.map((jsAst.Name name) => name.name).join();
122 } 115 }
123 return _cachedName; 116 return _cachedName;
124 } 117 }
125 118
126 String get key => _parts.map((_NamerName name) => name.key).join(); 119 String get key => _parts.map((_NamerName name) => name.key).join();
127 120
128 bool operator==(other) { 121 bool operator ==(other) {
129 if (other is _NameReference) other = other._target; 122 if (other is _NameReference) other = other._target;
130 if (identical(this, other)) return true; 123 if (identical(this, other)) return true;
131 if (other is! CompoundName) return false; 124 if (other is! CompoundName) return false;
132 if (other._parts.length != _parts.length) return false; 125 if (other._parts.length != _parts.length) return false;
133 for (int i = 0; i < _parts.length; ++i) { 126 for (int i = 0; i < _parts.length; ++i) {
134 if (other._parts[i] != _parts[i]) return false; 127 if (other._parts[i] != _parts[i]) return false;
135 } 128 }
136 return true; 129 return true;
137 } 130 }
138 131
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 int compareTo(_NamerName other) { 174 int compareTo(_NamerName other) {
182 other = other._target; 175 other = other._target;
183 if (other._kind != _kind) return other._kind - _kind; 176 if (other._kind != _kind) return other._kind - _kind;
184 TokenName otherToken = other; 177 TokenName otherToken = other;
185 return key.compareTo(otherToken.key); 178 return key.compareTo(otherToken.key);
186 } 179 }
187 180
188 markSeen(jsAst.TokenCounter counter) => _rc++; 181 markSeen(jsAst.TokenCounter counter) => _rc++;
189 182
190 @override 183 @override
191 bool operator==(other) { 184 bool operator ==(other) {
192 if (other is _NameReference) other = other._target; 185 if (other is _NameReference) other = other._target;
193 if (identical(this, other)) return true; 186 if (identical(this, other)) return true;
194 return false; 187 return false;
195 } 188 }
196 189
197 @override 190 @override
198 int get hashCode => super.hashCode; 191 int get hashCode => super.hashCode;
199 192
200 finalize() { 193 finalize() {
201 assert(invariant(NO_LOCATION_SPANNABLE, !isFinalized, 194 assert(invariant(NO_LOCATION_SPANNABLE, !isFinalized,
(...skipping 11 matching lines...) Expand all
213 Iterable<jsAst.Node> get containedNodes => [_target]; 206 Iterable<jsAst.Node> get containedNodes => [_target];
214 207
215 _NameReference(this._target); 208 _NameReference(this._target);
216 209
217 String get name => _target.name; 210 String get name => _target.name;
218 211
219 @override 212 @override
220 int compareTo(_NamerName other) => _target.compareTo(other); 213 int compareTo(_NamerName other) => _target.compareTo(other);
221 214
222 @override 215 @override
223 bool operator==(other) => _target == other; 216 bool operator ==(other) => _target == other;
224 217
225 @override 218 @override
226 int get hashCode => _target.hashCode; 219 int get hashCode => _target.hashCode;
227 } 220 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/namer.dart ('k') | pkg/compiler/lib/src/js_backend/native_data.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698