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.class_builder; | 5 library fasta.class_builder; |
6 | 6 |
7 import '../errors.dart' show internalError; | 7 import '../errors.dart' show internalError; |
8 | 8 |
9 import 'builder.dart' | 9 import 'builder.dart' |
10 show | 10 show |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 LibraryBuilder parent, | 49 LibraryBuilder parent, |
50 int charOffset) | 50 int charOffset) |
51 : scopeBuilder = new ScopeBuilder(scope), | 51 : scopeBuilder = new ScopeBuilder(scope), |
52 constructorScopeBuilder = new ScopeBuilder(constructors), | 52 constructorScopeBuilder = new ScopeBuilder(constructors), |
53 super(metadata, modifiers, name, parent, charOffset); | 53 super(metadata, modifiers, name, parent, charOffset); |
54 | 54 |
55 /// Returns true if this class is the result of applying a mixin to its | 55 /// Returns true if this class is the result of applying a mixin to its |
56 /// superclass. | 56 /// superclass. |
57 bool get isMixinApplication => mixedInType != null; | 57 bool get isMixinApplication => mixedInType != null; |
58 | 58 |
| 59 bool get isNamedMixinApplication { |
| 60 return isMixinApplication && super.isNamedMixinApplication; |
| 61 } |
| 62 |
59 T get mixedInType; | 63 T get mixedInType; |
60 | 64 |
| 65 void set mixedInType(T mixin); |
| 66 |
61 List<ConstructorReferenceBuilder> get constructorReferences => null; | 67 List<ConstructorReferenceBuilder> get constructorReferences => null; |
62 | 68 |
63 LibraryBuilder get library { | 69 LibraryBuilder get library { |
64 LibraryBuilder library = parent; | 70 LibraryBuilder library = parent; |
65 return library.partOfLibrary ?? library; | 71 return library.partOfLibrary ?? library; |
66 } | 72 } |
67 | 73 |
68 @override | 74 @override |
69 int resolveConstructors(LibraryBuilder library) { | 75 int resolveConstructors(LibraryBuilder library) { |
70 if (constructorReferences == null) return 0; | 76 if (constructorReferences == null) return 0; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 if (s != null) return s; | 137 if (s != null) return s; |
132 } | 138 } |
133 } | 139 } |
134 return null; | 140 return null; |
135 } | 141 } |
136 | 142 |
137 void handleNamedTypeBuilder(NamedTypeBuilder t) { | 143 void handleNamedTypeBuilder(NamedTypeBuilder t) { |
138 builder = t.builder; | 144 builder = t.builder; |
139 arguments = t.arguments ?? const []; | 145 arguments = t.arguments ?? const []; |
140 if (builder is ClassBuilder) { | 146 if (builder is ClassBuilder) { |
141 variables = builder.typeVariables; | 147 ClassBuilder cls = builder; |
142 supertype = builder.supertype; | 148 variables = cls.typeVariables; |
| 149 supertype = cls.supertype; |
143 } | 150 } |
144 } | 151 } |
145 | 152 |
146 while (builder != superclass) { | 153 while (builder != superclass) { |
147 variables = null; | 154 variables = null; |
148 if (supertype is NamedTypeBuilder) { | 155 if (supertype is NamedTypeBuilder) { |
149 handleNamedTypeBuilder(supertype); | 156 handleNamedTypeBuilder(supertype); |
150 } else if (supertype is MixinApplicationBuilder) { | 157 } else if (supertype is MixinApplicationBuilder) { |
151 MixinApplicationBuilder t = supertype; | 158 MixinApplicationBuilder t = supertype; |
152 NamedTypeBuilder s = findSuperclass(t); | 159 NamedTypeBuilder s = findSuperclass(t); |
153 if (s != null) { | 160 if (s != null) { |
154 handleNamedTypeBuilder(s); | 161 handleNamedTypeBuilder(s); |
155 } | 162 } |
156 supertype = t.supertype; | 163 supertype = t.supertype; |
157 } else { | 164 } else { |
158 internalError("Superclass not found.", fileUri, charOffset); | 165 internalError("Superclass not found '${superclass.fullNameForErrors}'.", |
| 166 fileUri, charOffset); |
159 } | 167 } |
160 if (variables != null) { | 168 if (variables != null) { |
161 Map<TypeVariableBuilder, TypeBuilder> directSubstitutionMap = | 169 Map<TypeVariableBuilder, TypeBuilder> directSubstitutionMap = |
162 <TypeVariableBuilder, TypeBuilder>{}; | 170 <TypeVariableBuilder, TypeBuilder>{}; |
163 for (int i = 0; i < variables.length; i++) { | 171 for (int i = 0; i < variables.length; i++) { |
164 TypeBuilder argument = | 172 TypeBuilder argument = |
165 i < arguments.length ? arguments[i] : dynamicType; | 173 i < arguments.length ? arguments[i] : dynamicType; |
166 if (substitutionMap != null) { | 174 if (substitutionMap != null) { |
167 argument = argument.subst(substitutionMap); | 175 argument = argument.subst(substitutionMap); |
168 } | 176 } |
(...skipping 21 matching lines...) Expand all Loading... |
190 } | 198 } |
191 | 199 |
192 void addWarning(int charOffset, String message) { | 200 void addWarning(int charOffset, String message) { |
193 library.addWarning(charOffset, message, fileUri: fileUri); | 201 library.addWarning(charOffset, message, fileUri: fileUri); |
194 } | 202 } |
195 | 203 |
196 void addNit(int charOffset, String message) { | 204 void addNit(int charOffset, String message) { |
197 library.addNit(charOffset, message, fileUri: fileUri); | 205 library.addNit(charOffset, message, fileUri: fileUri); |
198 } | 206 } |
199 } | 207 } |
OLD | NEW |