| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 dart._internal; | 5 part of dart._internal; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Implementation of [core.Symbol]. This class uses the same name as | 8 * Implementation of [core.Symbol]. This class uses the same name as |
| 9 * a core class so a user can't tell the difference. | 9 * a core class so a user can't tell the difference. |
| 10 * | 10 * |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 /** | 103 /** |
| 104 * Platform-private method used by the mirror system to create | 104 * Platform-private method used by the mirror system to create |
| 105 * otherwise invalid names. | 105 * otherwise invalid names. |
| 106 */ | 106 */ |
| 107 const Symbol.unvalidated(this._name); | 107 const Symbol.unvalidated(this._name); |
| 108 | 108 |
| 109 // This is called by dart2js. | 109 // This is called by dart2js. |
| 110 Symbol.validated(String name) | 110 Symbol.validated(String name) |
| 111 : this._name = validatePublicSymbol(name); | 111 : this._name = validatePublicSymbol(name); |
| 112 | 112 |
| 113 bool operator ==(other) => other is Symbol && _name == other._name; | 113 bool operator ==(Object other) => other is Symbol && _name == other._name; |
| 114 | 114 |
| 115 int get hashCode { | 115 int get hashCode { |
| 116 const arbitraryPrime = 664597; | 116 const arbitraryPrime = 664597; |
| 117 return 0x1fffffff & (arbitraryPrime * _name.hashCode); | 117 return 0x1fffffff & (arbitraryPrime * _name.hashCode); |
| 118 } | 118 } |
| 119 | 119 |
| 120 toString() => 'Symbol("$_name")'; | 120 toString() => 'Symbol("$_name")'; |
| 121 | 121 |
| 122 /// Platform-private accessor which cannot be called from user libraries. | 122 /// Platform-private accessor which cannot be called from user libraries. |
| 123 static String getName(Symbol symbol) => symbol._name; | 123 static String getName(Symbol symbol) => symbol._name; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 136 | 136 |
| 137 /** | 137 /** |
| 138 * Checks whether name is a valid symbol name. | 138 * Checks whether name is a valid symbol name. |
| 139 * | 139 * |
| 140 * This test allows both private and non-private symbols. | 140 * This test allows both private and non-private symbols. |
| 141 */ | 141 */ |
| 142 static bool isValidSymbol(String name) { | 142 static bool isValidSymbol(String name) { |
| 143 return (name.isEmpty || symbolPattern.hasMatch(name)); | 143 return (name.isEmpty || symbolPattern.hasMatch(name)); |
| 144 } | 144 } |
| 145 } | 145 } |
| OLD | NEW |