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

Side by Side Diff: sdk/lib/_internal/lib/js_mirrors.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) 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 library dart._js_mirrors; 5 library dart._js_mirrors;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection' show UnmodifiableListView; 8 import 'dart:collection' show UnmodifiableListView;
9 import 'dart:mirrors'; 9 import 'dart:mirrors';
10 10
(...skipping 11 matching lines...) Expand all
22 Null, 22 Null,
23 Primitives, 23 Primitives,
24 RuntimeError, 24 RuntimeError,
25 createRuntimeType, 25 createRuntimeType,
26 createUnmangledInvocationMirror, 26 createUnmangledInvocationMirror,
27 getMangledTypeName, 27 getMangledTypeName,
28 throwInvalidReflectionError, 28 throwInvalidReflectionError,
29 runtimeTypeToString; 29 runtimeTypeToString;
30 import 'dart:_interceptors' show 30 import 'dart:_interceptors' show
31 Interceptor, 31 Interceptor,
32 JSExtendableArray; 32 JSExtendableArray,
33 getInterceptor;
ahe 2013/08/30 20:40:14 I think you can remove this import if my suggestio
rmacnak 2013/08/30 21:08:29 Done.
33 import 'dart:_js_names'; 34 import 'dart:_js_names';
34 35
35 /// No-op method that is called to inform the compiler that tree-shaking needs 36 /// No-op method that is called to inform the compiler that tree-shaking needs
36 /// to be disabled. 37 /// to be disabled.
37 disableTreeShaking() => preserveNames(); 38 disableTreeShaking() => preserveNames();
38 39
39 /// No-op method that is called to inform the compiler that metadata must be 40 /// No-op method that is called to inform the compiler that metadata must be
40 /// preserved at runtime. 41 /// preserved at runtime.
41 preserveMetadata() {} 42 preserveMetadata() {}
42 43
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 671
671 InstanceMirror getField(Symbol fieldName) { 672 InstanceMirror getField(Symbol fieldName) {
672 String reflectiveName = n(fieldName); 673 String reflectiveName = n(fieldName);
673 return _invoke(fieldName, JSInvocationMirror.GETTER, reflectiveName, []); 674 return _invoke(fieldName, JSInvocationMirror.GETTER, reflectiveName, []);
674 } 675 }
675 676
676 delegate(Invocation invocation) { 677 delegate(Invocation invocation) {
677 return JSInvocationMirror.invokeFromMirror(invocation, reflectee); 678 return JSInvocationMirror.invokeFromMirror(invocation, reflectee);
678 } 679 }
679 680
681 operator ==(other) {
682 return other is JsInstanceMirror &&
683 identical(reflectee, other.reflectee);
684 }
685
686 int get hashCode {
687 // If the reflectee is intercepted, use the base hashCode to preserve the
688 // illusion that, e.g. doubles, with the same value are identical.
689 // Otherwise, use the primitive identity hash to maintain correctness even
690 // if a user-defined hashCode returns different values for successive
691 // invocations.
692 return getInterceptor(reflectee) is Interceptor
ahe 2013/08/30 20:40:14 I think other native types, such as DivElement, wi
rmacnak 2013/08/30 21:08:29 Done, but I have to also separate out null. typeof
693 ? reflectee.hashCode
694 : Primitives.objectHashCode(reflectee);
695 }
696
680 String toString() => 'InstanceMirror on ${Error.safeToString(reflectee)}'; 697 String toString() => 'InstanceMirror on ${Error.safeToString(reflectee)}';
681 698
682 // TODO(ahe): Remove this method from the API. 699 // TODO(ahe): Remove this method from the API.
683 MirrorSystem get mirrors => currentJsMirrorSystem; 700 MirrorSystem get mirrors => currentJsMirrorSystem;
684 } 701 }
685 702
686 class JsClassMirror extends JsTypeMirror with JsObjectMirror 703 class JsClassMirror extends JsTypeMirror with JsObjectMirror
687 implements ClassMirror { 704 implements ClassMirror {
688 final String _mangledName; 705 final String _mangledName;
689 final _jsConstructorOrInterceptor; 706 final _jsConstructorOrInterceptor;
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after
1526 void operator []=(K key, V value) => _throw(); 1543 void operator []=(K key, V value) => _throw();
1527 1544
1528 V putIfAbsent(K key, V ifAbsent()) { _throw(); } 1545 V putIfAbsent(K key, V ifAbsent()) { _throw(); }
1529 1546
1530 void addAll(Map<K, V> other) => _throw(); 1547 void addAll(Map<K, V> other) => _throw();
1531 1548
1532 V remove(K key) { _throw(); } 1549 V remove(K key) { _throw(); }
1533 1550
1534 void clear() => _throw(); 1551 void clear() => _throw();
1535 } 1552 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698