| 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:kernel/ast.dart' | 7 import 'package:kernel/ast.dart' |
| 8 show Class, Constructor, Supertype, TreeNode, setParents; | 8 show Class, Constructor, Supertype, TreeNode, setParents; |
| 9 | 9 |
| 10 import '../errors.dart' show internalError; | 10 import '../errors.dart' show internalError; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 count += cls.typeParameters.length; | 78 count += cls.typeParameters.length; |
| 79 } | 79 } |
| 80 return count + super.resolveTypes(library); | 80 return count + super.resolveTypes(library); |
| 81 } | 81 } |
| 82 | 82 |
| 83 Class build(KernelLibraryBuilder library) { | 83 Class build(KernelLibraryBuilder library) { |
| 84 void buildBuilder(Builder builder) { | 84 void buildBuilder(Builder builder) { |
| 85 if (builder is KernelFieldBuilder) { | 85 if (builder is KernelFieldBuilder) { |
| 86 // TODO(ahe): It would be nice to have a common interface for the build | 86 // TODO(ahe): It would be nice to have a common interface for the build |
| 87 // method to avoid duplicating these two cases. | 87 // method to avoid duplicating these two cases. |
| 88 cls.addMember(builder.build(library.library)); | 88 cls.addMember(builder.build(library)); |
| 89 } else if (builder is KernelFunctionBuilder) { | 89 } else if (builder is KernelFunctionBuilder) { |
| 90 cls.addMember(builder.build(library.library)); | 90 cls.addMember(builder.build(library)); |
| 91 } else { | 91 } else { |
| 92 internalError("Unhandled builder: ${builder.runtimeType}"); | 92 internalError("Unhandled builder: ${builder.runtimeType}"); |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 | 95 |
| 96 members.forEach((String name, Builder builder) { | 96 members.forEach((String name, Builder builder) { |
| 97 do { | 97 do { |
| 98 buildBuilder(builder); | 98 buildBuilder(builder); |
| 99 builder = builder.next; | 99 builder = builder.next; |
| 100 } while (builder != null); | 100 } while (builder != null); |
| 101 }); | 101 }); |
| 102 cls.supertype = supertype?.buildSupertype(); | 102 cls.supertype = supertype?.buildSupertype(library); |
| 103 cls.mixedInType = mixedInType?.buildSupertype(); | 103 cls.mixedInType = mixedInType?.buildSupertype(library); |
| 104 // TODO(ahe): If `cls.supertype` is null, and this isn't Object, report a | 104 // TODO(ahe): If `cls.supertype` is null, and this isn't Object, report a |
| 105 // compile-time error. | 105 // compile-time error. |
| 106 cls.isAbstract = isAbstract; | 106 cls.isAbstract = isAbstract; |
| 107 if (interfaces != null) { | 107 if (interfaces != null) { |
| 108 for (KernelTypeBuilder interface in interfaces) { | 108 for (KernelTypeBuilder interface in interfaces) { |
| 109 Supertype supertype = interface.buildSupertype(); | 109 Supertype supertype = interface.buildSupertype(library); |
| 110 if (supertype != null) { | 110 if (supertype != null) { |
| 111 // TODO(ahe): Report an error if supertype is null. | 111 // TODO(ahe): Report an error if supertype is null. |
| 112 cls.implementedTypes.add(supertype); | 112 cls.implementedTypes.add(supertype); |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 return cls; | 116 return cls; |
| 117 } | 117 } |
| 118 | 118 |
| 119 Builder findConstructorOrFactory(String name) => constructors[name]; | 119 Builder findConstructorOrFactory(String name) => constructors[name]; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 142 Map<String, Builder> computeConstructors(Map<String, Builder> members) { | 142 Map<String, Builder> computeConstructors(Map<String, Builder> members) { |
| 143 Map<String, Builder> constructors = <String, Builder>{}; | 143 Map<String, Builder> constructors = <String, Builder>{}; |
| 144 members.forEach((String name, Builder builder) { | 144 members.forEach((String name, Builder builder) { |
| 145 if (builder is ProcedureBuilder && | 145 if (builder is ProcedureBuilder && |
| 146 (builder.isConstructor || builder.isFactory)) { | 146 (builder.isConstructor || builder.isFactory)) { |
| 147 constructors[name] = builder; | 147 constructors[name] = builder; |
| 148 } | 148 } |
| 149 }); | 149 }); |
| 150 return constructors; | 150 return constructors; |
| 151 } | 151 } |
| OLD | NEW |