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

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

Issue 2926763003: Add type inference for complex assignments whose LHS is an index expression. (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.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, MemberKind, optional; 10 import '../parser/parser.dart' show FormalParameterType, MemberKind, optional;
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 push(new KernelLogicalExpression(receiver, token.stringValue, argument)); 740 push(new KernelLogicalExpression(receiver, token.stringValue, argument));
741 } 741 }
742 742
743 /// Handle `a ?? b`. 743 /// Handle `a ?? b`.
744 void doIfNull(Token token) { 744 void doIfNull(Token token) {
745 Expression b = popForValue(); 745 Expression b = popForValue();
746 Expression a = popForValue(); 746 Expression a = popForValue();
747 VariableDeclaration variable = new VariableDeclaration.forValue(a); 747 VariableDeclaration variable = new VariableDeclaration.forValue(a);
748 push(makeLet( 748 push(makeLet(
749 variable, 749 variable,
750 new ConditionalExpression(buildIsNull(new VariableGet(variable)), b, 750 new KernelConditionalExpression(buildIsNull(new VariableGet(variable)),
751 new VariableGet(variable), const DynamicType()))); 751 b, new VariableGet(variable))));
752 } 752 }
753 753
754 /// Handle `a?.b(...)`. 754 /// Handle `a?.b(...)`.
755 void doIfNotNull(Token token) { 755 void doIfNotNull(Token token) {
756 IncompleteSend send = pop(); 756 IncompleteSend send = pop();
757 push(send.withReceiver(pop(), token.charOffset, isNullAware: true)); 757 push(send.withReceiver(pop(), token.charOffset, isNullAware: true));
758 } 758 }
759 759
760 void doDotOrCascadeExpression(Token token) { 760 void doDotOrCascadeExpression(Token token) {
761 // TODO(ahe): Handle null-aware. 761 // TODO(ahe): Handle null-aware.
(...skipping 2090 matching lines...) Expand 10 before | Expand all | Expand 10 after
2852 {bool isConstantExpression: false, 2852 {bool isConstantExpression: false,
2853 bool isNullAware: false, 2853 bool isNullAware: false,
2854 bool isImplicitCall: false}) { 2854 bool isImplicitCall: false}) {
2855 if (constantExpressionRequired && !isConstantExpression) { 2855 if (constantExpressionRequired && !isConstantExpression) {
2856 return buildCompileTimeError("Not a constant expression.", offset); 2856 return buildCompileTimeError("Not a constant expression.", offset);
2857 } 2857 }
2858 if (isNullAware) { 2858 if (isNullAware) {
2859 VariableDeclaration variable = new VariableDeclaration.forValue(receiver); 2859 VariableDeclaration variable = new VariableDeclaration.forValue(receiver);
2860 return makeLet( 2860 return makeLet(
2861 variable, 2861 variable,
2862 new ConditionalExpression( 2862 new KernelConditionalExpression(
2863 buildIsNull(new VariableGet(variable)), 2863 buildIsNull(new VariableGet(variable)),
2864 new NullLiteral(), 2864 new NullLiteral(),
2865 new MethodInvocation(new VariableGet(variable), name, arguments) 2865 new MethodInvocation(new VariableGet(variable), name, arguments)
2866 ..fileOffset = offset, 2866 ..fileOffset = offset));
2867 const DynamicType()));
2868 } else { 2867 } else {
2869 return new KernelMethodInvocation(receiver, name, arguments, 2868 return new KernelMethodInvocation(receiver, name, arguments,
2870 isImplicitCall: isImplicitCall) 2869 isImplicitCall: isImplicitCall)
2871 ..fileOffset = offset; 2870 ..fileOffset = offset;
2872 } 2871 }
2873 } 2872 }
2874 2873
2875 @override 2874 @override
2876 void addCompileTimeErrorFromMessage(FastaMessage message) { 2875 void addCompileTimeErrorFromMessage(FastaMessage message) {
2877 library.addCompileTimeError(message.charOffset, message.message, 2876 library.addCompileTimeError(message.charOffset, message.message,
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
3330 if (starToken == null) { 3329 if (starToken == null) {
3331 return AsyncMarker.Async; 3330 return AsyncMarker.Async;
3332 } else { 3331 } else {
3333 assert(identical(starToken.stringValue, "*")); 3332 assert(identical(starToken.stringValue, "*"));
3334 return AsyncMarker.AsyncStar; 3333 return AsyncMarker.AsyncStar;
3335 } 3334 }
3336 } else { 3335 } else {
3337 return internalError("Unknown async modifier: $asyncToken"); 3336 return internalError("Unknown async modifier: $asyncToken");
3338 } 3337 }
3339 } 3338 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698