| OLD | NEW |
| 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 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(new KernelIfNullExpression( | 867 push(new KernelIfNullExpression( |
| 868 variable, | 868 variable, |
| 869 new KernelConditionalExpression( | 869 new ConditionalExpression( |
| 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 null))); |
| 873 } | 874 } |
| 874 | 875 |
| 875 /// Handle `a?.b(...)`. | 876 /// Handle `a?.b(...)`. |
| 876 void doIfNotNull(Token token) { | 877 void doIfNotNull(Token token) { |
| 877 IncompleteSend send = pop(); | 878 IncompleteSend send = pop(); |
| 878 push(send.withReceiver(pop(), token.charOffset, isNullAware: true)); | 879 push(send.withReceiver(pop(), token.charOffset, isNullAware: true)); |
| 879 } | 880 } |
| 880 | 881 |
| 881 void doDotOrCascadeExpression(Token token) { | 882 void doDotOrCascadeExpression(Token token) { |
| 882 // TODO(ahe): Handle null-aware. | 883 // TODO(ahe): Handle null-aware. |
| (...skipping 2312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3195 } | 3196 } |
| 3196 if (isNullAware) { | 3197 if (isNullAware) { |
| 3197 VariableDeclaration variable = new VariableDeclaration.forValue(receiver); | 3198 VariableDeclaration variable = new VariableDeclaration.forValue(receiver); |
| 3198 return new KernelNullAwareMethodInvocation( | 3199 return new KernelNullAwareMethodInvocation( |
| 3199 variable, | 3200 variable, |
| 3200 new ConditionalExpression( | 3201 new ConditionalExpression( |
| 3201 buildIsNull(new VariableGet(variable), offset), | 3202 buildIsNull(new VariableGet(variable), offset), |
| 3202 new NullLiteral(), | 3203 new NullLiteral(), |
| 3203 new MethodInvocation(new VariableGet(variable), name, arguments) | 3204 new MethodInvocation(new VariableGet(variable), name, arguments) |
| 3204 ..fileOffset = offset, | 3205 ..fileOffset = offset, |
| 3205 const DynamicType()) | 3206 null) |
| 3206 ..fileOffset = offset) | 3207 ..fileOffset = offset) |
| 3207 ..fileOffset = offset; | 3208 ..fileOffset = offset; |
| 3208 } else { | 3209 } else { |
| 3209 return new KernelMethodInvocation(receiver, name, arguments, | 3210 return new KernelMethodInvocation(receiver, name, arguments, |
| 3210 isImplicitCall: isImplicitCall) | 3211 isImplicitCall: isImplicitCall) |
| 3211 ..fileOffset = offset; | 3212 ..fileOffset = offset; |
| 3212 } | 3213 } |
| 3213 } | 3214 } |
| 3214 | 3215 |
| 3215 @override | 3216 @override |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3673 if (starToken == null) { | 3674 if (starToken == null) { |
| 3674 return AsyncMarker.Async; | 3675 return AsyncMarker.Async; |
| 3675 } else { | 3676 } else { |
| 3676 assert(identical(starToken.stringValue, "*")); | 3677 assert(identical(starToken.stringValue, "*")); |
| 3677 return AsyncMarker.AsyncStar; | 3678 return AsyncMarker.AsyncStar; |
| 3678 } | 3679 } |
| 3679 } else { | 3680 } else { |
| 3680 return internalError("Unknown async modifier: $asyncToken"); | 3681 return internalError("Unknown async modifier: $asyncToken"); |
| 3681 } | 3682 } |
| 3682 } | 3683 } |
| OLD | NEW |