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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 } | 63 } |
| 64 | 64 |
| 65 Map<Uri, LibraryMirror> _createLibrariesMap(Map<String, LibraryMirror> map) { | 65 Map<Uri, LibraryMirror> _createLibrariesMap(Map<String, LibraryMirror> map) { |
| 66 var result = new Map<Uri, LibraryMirror>(); | 66 var result = new Map<Uri, LibraryMirror>(); |
| 67 map.forEach((String url, LibraryMirror mirror) { | 67 map.forEach((String url, LibraryMirror mirror) { |
| 68 result[Uri.parse(url)] = mirror; | 68 result[Uri.parse(url)] = mirror; |
| 69 }); | 69 }); |
| 70 return result; | 70 return result; |
| 71 } | 71 } |
| 72 | 72 |
| 73 List<InstanceMirror> _metadata(mirror) | 73 List _metadata(reflectee) |
| 74 native 'Mirrors_metadata'; | 74 native 'DeclarationMirror_metadata'; |
| 75 | 75 |
| 76 // This will verify the argument types, unwrap them, and ensure we have a fixed | 76 // This will verify the argument types, unwrap them, and ensure we have a fixed |
| 77 // array. | 77 // array. |
| 78 List _unwarpAsyncPositionals(wrappedArgs){ | 78 List _unwarpAsyncPositionals(wrappedArgs){ |
| 79 List unwrappedArgs = new List(wrappedArgs.length); | 79 List unwrappedArgs = new List(wrappedArgs.length); |
| 80 for(int i = 0; i < wrappedArgs.length; i++){ | 80 for(int i = 0; i < wrappedArgs.length; i++){ |
| 81 var wrappedArg = wrappedArgs[i]; | 81 var wrappedArg = wrappedArgs[i]; |
| 82 if(_isSimpleValue(wrappedArg)) { | 82 if(_isSimpleValue(wrappedArg)) { |
| 83 unwrappedArgs[i] = wrappedArg; | 83 unwrappedArgs[i] = wrappedArg; |
| 84 } else if(wrappedArg is InstanceMirror) { | 84 } else if(wrappedArg is InstanceMirror) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 LibraryMirror get rootLibrary { | 157 LibraryMirror get rootLibrary { |
| 158 if (_rootLibrary is _LazyLibraryMirror) { | 158 if (_rootLibrary is _LazyLibraryMirror) { |
| 159 _rootLibrary = _rootLibrary.resolve(mirrors); | 159 _rootLibrary = _rootLibrary.resolve(mirrors); |
| 160 } | 160 } |
| 161 return _rootLibrary; | 161 return _rootLibrary; |
| 162 } | 162 } |
| 163 | 163 |
| 164 String toString() => "IsolateMirror on '$debugName'"; | 164 String toString() => "IsolateMirror on '$debugName'"; |
| 165 } | 165 } |
| 166 | 166 |
| 167 // A VMReference is used to hold a reference to a VM-internal object, | 167 abstract class _LocalObjectMirrorImpl extends _LocalMirrorImpl |
| 168 // which can include things like libraries, classes, etc. | |
| 169 class VMReference extends NativeFieldWrapperClass1 { | |
| 170 } | |
| 171 | |
| 172 abstract class _LocalVMObjectMirrorImpl extends _LocalMirrorImpl { | |
| 173 _LocalVMObjectMirrorImpl(this._reference) {} | |
| 174 | |
| 175 // For now, all VMObjects hold a VMReference. We could consider | |
| 176 // storing the Object reference itself here if the object is a Dart | |
| 177 // language objects (except for objects of type VMReference, of | |
| 178 // course). | |
| 179 VMReference _reference; | |
| 180 } | |
| 181 | |
| 182 abstract class _LocalObjectMirrorImpl extends _LocalVMObjectMirrorImpl | |
| 183 implements ObjectMirror { | 168 implements ObjectMirror { |
| 184 _LocalObjectMirrorImpl(this._reflectee, ref) : super(ref) {} | 169 _LocalObjectMirrorImpl(this._reflectee); |
| 185 | 170 |
| 186 final _reflectee; // May be a MirrorReference or an ordinary object. | 171 final _reflectee; // May be a MirrorReference or an ordinary object. |
| 187 | 172 |
| 188 InstanceMirror invoke(Symbol memberName, | 173 InstanceMirror invoke(Symbol memberName, |
| 189 List positionalArguments, | 174 List positionalArguments, |
| 190 [Map<Symbol, dynamic> namedArguments]) { | 175 [Map<Symbol, dynamic> namedArguments]) { |
| 191 if (namedArguments != null) { | 176 if (namedArguments != null) { |
| 192 throw new UnimplementedError( | 177 throw new UnimplementedError( |
| 193 'named argument support is not implemented'); | 178 'named argument support is not implemented'); |
| 194 } | 179 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 268 'positional argument $i ($arg) was not a simple value'); | 253 'positional argument $i ($arg) was not a simple value'); |
| 269 } | 254 } |
| 270 } | 255 } |
| 271 } | 256 } |
| 272 | 257 |
| 273 class _LocalInstanceMirrorImpl extends _LocalObjectMirrorImpl | 258 class _LocalInstanceMirrorImpl extends _LocalObjectMirrorImpl |
| 274 implements InstanceMirror { | 259 implements InstanceMirror { |
| 275 // TODO(ahe): This is a hack, see delegate below. | 260 // TODO(ahe): This is a hack, see delegate below. |
| 276 static Function _invokeOnClosure; | 261 static Function _invokeOnClosure; |
| 277 | 262 |
| 278 _LocalInstanceMirrorImpl(ref, | 263 _LocalInstanceMirrorImpl(this._type, |
| 279 this._type, | 264 reflectee) : super(reflectee) {} |
| 280 reflectee) : super(reflectee, ref) {} | |
| 281 | 265 |
| 282 var _type; | 266 var _type; |
| 283 ClassMirror get type { | 267 ClassMirror get type { |
| 284 if (_type is! Mirror) { | 268 if (_type is! Mirror) { |
| 285 _type = _type.resolve(mirrors); | 269 _type = _type.resolve(mirrors); |
| 286 } | 270 } |
| 287 return _type; | 271 return _type; |
| 288 } | 272 } |
| 289 | 273 |
| 290 // LocalInstanceMirrors always reflect local instances | 274 // LocalInstanceMirrors always reflect local instances |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 314 | 298 |
| 315 _invokeGetter(reflectee, getterName) | 299 _invokeGetter(reflectee, getterName) |
| 316 native 'InstanceMirror_invokeGetter'; | 300 native 'InstanceMirror_invokeGetter'; |
| 317 | 301 |
| 318 _invokeSetter(reflectee, setterName, value) | 302 _invokeSetter(reflectee, setterName, value) |
| 319 native 'InstanceMirror_invokeSetter'; | 303 native 'InstanceMirror_invokeSetter'; |
| 320 } | 304 } |
| 321 | 305 |
| 322 class _LocalClosureMirrorImpl extends _LocalInstanceMirrorImpl | 306 class _LocalClosureMirrorImpl extends _LocalInstanceMirrorImpl |
| 323 implements ClosureMirror { | 307 implements ClosureMirror { |
| 324 _LocalClosureMirrorImpl(ref, | 308 _LocalClosureMirrorImpl(type, |
| 325 type, | |
| 326 reflectee, | 309 reflectee, |
| 327 this.function) : super(ref, type, reflectee) {} | 310 this.function) : super(type, reflectee) {} |
| 328 | 311 |
| 329 final MethodMirror function; | 312 final MethodMirror function; |
| 330 | 313 |
| 331 String get source { | 314 String get source { |
| 332 throw new UnimplementedError( | 315 throw new UnimplementedError( |
| 333 'ClosureMirror.source is not implemented'); | 316 'ClosureMirror.source is not implemented'); |
| 334 } | 317 } |
| 335 | 318 |
| 336 InstanceMirror apply(List<Object> positionalArguments, | 319 InstanceMirror apply(List<Object> positionalArguments, |
| 337 [Map<Symbol, Object> namedArguments]) { | 320 [Map<Symbol, Object> namedArguments]) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 397 return resolved; | 380 return resolved; |
| 398 } | 381 } |
| 399 | 382 |
| 400 final String libraryUrl; | 383 final String libraryUrl; |
| 401 final Symbol typeName; | 384 final Symbol typeName; |
| 402 } | 385 } |
| 403 | 386 |
| 404 class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl | 387 class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl |
| 405 implements ClassMirror { | 388 implements ClassMirror { |
| 406 _LocalClassMirrorImpl(reflectee, | 389 _LocalClassMirrorImpl(reflectee, |
| 407 ref, | |
| 408 String simpleName, | 390 String simpleName, |
| 409 this.isClass, | 391 this.isClass, |
| 410 this._owner, | 392 this._owner, |
| 411 this._superclass, | 393 this._superclass, |
| 412 this._superinterfaces, | 394 this._superinterfaces, |
| 413 this._defaultFactory, | 395 this._defaultFactory, |
| 414 Map<String, Mirror> members, | 396 Map<String, Mirror> members, |
| 415 Map<String, Mirror> constructors, | 397 Map<String, Mirror> constructors, |
| 416 Map<String, Mirror> typeVariables) | 398 Map<String, Mirror> typeVariables) |
| 417 : this._simpleName = _s(simpleName), | 399 : this._simpleName = _s(simpleName), |
| 418 this.members = _convertStringToSymbolMap(members), | 400 this.members = _convertStringToSymbolMap(members), |
| 419 this.constructors = _convertStringToSymbolMap(constructors), | 401 this.constructors = _convertStringToSymbolMap(constructors), |
| 420 this.typeVariables = _convertStringToSymbolMap(typeVariables), | 402 this.typeVariables = _convertStringToSymbolMap(typeVariables), |
| 421 super(reflectee, ref); | 403 super(reflectee); |
| 422 | 404 |
| 423 Symbol _simpleName; | 405 Symbol _simpleName; |
| 424 Symbol get simpleName { | 406 Symbol get simpleName { |
| 425 // dynamic, void and the function types have their names set eagerly in the | 407 // dynamic, void and the function types have their names set eagerly in the |
| 426 // constructor. | 408 // constructor. |
| 427 if(_simpleName == null) { | 409 if(_simpleName == null) { |
| 428 _simpleName = _s(_name(_reflectee)); | 410 _simpleName = _s(_name(_reflectee)); |
| 429 } | 411 } |
| 430 return _simpleName; | 412 return _simpleName; |
| 431 } | 413 } |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 577 _n(constructorName), | 559 _n(constructorName), |
| 578 _unwarpAsyncPositionals(positionalArgument s)); | 560 _unwarpAsyncPositionals(positionalArgument s)); |
| 579 return new Future.value(reflect(result)); | 561 return new Future.value(reflect(result)); |
| 580 } on MirroredError catch(e) { | 562 } on MirroredError catch(e) { |
| 581 return new Future.error(e); | 563 return new Future.error(e); |
| 582 } | 564 } |
| 583 } | 565 } |
| 584 | 566 |
| 585 // get the metadata objects, convert them into InstanceMirrors using | 567 // get the metadata objects, convert them into InstanceMirrors using |
| 586 // reflect() and then make them into a Dart list | 568 // reflect() and then make them into a Dart list |
| 587 List<InstanceMirror> get metadata => _metadata(this).map(reflect).toList(); | 569 List<InstanceMirror> get metadata => _metadata(_reflectee).map(reflect).toList (); |
|
ahe
2013/07/17 13:03:39
Long line.
| |
| 588 | 570 |
| 589 | 571 |
| 590 static _name(reflectee) | 572 static _name(reflectee) |
| 591 native "ClassMirror_name"; | 573 native "ClassMirror_name"; |
| 592 | 574 |
| 593 _invoke(reflectee, memberName, positionalArguments) | 575 _invoke(reflectee, memberName, positionalArguments) |
| 594 native 'ClassMirror_invoke'; | 576 native 'ClassMirror_invoke'; |
| 595 | 577 |
| 596 _invokeGetter(reflectee, getterName) | 578 _invokeGetter(reflectee, getterName) |
| 597 native 'ClassMirror_invokeGetter'; | 579 native 'ClassMirror_invokeGetter'; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 610 return mirrors._lookupFunctionTypeMirror(returnType.resolve(mirrors), | 592 return mirrors._lookupFunctionTypeMirror(returnType.resolve(mirrors), |
| 611 parameters); | 593 parameters); |
| 612 } | 594 } |
| 613 | 595 |
| 614 final returnType; | 596 final returnType; |
| 615 final List<ParameterMirror> parameters; | 597 final List<ParameterMirror> parameters; |
| 616 } | 598 } |
| 617 | 599 |
| 618 class _LocalFunctionTypeMirrorImpl extends _LocalClassMirrorImpl | 600 class _LocalFunctionTypeMirrorImpl extends _LocalClassMirrorImpl |
| 619 implements FunctionTypeMirror { | 601 implements FunctionTypeMirror { |
| 620 _LocalFunctionTypeMirrorImpl(ref, | 602 _LocalFunctionTypeMirrorImpl(reflectee, |
| 621 simpleName, | 603 simpleName, |
| 622 this._returnType, | 604 this._returnType, |
| 623 this.parameters) | 605 this.parameters) |
| 624 : super(null, | 606 : super(reflectee, |
| 625 ref, | |
| 626 simpleName, | 607 simpleName, |
| 627 true, | 608 true, |
| 628 null, | 609 null, |
| 629 new _LazyTypeMirror('dart:core', 'Object'), | 610 new _LazyTypeMirror('dart:core', 'Object'), |
| 630 [ new _LazyTypeMirror('dart:core', 'Function') ], | 611 [ new _LazyTypeMirror('dart:core', 'Function') ], |
| 631 null, | 612 null, |
| 632 const {}, | 613 const {}, |
| 633 const {}, | 614 const {}, |
| 634 const {}); | 615 const {}); |
| 635 | 616 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 695 } | 676 } |
| 696 | 677 |
| 697 var _upperBound; | 678 var _upperBound; |
| 698 TypeMirror get upperBound { | 679 TypeMirror get upperBound { |
| 699 if (_upperBound is! Mirror) { | 680 if (_upperBound is! Mirror) { |
| 700 _upperBound = _upperBound.resolve(mirrors); | 681 _upperBound = _upperBound.resolve(mirrors); |
| 701 } | 682 } |
| 702 return _upperBound; | 683 return _upperBound; |
| 703 } | 684 } |
| 704 | 685 |
| 705 // get the metadata objects, convert them into InstanceMirrors using | 686 List<InstanceMirror> get metadata { |
| 706 // reflect() and then make them into a Dart list | 687 throw new UnimplementedError( |
| 707 List<InstanceMirror> get metadata => _metadata(this).map(reflect).toList(); | 688 'TypeVariableMirror.metadata is not implemented'); |
| 689 } | |
| 708 | 690 |
| 709 String toString() => "TypeVariableMirror on '${_n(simpleName)}'"; | 691 String toString() => "TypeVariableMirror on '${_n(simpleName)}'"; |
| 710 } | 692 } |
| 711 | 693 |
| 712 | 694 |
| 713 class _LocalTypedefMirrorImpl extends _LocalMirrorImpl | 695 class _LocalTypedefMirrorImpl extends _LocalMirrorImpl |
| 714 implements TypedefMirror { | 696 implements TypedefMirror { |
| 715 _LocalTypedefMirrorImpl(String simpleName, | 697 _LocalTypedefMirrorImpl(String simpleName, |
| 716 this._owner, | 698 this._owner, |
| 717 this._referent) | 699 this._referent) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 762 LibraryMirror resolve(MirrorSystem mirrors) { | 744 LibraryMirror resolve(MirrorSystem mirrors) { |
| 763 return mirrors.libraries[Uri.parse(libraryUrl)]; | 745 return mirrors.libraries[Uri.parse(libraryUrl)]; |
| 764 } | 746 } |
| 765 | 747 |
| 766 final String libraryUrl; | 748 final String libraryUrl; |
| 767 } | 749 } |
| 768 | 750 |
| 769 class _LocalLibraryMirrorImpl extends _LocalObjectMirrorImpl | 751 class _LocalLibraryMirrorImpl extends _LocalObjectMirrorImpl |
| 770 implements LibraryMirror { | 752 implements LibraryMirror { |
| 771 _LocalLibraryMirrorImpl(reflectee, | 753 _LocalLibraryMirrorImpl(reflectee, |
| 772 ref, | |
| 773 String simpleName, | 754 String simpleName, |
| 774 String url, | 755 String url, |
| 775 Map<String, Mirror> members) | 756 Map<String, Mirror> members) |
| 776 : this.simpleName = _s(simpleName), | 757 : this.simpleName = _s(simpleName), |
| 777 this.members = _convertStringToSymbolMap(members), | 758 this.members = _convertStringToSymbolMap(members), |
| 778 this.uri = Uri.parse(url), | 759 this.uri = Uri.parse(url), |
| 779 super(reflectee, ref); | 760 super(reflectee); |
| 780 | 761 |
| 781 final Symbol simpleName; | 762 final Symbol simpleName; |
| 782 | 763 |
| 783 // The simple name and the qualified name are the same for a library. | 764 // The simple name and the qualified name are the same for a library. |
| 784 Symbol get qualifiedName => simpleName; | 765 Symbol get qualifiedName => simpleName; |
| 785 | 766 |
| 786 // Always null for libraries. | 767 // Always null for libraries. |
| 787 final DeclarationMirror owner = null; | 768 final DeclarationMirror owner = null; |
| 788 | 769 |
| 789 // Always false for libraries. | 770 // Always false for libraries. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 841 Map<Symbol, VariableMirror> get variables { | 822 Map<Symbol, VariableMirror> get variables { |
| 842 if (_variables == null) { | 823 if (_variables == null) { |
| 843 _variables = _filterMap(members, | 824 _variables = _filterMap(members, |
| 844 (key, value) => (value is VariableMirror)); | 825 (key, value) => (value is VariableMirror)); |
| 845 } | 826 } |
| 846 return _variables; | 827 return _variables; |
| 847 } | 828 } |
| 848 | 829 |
| 849 // get the metadata objects, convert them into InstanceMirrors using | 830 // get the metadata objects, convert them into InstanceMirrors using |
| 850 // reflect() and then make them into a Dart list | 831 // reflect() and then make them into a Dart list |
| 851 List<InstanceMirror> get metadata => _metadata(this).map(reflect).toList(); | 832 List<InstanceMirror> get metadata => _metadata(_reflectee).map(reflect).toList (); |
|
ahe
2013/07/17 13:03:39
Long line.
| |
| 852 | 833 |
| 853 String toString() => "LibraryMirror on '${_n(simpleName)}'"; | 834 String toString() => "LibraryMirror on '${_n(simpleName)}'"; |
| 854 | 835 |
| 855 _invoke(reflectee, memberName, positionalArguments) | 836 _invoke(reflectee, memberName, positionalArguments) |
| 856 native 'LibraryMirror_invoke'; | 837 native 'LibraryMirror_invoke'; |
| 857 | 838 |
| 858 _invokeGetter(reflectee, getterName) | 839 _invokeGetter(reflectee, getterName) |
| 859 native 'LibraryMirror_invokeGetter'; | 840 native 'LibraryMirror_invokeGetter'; |
| 860 | 841 |
| 861 _invokeSetter(reflectee, setterName, value) | 842 _invokeSetter(reflectee, setterName, value) |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 963 | 944 |
| 964 final bool isConstConstructor; | 945 final bool isConstConstructor; |
| 965 final bool isGenerativeConstructor; | 946 final bool isGenerativeConstructor; |
| 966 final bool isRedirectingConstructor; | 947 final bool isRedirectingConstructor; |
| 967 final bool isFactoryConstructor; | 948 final bool isFactoryConstructor; |
| 968 | 949 |
| 969 List<InstanceMirror> get metadata { | 950 List<InstanceMirror> get metadata { |
| 970 owner; // ensure owner is computed | 951 owner; // ensure owner is computed |
| 971 // get the metadata objects, convert them into InstanceMirrors using | 952 // get the metadata objects, convert them into InstanceMirrors using |
| 972 // reflect() and then make them into a Dart list | 953 // reflect() and then make them into a Dart list |
| 973 return _metadata(this).map(reflect).toList(); | 954 return _metadata(_reflectee).map(reflect).toList(); |
| 974 } | 955 } |
| 975 | 956 |
| 976 String toString() => "MethodMirror on '${_n(simpleName)}'"; | 957 String toString() => "MethodMirror on '${_n(simpleName)}'"; |
| 977 | 958 |
| 978 static String _MethodMirror_name(reflectee) | 959 static String _MethodMirror_name(reflectee) |
| 979 native "MethodMirror_name"; | 960 native "MethodMirror_name"; |
| 980 } | 961 } |
| 981 | 962 |
| 982 class _LocalVariableMirrorImpl extends _LocalMirrorImpl | 963 class _LocalVariableMirrorImpl extends _LocalMirrorImpl |
| 983 implements VariableMirror { | 964 implements VariableMirror { |
| 984 _LocalVariableMirrorImpl(String simpleName, | 965 _LocalVariableMirrorImpl(this._reflectee, |
| 966 String simpleName, | |
| 985 this._owner, | 967 this._owner, |
| 986 this._type, | 968 this._type, |
| 987 this.isStatic, | 969 this.isStatic, |
| 988 this.isFinal) | 970 this.isFinal) |
| 989 : this.simpleName = _s(simpleName); | 971 : this.simpleName = _s(simpleName); |
| 990 | 972 |
| 973 final _MirrorReference _reflectee; | |
| 991 final Symbol simpleName; | 974 final Symbol simpleName; |
| 992 | 975 |
| 993 Symbol _qualifiedName = null; | 976 Symbol _qualifiedName = null; |
| 994 Symbol get qualifiedName { | 977 Symbol get qualifiedName { |
| 995 if (_qualifiedName == null) { | 978 if (_qualifiedName == null) { |
| 996 _qualifiedName = _computeQualifiedName(owner, simpleName); | 979 _qualifiedName = _computeQualifiedName(owner, simpleName); |
| 997 } | 980 } |
| 998 return _qualifiedName; | 981 return _qualifiedName; |
| 999 } | 982 } |
| 1000 | 983 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 1024 if (_type is! Mirror) { | 1007 if (_type is! Mirror) { |
| 1025 _type = _type.resolve(mirrors); | 1008 _type = _type.resolve(mirrors); |
| 1026 } | 1009 } |
| 1027 return _type; | 1010 return _type; |
| 1028 } | 1011 } |
| 1029 | 1012 |
| 1030 final bool isStatic; | 1013 final bool isStatic; |
| 1031 final bool isFinal; | 1014 final bool isFinal; |
| 1032 | 1015 |
| 1033 List<InstanceMirror> get metadata { | 1016 List<InstanceMirror> get metadata { |
| 1034 owner; // ensure owner is computed | |
| 1035 // get the metadata objects, convert them into InstanceMirrors using | 1017 // get the metadata objects, convert them into InstanceMirrors using |
| 1036 // reflect() and then make them into a Dart list | 1018 // reflect() and then make them into a Dart list |
| 1037 return _metadata(this).map(reflect).toList(); | 1019 return _metadata(_reflectee).map(reflect).toList(); |
| 1038 } | 1020 } |
| 1039 | 1021 |
| 1040 String toString() => "VariableMirror on '${_n(simpleName)}'"; | 1022 String toString() => "VariableMirror on '${_n(simpleName)}'"; |
| 1041 } | 1023 } |
| 1042 | 1024 |
| 1043 class _LocalParameterMirrorImpl extends _LocalVariableMirrorImpl | 1025 class _LocalParameterMirrorImpl extends _LocalVariableMirrorImpl |
| 1044 implements ParameterMirror { | 1026 implements ParameterMirror { |
| 1045 _LocalParameterMirrorImpl(type, this.isOptional) | 1027 _LocalParameterMirrorImpl(type, this.isOptional) |
| 1046 : super('<TODO:unnamed>', null, type, false, false) {} | 1028 : super(null, '<TODO:unnamed>', null, type, false, false) {} |
| 1047 | 1029 |
| 1048 final bool isOptional; | 1030 final bool isOptional; |
| 1049 | 1031 |
| 1050 String get defaultValue { | 1032 String get defaultValue { |
| 1051 throw new UnimplementedError( | 1033 throw new UnimplementedError( |
| 1052 'ParameterMirror.defaultValue is not implemented'); | 1034 'ParameterMirror.defaultValue is not implemented'); |
| 1053 } | 1035 } |
| 1054 | 1036 |
| 1055 bool get hasDefaultValue { | 1037 bool get hasDefaultValue { |
| 1056 throw new UnimplementedError( | 1038 throw new UnimplementedError( |
| 1057 'ParameterMirror.hasDefaultValue is not implemented'); | 1039 'ParameterMirror.hasDefaultValue is not implemented'); |
| 1058 } | 1040 } |
| 1041 | |
| 1042 // TODO(11418): Implement. | |
| 1043 List<InstanceMirror> get metadata { | |
| 1044 throw new UnimplementedError( | |
| 1045 'ParameterMirror.metadata is not implemented'); | |
| 1046 } | |
| 1059 } | 1047 } |
| 1060 | 1048 |
| 1061 class _SpecialTypeMirrorImpl extends _LocalMirrorImpl | 1049 class _SpecialTypeMirrorImpl extends _LocalMirrorImpl |
| 1062 implements TypeMirror, DeclarationMirror { | 1050 implements TypeMirror, DeclarationMirror { |
| 1063 _SpecialTypeMirrorImpl(this.simpleName); | 1051 _SpecialTypeMirrorImpl(this.simpleName); |
| 1064 | 1052 |
| 1065 final bool isPrivate = false; | 1053 final bool isPrivate = false; |
| 1066 final bool isTopLevel = true; | 1054 final bool isTopLevel = true; |
| 1067 | 1055 |
| 1068 // Fixed length 0, therefore immutable. | 1056 // Fixed length 0, therefore immutable. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1126 } | 1114 } |
| 1127 | 1115 |
| 1128 // Creates a new local ClassMirror. | 1116 // Creates a new local ClassMirror. |
| 1129 static ClassMirror makeLocalClassMirror(Type key) | 1117 static ClassMirror makeLocalClassMirror(Type key) |
| 1130 native "Mirrors_makeLocalClassMirror"; | 1118 native "Mirrors_makeLocalClassMirror"; |
| 1131 | 1119 |
| 1132 static ClassMirror reflectClass(Type key) { | 1120 static ClassMirror reflectClass(Type key) { |
| 1133 return makeLocalClassMirror(key); | 1121 return makeLocalClassMirror(key); |
| 1134 } | 1122 } |
| 1135 } | 1123 } |
| OLD | NEW |