OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.parser.diet.task; | 5 library dart2js.parser.diet.task; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../common/backend_api.dart' show Backend; | 8 import '../common/backend_api.dart' show Backend; |
9 import '../common/tasks.dart' show CompilerTask, Measurer; | 9 import '../common/tasks.dart' show CompilerTask, Measurer; |
10 import '../elements/elements.dart' show CompilationUnitElement; | 10 import '../elements/elements.dart' show CompilationUnitElement; |
11 import '../id_generator.dart'; | 11 import '../id_generator.dart'; |
12 import '../tokens/token.dart' show Token; | 12 import '../tokens/token.dart' show Token; |
13 import 'element_listener.dart' show ElementListener, ScannerOptions; | 13 import 'element_listener.dart' show ElementListener, ScannerOptions; |
14 import 'listener.dart' show ParserError; | 14 import 'listener.dart' show ParserError; |
15 import 'partial_parser.dart' show PartialParser; | 15 import 'partial_parser.dart' show PartialParser; |
16 | 16 |
17 class DietParserTask extends CompilerTask { | 17 class DietParserTask extends CompilerTask { |
18 final IdGenerator _idGenerator; | 18 final IdGenerator _idGenerator; |
19 final Backend _backend; | 19 final Backend _backend; |
20 final DiagnosticReporter _reporter; | 20 final DiagnosticReporter _reporter; |
21 | 21 |
22 DietParserTask(this._idGenerator, this._backend, this._reporter, | 22 DietParserTask( |
23 Measurer measurer) | 23 this._idGenerator, this._backend, this._reporter, Measurer measurer) |
24 : super(measurer); | 24 : super(measurer); |
25 | 25 |
26 final String name = 'Diet Parser'; | 26 final String name = 'Diet Parser'; |
27 | 27 |
28 dietParse(CompilationUnitElement compilationUnit, Token tokens) { | 28 dietParse(CompilationUnitElement compilationUnit, Token tokens) { |
29 measure(() { | 29 measure(() { |
30 ScannerOptions scannerOptions = new ScannerOptions( | 30 ScannerOptions scannerOptions = new ScannerOptions( |
31 canUseNative: _backend.canLibraryUseNative(compilationUnit.library)); | 31 canUseNative: _backend.canLibraryUseNative(compilationUnit.library)); |
32 ElementListener listener = new ElementListener( | 32 ElementListener listener = new ElementListener( |
33 scannerOptions, _reporter, compilationUnit, _idGenerator); | 33 scannerOptions, _reporter, compilationUnit, _idGenerator); |
34 PartialParser parser = new PartialParser(listener); | 34 PartialParser parser = new PartialParser(listener); |
35 try { | 35 try { |
36 parser.parseUnit(tokens); | 36 parser.parseUnit(tokens); |
37 } on ParserError catch (_) { | 37 } on ParserError catch (_) { |
38 // TODO(johnniwinther): assert that the error was reported once there is | 38 // TODO(johnniwinther): assert that the error was reported once there is |
39 // a [hasErrorBeenReported] field in [DiagnosticReporter] | 39 // a [hasErrorBeenReported] field in [DiagnosticReporter] |
40 // The error should have already been reported by the parser. | 40 // The error should have already been reported by the parser. |
41 } | 41 } |
42 }); | 42 }); |
43 } | 43 } |
44 } | 44 } |
OLD | NEW |