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 import 'dart:core' hide Symbol; | 5 import 'dart:core' hide Symbol; |
6 | 6 |
7 @patch | 7 @patch class Symbol { |
8 class Symbol { | 8 @patch const Symbol(String name) |
9 @patch | 9 : this._name = name; |
10 const Symbol(String name) : this._name = name; | |
11 | 10 |
12 @patch | 11 @patch toString() => 'Symbol("${getUnmangledName(this)}")'; |
13 toString() => 'Symbol("${getUnmangledName(this)}")'; | |
14 | 12 |
15 static getUnmangledName(Symbol symbol) { | 13 static getUnmangledName(Symbol symbol) { |
16 String string = Symbol.getName(symbol); | 14 String string = Symbol.getName(symbol); |
17 | 15 |
18 // Remove closurization hash mark | 16 // Remove closurization hash mark |
19 // #foo -> foo | 17 // #foo -> foo |
20 if (string.startsWith('#')) { | 18 if (string.startsWith('#')) { |
21 string = string.substring(1); | 19 string = string.substring(1); |
22 } | 20 } |
23 // get:foo -> foo | 21 // get:foo -> foo |
(...skipping 25 matching lines...) Expand all Loading... |
49 if (!skip) { | 47 if (!skip) { |
50 result.write(char); | 48 result.write(char); |
51 } | 49 } |
52 } | 50 } |
53 if (add_setter_suffix) { | 51 if (add_setter_suffix) { |
54 result.write('='); | 52 result.write('='); |
55 } | 53 } |
56 return result.toString(); | 54 return result.toString(); |
57 } | 55 } |
58 | 56 |
59 @patch | 57 @patch int get hashCode { |
60 int get hashCode { | |
61 const arbitraryPrime = 664597; | 58 const arbitraryPrime = 664597; |
62 return 0x1fffffff & (arbitraryPrime * _name.hashCode); | 59 return 0x1fffffff & (arbitraryPrime * _name.hashCode); |
63 } | 60 } |
64 } | 61 } |
OLD | NEW |