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 | 6 |
7 // The VM has its own implementation of equals. | 7 // The VM has its own implementation of equals. |
8 bool operator ==(other) native "Object_equals"; | 8 bool operator ==(other) native "Object_equals"; |
9 | 9 |
10 // Helpers used to implement hashCode. If a hashCode is used, we remember it | 10 // Helpers used to implement hashCode. If a hashCode is used, we remember it |
(...skipping 11 matching lines...) Expand all Loading... |
22 // We want the hash to be a Smi value greater than 0. | 22 // We want the hash to be a Smi value greater than 0. |
23 result = _hashCodeRnd.nextInt(0x40000000); | 23 result = _hashCodeRnd.nextInt(0x40000000); |
24 while (result == 0) { | 24 while (result == 0) { |
25 result = _hashCodeRnd.nextInt(0x40000000); | 25 result = _hashCodeRnd.nextInt(0x40000000); |
26 } | 26 } |
27 _setHash(obj, result); | 27 _setHash(obj, result); |
28 } | 28 } |
29 return result; | 29 return result; |
30 } | 30 } |
31 | 31 |
32 /* @patch */ int get hashCode => _objectHashCode(this); | 32 @patch int get hashCode => _objectHashCode(this); |
33 int get _identityHashCode => _objectHashCode(this); | 33 int get _identityHashCode => _objectHashCode(this); |
34 | 34 |
35 /* @patch */ String toString() native "Object_toString"; | 35 @patch String toString() native "Object_toString"; |
36 // A statically dispatched version of Object.toString. | 36 // A statically dispatched version of Object.toString. |
37 static String _toString(obj) native "Object_toString"; | 37 static String _toString(obj) native "Object_toString"; |
38 | 38 |
39 _noSuchMethod(bool isMethod, | 39 _noSuchMethod(bool isMethod, |
40 String memberName, | 40 String memberName, |
41 int type, | 41 int type, |
42 List arguments, | 42 List arguments, |
43 Map<String, dynamic> namedArguments) | 43 Map<String, dynamic> namedArguments) |
44 native "Object_noSuchMethod"; | 44 native "Object_noSuchMethod"; |
45 | 45 |
46 /* @patch */ noSuchMethod(Invocation invocation) { | 46 @patch noSuchMethod(Invocation invocation) { |
47 return _noSuchMethod(invocation.isMethod, | 47 return _noSuchMethod(invocation.isMethod, |
48 internal.Symbol.getName(invocation.memberName), | 48 internal.Symbol.getName(invocation.memberName), |
49 invocation._type, | 49 invocation._type, |
50 invocation.positionalArguments, | 50 invocation.positionalArguments, |
51 _symbolMapToStringMap(invocation.namedArguments)); | 51 _symbolMapToStringMap(invocation.namedArguments)); |
52 } | 52 } |
53 | 53 |
54 /* @patch */ Type get runtimeType native "Object_runtimeType"; | 54 @patch Type get runtimeType native "Object_runtimeType"; |
55 | 55 |
56 // Call this function instead of inlining instanceof, thus collecting | 56 // Call this function instead of inlining instanceof, thus collecting |
57 // type feedback and reducing code size of unoptimized code. | 57 // type feedback and reducing code size of unoptimized code. |
58 bool _instanceOf(instantiator_type_arguments, type, bool negate) | 58 bool _instanceOf(instantiator_type_arguments, type, bool negate) |
59 native "Object_instanceOf"; | 59 native "Object_instanceOf"; |
60 | 60 |
61 // Group of functions for implementing fast simple instance of. | 61 // Group of functions for implementing fast simple instance of. |
62 bool _simpleInstanceOf(type) native "Object_simpleInstanceOf"; | 62 bool _simpleInstanceOf(type) native "Object_simpleInstanceOf"; |
63 bool _simpleInstanceOfTrue(type) => true; | 63 bool _simpleInstanceOfTrue(type) => true; |
64 bool _simpleInstanceOfFalse(type) => false; | 64 bool _simpleInstanceOfFalse(type) => false; |
65 | 65 |
66 bool _instanceOfDouble(bool negate) native "Object_instanceOfDouble"; | 66 bool _instanceOfDouble(bool negate) native "Object_instanceOfDouble"; |
67 bool _instanceOfNum(bool negate) native "Object_instanceOfNum"; | 67 bool _instanceOfNum(bool negate) native "Object_instanceOfNum"; |
68 bool _instanceOfInt(bool negate) native "Object_instanceOfInt"; | 68 bool _instanceOfInt(bool negate) native "Object_instanceOfInt"; |
69 bool _instanceOfSmi(bool negate) native "Object_instanceOfSmi"; | 69 bool _instanceOfSmi(bool negate) native "Object_instanceOfSmi"; |
70 bool _instanceOfString(bool negate) native "Object_instanceOfString"; | 70 bool _instanceOfString(bool negate) native "Object_instanceOfString"; |
71 | 71 |
72 // Call this function instead of inlining 'as', thus collecting type | 72 // Call this function instead of inlining 'as', thus collecting type |
73 // feedback. Returns receiver. | 73 // feedback. Returns receiver. |
74 _as(instantiator_type_arguments, type) native "Object_as"; | 74 _as(instantiator_type_arguments, type) native "Object_as"; |
75 | 75 |
76 static _symbolMapToStringMap(Map<Symbol, dynamic> map) { | 76 static _symbolMapToStringMap(Map<Symbol, dynamic> map) { |
77 var result = new Map<String, dynamic>(); | 77 var result = new Map<String, dynamic>(); |
78 map.forEach((Symbol key, value) { | 78 map.forEach((Symbol key, value) { |
79 result[internal.Symbol.getName(key)] = value; | 79 result[internal.Symbol.getName(key)] = value; |
80 }); | 80 }); |
81 return result; | 81 return result; |
82 } | 82 } |
83 } | 83 } |
OLD | NEW |