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

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

Issue 2916333002: Setup correct scope for initializers and complain about fields initialized more than once. (Closed)
Patch Set: More typos. Created 3 years, 6 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.outline_builder; 5 library fasta.outline_builder;
6 6
7 import 'package:kernel/ast.dart' show ProcedureKind; 7 import 'package:kernel/ast.dart' show ProcedureKind;
8 8
9 import '../fasta_codes.dart' show FastaMessage, codeExpectedBlockToSkip; 9 import '../fasta_codes.dart' show FastaMessage, codeExpectedBlockToSkip;
10 10
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 } 620 }
621 List<MetadataBuilder> metadata = pop(); 621 List<MetadataBuilder> metadata = pop();
622 library.addFunctionTypeAlias( 622 library.addFunctionTypeAlias(
623 metadata, returnType, name, typeVariables, formals, charOffset); 623 metadata, returnType, name, typeVariables, formals, charOffset);
624 checkEmpty(typedefKeyword.charOffset); 624 checkEmpty(typedefKeyword.charOffset);
625 } 625 }
626 626
627 @override 627 @override
628 void endTopLevelFields(int count, Token beginToken, Token endToken) { 628 void endTopLevelFields(int count, Token beginToken, Token endToken) {
629 debugEvent("endTopLevelFields"); 629 debugEvent("endTopLevelFields");
630 List namesOffsetsAndInitializers = popList(count * 4); 630 List fieldsInfo = popList(count * 4);
631 TypeBuilder type = pop(); 631 TypeBuilder type = pop();
632 int modifiers = Modifier.validate(pop()); 632 int modifiers = Modifier.validate(pop());
633 List<MetadataBuilder> metadata = pop(); 633 List<MetadataBuilder> metadata = pop();
634 library.addFields(metadata, modifiers, type, namesOffsetsAndInitializers); 634 library.addFields(metadata, modifiers, type, fieldsInfo);
635 checkEmpty(beginToken.charOffset); 635 checkEmpty(beginToken.charOffset);
636 } 636 }
637 637
638 @override 638 @override
639 void endFields(int count, Token beginToken, Token endToken) { 639 void endFields(int count, Token beginToken, Token endToken) {
640 debugEvent("Fields"); 640 debugEvent("Fields");
641 List namesOffsetsAndInitializers = popList(count * 4); 641 List fieldsInfo = popList(count * 4);
642 TypeBuilder type = pop(); 642 TypeBuilder type = pop();
643 int modifiers = Modifier.validate(pop()); 643 int modifiers = Modifier.validate(pop());
644 List<MetadataBuilder> metadata = pop(); 644 List<MetadataBuilder> metadata = pop();
645 library.addFields(metadata, modifiers, type, namesOffsetsAndInitializers); 645 library.addFields(metadata, modifiers, type, fieldsInfo);
646 } 646 }
647 647
648 @override 648 @override
649 void endTypeVariable(Token token, Token extendsOrSuper) { 649 void endTypeVariable(Token token, Token extendsOrSuper) {
650 debugEvent("endTypeVariable"); 650 debugEvent("endTypeVariable");
651 TypeBuilder bound = pop(); 651 TypeBuilder bound = pop();
652 int charOffset = pop(); 652 int charOffset = pop();
653 String name = pop(); 653 String name = pop();
654 // TODO(paulberry): type variable metadata should not be ignored. See 654 // TODO(paulberry): type variable metadata should not be ignored. See
655 // dartbug.com/28981. 655 // dartbug.com/28981.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 717
718 @override 718 @override
719 void endRedirectingFactoryBody(Token beginToken, Token endToken) { 719 void endRedirectingFactoryBody(Token beginToken, Token endToken) {
720 debugEvent("RedirectingFactoryBody"); 720 debugEvent("RedirectingFactoryBody");
721 push(MethodBody.RedirectingFactoryBody); 721 push(MethodBody.RedirectingFactoryBody);
722 } 722 }
723 723
724 @override 724 @override
725 void endFieldInitializer(Token assignmentOperator, Token token) { 725 void endFieldInitializer(Token assignmentOperator, Token token) {
726 debugEvent("FieldInitializer"); 726 debugEvent("FieldInitializer");
727 Token beforeLast = assignmentOperator.next;
728 Token next = beforeLast.next;
729 while (next != token && !next.isEof) {
730 // To avoid storing the rest of the token stream, we need to identify the
731 // token before [token]. That token will be the last token of the
732 // initializer expression and by setting its tail to EOF we only store
733 // the tokens for the expression.
734 // TODO(ahe): Might be clearer if this search was moved to
735 // `library.addFields`.
736 beforeLast = next;
737 next = next.next;
738 }
727 push(assignmentOperator.next); 739 push(assignmentOperator.next);
728 push(token); 740 push(beforeLast);
729 } 741 }
730 742
731 @override 743 @override
732 void handleNoFieldInitializer(Token token) { 744 void handleNoFieldInitializer(Token token) {
733 debugEvent("NoFieldInitializer"); 745 debugEvent("NoFieldInitializer");
734 push(NullValue.FieldInitializer); 746 push(NullValue.FieldInitializer);
735 push(NullValue.FieldInitializer); 747 push(NullValue.FieldInitializer);
736 } 748 }
737 749
738 @override 750 @override
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 Link<Token> handleMemberName(Link<Token> identifiers) { 810 Link<Token> handleMemberName(Link<Token> identifiers) {
799 if (!enableNative || identifiers.isEmpty) return identifiers; 811 if (!enableNative || identifiers.isEmpty) return identifiers;
800 return removeNativeClause(identifiers); 812 return removeNativeClause(identifiers);
801 } 813 }
802 814
803 @override 815 @override
804 void debugEvent(String name) { 816 void debugEvent(String name) {
805 // printEvent(name); 817 // printEvent(name);
806 } 818 }
807 } 819 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/source/diet_listener.dart ('k') | pkg/front_end/lib/src/fasta/source/source_library_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698