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