| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 patch class Object { | 5 patch class Object { |
| 6 |
| 7 // Helpers used to implement hashCode. If a hashCode is used we remember it |
| 8 // using an Expando object. A new hashCode value is calculated using a Random |
| 9 // number generator. |
| 10 static Expando _hashCodeExp = new Expando("Object.hashCode"); |
| 11 static Random _hashCodeRnd = new Random(); |
| 12 |
| 13 /* patch */ int hashCode() { |
| 14 var result = _hashCodeExp[this]; |
| 15 if (result == null) { |
| 16 result = _hashCodeRnd.nextInt(0x40000000); // Stay in Smi range. |
| 17 _hashCodeExp[this] = result; |
| 18 } |
| 19 return result; |
| 20 } |
| 21 |
| 6 /* patch */ String toString() => _toString(this); | 22 /* patch */ String toString() => _toString(this); |
| 7 | 23 |
| 8 /* patch */ void noSuchMethod(String functionName, List args) { | 24 /* patch */ void noSuchMethod(String functionName, List args) { |
| 9 _noSuchMethod(this, functionName, args); | 25 _noSuchMethod(this, functionName, args); |
| 10 } | 26 } |
| 11 | 27 |
| 12 static void _noSuchMethod(Object obj, String functionName, List args) | 28 static void _noSuchMethod(Object obj, String functionName, List args) |
| 13 native "Object_noSuchMethod"; | 29 native "Object_noSuchMethod"; |
| 14 | 30 |
| 15 static String _toString(Object obj) native "Object_toString"; | 31 static String _toString(Object obj) native "Object_toString"; |
| 16 } | 32 } |
| OLD | NEW |