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 'package:kernel/ast.dart' | 9 import 'package:kernel/ast.dart' |
10 show | 10 show |
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 superTarget ??= defaultSuperConstructor(cls); | 555 superTarget ??= defaultSuperConstructor(cls); |
556 Initializer initializer; | 556 Initializer initializer; |
557 if (superTarget == null) { | 557 if (superTarget == null) { |
558 builder.addCompileTimeError( | 558 builder.addCompileTimeError( |
559 templateSuperclassHasNoDefaultConstructor | 559 templateSuperclassHasNoDefaultConstructor |
560 .withArguments(cls.superclass.name), | 560 .withArguments(cls.superclass.name), |
561 constructor.fileOffset); | 561 constructor.fileOffset); |
562 initializer = new InvalidInitializer(); | 562 initializer = new InvalidInitializer(); |
563 } else { | 563 } else { |
564 initializer = | 564 initializer = |
565 new SuperInitializer(superTarget, new Arguments.empty()); | 565 new SuperInitializer(superTarget, new Arguments.empty()) |
| 566 ..isSynthetic = true; |
566 } | 567 } |
567 constructor.initializers.add(initializer); | 568 constructor.initializers.add(initializer); |
568 initializer.parent = constructor; | 569 initializer.parent = constructor; |
569 } | 570 } |
570 if (constructor.function.body == null) { | 571 if (constructor.function.body == null) { |
571 /// >If a generative constructor c is not a redirecting constructor | 572 /// >If a generative constructor c is not a redirecting constructor |
572 /// >and no body is provided, then c implicitly has an empty body {}. | 573 /// >and no body is provided, then c implicitly has an empty body {}. |
573 /// We use an empty statement instead. | 574 /// We use an empty statement instead. |
574 constructor.function.body = new EmptyStatement(); | 575 constructor.function.body = new EmptyStatement(); |
575 constructor.function.body.parent = constructor.function; | 576 constructor.function.body.parent = constructor.function; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 } | 611 } |
611 } | 612 } |
612 // Run through all fields that are initialized by some constructor, and | 613 // Run through all fields that are initialized by some constructor, and |
613 // make sure that all other constructors also initialize them. | 614 // make sure that all other constructors also initialize them. |
614 fieldInitializers.forEach( | 615 fieldInitializers.forEach( |
615 (Constructor constructor, List<FieldInitializer> initializers) { | 616 (Constructor constructor, List<FieldInitializer> initializers) { |
616 Iterable<Field> fields = initializers.map((i) => i.field); | 617 Iterable<Field> fields = initializers.map((i) => i.field); |
617 for (Field field in initializedFields.difference(fields.toSet())) { | 618 for (Field field in initializedFields.difference(fields.toSet())) { |
618 if (field.initializer == null) { | 619 if (field.initializer == null) { |
619 FieldInitializer initializer = | 620 FieldInitializer initializer = |
620 new FieldInitializer(field, new NullLiteral()); | 621 new FieldInitializer(field, new NullLiteral()) |
| 622 ..isSynthetic = true; |
621 initializer.parent = constructor; | 623 initializer.parent = constructor; |
622 constructor.initializers.insert(0, initializer); | 624 constructor.initializers.insert(0, initializer); |
623 } | 625 } |
624 } | 626 } |
625 }); | 627 }); |
626 } | 628 } |
627 | 629 |
628 /// Run all transformations that are needed when building a program for the | 630 /// Run all transformations that are needed when building a program for the |
629 /// first time. | 631 /// first time. |
630 void runBuildTransformations() { | 632 void runBuildTransformations() { |
(...skipping 26 matching lines...) Expand all Loading... |
657 } | 659 } |
658 for (Constructor constructor in superclass.constructors) { | 660 for (Constructor constructor in superclass.constructors) { |
659 if (constructor.name.name.isEmpty) { | 661 if (constructor.name.name.isEmpty) { |
660 return constructor.function.requiredParameterCount == 0 | 662 return constructor.function.requiredParameterCount == 0 |
661 ? constructor | 663 ? constructor |
662 : null; | 664 : null; |
663 } | 665 } |
664 } | 666 } |
665 return null; | 667 return null; |
666 } | 668 } |
OLD | NEW |