Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1438)

Side by Side Diff: lib/dartdoc/mirrors/dart2js_mirror.dart

Issue 10823257: Refactored accessors in mirrors from methods to properties. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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('../../compiler/compiler.dart', prefix: 'diagnostics'); 7 #import('../../compiler/compiler.dart', prefix: 'diagnostics');
8 #import('../../compiler/implementation/elements/elements.dart'); 8 #import('../../compiler/implementation/elements/elements.dart');
9 #import('../../compiler/implementation/apiimpl.dart', prefix: 'api'); 9 #import('../../compiler/implementation/apiimpl.dart', prefix: 'api');
10 #import('../../compiler/implementation/scanner/scannerlib.dart'); 10 #import('../../compiler/implementation/scanner/scannerlib.dart');
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 // TODO(johnniwinther): Detect file not found 351 // TODO(johnniwinther): Detect file not found
352 } 352 }
353 _compiler.runList(librariesUri); 353 _compiler.runList(librariesUri);
354 } 354 }
355 355
356 void addLibrary(String path) { 356 void addLibrary(String path) {
357 var uri = cwd.resolve(nativeToUriPath(path)); 357 var uri = cwd.resolve(nativeToUriPath(path));
358 _compiler.scanner.loadLibrary(uri, null); 358 _compiler.scanner.loadLibrary(uri, null);
359 } 359 }
360 360
361 MirrorSystem mirrors() => new Dart2JsMirrorSystem(_compiler); 361 MirrorSystem get mirrors() => new Dart2JsMirrorSystem(_compiler);
362 362
363 Future<String> compileToJavaScript() => 363 Future<String> compileToJavaScript() =>
364 new Future<String>.immediate(_compiler.assembledCode); 364 new Future<String>.immediate(_compiler.assembledCode);
365 } 365 }
366 366
367 367
368 //------------------------------------------------------------------------------ 368 //------------------------------------------------------------------------------
369 // Dart2Js specific extensions of mirror interfaces 369 // Dart2Js specific extensions of mirror interfaces
370 //------------------------------------------------------------------------------ 370 //------------------------------------------------------------------------------
371 371
(...skipping 15 matching lines...) Expand all
387 387
388 abstract class Dart2JsElementMirror implements Dart2JsMirror { 388 abstract class Dart2JsElementMirror implements Dart2JsMirror {
389 final Dart2JsMirrorSystem system; 389 final Dart2JsMirrorSystem system;
390 final Element _element; 390 final Element _element;
391 391
392 Dart2JsElementMirror(this.system, this._element) { 392 Dart2JsElementMirror(this.system, this._element) {
393 assert (system !== null); 393 assert (system !== null);
394 assert (_element !== null); 394 assert (_element !== null);
395 } 395 }
396 396
397 String simpleName() => _element.name.slowToString(); 397 String get simpleName() => _element.name.slowToString();
398 398
399 Location location() => new Dart2JsLocation( 399 Location get location() => new Dart2JsLocation(
400 _element.getCompilationUnit().script, 400 _element.getCompilationUnit().script,
401 system.compiler.spanFromElement(_element)); 401 system.compiler.spanFromElement(_element));
402 402
403 String toString() => _element.toString(); 403 String toString() => _element.toString();
404 404
405 int hashCode() => qualifiedName().hashCode(); 405 int hashCode() => qualifiedName.hashCode();
406 } 406 }
407 407
408 abstract class Dart2JsProxyMirror implements Dart2JsMirror { 408 abstract class Dart2JsProxyMirror implements Dart2JsMirror {
409 final Dart2JsMirrorSystem system; 409 final Dart2JsMirrorSystem system;
410 410
411 Dart2JsProxyMirror(this.system); 411 Dart2JsProxyMirror(this.system);
412 412
413 int hashCode() => qualifiedName().hashCode(); 413 int hashCode() => qualifiedName.hashCode();
414 } 414 }
415 415
416 //------------------------------------------------------------------------------ 416 //------------------------------------------------------------------------------
417 // Mirror system implementation. 417 // Mirror system implementation.
418 //------------------------------------------------------------------------------ 418 //------------------------------------------------------------------------------
419 419
420 class Dart2JsMirrorSystem implements MirrorSystem, Dart2JsMirror { 420 class Dart2JsMirrorSystem implements MirrorSystem, Dart2JsMirror {
421 final api.Compiler compiler; 421 final api.Compiler compiler;
422 Map<String, Dart2JsLibraryMirror> _libraries; 422 Map<String, Dart2JsLibraryMirror> _libraries;
423 Map<LibraryElement, Dart2JsLibraryMirror> _libraryMap; 423 Map<LibraryElement, Dart2JsLibraryMirror> _libraryMap;
424 424
425 Dart2JsMirrorSystem(this.compiler) 425 Dart2JsMirrorSystem(this.compiler)
426 : _libraryMap = new Map<LibraryElement, Dart2JsLibraryMirror>(); 426 : _libraryMap = new Map<LibraryElement, Dart2JsLibraryMirror>();
427 427
428 void _ensureLibraries() { 428 void _ensureLibraries() {
429 if (_libraries == null) { 429 if (_libraries == null) {
430 _libraries = <Dart2JsLibraryMirror>{}; 430 _libraries = <Dart2JsLibraryMirror>{};
431 compiler.libraries.forEach((_, LibraryElement v) { 431 compiler.libraries.forEach((_, LibraryElement v) {
432 var mirror = new Dart2JsLibraryMirror(system, v); 432 var mirror = new Dart2JsLibraryMirror(system, v);
433 _libraries[mirror.canonicalName] = mirror; 433 _libraries[mirror.canonicalName] = mirror;
434 _libraryMap[v] = mirror; 434 _libraryMap[v] = mirror;
435 }); 435 });
436 } 436 }
437 } 437 }
438 438
439 Map<Object, LibraryMirror> libraries() { 439 Map<Object, LibraryMirror> get libraries() {
440 _ensureLibraries(); 440 _ensureLibraries();
441 return new ImmutableMapWrapper<Object, LibraryMirror>(_libraries); 441 return new ImmutableMapWrapper<Object, LibraryMirror>(_libraries);
442 } 442 }
443 443
444 Dart2JsLibraryMirror getLibrary(LibraryElement element) { 444 Dart2JsLibraryMirror getLibrary(LibraryElement element) {
445 return _libraryMap[element]; 445 return _libraryMap[element];
446 } 446 }
447 447
448 Dart2JsMirrorSystem get system() => this; 448 Dart2JsMirrorSystem get system() => this;
449 449
450 String simpleName() => "mirror"; 450 String get simpleName() => "mirror";
451 String qualifiedName() => simpleName(); 451 String get qualifiedName() => simpleName;
452 452
453 String get canonicalName() => simpleName(); 453 String get canonicalName() => simpleName;
454 454
455 // TODO(johnniwinther): Hack! Dart2JsMirrorSystem need not be a Mirror. 455 // TODO(johnniwinther): Hack! Dart2JsMirrorSystem need not be a Mirror.
456 int hashCode() => qualifiedName().hashCode(); 456 int hashCode() => qualifiedName.hashCode();
457 } 457 }
458 458
459 abstract class Dart2JsObjectMirror extends Dart2JsElementMirror 459 abstract class Dart2JsObjectMirror extends Dart2JsElementMirror
460 implements ObjectMirror { 460 implements ObjectMirror {
461 Dart2JsObjectMirror(Dart2JsMirrorSystem system, Element element) 461 Dart2JsObjectMirror(Dart2JsMirrorSystem system, Element element)
462 : super(system, element); 462 : super(system, element);
463 } 463 }
464 464
465 class Dart2JsLibraryMirror extends Dart2JsObjectMirror 465 class Dart2JsLibraryMirror extends Dart2JsObjectMirror
466 implements LibraryMirror { 466 implements LibraryMirror {
467 Map<String, InterfaceMirror> _types; 467 Map<String, InterfaceMirror> _types;
468 Map<String, MemberMirror> _members; 468 Map<String, MemberMirror> _members;
469 469
470 Dart2JsLibraryMirror(Dart2JsMirrorSystem system, LibraryElement library) 470 Dart2JsLibraryMirror(Dart2JsMirrorSystem system, LibraryElement library)
471 : super(system, library); 471 : super(system, library);
472 472
473 LibraryElement get _library() => _element; 473 LibraryElement get _library() => _element;
474 474
475 LibraryMirror library() => this; 475 LibraryMirror library() => this;
476 476
477 String get canonicalName() => simpleName(); 477 String get canonicalName() => simpleName;
478 478
479 /** 479 /**
480 * Returns the library name (for libraries with a #library tag) or the script 480 * Returns the library name (for libraries with a #library tag) or the script
481 * file name (for scripts without a #library tag). The latter case is used to 481 * file name (for scripts without a #library tag). The latter case is used to
482 * provide a 'library name' for scripts, to use for instance in dartdoc. 482 * provide a 'library name' for scripts, to use for instance in dartdoc.
483 */ 483 */
484 String simpleName() { 484 String get simpleName() {
485 if (_library.libraryTag !== null) { 485 if (_library.libraryTag !== null) {
486 return _library.libraryTag.argument.dartString.slowToString(); 486 return _library.libraryTag.argument.dartString.slowToString();
487 } else { 487 } else {
488 // Use the file name as script name. 488 // Use the file name as script name.
489 String path = _library.script.uri.path; 489 String path = _library.script.uri.path;
490 return path.substring(path.lastIndexOf('/') + 1); 490 return path.substring(path.lastIndexOf('/') + 1);
491 } 491 }
492 } 492 }
493 493
494 String qualifiedName() => simpleName(); 494 String get qualifiedName() => simpleName;
495 495
496 void _ensureTypes() { 496 void _ensureTypes() {
497 if (_types == null) { 497 if (_types == null) {
498 _types = <InterfaceMirror>{}; 498 _types = <InterfaceMirror>{};
499 _library.forEachExport((Element e) { 499 _library.forEachExport((Element e) {
500 if (e.getLibrary() == _library) { 500 if (e.getLibrary() == _library) {
501 if (e.isClass()) { 501 if (e.isClass()) {
502 var type = new Dart2JsInterfaceMirror.fromLibrary(this, e); 502 var type = new Dart2JsInterfaceMirror.fromLibrary(this, e);
503 _types[type.canonicalName] = type; 503 _types[type.canonicalName] = type;
504 } else if (e.isTypedef()) { 504 } else if (e.isTypedef()) {
(...skipping 11 matching lines...) Expand all
516 _library.forEachExport((Element e) { 516 _library.forEachExport((Element e) {
517 if (!e.isClass() && !e.isTypedef()) { 517 if (!e.isClass() && !e.isTypedef()) {
518 for (var member in _convertElementMemberToMemberMirrors(this, e)) { 518 for (var member in _convertElementMemberToMemberMirrors(this, e)) {
519 _members[member.canonicalName] = member; 519 _members[member.canonicalName] = member;
520 } 520 }
521 } 521 }
522 }); 522 });
523 } 523 }
524 } 524 }
525 525
526 Map<Object, MemberMirror> declaredMembers() { 526 Map<Object, MemberMirror> get declaredMembers() {
527 _ensureMembers(); 527 _ensureMembers();
528 return new ImmutableMapWrapper<Object, MemberMirror>(_members); 528 return new ImmutableMapWrapper<Object, MemberMirror>(_members);
529 } 529 }
530 530
531 Map<Object, InterfaceMirror> types() { 531 Map<Object, InterfaceMirror> get types() {
532 _ensureTypes(); 532 _ensureTypes();
533 return new ImmutableMapWrapper<Object, InterfaceMirror>(_types); 533 return new ImmutableMapWrapper<Object, InterfaceMirror>(_types);
534 } 534 }
535 535
536 Location location() { 536 Location get location() {
537 var script = _library.getCompilationUnit().script; 537 var script = _library.getCompilationUnit().script;
538 return new Dart2JsLocation( 538 return new Dart2JsLocation(
539 script, 539 script,
540 new SourceSpan(script.uri, 0, script.text.length)); 540 new SourceSpan(script.uri, 0, script.text.length));
541 } 541 }
542 } 542 }
543 543
544 class Dart2JsLocation implements Location { 544 class Dart2JsLocation implements Location {
545 Script _script; 545 Script _script;
546 SourceSpan _span; 546 SourceSpan _span;
547 547
548 Dart2JsLocation(this._script, this._span); 548 Dart2JsLocation(this._script, this._span);
549 549
550 int start() => _span.begin; 550 int get start() => _span.begin;
551 int end() => _span.end;
552 Source source() => new Dart2JsSource(_script);
553 551
554 String text() => _script.text.substring(start(), end()); 552 int get end() => _span.end;
553
554 Source get source() => new Dart2JsSource(_script);
555
556 String get text() => _script.text.substring(start, end);
555 } 557 }
556 558
557 class Dart2JsSource implements Source { 559 class Dart2JsSource implements Source {
558 Script _script; 560 Script _script;
559 561
560 Dart2JsSource(this._script); 562 Dart2JsSource(this._script);
561 563
562 Uri uri() => _script.uri; 564 Uri get uri() => _script.uri;
563 String text() => _script.text; 565
566 String get text() => _script.text;
564 } 567 }
565 568
566 class Dart2JsParameterMirror extends Dart2JsElementMirror 569 class Dart2JsParameterMirror extends Dart2JsElementMirror
567 implements ParameterMirror { 570 implements ParameterMirror {
568 final MethodMirror _method; 571 final MethodMirror _method;
569 final bool _isOptional; 572 final bool _isOptional;
570 573
571 factory Dart2JsParameterMirror(Dart2JsMirrorSystem system, 574 factory Dart2JsParameterMirror(Dart2JsMirrorSystem system,
572 MethodMirror method, 575 MethodMirror method,
573 VariableElement element, 576 VariableElement element,
574 bool isOptional) { 577 bool isOptional) {
575 if (element is FieldParameterElement) { 578 if (element is FieldParameterElement) {
576 return new Dart2JsFieldParameterMirror(system, 579 return new Dart2JsFieldParameterMirror(system,
577 method, element, isOptional); 580 method, element, isOptional);
578 } 581 }
579 return new Dart2JsParameterMirror._normal(system, 582 return new Dart2JsParameterMirror._normal(system,
580 method, element, isOptional); 583 method, element, isOptional);
581 } 584 }
582 585
583 Dart2JsParameterMirror._normal(Dart2JsMirrorSystem system, 586 Dart2JsParameterMirror._normal(Dart2JsMirrorSystem system,
584 this._method, 587 this._method,
585 VariableElement element, 588 VariableElement element,
586 this._isOptional) 589 this._isOptional)
587 : super(system, element); 590 : super(system, element);
588 591
589 VariableElement get _variableElement() => _element; 592 VariableElement get _variableElement() => _element;
590 593
591 String get canonicalName() => simpleName(); 594 String get canonicalName() => simpleName;
592 595
593 String qualifiedName() => '${_method.qualifiedName()}#${simpleName()}'; 596 String get qualifiedName() => '${_method.qualifiedName}#${simpleName}';
594 597
595 TypeMirror type() => _convertTypeToTypeMirror(system, 598 TypeMirror get type() => _convertTypeToTypeMirror(system,
596 _variableElement.computeType(system.compiler), 599 _variableElement.computeType(system.compiler),
597 system.compiler.dynamicClass.computeType(system.compiler), 600 system.compiler.dynamicClass.computeType(system.compiler),
598 _variableElement.variables.functionSignature); 601 _variableElement.variables.functionSignature);
599 602
600 String defaultValue() { 603 String get defaultValue() {
601 if (hasDefaultValue()) { 604 if (hasDefaultValue) {
602 SendSet expression = _variableElement.cachedNode.asSendSet(); 605 SendSet expression = _variableElement.cachedNode.asSendSet();
603 return expression.arguments.head.unparse(); 606 return expression.arguments.head.unparse();
604 } 607 }
605 return null; 608 return null;
606 } 609 }
607 bool hasDefaultValue() { 610 bool get hasDefaultValue() {
608 return _variableElement.cachedNode !== null && 611 return _variableElement.cachedNode !== null &&
609 _variableElement.cachedNode is SendSet; 612 _variableElement.cachedNode is SendSet;
610 } 613 }
611 614
612 bool isOptional() => _isOptional; 615 bool get isOptional() => _isOptional;
turnidge 2012/08/09 17:44:13 This could be made a final bool field instead of a
Johnni Winther 2012/08/10 23:40:23 Done.
613 616
614 bool isInitializingFormal() => false; 617 bool get isInitializingFormal() => false;
615 618
616 FieldMirror initializedField() => null; 619 FieldMirror get initializedField() => null;
617 } 620 }
618 621
619 class Dart2JsFieldParameterMirror extends Dart2JsParameterMirror { 622 class Dart2JsFieldParameterMirror extends Dart2JsParameterMirror {
620 623
621 Dart2JsFieldParameterMirror(Dart2JsMirrorSystem system, 624 Dart2JsFieldParameterMirror(Dart2JsMirrorSystem system,
622 MethodMirror method, 625 MethodMirror method,
623 FieldParameterElement element, 626 FieldParameterElement element,
624 bool isOptional) 627 bool isOptional)
625 : super._normal(system, method, element, isOptional); 628 : super._normal(system, method, element, isOptional);
626 629
627 FieldParameterElement get _fieldParameterElement() => _element; 630 FieldParameterElement get _fieldParameterElement() => _element;
628 631
629 TypeMirror type() { 632 TypeMirror get type() {
630 if (_fieldParameterElement.variables.cachedNode.type !== null) { 633 if (_fieldParameterElement.variables.cachedNode.type !== null) {
631 return super.type(); 634 return super.type;
632 } 635 }
633 return _convertTypeToTypeMirror(system, 636 return _convertTypeToTypeMirror(system,
634 _fieldParameterElement.fieldElement.computeType(system.compiler), 637 _fieldParameterElement.fieldElement.computeType(system.compiler),
635 system.compiler.dynamicClass.computeType(system.compiler), 638 system.compiler.dynamicClass.computeType(system.compiler),
636 _variableElement.variables.functionSignature); 639 _variableElement.variables.functionSignature);
637 } 640 }
638 641
639 bool isInitializingFormal() => true; 642 bool get isInitializingFormal() => true;
640 643
641 FieldMirror initializedField() => new Dart2JsFieldMirror( 644 FieldMirror get initializedField() => new Dart2JsFieldMirror(
642 _method.surroundingDeclaration(), _fieldParameterElement.fieldElement); 645 _method.surroundingDeclaration, _fieldParameterElement.fieldElement);
643 } 646 }
644 647
645 //------------------------------------------------------------------------------ 648 //------------------------------------------------------------------------------
646 // Declarations 649 // Declarations
647 //------------------------------------------------------------------------------ 650 //------------------------------------------------------------------------------
648 class Dart2JsInterfaceMirror extends Dart2JsObjectMirror 651 class Dart2JsInterfaceMirror extends Dart2JsObjectMirror
649 implements Dart2JsTypeMirror, InterfaceMirror { 652 implements Dart2JsTypeMirror, InterfaceMirror {
650 final Dart2JsLibraryMirror _library; 653 final Dart2JsLibraryMirror _library;
651 Map<String, Dart2JsMemberMirror> _members; 654 Map<String, Dart2JsMemberMirror> _members;
652 List<TypeVariableMirror> _typeVariables; 655 List<TypeVariableMirror> _typeVariables;
653 656
654 Dart2JsInterfaceMirror(Dart2JsMirrorSystem system, ClassElement _class) 657 Dart2JsInterfaceMirror(Dart2JsMirrorSystem system, ClassElement _class)
655 : this._library = system.getLibrary(_class.getLibrary()), 658 : this._library = system.getLibrary(_class.getLibrary()),
656 super(system, _class); 659 super(system, _class);
657 660
658 ClassElement get _class() => _element; 661 ClassElement get _class() => _element;
659 662
660 663
661 Dart2JsInterfaceMirror.fromLibrary(Dart2JsLibraryMirror library, 664 Dart2JsInterfaceMirror.fromLibrary(Dart2JsLibraryMirror library,
662 ClassElement _class) 665 ClassElement _class)
663 : this._library = library, 666 : this._library = library,
664 super(library.system, _class); 667 super(library.system, _class);
665 668
666 String get canonicalName() => simpleName(); 669 String get canonicalName() => simpleName;
667 670
668 String qualifiedName() => '${library().qualifiedName()}.${simpleName()}'; 671 String get qualifiedName() => '${library.qualifiedName}.${simpleName}';
669 672
670 Location location() { 673 Location get location() {
671 if (_class is PartialClassElement) { 674 if (_class is PartialClassElement) {
672 var node = _class.parseNode(_diagnosticListener); 675 var node = _class.parseNode(_diagnosticListener);
673 if (node !== null) { 676 if (node !== null) {
674 var script = _class.getCompilationUnit().script; 677 var script = _class.getCompilationUnit().script;
675 var span = system.compiler.spanFromNode(node, script.uri); 678 var span = system.compiler.spanFromNode(node, script.uri);
676 return new Dart2JsLocation(script, span); 679 return new Dart2JsLocation(script, span);
677 } 680 }
678 } 681 }
679 return super.location(); 682 return super.location;
680 } 683 }
681 684
682 void _ensureMembers() { 685 void _ensureMembers() {
683 if (_members == null) { 686 if (_members == null) {
684 _members = <Dart2JsMemberMirror>{}; 687 _members = <Dart2JsMemberMirror>{};
685 _class.constructors.forEach((_, e) { 688 _class.constructors.forEach((_, e) {
686 for (var member in _convertElementMemberToMemberMirrors(this, e)) { 689 for (var member in _convertElementMemberToMemberMirrors(this, e)) {
687 _members[member.canonicalName] = member; 690 _members[member.canonicalName] = member;
688 } 691 }
689 }); 692 });
690 _class.localMembers.forEach((_, e) { 693 _class.localMembers.forEach((_, e) {
691 for (var member in _convertElementMemberToMemberMirrors(this, e)) { 694 for (var member in _convertElementMemberToMemberMirrors(this, e)) {
692 _members[member.canonicalName] = member; 695 _members[member.canonicalName] = member;
693 } 696 }
694 }); 697 });
695 } 698 }
696 } 699 }
697 700
698 Map<Object, MemberMirror> declaredMembers() { 701 Map<Object, MemberMirror> get declaredMembers() {
699 _ensureMembers(); 702 _ensureMembers();
700 return new ImmutableMapWrapper<Object, MemberMirror>(_members); 703 return new ImmutableMapWrapper<Object, MemberMirror>(_members);
701 } 704 }
702 705
703 LibraryMirror library() { 706 LibraryMirror get library() {
turnidge 2012/08/09 17:44:13 Ditto here. You get the idea. Again, your call.
Johnni Winther 2012/08/10 23:40:23 Done.
704 return _library; 707 return _library;
705 } 708 }
706 709
707 bool get isObject() => _class == system.compiler.objectClass; 710 bool get isObject() => _class == system.compiler.objectClass;
708 711
709 bool get isDynamic() => _class == system.compiler.dynamicClass; 712 bool get isDynamic() => _class == system.compiler.dynamicClass;
710 713
711 bool get isVoid() => false; 714 bool get isVoid() => false;
712 715
713 bool get isTypeVariable() => false; 716 bool get isTypeVariable() => false;
714 717
715 bool get isTypedef() => false; 718 bool get isTypedef() => false;
716 719
717 bool get isFunction() => false; 720 bool get isFunction() => false;
718 721
719 InterfaceMirror get declaration() => this; 722 InterfaceMirror get declaration() => this;
720 723
721 InterfaceMirror superclass() { 724 InterfaceMirror get superclass() {
722 if (_class.supertype != null) { 725 if (_class.supertype != null) {
723 return new Dart2JsInterfaceTypeMirror(system, _class.supertype); 726 return new Dart2JsInterfaceTypeMirror(system, _class.supertype);
724 } 727 }
725 return null; 728 return null;
726 } 729 }
727 730
728 Map<Object, InterfaceMirror> interfaces() { 731 Map<Object, InterfaceMirror> get interfaces() {
729 var map = new Map<String, InterfaceMirror>(); 732 var map = new Map<String, InterfaceMirror>();
730 Link<Type> link = _class.interfaces; 733 Link<Type> link = _class.interfaces;
731 while (!link.isEmpty()) { 734 while (!link.isEmpty()) {
732 var type = _convertTypeToTypeMirror(system, link.head, 735 var type = _convertTypeToTypeMirror(system, link.head,
733 system.compiler.dynamicClass.computeType(system.compiler)); 736 system.compiler.dynamicClass.computeType(system.compiler));
734 map[type.canonicalName] = type; 737 map[type.canonicalName] = type;
735 link = link.tail; 738 link = link.tail;
736 } 739 }
737 return new ImmutableMapWrapper<Object, InterfaceMirror>(map); 740 return new ImmutableMapWrapper<Object, InterfaceMirror>(map);
738 } 741 }
739 742
740 bool get isClass() => !_class.isInterface(); 743 bool get isClass() => !_class.isInterface();
741 744
742 bool get isInterface() => _class.isInterface(); 745 bool get isInterface() => _class.isInterface();
743 746
744 bool get isPrivate() => _isPrivate(simpleName()); 747 bool get isPrivate() => _isPrivate(simpleName);
745 748
746 bool get isDeclaration() => true; 749 bool get isDeclaration() => true;
747 750
748 List<TypeMirror> typeArguments() { 751 List<TypeMirror> get typeArguments() {
749 throw new UnsupportedOperationException( 752 throw new UnsupportedOperationException(
750 'Declarations do not have type arguments'); 753 'Declarations do not have type arguments');
751 } 754 }
752 755
753 List<TypeVariableMirror> typeVariables() { 756 List<TypeVariableMirror> get typeVariables() {
754 if (_typeVariables == null) { 757 if (_typeVariables == null) {
755 _typeVariables = <TypeVariableMirror>[]; 758 _typeVariables = <TypeVariableMirror>[];
756 _class.ensureResolved(system.compiler); 759 _class.ensureResolved(system.compiler);
757 for (TypeVariableType typeVariable in _class.typeVariables) { 760 for (TypeVariableType typeVariable in _class.typeVariables) {
758 _typeVariables.add( 761 _typeVariables.add(
759 new Dart2JsTypeVariableMirror(system, typeVariable)); 762 new Dart2JsTypeVariableMirror(system, typeVariable));
760 } 763 }
761 } 764 }
762 return _typeVariables; 765 return _typeVariables;
763 } 766 }
764 767
765 Map<Object, MethodMirror> constructors() { 768 Map<Object, MethodMirror> get constructors() {
766 _ensureMembers(); 769 _ensureMembers();
767 return new AsFilteredImmutableMap<Object, MemberMirror, MethodMirror>( 770 return new AsFilteredImmutableMap<Object, MemberMirror, MethodMirror>(
768 _members, (m) => m.isConstructor ? m : null); 771 _members, (m) => m.isConstructor ? m : null);
769 } 772 }
770 773
771 /** 774 /**
772 * Returns the default type for this interface. 775 * Returns the default type for this interface.
773 */ 776 */
774 InterfaceMirror defaultType() { 777 InterfaceMirror get defaultType() {
775 if (_class.defaultClass != null) { 778 if (_class.defaultClass != null) {
776 return new Dart2JsInterfaceTypeMirror(system, _class.defaultClass); 779 return new Dart2JsInterfaceTypeMirror(system, _class.defaultClass);
777 } 780 }
778 return null; 781 return null;
779 } 782 }
780 783
781 bool operator ==(Object other) { 784 bool operator ==(Object other) {
782 if (this === other) { 785 if (this === other) {
783 return true; 786 return true;
784 } 787 }
785 if (other is! InterfaceMirror) { 788 if (other is! InterfaceMirror) {
786 return false; 789 return false;
787 } 790 }
788 if (library() != other.library()) { 791 if (library != other.library) {
789 return false; 792 return false;
790 } 793 }
791 if (isDeclaration !== other.isDeclaration) { 794 if (isDeclaration !== other.isDeclaration) {
792 return false; 795 return false;
793 } 796 }
794 return qualifiedName() == other.qualifiedName(); 797 return qualifiedName == other.qualifiedName;
795 } 798 }
796 } 799 }
797 800
798 class Dart2JsTypedefMirror extends Dart2JsElementMirror 801 class Dart2JsTypedefMirror extends Dart2JsElementMirror
799 implements Dart2JsTypeMirror, TypedefMirror { 802 implements Dart2JsTypeMirror, TypedefMirror {
800 final Dart2JsLibraryMirror _library; 803 final Dart2JsLibraryMirror _library;
801 List<TypeVariableMirror> _typeVariables; 804 List<TypeVariableMirror> _typeVariables;
802 TypeMirror _definition; 805 TypeMirror _definition;
803 806
804 Dart2JsTypedefMirror(Dart2JsMirrorSystem system, TypedefElement _typedef) 807 Dart2JsTypedefMirror(Dart2JsMirrorSystem system, TypedefElement _typedef)
805 : this._library = system.getLibrary(_typedef.getLibrary()), 808 : this._library = system.getLibrary(_typedef.getLibrary()),
806 super(system, _typedef); 809 super(system, _typedef);
807 810
808 Dart2JsTypedefMirror.fromLibrary(Dart2JsLibraryMirror library, 811 Dart2JsTypedefMirror.fromLibrary(Dart2JsLibraryMirror library,
809 TypedefElement _typedef) 812 TypedefElement _typedef)
810 : this._library = library, 813 : this._library = library,
811 super(library.system, _typedef); 814 super(library.system, _typedef);
812 815
813 TypedefElement get _typedef() => _element; 816 TypedefElement get _typedef() => _element;
814 817
815 String get canonicalName() => simpleName(); 818 String get canonicalName() => simpleName;
816 819
817 String qualifiedName() => '${library().qualifiedName()}.${simpleName()}'; 820 String get qualifiedName() => '${library.qualifiedName}.${simpleName}';
818 821
819 Location location() { 822 Location get location() {
820 var node = _typedef.parseNode(_diagnosticListener); 823 var node = _typedef.parseNode(_diagnosticListener);
821 if (node !== null) { 824 if (node !== null) {
822 var script = _typedef.getCompilationUnit().script; 825 var script = _typedef.getCompilationUnit().script;
823 var span = system.compiler.spanFromNode(node, script.uri); 826 var span = system.compiler.spanFromNode(node, script.uri);
824 return new Dart2JsLocation(script, span); 827 return new Dart2JsLocation(script, span);
825 } 828 }
826 return super.location(); 829 return super.location;
827 } 830 }
828 831
829 LibraryMirror library() => _library; 832 LibraryMirror get library() => _library;
830 833
831 bool get isObject() => false; 834 bool get isObject() => false;
832 835
833 bool get isDynamic() => false; 836 bool get isDynamic() => false;
834 837
835 bool get isVoid() => false; 838 bool get isVoid() => false;
836 839
837 bool get isTypeVariable() => false; 840 bool get isTypeVariable() => false;
838 841
839 bool get isTypedef() => true; 842 bool get isTypedef() => true;
840 843
841 bool get isFunction() => false; 844 bool get isFunction() => false;
842 845
843 List<TypeMirror> typeArguments() { 846 List<TypeMirror> get typeArguments() {
844 throw new UnsupportedOperationException( 847 throw new UnsupportedOperationException(
845 'Declarations do not have type arguments'); 848 'Declarations do not have type arguments');
846 } 849 }
847 850
848 List<TypeVariableMirror> typeVariables() { 851 List<TypeVariableMirror> get typeVariables() {
849 if (_typeVariables == null) { 852 if (_typeVariables == null) {
850 _typeVariables = <TypeVariableMirror>[]; 853 _typeVariables = <TypeVariableMirror>[];
851 // TODO(johnniwinther): Equip [Typedef] with a [typeParameters] map, just 854 // TODO(johnniwinther): Equip [Typedef] with a [typeParameters] map, just
852 // like [ClassElement]. 855 // like [ClassElement].
853 } 856 }
854 return _typeVariables; 857 return _typeVariables;
855 } 858 }
856 859
857 TypeMirror definition() { 860 TypeMirror get definition() {
858 if (_definition === null) { 861 if (_definition === null) {
859 // TODO(johnniwinther): Provide access to the functionSignature of the 862 // TODO(johnniwinther): Provide access to the functionSignature of the
860 // aliased function definition. 863 // aliased function definition.
861 } 864 }
862 return _definition; 865 return _definition;
863 } 866 }
864 867
865 Map<Object, MemberMirror> declaredMembers() => const <MemberMirror>{}; 868 Map<Object, MemberMirror> get declaredMembers() => const <MemberMirror>{};
866 869
867 InterfaceMirror get declaration() => this; 870 InterfaceMirror get declaration() => this;
868 871
869 // TODO(johnniwinther): How should a typedef respond to these? 872 // TODO(johnniwinther): How should a typedef respond to these?
870 InterfaceMirror superclass() => null; 873 InterfaceMirror get superclass() => null;
871 874
872 Map<Object, InterfaceMirror> interfaces() => const <InterfaceMirror>{}; 875 Map<Object, InterfaceMirror> get interfaces() => const <InterfaceMirror>{};
873 876
874 bool get isClass() => false; 877 bool get isClass() => false;
875 878
876 bool get isInterface() => false; 879 bool get isInterface() => false;
877 880
878 bool get isPrivate() => _isPrivate(simpleName()); 881 bool get isPrivate() => _isPrivate(simpleName);
879 882
880 bool get isDeclaration() => true; 883 bool get isDeclaration() => true;
881 884
882 Map<Object, MethodMirror> constructors() => const <MethodMirror>{}; 885 Map<Object, MethodMirror> get constructors() => const <MethodMirror>{};
883 886
884 InterfaceMirror defaultType() => null; 887 InterfaceMirror get defaultType() => null;
885 } 888 }
886 889
887 class Dart2JsTypeVariableMirror extends Dart2JsTypeElementMirror 890 class Dart2JsTypeVariableMirror extends Dart2JsTypeElementMirror
888 implements TypeVariableMirror { 891 implements TypeVariableMirror {
889 final TypeVariableType _typeVariableType; 892 final TypeVariableType _typeVariableType;
890 InterfaceMirror _declarer; 893 InterfaceMirror _declarer;
891 894
892 Dart2JsTypeVariableMirror(Dart2JsMirrorSystem system, 895 Dart2JsTypeVariableMirror(Dart2JsMirrorSystem system,
893 TypeVariableType typeVariableType) 896 TypeVariableType typeVariableType)
894 : this._typeVariableType = typeVariableType, 897 : this._typeVariableType = typeVariableType,
895 super(system, typeVariableType) { 898 super(system, typeVariableType) {
896 assert(_typeVariableType !== null); 899 assert(_typeVariableType !== null);
897 } 900 }
898 901
899 902
900 String qualifiedName() => '${declarer().qualifiedName()}.${simpleName()}'; 903 String get qualifiedName() => '${declarer.qualifiedName}.${simpleName}';
901 904
902 InterfaceMirror declarer() { 905 InterfaceMirror get declarer() {
903 if (_declarer === null) { 906 if (_declarer === null) {
904 if (_typeVariableType.element.enclosingElement.isClass()) { 907 if (_typeVariableType.element.enclosingElement.isClass()) {
905 _declarer = new Dart2JsInterfaceMirror(system, 908 _declarer = new Dart2JsInterfaceMirror(system,
906 _typeVariableType.element.enclosingElement); 909 _typeVariableType.element.enclosingElement);
907 } else if (_typeVariableType.element.enclosingElement.isTypedef()) { 910 } else if (_typeVariableType.element.enclosingElement.isTypedef()) {
908 _declarer = new Dart2JsTypedefMirror(system, 911 _declarer = new Dart2JsTypedefMirror(system,
909 _typeVariableType.element.enclosingElement); 912 _typeVariableType.element.enclosingElement);
910 } 913 }
911 } 914 }
912 return _declarer; 915 return _declarer;
913 } 916 }
914 917
915 LibraryMirror library() => declarer().library(); 918 LibraryMirror get library() => declarer.library;
916 919
917 bool get isObject() => false; 920 bool get isObject() => false;
918 921
919 bool get isDynamic() => false; 922 bool get isDynamic() => false;
920 923
921 bool get isVoid() => false; 924 bool get isVoid() => false;
922 925
923 bool get isTypeVariable() => true; 926 bool get isTypeVariable() => true;
924 927
925 bool get isTypedef() => false; 928 bool get isTypedef() => false;
926 929
927 bool get isFunction() => false; 930 bool get isFunction() => false;
928 931
929 TypeMirror bound() => _convertTypeToTypeMirror( 932 TypeMirror get bound() => _convertTypeToTypeMirror(
930 system, 933 system,
931 _typeVariableType.element.bound, 934 _typeVariableType.element.bound,
932 system.compiler.objectClass.computeType(system.compiler)); 935 system.compiler.objectClass.computeType(system.compiler));
933 936
934 bool operator ==(Object other) { 937 bool operator ==(Object other) {
935 if (this === other) { 938 if (this === other) {
936 return true; 939 return true;
937 } 940 }
938 if (other is! TypeVariableMirror) { 941 if (other is! TypeVariableMirror) {
939 return false; 942 return false;
940 } 943 }
941 if (declarer() != other.declarer()) { 944 if (declarer != other.declarer) {
942 return false; 945 return false;
943 } 946 }
944 return qualifiedName() == other.qualifiedName(); 947 return qualifiedName == other.qualifiedName;
945 } 948 }
946 } 949 }
947 950
948 951
949 //------------------------------------------------------------------------------ 952 //------------------------------------------------------------------------------
950 // Types 953 // Types
951 //------------------------------------------------------------------------------ 954 //------------------------------------------------------------------------------
952 955
953 abstract class Dart2JsTypeElementMirror extends Dart2JsProxyMirror 956 abstract class Dart2JsTypeElementMirror extends Dart2JsProxyMirror
954 implements Dart2JsTypeMirror { 957 implements Dart2JsTypeMirror {
955 final Type _type; 958 final Type _type;
956 959
957 Dart2JsTypeElementMirror(Dart2JsMirrorSystem system, this._type) 960 Dart2JsTypeElementMirror(Dart2JsMirrorSystem system, this._type)
958 : super(system); 961 : super(system);
959 962
960 String simpleName() => _type.name.slowToString(); 963 String get simpleName() => _type.name.slowToString();
961 964
962 String get canonicalName() => simpleName(); 965 String get canonicalName() => simpleName;
963 966
964 Location location() { 967 Location get location() {
965 var script = _type.element.getCompilationUnit().script; 968 var script = _type.element.getCompilationUnit().script;
966 return new Dart2JsLocation(script, 969 return new Dart2JsLocation(script,
967 system.compiler.spanFromElement(_type.element)); 970 system.compiler.spanFromElement(_type.element));
968 } 971 }
969 972
970 LibraryMirror library() { 973 LibraryMirror get library() {
971 return system.getLibrary(_type.element.getLibrary()); 974 return system.getLibrary(_type.element.getLibrary());
972 } 975 }
973 976
974 String toString() => _type.element.toString(); 977 String toString() => _type.element.toString();
975 } 978 }
976 979
977 class Dart2JsInterfaceTypeMirror extends Dart2JsTypeElementMirror 980 class Dart2JsInterfaceTypeMirror extends Dart2JsTypeElementMirror
978 implements InterfaceMirror { 981 implements InterfaceMirror {
979 List<TypeMirror> _typeArguments; 982 List<TypeMirror> _typeArguments;
980 983
981 Dart2JsInterfaceTypeMirror(Dart2JsMirrorSystem system, 984 Dart2JsInterfaceTypeMirror(Dart2JsMirrorSystem system,
982 InterfaceType interfaceType) 985 InterfaceType interfaceType)
983 : super(system, interfaceType); 986 : super(system, interfaceType);
984 987
985 InterfaceType get _interfaceType() => _type; 988 InterfaceType get _interfaceType() => _type;
986 989
987 String qualifiedName() => declaration.qualifiedName(); 990 String get qualifiedName() => declaration.qualifiedName;
988 991
989 // TODO(johnniwinther): Substitute type arguments for type variables. 992 // TODO(johnniwinther): Substitute type arguments for type variables.
990 Map<Object, MemberMirror> declaredMembers() => declaration.declaredMembers(); 993 Map<Object, MemberMirror> get declaredMembers() => declaration.declaredMembers ;
991 994
992 bool get isObject() => system.compiler.objectClass == _type.element; 995 bool get isObject() => system.compiler.objectClass == _type.element;
993 996
994 bool get isDynamic() => system.compiler.dynamicClass == _type.element; 997 bool get isDynamic() => system.compiler.dynamicClass == _type.element;
995 998
996 bool get isTypeVariable() => false; 999 bool get isTypeVariable() => false;
997 1000
998 bool get isVoid() => false; 1001 bool get isVoid() => false;
999 1002
1000 bool get isTypedef() => false; 1003 bool get isTypedef() => false;
1001 1004
1002 bool get isFunction() => false; 1005 bool get isFunction() => false;
1003 1006
1004 InterfaceMirror get declaration() 1007 InterfaceMirror get declaration()
1005 => new Dart2JsInterfaceMirror(system, _type.element); 1008 => new Dart2JsInterfaceMirror(system, _type.element);
1006 1009
1007 // TODO(johnniwinther): Substitute type arguments for type variables. 1010 // TODO(johnniwinther): Substitute type arguments for type variables.
1008 InterfaceMirror superclass() => declaration.superclass(); 1011 InterfaceMirror get superclass() => declaration.superclass;
1009 1012
1010 // TODO(johnniwinther): Substitute type arguments for type variables. 1013 // TODO(johnniwinther): Substitute type arguments for type variables.
1011 Map<Object, InterfaceMirror> interfaces() => declaration.interfaces(); 1014 Map<Object, InterfaceMirror> get interfaces() => declaration.interfaces;
1012 1015
1013 bool get isClass() => declaration.isClass; 1016 bool get isClass() => declaration.isClass;
1014 1017
1015 bool get isInterface() => declaration.isInterface; 1018 bool get isInterface() => declaration.isInterface;
1016 1019
1017 bool get isPrivate() => declaration.isPrivate; 1020 bool get isPrivate() => declaration.isPrivate;
1018 1021
1019 bool get isDeclaration() => false; 1022 bool get isDeclaration() => false;
1020 1023
1021 List<TypeMirror> typeArguments() { 1024 List<TypeMirror> get typeArguments() {
1022 if (_typeArguments == null) { 1025 if (_typeArguments == null) {
1023 _typeArguments = <TypeMirror>[]; 1026 _typeArguments = <TypeMirror>[];
1024 Link<Type> type = _interfaceType.arguments; 1027 Link<Type> type = _interfaceType.arguments;
1025 while (type != null && type.head != null) { 1028 while (type != null && type.head != null) {
1026 _typeArguments.add(_convertTypeToTypeMirror(system, type.head, 1029 _typeArguments.add(_convertTypeToTypeMirror(system, type.head,
1027 system.compiler.dynamicClass.computeType(system.compiler))); 1030 system.compiler.dynamicClass.computeType(system.compiler)));
1028 type = type.tail; 1031 type = type.tail;
1029 } 1032 }
1030 } 1033 }
1031 return _typeArguments; 1034 return _typeArguments;
1032 } 1035 }
1033 1036
1034 List<TypeVariableMirror> typeVariables() => declaration.typeVariables(); 1037 List<TypeVariableMirror> get typeVariables() => declaration.typeVariables;
1035 1038
1036 // TODO(johnniwinther): Substitute type arguments for type variables. 1039 // TODO(johnniwinther): Substitute type arguments for type variables.
1037 Map<Object, MethodMirror> constructors() => declaration.constructors(); 1040 Map<Object, MethodMirror> get constructors() => declaration.constructors;
1038 1041
1039 // TODO(johnniwinther): Substitute type arguments for type variables? 1042 // TODO(johnniwinther): Substitute type arguments for type variables?
1040 InterfaceMirror defaultType() => declaration.defaultType(); 1043 InterfaceMirror get defaultType() => declaration.defaultType;
1041 1044
1042 bool operator ==(Object other) { 1045 bool operator ==(Object other) {
1043 if (this === other) { 1046 if (this === other) {
1044 return true; 1047 return true;
1045 } 1048 }
1046 if (other is! InterfaceMirror) { 1049 if (other is! InterfaceMirror) {
1047 return false; 1050 return false;
1048 } 1051 }
1049 if (other.isDeclaration) { 1052 if (other.isDeclaration) {
1050 return false; 1053 return false;
1051 } 1054 }
1052 if (declaration != other.declaration) { 1055 if (declaration != other.declaration) {
1053 return false; 1056 return false;
1054 } 1057 }
1055 var thisTypeArguments = typeArguments().iterator(); 1058 var thisTypeArguments = typeArguments.iterator();
1056 var otherTypeArguments = other.typeArguments().iterator(); 1059 var otherTypeArguments = other.typeArguments.iterator();
1057 while (thisTypeArguments.hasNext() && otherTypeArguments.hasNext()) { 1060 while (thisTypeArguments.hasNext() && otherTypeArguments.hasNext()) {
1058 if (thisTypeArguments.next() != otherTypeArguments.next()) { 1061 if (thisTypeArguments.next() != otherTypeArguments.next()) {
1059 return false; 1062 return false;
1060 } 1063 }
1061 } 1064 }
1062 return !thisTypeArguments.hasNext() && !otherTypeArguments.hasNext(); 1065 return !thisTypeArguments.hasNext() && !otherTypeArguments.hasNext();
1063 } 1066 }
1064 } 1067 }
1065 1068
1066 1069
1067 class Dart2JsFunctionTypeMirror extends Dart2JsTypeElementMirror 1070 class Dart2JsFunctionTypeMirror extends Dart2JsTypeElementMirror
1068 implements FunctionTypeMirror { 1071 implements FunctionTypeMirror {
1069 final FunctionSignature _functionSignature; 1072 final FunctionSignature _functionSignature;
1070 List<ParameterMirror> _parameters; 1073 List<ParameterMirror> _parameters;
1071 1074
1072 Dart2JsFunctionTypeMirror(Dart2JsMirrorSystem system, 1075 Dart2JsFunctionTypeMirror(Dart2JsMirrorSystem system,
1073 FunctionType functionType, this._functionSignature) 1076 FunctionType functionType, this._functionSignature)
1074 : super(system, functionType) { 1077 : super(system, functionType) {
1075 assert (_functionSignature !== null); 1078 assert (_functionSignature !== null);
1076 } 1079 }
1077 1080
1078 FunctionType get _functionType() => _type; 1081 FunctionType get _functionType() => _type;
1079 1082
1080 // TODO(johnniwinther): Is this the qualified name of a function type? 1083 // TODO(johnniwinther): Is this the qualified name of a function type?
1081 String qualifiedName() => declaration.qualifiedName(); 1084 String get qualifiedName() => declaration.qualifiedName;
1082 1085
1083 // TODO(johnniwinther): Substitute type arguments for type variables. 1086 // TODO(johnniwinther): Substitute type arguments for type variables.
1084 Map<Object, MemberMirror> declaredMembers() { 1087 Map<Object, MemberMirror> get declaredMembers() {
1085 var method = callMethod(); 1088 var method = callMethod;
1086 if (method !== null) { 1089 if (method !== null) {
1087 var map = new Map<String, MemberMirror>.from( 1090 var map = new Map<String, MemberMirror>.from(
1088 declaration.declaredMembers()); 1091 declaration.declaredMembers);
1089 var name = method.qualifiedName(); 1092 var name = method.qualifiedName;
1090 map[name] = method; 1093 map[name] = method;
1091 Function func = null; 1094 Function func = null;
1092 return new ImmutableMapWrapper<Object, MemberMirror>(map); 1095 return new ImmutableMapWrapper<Object, MemberMirror>(map);
1093 } 1096 }
1094 return declaration.declaredMembers(); 1097 return declaration.declaredMembers;
1095 } 1098 }
1096 1099
1097 bool get isObject() => system.compiler.objectClass == _type.element; 1100 bool get isObject() => system.compiler.objectClass == _type.element;
1098 1101
1099 bool get isDynamic() => system.compiler.dynamicClass == _type.element; 1102 bool get isDynamic() => system.compiler.dynamicClass == _type.element;
1100 1103
1101 bool get isVoid() => false; 1104 bool get isVoid() => false;
1102 1105
1103 bool get isTypeVariable() => false; 1106 bool get isTypeVariable() => false;
1104 1107
1105 bool get isTypedef() => false; 1108 bool get isTypedef() => false;
1106 1109
1107 bool get isFunction() => true; 1110 bool get isFunction() => true;
1108 1111
1109 MethodMirror callMethod() => _convertElementMethodToMethodMirror( 1112 MethodMirror get callMethod() => _convertElementMethodToMethodMirror(
1110 system.getLibrary(_functionType.element.getLibrary()), 1113 system.getLibrary(_functionType.element.getLibrary()),
1111 _functionType.element); 1114 _functionType.element);
1112 1115
1113 InterfaceMirror get declaration() 1116 InterfaceMirror get declaration()
1114 => new Dart2JsInterfaceMirror(system, system.compiler.functionClass); 1117 => new Dart2JsInterfaceMirror(system, system.compiler.functionClass);
1115 1118
1116 // TODO(johnniwinther): Substitute type arguments for type variables. 1119 // TODO(johnniwinther): Substitute type arguments for type variables.
1117 InterfaceMirror superclass() => declaration.superclass(); 1120 InterfaceMirror get superclass() => declaration.superclass;
1118 1121
1119 // TODO(johnniwinther): Substitute type arguments for type variables. 1122 // TODO(johnniwinther): Substitute type arguments for type variables.
1120 Map<Object, InterfaceMirror> interfaces() => declaration.interfaces(); 1123 Map<Object, InterfaceMirror> get interfaces() => declaration.interfaces;
1121 1124
1122 bool get isClass() => declaration.isClass; 1125 bool get isClass() => declaration.isClass;
1123 1126
1124 bool get isInterface() => declaration.isInterface; 1127 bool get isInterface() => declaration.isInterface;
1125 1128
1126 bool get isPrivate() => declaration.isPrivate; 1129 bool get isPrivate() => declaration.isPrivate;
1127 1130
1128 bool get isDeclaration() => false; 1131 bool get isDeclaration() => false;
1129 1132
1130 List<TypeMirror> typeArguments() => const <TypeMirror>[]; 1133 List<TypeMirror> get typeArguments() => const <TypeMirror>[];
1131 1134
1132 List<TypeVariableMirror> typeVariables() => declaration.typeVariables(); 1135 List<TypeVariableMirror> get typeVariables() => declaration.typeVariables;
1133 1136
1134 Map<Object, MethodMirror> constructors() => <MethodMirror>{}; 1137 Map<Object, MethodMirror> get constructors() => <MethodMirror>{};
1135 1138
1136 InterfaceMirror defaultType() => null; 1139 InterfaceMirror get defaultType() => null;
1137 1140
1138 TypeMirror returnType() { 1141 TypeMirror get returnType() {
1139 return _convertTypeToTypeMirror(system, _functionType.returnType, 1142 return _convertTypeToTypeMirror(system, _functionType.returnType,
1140 system.compiler.dynamicClass.computeType(system.compiler)); 1143 system.compiler.dynamicClass.computeType(system.compiler));
1141 } 1144 }
1142 1145
1143 List<ParameterMirror> parameters() { 1146 List<ParameterMirror> get parameters() {
1144 if (_parameters === null) { 1147 if (_parameters === null) {
1145 _parameters = _parametersFromFunctionSignature(system, callMethod(), 1148 _parameters = _parametersFromFunctionSignature(system, callMethod,
1146 _functionSignature); 1149 _functionSignature);
1147 } 1150 }
1148 return _parameters; 1151 return _parameters;
1149 } 1152 }
1150 } 1153 }
1151 1154
1152 class Dart2JsVoidMirror extends Dart2JsTypeElementMirror { 1155 class Dart2JsVoidMirror extends Dart2JsTypeElementMirror {
1153 1156
1154 Dart2JsVoidMirror(Dart2JsMirrorSystem system, VoidType voidType) 1157 Dart2JsVoidMirror(Dart2JsMirrorSystem system, VoidType voidType)
1155 : super(system, voidType); 1158 : super(system, voidType);
1156 1159
1157 VoidType get _voidType() => _type; 1160 VoidType get _voidType() => _type;
1158 1161
1159 String qualifiedName() => simpleName(); 1162 String get qualifiedName() => simpleName;
1160 1163
1161 /** 1164 /**
1162 * The void type has no location. 1165 * The void type has no location.
1163 */ 1166 */
1164 Location location() => null; 1167 Location get location() => null;
1165 1168
1166 /** 1169 /**
1167 * The void type has no library. 1170 * The void type has no library.
1168 */ 1171 */
1169 LibraryMirror getLibrary() => null; 1172 LibraryMirror get library() => null;
1170 1173
1171 bool get isObject() => false; 1174 bool get isObject() => false;
1172 1175
1173 bool get isVoid() => true; 1176 bool get isVoid() => true;
1174 1177
1175 bool get isDynamic() => false; 1178 bool get isDynamic() => false;
1176 1179
1177 bool get isTypeVariable() => false; 1180 bool get isTypeVariable() => false;
1178 1181
1179 bool get isTypedef() => false; 1182 bool get isTypedef() => false;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 _canonicalName = _name; 1258 _canonicalName = _name;
1256 } else if (kind == Dart2JsMethodKind.SETTER) { 1259 } else if (kind == Dart2JsMethodKind.SETTER) {
1257 _canonicalName = '$_name='; 1260 _canonicalName = '$_name=';
1258 } else { 1261 } else {
1259 assert(false); 1262 assert(false);
1260 } 1263 }
1261 } 1264 }
1262 1265
1263 FunctionElement get _function() => _element; 1266 FunctionElement get _function() => _element;
1264 1267
1265 String simpleName() => _name; 1268 String get simpleName() => _name;
1266 1269
1267 String qualifiedName() 1270 String get qualifiedName()
1268 => '${surroundingDeclaration().qualifiedName()}.$canonicalName'; 1271 => '${surroundingDeclaration.qualifiedName}.$canonicalName';
1269 1272
1270 String get canonicalName() => _canonicalName; 1273 String get canonicalName() => _canonicalName;
1271 1274
1272 ObjectMirror surroundingDeclaration() => _objectMirror; 1275 ObjectMirror get surroundingDeclaration() => _objectMirror;
1273 1276
1274 bool get isTopLevel() => _objectMirror is LibraryMirror; 1277 bool get isTopLevel() => _objectMirror is LibraryMirror;
1275 1278
1276 bool get isConstructor() 1279 bool get isConstructor()
1277 => _kind == Dart2JsMethodKind.CONSTRUCTOR || isConst || isFactory; 1280 => _kind == Dart2JsMethodKind.CONSTRUCTOR || isConst || isFactory;
1278 1281
1279 bool get isField() => false; 1282 bool get isField() => false;
1280 1283
1281 bool get isMethod() => !isConstructor; 1284 bool get isMethod() => !isConstructor;
1282 1285
1283 bool get isPrivate() => _isPrivate(simpleName()); 1286 bool get isPrivate() => _isPrivate(simpleName);
1284 1287
1285 bool get isStatic() => 1288 bool get isStatic() =>
1286 _function.modifiers !== null && _function.modifiers.isStatic(); 1289 _function.modifiers !== null && _function.modifiers.isStatic();
1287 1290
1288 List<ParameterMirror> parameters() { 1291 List<ParameterMirror> get parameters() {
1289 return _parametersFromFunctionSignature(system, this, 1292 return _parametersFromFunctionSignature(system, this,
1290 _function.computeSignature(system.compiler)); 1293 _function.computeSignature(system.compiler));
1291 } 1294 }
1292 1295
1293 TypeMirror returnType() => _convertTypeToTypeMirror( 1296 TypeMirror get returnType() => _convertTypeToTypeMirror(
1294 system, _function.computeSignature(system.compiler).returnType, 1297 system, _function.computeSignature(system.compiler).returnType,
1295 system.compiler.dynamicClass.computeType(system.compiler)); 1298 system.compiler.dynamicClass.computeType(system.compiler));
1296 1299
1297 bool get isConst() => _kind == Dart2JsMethodKind.CONST; 1300 bool get isConst() => _kind == Dart2JsMethodKind.CONST;
1298 1301
1299 bool get isFactory() => _kind == Dart2JsMethodKind.FACTORY; 1302 bool get isFactory() => _kind == Dart2JsMethodKind.FACTORY;
1300 1303
1301 String get constructorName() => _constructorName; 1304 String get constructorName() => _constructorName;
1302 1305
1303 bool get isGetter() => _kind == Dart2JsMethodKind.GETTER; 1306 bool get isGetter() => _kind == Dart2JsMethodKind.GETTER;
1304 1307
1305 bool get isSetter() => _kind == Dart2JsMethodKind.SETTER; 1308 bool get isSetter() => _kind == Dart2JsMethodKind.SETTER;
1306 1309
1307 bool get isOperator() => _kind == Dart2JsMethodKind.OPERATOR; 1310 bool get isOperator() => _kind == Dart2JsMethodKind.OPERATOR;
1308 1311
1309 String get operatorName() => _operatorName; 1312 String get operatorName() => _operatorName;
1310 1313
1311 Location location() { 1314 Location get location() {
1312 var node = _function.parseNode(_diagnosticListener); 1315 var node = _function.parseNode(_diagnosticListener);
1313 if (node !== null) { 1316 if (node !== null) {
1314 var script = _function.getCompilationUnit().script; 1317 var script = _function.getCompilationUnit().script;
1315 var span = system.compiler.spanFromNode(node, script.uri); 1318 var span = system.compiler.spanFromNode(node, script.uri);
1316 return new Dart2JsLocation(script, span); 1319 return new Dart2JsLocation(script, span);
1317 } 1320 }
1318 return super.location(); 1321 return super.location;
1319 } 1322 }
1320 1323
1321 } 1324 }
1322 1325
1323 class Dart2JsFieldMirror extends Dart2JsElementMirror 1326 class Dart2JsFieldMirror extends Dart2JsElementMirror
1324 implements Dart2JsMemberMirror, FieldMirror { 1327 implements Dart2JsMemberMirror, FieldMirror {
1325 Dart2JsObjectMirror _objectMirror; 1328 Dart2JsObjectMirror _objectMirror;
1326 VariableElement _variable; 1329 VariableElement _variable;
1327 1330
1328 Dart2JsFieldMirror(Dart2JsObjectMirror objectMirror, 1331 Dart2JsFieldMirror(Dart2JsObjectMirror objectMirror,
1329 VariableElement variable) 1332 VariableElement variable)
1330 : this._objectMirror = objectMirror, 1333 : this._objectMirror = objectMirror,
1331 this._variable = variable, 1334 this._variable = variable,
1332 super(objectMirror.system, variable); 1335 super(objectMirror.system, variable);
1333 1336
1334 String qualifiedName() 1337 String get qualifiedName()
1335 => '${surroundingDeclaration().qualifiedName()}.$canonicalName'; 1338 => '${surroundingDeclaration.qualifiedName}.$canonicalName';
1336 1339
1337 String get canonicalName() => simpleName(); 1340 String get canonicalName() => simpleName;
1338 1341
1339 ObjectMirror surroundingDeclaration() => _objectMirror; 1342 ObjectMirror get surroundingDeclaration() => _objectMirror;
1340 1343
1341 bool get isTopLevel() => _objectMirror is LibraryMirror; 1344 bool get isTopLevel() => _objectMirror is LibraryMirror;
1342 1345
1343 bool get isConstructor() => false; 1346 bool get isConstructor() => false;
1344 1347
1345 bool get isField() => true; 1348 bool get isField() => true;
1346 1349
1347 bool get isMethod() => false; 1350 bool get isMethod() => false;
1348 1351
1349 bool get isPrivate() => _isPrivate(simpleName()); 1352 bool get isPrivate() => _isPrivate(simpleName);
1350 1353
1351 bool get isStatic() => _variable.modifiers.isStatic(); 1354 bool get isStatic() => _variable.modifiers.isStatic();
1352 1355
1353 bool get isFinal() => _variable.modifiers.isFinal(); 1356 bool get isFinal() => _variable.modifiers.isFinal();
1354 1357
1355 TypeMirror type() => _convertTypeToTypeMirror(system, 1358 TypeMirror get type() => _convertTypeToTypeMirror(system,
1356 _variable.computeType(system.compiler), 1359 _variable.computeType(system.compiler),
1357 system.compiler.dynamicClass.computeType(system.compiler)); 1360 system.compiler.dynamicClass.computeType(system.compiler));
1358 1361
1359 Location location() { 1362 Location get location() {
1360 var script = _variable.getCompilationUnit().script; 1363 var script = _variable.getCompilationUnit().script;
1361 var node = _variable.variables.parseNode(_diagnosticListener); 1364 var node = _variable.variables.parseNode(_diagnosticListener);
1362 if (node !== null) { 1365 if (node !== null) {
1363 var span = system.compiler.spanFromNode(node, script.uri); 1366 var span = system.compiler.spanFromNode(node, script.uri);
1364 return new Dart2JsLocation(script, span); 1367 return new Dart2JsLocation(script, span);
1365 } else { 1368 } else {
1366 var span = system.compiler.spanFromElement(_variable); 1369 var span = system.compiler.spanFromElement(_variable);
1367 return new Dart2JsLocation(script, span); 1370 return new Dart2JsLocation(script, span);
1368 } 1371 }
1369 } 1372 }
1370 } 1373 }
1371 1374
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698