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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: pkg/front_end/lib/src/fasta/source/outline_builder.dart
diff --git a/pkg/front_end/lib/src/fasta/source/outline_builder.dart b/pkg/front_end/lib/src/fasta/source/outline_builder.dart
index bd2a56981c0921ad635d678c697f7522e315d2f2..c7f0c213b6158ef19bf521e61f197dbb739e3007 100644
--- a/pkg/front_end/lib/src/fasta/source/outline_builder.dart
+++ b/pkg/front_end/lib/src/fasta/source/outline_builder.dart
@@ -627,22 +627,22 @@ class OutlineBuilder extends UnhandledListener {
@override
void endTopLevelFields(int count, Token beginToken, Token endToken) {
debugEvent("endTopLevelFields");
- List namesOffsetsAndInitializers = popList(count * 4);
+ List fieldsInfo = popList(count * 4);
TypeBuilder type = pop();
int modifiers = Modifier.validate(pop());
List<MetadataBuilder> metadata = pop();
- library.addFields(metadata, modifiers, type, namesOffsetsAndInitializers);
+ library.addFields(metadata, modifiers, type, fieldsInfo);
checkEmpty(beginToken.charOffset);
}
@override
void endFields(int count, Token beginToken, Token endToken) {
debugEvent("Fields");
- List namesOffsetsAndInitializers = popList(count * 4);
+ List fieldsInfo = popList(count * 4);
TypeBuilder type = pop();
int modifiers = Modifier.validate(pop());
List<MetadataBuilder> metadata = pop();
- library.addFields(metadata, modifiers, type, namesOffsetsAndInitializers);
+ library.addFields(metadata, modifiers, type, fieldsInfo);
}
@override
@@ -724,8 +724,20 @@ class OutlineBuilder extends UnhandledListener {
@override
void endFieldInitializer(Token assignmentOperator, Token token) {
debugEvent("FieldInitializer");
+ Token beforeLast = assignmentOperator.next;
+ Token next = beforeLast.next;
+ while (next != token && !next.isEof) {
+ // To avoid storing the rest of the token stream, we need to identify the
+ // token before [token]. That token will be the last token of the
+ // initializer expression and by setting its tail to EOF we only store
+ // the tokens for the expression.
+ // TODO(ahe): Might be clearer if this search was moved to
+ // `library.addFields`.
+ beforeLast = next;
+ next = next.next;
+ }
push(assignmentOperator.next);
- push(token);
+ push(beforeLast);
}
@override
« 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