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

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

Issue 2631693002: Fasta kernel builders. (Closed)
Patch Set: Address comments. Created 3 years, 11 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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library fasta.kernel_mixin_application_builder;
6
7 import 'package:kernel/ast.dart' show
8 Class,
9 InterfaceType,
10 Supertype;
11
12 import 'kernel_builder.dart' show
13 KernelTypeBuilder,
14 MixinApplicationBuilder;
15
16 class KernelMixinApplicationBuilder
17 extends MixinApplicationBuilder<KernelTypeBuilder>
18 implements KernelTypeBuilder {
19 Supertype builtType;
20
21 KernelMixinApplicationBuilder(KernelTypeBuilder supertype,
22 List<KernelTypeBuilder> mixins)
23 : super(supertype, mixins);
24
25 InterfaceType build() => buildSupertype().asInterfaceType;
26
27 Supertype buildSupertype() {
28 if (builtType != null) return builtType;
29 Supertype supertype =
30 this.supertype.buildSupertype()?.classNode?.asRawSupertype;
31 if (supertype == null) {
32 return null;
33 }
34 for (KernelTypeBuilder builder in mixins) {
35 Supertype mixin = builder.buildSupertype()?.classNode?.asRawSupertype;
36 if (mixin == null) {
37 return null;
38 }
39 Class application = new Class(
40 name: "${supertype.classNode.name}&${mixin.classNode.name}",
41 isAbstract: true,
42 supertype: supertype,
43 mixedInType: mixin,
44 typeParameters: null); // TODO(ahe): Compute these.
45 // TODO(ahe): Use asThisSupertype instead and translate type variables.
46 supertype = application.asRawSupertype;
47 }
48 builtType = supertype;
49 return builtType;
50 }
51 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698