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

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

Issue 23460013: Implement InstanceMirror.== in dart2js and InstanceMirror.hashCode in the VM and … (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
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 // VM-specific implementation of the dart:mirrors library. 5 // VM-specific implementation of the dart:mirrors library.
6 6
7 import "dart:collection"; 7 import "dart:collection";
8 8
9 // These values are allowed to be passed directly over the wire. 9 // These values are allowed to be passed directly over the wire.
10 bool _isSimpleValue(var value) { 10 bool _isSimpleValue(var value) {
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 return _invokeOnClosure(reflectee, invocation); 276 return _invokeOnClosure(reflectee, invocation);
277 } 277 }
278 278
279 String toString() => 'InstanceMirror on ${Error.safeToString(_reflectee)}'; 279 String toString() => 'InstanceMirror on ${Error.safeToString(_reflectee)}';
280 280
281 bool operator ==(other) { 281 bool operator ==(other) {
282 return other is _LocalInstanceMirrorImpl && 282 return other is _LocalInstanceMirrorImpl &&
283 identical(_reflectee, other._reflectee); 283 identical(_reflectee, other._reflectee);
284 } 284 }
285 285
286 int get hashCode => _reflectee.hashCode; 286 int get hashCode {
287 // If the reflectee is a double or bignum, use the base hashCode to preserve
288 // the illusion that boxed numbers with the same value are identical. If the
289 // reflectee is a Smi, use the base hashCode because Object.hashCode does
290 // not work for non-heap objects. Otherwise, use Object.hashCode to maintain
291 // correctness even if a user-defined hashCode returns different values for
292 // successive invocations.
293 return _reflectee is num ? _reflectee.hashCode : _identityHash(_reflectee);
294 }
295
296 static _identityHash(reflectee)
297 native "InstanceMirror_identityHash";
287 298
288 _invoke(reflectee, functionName, positionalArguments) 299 _invoke(reflectee, functionName, positionalArguments)
289 native 'InstanceMirror_invoke'; 300 native 'InstanceMirror_invoke';
290 301
291 _invokeGetter(reflectee, getterName) 302 _invokeGetter(reflectee, getterName)
292 native 'InstanceMirror_invokeGetter'; 303 native 'InstanceMirror_invokeGetter';
293 304
294 _invokeSetter(reflectee, setterName, value) 305 _invokeSetter(reflectee, setterName, value)
295 native 'InstanceMirror_invokeSetter'; 306 native 'InstanceMirror_invokeSetter';
296 307
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 if (typeMirror == null) { 1306 if (typeMirror == null) {
1296 typeMirror = makeLocalTypeMirror(key); 1307 typeMirror = makeLocalTypeMirror(key);
1297 _instanitationCache[key] = typeMirror; 1308 _instanitationCache[key] = typeMirror;
1298 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { 1309 if (typeMirror is ClassMirror && !typeMirror._isGeneric) {
1299 _declarationCache[key] = typeMirror; 1310 _declarationCache[key] = typeMirror;
1300 } 1311 }
1301 } 1312 }
1302 return typeMirror; 1313 return typeMirror;
1303 } 1314 }
1304 } 1315 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698