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

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

Issue 2918593003: Pass ClassHierarchy instead of creating it. (Closed)
Patch Set: Created 3 years, 6 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; 5 library fasta;
6 6
7 import 'dart:async' show Future; 7 import 'dart:async' show Future;
8 8
9 import 'dart:convert' show JSON; 9 import 'dart:convert' show JSON;
10 10
11 import 'dart:io' show BytesBuilder, Directory, File, exitCode; 11 import 'dart:io' show BytesBuilder, Directory, File, exitCode;
12 12
13 import 'package:front_end/file_system.dart'; 13 import 'package:front_end/file_system.dart';
14 import 'package:front_end/physical_file_system.dart'; 14 import 'package:front_end/physical_file_system.dart';
15 import 'package:front_end/src/fasta/kernel/utils.dart'; 15 import 'package:front_end/src/fasta/kernel/utils.dart';
16 import 'package:kernel/binary/ast_to_binary.dart' 16 import 'package:kernel/binary/ast_to_binary.dart'
17 show LibraryFilteringBinaryPrinter; 17 show LibraryFilteringBinaryPrinter;
18 18
19 import 'package:kernel/class_hierarchy.dart' show ClassHierarchy;
20
19 import 'package:kernel/core_types.dart' show CoreTypes; 21 import 'package:kernel/core_types.dart' show CoreTypes;
20 22
21 import 'package:kernel/kernel.dart' show Library, Program, loadProgramFromBytes; 23 import 'package:kernel/kernel.dart' show Library, Program, loadProgramFromBytes;
22 24
23 import 'package:kernel/target/targets.dart' show Target, TargetFlags, getTarget; 25 import 'package:kernel/target/targets.dart' show Target, TargetFlags, getTarget;
24 26
25 import 'compiler_command_line.dart' show CompilerCommandLine; 27 import 'compiler_command_line.dart' show CompilerCommandLine;
26 28
27 import 'compiler_context.dart' show CompilerContext; 29 import 'compiler_context.dart' show CompilerContext;
28 30
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 if (!await fileSystem.entityForUri(fileName).exists()) { 191 if (!await fileSystem.entityForUri(fileName).exists()) {
190 return new CompilationResult.error( 192 return new CompilationResult.error(
191 formatUnexpected(fileName, -1, "No such file.")); 193 formatUnexpected(fileName, -1, "No such file."));
192 } 194 }
193 if (!await new Directory.fromUri(patchedSdk).exists()) { 195 if (!await new Directory.fromUri(patchedSdk).exists()) {
194 return new CompilationResult.error( 196 return new CompilationResult.error(
195 formatUnexpected(patchedSdk, -1, "Patched sdk directory not found.")); 197 formatUnexpected(patchedSdk, -1, "Patched sdk directory not found."));
196 } 198 }
197 199
198 CoreTypes coreTypes; 200 CoreTypes coreTypes;
201 ClassHierarchy hierarchy;
199 Program program; 202 Program program;
200 try { 203 try {
201 TranslateUri uriTranslator = 204 TranslateUri uriTranslator =
202 await TranslateUri.parse(fileSystem, patchedSdk, packages: packages); 205 await TranslateUri.parse(fileSystem, patchedSdk, packages: packages);
203 final Ticker ticker = new Ticker(isVerbose: verbose); 206 final Ticker ticker = new Ticker(isVerbose: verbose);
204 final DillTarget dillTarget = 207 final DillTarget dillTarget =
205 new DillTarget(ticker, uriTranslator, backendTarget); 208 new DillTarget(ticker, uriTranslator, backendTarget);
206 _appendDillForUri(dillTarget, patchedSdk.resolve('platform.dill')); 209 _appendDillForUri(dillTarget, patchedSdk.resolve('platform.dill'));
207 final KernelTarget kernelTarget = 210 final KernelTarget kernelTarget =
208 new KernelTarget(fileSystem, dillTarget, uriTranslator, strongMode); 211 new KernelTarget(fileSystem, dillTarget, uriTranslator, strongMode);
209 kernelTarget.read(fileName); 212 kernelTarget.read(fileName);
210 await dillTarget.buildOutlines(); 213 await dillTarget.buildOutlines();
211 await kernelTarget.buildOutlines(); 214 await kernelTarget.buildOutlines();
212 coreTypes = kernelTarget.loader.coreTypes; 215 coreTypes = kernelTarget.loader.coreTypes;
216 hierarchy = kernelTarget.loader.hierarchy;
213 program = await kernelTarget.buildProgram(); 217 program = await kernelTarget.buildProgram();
214 if (kernelTarget.errors.isNotEmpty) { 218 if (kernelTarget.errors.isNotEmpty) {
215 return new CompilationResult.errors(kernelTarget.errors); 219 return new CompilationResult.errors(kernelTarget.errors);
216 } 220 }
217 } on InputError catch (e) { 221 } on InputError catch (e) {
218 return new CompilationResult.error(e.format()); 222 return new CompilationResult.error(e.format());
219 } 223 }
220 224
221 if (program.mainMethod == null) { 225 if (program.mainMethod == null) {
222 return new CompilationResult.error("No 'main' method found."); 226 return new CompilationResult.error("No 'main' method found.");
223 } 227 }
224 228
225 // Perform target-specific transformations. 229 // Perform target-specific transformations.
226 Target target = getTarget("vm", new TargetFlags(strongMode: false)); 230 Target target = getTarget("vm", new TargetFlags(strongMode: false));
227 target.performModularTransformations(coreTypes, program); 231 target.performModularTransformations(coreTypes, hierarchy, program);
228 target.performGlobalTransformations(coreTypes, program); 232 target.performGlobalTransformations(coreTypes, program);
229 233
230 // Write the program to a list of bytes and return it. Do not include 234 // Write the program to a list of bytes and return it. Do not include
231 // libraries that have a dart: import URI. 235 // libraries that have a dart: import URI.
232 // 236 //
233 // TODO(kmillikin): This is intended to exclude platform libraries that are 237 // TODO(kmillikin): This is intended to exclude platform libraries that are
234 // included in the Kernel binary platform platform.dill. It does not 238 // included in the Kernel binary platform platform.dill. It does not
235 // necessarily exclude exactly the platform libraries. Use a better 239 // necessarily exclude exactly the platform libraries. Use a better
236 // predicate that knows what is included in platform.dill. 240 // predicate that knows what is included in platform.dill.
237 var sink = new ByteSink(); 241 var sink = new ByteSink();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 final BytesBuilder builder = new BytesBuilder(); 309 final BytesBuilder builder = new BytesBuilder();
306 310
307 void add(List<int> data) { 311 void add(List<int> data) {
308 builder.add(data); 312 builder.add(data);
309 } 313 }
310 314
311 void close() { 315 void close() {
312 // Nothing to do. 316 // Nothing to do.
313 } 317 }
314 } 318 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698