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

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

Issue 9568008: Do not allow native syntax on all libraries. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/
Patch Set: 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
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 compiler.nativeHandler.processNativeClasses(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.slowToString()); 28 Uri resolved = base.resolve(argument.slowToString());
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 compiler.dietParser.dietParse(compilationUnit, tokens); 85 compiler.dietParser.dietParse(compilationUnit, tokens);
86 } 86 }
87 87
88 LibraryElement loadLibrary(Uri uri, ScriptTag node) { 88 LibraryElement loadLibrary(Uri uri, ScriptTag node) {
89 bool newLibrary = false; 89 bool newLibrary = false;
90 LibraryElement library = 90 LibraryElement library =
91 compiler.universe.libraries.putIfAbsent(uri.toString(), () { 91 compiler.universe.libraries.putIfAbsent(uri.toString(), () {
92 newLibrary = true; 92 newLibrary = true;
93 Script script = compiler.readScript(uri, node); 93 Script script = compiler.readScript(uri, node);
94 LibraryElement element = new LibraryElement(script); 94 LibraryElement element = new LibraryElement(script);
95 native.checkNativeSupport(compiler, element, uri); 95 compiler.nativeHandler.checkNativeSupport(element, uri);
96 return element; 96 return element;
97 }); 97 });
98 if (newLibrary) { 98 if (newLibrary) {
99 compiler.withCurrentElement(library, () => scan(library)); 99 compiler.withCurrentElement(library, () => scan(library));
100 } 100 }
101 return library; 101 return library;
102 } 102 }
103 103
104 void importLibrary(LibraryElement library, LibraryElement imported, 104 void importLibrary(LibraryElement library, LibraryElement imported,
105 LiteralString prefix) { 105 LiteralString prefix) {
(...skipping 15 matching lines...) Expand all
121 final String name = 'Diet Parser'; 121 final String name = 'Diet Parser';
122 122
123 dietParse(CompilationUnitElement compilationUnit, Token tokens) { 123 dietParse(CompilationUnitElement compilationUnit, Token tokens) {
124 measure(() { 124 measure(() {
125 ElementListener listener = new ElementListener(compiler, compilationUnit); 125 ElementListener listener = new ElementListener(compiler, compilationUnit);
126 PartialParser parser = new PartialParser(listener); 126 PartialParser parser = new PartialParser(listener);
127 parser.parseUnit(tokens); 127 parser.parseUnit(tokens);
128 }); 128 });
129 } 129 }
130 } 130 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698