| OLD | NEW |
| 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 part of scanner; | 5 library dart2js.scanner.task; |
| 6 |
| 7 import '../common/tasks.dart' show |
| 8 CompilerTask; |
| 9 import '../compiler.dart' show |
| 10 Compiler; |
| 11 import '../elements/elements.dart' show |
| 12 CompilationUnitElement, |
| 13 LibraryElement; |
| 14 import '../script.dart' show |
| 15 Script; |
| 16 |
| 17 import 'scanner.dart' show |
| 18 Scanner; |
| 19 import 'string_scanner.dart' show |
| 20 StringScanner; |
| 21 import 'token.dart' show |
| 22 Token; |
| 6 | 23 |
| 7 class ScannerTask extends CompilerTask { | 24 class ScannerTask extends CompilerTask { |
| 8 ScannerTask(Compiler compiler) : super(compiler); | 25 ScannerTask(Compiler compiler) : super(compiler); |
| 9 String get name => 'Scanner'; | 26 String get name => 'Scanner'; |
| 10 | 27 |
| 11 void scanLibrary(LibraryElement library) { | 28 void scanLibrary(LibraryElement library) { |
| 12 CompilationUnitElement compilationUnit = library.entryCompilationUnit; | 29 CompilationUnitElement compilationUnit = library.entryCompilationUnit; |
| 13 String canonicalUri = library.canonicalUri.toString(); | 30 String canonicalUri = library.canonicalUri.toString(); |
| 14 String resolvedUri = compilationUnit.script.resourceUri.toString(); | 31 String resolvedUri = compilationUnit.script.resourceUri.toString(); |
| 15 if (canonicalUri == resolvedUri) { | 32 if (canonicalUri == resolvedUri) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 43 * value ('\x00'). If [source] does not end with '0', the string is copied | 60 * value ('\x00'). If [source] does not end with '0', the string is copied |
| 44 * before scanning. | 61 * before scanning. |
| 45 */ | 62 */ |
| 46 Token tokenize(String source) { | 63 Token tokenize(String source) { |
| 47 return measure(() { | 64 return measure(() { |
| 48 return new StringScanner.fromString(source, includeComments: false) | 65 return new StringScanner.fromString(source, includeComments: false) |
| 49 .tokenize(); | 66 .tokenize(); |
| 50 }); | 67 }); |
| 51 } | 68 } |
| 52 } | 69 } |
| 53 | |
| 54 class DietParserTask extends CompilerTask { | |
| 55 DietParserTask(Compiler compiler) : super(compiler); | |
| 56 final String name = 'Diet Parser'; | |
| 57 | |
| 58 dietParse(CompilationUnitElement compilationUnit, Token tokens) { | |
| 59 measure(() { | |
| 60 Function idGenerator = compiler.getNextFreeClassId; | |
| 61 ElementListener listener = | |
| 62 new ElementListener(compiler, compilationUnit, idGenerator); | |
| 63 PartialParser parser = new PartialParser(listener); | |
| 64 try { | |
| 65 parser.parseUnit(tokens); | |
| 66 } on ParserError catch(_) { | |
| 67 assert(invariant(compilationUnit, compiler.compilationFailed)); | |
| 68 } | |
| 69 }); | |
| 70 } | |
| 71 } | |
| OLD | NEW |