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

Side by Side Diff: pkg/front_end/lib/src/fasta/source/source_loader.dart

Issue 2824393002: Introduce a testing framework for use with fasta type inference. (Closed)
Patch Set: Created 3 years, 8 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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.source_loader; 5 library fasta.source_loader;
6 6
7 import 'dart:async' show Future; 7 import 'dart:async' show Future;
8 8
9 import 'dart:typed_data' show Uint8List; 9 import 'dart:typed_data' show Uint8List;
10 10
11 import 'package:front_end/src/base/instrumentation.dart' show Instrumentation;
12
11 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart' 13 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart'
12 show KernelTypeInferrer; 14 show KernelTypeInferrer;
13 15
14 import 'package:kernel/ast.dart' show Program; 16 import 'package:kernel/ast.dart' show Program;
15 17
16 import 'package:kernel/class_hierarchy.dart' show ClassHierarchy; 18 import 'package:kernel/class_hierarchy.dart' show ClassHierarchy;
17 19
18 import 'package:kernel/core_types.dart' show CoreTypes; 20 import 'package:kernel/core_types.dart' show CoreTypes;
19 21
20 import '../builder/builder.dart' show Builder, ClassBuilder, LibraryBuilder; 22 import '../builder/builder.dart' show Builder, ClassBuilder, LibraryBuilder;
(...skipping 25 matching lines...) Expand all
46 import 'source_library_builder.dart' show SourceLibraryBuilder; 48 import 'source_library_builder.dart' show SourceLibraryBuilder;
47 49
48 class SourceLoader<L> extends Loader<L> { 50 class SourceLoader<L> extends Loader<L> {
49 final Map<Uri, List<int>> sourceBytes = <Uri, List<int>>{}; 51 final Map<Uri, List<int>> sourceBytes = <Uri, List<int>>{};
50 final bool excludeSource = CompilerContext.current.options.excludeSource; 52 final bool excludeSource = CompilerContext.current.options.excludeSource;
51 53
52 // Used when building directly to kernel. 54 // Used when building directly to kernel.
53 ClassHierarchy hierarchy; 55 ClassHierarchy hierarchy;
54 CoreTypes coreTypes; 56 CoreTypes coreTypes;
55 57
58 Instrumentation instrumentation;
59
56 SourceLoader(TargetImplementation target) : super(target); 60 SourceLoader(TargetImplementation target) : super(target);
57 61
58 Future<Token> tokenize(SourceLibraryBuilder library, 62 Future<Token> tokenize(SourceLibraryBuilder library,
59 {bool suppressLexicalErrors: false}) async { 63 {bool suppressLexicalErrors: false}) async {
60 Uri uri = library.fileUri; 64 Uri uri = library.fileUri;
61 if (uri == null || uri.scheme != "file") { 65 if (uri == null || uri.scheme != "file") {
62 return inputError(library.uri, -1, "Not found: ${library.uri}."); 66 return inputError(library.uri, -1, "Not found: ${library.uri}.");
63 } 67 }
64 List<int> bytes = sourceBytes[uri]; 68 List<int> bytes = sourceBytes[uri];
65 if (bytes == null) { 69 if (bytes == null) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 if (tokens != null) { 120 if (tokens != null) {
117 listener.uri = part.fileUri; 121 listener.uri = part.fileUri;
118 parser.parseUnit(tokens); 122 parser.parseUnit(tokens);
119 } 123 }
120 } 124 }
121 } 125 }
122 } 126 }
123 127
124 DietListener createDietListener(LibraryBuilder library) { 128 DietListener createDietListener(LibraryBuilder library) {
125 return new DietListener(library, hierarchy, coreTypes, 129 return new DietListener(library, hierarchy, coreTypes,
126 new KernelTypeInferrer(coreTypes, hierarchy)); 130 new KernelTypeInferrer(coreTypes, hierarchy, instrumentation));
127 } 131 }
128 132
129 void resolveParts() { 133 void resolveParts() {
130 List<Uri> parts = <Uri>[]; 134 List<Uri> parts = <Uri>[];
131 builders.forEach((Uri uri, LibraryBuilder library) { 135 builders.forEach((Uri uri, LibraryBuilder library) {
132 if (library is SourceLibraryBuilder) { 136 if (library is SourceLibraryBuilder) {
133 if (library.isPart) { 137 if (library.isPart) {
134 library.validatePart(); 138 library.validatePart();
135 parts.add(uri); 139 parts.add(uri);
136 } else { 140 } else {
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 void checkOverrides(List<SourceClassBuilder> sourceClasses) { 359 void checkOverrides(List<SourceClassBuilder> sourceClasses) {
356 assert(hierarchy != null); 360 assert(hierarchy != null);
357 for (SourceClassBuilder builder in sourceClasses) { 361 for (SourceClassBuilder builder in sourceClasses) {
358 builder.checkOverrides(hierarchy); 362 builder.checkOverrides(hierarchy);
359 } 363 }
360 ticker.logMs("Checked overrides"); 364 ticker.logMs("Checked overrides");
361 } 365 }
362 366
363 List<Uri> getDependencies() => sourceBytes.keys.toList(); 367 List<Uri> getDependencies() => sourceBytes.keys.toList();
364 } 368 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698