OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 fasta.analyzer_target; | 5 library fasta.analyzer_target; |
6 | 6 |
7 import 'package:front_end/physical_file_system.dart'; | 7 import 'package:front_end/physical_file_system.dart'; |
8 import 'package:kernel/ast.dart' show Library, Source; | 8 import 'package:kernel/ast.dart' show Library, Source; |
9 | 9 |
10 import 'package:front_end/src/fasta/kernel/kernel_target.dart' | 10 import 'package:front_end/src/fasta/kernel/kernel_target.dart' |
11 show KernelTarget; | 11 show KernelTarget; |
12 | 12 |
13 import 'package:front_end/src/fasta/uri_translator.dart' show UriTranslator; | 13 import 'package:front_end/src/fasta/uri_translator.dart' show UriTranslator; |
14 | 14 |
15 import 'package:front_end/src/fasta/dill/dill_target.dart' show DillTarget; | 15 import 'package:front_end/src/fasta/dill/dill_target.dart' show DillTarget; |
16 | 16 |
17 import 'analyzer_loader.dart' show AnalyzerLoader; | 17 import 'analyzer_loader.dart' show AnalyzerLoader; |
18 | 18 |
19 class AnalyzerTarget extends KernelTarget { | 19 class AnalyzerTarget extends KernelTarget { |
20 AnalyzerTarget( | 20 /// Indicates whether a kernel representation of the code should be generated. |
21 DillTarget dillTarget, UriTranslator uriTranslator, bool strongMode, | 21 /// |
| 22 /// When `false`, an analyzer AST is generated, and type inference is copied |
| 23 /// over to it, but the result is not converted to a kernel representation. |
| 24 /// |
| 25 /// TODO(paulberry): remove this once "kompile" functionality is no longer |
| 26 /// needed. |
| 27 final bool generateKernel; |
| 28 |
| 29 /// Indicates whether a resolved AST should be generated. |
| 30 /// |
| 31 /// When `false`, an analyzer AST is generated, but none of the types or |
| 32 /// elements pointed to by the AST are guaranteed to be correct. |
| 33 /// |
| 34 /// This is needed in order to support the old "kompile" use case, since the |
| 35 /// tests of that functionality were based on the behavior prior to |
| 36 /// integrating resolution and type inference with analyzer. |
| 37 /// |
| 38 /// TODO(paulberry): remove this once "kompile" functionality is no longer |
| 39 /// needed. |
| 40 final bool doResolution; |
| 41 |
| 42 AnalyzerTarget(DillTarget dillTarget, UriTranslator uriTranslator, |
| 43 bool strongMode, this.generateKernel, this.doResolution, |
22 [Map<String, Source> uriToSource]) | 44 [Map<String, Source> uriToSource]) |
23 : super(PhysicalFileSystem.instance, dillTarget, uriTranslator, | 45 : super(PhysicalFileSystem.instance, dillTarget, uriTranslator, |
24 uriToSource); | 46 uriToSource); |
25 | 47 |
26 @override | 48 @override |
27 AnalyzerLoader<Library> createLoader() => new AnalyzerLoader<Library>(this); | 49 AnalyzerLoader<Library> createLoader() => |
| 50 new AnalyzerLoader<Library>(this, generateKernel, doResolution); |
28 } | 51 } |
OLD | NEW |