OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 /** A formal parameter to a [Method]. */ | 5 /** A formal parameter to a [Method]. */ |
6 class Parameter { | 6 class Parameter { |
7 FormalNode definition; | 7 FormalNode definition; |
8 Member method; | 8 Member method; |
9 | 9 |
10 String name; | 10 String name; |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 String get generatedFactoryName() { | 190 String get generatedFactoryName() { |
191 assert(this.isFactory); | 191 assert(this.isFactory); |
192 String prefix = '${declaringType.jsname}.${constructorName}\$'; | 192 String prefix = '${declaringType.jsname}.${constructorName}\$'; |
193 if (name == '') { | 193 if (name == '') { |
194 return '${prefix}factory'; | 194 return '${prefix}factory'; |
195 } else { | 195 } else { |
196 return '${prefix}$name\$factory'; | 196 return '${prefix}$name\$factory'; |
197 } | 197 } |
198 } | 198 } |
199 | 199 |
200 int hashCode() => (declaringType.hashCode() << 4) ^ name.hashCode(); | 200 int hashCode() { |
| 201 final typeCode = declaringType == null ? 1 : declaringType.hashCode(); |
| 202 final nameCode = isConstructor ? constructorName.hashCode() : |
| 203 name.hashCode(); |
| 204 return (typeCode << 4) ^ nameCode; |
| 205 } |
| 206 |
| 207 bool operator ==(other) { |
| 208 return other is Member && isConstructor == other.isConstructor && |
| 209 declaringType == other.declaringType && (isConstructor ? |
| 210 constructorName == other.constructorName : name == other.name); |
| 211 } |
201 } | 212 } |
202 | 213 |
203 | 214 |
204 /** | 215 /** |
205 * Types are treated as first class members of their library's top type. | 216 * Types are treated as first class members of their library's top type. |
206 */ | 217 */ |
207 // TODO(jmesserly): perhaps Type should extend Member, but that can get | 218 // TODO(jmesserly): perhaps Type should extend Member, but that can get |
208 // complicated. | 219 // complicated. |
209 class TypeMember extends Member { | 220 class TypeMember extends Member { |
210 final DefinedType type; | 221 final DefinedType type; |
(...skipping 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1736 } | 1747 } |
1737 | 1748 |
1738 void forEach(void f(Member member)) { | 1749 void forEach(void f(Member member)) { |
1739 factories.forEach((_, Map constructors) { | 1750 factories.forEach((_, Map constructors) { |
1740 constructors.forEach((_, Member member) { | 1751 constructors.forEach((_, Member member) { |
1741 f(member); | 1752 f(member); |
1742 }); | 1753 }); |
1743 }); | 1754 }); |
1744 } | 1755 } |
1745 } | 1756 } |
OLD | NEW |