| 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 library mirrors_dart2js; | 5 library mirrors_dart2js; |
| 6 | 6 |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 import 'dart:uri'; | 8 import 'dart:uri'; |
| 9 | 9 |
| 10 import '../../../../../lib/compiler/compiler.dart' as diagnostics; | 10 import '../../../../../lib/compiler/compiler.dart' as diagnostics; |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 Future<String> compileToJavaScript() => | 375 Future<String> compileToJavaScript() => |
| 376 new Future<String>.immediate(_compiler.assembledCode); | 376 new Future<String>.immediate(_compiler.assembledCode); |
| 377 } | 377 } |
| 378 | 378 |
| 379 | 379 |
| 380 //------------------------------------------------------------------------------ | 380 //------------------------------------------------------------------------------ |
| 381 // Dart2Js specific extensions of mirror interfaces | 381 // Dart2Js specific extensions of mirror interfaces |
| 382 //------------------------------------------------------------------------------ | 382 //------------------------------------------------------------------------------ |
| 383 | 383 |
| 384 abstract class Dart2JsMirror implements Mirror { | 384 abstract class Dart2JsMirror implements Mirror { |
| 385 Dart2JsMirrorSystem get system; | 385 Dart2JsMirrorSystem get mirrors; |
| 386 } | 386 } |
| 387 | 387 |
| 388 abstract class Dart2JsDeclarationMirror | 388 abstract class Dart2JsDeclarationMirror |
| 389 implements Dart2JsMirror, DeclarationMirror { | 389 implements Dart2JsMirror, DeclarationMirror { |
| 390 | 390 |
| 391 bool get isTopLevel => owner != null && owner is LibraryMirror; | 391 bool get isTopLevel => owner != null && owner is LibraryMirror; |
| 392 | 392 |
| 393 bool get isPrivate => _isPrivate(simpleName); | 393 bool get isPrivate => _isPrivate(simpleName); |
| 394 } | 394 } |
| 395 | 395 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 407 | 407 |
| 408 bool get isStatic => false; | 408 bool get isStatic => false; |
| 409 } | 409 } |
| 410 | 410 |
| 411 abstract class Dart2JsTypeMirror extends Dart2JsDeclarationMirror | 411 abstract class Dart2JsTypeMirror extends Dart2JsDeclarationMirror |
| 412 implements TypeMirror { | 412 implements TypeMirror { |
| 413 | 413 |
| 414 } | 414 } |
| 415 | 415 |
| 416 abstract class Dart2JsElementMirror extends Dart2JsDeclarationMirror { | 416 abstract class Dart2JsElementMirror extends Dart2JsDeclarationMirror { |
| 417 final Dart2JsMirrorSystem system; | 417 final Dart2JsMirrorSystem mirrors; |
| 418 final Element _element; | 418 final Element _element; |
| 419 | 419 |
| 420 Dart2JsElementMirror(this.system, this._element) { | 420 Dart2JsElementMirror(this.mirrors, this._element) { |
| 421 assert (system !== null); | 421 assert (mirrors !== null); |
| 422 assert (_element !== null); | 422 assert (_element !== null); |
| 423 } | 423 } |
| 424 | 424 |
| 425 String get simpleName => _element.name.slowToString(); | 425 String get simpleName => _element.name.slowToString(); |
| 426 | 426 |
| 427 String get displayName => simpleName; | 427 String get displayName => simpleName; |
| 428 | 428 |
| 429 SourceLocation get location => new Dart2JsLocation( | 429 SourceLocation get location => new Dart2JsLocation( |
| 430 _element.getCompilationUnit().script, | 430 _element.getCompilationUnit().script, |
| 431 system.compiler.spanFromElement(_element)); | 431 mirrors.compiler.spanFromElement(_element)); |
| 432 | 432 |
| 433 String toString() => _element.toString(); | 433 String toString() => _element.toString(); |
| 434 | 434 |
| 435 int get hashCode => qualifiedName.hashCode; | 435 int get hashCode => qualifiedName.hashCode; |
| 436 } | 436 } |
| 437 | 437 |
| 438 abstract class Dart2JsProxyMirror extends Dart2JsDeclarationMirror { | 438 abstract class Dart2JsProxyMirror extends Dart2JsDeclarationMirror { |
| 439 final Dart2JsMirrorSystem system; | 439 final Dart2JsMirrorSystem mirrors; |
| 440 | 440 |
| 441 Dart2JsProxyMirror(this.system); | 441 Dart2JsProxyMirror(this.mirrors); |
| 442 | 442 |
| 443 String get displayName => simpleName; | 443 String get displayName => simpleName; |
| 444 | 444 |
| 445 int get hashCode => qualifiedName.hashCode; | 445 int get hashCode => qualifiedName.hashCode; |
| 446 } | 446 } |
| 447 | 447 |
| 448 //------------------------------------------------------------------------------ | 448 //------------------------------------------------------------------------------ |
| 449 // Mirror system implementation. | 449 // Mirror system implementation. |
| 450 //------------------------------------------------------------------------------ | 450 //------------------------------------------------------------------------------ |
| 451 | 451 |
| 452 class Dart2JsMirrorSystem implements MirrorSystem, Dart2JsMirror { | 452 class Dart2JsMirrorSystem implements MirrorSystem, Dart2JsMirror { |
| 453 final api.Compiler compiler; | 453 final api.Compiler compiler; |
| 454 Map<String, Dart2JsLibraryMirror> _libraries; | 454 Map<String, Dart2JsLibraryMirror> _libraries; |
| 455 Map<LibraryElement, Dart2JsLibraryMirror> _libraryMap; | 455 Map<LibraryElement, Dart2JsLibraryMirror> _libraryMap; |
| 456 | 456 |
| 457 Dart2JsMirrorSystem(this.compiler) | 457 Dart2JsMirrorSystem(this.compiler) |
| 458 : _libraryMap = new Map<LibraryElement, Dart2JsLibraryMirror>(); | 458 : _libraryMap = new Map<LibraryElement, Dart2JsLibraryMirror>(); |
| 459 | 459 |
| 460 void _ensureLibraries() { | 460 void _ensureLibraries() { |
| 461 if (_libraries == null) { | 461 if (_libraries == null) { |
| 462 _libraries = <String, Dart2JsLibraryMirror>{}; | 462 _libraries = <String, Dart2JsLibraryMirror>{}; |
| 463 compiler.libraries.forEach((_, LibraryElement v) { | 463 compiler.libraries.forEach((_, LibraryElement v) { |
| 464 var mirror = new Dart2JsLibraryMirror(system, v); | 464 var mirror = new Dart2JsLibraryMirror(mirrors, v); |
| 465 _libraries[mirror.simpleName] = mirror; | 465 _libraries[mirror.simpleName] = mirror; |
| 466 _libraryMap[v] = mirror; | 466 _libraryMap[v] = mirror; |
| 467 }); | 467 }); |
| 468 } | 468 } |
| 469 } | 469 } |
| 470 | 470 |
| 471 Map<String, LibraryMirror> get libraries { | 471 Map<String, LibraryMirror> get libraries { |
| 472 _ensureLibraries(); | 472 _ensureLibraries(); |
| 473 return new ImmutableMapWrapper<String, LibraryMirror>(_libraries); | 473 return new ImmutableMapWrapper<String, LibraryMirror>(_libraries); |
| 474 } | 474 } |
| 475 | 475 |
| 476 Dart2JsLibraryMirror getLibrary(LibraryElement element) { | 476 Dart2JsLibraryMirror _getLibrary(LibraryElement element) => |
| 477 return _libraryMap[element]; | 477 _libraryMap[element]; |
| 478 } | |
| 479 | 478 |
| 480 Dart2JsMirrorSystem get system => this; | 479 Dart2JsMirrorSystem get mirrors => this; |
| 481 | 480 |
| 482 String get simpleName => "mirror"; | 481 TypeMirror get dynamicType => |
| 483 String get displayName => simpleName; | 482 _convertTypeToTypeMirror(this, compiler.types.dynamicType, null); |
| 484 String get qualifiedName => simpleName; | |
| 485 | 483 |
| 486 // TODO(johnniwinther): Hack! Dart2JsMirrorSystem need not be a Mirror. | 484 TypeMirror get voidType => |
| 487 int get hashCode => qualifiedName.hashCode; | 485 _convertTypeToTypeMirror(this, compiler.types.voidType, null); |
| 488 } | 486 } |
| 489 | 487 |
| 490 abstract class Dart2JsContainerMirror extends Dart2JsElementMirror | 488 abstract class Dart2JsContainerMirror extends Dart2JsElementMirror |
| 491 implements ContainerMirror { | 489 implements ContainerMirror { |
| 492 Map<String, MemberMirror> _members; | 490 Map<String, MemberMirror> _members; |
| 493 | 491 |
| 494 Dart2JsContainerMirror(Dart2JsMirrorSystem system, Element element) | 492 Dart2JsContainerMirror(Dart2JsMirrorSystem system, Element element) |
| 495 : super(system, element); | 493 : super(system, element); |
| 496 | 494 |
| 497 abstract void _ensureMembers(); | 495 abstract void _ensureMembers(); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 } | 569 } |
| 572 | 570 |
| 573 String get qualifiedName => simpleName; | 571 String get qualifiedName => simpleName; |
| 574 | 572 |
| 575 void _ensureClasses() { | 573 void _ensureClasses() { |
| 576 if (_classes == null) { | 574 if (_classes == null) { |
| 577 _classes = <String, ClassMirror>{}; | 575 _classes = <String, ClassMirror>{}; |
| 578 _library.forEachLocalMember((Element e) { | 576 _library.forEachLocalMember((Element e) { |
| 579 if (e.isClass()) { | 577 if (e.isClass()) { |
| 580 ClassElement classElement = e; | 578 ClassElement classElement = e; |
| 581 classElement.ensureResolved(system.compiler); | 579 classElement.ensureResolved(mirrors.compiler); |
| 582 var type = new Dart2JsClassMirror.fromLibrary(this, classElement); | 580 var type = new Dart2JsClassMirror.fromLibrary(this, classElement); |
| 583 assert(invariant(_library, !_classes.containsKey(type.simpleName), | 581 assert(invariant(_library, !_classes.containsKey(type.simpleName), |
| 584 message: "Type name '${type.simpleName}' " | 582 message: "Type name '${type.simpleName}' " |
| 585 "is not unique in $_library.")); | 583 "is not unique in $_library.")); |
| 586 _classes[type.simpleName] = type; | 584 _classes[type.simpleName] = type; |
| 587 } else if (e.isTypedef()) { | 585 } else if (e.isTypedef()) { |
| 588 var type = new Dart2JsTypedefMirror.fromLibrary(this, | 586 var type = new Dart2JsTypedefMirror.fromLibrary(this, |
| 589 e.computeType(system.compiler)); | 587 e.computeType(mirrors.compiler)); |
| 590 assert(invariant(_library, !_classes.containsKey(type.simpleName), | 588 assert(invariant(_library, !_classes.containsKey(type.simpleName), |
| 591 message: "Type name '${type.simpleName}' " | 589 message: "Type name '${type.simpleName}' " |
| 592 "is not unique in $_library.")); | 590 "is not unique in $_library.")); |
| 593 _classes[type.simpleName] = type; | 591 _classes[type.simpleName] = type; |
| 594 } | 592 } |
| 595 }); | 593 }); |
| 596 } | 594 } |
| 597 } | 595 } |
| 598 | 596 |
| 599 void _ensureMembers() { | 597 void _ensureMembers() { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 this.isOptional, | 671 this.isOptional, |
| 674 this.isNamed) | 672 this.isNamed) |
| 675 : super(system, element); | 673 : super(system, element); |
| 676 | 674 |
| 677 DeclarationMirror get owner => _method; | 675 DeclarationMirror get owner => _method; |
| 678 | 676 |
| 679 VariableElement get _variableElement => _element; | 677 VariableElement get _variableElement => _element; |
| 680 | 678 |
| 681 String get qualifiedName => '${_method.qualifiedName}#${simpleName}'; | 679 String get qualifiedName => '${_method.qualifiedName}#${simpleName}'; |
| 682 | 680 |
| 683 TypeMirror get type => _convertTypeToTypeMirror(system, | 681 TypeMirror get type => _convertTypeToTypeMirror(mirrors, |
| 684 _variableElement.computeType(system.compiler), | 682 _variableElement.computeType(mirrors.compiler), |
| 685 system.compiler.types.dynamicType, | 683 mirrors.compiler.types.dynamicType, |
| 686 _variableElement.variables.functionSignature); | 684 _variableElement.variables.functionSignature); |
| 687 | 685 |
| 688 | 686 |
| 689 bool get isFinal => false; | 687 bool get isFinal => false; |
| 690 | 688 |
| 691 bool get isConst => false; | 689 bool get isConst => false; |
| 692 | 690 |
| 693 String get defaultValue { | 691 String get defaultValue { |
| 694 if (hasDefaultValue) { | 692 if (hasDefaultValue) { |
| 695 SendSet expression = _variableElement.cachedNode.asSendSet(); | 693 SendSet expression = _variableElement.cachedNode.asSendSet(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 716 bool isOptional, | 714 bool isOptional, |
| 717 bool isNamed) | 715 bool isNamed) |
| 718 : super._normal(system, method, element, isOptional, isNamed); | 716 : super._normal(system, method, element, isOptional, isNamed); |
| 719 | 717 |
| 720 FieldParameterElement get _fieldParameterElement => _element; | 718 FieldParameterElement get _fieldParameterElement => _element; |
| 721 | 719 |
| 722 TypeMirror get type { | 720 TypeMirror get type { |
| 723 if (_fieldParameterElement.variables.cachedNode.type !== null) { | 721 if (_fieldParameterElement.variables.cachedNode.type !== null) { |
| 724 return super.type; | 722 return super.type; |
| 725 } | 723 } |
| 726 return _convertTypeToTypeMirror(system, | 724 return _convertTypeToTypeMirror(mirrors, |
| 727 _fieldParameterElement.fieldElement.computeType(system.compiler), | 725 _fieldParameterElement.fieldElement.computeType(mirrors.compiler), |
| 728 system.compiler.types.dynamicType, | 726 mirrors.compiler.types.dynamicType, |
| 729 _variableElement.variables.functionSignature); | 727 _variableElement.variables.functionSignature); |
| 730 } | 728 } |
| 731 | 729 |
| 732 bool get isInitializingFormal => true; | 730 bool get isInitializingFormal => true; |
| 733 | 731 |
| 734 VariableMirror get initializedField => new Dart2JsFieldMirror( | 732 VariableMirror get initializedField => new Dart2JsFieldMirror( |
| 735 _method.owner, _fieldParameterElement.fieldElement); | 733 _method.owner, _fieldParameterElement.fieldElement); |
| 736 } | 734 } |
| 737 | 735 |
| 738 //------------------------------------------------------------------------------ | 736 //------------------------------------------------------------------------------ |
| 739 // Declarations | 737 // Declarations |
| 740 //------------------------------------------------------------------------------ | 738 //------------------------------------------------------------------------------ |
| 741 class Dart2JsClassMirror extends Dart2JsContainerMirror | 739 class Dart2JsClassMirror extends Dart2JsContainerMirror |
| 742 implements Dart2JsTypeMirror, ClassMirror { | 740 implements Dart2JsTypeMirror, ClassMirror { |
| 743 final Dart2JsLibraryMirror library; | 741 final Dart2JsLibraryMirror library; |
| 744 List<TypeVariableMirror> _typeVariables; | 742 List<TypeVariableMirror> _typeVariables; |
| 745 | 743 |
| 746 Dart2JsClassMirror(Dart2JsMirrorSystem system, ClassElement _class) | 744 Dart2JsClassMirror(Dart2JsMirrorSystem system, ClassElement _class) |
| 747 : this.library = system.getLibrary(_class.getLibrary()), | 745 : this.library = system._getLibrary(_class.getLibrary()), |
| 748 super(system, _class); | 746 super(system, _class); |
| 749 | 747 |
| 750 ClassElement get _class => _element; | 748 ClassElement get _class => _element; |
| 751 | 749 |
| 752 Dart2JsClassMirror.fromLibrary(Dart2JsLibraryMirror library, | 750 Dart2JsClassMirror.fromLibrary(Dart2JsLibraryMirror library, |
| 753 ClassElement _class) | 751 ClassElement _class) |
| 754 : this.library = library, | 752 : this.library = library, |
| 755 super(library.system, _class); | 753 super(library.mirrors, _class); |
| 756 | 754 |
| 757 DeclarationMirror get owner => library; | 755 DeclarationMirror get owner => library; |
| 758 | 756 |
| 759 String get qualifiedName => '${library.qualifiedName}.${simpleName}'; | 757 String get qualifiedName => '${library.qualifiedName}.${simpleName}'; |
| 760 | 758 |
| 761 SourceLocation get location { | 759 SourceLocation get location { |
| 762 if (_class is PartialClassElement) { | 760 if (_class is PartialClassElement) { |
| 763 var node = _class.parseNode(system.compiler); | 761 var node = _class.parseNode(mirrors.compiler); |
| 764 if (node !== null) { | 762 if (node !== null) { |
| 765 var script = _class.getCompilationUnit().script; | 763 var script = _class.getCompilationUnit().script; |
| 766 var span = system.compiler.spanFromNode(node, script.uri); | 764 var span = mirrors.compiler.spanFromNode(node, script.uri); |
| 767 return new Dart2JsLocation(script, span); | 765 return new Dart2JsLocation(script, span); |
| 768 } | 766 } |
| 769 } | 767 } |
| 770 return super.location; | 768 return super.location; |
| 771 } | 769 } |
| 772 | 770 |
| 773 void _ensureMembers() { | 771 void _ensureMembers() { |
| 774 if (_members == null) { | 772 if (_members == null) { |
| 775 _members = <String, Dart2JsMemberMirror>{}; | 773 _members = <String, Dart2JsMemberMirror>{}; |
| 776 _class.forEachMember((_, e) { | 774 _class.forEachMember((_, e) { |
| 777 for (var member in _convertElementMemberToMemberMirrors(this, e)) { | 775 for (var member in _convertElementMemberToMemberMirrors(this, e)) { |
| 778 assert(!_members.containsKey(member.simpleName)); | 776 assert(!_members.containsKey(member.simpleName)); |
| 779 _members[member.simpleName] = member; | 777 _members[member.simpleName] = member; |
| 780 } | 778 } |
| 781 }); | 779 }); |
| 782 } | 780 } |
| 783 } | 781 } |
| 784 | 782 |
| 785 Map<String, MethodMirror> get methods => functions; | 783 Map<String, MethodMirror> get methods => functions; |
| 786 | 784 |
| 787 Map<String, MethodMirror> get constructors { | 785 Map<String, MethodMirror> get constructors { |
| 788 _ensureMembers(); | 786 _ensureMembers(); |
| 789 return new AsFilteredImmutableMap<String, MemberMirror, MethodMirror>( | 787 return new AsFilteredImmutableMap<String, MemberMirror, MethodMirror>( |
| 790 _members, (m) => m.isConstructor ? m : null); | 788 _members, (m) => m.isConstructor ? m : null); |
| 791 } | 789 } |
| 792 | 790 |
| 793 bool get isObject => _class == system.compiler.objectClass; | 791 bool get isObject => _class == mirrors.compiler.objectClass; |
| 794 | 792 |
| 795 bool get isDynamic => false; | 793 bool get isDynamic => false; |
| 796 | 794 |
| 797 bool get isVoid => false; | 795 bool get isVoid => false; |
| 798 | 796 |
| 799 bool get isTypeVariable => false; | 797 bool get isTypeVariable => false; |
| 800 | 798 |
| 801 bool get isTypedef => false; | 799 bool get isTypedef => false; |
| 802 | 800 |
| 803 bool get isFunction => false; | 801 bool get isFunction => false; |
| 804 | 802 |
| 805 ClassMirror get originalDeclaration => this; | 803 ClassMirror get originalDeclaration => this; |
| 806 | 804 |
| 807 ClassMirror get superclass { | 805 ClassMirror get superclass { |
| 808 if (_class.supertype != null) { | 806 if (_class.supertype != null) { |
| 809 return new Dart2JsInterfaceTypeMirror(system, _class.supertype); | 807 return new Dart2JsInterfaceTypeMirror(mirrors, _class.supertype); |
| 810 } | 808 } |
| 811 return null; | 809 return null; |
| 812 } | 810 } |
| 813 | 811 |
| 814 List<ClassMirror> get superinterfaces { | 812 List<ClassMirror> get superinterfaces { |
| 815 var list = <ClassMirror>[]; | 813 var list = <ClassMirror>[]; |
| 816 Link<DartType> link = _class.interfaces; | 814 Link<DartType> link = _class.interfaces; |
| 817 while (!link.isEmpty) { | 815 while (!link.isEmpty) { |
| 818 var type = _convertTypeToTypeMirror(system, link.head, | 816 var type = _convertTypeToTypeMirror(mirrors, link.head, |
| 819 system.compiler.types.dynamicType); | 817 mirrors.compiler.types.dynamicType); |
| 820 list.add(type); | 818 list.add(type); |
| 821 link = link.tail; | 819 link = link.tail; |
| 822 } | 820 } |
| 823 return list; | 821 return list; |
| 824 } | 822 } |
| 825 | 823 |
| 826 bool get isClass => !_class.isInterface(); | 824 bool get isClass => !_class.isInterface(); |
| 827 | 825 |
| 828 bool get isInterface => _class.isInterface(); | 826 bool get isInterface => _class.isInterface(); |
| 829 | 827 |
| 830 bool get isAbstract => _class.modifiers.isAbstract(); | 828 bool get isAbstract => _class.modifiers.isAbstract(); |
| 831 | 829 |
| 832 bool get isOriginalDeclaration => true; | 830 bool get isOriginalDeclaration => true; |
| 833 | 831 |
| 834 List<TypeMirror> get typeArguments { | 832 List<TypeMirror> get typeArguments { |
| 835 throw new UnsupportedError( | 833 throw new UnsupportedError( |
| 836 'Declarations do not have type arguments'); | 834 'Declarations do not have type arguments'); |
| 837 } | 835 } |
| 838 | 836 |
| 839 List<TypeVariableMirror> get typeVariables { | 837 List<TypeVariableMirror> get typeVariables { |
| 840 if (_typeVariables == null) { | 838 if (_typeVariables == null) { |
| 841 _typeVariables = <TypeVariableMirror>[]; | 839 _typeVariables = <TypeVariableMirror>[]; |
| 842 _class.ensureResolved(system.compiler); | 840 _class.ensureResolved(mirrors.compiler); |
| 843 for (TypeVariableType typeVariable in _class.typeVariables) { | 841 for (TypeVariableType typeVariable in _class.typeVariables) { |
| 844 _typeVariables.add( | 842 _typeVariables.add( |
| 845 new Dart2JsTypeVariableMirror(system, typeVariable)); | 843 new Dart2JsTypeVariableMirror(mirrors, typeVariable)); |
| 846 } | 844 } |
| 847 } | 845 } |
| 848 return _typeVariables; | 846 return _typeVariables; |
| 849 } | 847 } |
| 850 | 848 |
| 851 /** | 849 /** |
| 852 * Returns the default type for this interface. | 850 * Returns the default type for this interface. |
| 853 */ | 851 */ |
| 854 ClassMirror get defaultFactory { | 852 ClassMirror get defaultFactory { |
| 855 if (_class.defaultClass != null) { | 853 if (_class.defaultClass != null) { |
| 856 return new Dart2JsInterfaceTypeMirror(system, _class.defaultClass); | 854 return new Dart2JsInterfaceTypeMirror(mirrors, _class.defaultClass); |
| 857 } | 855 } |
| 858 return null; | 856 return null; |
| 859 } | 857 } |
| 860 | 858 |
| 861 bool operator ==(Object other) { | 859 bool operator ==(Object other) { |
| 862 if (this === other) { | 860 if (this === other) { |
| 863 return true; | 861 return true; |
| 864 } | 862 } |
| 865 if (other is! ClassMirror) { | 863 if (other is! ClassMirror) { |
| 866 return false; | 864 return false; |
| 867 } | 865 } |
| 868 if (library != other.library) { | 866 if (library != other.library) { |
| 869 return false; | 867 return false; |
| 870 } | 868 } |
| 871 if (isOriginalDeclaration !== other.isOriginalDeclaration) { | 869 if (isOriginalDeclaration !== other.isOriginalDeclaration) { |
| 872 return false; | 870 return false; |
| 873 } | 871 } |
| 874 return qualifiedName == other.qualifiedName; | 872 return qualifiedName == other.qualifiedName; |
| 875 } | 873 } |
| 876 } | 874 } |
| 877 | 875 |
| 878 class Dart2JsTypedefMirror extends Dart2JsTypeElementMirror | 876 class Dart2JsTypedefMirror extends Dart2JsTypeElementMirror |
| 879 implements Dart2JsTypeMirror, TypedefMirror { | 877 implements Dart2JsTypeMirror, TypedefMirror { |
| 880 final Dart2JsLibraryMirror _library; | 878 final Dart2JsLibraryMirror _library; |
| 881 List<TypeVariableMirror> _typeVariables; | 879 List<TypeVariableMirror> _typeVariables; |
| 882 TypeMirror _definition; | 880 TypeMirror _definition; |
| 883 | 881 |
| 884 Dart2JsTypedefMirror(Dart2JsMirrorSystem system, TypedefType _typedef) | 882 Dart2JsTypedefMirror(Dart2JsMirrorSystem system, TypedefType _typedef) |
| 885 : this._library = system.getLibrary(_typedef.element.getLibrary()), | 883 : this._library = system._getLibrary(_typedef.element.getLibrary()), |
| 886 super(system, _typedef); | 884 super(system, _typedef); |
| 887 | 885 |
| 888 Dart2JsTypedefMirror.fromLibrary(Dart2JsLibraryMirror library, | 886 Dart2JsTypedefMirror.fromLibrary(Dart2JsLibraryMirror library, |
| 889 TypedefType _typedef) | 887 TypedefType _typedef) |
| 890 : this._library = library, | 888 : this._library = library, |
| 891 super(library.system, _typedef); | 889 super(library.mirrors, _typedef); |
| 892 | 890 |
| 893 TypedefType get _typedef => _type; | 891 TypedefType get _typedef => _type; |
| 894 | 892 |
| 895 String get qualifiedName => '${library.qualifiedName}.${simpleName}'; | 893 String get qualifiedName => '${library.qualifiedName}.${simpleName}'; |
| 896 | 894 |
| 897 SourceLocation get location { | 895 SourceLocation get location { |
| 898 var node = _typedef.element.parseNode(_diagnosticListener); | 896 var node = _typedef.element.parseNode(_diagnosticListener); |
| 899 if (node !== null) { | 897 if (node !== null) { |
| 900 var script = _typedef.element.getCompilationUnit().script; | 898 var script = _typedef.element.getCompilationUnit().script; |
| 901 var span = system.compiler.spanFromNode(node, script.uri); | 899 var span = mirrors.compiler.spanFromNode(node, script.uri); |
| 902 return new Dart2JsLocation(script, span); | 900 return new Dart2JsLocation(script, span); |
| 903 } | 901 } |
| 904 return super.location; | 902 return super.location; |
| 905 } | 903 } |
| 906 | 904 |
| 907 LibraryMirror get library => _library; | 905 LibraryMirror get library => _library; |
| 908 | 906 |
| 909 bool get isTypedef => true; | 907 bool get isTypedef => true; |
| 910 | 908 |
| 911 List<TypeMirror> get typeArguments { | 909 List<TypeMirror> get typeArguments { |
| 912 throw new UnsupportedError( | 910 throw new UnsupportedError( |
| 913 'Declarations do not have type arguments'); | 911 'Declarations do not have type arguments'); |
| 914 } | 912 } |
| 915 | 913 |
| 916 List<TypeVariableMirror> get typeVariables { | 914 List<TypeVariableMirror> get typeVariables { |
| 917 if (_typeVariables == null) { | 915 if (_typeVariables == null) { |
| 918 _typeVariables = <TypeVariableMirror>[]; | 916 _typeVariables = <TypeVariableMirror>[]; |
| 919 for (TypeVariableType typeVariable in _typedef.typeArguments) { | 917 for (TypeVariableType typeVariable in _typedef.typeArguments) { |
| 920 _typeVariables.add( | 918 _typeVariables.add( |
| 921 new Dart2JsTypeVariableMirror(system, typeVariable)); | 919 new Dart2JsTypeVariableMirror(mirrors, typeVariable)); |
| 922 } | 920 } |
| 923 } | 921 } |
| 924 return _typeVariables; | 922 return _typeVariables; |
| 925 } | 923 } |
| 926 | 924 |
| 927 TypeMirror get value { | 925 TypeMirror get value { |
| 928 if (_definition === null) { | 926 if (_definition === null) { |
| 929 // TODO(johnniwinther): Should be [ensureResolved]. | 927 // TODO(johnniwinther): Should be [ensureResolved]. |
| 930 system.compiler.resolveTypedef(_typedef.element); | 928 mirrors.compiler.resolveTypedef(_typedef.element); |
| 931 _definition = _convertTypeToTypeMirror( | 929 _definition = _convertTypeToTypeMirror( |
| 932 system, | 930 mirrors, |
| 933 _typedef.element.alias, | 931 _typedef.element.alias, |
| 934 system.compiler.types.dynamicType, | 932 mirrors.compiler.types.dynamicType, |
| 935 _typedef.element.functionSignature); | 933 _typedef.element.functionSignature); |
| 936 } | 934 } |
| 937 return _definition; | 935 return _definition; |
| 938 } | 936 } |
| 939 | 937 |
| 940 ClassMirror get originalDeclaration => this; | 938 ClassMirror get originalDeclaration => this; |
| 941 | 939 |
| 942 // TODO(johnniwinther): How should a typedef respond to these? | 940 // TODO(johnniwinther): How should a typedef respond to these? |
| 943 ClassMirror get superclass => null; | 941 ClassMirror get superclass => null; |
| 944 | 942 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 964 super(system, typeVariableType) { | 962 super(system, typeVariableType) { |
| 965 assert(_typeVariableType !== null); | 963 assert(_typeVariableType !== null); |
| 966 } | 964 } |
| 967 | 965 |
| 968 | 966 |
| 969 String get qualifiedName => '${declarer.qualifiedName}.${simpleName}'; | 967 String get qualifiedName => '${declarer.qualifiedName}.${simpleName}'; |
| 970 | 968 |
| 971 ClassMirror get declarer { | 969 ClassMirror get declarer { |
| 972 if (_declarer === null) { | 970 if (_declarer === null) { |
| 973 if (_typeVariableType.element.enclosingElement.isClass()) { | 971 if (_typeVariableType.element.enclosingElement.isClass()) { |
| 974 _declarer = new Dart2JsClassMirror(system, | 972 _declarer = new Dart2JsClassMirror(mirrors, |
| 975 _typeVariableType.element.enclosingElement); | 973 _typeVariableType.element.enclosingElement); |
| 976 } else if (_typeVariableType.element.enclosingElement.isTypedef()) { | 974 } else if (_typeVariableType.element.enclosingElement.isTypedef()) { |
| 977 _declarer = new Dart2JsTypedefMirror(system, | 975 _declarer = new Dart2JsTypedefMirror(mirrors, |
| 978 _typeVariableType.element.enclosingElement.computeType( | 976 _typeVariableType.element.enclosingElement.computeType( |
| 979 system.compiler)); | 977 mirrors.compiler)); |
| 980 } | 978 } |
| 981 } | 979 } |
| 982 return _declarer; | 980 return _declarer; |
| 983 } | 981 } |
| 984 | 982 |
| 985 LibraryMirror get library => declarer.library; | 983 LibraryMirror get library => declarer.library; |
| 986 | 984 |
| 987 DeclarationMirror get owner => declarer; | 985 DeclarationMirror get owner => declarer; |
| 988 | 986 |
| 989 bool get isTypeVariable => true; | 987 bool get isTypeVariable => true; |
| 990 | 988 |
| 991 TypeMirror get upperBound => _convertTypeToTypeMirror( | 989 TypeMirror get upperBound => _convertTypeToTypeMirror( |
| 992 system, | 990 mirrors, |
| 993 _typeVariableType.element.bound, | 991 _typeVariableType.element.bound, |
| 994 system.compiler.objectClass.computeType(system.compiler)); | 992 mirrors.compiler.objectClass.computeType(mirrors.compiler)); |
| 995 | 993 |
| 996 bool operator ==(Object other) { | 994 bool operator ==(Object other) { |
| 997 if (this === other) { | 995 if (this === other) { |
| 998 return true; | 996 return true; |
| 999 } | 997 } |
| 1000 if (other is! TypeVariableMirror) { | 998 if (other is! TypeVariableMirror) { |
| 1001 return false; | 999 return false; |
| 1002 } | 1000 } |
| 1003 if (declarer != other.declarer) { | 1001 if (declarer != other.declarer) { |
| 1004 return false; | 1002 return false; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1017 final DartType _type; | 1015 final DartType _type; |
| 1018 | 1016 |
| 1019 Dart2JsTypeElementMirror(Dart2JsMirrorSystem system, this._type) | 1017 Dart2JsTypeElementMirror(Dart2JsMirrorSystem system, this._type) |
| 1020 : super(system); | 1018 : super(system); |
| 1021 | 1019 |
| 1022 String get simpleName => _type.name.slowToString(); | 1020 String get simpleName => _type.name.slowToString(); |
| 1023 | 1021 |
| 1024 SourceLocation get location { | 1022 SourceLocation get location { |
| 1025 var script = _type.element.getCompilationUnit().script; | 1023 var script = _type.element.getCompilationUnit().script; |
| 1026 return new Dart2JsLocation(script, | 1024 return new Dart2JsLocation(script, |
| 1027 system.compiler.spanFromElement(_type.element)); | 1025 mirrors.compiler.spanFromElement(_type.element)); |
| 1028 } | 1026 } |
| 1029 | 1027 |
| 1030 DeclarationMirror get owner => library; | 1028 DeclarationMirror get owner => library; |
| 1031 | 1029 |
| 1032 LibraryMirror get library { | 1030 LibraryMirror get library { |
| 1033 return system.getLibrary(_type.element.getLibrary()); | 1031 return mirrors._getLibrary(_type.element.getLibrary()); |
| 1034 } | 1032 } |
| 1035 | 1033 |
| 1036 bool get isObject => false; | 1034 bool get isObject => false; |
| 1037 | 1035 |
| 1038 bool get isVoid => false; | 1036 bool get isVoid => false; |
| 1039 | 1037 |
| 1040 bool get isDynamic => false; | 1038 bool get isDynamic => false; |
| 1041 | 1039 |
| 1042 bool get isTypeVariable => false; | 1040 bool get isTypeVariable => false; |
| 1043 | 1041 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1070 InterfaceType interfaceType) | 1068 InterfaceType interfaceType) |
| 1071 : super(system, interfaceType); | 1069 : super(system, interfaceType); |
| 1072 | 1070 |
| 1073 InterfaceType get _interfaceType => _type; | 1071 InterfaceType get _interfaceType => _type; |
| 1074 | 1072 |
| 1075 String get qualifiedName => originalDeclaration.qualifiedName; | 1073 String get qualifiedName => originalDeclaration.qualifiedName; |
| 1076 | 1074 |
| 1077 // TODO(johnniwinther): Substitute type arguments for type variables. | 1075 // TODO(johnniwinther): Substitute type arguments for type variables. |
| 1078 Map<String, MemberMirror> get members => originalDeclaration.members; | 1076 Map<String, MemberMirror> get members => originalDeclaration.members; |
| 1079 | 1077 |
| 1080 bool get isObject => system.compiler.objectClass == _type.element; | 1078 bool get isObject => mirrors.compiler.objectClass == _type.element; |
| 1081 | 1079 |
| 1082 bool get isDynamic => system.compiler.dynamicClass == _type.element; | 1080 bool get isDynamic => mirrors.compiler.dynamicClass == _type.element; |
| 1083 | 1081 |
| 1084 ClassMirror get originalDeclaration | 1082 ClassMirror get originalDeclaration |
| 1085 => new Dart2JsClassMirror(system, _type.element); | 1083 => new Dart2JsClassMirror(mirrors, _type.element); |
| 1086 | 1084 |
| 1087 // TODO(johnniwinther): Substitute type arguments for type variables. | 1085 // TODO(johnniwinther): Substitute type arguments for type variables. |
| 1088 ClassMirror get superclass => originalDeclaration.superclass; | 1086 ClassMirror get superclass => originalDeclaration.superclass; |
| 1089 | 1087 |
| 1090 // TODO(johnniwinther): Substitute type arguments for type variables. | 1088 // TODO(johnniwinther): Substitute type arguments for type variables. |
| 1091 List<ClassMirror> get superinterfaces => originalDeclaration.superinterfaces; | 1089 List<ClassMirror> get superinterfaces => originalDeclaration.superinterfaces; |
| 1092 | 1090 |
| 1093 bool get isClass => originalDeclaration.isClass; | 1091 bool get isClass => originalDeclaration.isClass; |
| 1094 | 1092 |
| 1095 bool get isInterface => originalDeclaration.isInterface; | 1093 bool get isInterface => originalDeclaration.isInterface; |
| 1096 | 1094 |
| 1097 bool get isAbstract => originalDeclaration.isAbstract; | 1095 bool get isAbstract => originalDeclaration.isAbstract; |
| 1098 | 1096 |
| 1099 bool get isPrivate => originalDeclaration.isPrivate; | 1097 bool get isPrivate => originalDeclaration.isPrivate; |
| 1100 | 1098 |
| 1101 bool get isOriginalDeclaration => false; | 1099 bool get isOriginalDeclaration => false; |
| 1102 | 1100 |
| 1103 List<TypeMirror> get typeArguments { | 1101 List<TypeMirror> get typeArguments { |
| 1104 if (_typeArguments == null) { | 1102 if (_typeArguments == null) { |
| 1105 _typeArguments = <TypeMirror>[]; | 1103 _typeArguments = <TypeMirror>[]; |
| 1106 Link<DartType> type = _interfaceType.arguments; | 1104 Link<DartType> type = _interfaceType.arguments; |
| 1107 while (type != null && type.head != null) { | 1105 while (type != null && type.head != null) { |
| 1108 _typeArguments.add(_convertTypeToTypeMirror(system, type.head, | 1106 _typeArguments.add(_convertTypeToTypeMirror(mirrors, type.head, |
| 1109 system.compiler.types.dynamicType)); | 1107 mirrors.compiler.types.dynamicType)); |
| 1110 type = type.tail; | 1108 type = type.tail; |
| 1111 } | 1109 } |
| 1112 } | 1110 } |
| 1113 return _typeArguments; | 1111 return _typeArguments; |
| 1114 } | 1112 } |
| 1115 | 1113 |
| 1116 List<TypeVariableMirror> get typeVariables => | 1114 List<TypeVariableMirror> get typeVariables => |
| 1117 originalDeclaration.typeVariables; | 1115 originalDeclaration.typeVariables; |
| 1118 | 1116 |
| 1119 // TODO(johnniwinther): Substitute type arguments for type variables. | 1117 // TODO(johnniwinther): Substitute type arguments for type variables. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1186 assert(!map.containsKey(name)); | 1184 assert(!map.containsKey(name)); |
| 1187 map[name] = method; | 1185 map[name] = method; |
| 1188 return new ImmutableMapWrapper<String, MemberMirror>(map); | 1186 return new ImmutableMapWrapper<String, MemberMirror>(map); |
| 1189 } | 1187 } |
| 1190 return originalDeclaration.members; | 1188 return originalDeclaration.members; |
| 1191 } | 1189 } |
| 1192 | 1190 |
| 1193 bool get isFunction => true; | 1191 bool get isFunction => true; |
| 1194 | 1192 |
| 1195 MethodMirror get callMethod => _convertElementMethodToMethodMirror( | 1193 MethodMirror get callMethod => _convertElementMethodToMethodMirror( |
| 1196 system.getLibrary(_functionType.element.getLibrary()), | 1194 mirrors._getLibrary(_functionType.element.getLibrary()), |
| 1197 _functionType.element); | 1195 _functionType.element); |
| 1198 | 1196 |
| 1199 ClassMirror get originalDeclaration | 1197 ClassMirror get originalDeclaration |
| 1200 => new Dart2JsClassMirror(system, system.compiler.functionClass); | 1198 => new Dart2JsClassMirror(mirrors, mirrors.compiler.functionClass); |
| 1201 | 1199 |
| 1202 // TODO(johnniwinther): Substitute type arguments for type variables. | 1200 // TODO(johnniwinther): Substitute type arguments for type variables. |
| 1203 ClassMirror get superclass => originalDeclaration.superclass; | 1201 ClassMirror get superclass => originalDeclaration.superclass; |
| 1204 | 1202 |
| 1205 // TODO(johnniwinther): Substitute type arguments for type variables. | 1203 // TODO(johnniwinther): Substitute type arguments for type variables. |
| 1206 List<ClassMirror> get superinterfaces => originalDeclaration.superinterfaces; | 1204 List<ClassMirror> get superinterfaces => originalDeclaration.superinterfaces; |
| 1207 | 1205 |
| 1208 bool get isClass => originalDeclaration.isClass; | 1206 bool get isClass => originalDeclaration.isClass; |
| 1209 | 1207 |
| 1210 bool get isInterface => originalDeclaration.isInterface; | 1208 bool get isInterface => originalDeclaration.isInterface; |
| 1211 | 1209 |
| 1212 bool get isPrivate => originalDeclaration.isPrivate; | 1210 bool get isPrivate => originalDeclaration.isPrivate; |
| 1213 | 1211 |
| 1214 bool get isOriginalDeclaration => false; | 1212 bool get isOriginalDeclaration => false; |
| 1215 | 1213 |
| 1216 bool get isAbstract => false; | 1214 bool get isAbstract => false; |
| 1217 | 1215 |
| 1218 List<TypeMirror> get typeArguments => const <TypeMirror>[]; | 1216 List<TypeMirror> get typeArguments => const <TypeMirror>[]; |
| 1219 | 1217 |
| 1220 List<TypeVariableMirror> get typeVariables => | 1218 List<TypeVariableMirror> get typeVariables => |
| 1221 originalDeclaration.typeVariables; | 1219 originalDeclaration.typeVariables; |
| 1222 | 1220 |
| 1223 TypeMirror get returnType { | 1221 TypeMirror get returnType { |
| 1224 return _convertTypeToTypeMirror(system, _functionType.returnType, | 1222 return _convertTypeToTypeMirror(mirrors, _functionType.returnType, |
| 1225 system.compiler.types.dynamicType); | 1223 mirrors.compiler.types.dynamicType); |
| 1226 } | 1224 } |
| 1227 | 1225 |
| 1228 List<ParameterMirror> get parameters { | 1226 List<ParameterMirror> get parameters { |
| 1229 if (_parameters === null) { | 1227 if (_parameters === null) { |
| 1230 _parameters = _parametersFromFunctionSignature(system, callMethod, | 1228 _parameters = _parametersFromFunctionSignature(mirrors, callMethod, |
| 1231 _functionSignature); | 1229 _functionSignature); |
| 1232 } | 1230 } |
| 1233 return _parameters; | 1231 return _parameters; |
| 1234 } | 1232 } |
| 1235 } | 1233 } |
| 1236 | 1234 |
| 1237 class Dart2JsVoidMirror extends Dart2JsTypeElementMirror { | 1235 class Dart2JsVoidMirror extends Dart2JsTypeElementMirror { |
| 1238 | 1236 |
| 1239 Dart2JsVoidMirror(Dart2JsMirrorSystem system, VoidType voidType) | 1237 Dart2JsVoidMirror(Dart2JsMirrorSystem system, VoidType voidType) |
| 1240 : super(system, voidType); | 1238 : super(system, voidType); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1307 final Dart2JsContainerMirror _objectMirror; | 1305 final Dart2JsContainerMirror _objectMirror; |
| 1308 String _simpleName; | 1306 String _simpleName; |
| 1309 String _displayName; | 1307 String _displayName; |
| 1310 String _constructorName; | 1308 String _constructorName; |
| 1311 String _operatorName; | 1309 String _operatorName; |
| 1312 Dart2JsMethodKind _kind; | 1310 Dart2JsMethodKind _kind; |
| 1313 | 1311 |
| 1314 Dart2JsMethodMirror(Dart2JsContainerMirror objectMirror, | 1312 Dart2JsMethodMirror(Dart2JsContainerMirror objectMirror, |
| 1315 FunctionElement function) | 1313 FunctionElement function) |
| 1316 : this._objectMirror = objectMirror, | 1314 : this._objectMirror = objectMirror, |
| 1317 super(objectMirror.system, function) { | 1315 super(objectMirror.mirrors, function) { |
| 1318 _simpleName = _element.name.slowToString(); | 1316 _simpleName = _element.name.slowToString(); |
| 1319 if (_function.kind == ElementKind.GETTER) { | 1317 if (_function.kind == ElementKind.GETTER) { |
| 1320 _kind = Dart2JsMethodKind.GETTER; | 1318 _kind = Dart2JsMethodKind.GETTER; |
| 1321 _displayName = _simpleName; | 1319 _displayName = _simpleName; |
| 1322 } else if (_function.kind == ElementKind.SETTER) { | 1320 } else if (_function.kind == ElementKind.SETTER) { |
| 1323 _kind = Dart2JsMethodKind.SETTER; | 1321 _kind = Dart2JsMethodKind.SETTER; |
| 1324 _displayName = _simpleName; | 1322 _displayName = _simpleName; |
| 1325 _simpleName = '$_simpleName='; | 1323 _simpleName = '$_simpleName='; |
| 1326 } else if (_function.kind == ElementKind.GENERATIVE_CONSTRUCTOR) { | 1324 } else if (_function.kind == ElementKind.GENERATIVE_CONSTRUCTOR) { |
| 1327 _constructorName = ''; | 1325 _constructorName = ''; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1390 => _kind == Dart2JsMethodKind.CONSTRUCTOR || isConst || isFactory; | 1388 => _kind == Dart2JsMethodKind.CONSTRUCTOR || isConst || isFactory; |
| 1391 | 1389 |
| 1392 bool get isMethod => !isConstructor; | 1390 bool get isMethod => !isConstructor; |
| 1393 | 1391 |
| 1394 bool get isPrivate => | 1392 bool get isPrivate => |
| 1395 isConstructor ? _isPrivate(constructorName) : _isPrivate(simpleName); | 1393 isConstructor ? _isPrivate(constructorName) : _isPrivate(simpleName); |
| 1396 | 1394 |
| 1397 bool get isStatic => _function.modifiers.isStatic(); | 1395 bool get isStatic => _function.modifiers.isStatic(); |
| 1398 | 1396 |
| 1399 List<ParameterMirror> get parameters { | 1397 List<ParameterMirror> get parameters { |
| 1400 return _parametersFromFunctionSignature(system, this, | 1398 return _parametersFromFunctionSignature(mirrors, this, |
| 1401 _function.computeSignature(system.compiler)); | 1399 _function.computeSignature(mirrors.compiler)); |
| 1402 } | 1400 } |
| 1403 | 1401 |
| 1404 TypeMirror get returnType => _convertTypeToTypeMirror( | 1402 TypeMirror get returnType => _convertTypeToTypeMirror( |
| 1405 system, _function.computeSignature(system.compiler).returnType, | 1403 mirrors, _function.computeSignature(mirrors.compiler).returnType, |
| 1406 system.compiler.types.dynamicType); | 1404 mirrors.compiler.types.dynamicType); |
| 1407 | 1405 |
| 1408 bool get isAbstract => _function.modifiers.isAbstract(); | 1406 bool get isAbstract => _function.modifiers.isAbstract(); |
| 1409 | 1407 |
| 1410 bool get isConst => _kind == Dart2JsMethodKind.CONST; | 1408 bool get isConst => _kind == Dart2JsMethodKind.CONST; |
| 1411 | 1409 |
| 1412 bool get isFactory => _kind == Dart2JsMethodKind.FACTORY; | 1410 bool get isFactory => _kind == Dart2JsMethodKind.FACTORY; |
| 1413 | 1411 |
| 1414 String get constructorName => _constructorName; | 1412 String get constructorName => _constructorName; |
| 1415 | 1413 |
| 1416 bool get isGetter => _kind == Dart2JsMethodKind.GETTER; | 1414 bool get isGetter => _kind == Dart2JsMethodKind.GETTER; |
| 1417 | 1415 |
| 1418 bool get isSetter => _kind == Dart2JsMethodKind.SETTER; | 1416 bool get isSetter => _kind == Dart2JsMethodKind.SETTER; |
| 1419 | 1417 |
| 1420 bool get isOperator => _kind == Dart2JsMethodKind.OPERATOR; | 1418 bool get isOperator => _kind == Dart2JsMethodKind.OPERATOR; |
| 1421 | 1419 |
| 1422 String get operatorName => _operatorName; | 1420 String get operatorName => _operatorName; |
| 1423 | 1421 |
| 1424 SourceLocation get location { | 1422 SourceLocation get location { |
| 1425 var node = _function.parseNode(_diagnosticListener); | 1423 var node = _function.parseNode(_diagnosticListener); |
| 1426 if (node !== null) { | 1424 if (node !== null) { |
| 1427 var script = _function.getCompilationUnit().script; | 1425 var script = _function.getCompilationUnit().script; |
| 1428 var span = system.compiler.spanFromNode(node, script.uri); | 1426 var span = mirrors.compiler.spanFromNode(node, script.uri); |
| 1429 return new Dart2JsLocation(script, span); | 1427 return new Dart2JsLocation(script, span); |
| 1430 } | 1428 } |
| 1431 return super.location; | 1429 return super.location; |
| 1432 } | 1430 } |
| 1433 | 1431 |
| 1434 } | 1432 } |
| 1435 | 1433 |
| 1436 class Dart2JsFieldMirror extends Dart2JsMemberMirror implements VariableMirror { | 1434 class Dart2JsFieldMirror extends Dart2JsMemberMirror implements VariableMirror { |
| 1437 Dart2JsContainerMirror _objectMirror; | 1435 Dart2JsContainerMirror _objectMirror; |
| 1438 VariableElement _variable; | 1436 VariableElement _variable; |
| 1439 | 1437 |
| 1440 Dart2JsFieldMirror(Dart2JsContainerMirror objectMirror, | 1438 Dart2JsFieldMirror(Dart2JsContainerMirror objectMirror, |
| 1441 VariableElement variable) | 1439 VariableElement variable) |
| 1442 : this._objectMirror = objectMirror, | 1440 : this._objectMirror = objectMirror, |
| 1443 this._variable = variable, | 1441 this._variable = variable, |
| 1444 super(objectMirror.system, variable); | 1442 super(objectMirror.mirrors, variable); |
| 1445 | 1443 |
| 1446 String get qualifiedName | 1444 String get qualifiedName |
| 1447 => '${owner.qualifiedName}.$simpleName'; | 1445 => '${owner.qualifiedName}.$simpleName'; |
| 1448 | 1446 |
| 1449 DeclarationMirror get owner => _objectMirror; | 1447 DeclarationMirror get owner => _objectMirror; |
| 1450 | 1448 |
| 1451 bool get isTopLevel => _objectMirror is LibraryMirror; | 1449 bool get isTopLevel => _objectMirror is LibraryMirror; |
| 1452 | 1450 |
| 1453 bool get isField => true; | 1451 bool get isField => true; |
| 1454 | 1452 |
| 1455 bool get isStatic => _variable.modifiers.isStatic(); | 1453 bool get isStatic => _variable.modifiers.isStatic(); |
| 1456 | 1454 |
| 1457 bool get isFinal => _variable.modifiers.isFinal(); | 1455 bool get isFinal => _variable.modifiers.isFinal(); |
| 1458 | 1456 |
| 1459 bool get isConst => _variable.modifiers.isConst(); | 1457 bool get isConst => _variable.modifiers.isConst(); |
| 1460 | 1458 |
| 1461 TypeMirror get type => _convertTypeToTypeMirror(system, | 1459 TypeMirror get type => _convertTypeToTypeMirror(mirrors, |
| 1462 _variable.computeType(system.compiler), | 1460 _variable.computeType(mirrors.compiler), |
| 1463 system.compiler.types.dynamicType); | 1461 mirrors.compiler.types.dynamicType); |
| 1464 | 1462 |
| 1465 SourceLocation get location { | 1463 SourceLocation get location { |
| 1466 var script = _variable.getCompilationUnit().script; | 1464 var script = _variable.getCompilationUnit().script; |
| 1467 var node = _variable.variables.parseNode(_diagnosticListener); | 1465 var node = _variable.variables.parseNode(_diagnosticListener); |
| 1468 if (node !== null) { | 1466 if (node !== null) { |
| 1469 var span = system.compiler.spanFromNode(node, script.uri); | 1467 var span = mirrors.compiler.spanFromNode(node, script.uri); |
| 1470 return new Dart2JsLocation(script, span); | 1468 return new Dart2JsLocation(script, span); |
| 1471 } else { | 1469 } else { |
| 1472 var span = system.compiler.spanFromElement(_variable); | 1470 var span = mirrors.compiler.spanFromElement(_variable); |
| 1473 return new Dart2JsLocation(script, span); | 1471 return new Dart2JsLocation(script, span); |
| 1474 } | 1472 } |
| 1475 } | 1473 } |
| 1476 } | 1474 } |
| 1477 | 1475 |
| OLD | NEW |