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/tasks.dart' show CompilerTask; | 8 import '../common/tasks.dart' show CompilerTask; |
9 import '../compiler.dart' show Compiler; | 9 import '../compiler.dart' show Compiler; |
10 import '../elements/elements.dart' show CompilationUnitElement; | 10 import '../elements/elements.dart' show CompilationUnitElement; |
| 11 import '../id_generator.dart'; |
11 import '../tokens/token.dart' show Token; | 12 import '../tokens/token.dart' show Token; |
12 | 13 |
13 import 'listener.dart' show ParserError; | 14 import 'listener.dart' show ParserError; |
14 import 'element_listener.dart' show ElementListener, ScannerOptions; | 15 import 'element_listener.dart' show ElementListener, ScannerOptions; |
15 import '../options.dart' show ParserOptions; | 16 import '../options.dart' show ParserOptions; |
16 import 'partial_parser.dart' show PartialParser; | 17 import 'partial_parser.dart' show PartialParser; |
17 | 18 |
18 class DietParserTask extends CompilerTask { | 19 class DietParserTask extends CompilerTask { |
19 final ParserOptions _parserOptions; | 20 final ParserOptions _parserOptions; |
| 21 final IdGenerator _idGenerator; |
20 | 22 |
21 DietParserTask(Compiler compiler, this._parserOptions) : super(compiler); | 23 DietParserTask(Compiler compiler, this._parserOptions, this._idGenerator) |
| 24 : super(compiler); |
22 | 25 |
23 final String name = 'Diet Parser'; | 26 final String name = 'Diet Parser'; |
24 | 27 |
25 dietParse(CompilationUnitElement compilationUnit, Token tokens) { | 28 dietParse(CompilationUnitElement compilationUnit, Token tokens) { |
26 measure(() { | 29 measure(() { |
27 Function idGenerator = compiler.getNextFreeClassId; | |
28 ScannerOptions scannerOptions = | 30 ScannerOptions scannerOptions = |
29 new ScannerOptions.from(compiler, compilationUnit.library); | 31 new ScannerOptions.from(compiler, compilationUnit.library); |
30 ElementListener listener = new ElementListener( | 32 ElementListener listener = new ElementListener( |
31 scannerOptions, compiler.reporter, compilationUnit, idGenerator); | 33 scannerOptions, compiler.reporter, compilationUnit, _idGenerator); |
32 PartialParser parser = new PartialParser(listener, _parserOptions); | 34 PartialParser parser = new PartialParser(listener, _parserOptions); |
33 try { | 35 try { |
34 parser.parseUnit(tokens); | 36 parser.parseUnit(tokens); |
35 } on ParserError catch (_) { | 37 } on ParserError catch (_) { |
36 assert(invariant(compilationUnit, compiler.compilationFailed)); | 38 assert(invariant(compilationUnit, compiler.compilationFailed)); |
37 } | 39 } |
38 }); | 40 }); |
39 } | 41 } |
40 } | 42 } |
OLD | NEW |