Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(511)

Side by Side Diff: pkg/analyzer/lib/src/fasta/analyzer_loader.dart

Issue 2981693002: Start copying resolution/inference data from front end to analyzer ASTs. (Closed)
Patch Set: Address code review comments. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_loader; 5 library fasta.analyzer_loader;
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 Program; 8 import 'package:kernel/ast.dart' show Program;
9 9
10 import 'package:front_end/src/fasta/builder/builder.dart' show LibraryBuilder; 10 import 'package:front_end/src/fasta/builder/builder.dart' show LibraryBuilder;
(...skipping 10 matching lines...) Expand all
21 import 'package:analyzer/src/fasta/element_store.dart' show ElementStore; 21 import 'package:analyzer/src/fasta/element_store.dart' show ElementStore;
22 22
23 import 'analyzer_diet_listener.dart' show AnalyzerDietListener; 23 import 'analyzer_diet_listener.dart' show AnalyzerDietListener;
24 24
25 import 'package:kernel/core_types.dart' show CoreTypes; 25 import 'package:kernel/core_types.dart' show CoreTypes;
26 import 'package:kernel/src/incremental_class_hierarchy.dart'; 26 import 'package:kernel/src/incremental_class_hierarchy.dart';
27 27
28 class AnalyzerLoader<L> extends SourceLoader<L> { 28 class AnalyzerLoader<L> extends SourceLoader<L> {
29 ElementStore elementStore; 29 ElementStore elementStore;
30 30
31 AnalyzerLoader(TargetImplementation target) 31 /// Indicates whether a kernel representation of the code should be generated.
32 ///
33 /// When `false`, an analyzer AST is generated, and type inference is copied
34 /// over to it, but the result is not converted to a kernel representation.
35 ///
36 /// TODO(paulberry): remove this once "kompile" functionality is no longer
37 /// needed.
38 final bool generateKernel;
39
40 /// Indicates whether a resolved AST should be generated.
41 ///
42 /// When `false`, an analyzer AST is generated, but none of the types or
43 /// elements pointed to by the AST are guaranteed to be correct.
44 ///
45 /// This is needed in order to support the old "kompile" use case, since the
46 /// tests of that functionality were based on the behavior prior to
47 /// integrating resolution and type inference with analyzer.
48 ///
49 /// TODO(paulberry): remove this once "kompile" functionality is no longer
50 /// needed.
51 final bool doResolution;
52
53 AnalyzerLoader(
54 TargetImplementation target, this.generateKernel, this.doResolution)
32 : super(PhysicalFileSystem.instance, target); 55 : super(PhysicalFileSystem.instance, target);
33 56
34 @override 57 @override
35 void computeHierarchy(Program program) { 58 void computeHierarchy(Program program) {
36 elementStore = new ElementStore(coreLibrary, builders); 59 elementStore = new ElementStore(coreLibrary, builders);
37 ticker.logMs("Built analyzer element model."); 60 ticker.logMs("Built analyzer element model.");
38 hierarchy = new IncrementalClassHierarchy(); 61 hierarchy = new IncrementalClassHierarchy();
39 ticker.logMs("Computed class hierarchy"); 62 ticker.logMs("Computed class hierarchy");
40 coreTypes = new CoreTypes(program); 63 coreTypes = new CoreTypes(program);
41 ticker.logMs("Computed core types"); 64 ticker.logMs("Computed core types");
42 } 65 }
43 66
44 @override 67 @override
45 AnalyzerDietListener createDietListener(LibraryBuilder library) { 68 AnalyzerDietListener createDietListener(LibraryBuilder library) {
46 return new AnalyzerDietListener(library, elementStore); 69 return new AnalyzerDietListener(library, elementStore, hierarchy, coreTypes,
70 typeInferenceEngine, generateKernel, doResolution);
47 } 71 }
48 72
49 @override 73 @override
50 void checkOverrides(List<SourceClassBuilder> sourceClasses) { 74 void checkOverrides(List<SourceClassBuilder> sourceClasses) {
51 // Not implemented yet. Requires [hierarchy]. 75 // Not implemented yet. Requires [hierarchy].
52 } 76 }
53 } 77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698