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

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart

Issue 2928033005: Add type inference for assignment to local variables. (Closed)
Patch Set: 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.fasta_accessors; 5 library fasta.fasta_accessors;
6 6
7 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart' 7 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart'
8 show KernelArguments, KernelComplexAssignment, KernelThisExpression; 8 show
9 KernelArguments,
10 KernelComplexAssignment,
11 KernelIndexAssign,
12 KernelThisExpression,
13 KernelVariableAssignment;
9 14
10 import 'package:front_end/src/fasta/kernel/utils.dart' show offsetForToken; 15 import 'package:front_end/src/fasta/kernel/utils.dart' show offsetForToken;
11 16
12 import 'package:front_end/src/scanner/token.dart' show Token; 17 import 'package:front_end/src/scanner/token.dart' show Token;
13 18
14 import 'frontend_accessors.dart' show Accessor; 19 import 'frontend_accessors.dart' show Accessor;
15 20
16 import 'package:front_end/src/fasta/type_inference/type_promotion.dart' 21 import 'package:front_end/src/fasta/type_inference/type_promotion.dart'
17 show TypePromoter; 22 show TypePromoter;
18 23
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 244
240 @override 245 @override
241 Expression buildAssignment(Expression value, {bool voidContext: false}) { 246 Expression buildAssignment(Expression value, {bool voidContext: false}) {
242 return buildError(new KernelArguments(<Expression>[value]), isSetter: true); 247 return buildError(new KernelArguments(<Expression>[value]), isSetter: true);
243 } 248 }
244 249
245 @override 250 @override
246 Expression buildCompoundAssignment(Name binaryOperator, Expression value, 251 Expression buildCompoundAssignment(Name binaryOperator, Expression value,
247 {int offset: TreeNode.noOffset, 252 {int offset: TreeNode.noOffset,
248 bool voidContext: false, 253 bool voidContext: false,
249 Procedure interfaceTarget}) { 254 Procedure interfaceTarget,
255 bool isPreIncDec: false}) {
250 return buildError(new KernelArguments(<Expression>[value]), isGetter: true); 256 return buildError(new KernelArguments(<Expression>[value]), isGetter: true);
251 } 257 }
252 258
253 @override 259 @override
254 Expression buildPrefixIncrement(Name binaryOperator, 260 Expression buildPrefixIncrement(Name binaryOperator,
255 {int offset: TreeNode.noOffset, 261 {int offset: TreeNode.noOffset,
256 bool voidContext: false, 262 bool voidContext: false,
257 Procedure interfaceTarget}) { 263 Procedure interfaceTarget}) {
258 return buildError(new KernelArguments(<Expression>[new IntLiteral(1)]), 264 return buildError(new KernelArguments(<Expression>[new IntLiteral(1)]),
259 isGetter: true); 265 isGetter: true);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 } 388 }
383 389
384 Expression buildNullAwareAssignment(Expression value, DartType type, 390 Expression buildNullAwareAssignment(Expression value, DartType type,
385 {bool voidContext: false}) { 391 {bool voidContext: false}) {
386 return buildAssignmentError(); 392 return buildAssignmentError();
387 } 393 }
388 394
389 Expression buildCompoundAssignment(Name binaryOperator, Expression value, 395 Expression buildCompoundAssignment(Name binaryOperator, Expression value,
390 {int offset: TreeNode.noOffset, 396 {int offset: TreeNode.noOffset,
391 bool voidContext: false, 397 bool voidContext: false,
392 Procedure interfaceTarget}) { 398 Procedure interfaceTarget,
399 bool isPreIncDec: false}) {
393 return buildAssignmentError(); 400 return buildAssignmentError();
394 } 401 }
395 402
396 Expression buildPrefixIncrement(Name binaryOperator, 403 Expression buildPrefixIncrement(Name binaryOperator,
397 {int offset: TreeNode.noOffset, 404 {int offset: TreeNode.noOffset,
398 bool voidContext: false, 405 bool voidContext: false,
399 Procedure interfaceTarget}) { 406 Procedure interfaceTarget}) {
400 return buildAssignmentError(); 407 return buildAssignmentError();
401 } 408 }
402 409
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 helper.toValue(receiver), name, arguments, offsetForToken(token), 491 helper.toValue(receiver), name, arguments, offsetForToken(token),
485 isNullAware: isNullAware); 492 isNullAware: isNullAware);
486 } 493 }
487 494
488 Expression buildNullAwareAssignment(Expression value, DartType type, 495 Expression buildNullAwareAssignment(Expression value, DartType type,
489 {bool voidContext: false}) { 496 {bool voidContext: false}) {
490 return internalError("Unhandled"); 497 return internalError("Unhandled");
491 } 498 }
492 499
493 Expression buildCompoundAssignment(Name binaryOperator, Expression value, 500 Expression buildCompoundAssignment(Name binaryOperator, Expression value,
494 {int offset, bool voidContext: false, Procedure interfaceTarget}) { 501 {int offset,
502 bool voidContext: false,
503 Procedure interfaceTarget,
504 bool isPreIncDec: false}) {
495 return internalError("Unhandled"); 505 return internalError("Unhandled");
496 } 506 }
497 507
498 Expression buildPrefixIncrement(Name binaryOperator, 508 Expression buildPrefixIncrement(Name binaryOperator,
499 {int offset, bool voidContext: false, Procedure interfaceTarget}) { 509 {int offset, bool voidContext: false, Procedure interfaceTarget}) {
500 return internalError("Unhandled"); 510 return internalError("Unhandled");
501 } 511 }
502 512
503 Expression buildPostfixIncrement(Name binaryOperator, 513 Expression buildPostfixIncrement(Name binaryOperator,
504 {int offset, bool voidContext: false, Procedure interfaceTarget}) { 514 {int offset, bool voidContext: false, Procedure interfaceTarget}) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 return PropertyAccessor.make( 550 return PropertyAccessor.make(
541 helper, token, helper.toValue(receiver), name, null, null, isNullAware); 551 helper, token, helper.toValue(receiver), name, null, null, isNullAware);
542 } 552 }
543 553
544 Expression buildNullAwareAssignment(Expression value, DartType type, 554 Expression buildNullAwareAssignment(Expression value, DartType type,
545 {bool voidContext: false}) { 555 {bool voidContext: false}) {
546 return internalError("Unhandled"); 556 return internalError("Unhandled");
547 } 557 }
548 558
549 Expression buildCompoundAssignment(Name binaryOperator, Expression value, 559 Expression buildCompoundAssignment(Name binaryOperator, Expression value,
550 {int offset, bool voidContext: false, Procedure interfaceTarget}) { 560 {int offset,
561 bool voidContext: false,
562 Procedure interfaceTarget,
563 bool isPreIncDec: false}) {
551 return internalError("Unhandled"); 564 return internalError("Unhandled");
552 } 565 }
553 566
554 Expression buildPrefixIncrement(Name binaryOperator, 567 Expression buildPrefixIncrement(Name binaryOperator,
555 {int offset, bool voidContext: false, Procedure interfaceTarget}) { 568 {int offset, bool voidContext: false, Procedure interfaceTarget}) {
556 return internalError("Unhandled"); 569 return internalError("Unhandled");
557 } 570 }
558 571
559 Expression buildPostfixIncrement(Name binaryOperator, 572 Expression buildPostfixIncrement(Name binaryOperator,
560 {int offset, bool voidContext: false, Procedure interfaceTarget}) { 573 {int offset, bool voidContext: false, Procedure interfaceTarget}) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 if (receiver is ThisExpression) { 613 if (receiver is ThisExpression) {
601 return new ThisIndexAccessor(helper, token, index, getter, setter); 614 return new ThisIndexAccessor(helper, token, index, getter, setter);
602 } else { 615 } else {
603 return new IndexAccessor.internal( 616 return new IndexAccessor.internal(
604 helper, token, receiver, index, getter, setter); 617 helper, token, receiver, index, getter, setter);
605 } 618 }
606 } 619 }
607 620
608 @override 621 @override
609 KernelComplexAssignment startComplexAssignment(Expression rhs) => 622 KernelComplexAssignment startComplexAssignment(Expression rhs) =>
610 new KernelComplexAssignment() 623 new KernelIndexAssign(receiver, index, rhs);
611 ..receiver = receiver
612 ..index = index
613 ..rhs = rhs;
614 } 624 }
615 625
616 class PropertyAccessor extends kernel.PropertyAccessor with FastaAccessor { 626 class PropertyAccessor extends kernel.PropertyAccessor with FastaAccessor {
617 final BuilderHelper helper; 627 final BuilderHelper helper;
618 628
619 PropertyAccessor.internal(this.helper, Token token, Expression receiver, 629 PropertyAccessor.internal(this.helper, Token token, Expression receiver,
620 Name name, Member getter, Member setter) 630 Name name, Member getter, Member setter)
621 : super.internal(helper, receiver, name, getter, setter, token); 631 : super.internal(helper, receiver, name, getter, setter, token);
622 632
623 String get plainNameForRead => name.name; 633 String get plainNameForRead => name.name;
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 846
837 String get plainNameForRead => variable.name; 847 String get plainNameForRead => variable.name;
838 848
839 Expression doInvocation(int offset, Arguments arguments) { 849 Expression doInvocation(int offset, Arguments arguments) {
840 return helper.buildMethodInvocation(buildSimpleRead(), callName, arguments, 850 return helper.buildMethodInvocation(buildSimpleRead(), callName, arguments,
841 adjustForImplicitCall(plainNameForRead, offset), 851 adjustForImplicitCall(plainNameForRead, offset),
842 isImplicitCall: true); 852 isImplicitCall: true);
843 } 853 }
844 854
845 toString() => "VariableAccessor()"; 855 toString() => "VariableAccessor()";
856
857 @override
858 KernelComplexAssignment startComplexAssignment(Expression rhs) =>
859 new KernelVariableAssignment(rhs);
846 } 860 }
847 861
848 class ReadOnlyAccessor extends kernel.ReadOnlyAccessor with FastaAccessor { 862 class ReadOnlyAccessor extends kernel.ReadOnlyAccessor with FastaAccessor {
849 final String plainNameForRead; 863 final String plainNameForRead;
850 864
851 ReadOnlyAccessor(BuilderHelper helper, Expression expression, 865 ReadOnlyAccessor(BuilderHelper helper, Expression expression,
852 this.plainNameForRead, Token token) 866 this.plainNameForRead, Token token)
853 : super(helper, expression, token); 867 : super(helper, expression, token);
854 868
855 Expression doInvocation(int offset, Arguments arguments) { 869 Expression doInvocation(int offset, Arguments arguments) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 offset ??= offsetForToken(this.token); 995 offset ??= offsetForToken(this.token);
982 return helper.throwNoSuchMethodError(new NullLiteral()..fileOffset = offset, 996 return helper.throwNoSuchMethodError(new NullLiteral()..fileOffset = offset,
983 plainNameForRead, arguments, offset, 997 plainNameForRead, arguments, offset,
984 isGetter: isGetter, isSetter: isSetter); 998 isGetter: isGetter, isSetter: isSetter);
985 } 999 }
986 } 1000 }
987 1001
988 bool isFieldOrGetter(Member member) { 1002 bool isFieldOrGetter(Member member) {
989 return member is Field || (member is Procedure && member.isGetter); 1003 return member is Field || (member is Procedure && member.isGetter);
990 } 1004 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/body_builder.dart ('k') | pkg/front_end/lib/src/fasta/kernel/frontend_accessors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698