| 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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 | 394 |
| 395 class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl | 395 class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl |
| 396 implements ClassMirror { | 396 implements ClassMirror { |
| 397 _LocalClassMirrorImpl(reflectee, | 397 _LocalClassMirrorImpl(reflectee, |
| 398 String simpleName, | 398 String simpleName, |
| 399 this.isClass, | 399 this.isClass, |
| 400 this._owner, | 400 this._owner, |
| 401 this._superclass, | 401 this._superclass, |
| 402 this._superinterfaces, | 402 this._superinterfaces, |
| 403 this._defaultFactory, | 403 this._defaultFactory, |
| 404 Map<String, Mirror> constructors, | |
| 405 Map<String, Mirror> typeVariables) | 404 Map<String, Mirror> typeVariables) |
| 406 : this._simpleName = _s(simpleName), | 405 : this._simpleName = _s(simpleName), |
| 407 this.constructors = _convertStringToSymbolMap(constructors), | |
| 408 this.typeVariables = _convertStringToSymbolMap(typeVariables), | 406 this.typeVariables = _convertStringToSymbolMap(typeVariables), |
| 409 super(reflectee); | 407 super(reflectee); |
| 410 | 408 |
| 411 Symbol _simpleName; | 409 Symbol _simpleName; |
| 412 Symbol get simpleName { | 410 Symbol get simpleName { |
| 413 // dynamic, void and the function types have their names set eagerly in the | 411 // dynamic, void and the function types have their names set eagerly in the |
| 414 // constructor. | 412 // constructor. |
| 415 if(_simpleName == null) { | 413 if(_simpleName == null) { |
| 416 _simpleName = _s(_name(_reflectee)); | 414 _simpleName = _s(_name(_reflectee)); |
| 417 } | 415 } |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 | 526 |
| 529 Map<Symbol, VariableMirror> get variables { | 527 Map<Symbol, VariableMirror> get variables { |
| 530 if (_variables == null) { | 528 if (_variables == null) { |
| 531 _variables = _filterMap( | 529 _variables = _filterMap( |
| 532 members, | 530 members, |
| 533 (key, value) => (value is VariableMirror)); | 531 (key, value) => (value is VariableMirror)); |
| 534 } | 532 } |
| 535 return _variables; | 533 return _variables; |
| 536 } | 534 } |
| 537 | 535 |
| 538 Map<Symbol, MethodMirror> constructors; | 536 Map<Symbol, MethodMirror> _constructors; |
| 537 |
| 538 Map<Symbol, MethodMirror> get constructors { |
| 539 if (_constructors == null) { |
| 540 _constructors = _makeMemberMap(_computeConstructors(_reflectee)); |
| 541 } |
| 542 return _constructors; |
| 543 } |
| 544 |
| 539 Map<Symbol, TypeVariableMirror> typeVariables; | 545 Map<Symbol, TypeVariableMirror> typeVariables; |
| 540 | 546 |
| 541 Map<Symbol, TypeMirror> get typeArguments { | 547 Map<Symbol, TypeMirror> get typeArguments { |
| 542 throw new UnimplementedError( | 548 throw new UnimplementedError( |
| 543 'ClassMirror.typeArguments is not implemented'); | 549 'ClassMirror.typeArguments is not implemented'); |
| 544 } | 550 } |
| 545 | 551 |
| 546 bool get isOriginalDeclaration { | 552 bool get isOriginalDeclaration { |
| 547 throw new UnimplementedError( | 553 throw new UnimplementedError( |
| 548 'ClassMirror.isOriginalDeclaration is not implemented'); | 554 'ClassMirror.isOriginalDeclaration is not implemented'); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 native "ClassMirror_name"; | 604 native "ClassMirror_name"; |
| 599 | 605 |
| 600 static _library(reflectee) | 606 static _library(reflectee) |
| 601 native "ClassMirror_library"; | 607 native "ClassMirror_library"; |
| 602 | 608 |
| 603 static _supertype(reflectee) | 609 static _supertype(reflectee) |
| 604 native "ClassMirror_supertype"; | 610 native "ClassMirror_supertype"; |
| 605 | 611 |
| 606 _computeMembers(reflectee) | 612 _computeMembers(reflectee) |
| 607 native "ClassMirror_members"; | 613 native "ClassMirror_members"; |
| 614 |
| 615 _computeConstructors(reflectee) |
| 616 native "ClassMirror_constructors"; |
| 608 | 617 |
| 609 _invoke(reflectee, memberName, positionalArguments) | 618 _invoke(reflectee, memberName, positionalArguments) |
| 610 native 'ClassMirror_invoke'; | 619 native 'ClassMirror_invoke'; |
| 611 | 620 |
| 612 _invokeGetter(reflectee, getterName) | 621 _invokeGetter(reflectee, getterName) |
| 613 native 'ClassMirror_invokeGetter'; | 622 native 'ClassMirror_invokeGetter'; |
| 614 | 623 |
| 615 _invokeSetter(reflectee, setterName, value) | 624 _invokeSetter(reflectee, setterName, value) |
| 616 native 'ClassMirror_invokeSetter'; | 625 native 'ClassMirror_invokeSetter'; |
| 617 | 626 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 637 simpleName, | 646 simpleName, |
| 638 this._returnType, | 647 this._returnType, |
| 639 this.parameters) | 648 this.parameters) |
| 640 : super(reflectee, | 649 : super(reflectee, |
| 641 simpleName, | 650 simpleName, |
| 642 true, | 651 true, |
| 643 null, | 652 null, |
| 644 new _LazyTypeMirror('dart:core', 'Object'), | 653 new _LazyTypeMirror('dart:core', 'Object'), |
| 645 [ new _LazyTypeMirror('dart:core', 'Function') ], | 654 [ new _LazyTypeMirror('dart:core', 'Function') ], |
| 646 null, | 655 null, |
| 647 const {}, | |
| 648 const {}); | 656 const {}); |
| 649 | 657 |
| 650 Map<Symbol, Mirror> get members => new Map<Symbol,Mirror>(); | 658 Map<Symbol, Mirror> get members => new Map<Symbol,Mirror>(); |
| 659 Map<Symbol, MethodMirror> get constructors => new Map<Symbol,MethodMirror>(); |
| 651 | 660 |
| 652 var _returnType; | 661 var _returnType; |
| 653 TypeMirror get returnType { | 662 TypeMirror get returnType { |
| 654 if (_returnType is! Mirror) { | 663 if (_returnType is! Mirror) { |
| 655 _returnType = _returnType.resolve(mirrors); | 664 _returnType = _returnType.resolve(mirrors); |
| 656 } | 665 } |
| 657 return _returnType; | 666 return _returnType; |
| 658 } | 667 } |
| 659 | 668 |
| 660 final List<ParameterMirror> parameters; | 669 final List<ParameterMirror> parameters; |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1224 static Expando<ClassMirror> _classMirrorCache = new Expando("ClassMirror"); | 1233 static Expando<ClassMirror> _classMirrorCache = new Expando("ClassMirror"); |
| 1225 static ClassMirror reflectClass(Type key) { | 1234 static ClassMirror reflectClass(Type key) { |
| 1226 var classMirror = _classMirrorCache[key]; | 1235 var classMirror = _classMirrorCache[key]; |
| 1227 if (classMirror == null) { | 1236 if (classMirror == null) { |
| 1228 classMirror = makeLocalClassMirror(key); | 1237 classMirror = makeLocalClassMirror(key); |
| 1229 _classMirrorCache[key] = classMirror; | 1238 _classMirrorCache[key] = classMirror; |
| 1230 } | 1239 } |
| 1231 return classMirror; | 1240 return classMirror; |
| 1232 } | 1241 } |
| 1233 } | 1242 } |
| OLD | NEW |