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

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

Issue 19473005: Address some drive-by comments: equality without hash, types in the instantiation expression. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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
« no previous file with comments | « no previous file | no next file » | 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 // VM-specific implementation of the dart:mirrors library. 5 // VM-specific implementation of the dart:mirrors library.
6 6
7 // These values are allowed to be passed directly over the wire. 7 // These values are allowed to be passed directly over the wire.
8 bool _isSimpleValue(var value) { 8 bool _isSimpleValue(var value) {
9 return (value == null || value is num || value is String || value is bool); 9 return (value == null || value is num || value is String || value is bool);
10 } 10 }
11 11
12 Map _filterMap(Map<Symbol, dynamic> old_map, bool filter(Symbol key, value)) { 12 Map _filterMap(Map<Symbol, dynamic> old_map, bool filter(Symbol key, value)) {
13 Map new_map = new Map<Symbol, dynamic>(); 13 Map new_map = new Map<Symbol, dynamic>();
14 old_map.forEach((key, value) { 14 old_map.forEach((key, value) {
15 if (filter(key, value)) { 15 if (filter(key, value)) {
16 new_map[key] = value; 16 new_map[key] = value;
17 } 17 }
18 }); 18 });
19 return new_map; 19 return new_map;
20 } 20 }
21 21
22 Map _makeMemberMap(List mirrors) { 22 Map _makeMemberMap(List mirrors) {
23 Map<Symbol, dynamic> result = new Map(); 23 Map result = new Map<Symbol, dynamic>();
24 mirrors.forEach((mirror) => result[mirror.simpleName] = mirror); 24 mirrors.forEach((mirror) => result[mirror.simpleName] = mirror);
25 return result; 25 return result;
26 } 26 }
27 27
28 String _n(Symbol symbol) => _symbol_dev.Symbol.getName(symbol); 28 String _n(Symbol symbol) => _symbol_dev.Symbol.getName(symbol);
29 29
30 Symbol _s(String name) { 30 Symbol _s(String name) {
31 if (name == null) return null; 31 if (name == null) return null;
32 return new _symbol_dev.Symbol.unvalidated(name); 32 return new _symbol_dev.Symbol.unvalidated(name);
33 } 33 }
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 : super(reflectee, 629 : super(reflectee,
630 simpleName, 630 simpleName,
631 true, 631 true,
632 null, 632 null,
633 new _LazyTypeMirror('dart:core', 'Object'), 633 new _LazyTypeMirror('dart:core', 'Object'),
634 [ new _LazyTypeMirror('dart:core', 'Function') ], 634 [ new _LazyTypeMirror('dart:core', 'Function') ],
635 null, 635 null,
636 const {}, 636 const {},
637 const {}); 637 const {});
638 638
639 Map<Symbol, Mirror> get members => const {}; 639 Map<Symbol, Mirror> get members => new Map<Symbol,Mirror>();
640 640
641 var _returnType; 641 var _returnType;
642 TypeMirror get returnType { 642 TypeMirror get returnType {
643 if (_returnType is! Mirror) { 643 if (_returnType is! Mirror) {
644 _returnType = _returnType.resolve(mirrors); 644 _returnType = _returnType.resolve(mirrors);
645 } 645 }
646 return _returnType; 646 return _returnType;
647 } 647 }
648 648
649 final List<ParameterMirror> parameters; 649 final List<ParameterMirror> parameters;
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 String toString() => "TypeMirror on '${_n(simpleName)}'"; 1145 String toString() => "TypeMirror on '${_n(simpleName)}'";
1146 1146
1147 // TODO(11955): Remove once dynamicType and voidType are canonical objects in 1147 // TODO(11955): Remove once dynamicType and voidType are canonical objects in
1148 // the object store. 1148 // the object store.
1149 operator ==(other) { 1149 operator ==(other) {
1150 if (other is! _SpecialTypeMirrorImpl) { 1150 if (other is! _SpecialTypeMirrorImpl) {
1151 return false; 1151 return false;
1152 } 1152 }
1153 return this.simpleName == other.simpleName; 1153 return this.simpleName == other.simpleName;
1154 } 1154 }
1155
1156 int get hashCode => simpleName.hashCode;
1155 } 1157 }
1156 1158
1157 class _Mirrors { 1159 class _Mirrors {
1158 // Does a port refer to our local isolate? 1160 // Does a port refer to our local isolate?
1159 static bool isLocalPort(SendPort port) native 'Mirrors_isLocalPort'; 1161 static bool isLocalPort(SendPort port) native 'Mirrors_isLocalPort';
1160 1162
1161 static MirrorSystem _currentMirrorSystem = null; 1163 static MirrorSystem _currentMirrorSystem = null;
1162 1164
1163 // Creates a new local MirrorSystem. 1165 // Creates a new local MirrorSystem.
1164 static MirrorSystem makeLocalMirrorSystem() 1166 static MirrorSystem makeLocalMirrorSystem()
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 static Expando<ClassMirror> _classMirrorCache = new Expando("ClassMirror"); 1205 static Expando<ClassMirror> _classMirrorCache = new Expando("ClassMirror");
1204 static ClassMirror reflectClass(Type key) { 1206 static ClassMirror reflectClass(Type key) {
1205 var classMirror = _classMirrorCache[key]; 1207 var classMirror = _classMirrorCache[key];
1206 if (classMirror == null) { 1208 if (classMirror == null) {
1207 classMirror = makeLocalClassMirror(key); 1209 classMirror = makeLocalClassMirror(key);
1208 _classMirrorCache[key] = classMirror; 1210 _classMirrorCache[key] = classMirror;
1209 } 1211 }
1210 return classMirror; 1212 return classMirror;
1211 } 1213 }
1212 } 1214 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698