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

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

Issue 10832136: Skeleton typedef type implementation (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased and updated cf. comments 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
« no previous file with comments | « lib/compiler/implementation/typechecker.dart ('k') | tests/co19/co19-dart2js.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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('../../../lib/compiler/compiler.dart', prefix: 'diagnostics'); 7 #import('../../../lib/compiler/compiler.dart', prefix: 'diagnostics');
8 #import('../../../lib/compiler/implementation/elements/elements.dart'); 8 #import('../../../lib/compiler/implementation/elements/elements.dart');
9 #import('../../../lib/compiler/implementation/apiimpl.dart', prefix: 'api'); 9 #import('../../../lib/compiler/implementation/apiimpl.dart', prefix: 'api');
10 #import('../../../lib/compiler/implementation/scanner/scannerlib.dart'); 10 #import('../../../lib/compiler/implementation/scanner/scannerlib.dart');
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 Type type, 54 Type type,
55 InterfaceType defaultType, 55 InterfaceType defaultType,
56 [FunctionSignature functionSignature]) { 56 [FunctionSignature functionSignature]) {
57 if (type === null) { 57 if (type === null) {
58 return new Dart2JsInterfaceTypeMirror(system, defaultType); 58 return new Dart2JsInterfaceTypeMirror(system, defaultType);
59 } else if (type is InterfaceType) { 59 } else if (type is InterfaceType) {
60 return new Dart2JsInterfaceTypeMirror(system, type); 60 return new Dart2JsInterfaceTypeMirror(system, type);
61 } else if (type is TypeVariableType) { 61 } else if (type is TypeVariableType) {
62 return new Dart2JsTypeVariableMirror(system, type); 62 return new Dart2JsTypeVariableMirror(system, type);
63 } else if (type is FunctionType) { 63 } else if (type is FunctionType) {
64 if (type.element is TypedefElement) { 64 return new Dart2JsFunctionTypeMirror(system, type, functionSignature);
65 return new Dart2JsTypedefMirror(system, type.element);
66 } else {
67 return new Dart2JsFunctionTypeMirror(system, type, functionSignature);
68 }
69 } else if (type is VoidType) { 65 } else if (type is VoidType) {
70 return new Dart2JsVoidMirror(system, type); 66 return new Dart2JsVoidMirror(system, type);
67 } else if (type is TypedefType) {
68 return new Dart2JsTypedefMirror(system, type);
71 } 69 }
72 throw new IllegalArgumentException("Unexpected interface type $type"); 70 throw new IllegalArgumentException("Unexpected interface type $type");
73 } 71 }
74 72
75 Collection<Dart2JsMemberMirror> _convertElementMemberToMemberMirrors( 73 Collection<Dart2JsMemberMirror> _convertElementMemberToMemberMirrors(
76 Dart2JsObjectMirror library, Element element) { 74 Dart2JsObjectMirror library, Element element) {
77 if (element is SynthesizedConstructorElement) { 75 if (element is SynthesizedConstructorElement) {
78 return const <Dart2JsMemberMirror>[]; 76 return const <Dart2JsMemberMirror>[];
79 } else if (element is VariableElement) { 77 } else if (element is VariableElement) {
80 return <Dart2JsMemberMirror>[new Dart2JsFieldMirror(library, element)]; 78 return <Dart2JsMemberMirror>[new Dart2JsFieldMirror(library, element)];
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 void _ensureTypes() { 491 void _ensureTypes() {
494 if (_types == null) { 492 if (_types == null) {
495 _types = <String, InterfaceMirror>{}; 493 _types = <String, InterfaceMirror>{};
496 _library.forEachExport((Element e) { 494 _library.forEachExport((Element e) {
497 if (e.getLibrary() == _library) { 495 if (e.getLibrary() == _library) {
498 if (e.isClass()) { 496 if (e.isClass()) {
499 e.ensureResolved(system.compiler); 497 e.ensureResolved(system.compiler);
500 var type = new Dart2JsInterfaceMirror.fromLibrary(this, e); 498 var type = new Dart2JsInterfaceMirror.fromLibrary(this, e);
501 _types[type.canonicalName] = type; 499 _types[type.canonicalName] = type;
502 } else if (e.isTypedef()) { 500 } else if (e.isTypedef()) {
503 var type = new Dart2JsTypedefMirror.fromLibrary(this, e); 501 var type = new Dart2JsTypedefMirror.fromLibrary(this,
502 e.computeType(system.compiler));
504 _types[type.canonicalName] = type; 503 _types[type.canonicalName] = type;
505 } 504 }
506 } 505 }
507 }); 506 });
508 } 507 }
509 } 508 }
510 509
511 void _ensureMembers() { 510 void _ensureMembers() {
512 if (_members == null) { 511 if (_members == null) {
513 _members = <String, MemberMirror>{}; 512 _members = <String, MemberMirror>{};
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 if (library != other.library) { 777 if (library != other.library) {
779 return false; 778 return false;
780 } 779 }
781 if (isDeclaration !== other.isDeclaration) { 780 if (isDeclaration !== other.isDeclaration) {
782 return false; 781 return false;
783 } 782 }
784 return qualifiedName == other.qualifiedName; 783 return qualifiedName == other.qualifiedName;
785 } 784 }
786 } 785 }
787 786
788 class Dart2JsTypedefMirror extends Dart2JsElementMirror 787 class Dart2JsTypedefMirror extends Dart2JsTypeElementMirror
789 implements Dart2JsTypeMirror, TypedefMirror { 788 implements Dart2JsTypeMirror, TypedefMirror {
790 final Dart2JsLibraryMirror _library; 789 final Dart2JsLibraryMirror _library;
791 List<TypeVariableMirror> _typeVariables; 790 List<TypeVariableMirror> _typeVariables;
792 TypeMirror _definition; 791 TypeMirror _definition;
793 792
794 Dart2JsTypedefMirror(Dart2JsMirrorSystem system, TypedefElement _typedef) 793 Dart2JsTypedefMirror(Dart2JsMirrorSystem system, TypedefType _typedef)
795 : this._library = system.getLibrary(_typedef.getLibrary()), 794 : this._library = system.getLibrary(_typedef.element.getLibrary()),
796 super(system, _typedef); 795 super(system, _typedef);
797 796
798 Dart2JsTypedefMirror.fromLibrary(Dart2JsLibraryMirror library, 797 Dart2JsTypedefMirror.fromLibrary(Dart2JsLibraryMirror library,
799 TypedefElement _typedef) 798 TypedefType _typedef)
800 : this._library = library, 799 : this._library = library,
801 super(library.system, _typedef); 800 super(library.system, _typedef);
802 801
803 TypedefElement get _typedef() => _element; 802 TypedefType get _typedef() => _type;
804 803
805 String get canonicalName() => simpleName; 804 String get canonicalName() => simpleName;
806 805
807 String get qualifiedName() => '${library.qualifiedName}.${simpleName}'; 806 String get qualifiedName() => '${library.qualifiedName}.${simpleName}';
808 807
809 Location get location() { 808 Location get location() {
810 var node = _typedef.parseNode(_diagnosticListener); 809 var node = _typedef.element.parseNode(_diagnosticListener);
811 if (node !== null) { 810 if (node !== null) {
812 var script = _typedef.getCompilationUnit().script; 811 var script = _typedef.element.getCompilationUnit().script;
813 var span = system.compiler.spanFromNode(node, script.uri); 812 var span = system.compiler.spanFromNode(node, script.uri);
814 return new Dart2JsLocation(script, span); 813 return new Dart2JsLocation(script, span);
815 } 814 }
816 return super.location; 815 return super.location;
817 } 816 }
818 817
819 LibraryMirror get library() => _library; 818 LibraryMirror get library() => _library;
820 819
821 bool get isObject() => false; 820 bool get isObject() => false;
822 821
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 891
893 String get qualifiedName() => '${declarer.qualifiedName}.${simpleName}'; 892 String get qualifiedName() => '${declarer.qualifiedName}.${simpleName}';
894 893
895 InterfaceMirror get declarer() { 894 InterfaceMirror get declarer() {
896 if (_declarer === null) { 895 if (_declarer === null) {
897 if (_typeVariableType.element.enclosingElement.isClass()) { 896 if (_typeVariableType.element.enclosingElement.isClass()) {
898 _declarer = new Dart2JsInterfaceMirror(system, 897 _declarer = new Dart2JsInterfaceMirror(system,
899 _typeVariableType.element.enclosingElement); 898 _typeVariableType.element.enclosingElement);
900 } else if (_typeVariableType.element.enclosingElement.isTypedef()) { 899 } else if (_typeVariableType.element.enclosingElement.isTypedef()) {
901 _declarer = new Dart2JsTypedefMirror(system, 900 _declarer = new Dart2JsTypedefMirror(system,
902 _typeVariableType.element.enclosingElement); 901 _typeVariableType.element.enclosingElement.computeType(
902 system.compiler));
903 } 903 }
904 } 904 }
905 return _declarer; 905 return _declarer;
906 } 906 }
907 907
908 LibraryMirror get library() => declarer.library; 908 LibraryMirror get library() => declarer.library;
909 909
910 bool get isObject() => false; 910 bool get isObject() => false;
911 911
912 bool get isDynamic() => false; 912 bool get isDynamic() => false;
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 if (node !== null) { 1361 if (node !== null) {
1362 var span = system.compiler.spanFromNode(node, script.uri); 1362 var span = system.compiler.spanFromNode(node, script.uri);
1363 return new Dart2JsLocation(script, span); 1363 return new Dart2JsLocation(script, span);
1364 } else { 1364 } else {
1365 var span = system.compiler.spanFromElement(_variable); 1365 var span = system.compiler.spanFromElement(_variable);
1366 return new Dart2JsLocation(script, span); 1366 return new Dart2JsLocation(script, span);
1367 } 1367 }
1368 } 1368 }
1369 } 1369 }
1370 1370
OLDNEW
« no previous file with comments | « lib/compiler/implementation/typechecker.dart ('k') | tests/co19/co19-dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698