OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 part of dart._collection.dev; |
| 6 |
| 7 /** |
| 8 * Implementation of [core.Symbol]. This class uses the same name as |
| 9 * a core class so a user can't tell the difference. |
| 10 * |
| 11 * The purpose of this class is to hide [_name] from user code, but |
| 12 * make it accessible to Dart platform code via the static method |
| 13 * [getName]. |
| 14 */ |
| 15 class Symbol implements core.Symbol { |
| 16 final String _name; |
| 17 |
| 18 external const Symbol(String name); |
| 19 |
| 20 /** |
| 21 * Platform-private method used by the mirror system to create |
| 22 * otherwise invalid names. |
| 23 */ |
| 24 const Symbol.unvalidated(this._name); |
| 25 |
| 26 bool operator ==(other) => other is Symbol && _name == other._name; |
| 27 |
| 28 int get hashCode { |
| 29 const arbitraryPrime = 664597; |
| 30 return 0x1fffffff & (arbitraryPrime * _name.hashCode); |
| 31 } |
| 32 |
| 33 /// Platform-private accessor which cannot be called from user libraries. |
| 34 static String getName(Symbol symbol) => symbol._name; |
| 35 } |
OLD | NEW |