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 library dart2js.scanner.task; | 5 library dart2js.scanner.task; |
6 | 6 |
7 import '../common/tasks.dart' show CompilerTask; | 7 import '../common/tasks.dart' show CompilerTask, Measurer; |
8 import '../compiler.dart' show Compiler; | 8 import '../diagnostics/diagnostic_listener.dart' show DiagnosticReporter; |
9 import '../elements/elements.dart' show CompilationUnitElement, LibraryElement; | 9 import '../elements/elements.dart' show CompilationUnitElement, LibraryElement; |
10 import '../script.dart' show Script; | 10 import '../script.dart' show Script; |
11 import '../parser/diet_parser_task.dart' show DietParserTask; | 11 import '../parser/diet_parser_task.dart' show DietParserTask; |
12 import '../tokens/token.dart' show Token; | 12 import '../tokens/token.dart' show Token; |
13 import '../tokens/token_constants.dart' as Tokens show COMMENT_TOKEN, EOF_TOKEN; | 13 import '../tokens/token_constants.dart' as Tokens show COMMENT_TOKEN, EOF_TOKEN; |
14 import '../tokens/token_map.dart' show TokenMap; | 14 import '../tokens/token_map.dart' show TokenMap; |
15 | 15 |
16 import 'scanner.dart' show Scanner; | 16 import 'scanner.dart' show Scanner; |
17 import 'string_scanner.dart' show StringScanner; | 17 import 'string_scanner.dart' show StringScanner; |
18 | 18 |
19 class ScannerTask extends CompilerTask { | 19 class ScannerTask extends CompilerTask { |
20 final DietParserTask _dietParser; | 20 final DietParserTask _dietParser; |
21 final bool _preserveComments; | 21 final bool _preserveComments; |
22 final TokenMap _commentMap; | 22 final TokenMap _commentMap; |
| 23 final DiagnosticReporter reporter; |
23 | 24 |
24 ScannerTask(Compiler compiler, this._dietParser, | 25 ScannerTask(this._dietParser, this.reporter, Measurer measurer, |
25 {bool preserveComments: false, TokenMap commentMap}) | 26 {bool preserveComments: false, TokenMap commentMap}) |
26 : _preserveComments = preserveComments, | 27 : _preserveComments = preserveComments, |
27 _commentMap = commentMap, | 28 _commentMap = commentMap, |
28 super(compiler) { | 29 super(measurer) { |
29 if (_preserveComments && _commentMap == null) { | 30 if (_preserveComments && _commentMap == null) { |
30 throw new ArgumentError( | 31 throw new ArgumentError( |
31 "commentMap must be provided if preserveComments is true"); | 32 "commentMap must be provided if preserveComments is true"); |
32 } | 33 } |
33 } | 34 } |
34 | 35 |
35 String get name => 'Scanner'; | 36 String get name => 'Scanner'; |
36 | 37 |
37 void scanLibrary(LibraryElement library) { | 38 void scanLibrary(LibraryElement library) { |
38 CompilationUnitElement compilationUnit = library.entryCompilationUnit; | 39 CompilationUnitElement compilationUnit = library.entryCompilationUnit; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 } else { | 92 } else { |
92 prevToken.next = currentToken; | 93 prevToken.next = currentToken; |
93 } | 94 } |
94 } | 95 } |
95 prevToken = currentToken; | 96 prevToken = currentToken; |
96 currentToken = currentToken.next; | 97 currentToken = currentToken.next; |
97 } | 98 } |
98 return firstToken; | 99 return firstToken; |
99 } | 100 } |
100 } | 101 } |
OLD | NEW |