| 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.source_class_builder; | 5 library fasta.source_class_builder; |
| 6 | 6 |
| 7 import 'package:front_end/src/fasta/builder/class_builder.dart' | |
| 8 show ClassBuilder; | |
| 9 | |
| 10 import 'package:front_end/src/fasta/source/source_library_builder.dart' | |
| 11 show SourceLibraryBuilder; | |
| 12 | |
| 13 import 'package:kernel/ast.dart' | 7 import 'package:kernel/ast.dart' |
| 14 show Class, Constructor, Supertype, TreeNode, setParents; | 8 show Class, Constructor, Supertype, TreeNode, setParents; |
| 15 | 9 |
| 16 import '../deprecated_problems.dart' show deprecated_internalProblem; | 10 import '../dill/dill_member_builder.dart' show DillMemberBuilder; |
| 17 | 11 |
| 18 import '../kernel/kernel_builder.dart' | 12 import '../kernel/kernel_builder.dart' |
| 19 show | 13 show |
| 20 Builder, | 14 Builder, |
| 15 ClassBuilder, |
| 21 ConstructorReferenceBuilder, | 16 ConstructorReferenceBuilder, |
| 22 KernelClassBuilder, | 17 KernelClassBuilder, |
| 23 KernelFieldBuilder, | 18 KernelFieldBuilder, |
| 24 KernelFunctionBuilder, | 19 KernelFunctionBuilder, |
| 25 KernelLibraryBuilder, | 20 KernelLibraryBuilder, |
| 26 KernelTypeBuilder, | 21 KernelTypeBuilder, |
| 27 KernelTypeVariableBuilder, | 22 KernelTypeVariableBuilder, |
| 28 LibraryBuilder, | 23 LibraryBuilder, |
| 29 MetadataBuilder, | 24 MetadataBuilder, |
| 30 Scope, | 25 Scope, |
| 31 TypeVariableBuilder, | 26 TypeVariableBuilder, |
| 32 compareProcedures; | 27 compareProcedures; |
| 33 | 28 |
| 34 import '../dill/dill_member_builder.dart' show DillMemberBuilder; | 29 import '../problems.dart' show unhandled; |
| 30 |
| 31 import 'source_library_builder.dart' show SourceLibraryBuilder; |
| 35 | 32 |
| 36 Class initializeClass( | 33 Class initializeClass( |
| 37 Class cls, String name, KernelLibraryBuilder parent, int charOffset) { | 34 Class cls, String name, KernelLibraryBuilder parent, int charOffset) { |
| 38 cls ??= new Class(name: name); | 35 cls ??= new Class(name: name); |
| 39 cls.fileUri ??= parent.library.fileUri; | 36 cls.fileUri ??= parent.library.fileUri; |
| 40 if (cls.fileOffset == TreeNode.noOffset) { | 37 if (cls.fileOffset == TreeNode.noOffset) { |
| 41 cls.fileOffset = charOffset; | 38 cls.fileOffset = charOffset; |
| 42 } | 39 } |
| 43 return cls; | 40 return cls; |
| 44 } | 41 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 Class build(KernelLibraryBuilder library, LibraryBuilder coreLibrary) { | 81 Class build(KernelLibraryBuilder library, LibraryBuilder coreLibrary) { |
| 85 void buildBuilders(String name, Builder builder) { | 82 void buildBuilders(String name, Builder builder) { |
| 86 do { | 83 do { |
| 87 if (builder is KernelFieldBuilder) { | 84 if (builder is KernelFieldBuilder) { |
| 88 // TODO(ahe): It would be nice to have a common interface for the | 85 // TODO(ahe): It would be nice to have a common interface for the |
| 89 // build method to avoid duplicating these two cases. | 86 // build method to avoid duplicating these two cases. |
| 90 cls.addMember(builder.build(library)); | 87 cls.addMember(builder.build(library)); |
| 91 } else if (builder is KernelFunctionBuilder) { | 88 } else if (builder is KernelFunctionBuilder) { |
| 92 cls.addMember(builder.build(library)); | 89 cls.addMember(builder.build(library)); |
| 93 } else { | 90 } else { |
| 94 deprecated_internalProblem( | 91 unhandled("${builder.runtimeType}", "buildBuilders", |
| 95 "Unhandled builder: ${builder.runtimeType}"); | 92 builder.charOffset, builder.fileUri); |
| 96 } | 93 } |
| 97 builder = builder.next; | 94 builder = builder.next; |
| 98 } while (builder != null); | 95 } while (builder != null); |
| 99 } | 96 } |
| 100 | 97 |
| 101 scope.forEach(buildBuilders); | 98 scope.forEach(buildBuilders); |
| 102 constructors.forEach(buildBuilders); | 99 constructors.forEach(buildBuilders); |
| 103 cls.supertype = supertype?.buildSupertype(library); | 100 cls.supertype = supertype?.buildSupertype(library); |
| 104 cls.mixedInType = mixedInType?.buildSupertype(library); | 101 cls.mixedInType = mixedInType?.buildSupertype(library); |
| 105 // TODO(ahe): If `cls.supertype` is null, and this isn't Object, report a | 102 // TODO(ahe): If `cls.supertype` is null, and this isn't Object, report a |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 } | 152 } |
| 156 | 153 |
| 157 @override | 154 @override |
| 158 void prepareInitializerInference( | 155 void prepareInitializerInference( |
| 159 SourceLibraryBuilder library, ClassBuilder currentClass) { | 156 SourceLibraryBuilder library, ClassBuilder currentClass) { |
| 160 scope.forEach((name, builder) { | 157 scope.forEach((name, builder) { |
| 161 builder.prepareInitializerInference(library, this); | 158 builder.prepareInitializerInference(library, this); |
| 162 }); | 159 }); |
| 163 } | 160 } |
| 164 } | 161 } |
| OLD | NEW |