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

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

Issue 14178010: Change libraries map to use Uri. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Test updated Created 7 years, 8 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 | « runtime/lib/mirrors.cc ('k') | runtime/tests/vm/dart/isolate_mirror_local_test.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 // 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 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 buf.write(', '); 55 buf.write(', ');
56 } 56 }
57 } 57 }
58 if (found_optional_param) { 58 if (found_optional_param) {
59 buf.write(']'); 59 buf.write(']');
60 } 60 }
61 buf.write(')'); 61 buf.write(')');
62 return buf.toString(); 62 return buf.toString();
63 } 63 }
64 64
65 class _LocalMirrorSystemImpl implements MirrorSystem { 65 Map<Uri, LibraryMirror> _createLibrariesMap(Map<String, LibraryMirror> map) {
66 // TODO(ahe): [libraries] should be Map<Uri, LibraryMirror>. 66 var result = new Map<Uri, LibraryMirror>();
67 map.forEach((String url, LibraryMirror mirror) {
68 result[Uri.parse(url)] = mirror;
69 });
70 return result;
71 }
72
73 class _LocalMirrorSystemImpl extends MirrorSystem {
67 // Change parameter back to "this.libraries" when native code is changed. 74 // Change parameter back to "this.libraries" when native code is changed.
68 _LocalMirrorSystemImpl(Map<String, LibraryMirror> libraries, this.isolate) 75 _LocalMirrorSystemImpl(Map<String, LibraryMirror> libraries, this.isolate)
69 : _functionTypes = new Map<String, FunctionTypeMirror>(), 76 : this.libraries = _createLibrariesMap(libraries),
70 this.libraries = _convertStringToSymbolMap(libraries); 77 _functionTypes = new Map<String, FunctionTypeMirror>();
71 78
72 final Map<Symbol, LibraryMirror> libraries; 79 final Map<Uri, LibraryMirror> libraries;
73 final IsolateMirror isolate; 80 final IsolateMirror isolate;
74 81
75 TypeMirror _dynamicType = null; 82 TypeMirror _dynamicType = null;
76 83
77 TypeMirror get dynamicType { 84 TypeMirror get dynamicType {
78 if (_dynamicType == null) { 85 if (_dynamicType == null) {
79 _dynamicType = 86 _dynamicType =
80 new _LocalClassMirrorImpl( 87 new _LocalClassMirrorImpl(
81 null, 'dynamic', false, null, null, [], null, 88 null, 'dynamic', false, null, null, [], null,
82 const {}, const {}, const {}); 89 const {}, const {}, const {});
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 Future<InstanceMirror> findInContext(Symbol name) { 401 Future<InstanceMirror> findInContext(Symbol name) {
395 throw new UnimplementedError( 402 throw new UnimplementedError(
396 'ClosureMirror.findInContext() is not implemented'); 403 'ClosureMirror.findInContext() is not implemented');
397 } 404 }
398 405
399 static _apply(ref, positionalArguments, async) 406 static _apply(ref, positionalArguments, async)
400 native 'LocalClosureMirrorImpl_apply'; 407 native 'LocalClosureMirrorImpl_apply';
401 } 408 }
402 409
403 class _LazyTypeMirror { 410 class _LazyTypeMirror {
404 _LazyTypeMirror(String libraryName, String typeName) 411 _LazyTypeMirror(String this.libraryUrl, String typeName)
405 : this.libraryName = _s(libraryName), 412 : this.typeName = _s(typeName);
406 this.typeName = _s(typeName);
407 413
408 TypeMirror resolve(MirrorSystem mirrors) { 414 TypeMirror resolve(MirrorSystem mirrors) {
409 if (libraryName == null) { 415 if (libraryUrl == null) {
410 if (typeName == const Symbol('dynamic')) { 416 if (typeName == const Symbol('dynamic')) {
411 return mirrors.dynamicType; 417 return mirrors.dynamicType;
412 } else if (typeName == const Symbol('void')) { 418 } else if (typeName == const Symbol('void')) {
413 return mirrors.voidType; 419 return mirrors.voidType;
414 } else { 420 } else {
415 throw new UnimplementedError( 421 throw new UnimplementedError(
416 "Mirror for type '$typeName' is not implemented"); 422 "Mirror for type '$typeName' is not implemented");
417 } 423 }
418 } 424 }
419 var resolved = mirrors.libraries[libraryName].members[typeName]; 425 var resolved = mirrors.libraries[Uri.parse(libraryUrl)].members[typeName];
420 if (resolved == null) { 426 if (resolved == null) {
421 throw new UnimplementedError( 427 throw new UnimplementedError(
422 "Mirror for type '$typeName' is not implemented"); 428 "Mirror for type '$typeName' is not implemented");
423 } 429 }
424 return resolved; 430 return resolved;
425 } 431 }
426 432
427 final Symbol libraryName; 433 final String libraryUrl;
428 final Symbol typeName; 434 final Symbol typeName;
429 } 435 }
430 436
431 class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl 437 class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl
432 implements ClassMirror { 438 implements ClassMirror {
433 _LocalClassMirrorImpl(ref, 439 _LocalClassMirrorImpl(ref,
434 String simpleName, 440 String simpleName,
435 this.isClass, 441 this.isClass,
436 this._owner, 442 this._owner,
437 this._superclass, 443 this._superclass,
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 _referent = _referent.resolve(mirrors); 757 _referent = _referent.resolve(mirrors);
752 } 758 }
753 return _referent; 759 return _referent;
754 } 760 }
755 761
756 String toString() => "TypedefMirror on '$simpleName'"; 762 String toString() => "TypedefMirror on '$simpleName'";
757 } 763 }
758 764
759 765
760 class _LazyLibraryMirror { 766 class _LazyLibraryMirror {
761 _LazyLibraryMirror(String libraryName) 767 _LazyLibraryMirror(String this.libraryUrl);
762 : this.libraryName = _s(libraryName);
763 768
764 LibraryMirror resolve(MirrorSystem mirrors) { 769 LibraryMirror resolve(MirrorSystem mirrors) {
765 return mirrors.libraries[libraryName]; 770 return mirrors.libraries[Uri.parse(libraryUrl)];
766 } 771 }
767 772
768 final Symbol libraryName; 773 final String libraryUrl;
769 } 774 }
770 775
771 class _LocalLibraryMirrorImpl extends _LocalObjectMirrorImpl 776 class _LocalLibraryMirrorImpl extends _LocalObjectMirrorImpl
772 implements LibraryMirror { 777 implements LibraryMirror {
773 _LocalLibraryMirrorImpl(ref, 778 _LocalLibraryMirrorImpl(ref,
774 String simpleName, 779 String simpleName,
775 String url, 780 String url,
776 Map<String, Mirror> members) 781 Map<String, Mirror> members)
777 : this.simpleName = _s(simpleName), 782 : this.simpleName = _s(simpleName),
778 this.members = _convertStringToSymbolMap(members), 783 this.members = _convertStringToSymbolMap(members),
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 } 1072 }
1068 1073
1069 // Creates a new local ClassMirror. 1074 // Creates a new local ClassMirror.
1070 static ClassMirror makeLocalClassMirror(Type key) 1075 static ClassMirror makeLocalClassMirror(Type key)
1071 native "Mirrors_makeLocalClassMirror"; 1076 native "Mirrors_makeLocalClassMirror";
1072 1077
1073 static ClassMirror reflectClass(Type key) { 1078 static ClassMirror reflectClass(Type key) {
1074 return makeLocalClassMirror(key); 1079 return makeLocalClassMirror(key);
1075 } 1080 }
1076 } 1081 }
OLDNEW
« no previous file with comments | « runtime/lib/mirrors.cc ('k') | runtime/tests/vm/dart/isolate_mirror_local_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698