| 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_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 CloneVisitor; | 9 import 'package:kernel/clone.dart' show CloneVisitor; |
| 10 | 10 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 // library scope. | 138 // library scope. |
| 139 Scope constructorScope = | 139 Scope constructorScope = |
| 140 new Scope(constructors, null, null, isModifiable: false); | 140 new Scope(constructors, null, null, isModifiable: false); |
| 141 ClassBuilder cls = new SourceClassBuilder( | 141 ClassBuilder cls = new SourceClassBuilder( |
| 142 documentationComment, | 142 documentationComment, |
| 143 metadata, | 143 metadata, |
| 144 modifiers, | 144 modifiers, |
| 145 className, | 145 className, |
| 146 typeVariables, | 146 typeVariables, |
| 147 applyMixins(supertype, | 147 applyMixins(supertype, |
| 148 subclassName: className, typeVariables: typeVariables), | 148 isSyntheticMixinImplementation: true, |
| 149 subclassName: className, |
| 150 typeVariables: typeVariables), |
| 149 interfaces, | 151 interfaces, |
| 150 classScope, | 152 classScope, |
| 151 constructorScope, | 153 constructorScope, |
| 152 this, | 154 this, |
| 153 new List<ConstructorReferenceBuilder>.from(constructorReferences), | 155 new List<ConstructorReferenceBuilder>.from(constructorReferences), |
| 154 charOffset); | 156 charOffset); |
| 155 constructorReferences.clear(); | 157 constructorReferences.clear(); |
| 156 Map<String, TypeVariableBuilder> typeVariablesByName = | 158 Map<String, TypeVariableBuilder> typeVariablesByName = |
| 157 checkTypeVariables(typeVariables, cls); | 159 checkTypeVariables(typeVariables, cls); |
| 158 void setParent(String name, MemberBuilder member) { | 160 void setParent(String name, MemberBuilder member) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 } | 212 } |
| 211 } | 213 } |
| 212 } | 214 } |
| 213 return typeVariablesByName; | 215 return typeVariablesByName; |
| 214 } | 216 } |
| 215 | 217 |
| 216 KernelTypeBuilder applyMixin( | 218 KernelTypeBuilder applyMixin( |
| 217 KernelTypeBuilder supertype, KernelTypeBuilder mixin, String signature, | 219 KernelTypeBuilder supertype, KernelTypeBuilder mixin, String signature, |
| 218 {String documentationComment, | 220 {String documentationComment, |
| 219 List<MetadataBuilder> metadata, | 221 List<MetadataBuilder> metadata, |
| 222 bool isSyntheticMixinImplementation: false, |
| 220 String name, | 223 String name, |
| 221 List<TypeVariableBuilder> typeVariables, | 224 List<TypeVariableBuilder> typeVariables, |
| 222 int modifiers: abstractMask, | 225 int modifiers: abstractMask, |
| 223 List<KernelTypeBuilder> interfaces, | 226 List<KernelTypeBuilder> interfaces, |
| 224 int charOffset: -1}) { | 227 int charOffset: -1}) { |
| 225 var constructors = <String, MemberBuilder>{}; | 228 var constructors = <String, MemberBuilder>{}; |
| 226 bool isNamed = name != null; | 229 bool isNamed = name != null; |
| 227 SourceClassBuilder builder; | 230 SourceClassBuilder builder; |
| 228 if (isNamed) { | 231 if (isNamed) { |
| 229 modifiers |= namedMixinApplicationMask; | 232 modifiers |= namedMixinApplicationMask; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 247 interfaces, | 250 interfaces, |
| 248 new Scope(<String, MemberBuilder>{}, <String, MemberBuilder>{}, | 251 new Scope(<String, MemberBuilder>{}, <String, MemberBuilder>{}, |
| 249 scope.withTypeVariables(typeVariables), | 252 scope.withTypeVariables(typeVariables), |
| 250 isModifiable: false), | 253 isModifiable: false), |
| 251 new Scope(constructors, null, null, isModifiable: false), | 254 new Scope(constructors, null, null, isModifiable: false), |
| 252 this, | 255 this, |
| 253 <ConstructorReferenceBuilder>[], | 256 <ConstructorReferenceBuilder>[], |
| 254 charOffset, | 257 charOffset, |
| 255 null, | 258 null, |
| 256 mixin); | 259 mixin); |
| 260 builder.cls.isSyntheticMixinImplementation = |
| 261 isSyntheticMixinImplementation; |
| 257 addBuilder(name, builder, charOffset); | 262 addBuilder(name, builder, charOffset); |
| 258 if (!isNamed) { | 263 if (!isNamed) { |
| 259 mixinApplicationClasses[name] = builder; | 264 mixinApplicationClasses[name] = builder; |
| 260 } | 265 } |
| 261 } | 266 } |
| 262 return addNamedType(name, <KernelTypeBuilder>[], charOffset) | 267 return addNamedType(name, <KernelTypeBuilder>[], charOffset) |
| 263 ..bind(isNamed ? builder : null); | 268 ..bind(isNamed ? builder : null); |
| 264 } | 269 } |
| 265 | 270 |
| 266 KernelTypeBuilder applyMixins(KernelTypeBuilder type, | 271 KernelTypeBuilder applyMixins(KernelTypeBuilder type, |
| 267 {List<MetadataBuilder> metadata, | 272 {List<MetadataBuilder> metadata, |
| 273 bool isSyntheticMixinImplementation: false, |
| 268 String name, | 274 String name, |
| 269 String subclassName, | 275 String subclassName, |
| 270 List<TypeVariableBuilder> typeVariables, | 276 List<TypeVariableBuilder> typeVariables, |
| 271 int modifiers: abstractMask, | 277 int modifiers: abstractMask, |
| 272 List<KernelTypeBuilder> interfaces, | 278 List<KernelTypeBuilder> interfaces, |
| 273 int charOffset: -1}) { | 279 int charOffset: -1}) { |
| 274 if (type is KernelMixinApplicationBuilder) { | 280 if (type is KernelMixinApplicationBuilder) { |
| 275 subclassName ??= name; | 281 subclassName ??= name; |
| 276 List<List<String>> signatureParts = <List<String>>[]; | 282 List<List<String>> signatureParts = <List<String>>[]; |
| 277 Map<String, String> unresolved = <String, String>{}; | 283 Map<String, String> unresolved = <String, String>{}; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 .toList(), | 406 .toList(), |
| 401 -1); | 407 -1); |
| 402 } | 408 } |
| 403 KernelNamedTypeBuilder mixin = type.mixins[i]; | 409 KernelNamedTypeBuilder mixin = type.mixins[i]; |
| 404 for (var type in mixin.arguments ?? const []) { | 410 for (var type in mixin.arguments ?? const []) { |
| 405 type.bind(variables[type.name]); | 411 type.bind(variables[type.name]); |
| 406 } | 412 } |
| 407 checkArguments(supertype); | 413 checkArguments(supertype); |
| 408 checkArguments(mixin); | 414 checkArguments(mixin); |
| 409 supertype = applyMixin(supertype, mixin, signature, | 415 supertype = applyMixin(supertype, mixin, signature, |
| 416 isSyntheticMixinImplementation: true, |
| 410 typeVariables: | 417 typeVariables: |
| 411 new List<TypeVariableBuilder>.from(variables.values)); | 418 new List<TypeVariableBuilder>.from(variables.values)); |
| 412 } | 419 } |
| 413 KernelNamedTypeBuilder mixin = type.mixins.last; | 420 KernelNamedTypeBuilder mixin = type.mixins.last; |
| 414 | 421 |
| 415 Set<String> supertypeArguments = new Set<String>(); | 422 Set<String> supertypeArguments = new Set<String>(); |
| 416 for (var part in currentSignatureParts) { | 423 for (var part in currentSignatureParts) { |
| 417 supertypeArguments.addAll(part); | 424 supertypeArguments.addAll(part); |
| 418 } | 425 } |
| 419 String signature = name == null ? computeSignature() : ""; | 426 String signature = name == null ? computeSignature() : ""; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 440 for (var type in mixin.arguments ?? const []) { | 447 for (var type in mixin.arguments ?? const []) { |
| 441 type.bind(variables[type.name]); | 448 type.bind(variables[type.name]); |
| 442 } | 449 } |
| 443 } | 450 } |
| 444 checkArguments(supertype); | 451 checkArguments(supertype); |
| 445 checkArguments(mixin); | 452 checkArguments(mixin); |
| 446 | 453 |
| 447 KernelNamedTypeBuilder t = applyMixin(supertype, mixin, signature, | 454 KernelNamedTypeBuilder t = applyMixin(supertype, mixin, signature, |
| 448 metadata: metadata, | 455 metadata: metadata, |
| 449 name: name, | 456 name: name, |
| 457 isSyntheticMixinImplementation: isSyntheticMixinImplementation, |
| 450 typeVariables: typeVariables, | 458 typeVariables: typeVariables, |
| 451 modifiers: modifiers, | 459 modifiers: modifiers, |
| 452 interfaces: interfaces, | 460 interfaces: interfaces, |
| 453 charOffset: charOffset); | 461 charOffset: charOffset); |
| 454 if (name == null) { | 462 if (name == null) { |
| 455 var builder = t.builder; | 463 var builder = t.builder; |
| 456 t = addNamedType( | 464 t = addNamedType( |
| 457 t.name, freeTypes.keys.map((k) => freeTypes[k]).toList(), -1); | 465 t.name, freeTypes.keys.map((k) => freeTypes[k]).toList(), -1); |
| 458 if (builder != null) { | 466 if (builder != null) { |
| 459 t.bind(builder); | 467 t.bind(builder); |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 mixinApplicationClasses.putIfAbsent(name, () => builder); | 878 mixinApplicationClasses.putIfAbsent(name, () => builder); |
| 871 if (existing != builder) { | 879 if (existing != builder) { |
| 872 part.scope.local.remove(name); | 880 part.scope.local.remove(name); |
| 873 } | 881 } |
| 874 }); | 882 }); |
| 875 super.includePart(part); | 883 super.includePart(part); |
| 876 nativeMethods.addAll(part.nativeMethods); | 884 nativeMethods.addAll(part.nativeMethods); |
| 877 boundlessTypeVariables.addAll(part.boundlessTypeVariables); | 885 boundlessTypeVariables.addAll(part.boundlessTypeVariables); |
| 878 } | 886 } |
| 879 } | 887 } |
| OLD | NEW |