| 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_mixin_application_builder; | 5 library fasta.kernel_mixin_application_builder; |
| 6 | 6 |
| 7 import 'package:kernel/ast.dart' show InterfaceType, Supertype, setParents; | 7 import 'package:kernel/ast.dart' show InterfaceType, Supertype, setParents; |
| 8 | 8 |
| 9 import '../modifier.dart' show abstractMask; | 9 import '../modifier.dart' show abstractMask; |
| 10 | 10 |
| 11 import 'kernel_builder.dart' | 11 import 'kernel_builder.dart' |
| 12 show | 12 show |
| 13 Builder, | 13 Builder, |
| 14 ConstructorReferenceBuilder, | 14 ConstructorReferenceBuilder, |
| 15 KernelLibraryBuilder, | 15 KernelLibraryBuilder, |
| 16 KernelNamedTypeBuilder, | 16 KernelNamedTypeBuilder, |
| 17 KernelTypeBuilder, | 17 KernelTypeBuilder, |
| 18 KernelTypeVariableBuilder, | 18 KernelTypeVariableBuilder, |
| 19 LibraryBuilder, |
| 19 MixinApplicationBuilder, | 20 MixinApplicationBuilder, |
| 20 TypeBuilder, | 21 TypeBuilder, |
| 21 TypeVariableBuilder; | 22 TypeVariableBuilder; |
| 22 | 23 |
| 23 import '../util/relativize.dart' show relativizeUri; | 24 import '../util/relativize.dart' show relativizeUri; |
| 24 | 25 |
| 25 import '../source/source_class_builder.dart' show SourceClassBuilder; | 26 import '../source/source_class_builder.dart' show SourceClassBuilder; |
| 26 | 27 |
| 27 class KernelMixinApplicationBuilder | 28 class KernelMixinApplicationBuilder |
| 28 extends MixinApplicationBuilder<KernelTypeBuilder> | 29 extends MixinApplicationBuilder<KernelTypeBuilder> |
| 29 implements KernelTypeBuilder { | 30 implements KernelTypeBuilder { |
| 30 final int charOffset; | 31 final int charOffset; |
| 31 | 32 |
| 32 final String relativeFileUri; | 33 final String relativeFileUri; |
| 33 | 34 |
| 34 final KernelLibraryBuilder library; | 35 final KernelLibraryBuilder library; |
| 35 | 36 |
| 36 Supertype builtType; | 37 Supertype builtType; |
| 37 | 38 |
| 38 List<TypeVariableBuilder> typeVariables; | 39 List<TypeVariableBuilder> typeVariables; |
| 39 | 40 |
| 40 String subclassName; | 41 String subclassName; |
| 41 | 42 |
| 42 KernelMixinApplicationBuilder(KernelTypeBuilder supertype, | 43 KernelMixinApplicationBuilder(KernelTypeBuilder supertype, |
| 43 List<KernelTypeBuilder> mixins, this.library, int charOffset, Uri fileUri) | 44 List<KernelTypeBuilder> mixins, this.library, int charOffset, Uri fileUri) |
| 44 : charOffset = charOffset, | 45 : charOffset = charOffset, |
| 45 relativeFileUri = relativizeUri(fileUri), | 46 relativeFileUri = relativizeUri(fileUri), |
| 46 super(supertype, mixins, charOffset, fileUri); | 47 super(supertype, mixins, charOffset, fileUri); |
| 47 | 48 |
| 48 InterfaceType build() => buildSupertype().asInterfaceType; | 49 InterfaceType build(LibraryBuilder library) { |
| 50 return buildSupertype(library)?.asInterfaceType; |
| 51 } |
| 49 | 52 |
| 50 Supertype buildSupertype() { | 53 Supertype buildSupertype(LibraryBuilder library) { |
| 51 if (builtType != null) return builtType; | 54 if (builtType != null) return builtType; |
| 52 KernelTypeBuilder s = this.supertype; | 55 KernelTypeBuilder s = this.supertype; |
| 53 for (KernelTypeBuilder builder in mixins) { | 56 for (KernelTypeBuilder builder in mixins) { |
| 54 s = applyMixin(s, builder); | 57 s = applyMixin(s, builder); |
| 55 } | 58 } |
| 56 builtType = s.buildSupertype(); | 59 builtType = s.buildSupertype(library); |
| 57 return builtType; | 60 return builtType; |
| 58 } | 61 } |
| 59 | 62 |
| 60 TypeBuilder applyMixin(TypeBuilder supertype, TypeBuilder mixin) { | 63 TypeBuilder applyMixin(TypeBuilder supertype, TypeBuilder mixin) { |
| 61 KernelLibraryBuilder library = this.library.partOfLibrary ?? this.library; | 64 KernelLibraryBuilder library = this.library.partOfLibrary ?? this.library; |
| 62 List<KernelTypeBuilder> typeArguments; | 65 List<KernelTypeBuilder> typeArguments; |
| 63 List<TypeVariableBuilder> newTypeVariables; | 66 List<TypeVariableBuilder> newTypeVariables; |
| 64 if (typeVariables != null) { | 67 if (typeVariables != null) { |
| 65 assert(subclassName != null); | 68 assert(subclassName != null); |
| 66 newTypeVariables = library.copyTypeVariables(typeVariables); | 69 newTypeVariables = library.copyTypeVariables(typeVariables); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 cls.cls.typeParameters.add(t.parameter); | 105 cls.cls.typeParameters.add(t.parameter); |
| 103 } | 106 } |
| 104 setParents(cls.cls.typeParameters, cls.cls); | 107 setParents(cls.cls.typeParameters, cls.cls); |
| 105 } | 108 } |
| 106 return cls; | 109 return cls; |
| 107 }); | 110 }); |
| 108 return new KernelNamedTypeBuilder( | 111 return new KernelNamedTypeBuilder( |
| 109 name, typeArguments, charOffset, library.fileUri)..builder = cls; | 112 name, typeArguments, charOffset, library.fileUri)..builder = cls; |
| 110 } | 113 } |
| 111 } | 114 } |
| OLD | NEW |