| 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_library_builder; | 5 library fasta.source_library_builder; |
| 6 | 6 |
| 7 import 'package:kernel/ast.dart' show | 7 import 'package:kernel/ast.dart' show |
| 8 AsyncMarker, | 8 AsyncMarker, |
| 9 ProcedureKind; | 9 ProcedureKind; |
| 10 | 10 |
| 11 import '../combinator.dart' show | 11 import '../combinator.dart' show |
| 12 Combinator; | 12 Combinator; |
| 13 | 13 |
| 14 import '../errors.dart' show | 14 import '../errors.dart' show |
| 15 inputError, | |
| 16 internalError; | 15 internalError; |
| 17 | 16 |
| 18 import '../import.dart' show | 17 import '../import.dart' show |
| 19 Import; | 18 Import; |
| 20 | 19 |
| 21 import 'source_loader.dart' show | 20 import 'source_loader.dart' show |
| 22 SourceLoader; | 21 SourceLoader; |
| 23 | 22 |
| 24 import '../builder/scope.dart' show | 23 import '../builder/scope.dart' show |
| 25 Scope; | 24 Scope; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 ConstructorReferenceBuilder name, List<FormalParameterBuilder> formals, | 193 ConstructorReferenceBuilder name, List<FormalParameterBuilder> formals, |
| 195 AsyncMarker asyncModifier, ConstructorReferenceBuilder redirectionTarget, | 194 AsyncMarker asyncModifier, ConstructorReferenceBuilder redirectionTarget, |
| 196 int charOffset); | 195 int charOffset); |
| 197 | 196 |
| 198 FormalParameterBuilder addFormalParameter( | 197 FormalParameterBuilder addFormalParameter( |
| 199 List<MetadataBuilder> metadata, int modifiers, | 198 List<MetadataBuilder> metadata, int modifiers, |
| 200 T type, String name, bool hasThis, int charOffset); | 199 T type, String name, bool hasThis, int charOffset); |
| 201 | 200 |
| 202 TypeVariableBuilder addTypeVariable(String name, T bound, int charOffset); | 201 TypeVariableBuilder addTypeVariable(String name, T bound, int charOffset); |
| 203 | 202 |
| 204 Builder addBuilder(String name, Builder builder) { | 203 Builder addBuilder(String name, Builder builder, int charOffset) { |
| 205 // TODO(ahe): Set the parent correctly here. Could then change the | 204 // TODO(ahe): Set the parent correctly here. Could then change the |
| 206 // implementation of MemberBuilder.isTopLevel to test explicitly for a | 205 // implementation of MemberBuilder.isTopLevel to test explicitly for a |
| 207 // LibraryBuilder. | 206 // LibraryBuilder. |
| 208 if (currentDeclaration == libraryDeclaration) { | 207 if (currentDeclaration == libraryDeclaration) { |
| 209 if (builder is MemberBuilder) { | 208 if (builder is MemberBuilder) { |
| 210 builder.parent = this; | 209 builder.parent = this; |
| 211 } else if (builder is TypeDeclarationBuilder) { | 210 } else if (builder is TypeDeclarationBuilder) { |
| 212 builder.parent = this; | 211 builder.parent = this; |
| 213 } else if (builder is PrefixBuilder) { | 212 } else if (builder is PrefixBuilder) { |
| 214 assert(builder.parent == this); | 213 assert(builder.parent == this); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 227 Builder other = existing.exports.putIfAbsent(name, () => builder); | 226 Builder other = existing.exports.putIfAbsent(name, () => builder); |
| 228 if (other != builder) { | 227 if (other != builder) { |
| 229 existing.exports[name] = | 228 existing.exports[name] = |
| 230 other.combineAmbiguousImport(name, builder, this); | 229 other.combineAmbiguousImport(name, builder, this); |
| 231 } | 230 } |
| 232 }); | 231 }); |
| 233 return existing; | 232 return existing; |
| 234 } else if (existing != null && (existing.next != null || | 233 } else if (existing != null && (existing.next != null || |
| 235 ((!existing.isGetter || !builder.isSetter) && | 234 ((!existing.isGetter || !builder.isSetter) && |
| 236 (!existing.isSetter || !builder.isGetter)))) { | 235 (!existing.isSetter || !builder.isGetter)))) { |
| 237 return inputError(uri, -1, "Duplicated definition of $name"); | 236 addCompileTimeError(charOffset, "Duplicated definition of '$name'."); |
| 238 } | 237 } |
| 239 return members[name] = builder; | 238 return members[name] = builder; |
| 240 } | 239 } |
| 241 | 240 |
| 242 void buildBuilder(Builder builder); | 241 void buildBuilder(Builder builder); |
| 243 | 242 |
| 244 R build() { | 243 R build() { |
| 245 members.forEach((String name, Builder builder) { | 244 members.forEach((String name, Builder builder) { |
| 246 do { | 245 do { |
| 247 buildBuilder(builder); | 246 buildBuilder(builder); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 275 parts.remove(part); | 274 parts.remove(part); |
| 276 return; | 275 return; |
| 277 } | 276 } |
| 278 if (part.partOf != name) { | 277 if (part.partOf != name) { |
| 279 print("${part.uri} is part of '${part.partOf}' but is used as a part " | 278 print("${part.uri} is part of '${part.partOf}' but is used as a part " |
| 280 "by '${name}' ($uri)"); | 279 "by '${name}' ($uri)"); |
| 281 parts.remove(part); | 280 parts.remove(part); |
| 282 return; | 281 return; |
| 283 } | 282 } |
| 284 } | 283 } |
| 285 part.members.forEach(addBuilder); | 284 part.members.forEach((String name, Builder builder) { |
| 285 addBuilder(name, builder, -1); |
| 286 }); |
| 286 types.addAll(part.types); | 287 types.addAll(part.types); |
| 287 constructorReferences.addAll(part.constructorReferences); | 288 constructorReferences.addAll(part.constructorReferences); |
| 288 part.partOfLibrary = this; | 289 part.partOfLibrary = this; |
| 289 // TODO(ahe): Include metadata from part? | 290 // TODO(ahe): Include metadata from part? |
| 290 } | 291 } |
| 291 | 292 |
| 292 void buildInitialScopes() { | 293 void buildInitialScopes() { |
| 293 members.forEach(addToExportScope); | 294 members.forEach(addToExportScope); |
| 294 members.forEach(addToScope); | 295 members.forEach(addToScope); |
| 295 } | 296 } |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 // parent declaration. | 413 // parent declaration. |
| 413 parent.addType(type); | 414 parent.addType(type); |
| 414 } else { | 415 } else { |
| 415 type.bind(builder); | 416 type.bind(builder); |
| 416 } | 417 } |
| 417 } | 418 } |
| 418 } | 419 } |
| 419 types.clear(); | 420 types.clear(); |
| 420 } | 421 } |
| 421 } | 422 } |
| OLD | NEW |