Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Side by Side Diff: runtime/lib/object_patch.dart

Issue 2759973004: Fix observatory tests broken by running dartfmt. Temporarily reverted formatting for evaluate_activ… (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/lib/null_patch.dart ('k') | runtime/lib/print_patch.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
6 6 class Object {
7 // The VM has its own implementation of equals. 7 // The VM has its own implementation of equals.
8 @patch bool operator ==(other) native "Object_equals"; 8 @patch
9 bool operator ==(other) native "Object_equals";
9 10
10 // Helpers used to implement hashCode. If a hashCode is used, we remember it 11 // Helpers used to implement hashCode. If a hashCode is used, we remember it
11 // in a weak table in the VM. A new hashCode value is calculated using a 12 // in a weak table in the VM. A new hashCode value is calculated using a
12 // number generator. 13 // number generator.
13 static final _hashCodeRnd = new Random(); 14 static final _hashCodeRnd = new Random();
14 15
15 static _getHash(obj) native "Object_getHash"; 16 static _getHash(obj) native "Object_getHash";
16 static _setHash(obj, hash) native "Object_setHash"; 17 static _setHash(obj, hash) native "Object_setHash";
17 18
18 // Shared static implentation for hashCode and _identityHashCode. 19 // Shared static implentation for hashCode and _identityHashCode.
19 static int _objectHashCode(obj) { 20 static int _objectHashCode(obj) {
20 var result = _getHash(obj); 21 var result = _getHash(obj);
21 if (result == 0) { 22 if (result == 0) {
22 // We want the hash to be a Smi value greater than 0. 23 // We want the hash to be a Smi value greater than 0.
23 result = _hashCodeRnd.nextInt(0x40000000); 24 result = _hashCodeRnd.nextInt(0x40000000);
24 while (result == 0) { 25 while (result == 0) {
25 result = _hashCodeRnd.nextInt(0x40000000); 26 result = _hashCodeRnd.nextInt(0x40000000);
26 } 27 }
27 _setHash(obj, result); 28 _setHash(obj, result);
28 } 29 }
29 return result; 30 return result;
30 } 31 }
31 32
32 @patch int get hashCode => _objectHashCode(this); 33 @patch
34 int get hashCode => _objectHashCode(this);
33 int get _identityHashCode => _objectHashCode(this); 35 int get _identityHashCode => _objectHashCode(this);
34 36
35 @patch String toString() native "Object_toString"; 37 @patch
38 String toString() native "Object_toString";
36 // A statically dispatched version of Object.toString. 39 // A statically dispatched version of Object.toString.
37 static String _toString(obj) native "Object_toString"; 40 static String _toString(obj) native "Object_toString";
38 41
39 _noSuchMethod(bool isMethod, 42 _noSuchMethod(bool isMethod, String memberName, int type, List arguments,
40 String memberName, 43 Map<String, dynamic> namedArguments) native "Object_noSuchMethod";
41 int type,
42 List arguments,
43 Map<String, dynamic> namedArguments)
44 native "Object_noSuchMethod";
45 44
46 @patch dynamic noSuchMethod(Invocation invocation) { 45 @patch
47 return _noSuchMethod(invocation.isMethod, 46 dynamic noSuchMethod(Invocation invocation) {
48 internal.Symbol.getName(invocation.memberName), 47 return _noSuchMethod(
49 invocation._type, 48 invocation.isMethod,
50 invocation.positionalArguments, 49 internal.Symbol.getName(invocation.memberName),
51 _symbolMapToStringMap(invocation.namedArguments)); 50 invocation._type,
51 invocation.positionalArguments,
52 _symbolMapToStringMap(invocation.namedArguments));
52 } 53 }
53 54
54 @patch Type get runtimeType native "Object_runtimeType"; 55 @patch
56 Type get runtimeType native "Object_runtimeType";
55 57
56 static bool _haveSameRuntimeType(a, b) native "Object_haveSameRuntimeType"; 58 static bool _haveSameRuntimeType(a, b) native "Object_haveSameRuntimeType";
57 59
58 // Call this function instead of inlining instanceof, thus collecting 60 // Call this function instead of inlining instanceof, thus collecting
59 // type feedback and reducing code size of unoptimized code. 61 // type feedback and reducing code size of unoptimized code.
60 bool _instanceOf(instantiator_type_arguments, type) 62 bool _instanceOf(instantiator_type_arguments, type)
61 native "Object_instanceOf"; 63 native "Object_instanceOf";
62 64
63 // Group of functions for implementing fast simple instance of. 65 // Group of functions for implementing fast simple instance of.
64 bool _simpleInstanceOf(type) native "Object_simpleInstanceOf"; 66 bool _simpleInstanceOf(type) native "Object_simpleInstanceOf";
65 bool _simpleInstanceOfTrue(type) => true; 67 bool _simpleInstanceOfTrue(type) => true;
66 bool _simpleInstanceOfFalse(type) => false; 68 bool _simpleInstanceOfFalse(type) => false;
67 69
68 // Call this function instead of inlining 'as', thus collecting type 70 // Call this function instead of inlining 'as', thus collecting type
69 // feedback. Returns receiver. 71 // feedback. Returns receiver.
70 _as(instantiator_type_arguments, type) native "Object_as"; 72 _as(instantiator_type_arguments, type) native "Object_as";
71 73
72 static _symbolMapToStringMap(Map<Symbol, dynamic> map) { 74 static _symbolMapToStringMap(Map<Symbol, dynamic> map) {
73 var result = new Map<String, dynamic>(); 75 var result = new Map<String, dynamic>();
74 map.forEach((Symbol key, value) { 76 map.forEach((Symbol key, value) {
75 result[internal.Symbol.getName(key)] = value; 77 result[internal.Symbol.getName(key)] = value;
76 }); 78 });
77 return result; 79 return result;
78 } 80 }
79 } 81 }
OLDNEW
« no previous file with comments | « runtime/lib/null_patch.dart ('k') | runtime/lib/print_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698