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

Side by Side Diff: dart/frog/leg/scanner/scanner_task.dart

Issue 9359039: Source in most stuff. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: changes Created 8 years, 10 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 class ScannerTask extends CompilerTask { 5 class ScannerTask extends CompilerTask {
6 ScannerTask(Compiler compiler) : super(compiler); 6 ScannerTask(Compiler compiler) : super(compiler);
7 String get name() => 'Scanner'; 7 String get name() => 'Scanner';
8 8
9 void scan(CompilationUnitElement compilationUnit) { 9 void scan(CompilationUnitElement compilationUnit) {
10 measure(() { 10 measure(() {
11 scanElements(compilationUnit); 11 scanElements(compilationUnit);
12 if (compilationUnit.kind === ElementKind.LIBRARY) { 12 if (compilationUnit.kind === ElementKind.LIBRARY) {
13 processScriptTags(compilationUnit); 13 processScriptTags(compilationUnit);
14 } 14 }
15 }); 15 });
16 } 16 }
17 17
18 void processScriptTags(LibraryElement library) { 18 void processScriptTags(LibraryElement library) {
19 LinkBuilder<ScriptTag> imports = new LinkBuilder<ScriptTag>();
20 Uri cwd = new Uri(scheme: 'file', path: compiler.currentDirectory);
kasperl 2012/02/15 09:22:30 The named arguments are cool. Would it make sense
ahe 2012/02/15 09:46:55 I need to process source directives before I start
21 Uri base = cwd.resolve(library.script.name.toString());
19 for (ScriptTag tag in library.tags.reverse()) { 22 for (ScriptTag tag in library.tags.reverse()) {
20 SourceString argument = tag.argument.value.copyWithoutQuotes(1, 1); 23 SourceString argument = tag.argument.value.copyWithoutQuotes(1, 1);
21 Uri cwd = new Uri(scheme: 'file', path: compiler.currentDirectory);
22 Uri base = cwd.resolve(library.script.name.toString());
23 Uri resolved = base.resolve(argument.toString()); 24 Uri resolved = base.resolve(argument.toString());
24 if (tag.isImport()) { 25 if (tag.isImport()) {
25 importLibrary(library, loadLibrary(resolved, tag), tag.prefix); 26 imports.addLast(tag);
26 } else if (tag.isLibrary()) { 27 } else if (tag.isLibrary()) {
27 if (library.libraryTag !== null) { 28 if (library.libraryTag !== null) {
28 compiler.cancel("duplicated library declaration", node: tag); 29 compiler.cancel("duplicated library declaration", node: tag);
29 } else { 30 } else {
30 library.libraryTag = tag; 31 library.libraryTag = tag;
31 } 32 }
32 } else if (tag.isSource()) { 33 } else if (tag.isSource()) {
33 Script script = compiler.readScript(resolved, tag); 34 Script script = compiler.readScript(resolved, tag);
34 CompilationUnitElement unit = 35 CompilationUnitElement unit =
35 new CompilationUnitElement(script, library); 36 new CompilationUnitElement(script, library);
36 compiler.withCurrentElement(unit, () => scan(unit)); 37 compiler.withCurrentElement(unit, () => scan(unit));
37 } else { 38 } else {
38 compiler.cancel("illegal script tag: ${tag.tag}", node: tag); 39 compiler.cancel("illegal script tag: ${tag.tag}", node: tag);
39 } 40 }
40 } 41 }
42 for (ScriptTag tag in imports.toLink()) {
ngeoffray 2012/02/15 09:53:03 Maybe add a comment on why you need to import last
ahe 2012/02/15 15:08:42 Done.
43 SourceString argument = tag.argument.value.copyWithoutQuotes(1, 1);
44 Uri resolved = base.resolve(argument.toString());
45 importLibrary(library, loadLibrary(resolved, tag), tag.prefix);
46 }
41 if (compiler.coreLibrary !== null) { 47 if (compiler.coreLibrary !== null) {
42 importLibrary(library, compiler.coreLibrary, null); 48 importLibrary(library, compiler.coreLibrary, null);
43 } 49 }
44 } 50 }
45 51
46 void scanElements(CompilationUnitElement compilationUnit) { 52 void scanElements(CompilationUnitElement compilationUnit) {
47 compiler.log("scanning $compilationUnit"); 53 compiler.log("scanning $compilationUnit");
48 Script script = compilationUnit.script; 54 Script script = compilationUnit.script;
49 Token tokens; 55 Token tokens;
50 try { 56 try {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } else { 92 } else {
87 for (Link<Element> link = imported.topLevelElements; !link.isEmpty(); 93 for (Link<Element> link = imported.topLevelElements; !link.isEmpty();
88 link = link.tail) { 94 link = link.tail) {
89 compiler.withCurrentElement(link.head, () { 95 compiler.withCurrentElement(link.head, () {
90 library.define(link.head, compiler); 96 library.define(link.head, compiler);
91 }); 97 });
92 } 98 }
93 } 99 }
94 } 100 }
95 } 101 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698