Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: pkg/front_end/lib/src/fasta/source/source_library_builder.dart

Issue 2788913002: Prepare for separate setter scope. (Closed)
Patch Set: Address comments. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 AsyncMarker, ProcedureKind; 7 import 'package:kernel/ast.dart' show AsyncMarker, ProcedureKind;
8 8
9 import '../combinator.dart' show Combinator; 9 import '../combinator.dart' show Combinator;
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 final List<ConstructorReferenceBuilder> constructorReferences = 44 final List<ConstructorReferenceBuilder> constructorReferences =
45 <ConstructorReferenceBuilder>[]; 45 <ConstructorReferenceBuilder>[];
46 46
47 final List<SourceLibraryBuilder<T, R>> parts = <SourceLibraryBuilder<T, R>>[]; 47 final List<SourceLibraryBuilder<T, R>> parts = <SourceLibraryBuilder<T, R>>[];
48 48
49 final List<Import> imports = <Import>[]; 49 final List<Import> imports = <Import>[];
50 50
51 final Map<String, Builder> exports = <String, Builder>{}; 51 final Map<String, Builder> exports = <String, Builder>{};
52 52
53 final Scope scope = new Scope(<String, Builder>{}, null, isModifiable: false); 53 final Scope scope = new Scope.top();
54 54
55 final Uri fileUri; 55 final Uri fileUri;
56 56
57 final List<List> implementationBuilders = <List<List>>[]; 57 final List<List> implementationBuilders = <List<List>>[];
58 58
59 String name; 59 String name;
60 60
61 String partOfName; 61 String partOfName;
62 62
63 Uri partOfUri; 63 Uri partOfUri;
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 // extends Object with Mixin {}` in the same library. 296 // extends Object with Mixin {}` in the same library.
297 return !existing.isMixinApplication || !other.isMixinApplication; 297 return !existing.isMixinApplication || !other.isMixinApplication;
298 } 298 }
299 return true; 299 return true;
300 } 300 }
301 301
302 void buildBuilder(Builder builder); 302 void buildBuilder(Builder builder);
303 303
304 R build() { 304 R build() {
305 assert(implementationBuilders.isEmpty); 305 assert(implementationBuilders.isEmpty);
306 members.forEach((String name, Builder builder) { 306 forEach((String name, Builder builder) {
307 do { 307 do {
308 buildBuilder(builder); 308 buildBuilder(builder);
309 builder = builder.next; 309 builder = builder.next;
310 } while (builder != null); 310 } while (builder != null);
311 }); 311 });
312 for (List list in implementationBuilders) { 312 for (List list in implementationBuilders) {
313 String name = list[0]; 313 String name = list[0];
314 Builder builder = list[1]; 314 Builder builder = list[1];
315 int charOffset = list[2]; 315 int charOffset = list[2];
316 addBuilder(name, builder, charOffset); 316 addBuilder(name, builder, charOffset);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 if (part.partOfName != name && part.partOfUri != uri) { 362 if (part.partOfName != name && part.partOfUri != uri) {
363 String partName = part.partOfName ?? "${part.partOfUri}"; 363 String partName = part.partOfName ?? "${part.partOfUri}";
364 String myName = name == null ? "'$uri'" : "'${name}' ($uri)"; 364 String myName = name == null ? "'$uri'" : "'${name}' ($uri)";
365 addWarning( 365 addWarning(
366 -1, 366 -1,
367 "Using '${part.fileUri}' as part of '$myName' but it's 'part of'" 367 "Using '${part.fileUri}' as part of '$myName' but it's 'part of'"
368 " declaration says '$partName'."); 368 " declaration says '$partName'.");
369 // The part is still included. 369 // The part is still included.
370 } 370 }
371 } 371 }
372 part.members.forEach((String name, Builder builder) { 372 part.forEach((String name, Builder builder) {
373 if (builder.next != null) { 373 if (builder.next != null) {
374 assert(builder.next.next == null); 374 assert(builder.next.next == null);
375 addBuilder(name, builder.next, builder.next.charOffset); 375 addBuilder(name, builder.next, builder.next.charOffset);
376 } 376 }
377 addBuilder(name, builder, builder.charOffset); 377 addBuilder(name, builder, builder.charOffset);
378 }); 378 });
379 types.addAll(part.types); 379 types.addAll(part.types);
380 constructorReferences.addAll(part.constructorReferences); 380 constructorReferences.addAll(part.constructorReferences);
381 part.partOfLibrary = this; 381 part.partOfLibrary = this;
382 // TODO(ahe): Include metadata from part? 382 // TODO(ahe): Include metadata from part?
383 } 383 }
384 384
385 void buildInitialScopes() { 385 void buildInitialScopes() {
386 members.forEach(addToExportScope); 386 forEach(addToExportScope);
387 members.forEach((String name, Builder member) { 387 forEach((String name, Builder member) {
388 addToScope(name, member, member.charOffset, false); 388 addToScope(name, member, member.charOffset, false);
389 }); 389 });
390 } 390 }
391 391
392 void addImportsToScope() { 392 void addImportsToScope() {
393 bool explicitCoreImport = this == loader.coreLibrary; 393 bool explicitCoreImport = this == loader.coreLibrary;
394 for (Import import in imports) { 394 for (Import import in imports) {
395 if (import.imported == loader.coreLibrary) { 395 if (import.imported == loader.coreLibrary) {
396 explicitCoreImport = true; 396 explicitCoreImport = true;
397 } 397 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 exports[name] = member; 433 exports[name] = member;
434 } 434 }
435 return true; 435 return true;
436 } 436 }
437 437
438 int resolveTypes(_) { 438 int resolveTypes(_) {
439 int typeCount = types.length; 439 int typeCount = types.length;
440 for (T t in types) { 440 for (T t in types) {
441 t.resolveIn(scope); 441 t.resolveIn(scope);
442 } 442 }
443 members.forEach((String name, Builder member) { 443 forEach((String name, Builder member) {
444 typeCount += member.resolveTypes(this); 444 typeCount += member.resolveTypes(this);
445 }); 445 });
446 return typeCount; 446 return typeCount;
447 } 447 }
448 448
449 int resolveConstructors(_) { 449 int resolveConstructors(_) {
450 int count = 0; 450 int count = 0;
451 members.forEach((String name, Builder member) { 451 forEach((String name, Builder member) {
452 count += member.resolveConstructors(this); 452 count += member.resolveConstructors(this);
453 }); 453 });
454 return count; 454 return count;
455 } 455 }
456 456
457 List<TypeVariableBuilder> copyTypeVariables( 457 List<TypeVariableBuilder> copyTypeVariables(
458 List<TypeVariableBuilder> original); 458 List<TypeVariableBuilder> original);
459 459
460 @override 460 @override
461 String get fullNameForErrors => name ?? "<library '$relativeFileUri'>"; 461 String get fullNameForErrors => name ?? "<library '$relativeFileUri'>";
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 } 537 }
538 538
539 /// Called to register [procedure] as a factory whose types are collected in 539 /// Called to register [procedure] as a factory whose types are collected in
540 /// [factoryDeclaration]. Later, once the class has been built, we can 540 /// [factoryDeclaration]. Later, once the class has been built, we can
541 /// synthesize type variables on the factory matching the class'. 541 /// synthesize type variables on the factory matching the class'.
542 void addFactoryDeclaration( 542 void addFactoryDeclaration(
543 ProcedureBuilder procedure, DeclarationBuilder<T> factoryDeclaration) { 543 ProcedureBuilder procedure, DeclarationBuilder<T> factoryDeclaration) {
544 factoryDeclarations[procedure] = factoryDeclaration; 544 factoryDeclarations[procedure] = factoryDeclaration;
545 } 545 }
546 } 546 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/source/source_class_builder.dart ('k') | pkg/front_end/lib/src/fasta/source/source_loader.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698