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

Side by Side Diff: pkg/compiler/lib/src/library_loader.dart

Issue 1132783002: Add Accessor, Getter, and Setter elements. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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 dart2js.library_loader; 5 library dart2js.library_loader;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'dart2jslib.dart' show 9 import 'dart2jslib.dart' show
10 Compiler, 10 Compiler,
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 }); 364 });
365 } 365 }
366 366
367 /** 367 /**
368 * Processes the library tags in [library]. 368 * Processes the library tags in [library].
369 * 369 *
370 * The imported/exported libraries are loaded and processed recursively but 370 * The imported/exported libraries are loaded and processed recursively but
371 * the import/export scopes are not set up. 371 * the import/export scopes are not set up.
372 */ 372 */
373 Future processLibraryTags(LibraryDependencyHandler handler, 373 Future processLibraryTags(LibraryDependencyHandler handler,
374 LibraryElement library) { 374 LibraryElementX library) {
375 TagState tagState = new TagState(); 375 TagState tagState = new TagState();
376 376
377 bool importsDartCore = false; 377 bool importsDartCore = false;
378 var libraryDependencies = new LinkBuilder<LibraryDependency>(); 378 var libraryDependencies = new LinkBuilder<LibraryDependency>();
379 Uri base = library.entryCompilationUnit.script.readableUri; 379 Uri base = library.entryCompilationUnit.script.readableUri;
380 380
381 return Future.forEach(library.tags, (LibraryTag tag) { 381 return Future.forEach(library.tags, (LibraryTag tag) {
382 return compiler.withCurrentElement(library, () { 382 return compiler.withCurrentElement(library, () {
383 if (tag.isImport) { 383 if (tag.isImport) {
384 Import import = tag; 384 Import import = tag;
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 */ 642 */
643 class ImportLink { 643 class ImportLink {
644 final Import import; 644 final Import import;
645 final LibraryElement importedLibrary; 645 final LibraryElement importedLibrary;
646 646
647 ImportLink(this.import, this.importedLibrary); 647 ImportLink(this.import, this.importedLibrary);
648 648
649 /** 649 /**
650 * Imports the library into the [importingLibrary]. 650 * Imports the library into the [importingLibrary].
651 */ 651 */
652 void importLibrary(Compiler compiler, LibraryElement importingLibrary) { 652 void importLibrary(Compiler compiler, LibraryElementX importingLibrary) {
653 assert(invariant(importingLibrary, 653 assert(invariant(importingLibrary,
654 importedLibrary.exportsHandled, 654 importedLibrary.exportsHandled,
655 message: 'Exports not handled on $importedLibrary')); 655 message: 'Exports not handled on $importedLibrary'));
656 var combinatorFilter = new CombinatorFilter.fromTag(import); 656 var combinatorFilter = new CombinatorFilter.fromTag(import);
657 if (import != null && import.prefix != null) { 657 if (import != null && import.prefix != null) {
658 String prefix = import.prefix.source; 658 String prefix = import.prefix.source;
659 Element existingElement = importingLibrary.find(prefix); 659 Element existingElement = importingLibrary.find(prefix);
660 PrefixElement prefixElement; 660 PrefixElement prefixElement;
661 if (existingElement == null || !existingElement.isPrefix) { 661 if (existingElement == null || !existingElement.isPrefix) {
662 prefixElement = new PrefixElementX(prefix, 662 prefixElement = new PrefixElementX(prefix,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 } 715 }
716 716
717 /** 717 /**
718 * A node in the library dependency graph. 718 * A node in the library dependency graph.
719 * 719 *
720 * This class is used to collect the library dependencies expressed through 720 * This class is used to collect the library dependencies expressed through
721 * import and export tags, and as the work-list entry in computations of library 721 * import and export tags, and as the work-list entry in computations of library
722 * exports performed in [LibraryDependencyHandler.computeExports]. 722 * exports performed in [LibraryDependencyHandler.computeExports].
723 */ 723 */
724 class LibraryDependencyNode { 724 class LibraryDependencyNode {
725 final LibraryElement library; 725 final LibraryElementX library;
726 726
727 // TODO(ahe): Remove [hashCodeCounter] and [hashCode] when 727 // TODO(ahe): Remove [hashCodeCounter] and [hashCode] when
728 // VM implementation of Object.hashCode is not slow. 728 // VM implementation of Object.hashCode is not slow.
729 final int hashCode = ++hashCodeCounter; 729 final int hashCode = ++hashCodeCounter;
730 static int hashCodeCounter = 0; 730 static int hashCodeCounter = 0;
731 731
732 732
733 /** 733 /**
734 * A linked list of the import tags that import [library] mapped to the 734 * A linked list of the import tags that import [library] mapped to the
735 * corresponding libraries. This is used to propagate exports into imports 735 * corresponding libraries. This is used to propagate exports into imports
(...skipping 22 matching lines...) Expand all
758 758
759 /** 759 /**
760 * The set of exported elements that need to be propageted to dependent 760 * The set of exported elements that need to be propageted to dependent
761 * libraries as part of the work-list computation performed in 761 * libraries as part of the work-list computation performed in
762 * [LibraryDependencyHandler.computeExports]. Each export element is mapped 762 * [LibraryDependencyHandler.computeExports]. Each export element is mapped
763 * to a list of exports directives that export it. 763 * to a list of exports directives that export it.
764 */ 764 */
765 Map<Element, Link<Export>> pendingExportMap = 765 Map<Element, Link<Export>> pendingExportMap =
766 new Map<Element, Link<Export>>(); 766 new Map<Element, Link<Export>>();
767 767
768 LibraryDependencyNode(LibraryElement this.library); 768 LibraryDependencyNode(this.library);
769 769
770 /** 770 /**
771 * Registers that the library of this node imports [importLibrary] through the 771 * Registers that the library of this node imports [importLibrary] through the
772 * [import] tag. 772 * [import] tag.
773 */ 773 */
774 void registerImportDependency(Import import, 774 void registerImportDependency(Import import,
775 LibraryElement importedLibrary) { 775 LibraryElement importedLibrary) {
776 imports = imports.prepend(new ImportLink(import, importedLibrary)); 776 imports = imports.prepend(new ImportLink(import, importedLibrary));
777 } 777 }
778 778
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 1008
1009 // Setup import scopes. 1009 // Setup import scopes.
1010 nodeMap.forEach((LibraryElement library, LibraryDependencyNode node) { 1010 nodeMap.forEach((LibraryElement library, LibraryDependencyNode node) {
1011 node.registerImports(compiler); 1011 node.registerImports(compiler);
1012 }); 1012 });
1013 } 1013 }
1014 1014
1015 /** 1015 /**
1016 * Registers that [library] depends on [loadedLibrary] through [tag]. 1016 * Registers that [library] depends on [loadedLibrary] through [tag].
1017 */ 1017 */
1018 void registerDependency(LibraryElement library, 1018 void registerDependency(LibraryElementX library,
1019 LibraryDependency tag, 1019 LibraryDependency tag,
1020 LibraryElement loadedLibrary) { 1020 LibraryElement loadedLibrary) {
1021 if (tag != null) { 1021 if (tag != null) {
1022 library.recordResolvedTag(tag, loadedLibrary); 1022 library.recordResolvedTag(tag, loadedLibrary);
1023 } 1023 }
1024 if (tag is Export) { 1024 if (tag is Export) {
1025 // [loadedLibrary] is exported by [library]. 1025 // [loadedLibrary] is exported by [library].
1026 LibraryDependencyNode exportingNode = nodeMap[library]; 1026 LibraryDependencyNode exportingNode = nodeMap[library];
1027 if (loadedLibrary.exportsHandled) { 1027 if (loadedLibrary.exportsHandled) {
1028 // Export scope already computed on [loadedLibrary]. 1028 // Export scope already computed on [loadedLibrary].
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 } 1186 }
1187 suffixes.add(const Link<Uri>().prepend(canonicalUri)); 1187 suffixes.add(const Link<Uri>().prepend(canonicalUri));
1188 } 1188 }
1189 suffixChainMap[library] = suffixes; 1189 suffixChainMap[library] = suffixes;
1190 return; 1190 return;
1191 } 1191 }
1192 1192
1193 computeSuffixes(rootLibrary, const Link<Uri>()); 1193 computeSuffixes(rootLibrary, const Link<Uri>());
1194 } 1194 }
1195 } 1195 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698