| 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 26 matching lines...) Expand all Loading... |
| 37 KernelFormalParameterBuilder, | 37 KernelFormalParameterBuilder, |
| 38 KernelFunctionTypeAliasBuilder, | 38 KernelFunctionTypeAliasBuilder, |
| 39 KernelFunctionTypeBuilder, | 39 KernelFunctionTypeBuilder, |
| 40 KernelInvalidTypeBuilder, | 40 KernelInvalidTypeBuilder, |
| 41 KernelMixinApplicationBuilder, | 41 KernelMixinApplicationBuilder, |
| 42 KernelNamedMixinApplicationBuilder, | 42 KernelNamedMixinApplicationBuilder, |
| 43 KernelNamedTypeBuilder, | 43 KernelNamedTypeBuilder, |
| 44 KernelProcedureBuilder, | 44 KernelProcedureBuilder, |
| 45 KernelTypeBuilder, | 45 KernelTypeBuilder, |
| 46 KernelTypeVariableBuilder, | 46 KernelTypeVariableBuilder, |
| 47 LibraryBuilder, |
| 47 MemberBuilder, | 48 MemberBuilder, |
| 48 MetadataBuilder, | 49 MetadataBuilder, |
| 49 NamedMixinApplicationBuilder, | 50 NamedMixinApplicationBuilder, |
| 50 PrefixBuilder, | 51 PrefixBuilder, |
| 51 ProcedureBuilder, | 52 ProcedureBuilder, |
| 52 Scope, | 53 Scope, |
| 53 TypeBuilder, | 54 TypeBuilder, |
| 54 TypeVariableBuilder, | 55 TypeVariableBuilder, |
| 55 compareProcedures; | 56 compareProcedures; |
| 56 | 57 |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 metadata, modifiers, type, name, hasThis, this, charOffset); | 334 metadata, modifiers, type, name, hasThis, this, charOffset); |
| 334 } | 335 } |
| 335 | 336 |
| 336 KernelTypeVariableBuilder addTypeVariable( | 337 KernelTypeVariableBuilder addTypeVariable( |
| 337 String name, KernelTypeBuilder bound, int charOffset) { | 338 String name, KernelTypeBuilder bound, int charOffset) { |
| 338 var builder = new KernelTypeVariableBuilder(name, this, charOffset, bound); | 339 var builder = new KernelTypeVariableBuilder(name, this, charOffset, bound); |
| 339 boundlessTypeVariables.add(builder); | 340 boundlessTypeVariables.add(builder); |
| 340 return builder; | 341 return builder; |
| 341 } | 342 } |
| 342 | 343 |
| 343 void buildBuilder(Builder builder) { | 344 @override |
| 345 void buildBuilder(Builder builder, LibraryBuilder coreLibrary) { |
| 344 if (builder is SourceClassBuilder) { | 346 if (builder is SourceClassBuilder) { |
| 345 Class cls = builder.build(this); | 347 Class cls = builder.build(this, coreLibrary); |
| 346 library.addClass(cls); | 348 library.addClass(cls); |
| 347 } else if (builder is KernelFieldBuilder) { | 349 } else if (builder is KernelFieldBuilder) { |
| 348 library.addMember(builder.build(this)..isStatic = true); | 350 library.addMember(builder.build(this)..isStatic = true); |
| 349 } else if (builder is KernelProcedureBuilder) { | 351 } else if (builder is KernelProcedureBuilder) { |
| 350 library.addMember(builder.build(this)..isStatic = true); | 352 library.addMember(builder.build(this)..isStatic = true); |
| 351 } else if (builder is FunctionTypeAliasBuilder) { | 353 } else if (builder is FunctionTypeAliasBuilder) { |
| 352 // Kernel discard typedefs and use their corresponding function types | 354 // Kernel discard typedefs and use their corresponding function types |
| 353 // directly. | 355 // directly. |
| 354 } else if (builder is KernelEnumBuilder) { | 356 } else if (builder is KernelEnumBuilder) { |
| 355 library.addClass(builder.build(this)); | 357 library.addClass(builder.build(this, coreLibrary)); |
| 356 } else if (builder is PrefixBuilder) { | 358 } else if (builder is PrefixBuilder) { |
| 357 // Ignored. Kernel doesn't represent prefixes. | 359 // Ignored. Kernel doesn't represent prefixes. |
| 358 } else if (builder is BuiltinTypeBuilder) { | 360 } else if (builder is BuiltinTypeBuilder) { |
| 359 // Nothing needed. | 361 // Nothing needed. |
| 360 } else { | 362 } else { |
| 361 internalError("Unhandled builder: ${builder.runtimeType}"); | 363 internalError("Unhandled builder: ${builder.runtimeType}"); |
| 362 } | 364 } |
| 363 } | 365 } |
| 364 | 366 |
| 365 Library build() { | 367 @override |
| 366 super.build(); | 368 Library build(LibraryBuilder coreLibrary) { |
| 369 super.build(coreLibrary); |
| 367 library.name = name; | 370 library.name = name; |
| 368 library.procedures.sort(compareProcedures); | 371 library.procedures.sort(compareProcedures); |
| 369 return library; | 372 return library; |
| 370 } | 373 } |
| 371 | 374 |
| 372 @override | 375 @override |
| 373 Builder buildAmbiguousBuilder( | 376 Builder buildAmbiguousBuilder( |
| 374 String name, Builder builder, Builder other, int charOffset, | 377 String name, Builder builder, Builder other, int charOffset, |
| 375 {bool isExport: false, bool isImport: false}) { | 378 {bool isExport: false, bool isImport: false}) { |
| 376 // TODO(ahe): Can I move this to Scope or Prefix? | 379 // TODO(ahe): Can I move this to Scope or Prefix? |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 } | 539 } |
| 537 | 540 |
| 538 @override | 541 @override |
| 539 void includePart(covariant KernelLibraryBuilder part) { | 542 void includePart(covariant KernelLibraryBuilder part) { |
| 540 super.includePart(part); | 543 super.includePart(part); |
| 541 nativeMethods.addAll(part.nativeMethods); | 544 nativeMethods.addAll(part.nativeMethods); |
| 542 boundlessTypeVariables.addAll(part.boundlessTypeVariables); | 545 boundlessTypeVariables.addAll(part.boundlessTypeVariables); |
| 543 assert(mixinApplicationClasses.isEmpty); | 546 assert(mixinApplicationClasses.isEmpty); |
| 544 } | 547 } |
| 545 } | 548 } |
| OLD | NEW |