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