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

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

Issue 9447100: Return null from stringValue and call slowToString() instead of toString(). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: changes Created 8 years, 9 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 | « dart/frog/leg/scanner/scanner.dart ('k') | dart/frog/leg/scanner/string_scanner.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 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 if (compilationUnit.kind === ElementKind.LIBRARY) { 11 if (compilationUnit.kind === ElementKind.LIBRARY) {
12 compiler.log("scanning library ${compilationUnit.script.name}"); 12 compiler.log("scanning library ${compilationUnit.script.name}");
13 } 13 }
14 scanElements(compilationUnit); 14 scanElements(compilationUnit);
15 if (compilationUnit.kind === ElementKind.LIBRARY) { 15 if (compilationUnit.kind === ElementKind.LIBRARY) {
16 processScriptTags(compilationUnit); 16 processScriptTags(compilationUnit);
17 } 17 }
18 native.processNativeClasses(compiler, compilationUnit); 18 native.processNativeClasses(compiler, compilationUnit);
19 }); 19 });
20 } 20 }
21 21
22 void processScriptTags(LibraryElement library) { 22 void processScriptTags(LibraryElement library) {
23 LinkBuilder<ScriptTag> imports = new LinkBuilder<ScriptTag>(); 23 LinkBuilder<ScriptTag> imports = new LinkBuilder<ScriptTag>();
24 Uri cwd = new Uri(scheme: 'file', path: compiler.currentDirectory); 24 Uri cwd = new Uri(scheme: 'file', path: compiler.currentDirectory);
25 Uri base = cwd.resolve(library.script.name.toString()); 25 Uri base = cwd.resolve(library.script.name.toString());
26 for (ScriptTag tag in library.tags.reverse()) { 26 for (ScriptTag tag in library.tags.reverse()) {
27 SourceString argument = tag.argument.value.copyWithoutQuotes(1, 1); 27 SourceString argument = tag.argument.value.copyWithoutQuotes(1, 1);
28 Uri resolved = base.resolve(argument.toString()); 28 Uri resolved = base.resolve(argument.slowToString());
29 if (tag.isImport()) { 29 if (tag.isImport()) {
30 // It is not safe to import other libraries at this point as 30 // It is not safe to import other libraries at this point as
31 // another library could then observe the current library 31 // another library could then observe the current library
32 // before it fully declares all the members that are sourced 32 // before it fully declares all the members that are sourced
33 // in. 33 // in.
34 imports.addLast(tag); 34 imports.addLast(tag);
35 } else if (tag.isLibrary()) { 35 } else if (tag.isLibrary()) {
36 if (library.libraryTag !== null) { 36 if (library.libraryTag !== null) {
37 compiler.cancel("duplicated library declaration", node: tag); 37 compiler.cancel("duplicated library declaration", node: tag);
38 } else { 38 } else {
39 library.libraryTag = tag; 39 library.libraryTag = tag;
40 } 40 }
41 } else if (tag.isSource()) { 41 } else if (tag.isSource()) {
42 Script script = compiler.readScript(resolved, tag); 42 Script script = compiler.readScript(resolved, tag);
43 CompilationUnitElement unit = 43 CompilationUnitElement unit =
44 new CompilationUnitElement(script, library); 44 new CompilationUnitElement(script, library);
45 compiler.withCurrentElement(unit, () => scan(unit)); 45 compiler.withCurrentElement(unit, () => scan(unit));
46 } else { 46 } else {
47 compiler.cancel("illegal script tag: ${tag.tag}", node: tag); 47 compiler.cancel("illegal script tag: ${tag.tag}", node: tag);
48 } 48 }
49 } 49 }
50 // TODO(ahe): During Compiler.scanBuiltinLibraries, 50 // TODO(ahe): During Compiler.scanBuiltinLibraries,
51 // compiler.coreLibrary is null. Clean this up when there is a 51 // compiler.coreLibrary is null. Clean this up when there is a
52 // better way to access "dart:core". 52 // better way to access "dart:core".
53 bool implicitlyImportCoreLibrary = compiler.coreLibrary !== null; 53 bool implicitlyImportCoreLibrary = compiler.coreLibrary !== null;
54 for (ScriptTag tag in imports.toLink()) { 54 for (ScriptTag tag in imports.toLink()) {
55 // Now that we have processed all the source tags, it is safe to 55 // Now that we have processed all the source tags, it is safe to
56 // start loading other libraries. 56 // start loading other libraries.
57 SourceString argument = tag.argument.value.copyWithoutQuotes(1, 1); 57 SourceString argument = tag.argument.value.copyWithoutQuotes(1, 1);
58 Uri resolved = base.resolve(argument.toString()); 58 Uri resolved = base.resolve(argument.slowToString());
59 if (resolved.toString() == "dart:core") { 59 if (resolved.toString() == "dart:core") {
60 implicitlyImportCoreLibrary = false; 60 implicitlyImportCoreLibrary = false;
61 } 61 }
62 importLibrary(library, loadLibrary(resolved, tag), tag.prefix); 62 importLibrary(library, loadLibrary(resolved, tag), tag.prefix);
63 } 63 }
64 if (implicitlyImportCoreLibrary) { 64 if (implicitlyImportCoreLibrary) {
65 importLibrary(library, compiler.coreLibrary, null); 65 importLibrary(library, compiler.coreLibrary, null);
66 } 66 }
67 } 67 }
68 68
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 final String name = 'Diet Parser'; 119 final String name = 'Diet Parser';
120 120
121 dietParse(CompilationUnitElement compilationUnit, Token tokens) { 121 dietParse(CompilationUnitElement compilationUnit, Token tokens) {
122 measure(() { 122 measure(() {
123 ElementListener listener = new ElementListener(compiler, compilationUnit); 123 ElementListener listener = new ElementListener(compiler, compilationUnit);
124 PartialParser parser = new PartialParser(listener); 124 PartialParser parser = new PartialParser(listener);
125 parser.parseUnit(tokens); 125 parser.parseUnit(tokens);
126 }); 126 });
127 } 127 }
128 } 128 }
OLDNEW
« no previous file with comments | « dart/frog/leg/scanner/scanner.dart ('k') | dart/frog/leg/scanner/string_scanner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698