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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 KernelTypeBuilder type = new KernelMixinApplicationBuilder( | 107 KernelTypeBuilder type = new KernelMixinApplicationBuilder( |
108 supertype, mixins, this, charOffset, fileUri); | 108 supertype, mixins, this, charOffset, fileUri); |
109 return addType(type); | 109 return addType(type); |
110 } | 110 } |
111 | 111 |
112 KernelTypeBuilder addVoidType(int charOffset) { | 112 KernelTypeBuilder addVoidType(int charOffset) { |
113 return addNamedType("void", null, charOffset); | 113 return addNamedType("void", null, charOffset); |
114 } | 114 } |
115 | 115 |
116 void addClass( | 116 void addClass( |
| 117 String documentationComment, |
117 List<MetadataBuilder> metadata, | 118 List<MetadataBuilder> metadata, |
118 int modifiers, | 119 int modifiers, |
119 String className, | 120 String className, |
120 List<TypeVariableBuilder> typeVariables, | 121 List<TypeVariableBuilder> typeVariables, |
121 KernelTypeBuilder supertype, | 122 KernelTypeBuilder supertype, |
122 List<KernelTypeBuilder> interfaces, | 123 List<KernelTypeBuilder> interfaces, |
123 int charOffset) { | 124 int charOffset) { |
124 // Nested declaration began in `OutlineBuilder.beginClassDeclaration`. | 125 // Nested declaration began in `OutlineBuilder.beginClassDeclaration`. |
125 var declaration = endNestedDeclaration(className) | 126 var declaration = endNestedDeclaration(className) |
126 ..resolveTypes(typeVariables, this); | 127 ..resolveTypes(typeVariables, this); |
127 assert(declaration.parent == libraryDeclaration); | 128 assert(declaration.parent == libraryDeclaration); |
128 Map<String, MemberBuilder> members = declaration.members; | 129 Map<String, MemberBuilder> members = declaration.members; |
129 Map<String, MemberBuilder> constructors = declaration.constructors; | 130 Map<String, MemberBuilder> constructors = declaration.constructors; |
130 Map<String, MemberBuilder> setters = declaration.setters; | 131 Map<String, MemberBuilder> setters = declaration.setters; |
131 | 132 |
132 Scope classScope = new Scope( | 133 Scope classScope = new Scope( |
133 members, setters, scope.withTypeVariables(typeVariables), | 134 members, setters, scope.withTypeVariables(typeVariables), |
134 isModifiable: false); | 135 isModifiable: false); |
135 | 136 |
136 // When looking up a constructor, we don't consider type variables or the | 137 // When looking up a constructor, we don't consider type variables or the |
137 // library scope. | 138 // library scope. |
138 Scope constructorScope = | 139 Scope constructorScope = |
139 new Scope(constructors, null, null, isModifiable: false); | 140 new Scope(constructors, null, null, isModifiable: false); |
140 ClassBuilder cls = new SourceClassBuilder( | 141 ClassBuilder cls = new SourceClassBuilder( |
| 142 documentationComment, |
141 metadata, | 143 metadata, |
142 modifiers, | 144 modifiers, |
143 className, | 145 className, |
144 typeVariables, | 146 typeVariables, |
145 applyMixins(supertype, | 147 applyMixins(supertype, |
146 subclassName: className, typeVariables: typeVariables), | 148 subclassName: className, typeVariables: typeVariables), |
147 interfaces, | 149 interfaces, |
148 classScope, | 150 classScope, |
149 constructorScope, | 151 constructorScope, |
150 this, | 152 this, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 messageTypeVariableSameNameAsEnclosing, tv.charOffset, fileUri); | 208 messageTypeVariableSameNameAsEnclosing, tv.charOffset, fileUri); |
207 } | 209 } |
208 } | 210 } |
209 } | 211 } |
210 } | 212 } |
211 return typeVariablesByName; | 213 return typeVariablesByName; |
212 } | 214 } |
213 | 215 |
214 KernelTypeBuilder applyMixin( | 216 KernelTypeBuilder applyMixin( |
215 KernelTypeBuilder supertype, KernelTypeBuilder mixin, String signature, | 217 KernelTypeBuilder supertype, KernelTypeBuilder mixin, String signature, |
216 {List<MetadataBuilder> metadata, | 218 {String documentationComment, |
| 219 List<MetadataBuilder> metadata, |
217 String name, | 220 String name, |
218 List<TypeVariableBuilder> typeVariables, | 221 List<TypeVariableBuilder> typeVariables, |
219 int modifiers: abstractMask, | 222 int modifiers: abstractMask, |
220 List<KernelTypeBuilder> interfaces, | 223 List<KernelTypeBuilder> interfaces, |
221 int charOffset: -1}) { | 224 int charOffset: -1}) { |
222 var constructors = <String, MemberBuilder>{}; | 225 var constructors = <String, MemberBuilder>{}; |
223 bool isNamed = name != null; | 226 bool isNamed = name != null; |
224 SourceClassBuilder builder; | 227 SourceClassBuilder builder; |
225 if (isNamed) { | 228 if (isNamed) { |
226 modifiers |= namedMixinApplicationMask; | 229 modifiers |= namedMixinApplicationMask; |
227 } else { | 230 } else { |
228 name = supertype.name; | 231 name = supertype.name; |
229 int index = name.indexOf("^"); | 232 int index = name.indexOf("^"); |
230 if (index != -1) { | 233 if (index != -1) { |
231 name = name.substring(0, index); | 234 name = name.substring(0, index); |
232 } | 235 } |
233 name = "$name&${mixin.name}$signature"; | 236 name = "$name&${mixin.name}$signature"; |
234 builder = mixinApplicationClasses[name]; | 237 builder = mixinApplicationClasses[name]; |
235 } | 238 } |
236 if (builder == null) { | 239 if (builder == null) { |
237 builder = new SourceClassBuilder( | 240 builder = new SourceClassBuilder( |
| 241 documentationComment, |
238 metadata, | 242 metadata, |
239 modifiers, | 243 modifiers, |
240 name, | 244 name, |
241 typeVariables, | 245 typeVariables, |
242 supertype, | 246 supertype, |
243 interfaces, | 247 interfaces, |
244 new Scope(<String, MemberBuilder>{}, <String, MemberBuilder>{}, | 248 new Scope(<String, MemberBuilder>{}, <String, MemberBuilder>{}, |
245 scope.withTypeVariables(typeVariables), | 249 scope.withTypeVariables(typeVariables), |
246 isModifiable: false), | 250 isModifiable: false), |
247 new Scope(constructors, null, null, isModifiable: false), | 251 new Scope(constructors, null, null, isModifiable: false), |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 mixinApplicationClasses.putIfAbsent(name, () => builder); | 870 mixinApplicationClasses.putIfAbsent(name, () => builder); |
867 if (existing != builder) { | 871 if (existing != builder) { |
868 part.scope.local.remove(name); | 872 part.scope.local.remove(name); |
869 } | 873 } |
870 }); | 874 }); |
871 super.includePart(part); | 875 super.includePart(part); |
872 nativeMethods.addAll(part.nativeMethods); | 876 nativeMethods.addAll(part.nativeMethods); |
873 boundlessTypeVariables.addAll(part.boundlessTypeVariables); | 877 boundlessTypeVariables.addAll(part.boundlessTypeVariables); |
874 } | 878 } |
875 } | 879 } |
OLD | NEW |