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

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/body_builder.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.body_builder; 5 library fasta.body_builder;
6 6
7 import '../fasta_codes.dart' 7 import '../fasta_codes.dart'
8 show FastaMessage, codeExpectedButGot, codeExpectedFunctionBody; 8 show FastaMessage, codeExpectedButGot, codeExpectedFunctionBody;
9 9
10 import '../parser/parser.dart' show FormalParameterType, optional; 10 import '../parser/parser.dart' show FormalParameterType, optional;
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 } 302 }
303 303
304 void doFields(int count) { 304 void doFields(int count) {
305 for (int i = 0; i < count; i++) { 305 for (int i = 0; i < count; i++) {
306 Expression initializer = pop(); 306 Expression initializer = pop();
307 Identifier identifier = pop(); 307 Identifier identifier = pop();
308 if (initializer != null) { 308 if (initializer != null) {
309 String name = identifier.name; 309 String name = identifier.name;
310 FieldBuilder field; 310 FieldBuilder field;
311 if (classBuilder != null) { 311 if (classBuilder != null) {
312 field = classBuilder.members[name]; 312 field = classBuilder[name];
313 } else { 313 } else {
314 field = library.members[name]; 314 field = library[name];
315 } 315 }
316 if (field.next != null) { 316 if (field.next != null) {
317 // TODO(ahe): This can happen, for example, if a final field is 317 // TODO(ahe): This can happen, for example, if a final field is
318 // combined with a setter. 318 // combined with a setter.
319 internalError( 319 internalError(
320 "Unhandled: '${field.name}' has more than one declaration."); 320 "Unhandled: '${field.name}' has more than one declaration.");
321 } 321 }
322 field.initializer = initializer; 322 field.initializer = initializer;
323 } 323 }
324 } 324 }
(...skipping 20 matching lines...) Expand all
345 } 345 }
346 } 346 }
347 347
348 @override 348 @override
349 void prepareInitializers() { 349 void prepareInitializers() {
350 scope = formalParameterScope; 350 scope = formalParameterScope;
351 assert(fieldInitializers.isEmpty); 351 assert(fieldInitializers.isEmpty);
352 final member = this.member; 352 final member = this.member;
353 if (member is KernelConstructorBuilder) { 353 if (member is KernelConstructorBuilder) {
354 Constructor constructor = member.constructor; 354 Constructor constructor = member.constructor;
355 classBuilder.members.forEach((String name, Builder builder) { 355 classBuilder.forEach((String name, Builder builder) {
356 if (builder is KernelFieldBuilder && builder.isInstanceMember) { 356 if (builder is KernelFieldBuilder && builder.isInstanceMember) {
357 // TODO(ahe): Compute initializers (as in `field = initializer`). 357 // TODO(ahe): Compute initializers (as in `field = initializer`).
358 fieldInitializers[name] = new FieldInitializer(builder.field, null) 358 fieldInitializers[name] = new FieldInitializer(builder.field, null)
359 ..parent = constructor; 359 ..parent = constructor;
360 } 360 }
361 }); 361 });
362 if (member.formals != null) { 362 if (member.formals != null) {
363 for (KernelFormalParameterBuilder formal in member.formals) { 363 for (KernelFormalParameterBuilder formal in member.formals) {
364 if (formal.hasThis) { 364 if (formal.hasThis) {
365 FieldInitializer initializer = fieldInitializers[formal.name]; 365 FieldInitializer initializer = fieldInitializers[formal.name];
(...skipping 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after
1781 return; 1781 return;
1782 } 1782 }
1783 1783
1784 if (typeArguments != null) { 1784 if (typeArguments != null) {
1785 assert(arguments.types.isEmpty); 1785 assert(arguments.types.isEmpty);
1786 arguments.types.addAll(typeArguments); 1786 arguments.types.addAll(typeArguments);
1787 } 1787 }
1788 1788
1789 String errorName; 1789 String errorName;
1790 if (type is ClassBuilder) { 1790 if (type is ClassBuilder) {
1791 Builder b = type.findConstructorOrFactory(name); 1791 Builder b = type.findConstructorOrFactory(name, token.charOffset, uri);
1792 Member target; 1792 Member target;
1793 if (b == null) { 1793 if (b == null) {
1794 // Not found. Reported below. 1794 // Not found. Reported below.
1795 } else if (b.isConstructor) { 1795 } else if (b.isConstructor) {
1796 if (type.isAbstract) { 1796 if (type.isAbstract) {
1797 push(evaluateArgumentsBefore( 1797 push(evaluateArgumentsBefore(
1798 arguments, 1798 arguments,
1799 buildAbstractClassInstantiationError( 1799 buildAbstractClassInstantiationError(
1800 type.name, nameToken.charOffset))); 1800 type.name, nameToken.charOffset)));
1801 return; 1801 return;
(...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after
2880 for (VariableDeclaration parameter in required) { 2880 for (VariableDeclaration parameter in required) {
2881 local[parameter.name] = 2881 local[parameter.name] =
2882 new KernelVariableBuilder(parameter, builder, builder.fileUri); 2882 new KernelVariableBuilder(parameter, builder, builder.fileUri);
2883 } 2883 }
2884 if (optional != null) { 2884 if (optional != null) {
2885 for (VariableDeclaration parameter in optional.formals) { 2885 for (VariableDeclaration parameter in optional.formals) {
2886 local[parameter.name] = 2886 local[parameter.name] =
2887 new KernelVariableBuilder(parameter, builder, builder.fileUri); 2887 new KernelVariableBuilder(parameter, builder, builder.fileUri);
2888 } 2888 }
2889 } 2889 }
2890 return new Scope(local, parent, isModifiable: false); 2890 return new Scope(local, null, parent, isModifiable: false);
2891 } 2891 }
2892 } 2892 }
2893 2893
2894 /// Returns a block like this: 2894 /// Returns a block like this:
2895 /// 2895 ///
2896 /// { 2896 /// {
2897 /// statement; 2897 /// statement;
2898 /// body; 2898 /// body;
2899 /// } 2899 /// }
2900 /// 2900 ///
(...skipping 23 matching lines...) Expand all
2924 } else if (node is PrefixBuilder) { 2924 } else if (node is PrefixBuilder) {
2925 return node.name; 2925 return node.name;
2926 } else if (node is ThisAccessor) { 2926 } else if (node is ThisAccessor) {
2927 return node.isSuper ? "super" : "this"; 2927 return node.isSuper ? "super" : "this";
2928 } else if (node is FastaAccessor) { 2928 } else if (node is FastaAccessor) {
2929 return node.plainNameForRead; 2929 return node.plainNameForRead;
2930 } else { 2930 } else {
2931 return internalError("Unhandled: ${node.runtimeType}"); 2931 return internalError("Unhandled: ${node.runtimeType}");
2932 } 2932 }
2933 } 2933 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/dill/dill_target.dart ('k') | pkg/front_end/lib/src/fasta/kernel/kernel_enum_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698