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

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

Issue 2874723002: Add a way to use shared CanonicalName root to deserialize Program. (Closed)
Patch Set: Move 'nameRoot' into KernelTarget.link(). Created 3 years, 7 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
« no previous file with comments | « pkg/front_end/lib/src/fasta/fasta.dart ('k') | pkg/front_end/test/fasta/testing/suite.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.kernel_target; 5 library fasta.kernel_target;
6 6
7 import 'dart:async' show Future; 7 import 'dart:async' show Future;
8 8
9 import 'dart:io' show File, IOSink; 9 import 'dart:io' show File, IOSink;
10 10
11 import 'package:front_end/file_system.dart'; 11 import 'package:front_end/file_system.dart';
12 import 'package:kernel/ast.dart' 12 import 'package:kernel/ast.dart'
13 show 13 show
14 Arguments, 14 Arguments,
15 AsyncMarker, 15 AsyncMarker,
16 CanonicalName,
16 Class, 17 Class,
17 Constructor, 18 Constructor,
18 DartType, 19 DartType,
19 DynamicType, 20 DynamicType,
20 EmptyStatement, 21 EmptyStatement,
21 Expression, 22 Expression,
22 ExpressionStatement, 23 ExpressionStatement,
23 Field, 24 Field,
24 FieldInitializer, 25 FieldInitializer,
25 FunctionNode, 26 FunctionNode,
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 String message = error.format(); 224 String message = error.format();
224 print(message); 225 print(message);
225 errors.add(message); 226 errors.add(message);
226 } 227 }
227 program = erroneousProgram(isFullProgram); 228 program = erroneousProgram(isFullProgram);
228 return uri == null 229 return uri == null
229 ? new Future<Program>.value(program) 230 ? new Future<Program>.value(program)
230 : writeLinkedProgram(uri, program, isFullProgram: isFullProgram); 231 : writeLinkedProgram(uri, program, isFullProgram: isFullProgram);
231 } 232 }
232 233
233 Future<Program> writeOutline(Uri uri) async { 234 Future<Program> writeOutline(Uri uri, {CanonicalName nameRoot}) async {
234 if (loader.first == null) return null; 235 if (loader.first == null) return null;
235 try { 236 try {
236 loader.createTypeInferenceEngine(); 237 loader.createTypeInferenceEngine();
237 await loader.buildOutlines(); 238 await loader.buildOutlines();
238 loader.coreLibrary 239 loader.coreLibrary
239 .becomeCoreLibrary(const DynamicType(), const VoidType()); 240 .becomeCoreLibrary(const DynamicType(), const VoidType());
240 dynamicType.bind(loader.coreLibrary["dynamic"]); 241 dynamicType.bind(loader.coreLibrary["dynamic"]);
241 loader.resolveParts(); 242 loader.resolveParts();
242 loader.computeLibraryScopes(); 243 loader.computeLibraryScopes();
243 loader.resolveTypes(); 244 loader.resolveTypes();
244 loader.checkSemantics(); 245 loader.checkSemantics();
245 loader.buildProgram(); 246 loader.buildProgram();
246 List<SourceClassBuilder> sourceClasses = collectAllSourceClasses(); 247 List<SourceClassBuilder> sourceClasses = collectAllSourceClasses();
247 installDefaultSupertypes(); 248 installDefaultSupertypes();
248 installDefaultConstructors(sourceClasses); 249 installDefaultConstructors(sourceClasses);
249 loader.resolveConstructors(); 250 loader.resolveConstructors();
250 loader.finishTypeVariables(objectClassBuilder); 251 loader.finishTypeVariables(objectClassBuilder);
251 program = link(new List<Library>.from(loader.libraries)); 252 program =
253 link(new List<Library>.from(loader.libraries), nameRoot: nameRoot);
252 loader.computeHierarchy(program); 254 loader.computeHierarchy(program);
253 loader.checkOverrides(sourceClasses); 255 loader.checkOverrides(sourceClasses);
254 loader.prepareInitializerInference(); 256 loader.prepareInitializerInference();
255 loader.performInitializerInference(); 257 loader.performInitializerInference();
256 if (uri == null) return program; 258 if (uri == null) return program;
257 return await writeLinkedProgram(uri, program, isFullProgram: false); 259 return await writeLinkedProgram(uri, program, isFullProgram: false);
258 } on InputError catch (e) { 260 } on InputError catch (e) {
259 return handleInputError(uri, e, isFullProgram: false); 261 return handleInputError(uri, e, isFullProgram: false);
260 } catch (e, s) { 262 } catch (e, s) {
261 return reportCrash(e, s, loader?.currentUriForCrashReporting); 263 return reportCrash(e, s, loader?.currentUriForCrashReporting);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 library.addBuilder(mainBuilder.name, mainBuilder, -1); 363 library.addBuilder(mainBuilder.name, mainBuilder, -1);
362 mainBuilder.body = new ExpressionStatement( 364 mainBuilder.body = new ExpressionStatement(
363 new Throw(new StringLiteral("${errors.join('\n')}"))); 365 new Throw(new StringLiteral("${errors.join('\n')}")));
364 } 366 }
365 library.build(loader.coreLibrary); 367 library.build(loader.coreLibrary);
366 return link(<Library>[library.library]); 368 return link(<Library>[library.library]);
367 } 369 }
368 370
369 /// Creates a program by combining [libraries] with the libraries of 371 /// Creates a program by combining [libraries] with the libraries of
370 /// `dillTarget.loader.program`. 372 /// `dillTarget.loader.program`.
371 Program link(List<Library> libraries) { 373 Program link(List<Library> libraries, {CanonicalName nameRoot}) {
372 Map<String, Source> uriToSource = 374 Map<String, Source> uriToSource =
373 new Map<String, Source>.from(this.uriToSource); 375 new Map<String, Source>.from(this.uriToSource);
374 376
375 final Program binary = dillTarget.loader.program; 377 libraries.addAll(dillTarget.loader.libraries);
376 if (binary != null) {
377 libraries.addAll(binary.libraries);
378 uriToSource.addAll(binary.uriToSource);
Siggi Cherem (dart-lang) 2017/05/12 17:29:25 do we need to preserve this somehow? (when linking
scheglov 2017/05/12 17:44:21 I will add TODO for now.
379 }
380 378
381 // TODO(ahe): Remove this line. Kernel seems to generate a default line map 379 // TODO(ahe): Remove this line. Kernel seems to generate a default line map
382 // that used when there's no fileUri on an element. Instead, ensure all 380 // that used when there's no fileUri on an element. Instead, ensure all
383 // elements have a fileUri. 381 // elements have a fileUri.
384 uriToSource[""] = new Source(<int>[0], const <int>[]); 382 uriToSource[""] = new Source(<int>[0], const <int>[]);
385 Program program = new Program(libraries, uriToSource); 383 Program program = new Program(
384 nameRoot: nameRoot, libraries: libraries, uriToSource: uriToSource);
386 if (loader.first != null) { 385 if (loader.first != null) {
387 Builder builder = loader.first.lookup("main", -1, null); 386 Builder builder = loader.first.lookup("main", -1, null);
388 if (builder is KernelProcedureBuilder) { 387 if (builder is KernelProcedureBuilder) {
389 program.mainMethod = builder.procedure; 388 program.mainMethod = builder.procedure;
390 } 389 }
391 } 390 }
392 if (errors.isEmpty || dillTarget.isLoaded) { 391 if (errors.isEmpty || dillTarget.isLoaded) {
393 runLinkTransformations(program); 392 runLinkTransformations(program);
394 } 393 }
395 ticker.logMs("Linked program"); 394 ticker.logMs("Linked program");
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 } 717 }
719 for (Constructor constructor in superclass.constructors) { 718 for (Constructor constructor in superclass.constructors) {
720 if (constructor.name.name.isEmpty) { 719 if (constructor.name.name.isEmpty) {
721 return constructor.function.requiredParameterCount == 0 720 return constructor.function.requiredParameterCount == 0
722 ? constructor 721 ? constructor
723 : null; 722 : null;
724 } 723 }
725 } 724 }
726 return null; 725 return null;
727 } 726 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/fasta.dart ('k') | pkg/front_end/test/fasta/testing/suite.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698