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

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

Issue 2689303003: Implement type variables in mixin applications. (Closed)
Patch Set: Address comments. Created 3 years, 10 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
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_library_builder; 5 library fasta.kernel_library_builder;
6 6
7 import 'package:kernel/ast.dart'; 7 import 'package:kernel/ast.dart';
8 8
9 import 'package:kernel/clone.dart' show 9 import 'package:kernel/clone.dart' show
10 CloneVisitor; 10 CloneVisitor;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 new DynamicTypeBuilder(const DynamicType(), this, charOffset); 85 new DynamicTypeBuilder(const DynamicType(), this, charOffset);
86 } else { 86 } else {
87 addType(type); 87 addType(type);
88 } 88 }
89 return type; 89 return type;
90 } 90 }
91 91
92 KernelTypeBuilder addMixinApplication(KernelTypeBuilder supertype, 92 KernelTypeBuilder addMixinApplication(KernelTypeBuilder supertype,
93 List<KernelTypeBuilder> mixins, int charOffset) { 93 List<KernelTypeBuilder> mixins, int charOffset) {
94 KernelTypeBuilder type = new KernelMixinApplicationBuilder( 94 KernelTypeBuilder type = new KernelMixinApplicationBuilder(
95 supertype, mixins, charOffset, fileUri); 95 supertype, mixins, this, charOffset, fileUri);
96 return addType(type); 96 return addType(type);
97 } 97 }
98 98
99 KernelTypeBuilder addVoidType(int charOffset) { 99 KernelTypeBuilder addVoidType(int charOffset) {
100 return new KernelNamedTypeBuilder("void", null, charOffset, fileUri); 100 return new KernelNamedTypeBuilder("void", null, charOffset, fileUri);
101 } 101 }
102 102
103 void addClass(List<MetadataBuilder> metadata, 103 void addClass(List<MetadataBuilder> metadata,
104 int modifiers, String className, 104 int modifiers, String className,
105 List<TypeVariableBuilder> typeVariables, KernelTypeBuilder supertype, 105 List<TypeVariableBuilder> typeVariables, KernelTypeBuilder supertype,
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 KernelTypeBuilder bound, int charOffset) { 218 KernelTypeBuilder bound, int charOffset) {
219 var builder = new KernelTypeVariableBuilder(name, this, charOffset, bound); 219 var builder = new KernelTypeVariableBuilder(name, this, charOffset, bound);
220 boundlessTypeVariables.add(builder); 220 boundlessTypeVariables.add(builder);
221 return builder; 221 return builder;
222 } 222 }
223 223
224 void buildBuilder(Builder builder) { 224 void buildBuilder(Builder builder) {
225 if (builder is SourceClassBuilder) { 225 if (builder is SourceClassBuilder) {
226 Class cls = builder.build(this); 226 Class cls = builder.build(this);
227 library.addClass(cls); 227 library.addClass(cls);
228 Class superclass = cls.superclass;
229 if (superclass != null && superclass.isMixinApplication) {
230 List<Class> mixinApplications = <Class>[];
231 mixinApplicationClasses.add(cls);
232 while (superclass != null && superclass.isMixinApplication) {
233 if (superclass.parent == null) {
234 mixinApplications.add(superclass);
235 }
236 superclass = superclass.superclass;
237 }
238 for (Class cls in mixinApplications.reversed) {
239 // TODO(ahe): Should be able to move this into the above loop as long
240 // as we don't care about matching dartk perfectly.
241 library.addClass(cls);
242 mixinApplicationClasses.add(cls);
243 }
244 }
245 } else if (builder is KernelFieldBuilder) { 228 } else if (builder is KernelFieldBuilder) {
246 library.addMember(builder.build(library)..isStatic = true); 229 library.addMember(builder.build(library)..isStatic = true);
247 } else if (builder is KernelProcedureBuilder) { 230 } else if (builder is KernelProcedureBuilder) {
248 library.addMember(builder.build(library)..isStatic = true); 231 library.addMember(builder.build(library)..isStatic = true);
249 } else if (builder is FunctionTypeAliasBuilder) { 232 } else if (builder is FunctionTypeAliasBuilder) {
250 // Kernel discard typedefs and use their corresponding function types 233 // Kernel discard typedefs and use their corresponding function types
251 // directly. 234 // directly.
252 } else if (builder is KernelEnumBuilder) { 235 } else if (builder is KernelEnumBuilder) {
253 library.addClass(builder.build(this)); 236 library.addClass(builder.build(this));
254 } else if (builder is PrefixBuilder) { 237 } else if (builder is PrefixBuilder) {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 } 355 }
373 } 356 }
374 357
375 bool isConstructorName(String name, String className) { 358 bool isConstructorName(String name, String className) {
376 if (name.startsWith(className)) { 359 if (name.startsWith(className)) {
377 if (name.length == className.length) return true; 360 if (name.length == className.length) return true;
378 if (name.startsWith(".", className.length)) return true; 361 if (name.startsWith(".", className.length)) return true;
379 } 362 }
380 return false; 363 return false;
381 } 364 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698