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