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

Unified Diff: lib/compiler/implementation/scanner/scanner_task.dart

Issue 10832203: Refactor Library/CompilationUnit and how we define local Scope. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase and refactor ClassElement.constructors. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/compiler/implementation/scanner/listener.dart ('k') | lib/dartdoc/mirrors/dart2js_mirror.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/scanner/scanner_task.dart
diff --git a/lib/compiler/implementation/scanner/scanner_task.dart b/lib/compiler/implementation/scanner/scanner_task.dart
index a1ed5fb6ba1faf9dd96d814c8bd959a64ad8bda7..d3aee92515d299aa958a1754aa431c10c96df67f 100644
--- a/lib/compiler/implementation/scanner/scanner_task.dart
+++ b/lib/compiler/implementation/scanner/scanner_task.dart
@@ -6,15 +6,16 @@ class ScannerTask extends CompilerTask {
ScannerTask(Compiler compiler) : super(compiler);
String get name() => 'Scanner';
+ void scanLibrary(LibraryElement library) {
+ var compilationUnit = library.entryCompilationUnit;
+ compiler.log("scanning library ${compilationUnit.script.name}");
+ scan(compilationUnit);
+ processScriptTags(library);
+ }
+
void scan(CompilationUnitElement compilationUnit) {
measure(() {
- if (compilationUnit.kind === ElementKind.LIBRARY) {
- compiler.log("scanning library ${compilationUnit.script.name}");
- }
scanElements(compilationUnit);
- if (compilationUnit.kind === ElementKind.LIBRARY) {
- processScriptTags(compilationUnit);
- }
});
}
@@ -35,7 +36,7 @@ class ScannerTask extends CompilerTask {
}
LinkBuilder<ScriptTag> imports = new LinkBuilder<ScriptTag>();
- Uri base = library.script.uri;
+ Uri base = library.uri;
for (ScriptTag tag in library.tags.reverse()) {
StringNode argument = tag.argument;
// TODO(lrn): Support interpolations here. We need access to the
@@ -122,7 +123,7 @@ class ScannerTask extends CompilerTask {
});
if (newLibrary) {
compiler.withCurrentElement(library, () {
- scan(library);
+ scanLibrary(library);
compiler.onLibraryLoaded(library, uri);
});
}
@@ -130,11 +131,12 @@ class ScannerTask extends CompilerTask {
}
void importLibrary(LibraryElement library, LibraryElement imported,
- ScriptTag tag, [CompilationUnitElement patch]) {
+ ScriptTag tag,
+ [CompilationUnitElement patchCompilationUnit]) {
if (!imported.hasLibraryName()) {
compiler.withCurrentElement(library, () {
compiler.reportError(tag === null ? null : tag.argument,
- 'no #library tag found in ${imported.script.uri}');
+ 'no #library tag found in ${imported.uri}');
});
}
if (tag !== null && tag.prefix !== null) {
@@ -142,8 +144,9 @@ class ScannerTask extends CompilerTask {
new SourceString(tag.prefix.dartString.slowToString());
Element e = library.find(prefix);
if (e === null) {
- e = new PrefixElement(prefix, library, tag.getBeginToken(), patch);
- library.define(e, compiler);
+ e = new PrefixElement(prefix, library, tag.getBeginToken(),
+ patchCompilationUnit);
+ library.addToScope(e, compiler);
}
if (e.kind !== ElementKind.PREFIX) {
compiler.withCurrentElement(e, () {
@@ -170,7 +173,7 @@ class ScannerTask extends CompilerTask {
} else {
imported.forEachExport((Element element) {
compiler.withCurrentElement(element, () {
- library.define(element, compiler);
+ library.addToScope(element, compiler);
});
});
}
« no previous file with comments | « lib/compiler/implementation/scanner/listener.dart ('k') | lib/dartdoc/mirrors/dart2js_mirror.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698