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

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

Issue 10854191: Require two type arguments for map literals (issue 4522). (Closed) Base URL: http://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
« no previous file with comments | « pkg/dartdoc/markdown.dart ('k') | pkg/logging/logging.dart » ('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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 throw message; 310 throw message;
311 } else if (fatal) { 311 } else if (fatal) {
312 SourceFile file = sourceFiles[uri.toString()]; 312 SourceFile file = sourceFiles[uri.toString()];
313 print(file.getLocationMessage(message, begin, end, true, (s) => s)); 313 print(file.getLocationMessage(message, begin, end, true, (s) => s));
314 throw message; 314 throw message;
315 } 315 }
316 } 316 }
317 317
318 Dart2JsCompilation(Path script, Path libraryRoot, 318 Dart2JsCompilation(Path script, Path libraryRoot,
319 [Path packageRoot, List<String> opts = const <String>[]]) 319 [Path packageRoot, List<String> opts = const <String>[]])
320 : cwd = getCurrentDirectory(), sourceFiles = <SourceFile>{} { 320 : cwd = getCurrentDirectory(), sourceFiles = <String, SourceFile>{} {
321 var libraryUri = cwd.resolve(libraryRoot.toString()); 321 var libraryUri = cwd.resolve(libraryRoot.toString());
322 var packageUri; 322 var packageUri;
323 if (packageRoot !== null) { 323 if (packageRoot !== null) {
324 packageUri = cwd.resolve(packageRoot.toString()); 324 packageUri = cwd.resolve(packageRoot.toString());
325 } else { 325 } else {
326 packageUri = libraryUri; 326 packageUri = libraryUri;
327 } 327 }
328 _compiler = new api.Compiler(provider, handler, 328 _compiler = new api.Compiler(provider, handler,
329 libraryUri, packageUri, <String>[]); 329 libraryUri, packageUri, <String>[]);
330 var scriptUri = cwd.resolve(script.toString()); 330 var scriptUri = cwd.resolve(script.toString());
331 // TODO(johnniwinther): Detect file not found 331 // TODO(johnniwinther): Detect file not found
332 _compiler.run(scriptUri); 332 _compiler.run(scriptUri);
333 } 333 }
334 334
335 Dart2JsCompilation.library(List<Path> libraries, Path libraryRoot, 335 Dart2JsCompilation.library(List<Path> libraries, Path libraryRoot,
336 [Path packageRoot, List<String> opts = const <String>[]]) 336 [Path packageRoot, List<String> opts = const <String>[]])
337 : cwd = getCurrentDirectory(), sourceFiles = <SourceFile>{} { 337 : cwd = getCurrentDirectory(), sourceFiles = <String, SourceFile>{} {
338 var libraryUri = cwd.resolve(libraryRoot.toString()); 338 var libraryUri = cwd.resolve(libraryRoot.toString());
339 var packageUri; 339 var packageUri;
340 if (packageRoot !== null) { 340 if (packageRoot !== null) {
341 packageUri = cwd.resolve(packageRoot.toString()); 341 packageUri = cwd.resolve(packageRoot.toString());
342 } else { 342 } else {
343 packageUri = libraryUri; 343 packageUri = libraryUri;
344 } 344 }
345 _compiler = new LibraryCompiler(provider, handler, 345 _compiler = new LibraryCompiler(provider, handler,
346 libraryUri, packageUri, <String>[]); 346 libraryUri, packageUri, <String>[]);
347 var librariesUri = <Uri>[]; 347 var librariesUri = <Uri>[];
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 class Dart2JsMirrorSystem implements MirrorSystem, Dart2JsMirror { 419 class Dart2JsMirrorSystem implements MirrorSystem, Dart2JsMirror {
420 final api.Compiler compiler; 420 final api.Compiler compiler;
421 Map<String, Dart2JsLibraryMirror> _libraries; 421 Map<String, Dart2JsLibraryMirror> _libraries;
422 Map<LibraryElement, Dart2JsLibraryMirror> _libraryMap; 422 Map<LibraryElement, Dart2JsLibraryMirror> _libraryMap;
423 423
424 Dart2JsMirrorSystem(this.compiler) 424 Dart2JsMirrorSystem(this.compiler)
425 : _libraryMap = new Map<LibraryElement, Dart2JsLibraryMirror>(); 425 : _libraryMap = new Map<LibraryElement, Dart2JsLibraryMirror>();
426 426
427 void _ensureLibraries() { 427 void _ensureLibraries() {
428 if (_libraries == null) { 428 if (_libraries == null) {
429 _libraries = <Dart2JsLibraryMirror>{}; 429 _libraries = <String, Dart2JsLibraryMirror>{};
430 compiler.libraries.forEach((_, LibraryElement v) { 430 compiler.libraries.forEach((_, LibraryElement v) {
431 var mirror = new Dart2JsLibraryMirror(system, v); 431 var mirror = new Dart2JsLibraryMirror(system, v);
432 _libraries[mirror.canonicalName] = mirror; 432 _libraries[mirror.canonicalName] = mirror;
433 _libraryMap[v] = mirror; 433 _libraryMap[v] = mirror;
434 }); 434 });
435 } 435 }
436 } 436 }
437 437
438 Map<Object, LibraryMirror> get libraries() { 438 Map<Object, LibraryMirror> get libraries() {
439 _ensureLibraries(); 439 _ensureLibraries();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 // Use the file name as script name. 487 // Use the file name as script name.
488 String path = _library.uri.path; 488 String path = _library.uri.path;
489 return path.substring(path.lastIndexOf('/') + 1); 489 return path.substring(path.lastIndexOf('/') + 1);
490 } 490 }
491 } 491 }
492 492
493 String get qualifiedName() => simpleName; 493 String get qualifiedName() => simpleName;
494 494
495 void _ensureTypes() { 495 void _ensureTypes() {
496 if (_types == null) { 496 if (_types == null) {
497 _types = <InterfaceMirror>{}; 497 _types = <String, InterfaceMirror>{};
498 _library.forEachExport((Element e) { 498 _library.forEachExport((Element e) {
499 if (e.getLibrary() == _library) { 499 if (e.getLibrary() == _library) {
500 if (e.isClass()) { 500 if (e.isClass()) {
501 e.ensureResolved(system.compiler); 501 e.ensureResolved(system.compiler);
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()) {
505 var type = new Dart2JsTypedefMirror.fromLibrary(this, e); 505 var type = new Dart2JsTypedefMirror.fromLibrary(this, e);
506 _types[type.canonicalName] = type; 506 _types[type.canonicalName] = type;
507 } 507 }
508 } 508 }
509 }); 509 });
510 } 510 }
511 } 511 }
512 512
513 void _ensureMembers() { 513 void _ensureMembers() {
514 if (_members == null) { 514 if (_members == null) {
515 _members = <MemberMirror>{}; 515 _members = <String, MemberMirror>{};
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
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 var script = _class.getCompilationUnit().script; 675 var script = _class.getCompilationUnit().script;
676 var span = system.compiler.spanFromNode(node, script.uri); 676 var span = system.compiler.spanFromNode(node, script.uri);
677 return new Dart2JsLocation(script, span); 677 return new Dart2JsLocation(script, span);
678 } 678 }
679 } 679 }
680 return super.location; 680 return super.location;
681 } 681 }
682 682
683 void _ensureMembers() { 683 void _ensureMembers() {
684 if (_members == null) { 684 if (_members == null) {
685 _members = <Dart2JsMemberMirror>{}; 685 _members = <String, Dart2JsMemberMirror>{};
686 _class.localMembers.forEach((e) { 686 _class.localMembers.forEach((e) {
687 for (var member in _convertElementMemberToMemberMirrors(this, e)) { 687 for (var member in _convertElementMemberToMemberMirrors(this, e)) {
688 _members[member.canonicalName] = member; 688 _members[member.canonicalName] = member;
689 } 689 }
690 }); 690 });
691 } 691 }
692 } 692 }
693 693
694 Map<Object, MemberMirror> get declaredMembers() { 694 Map<Object, MemberMirror> get declaredMembers() {
695 _ensureMembers(); 695 _ensureMembers();
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 } 847 }
848 848
849 TypeMirror get definition() { 849 TypeMirror get definition() {
850 if (_definition === null) { 850 if (_definition === null) {
851 // TODO(johnniwinther): Provide access to the functionSignature of the 851 // TODO(johnniwinther): Provide access to the functionSignature of the
852 // aliased function definition. 852 // aliased function definition.
853 } 853 }
854 return _definition; 854 return _definition;
855 } 855 }
856 856
857 Map<Object, MemberMirror> get declaredMembers() => const <MemberMirror>{}; 857 Map<Object, MemberMirror> get declaredMembers() =>
858 const <String, MemberMirror>{};
858 859
859 InterfaceMirror get declaration() => this; 860 InterfaceMirror get declaration() => this;
860 861
861 // TODO(johnniwinther): How should a typedef respond to these? 862 // TODO(johnniwinther): How should a typedef respond to these?
862 InterfaceMirror get superclass() => null; 863 InterfaceMirror get superclass() => null;
863 864
864 Map<Object, InterfaceMirror> get interfaces() => const <InterfaceMirror>{}; 865 Map<Object, InterfaceMirror> get interfaces() =>
866 const <String, InterfaceMirror>{};
865 867
866 bool get isClass() => false; 868 bool get isClass() => false;
867 869
868 bool get isInterface() => false; 870 bool get isInterface() => false;
869 871
870 bool get isPrivate() => _isPrivate(simpleName); 872 bool get isPrivate() => _isPrivate(simpleName);
871 873
872 bool get isDeclaration() => true; 874 bool get isDeclaration() => true;
873 875
874 Map<Object, MethodMirror> get constructors() => const <MethodMirror>{}; 876 Map<Object, MethodMirror> get constructors() =>
877 const <String, MethodMirror>{};
875 878
876 InterfaceMirror get defaultType() => null; 879 InterfaceMirror get defaultType() => null;
877 } 880 }
878 881
879 class Dart2JsTypeVariableMirror extends Dart2JsTypeElementMirror 882 class Dart2JsTypeVariableMirror extends Dart2JsTypeElementMirror
880 implements TypeVariableMirror { 883 implements TypeVariableMirror {
881 final TypeVariableType _typeVariableType; 884 final TypeVariableType _typeVariableType;
882 InterfaceMirror _declarer; 885 InterfaceMirror _declarer;
883 886
884 Dart2JsTypeVariableMirror(Dart2JsMirrorSystem system, 887 Dart2JsTypeVariableMirror(Dart2JsMirrorSystem system,
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 bool get isInterface() => declaration.isInterface; 1119 bool get isInterface() => declaration.isInterface;
1117 1120
1118 bool get isPrivate() => declaration.isPrivate; 1121 bool get isPrivate() => declaration.isPrivate;
1119 1122
1120 bool get isDeclaration() => false; 1123 bool get isDeclaration() => false;
1121 1124
1122 List<TypeMirror> get typeArguments() => const <TypeMirror>[]; 1125 List<TypeMirror> get typeArguments() => const <TypeMirror>[];
1123 1126
1124 List<TypeVariableMirror> get typeVariables() => declaration.typeVariables; 1127 List<TypeVariableMirror> get typeVariables() => declaration.typeVariables;
1125 1128
1126 Map<Object, MethodMirror> get constructors() => <MethodMirror>{}; 1129 Map<Object, MethodMirror> get constructors() =>
1130 <String, MethodMirror>{};
1127 1131
1128 InterfaceMirror get defaultType() => null; 1132 InterfaceMirror get defaultType() => null;
1129 1133
1130 TypeMirror get returnType() { 1134 TypeMirror get returnType() {
1131 return _convertTypeToTypeMirror(system, _functionType.returnType, 1135 return _convertTypeToTypeMirror(system, _functionType.returnType,
1132 system.compiler.dynamicClass.computeType(system.compiler)); 1136 system.compiler.dynamicClass.computeType(system.compiler));
1133 } 1137 }
1134 1138
1135 List<ParameterMirror> get parameters() { 1139 List<ParameterMirror> get parameters() {
1136 if (_parameters === null) { 1140 if (_parameters === null) {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 if (node !== null) { 1358 if (node !== null) {
1355 var span = system.compiler.spanFromNode(node, script.uri); 1359 var span = system.compiler.spanFromNode(node, script.uri);
1356 return new Dart2JsLocation(script, span); 1360 return new Dart2JsLocation(script, span);
1357 } else { 1361 } else {
1358 var span = system.compiler.spanFromElement(_variable); 1362 var span = system.compiler.spanFromElement(_variable);
1359 return new Dart2JsLocation(script, span); 1363 return new Dart2JsLocation(script, span);
1360 } 1364 }
1361 } 1365 }
1362 } 1366 }
1363 1367
OLDNEW
« no previous file with comments | « pkg/dartdoc/markdown.dart ('k') | pkg/logging/logging.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698