| 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.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 'package:front_end/file_system.dart'; | |
| 10 | |
| 11 import 'package:kernel/ast.dart' | 9 import 'package:kernel/ast.dart' |
| 12 show | 10 show |
| 13 Arguments, | 11 Arguments, |
| 14 CanonicalName, | 12 CanonicalName, |
| 15 Class, | 13 Class, |
| 16 Constructor, | 14 Constructor, |
| 17 DartType, | 15 DartType, |
| 18 DynamicType, | 16 DynamicType, |
| 19 EmptyStatement, | 17 EmptyStatement, |
| 20 Expression, | 18 Expression, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 35 StringLiteral, | 33 StringLiteral, |
| 36 SuperInitializer, | 34 SuperInitializer, |
| 37 Throw, | 35 Throw, |
| 38 TypeParameter, | 36 TypeParameter, |
| 39 VariableDeclaration, | 37 VariableDeclaration, |
| 40 VariableGet, | 38 VariableGet, |
| 41 VoidType; | 39 VoidType; |
| 42 | 40 |
| 43 import 'package:kernel/type_algebra.dart' show substitute; | 41 import 'package:kernel/type_algebra.dart' show substitute; |
| 44 | 42 |
| 45 import '../source/source_loader.dart' show SourceLoader; | 43 import '../../../file_system.dart' show FileSystem; |
| 44 |
| 45 import '../compiler_context.dart' show CompilerContext; |
| 46 |
| 47 import '../deprecated_problems.dart' |
| 48 show |
| 49 deprecated_formatUnexpected, |
| 50 deprecated_InputError, |
| 51 reportCrash, |
| 52 resetCrashReporting; |
| 53 |
| 54 import '../dill/dill_target.dart' show DillTarget; |
| 55 |
| 56 import '../messages.dart' show LocatedMessage; |
| 57 |
| 58 import '../problems.dart' show unhandled; |
| 46 | 59 |
| 47 import '../source/source_class_builder.dart' show SourceClassBuilder; | 60 import '../source/source_class_builder.dart' show SourceClassBuilder; |
| 48 | 61 |
| 62 import '../source/source_loader.dart' show SourceLoader; |
| 63 |
| 49 import '../target_implementation.dart' show TargetImplementation; | 64 import '../target_implementation.dart' show TargetImplementation; |
| 50 | 65 |
| 51 import '../translate_uri.dart' show TranslateUri; | 66 import '../translate_uri.dart' show TranslateUri; |
| 52 | 67 |
| 53 import '../dill/dill_target.dart' show DillTarget; | |
| 54 | |
| 55 import '../deprecated_problems.dart' | |
| 56 show | |
| 57 deprecated_formatUnexpected, | |
| 58 deprecated_InputError, | |
| 59 deprecated_internalProblem, | |
| 60 reportCrash, | |
| 61 resetCrashReporting; | |
| 62 | |
| 63 import '../messages.dart' show LocatedMessage; | |
| 64 | |
| 65 import '../util/relativize.dart' show relativizeUri; | 68 import '../util/relativize.dart' show relativizeUri; |
| 66 | 69 |
| 67 import '../compiler_context.dart' show CompilerContext; | |
| 68 | |
| 69 import 'kernel_builder.dart' | 70 import 'kernel_builder.dart' |
| 70 show | 71 show |
| 71 Builder, | 72 Builder, |
| 72 ClassBuilder, | 73 ClassBuilder, |
| 73 InvalidTypeBuilder, | 74 InvalidTypeBuilder, |
| 74 KernelClassBuilder, | 75 KernelClassBuilder, |
| 75 KernelLibraryBuilder, | 76 KernelLibraryBuilder, |
| 76 KernelNamedTypeBuilder, | 77 KernelNamedTypeBuilder, |
| 77 KernelProcedureBuilder, | 78 KernelProcedureBuilder, |
| 78 LibraryBuilder, | 79 LibraryBuilder, |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 } | 147 } |
| 147 } | 148 } |
| 148 return new KernelLibraryBuilder(uri, fileUri, loader, isPatch); | 149 return new KernelLibraryBuilder(uri, fileUri, loader, isPatch); |
| 149 } | 150 } |
| 150 | 151 |
| 151 void forEachDirectSupertype(ClassBuilder cls, void f(NamedTypeBuilder type)) { | 152 void forEachDirectSupertype(ClassBuilder cls, void f(NamedTypeBuilder type)) { |
| 152 TypeBuilder supertype = cls.supertype; | 153 TypeBuilder supertype = cls.supertype; |
| 153 if (supertype is NamedTypeBuilder) { | 154 if (supertype is NamedTypeBuilder) { |
| 154 f(supertype); | 155 f(supertype); |
| 155 } else if (supertype != null) { | 156 } else if (supertype != null) { |
| 156 deprecated_internalProblem("Unhandled: ${supertype.runtimeType}"); | 157 unhandled("${supertype.runtimeType}", "forEachDirectSupertype", |
| 158 cls.charOffset, cls.fileUri); |
| 157 } | 159 } |
| 158 if (cls.interfaces != null) { | 160 if (cls.interfaces != null) { |
| 159 for (NamedTypeBuilder t in cls.interfaces) { | 161 for (NamedTypeBuilder t in cls.interfaces) { |
| 160 f(t); | 162 f(t); |
| 161 } | 163 } |
| 162 } | 164 } |
| 163 if (cls.library.loader == loader && | 165 if (cls.library.loader == loader && |
| 164 // TODO(ahe): Implement DillClassBuilder.mixedInType and remove the | 166 // TODO(ahe): Implement DillClassBuilder.mixedInType and remove the |
| 165 // above check. | 167 // above check. |
| 166 cls.mixedInType != null) { | 168 cls.mixedInType != null) { |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 /// >that is accessible to LM , C has an implicitly declared constructor | 421 /// >that is accessible to LM , C has an implicitly declared constructor |
| 420 /// >named q'i = [C/S]qi of the form q'i(ai1,...,aiki) : | 422 /// >named q'i = [C/S]qi of the form q'i(ai1,...,aiki) : |
| 421 /// >super(ai1,...,aiki);. | 423 /// >super(ai1,...,aiki);. |
| 422 TypeDeclarationBuilder supertype = builder; | 424 TypeDeclarationBuilder supertype = builder; |
| 423 while (supertype.isMixinApplication) { | 425 while (supertype.isMixinApplication) { |
| 424 SourceClassBuilder named = supertype; | 426 SourceClassBuilder named = supertype; |
| 425 TypeBuilder type = named.supertype; | 427 TypeBuilder type = named.supertype; |
| 426 if (type is NamedTypeBuilder) { | 428 if (type is NamedTypeBuilder) { |
| 427 supertype = type.builder; | 429 supertype = type.builder; |
| 428 } else { | 430 } else { |
| 429 deprecated_internalProblem("Unhandled: ${type.runtimeType}"); | 431 unhandled("${type.runtimeType}", "installDefaultConstructor", |
| 432 builder.charOffset, builder.fileUri); |
| 430 } | 433 } |
| 431 } | 434 } |
| 432 if (supertype is KernelClassBuilder) { | 435 if (supertype is KernelClassBuilder) { |
| 433 Map<TypeParameter, DartType> substitutionMap = | 436 Map<TypeParameter, DartType> substitutionMap = |
| 434 computeKernelSubstitutionMap( | 437 computeKernelSubstitutionMap( |
| 435 builder.getSubstitutionMap(supertype, builder.fileUri, | 438 builder.getSubstitutionMap(supertype, builder.fileUri, |
| 436 builder.charOffset, dynamicType), | 439 builder.charOffset, dynamicType), |
| 437 builder.parent); | 440 builder.parent); |
| 438 if (supertype.cls.constructors.isEmpty) { | 441 if (supertype.cls.constructors.isEmpty) { |
| 439 builder.addSyntheticConstructor(makeDefaultConstructor()); | 442 builder.addSyntheticConstructor(makeDefaultConstructor()); |
| 440 } else { | 443 } else { |
| 441 for (Constructor constructor in supertype.cls.constructors) { | 444 for (Constructor constructor in supertype.cls.constructors) { |
| 442 builder.addSyntheticConstructor(makeMixinApplicationConstructor( | 445 builder.addSyntheticConstructor(makeMixinApplicationConstructor( |
| 443 builder.cls.mixin, constructor, substitutionMap)); | 446 builder.cls.mixin, constructor, substitutionMap)); |
| 444 } | 447 } |
| 445 } | 448 } |
| 446 } else if (supertype is InvalidTypeBuilder) { | 449 } else if (supertype is InvalidTypeBuilder) { |
| 447 builder.addSyntheticConstructor(makeDefaultConstructor()); | 450 builder.addSyntheticConstructor(makeDefaultConstructor()); |
| 448 } else { | 451 } else { |
| 449 deprecated_internalProblem("Unhandled: ${supertype.runtimeType}"); | 452 unhandled("${supertype.runtimeType}", "installDefaultConstructor", |
| 453 builder.charOffset, builder.fileUri); |
| 450 } | 454 } |
| 451 } else { | 455 } else { |
| 452 /// >Iff no constructor is specified for a class C, it implicitly has a | 456 /// >Iff no constructor is specified for a class C, it implicitly has a |
| 453 /// >default constructor C() : super() {}, unless C is class Object. | 457 /// >default constructor C() : super() {}, unless C is class Object. |
| 454 // The superinitializer is installed below in [finishConstructors]. | 458 // The superinitializer is installed below in [finishConstructors]. |
| 455 builder.addSyntheticConstructor(makeDefaultConstructor()); | 459 builder.addSyntheticConstructor(makeDefaultConstructor()); |
| 456 } | 460 } |
| 457 } | 461 } |
| 458 | 462 |
| 459 Map<TypeParameter, DartType> computeKernelSubstitutionMap( | 463 Map<TypeParameter, DartType> computeKernelSubstitutionMap( |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 } | 664 } |
| 661 for (Constructor constructor in superclass.constructors) { | 665 for (Constructor constructor in superclass.constructors) { |
| 662 if (constructor.name.name.isEmpty) { | 666 if (constructor.name.name.isEmpty) { |
| 663 return constructor.function.requiredParameterCount == 0 | 667 return constructor.function.requiredParameterCount == 0 |
| 664 ? constructor | 668 ? constructor |
| 665 : null; | 669 : null; |
| 666 } | 670 } |
| 667 } | 671 } |
| 668 return null; | 672 return null; |
| 669 } | 673 } |
| OLD | NEW |