| 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 | 7 import 'package:kernel/ast.dart' show |
| 8 Class, | 8 Class, |
| 9 InterfaceType, | 9 InterfaceType, |
| 10 Supertype; | 10 Supertype; |
| 11 | 11 |
| 12 import 'kernel_builder.dart' show | 12 import 'kernel_builder.dart' show |
| 13 KernelTypeBuilder, | 13 KernelTypeBuilder, |
| 14 MixinApplicationBuilder; | 14 MixinApplicationBuilder; |
| 15 | 15 |
| 16 import '../util/relativize.dart' show |
| 17 relativizeUri; |
| 18 |
| 16 class KernelMixinApplicationBuilder | 19 class KernelMixinApplicationBuilder |
| 17 extends MixinApplicationBuilder<KernelTypeBuilder> | 20 extends MixinApplicationBuilder<KernelTypeBuilder> |
| 18 implements KernelTypeBuilder { | 21 implements KernelTypeBuilder { |
| 22 final int charOffset; |
| 23 |
| 24 final String relativeFileUri; |
| 25 |
| 19 Supertype builtType; | 26 Supertype builtType; |
| 20 | 27 |
| 21 KernelMixinApplicationBuilder(KernelTypeBuilder supertype, | 28 KernelMixinApplicationBuilder(KernelTypeBuilder supertype, |
| 22 List<KernelTypeBuilder> mixins) | 29 List<KernelTypeBuilder> mixins, int charOffset, Uri fileUri) |
| 23 : super(supertype, mixins); | 30 : charOffset = charOffset, |
| 31 relativeFileUri = relativizeUri(fileUri), |
| 32 super(supertype, mixins, charOffset, fileUri); |
| 24 | 33 |
| 25 InterfaceType build() => buildSupertype().asInterfaceType; | 34 InterfaceType build() => buildSupertype().asInterfaceType; |
| 26 | 35 |
| 27 Supertype buildSupertype() { | 36 Supertype buildSupertype() { |
| 28 if (builtType != null) return builtType; | 37 if (builtType != null) return builtType; |
| 29 Supertype supertype = | 38 Supertype supertype = |
| 30 this.supertype.buildSupertype()?.classNode?.asRawSupertype; | 39 this.supertype.buildSupertype()?.classNode?.asRawSupertype; |
| 31 if (supertype == null) { | 40 if (supertype == null) { |
| 32 return null; | 41 return null; |
| 33 } | 42 } |
| 34 for (KernelTypeBuilder builder in mixins) { | 43 for (KernelTypeBuilder builder in mixins) { |
| 35 Supertype mixin = builder.buildSupertype()?.classNode?.asRawSupertype; | 44 Supertype mixin = builder.buildSupertype()?.classNode?.asRawSupertype; |
| 36 if (mixin == null) { | 45 if (mixin == null) { |
| 37 return null; | 46 return null; |
| 38 } | 47 } |
| 39 Class application = new Class( | 48 Class application = new Class( |
| 40 name: "${supertype.classNode.name}&${mixin.classNode.name}", | 49 name: "${supertype.classNode.name}&${mixin.classNode.name}", |
| 41 isAbstract: true, | 50 isAbstract: true, |
| 42 supertype: supertype, | 51 supertype: supertype, |
| 43 mixedInType: mixin, | 52 mixedInType: mixin, |
| 44 typeParameters: null); // TODO(ahe): Compute these. | 53 typeParameters: null, // TODO(ahe): Compute these. |
| 54 fileUri: relativeFileUri); |
| 55 application.fileOffset = charOffset; |
| 45 // TODO(ahe): Use asThisSupertype instead and translate type variables. | 56 // TODO(ahe): Use asThisSupertype instead and translate type variables. |
| 46 supertype = application.asRawSupertype; | 57 supertype = application.asRawSupertype; |
| 47 } | 58 } |
| 48 builtType = supertype; | 59 builtType = supertype; |
| 49 return builtType; | 60 return builtType; |
| 50 } | 61 } |
| 51 } | 62 } |
| OLD | NEW |