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

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/kernel_target.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.kernel_target; 5 library fasta.kernel_target;
6 6
7 import 'dart:async' show Future; 7 import 'dart:async' show Future;
8 8
9 import 'dart:io' show File, IOSink; 9 import 'dart:io' show File, IOSink;
10 10
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 if (cls.interfaces != null) { 168 if (cls.interfaces != null) {
169 for (NamedTypeBuilder t in cls.interfaces) { 169 for (NamedTypeBuilder t in cls.interfaces) {
170 add(t); 170 add(t);
171 } 171 }
172 } 172 }
173 } 173 }
174 174
175 List<ClassBuilder> collectAllClasses() { 175 List<ClassBuilder> collectAllClasses() {
176 List<ClassBuilder> result = <ClassBuilder>[]; 176 List<ClassBuilder> result = <ClassBuilder>[];
177 loader.builders.forEach((Uri uri, LibraryBuilder library) { 177 loader.builders.forEach((Uri uri, LibraryBuilder library) {
178 library.members.forEach((String name, Builder member) { 178 library.forEach((String name, Builder member) {
179 if (member is KernelClassBuilder) { 179 if (member is KernelClassBuilder) {
180 result.add(member); 180 result.add(member);
181 } 181 }
182 }); 182 });
183 // TODO(ahe): Translate this if needed: 183 // TODO(ahe): Translate this if needed:
184 // if (library is KernelLibraryBuilder) { 184 // if (library is KernelLibraryBuilder) {
185 // result.addAll(library.mixinApplicationClasses); 185 // result.addAll(library.mixinApplicationClasses);
186 // } 186 // }
187 }); 187 });
188 return result; 188 return result;
189 } 189 }
190 190
191 List<SourceClassBuilder> collectAllSourceClasses() { 191 List<SourceClassBuilder> collectAllSourceClasses() {
192 List<SourceClassBuilder> result = <SourceClassBuilder>[]; 192 List<SourceClassBuilder> result = <SourceClassBuilder>[];
193 loader.builders.forEach((Uri uri, LibraryBuilder library) { 193 loader.builders.forEach((Uri uri, LibraryBuilder library) {
194 library.members.forEach((String name, Builder member) { 194 library.forEach((String name, Builder member) {
195 if (member is SourceClassBuilder) { 195 if (member is SourceClassBuilder) {
196 result.add(member); 196 result.add(member);
197 } 197 }
198 }); 198 });
199 }); 199 });
200 return result; 200 return result;
201 } 201 }
202 202
203 void breakCycle(ClassBuilder builder) { 203 void breakCycle(ClassBuilder builder) {
204 Class cls = builder.target; 204 Class cls = builder.target;
(...skipping 18 matching lines...) Expand all
223 ? new Future<Program>.value(program) 223 ? new Future<Program>.value(program)
224 : writeLinkedProgram(uri, program, isFullProgram: isFullProgram); 224 : writeLinkedProgram(uri, program, isFullProgram: isFullProgram);
225 } 225 }
226 226
227 Future<Program> writeOutline(Uri uri) async { 227 Future<Program> writeOutline(Uri uri) async {
228 if (loader.first == null) return null; 228 if (loader.first == null) return null;
229 try { 229 try {
230 await loader.buildOutlines(); 230 await loader.buildOutlines();
231 loader.coreLibrary 231 loader.coreLibrary
232 .becomeCoreLibrary(const DynamicType(), const VoidType()); 232 .becomeCoreLibrary(const DynamicType(), const VoidType());
233 dynamicType.bind(loader.coreLibrary.members["dynamic"]); 233 dynamicType.bind(loader.coreLibrary["dynamic"]);
234 loader.resolveParts(); 234 loader.resolveParts();
235 loader.computeLibraryScopes(); 235 loader.computeLibraryScopes();
236 loader.resolveTypes(); 236 loader.resolveTypes();
237 loader.buildProgram(); 237 loader.buildProgram();
238 loader.checkSemantics(); 238 loader.checkSemantics();
239 List<SourceClassBuilder> sourceClasses = collectAllSourceClasses(); 239 List<SourceClassBuilder> sourceClasses = collectAllSourceClasses();
240 installDefaultSupertypes(); 240 installDefaultSupertypes();
241 installDefaultConstructors(sourceClasses); 241 installDefaultConstructors(sourceClasses);
242 loader.resolveConstructors(); 242 loader.resolveConstructors();
243 loader.finishTypeVariables(objectClassBuilder); 243 loader.finishTypeVariables(objectClassBuilder);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 libraries.addAll(binary.libraries); 350 libraries.addAll(binary.libraries);
351 uriToSource.addAll(binary.uriToSource); 351 uriToSource.addAll(binary.uriToSource);
352 } 352 }
353 353
354 // TODO(ahe): Remove this line. Kernel seems to generate a default line map 354 // TODO(ahe): Remove this line. Kernel seems to generate a default line map
355 // that used when there's no fileUri on an element. Instead, ensure all 355 // that used when there's no fileUri on an element. Instead, ensure all
356 // elements have a fileUri. 356 // elements have a fileUri.
357 uriToSource[""] = new Source(<int>[0], const <int>[]); 357 uriToSource[""] = new Source(<int>[0], const <int>[]);
358 Program program = new Program(libraries, uriToSource); 358 Program program = new Program(libraries, uriToSource);
359 if (loader.first != null) { 359 if (loader.first != null) {
360 Builder builder = loader.first.members["main"]; 360 Builder builder = loader.first.lookup("main", -1, null);
361 if (builder is KernelProcedureBuilder) { 361 if (builder is KernelProcedureBuilder) {
362 program.mainMethod = builder.procedure; 362 program.mainMethod = builder.procedure;
363 } 363 }
364 } 364 }
365 if (errors.isEmpty || dillTarget.isLoaded) { 365 if (errors.isEmpty || dillTarget.isLoaded) {
366 setup_builtin_library.transformProgram(program); 366 setup_builtin_library.transformProgram(program);
367 } 367 }
368 ticker.logMs("Linked program"); 368 ticker.logMs("Linked program");
369 return program; 369 return program;
370 } 370 }
(...skipping 12 matching lines...) Expand all
383 ticker.logMs("Wrote program to ${uri.toFilePath()}"); 383 ticker.logMs("Wrote program to ${uri.toFilePath()}");
384 } else { 384 } else {
385 ticker.logMs("Wrote outline to ${uri.toFilePath()}"); 385 ticker.logMs("Wrote outline to ${uri.toFilePath()}");
386 } 386 }
387 return null; 387 return null;
388 } 388 }
389 389
390 void installDefaultSupertypes() { 390 void installDefaultSupertypes() {
391 Class objectClass = this.objectClass; 391 Class objectClass = this.objectClass;
392 loader.builders.forEach((Uri uri, LibraryBuilder library) { 392 loader.builders.forEach((Uri uri, LibraryBuilder library) {
393 library.members.forEach((String name, Builder builder) { 393 library.forEach((String name, Builder builder) {
394 if (builder is SourceClassBuilder) { 394 if (builder is SourceClassBuilder) {
395 Class cls = builder.target; 395 Class cls = builder.target;
396 if (cls != objectClass) { 396 if (cls != objectClass) {
397 cls.supertype ??= objectClass.asRawSupertype; 397 cls.supertype ??= objectClass.asRawSupertype;
398 } 398 }
399 if (builder.isMixinApplication) { 399 if (builder.isMixinApplication) {
400 cls.mixedInType = builder.mixedInType.buildSupertype(library); 400 cls.mixedInType = builder.mixedInType.buildSupertype(library);
401 } 401 }
402 } 402 }
403 }); 403 });
404 }); 404 });
405 ticker.logMs("Installed Object as implicit superclass"); 405 ticker.logMs("Installed Object as implicit superclass");
406 } 406 }
407 407
408 void installDefaultConstructors(List<SourceClassBuilder> builders) { 408 void installDefaultConstructors(List<SourceClassBuilder> builders) {
409 Class objectClass = this.objectClass; 409 Class objectClass = this.objectClass;
410 for (SourceClassBuilder builder in builders) { 410 for (SourceClassBuilder builder in builders) {
411 if (builder.target != objectClass) { 411 if (builder.target != objectClass) {
412 installDefaultConstructor(builder); 412 installDefaultConstructor(builder);
413 } 413 }
414 } 414 }
415 ticker.logMs("Installed default constructors"); 415 ticker.logMs("Installed default constructors");
416 } 416 }
417 417
418 KernelClassBuilder get objectClassBuilder { 418 KernelClassBuilder get objectClassBuilder => loader.coreLibrary["Object"];
419 return loader.coreLibrary.exports["Object"];
420 }
421 419
422 Class get objectClass => objectClassBuilder.cls; 420 Class get objectClass => objectClassBuilder.cls;
423 421
424 /// If [builder] doesn't have a constructors, install the defaults. 422 /// If [builder] doesn't have a constructors, install the defaults.
425 void installDefaultConstructor(SourceClassBuilder builder) { 423 void installDefaultConstructor(SourceClassBuilder builder) {
426 if (builder.cls.isMixinApplication) { 424 if (builder.cls.isMixinApplication) {
427 // We have to test if builder.cls is a mixin application. [builder] may 425 // We have to test if builder.cls is a mixin application. [builder] may
428 // think it's a mixin application, but if its mixed-in type couldn't be 426 // think it's a mixin application, but if its mixed-in type couldn't be
429 // resolved, the target class won't be a mixin application and we need 427 // resolved, the target class won't be a mixin application and we need
430 // to add a default constructor to complete error recovery. 428 // to add a default constructor to complete error recovery.
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 } 696 }
699 for (Constructor constructor in superclass.constructors) { 697 for (Constructor constructor in superclass.constructors) {
700 if (constructor.name.name.isEmpty) { 698 if (constructor.name.name.isEmpty) {
701 return constructor.function.requiredParameterCount == 0 699 return constructor.function.requiredParameterCount == 0
702 ? constructor 700 ? constructor
703 : null; 701 : null;
704 } 702 }
705 } 703 }
706 return null; 704 return null;
707 } 705 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/kernel_enum_builder.dart ('k') | pkg/front_end/lib/src/fasta/scope.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698