| 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.mixin_application_builder; | 5 library fasta.mixin_application_builder; |
| 6 | 6 |
| 7 import '../errors.dart' show | 7 import '../errors.dart' show |
| 8 internalError; | 8 internalError; |
| 9 | 9 |
| 10 import 'builder.dart' show | 10 import 'builder.dart' show |
| 11 TypeBuilder, | 11 TypeBuilder, |
| 12 TypeDeclarationBuilder; | 12 TypeDeclarationBuilder, |
| 13 TypeVariableBuilder; |
| 13 | 14 |
| 14 import 'scope.dart' show | 15 import 'scope.dart' show |
| 15 Scope; | 16 Scope; |
| 16 | 17 |
| 17 abstract class MixinApplicationBuilder<T extends TypeBuilder> | 18 abstract class MixinApplicationBuilder<T extends TypeBuilder> |
| 18 extends TypeBuilder { | 19 extends TypeBuilder { |
| 19 final T supertype; | 20 final T supertype; |
| 20 final List<T> mixins; | 21 final List<T> mixins; |
| 21 | 22 |
| 22 MixinApplicationBuilder(this.supertype, this.mixins, int charOffset, | 23 MixinApplicationBuilder(this.supertype, this.mixins, int charOffset, |
| 23 Uri fileUri) | 24 Uri fileUri) |
| 24 : super(charOffset, fileUri); | 25 : super(charOffset, fileUri); |
| 25 | 26 |
| 27 void set typeVariables(List<TypeVariableBuilder> variables); |
| 28 |
| 29 /// If this mixin application uses type variables, it needs a unique name |
| 30 /// based on its subclass. If this name is provided, the name will be |
| 31 /// `name^mixin`, otherwise it'll be `superclass&mixin`. |
| 32 // |
| 33 // TODO(ahe): This is to reduce diff against dartk. Consider if this is |
| 34 // necessary. |
| 35 void set subclassName(String value); |
| 36 |
| 26 String get name => null; | 37 String get name => null; |
| 27 | 38 |
| 28 void resolveIn(Scope scope) { | 39 void resolveIn(Scope scope) { |
| 29 supertype.resolveIn(scope); | 40 supertype.resolveIn(scope); |
| 30 for (T t in mixins) { | 41 for (T t in mixins) { |
| 31 t.resolveIn(scope); | 42 t.resolveIn(scope); |
| 32 } | 43 } |
| 33 } | 44 } |
| 34 | 45 |
| 35 void bind(TypeDeclarationBuilder builder) { | 46 void bind(TypeDeclarationBuilder builder) { |
| 36 internalError("Internal error: can't bind a mixin application."); | 47 internalError("Internal error: can't bind a mixin application."); |
| 37 } | 48 } |
| 38 | 49 |
| 39 String get debugName => "MixinApplicationBuilder"; | 50 String get debugName => "MixinApplicationBuilder"; |
| 40 | 51 |
| 41 StringBuffer printOn(StringBuffer buffer) { | 52 StringBuffer printOn(StringBuffer buffer) { |
| 42 buffer.write(supertype); | 53 buffer.write(supertype); |
| 43 buffer.write(" with "); | 54 buffer.write(" with "); |
| 44 bool first = true; | 55 bool first = true; |
| 45 for (T t in mixins) { | 56 for (T t in mixins) { |
| 46 if (!first) buffer.write(", "); | 57 if (!first) buffer.write(", "); |
| 47 first = false; | 58 first = false; |
| 48 t.printOn(buffer); | 59 t.printOn(buffer); |
| 49 } | 60 } |
| 50 return buffer; | 61 return buffer; |
| 51 } | 62 } |
| 52 } | 63 } |
| OLD | NEW |