| 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:front_end/src/fasta/scanner/token.dart' show SymbolToken, Token; |
| 8 |
| 9 import 'package:front_end/src/fasta/type_inference/type_inferrer.dart' |
| 10 show TypeInferrer; |
| 11 |
| 7 import 'package:kernel/ast.dart' show AsyncMarker, ProcedureKind; | 12 import 'package:kernel/ast.dart' show AsyncMarker, ProcedureKind; |
| 8 | 13 |
| 9 import '../combinator.dart' show Combinator; | 14 import '../combinator.dart' show Combinator; |
| 10 | 15 |
| 11 import '../errors.dart' show inputError, internalError; | 16 import '../errors.dart' show inputError, internalError; |
| 12 | 17 |
| 13 import '../export.dart' show Export; | 18 import '../export.dart' show Export; |
| 14 | 19 |
| 15 import '../import.dart' show Import; | 20 import '../import.dart' show Import; |
| 16 | 21 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 void addNamedMixinApplication( | 169 void addNamedMixinApplication( |
| 165 List<MetadataBuilder> metadata, | 170 List<MetadataBuilder> metadata, |
| 166 String name, | 171 String name, |
| 167 List<TypeVariableBuilder> typeVariables, | 172 List<TypeVariableBuilder> typeVariables, |
| 168 int modifiers, | 173 int modifiers, |
| 169 T mixinApplication, | 174 T mixinApplication, |
| 170 List<T> interfaces, | 175 List<T> interfaces, |
| 171 int charOffset); | 176 int charOffset); |
| 172 | 177 |
| 173 void addField(List<MetadataBuilder> metadata, int modifiers, T type, | 178 void addField(List<MetadataBuilder> metadata, int modifiers, T type, |
| 174 String name, int charOffset); | 179 String name, int charOffset, Token initializer); |
| 175 | 180 |
| 176 void addFields(List<MetadataBuilder> metadata, int modifiers, T type, | 181 void addFields(List<MetadataBuilder> metadata, int modifiers, T type, |
| 177 List<Object> namesAndOffsets) { | 182 List<Object> namesOffsetsAndInitializers) { |
| 178 for (int i = 0; i < namesAndOffsets.length; i += 2) { | 183 for (int i = 0; i < namesOffsetsAndInitializers.length; i += 4) { |
| 179 String name = namesAndOffsets[i]; | 184 String name = namesOffsetsAndInitializers[i]; |
| 180 int charOffset = namesAndOffsets[i + 1]; | 185 int charOffset = namesOffsetsAndInitializers[i + 1]; |
| 181 addField(metadata, modifiers, type, name, charOffset); | 186 Token initializer; |
| 187 if (type == null) { |
| 188 initializer = namesOffsetsAndInitializers[i + 2]; |
| 189 Token afterInitializer = namesOffsetsAndInitializers[i + 3]; |
| 190 // TODO(paulberry): figure out a way to do this without using |
| 191 // Token.previous. |
| 192 afterInitializer?.previous |
| 193 ?.setNext(new SymbolToken.eof(afterInitializer.offset)); |
| 194 } |
| 195 addField(metadata, modifiers, type, name, charOffset, initializer); |
| 182 } | 196 } |
| 183 } | 197 } |
| 184 | 198 |
| 185 void addProcedure( | 199 void addProcedure( |
| 186 List<MetadataBuilder> metadata, | 200 List<MetadataBuilder> metadata, |
| 187 int modifiers, | 201 int modifiers, |
| 188 T returnType, | 202 T returnType, |
| 189 String name, | 203 String name, |
| 190 List<TypeVariableBuilder> typeVariables, | 204 List<TypeVariableBuilder> typeVariables, |
| 191 List<FormalParameterBuilder> formals, | 205 List<FormalParameterBuilder> formals, |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 count += member.resolveConstructors(this); | 476 count += member.resolveConstructors(this); |
| 463 }); | 477 }); |
| 464 return count; | 478 return count; |
| 465 } | 479 } |
| 466 | 480 |
| 467 List<TypeVariableBuilder> copyTypeVariables( | 481 List<TypeVariableBuilder> copyTypeVariables( |
| 468 List<TypeVariableBuilder> original); | 482 List<TypeVariableBuilder> original); |
| 469 | 483 |
| 470 @override | 484 @override |
| 471 String get fullNameForErrors => name ?? "<library '$relativeFileUri'>"; | 485 String get fullNameForErrors => name ?? "<library '$relativeFileUri'>"; |
| 486 |
| 487 @override |
| 488 void prepareInitializerInference(TypeInferrer typeInferrer, |
| 489 LibraryBuilder library, ClassBuilder currentClass) { |
| 490 forEach((String name, Builder member) { |
| 491 member.prepareInitializerInference(typeInferrer, library, currentClass); |
| 492 }); |
| 493 } |
| 472 } | 494 } |
| 473 | 495 |
| 474 /// Unlike [Scope], this scope is used during construction of builders to | 496 /// Unlike [Scope], this scope is used during construction of builders to |
| 475 /// ensure types and members are added to and resolved in the correct location. | 497 /// ensure types and members are added to and resolved in the correct location. |
| 476 class DeclarationBuilder<T extends TypeBuilder> { | 498 class DeclarationBuilder<T extends TypeBuilder> { |
| 477 final DeclarationBuilder<T> parent; | 499 final DeclarationBuilder<T> parent; |
| 478 | 500 |
| 479 final Map<String, Builder> members; | 501 final Map<String, Builder> members; |
| 480 | 502 |
| 481 final Map<String, Builder> constructors; | 503 final Map<String, Builder> constructors; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 /// synthesize type variables on the factory matching the class'. | 578 /// synthesize type variables on the factory matching the class'. |
| 557 void addFactoryDeclaration( | 579 void addFactoryDeclaration( |
| 558 ProcedureBuilder procedure, DeclarationBuilder<T> factoryDeclaration) { | 580 ProcedureBuilder procedure, DeclarationBuilder<T> factoryDeclaration) { |
| 559 factoryDeclarations[procedure] = factoryDeclaration; | 581 factoryDeclarations[procedure] = factoryDeclaration; |
| 560 } | 582 } |
| 561 | 583 |
| 562 Scope toScope(Scope parent) { | 584 Scope toScope(Scope parent) { |
| 563 return new Scope(members, setters, parent, isModifiable: false); | 585 return new Scope(members, setters, parent, isModifiable: false); |
| 564 } | 586 } |
| 565 } | 587 } |
| OLD | NEW |