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

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

Issue 2944903002: Implement type inference for if-null expressions (a ?? b). (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
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 8 show
9 FastaMessage, 9 FastaMessage,
10 codeConstFieldWithoutInitializer, 10 codeConstFieldWithoutInitializer,
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 Expression argument = popForValue(); 857 Expression argument = popForValue();
858 Expression receiver = popForValue(); 858 Expression receiver = popForValue();
859 push(new KernelLogicalExpression(receiver, token.stringValue, argument)); 859 push(new KernelLogicalExpression(receiver, token.stringValue, argument));
860 } 860 }
861 861
862 /// Handle `a ?? b`. 862 /// Handle `a ?? b`.
863 void doIfNull(Token token) { 863 void doIfNull(Token token) {
864 Expression b = popForValue(); 864 Expression b = popForValue();
865 Expression a = popForValue(); 865 Expression a = popForValue();
866 VariableDeclaration variable = new VariableDeclaration.forValue(a); 866 VariableDeclaration variable = new VariableDeclaration.forValue(a);
867 push(makeLet( 867 push(new KernelIfNullExpression(
868 variable, 868 variable,
869 new KernelConditionalExpression( 869 new KernelConditionalExpression(
870 buildIsNull(new VariableGet(variable), offsetForToken(token)), 870 buildIsNull(new VariableGet(variable), offsetForToken(token)),
871 b, 871 b,
872 new VariableGet(variable)))); 872 new VariableGet(variable))));
873 } 873 }
874 874
875 /// Handle `a?.b(...)`. 875 /// Handle `a?.b(...)`.
876 void doIfNotNull(Token token) { 876 void doIfNotNull(Token token) {
877 IncompleteSend send = pop(); 877 IncompleteSend send = pop();
(...skipping 2792 matching lines...) Expand 10 before | Expand all | Expand 10 after
3670 if (starToken == null) { 3670 if (starToken == null) {
3671 return AsyncMarker.Async; 3671 return AsyncMarker.Async;
3672 } else { 3672 } else {
3673 assert(identical(starToken.stringValue, "*")); 3673 assert(identical(starToken.stringValue, "*"));
3674 return AsyncMarker.AsyncStar; 3674 return AsyncMarker.AsyncStar;
3675 } 3675 }
3676 } else { 3676 } else {
3677 return internalError("Unknown async modifier: $asyncToken"); 3677 return internalError("Unknown async modifier: $asyncToken");
3678 } 3678 }
3679 } 3679 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698