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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 final Map<String, LibraryMirror> libraries; | 50 final Map<String, LibraryMirror> libraries; |
51 final IsolateMirror isolate; | 51 final IsolateMirror isolate; |
52 | 52 |
53 TypeMirror _dynamicType = null; | 53 TypeMirror _dynamicType = null; |
54 | 54 |
55 TypeMirror get dynamicType { | 55 TypeMirror get dynamicType { |
56 if (_dynamicType == null) { | 56 if (_dynamicType == null) { |
57 _dynamicType = | 57 _dynamicType = |
58 new _LocalClassMirrorImpl( | 58 new _LocalClassMirrorImpl( |
59 null, 'Dynamic', false, null, null, [], null, | 59 null, 'dynamic', false, null, null, [], null, |
60 const {}, const {}, const {}); | 60 const {}, const {}, const {}); |
61 } | 61 } |
62 return _dynamicType; | 62 return _dynamicType; |
63 } | 63 } |
64 | 64 |
65 TypeMirror _voidType = null; | 65 TypeMirror _voidType = null; |
66 | 66 |
67 TypeMirror get voidType { | 67 TypeMirror get voidType { |
68 if (_voidType == null) { | 68 if (_voidType == null) { |
69 _voidType = | 69 _voidType = |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 | 333 |
334 static _apply(ref, positionalArguments) | 334 static _apply(ref, positionalArguments) |
335 native 'LocalClosureMirrorImpl_apply'; | 335 native 'LocalClosureMirrorImpl_apply'; |
336 } | 336 } |
337 | 337 |
338 class _LazyTypeMirror { | 338 class _LazyTypeMirror { |
339 _LazyTypeMirror(this.libraryName, this.typeName) {} | 339 _LazyTypeMirror(this.libraryName, this.typeName) {} |
340 | 340 |
341 TypeMirror resolve(MirrorSystem mirrors) { | 341 TypeMirror resolve(MirrorSystem mirrors) { |
342 if (libraryName == null) { | 342 if (libraryName == null) { |
343 // TODO(turnidge): Remove support for 'Dynamic'. | 343 if (typeName == 'dynamic') { |
344 if ((typeName == 'dynamic') || (typeName == 'Dynamic')) { | |
345 return mirrors.dynamicType; | 344 return mirrors.dynamicType; |
346 } else if (typeName == 'void') { | 345 } else if (typeName == 'void') { |
347 return mirrors.voidType; | 346 return mirrors.voidType; |
348 } else { | 347 } else { |
349 throw new UnimplementedError( | 348 throw new UnimplementedError( |
350 "Mirror for type '$typeName' is not implemented"); | 349 "Mirror for type '$typeName' is not implemented"); |
351 } | 350 } |
352 } | 351 } |
353 var resolved = mirrors.libraries[libraryName].members[typeName]; | 352 var resolved = mirrors.libraries[libraryName].members[typeName]; |
354 if (resolved == null) { | 353 if (resolved == null) { |
(...skipping 23 matching lines...) Expand all Loading... |
378 final String simpleName; | 377 final String simpleName; |
379 | 378 |
380 String _qualifiedName = null; | 379 String _qualifiedName = null; |
381 String get qualifiedName { | 380 String get qualifiedName { |
382 if (_owner != null) { | 381 if (_owner != null) { |
383 if (_qualifiedName == null) { | 382 if (_qualifiedName == null) { |
384 _qualifiedName = '${owner.qualifiedName}.${simpleName}'; | 383 _qualifiedName = '${owner.qualifiedName}.${simpleName}'; |
385 } | 384 } |
386 } else { | 385 } else { |
387 // The owner of a ClassMirror is null in certain odd cases, like | 386 // The owner of a ClassMirror is null in certain odd cases, like |
388 // 'void', 'Dynamic' and function type mirrors. | 387 // 'void', 'dynamic' and function type mirrors. |
389 _qualifiedName = simpleName; | 388 _qualifiedName = simpleName; |
390 } | 389 } |
391 return _qualifiedName; | 390 return _qualifiedName; |
392 } | 391 } |
393 | 392 |
394 var _owner; | 393 var _owner; |
395 DeclarationMirror get owner { | 394 DeclarationMirror get owner { |
396 if (_owner != null && _owner is! Mirror) { | 395 if (_owner != null && _owner is! Mirror) { |
397 _owner = _owner.resolve(mirrors); | 396 _owner = _owner.resolve(mirrors); |
398 } | 397 } |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
965 | 964 |
966 // Creates a new local InstanceMirror | 965 // Creates a new local InstanceMirror |
967 static InstanceMirror makeLocalInstanceMirror(Object reflectee) | 966 static InstanceMirror makeLocalInstanceMirror(Object reflectee) |
968 native 'Mirrors_makeLocalInstanceMirror'; | 967 native 'Mirrors_makeLocalInstanceMirror'; |
969 | 968 |
970 // Creates a new local mirror for some Object. | 969 // Creates a new local mirror for some Object. |
971 static InstanceMirror reflect(Object reflectee) { | 970 static InstanceMirror reflect(Object reflectee) { |
972 return makeLocalInstanceMirror(reflectee); | 971 return makeLocalInstanceMirror(reflectee); |
973 } | 972 } |
974 } | 973 } |
OLD | NEW |