| 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_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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 {bool dumpIr: false, bool verify: false}) async { | 263 {bool dumpIr: false, bool verify: false}) async { |
| 264 if (loader.first == null) return null; | 264 if (loader.first == null) return null; |
| 265 if (errors.isNotEmpty) { | 265 if (errors.isNotEmpty) { |
| 266 return handleInputError(uri, null, isFullProgram: true); | 266 return handleInputError(uri, null, isFullProgram: true); |
| 267 } | 267 } |
| 268 try { | 268 try { |
| 269 await loader.buildBodies(); | 269 await loader.buildBodies(); |
| 270 loader.finishStaticInvocations(); | 270 loader.finishStaticInvocations(); |
| 271 finishAllConstructors(); | 271 finishAllConstructors(); |
| 272 loader.finishNativeMethods(); | 272 loader.finishNativeMethods(); |
| 273 runBuildTransformations(); | 273 transformMixinApplications(); |
| 274 | 274 // TODO(ahe): Don't call this from two different places. |
| 275 setup_builtin_library.transformProgram(program); |
| 276 otherTransformations(); |
| 275 if (dumpIr) this.dumpIr(); | 277 if (dumpIr) this.dumpIr(); |
| 276 if (verify) this.verify(); | 278 if (verify) this.verify(); |
| 277 errors.addAll(loader.collectCompileTimeErrors().map((e) => e.format())); | 279 errors.addAll(loader.collectCompileTimeErrors().map((e) => e.format())); |
| 278 if (errors.isNotEmpty) { | 280 if (errors.isNotEmpty) { |
| 279 return handleInputError(uri, null, isFullProgram: true); | 281 return handleInputError(uri, null, isFullProgram: true); |
| 280 } | 282 } |
| 281 if (uri == null) return program; | 283 if (uri == null) return program; |
| 282 return await writeLinkedProgram(uri, program, isFullProgram: true); | 284 return await writeLinkedProgram(uri, program, isFullProgram: true); |
| 283 } on InputError catch (e) { | 285 } on InputError catch (e) { |
| 284 return handleInputError(uri, e, isFullProgram: true); | 286 return handleInputError(uri, e, isFullProgram: true); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 // elements have a fileUri. | 382 // elements have a fileUri. |
| 381 uriToSource[""] = new Source(<int>[0], const <int>[]); | 383 uriToSource[""] = new Source(<int>[0], const <int>[]); |
| 382 Program program = new Program(libraries, uriToSource); | 384 Program program = new Program(libraries, uriToSource); |
| 383 if (loader.first != null) { | 385 if (loader.first != null) { |
| 384 Builder builder = loader.first.lookup("main", -1, null); | 386 Builder builder = loader.first.lookup("main", -1, null); |
| 385 if (builder is KernelProcedureBuilder) { | 387 if (builder is KernelProcedureBuilder) { |
| 386 program.mainMethod = builder.procedure; | 388 program.mainMethod = builder.procedure; |
| 387 } | 389 } |
| 388 } | 390 } |
| 389 if (errors.isEmpty || dillTarget.isLoaded) { | 391 if (errors.isEmpty || dillTarget.isLoaded) { |
| 390 runLinkTransformations(program); | 392 setup_builtin_library.transformProgram(program); |
| 391 } | 393 } |
| 392 ticker.logMs("Linked program"); | 394 ticker.logMs("Linked program"); |
| 393 return program; | 395 return program; |
| 394 } | 396 } |
| 395 | 397 |
| 396 Future<Program> writeLinkedProgram(Uri uri, Program program, | 398 Future<Program> writeLinkedProgram(Uri uri, Program program, |
| 397 {bool isFullProgram}) async { | 399 {bool isFullProgram}) async { |
| 398 File output = new File.fromUri(uri); | 400 File output = new File.fromUri(uri); |
| 399 IOSink sink = output.openWrite(); | 401 IOSink sink = output.openWrite(); |
| 400 try { | 402 try { |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 if (field.initializer == null) { | 670 if (field.initializer == null) { |
| 669 FieldInitializer initializer = | 671 FieldInitializer initializer = |
| 670 new FieldInitializer(field, new NullLiteral()); | 672 new FieldInitializer(field, new NullLiteral()); |
| 671 initializer.parent = constructor; | 673 initializer.parent = constructor; |
| 672 constructor.initializers.insert(0, initializer); | 674 constructor.initializers.insert(0, initializer); |
| 673 } | 675 } |
| 674 } | 676 } |
| 675 }); | 677 }); |
| 676 } | 678 } |
| 677 | 679 |
| 678 /// Run all transformations that are needed when building a program for the | |
| 679 /// first time. | |
| 680 void runBuildTransformations() { | |
| 681 transformMixinApplications(); | |
| 682 // TODO(ahe): Don't call this from two different places. | |
| 683 setup_builtin_library.transformProgram(program); | |
| 684 otherTransformations(); | |
| 685 } | |
| 686 | |
| 687 /// Run all transformations that are needed when linking a program. | |
| 688 void runLinkTransformations(Program program) { | |
| 689 setup_builtin_library.transformProgram(program); | |
| 690 } | |
| 691 | |
| 692 void transformMixinApplications() { | 680 void transformMixinApplications() { |
| 693 new MixinFullResolution().transform(program); | 681 new MixinFullResolution().transform(program); |
| 694 ticker.logMs("Transformed mixin applications"); | 682 ticker.logMs("Transformed mixin applications"); |
| 695 } | 683 } |
| 696 | 684 |
| 697 void otherTransformations() { | 685 void otherTransformations() { |
| 698 // TODO(ahe): Don't generate type variables in the first place. | 686 // TODO(ahe): Don't generate type variables in the first place. |
| 699 program.accept(new Erasure()); | 687 program.accept(new Erasure()); |
| 700 ticker.logMs("Erased type variables in generic methods"); | 688 ticker.logMs("Erased type variables in generic methods"); |
| 701 // TODO(kmillikin): Make this run on a per-method basis. | 689 // TODO(kmillikin): Make this run on a per-method basis. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 729 } | 717 } |
| 730 for (Constructor constructor in superclass.constructors) { | 718 for (Constructor constructor in superclass.constructors) { |
| 731 if (constructor.name.name.isEmpty) { | 719 if (constructor.name.name.isEmpty) { |
| 732 return constructor.function.requiredParameterCount == 0 | 720 return constructor.function.requiredParameterCount == 0 |
| 733 ? constructor | 721 ? constructor |
| 734 : null; | 722 : null; |
| 735 } | 723 } |
| 736 } | 724 } |
| 737 return null; | 725 return null; |
| 738 } | 726 } |
| OLD | NEW |