Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 // For now, all VMObjects hold a VMReference. We could consider | 132 // For now, all VMObjects hold a VMReference. We could consider |
| 133 // storing the Object reference itself here if the object is a Dart | 133 // storing the Object reference itself here if the object is a Dart |
| 134 // language objects (except for objects of type VMReference, of | 134 // language objects (except for objects of type VMReference, of |
| 135 // course). | 135 // course). |
| 136 VMReference _reference; | 136 VMReference _reference; |
| 137 } | 137 } |
| 138 | 138 |
| 139 abstract class _LocalObjectMirrorImpl extends _LocalVMObjectMirrorImpl | 139 abstract class _LocalObjectMirrorImpl extends _LocalVMObjectMirrorImpl |
| 140 implements ObjectMirror { | 140 implements ObjectMirror { |
| 141 _LocalObjectMirrorImpl(ref) : super(ref) {} | 141 _LocalObjectMirrorImpl(ref) : super(ref) {} |
| 142 | 142 |
| 143 Future<InstanceMirror> invokeAsync(String memberName, | 143 Future<InstanceMirror> invokeAsync(String memberName, |
| 144 List positionalArguments, | 144 List positionalArguments, |
| 145 [Map<String,dynamic> namedArguments]) { | 145 [Map<String,dynamic> namedArguments]) { |
| 146 if (namedArguments != null) { | 146 if (namedArguments != null) { |
| 147 throw new UnimplementedError( | 147 throw new UnimplementedError( |
| 148 'named argument support is not implemented'); | 148 'named argument support is not implemented'); |
| 149 } | 149 } |
| 150 // Walk the arguments and make sure they are legal. | 150 // Walk the arguments and make sure they are legal. |
| 151 for (int i = 0; i < positionalArguments.length; i++) { | 151 for (int i = 0; i < positionalArguments.length; i++) { |
| 152 var arg = positionalArguments[i]; | 152 var arg = positionalArguments[i]; |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 675 return mirrors.libraries[libraryName]; | 675 return mirrors.libraries[libraryName]; |
| 676 } | 676 } |
| 677 | 677 |
| 678 final String libraryName; | 678 final String libraryName; |
| 679 } | 679 } |
| 680 | 680 |
| 681 class _LocalLibraryMirrorImpl extends _LocalObjectMirrorImpl | 681 class _LocalLibraryMirrorImpl extends _LocalObjectMirrorImpl |
| 682 implements LibraryMirror { | 682 implements LibraryMirror { |
| 683 _LocalLibraryMirrorImpl(ref, | 683 _LocalLibraryMirrorImpl(ref, |
| 684 this.simpleName, | 684 this.simpleName, |
| 685 this.url, | 685 String url, |
| 686 this.members) : super(ref) {} | 686 this.members) |
| 687 : this.uri = Uri.parse(url), super(ref) {} | |
| 687 | 688 |
| 688 final String simpleName; | 689 final String simpleName; |
| 689 | 690 |
| 690 // The simple name and the qualified name are the same for a library. | 691 // The simple name and the qualified name are the same for a library. |
| 691 String get qualifiedName => simpleName; | 692 String get qualifiedName => simpleName; |
| 692 | 693 |
| 693 // Always null for libraries. | 694 // Always null for libraries. |
| 694 final DeclarationMirror owner = null; | 695 final DeclarationMirror owner = null; |
| 695 | 696 |
| 696 // Always false for libraries. | 697 // Always false for libraries. |
| 697 final bool isPrivate = false; | 698 final bool isPrivate = false; |
| 698 | 699 |
| 699 // Always false for libraries. | 700 // Always false for libraries. |
| 700 final bool isTopLevel = false; | 701 final bool isTopLevel = false; |
| 701 | 702 |
| 702 SourceLocation get location { | 703 SourceLocation get location { |
| 703 throw new UnimplementedError( | 704 throw new UnimplementedError( |
| 704 'LibraryMirror.location is not implemented'); | 705 'LibraryMirror.location is not implemented'); |
| 705 } | 706 } |
| 706 | 707 |
| 707 final String url; | 708 String get url => uri.toString(); |
|
ahe
2013/04/15 13:24:48
Why keep "url"?
Johnni Winther
2013/04/17 09:40:33
Removed.
| |
| 709 final Uri uri; | |
| 708 final Map<String, Mirror> members; | 710 final Map<String, Mirror> members; |
| 709 | 711 |
| 710 Map<String, ClassMirror> _classes = null; | 712 Map<String, ClassMirror> _classes = null; |
| 711 Map<String, MethodMirror> _functions = null; | 713 Map<String, MethodMirror> _functions = null; |
| 712 Map<String, MethodMirror> _getters = null; | 714 Map<String, MethodMirror> _getters = null; |
| 713 Map<String, MethodMirror> _setters = null; | 715 Map<String, MethodMirror> _setters = null; |
| 714 Map<String, VariableMirror> _variables = null; | 716 Map<String, VariableMirror> _variables = null; |
| 715 | 717 |
| 716 Map<String, ClassMirror> get classes { | 718 Map<String, ClassMirror> get classes { |
| 717 if (_classes == null) { | 719 if (_classes == null) { |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 966 | 968 |
| 967 // Creates a new local mirror for some Object. | 969 // Creates a new local mirror for some Object. |
| 968 static InstanceMirror reflect(Object reflectee) { | 970 static InstanceMirror reflect(Object reflectee) { |
| 969 return makeLocalInstanceMirror(reflectee); | 971 return makeLocalInstanceMirror(reflectee); |
| 970 } | 972 } |
| 971 | 973 |
| 972 static ClassMirror reflectClass(Type reflectee) { | 974 static ClassMirror reflectClass(Type reflectee) { |
| 973 throw new UnimplementedError('reflectClass is not implemented'); | 975 throw new UnimplementedError('reflectClass is not implemented'); |
| 974 } | 976 } |
| 975 } | 977 } |
| OLD | NEW |