Chromium Code Reviews| OLD | NEW |
|---|---|
| 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:kernel/ast.dart' show Arguments, Expression, Program; | 11 import 'package:front_end/src/fasta/kernel/kernel_library_builder.dart' |
| 12 show KernelLibraryBuilder; | |
| 13 | |
| 14 import 'package:kernel/ast.dart' show Arguments, Class, Expression, Program; | |
| 12 | 15 |
| 13 import 'package:kernel/class_hierarchy.dart' show ClassHierarchy; | 16 import 'package:kernel/class_hierarchy.dart' show ClassHierarchy; |
| 14 | 17 |
| 15 import 'package:kernel/core_types.dart' show CoreTypes; | 18 import 'package:kernel/core_types.dart' show CoreTypes; |
| 16 | 19 |
| 17 import 'package:kernel/src/incremental_class_hierarchy.dart' | 20 import 'package:kernel/src/incremental_class_hierarchy.dart' |
| 18 show IncrementalClassHierarchy; | 21 show IncrementalClassHierarchy; |
| 19 | 22 |
| 20 import '../../../file_system.dart'; | 23 import '../../../file_system.dart'; |
| 21 | 24 |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 489 } | 492 } |
| 490 | 493 |
| 491 /// Performs the second phase of top level initializer inference, which is to | 494 /// Performs the second phase of top level initializer inference, which is to |
| 492 /// visit fields and top level variables in topologically-sorted order and | 495 /// visit fields and top level variables in topologically-sorted order and |
| 493 /// assign their types. | 496 /// assign their types. |
| 494 void performInitializerInference() { | 497 void performInitializerInference() { |
| 495 typeInferenceEngine.finishTopLevel(); | 498 typeInferenceEngine.finishTopLevel(); |
| 496 ticker.logMs("Performed initializer inference"); | 499 ticker.logMs("Performed initializer inference"); |
| 497 } | 500 } |
| 498 | 501 |
| 502 /// Annotates method formals that require runtime checks to restore soundness | |
| 503 /// as a result of the fact that Dart 2.0 treats all class type parameters as | |
| 504 /// covariant. | |
| 505 void computeFormalSafety() { | |
| 506 if (target.strongMode) { | |
| 507 var unorderedClasses = <Class>[]; | |
| 508 builders.forEach((Uri uri, LibraryBuilder library) { | |
|
ahe
2017/08/23 09:55:58
Can you pass in this list either from collectAllCl
Paul Berry
2017/08/23 17:09:10
Done.
| |
| 509 if (library is KernelLibraryBuilder) { | |
| 510 var builtLibrary = library.target; | |
| 511 unorderedClasses.addAll(builtLibrary.classes); | |
| 512 } | |
| 513 }); | |
| 514 for (var cls in hierarchy.getOrderedClasses(unorderedClasses)) { | |
| 515 typeInferenceEngine.computeFormalSafety(cls); | |
| 516 } | |
| 517 ticker.logMs("Computed formal checks"); | |
| 518 } | |
| 519 } | |
| 520 | |
| 499 List<Uri> getDependencies() => sourceBytes.keys.toList(); | 521 List<Uri> getDependencies() => sourceBytes.keys.toList(); |
| 500 | 522 |
| 501 Expression instantiateInvocation(Expression receiver, String name, | 523 Expression instantiateInvocation(Expression receiver, String name, |
| 502 Arguments arguments, int offset, bool isSuper) { | 524 Arguments arguments, int offset, bool isSuper) { |
| 503 return target.backendTarget.instantiateInvocation( | 525 return target.backendTarget.instantiateInvocation( |
| 504 coreTypes, receiver, name, arguments, offset, isSuper); | 526 coreTypes, receiver, name, arguments, offset, isSuper); |
| 505 } | 527 } |
| 506 | 528 |
| 507 Expression instantiateNoSuchMethodError( | 529 Expression instantiateNoSuchMethodError( |
| 508 Expression receiver, String name, Arguments arguments, int offset, | 530 Expression receiver, String name, Arguments arguments, int offset, |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 533 Expression throwCompileConstantError(Expression error) { | 555 Expression throwCompileConstantError(Expression error) { |
| 534 return target.backendTarget.throwCompileConstantError(coreTypes, error); | 556 return target.backendTarget.throwCompileConstantError(coreTypes, error); |
| 535 } | 557 } |
| 536 | 558 |
| 537 Expression buildCompileTimeError(Message message, int offset, Uri uri) { | 559 Expression buildCompileTimeError(Message message, int offset, Uri uri) { |
| 538 String text = target.context | 560 String text = target.context |
| 539 .format(message.withLocation(uri, offset), Severity.error); | 561 .format(message.withLocation(uri, offset), Severity.error); |
| 540 return target.backendTarget.buildCompileTimeError(coreTypes, text, offset); | 562 return target.backendTarget.buildCompileTimeError(coreTypes, text, offset); |
| 541 } | 563 } |
| 542 } | 564 } |
| OLD | NEW |