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

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

Issue 2940453002: Add offsets to the `== null` calls inserted by null-aware desugaring. (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 8 show
9 FastaMessage, 9 FastaMessage,
10 codeConstFieldWithoutInitializer, 10 codeConstFieldWithoutInitializer,
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 push(new KernelLogicalExpression(receiver, token.stringValue, argument)); 790 push(new KernelLogicalExpression(receiver, token.stringValue, argument));
791 } 791 }
792 792
793 /// Handle `a ?? b`. 793 /// Handle `a ?? b`.
794 void doIfNull(Token token) { 794 void doIfNull(Token token) {
795 Expression b = popForValue(); 795 Expression b = popForValue();
796 Expression a = popForValue(); 796 Expression a = popForValue();
797 VariableDeclaration variable = new VariableDeclaration.forValue(a); 797 VariableDeclaration variable = new VariableDeclaration.forValue(a);
798 push(makeLet( 798 push(makeLet(
799 variable, 799 variable,
800 new KernelConditionalExpression(buildIsNull(new VariableGet(variable)), 800 new KernelConditionalExpression(
801 b, new VariableGet(variable)))); 801 buildIsNull(new VariableGet(variable), offsetForToken(token)),
802 b,
803 new VariableGet(variable))));
802 } 804 }
803 805
804 /// Handle `a?.b(...)`. 806 /// Handle `a?.b(...)`.
805 void doIfNotNull(Token token) { 807 void doIfNotNull(Token token) {
806 IncompleteSend send = pop(); 808 IncompleteSend send = pop();
807 push(send.withReceiver(pop(), token.charOffset, isNullAware: true)); 809 push(send.withReceiver(pop(), token.charOffset, isNullAware: true));
808 } 810 }
809 811
810 void doDotOrCascadeExpression(Token token) { 812 void doDotOrCascadeExpression(Token token) {
811 // TODO(ahe): Handle null-aware. 813 // TODO(ahe): Handle null-aware.
(...skipping 2262 matching lines...) Expand 10 before | Expand all | Expand 10 after
3074 bool isNullAware: false, 3076 bool isNullAware: false,
3075 bool isImplicitCall: false}) { 3077 bool isImplicitCall: false}) {
3076 if (constantExpressionRequired && !isConstantExpression) { 3078 if (constantExpressionRequired && !isConstantExpression) {
3077 return buildCompileTimeError("Not a constant expression.", offset); 3079 return buildCompileTimeError("Not a constant expression.", offset);
3078 } 3080 }
3079 if (isNullAware) { 3081 if (isNullAware) {
3080 VariableDeclaration variable = new VariableDeclaration.forValue(receiver); 3082 VariableDeclaration variable = new VariableDeclaration.forValue(receiver);
3081 return makeLet( 3083 return makeLet(
3082 variable, 3084 variable,
3083 new KernelConditionalExpression( 3085 new KernelConditionalExpression(
3084 buildIsNull(new VariableGet(variable)), 3086 buildIsNull(new VariableGet(variable), offset),
3085 new NullLiteral(), 3087 new NullLiteral(),
3086 new MethodInvocation(new VariableGet(variable), name, arguments) 3088 new MethodInvocation(new VariableGet(variable), name, arguments)
3087 ..fileOffset = offset)); 3089 ..fileOffset = offset));
3088 } else { 3090 } else {
3089 return new KernelMethodInvocation(receiver, name, arguments, 3091 return new KernelMethodInvocation(receiver, name, arguments,
3090 isImplicitCall: isImplicitCall) 3092 isImplicitCall: isImplicitCall)
3091 ..fileOffset = offset; 3093 ..fileOffset = offset;
3092 } 3094 }
3093 } 3095 }
3094 3096
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
3162 } 3164 }
3163 3165
3164 Expression buildSimpleRead(); 3166 Expression buildSimpleRead();
3165 3167
3166 Expression buildForEffect(); 3168 Expression buildForEffect();
3167 3169
3168 Expression buildAssignment(Expression value, {bool voidContext: false}) { 3170 Expression buildAssignment(Expression value, {bool voidContext: false}) {
3169 return makeInvalidWrite(value); 3171 return makeInvalidWrite(value);
3170 } 3172 }
3171 3173
3172 Expression buildNullAwareAssignment(Expression value, DartType type, 3174 Expression buildNullAwareAssignment(
3175 Expression value, DartType type, int offset,
3173 {bool voidContext: false}) { 3176 {bool voidContext: false}) {
3174 return makeInvalidWrite(value); 3177 return makeInvalidWrite(value);
3175 } 3178 }
3176 3179
3177 Expression buildCompoundAssignment(Name binaryOperator, Expression value, 3180 Expression buildCompoundAssignment(Name binaryOperator, Expression value,
3178 {int offset: TreeNode.noOffset, 3181 {int offset: TreeNode.noOffset,
3179 bool voidContext: false, 3182 bool voidContext: false,
3180 Procedure interfaceTarget, 3183 Procedure interfaceTarget,
3181 bool isPreIncDec: false}) { 3184 bool isPreIncDec: false}) {
3182 return makeInvalidWrite(value); 3185 return makeInvalidWrite(value);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
3247 } else if (identical("/=", assignmentOperator)) { 3250 } else if (identical("/=", assignmentOperator)) {
3248 return accessor.buildCompoundAssignment(divisionName, value, 3251 return accessor.buildCompoundAssignment(divisionName, value,
3249 offset: offsetForToken(token), voidContext: voidContext); 3252 offset: offsetForToken(token), voidContext: voidContext);
3250 } else if (identical("<<=", assignmentOperator)) { 3253 } else if (identical("<<=", assignmentOperator)) {
3251 return accessor.buildCompoundAssignment(leftShiftName, value, 3254 return accessor.buildCompoundAssignment(leftShiftName, value,
3252 offset: offsetForToken(token), voidContext: voidContext); 3255 offset: offsetForToken(token), voidContext: voidContext);
3253 } else if (identical(">>=", assignmentOperator)) { 3256 } else if (identical(">>=", assignmentOperator)) {
3254 return accessor.buildCompoundAssignment(rightShiftName, value, 3257 return accessor.buildCompoundAssignment(rightShiftName, value,
3255 offset: offsetForToken(token), voidContext: voidContext); 3258 offset: offsetForToken(token), voidContext: voidContext);
3256 } else if (identical("??=", assignmentOperator)) { 3259 } else if (identical("??=", assignmentOperator)) {
3257 return accessor.buildNullAwareAssignment(value, const DynamicType(), 3260 return accessor.buildNullAwareAssignment(
3261 value, const DynamicType(), offsetForToken(token),
3258 voidContext: voidContext); 3262 voidContext: voidContext);
3259 } else if (identical("^=", assignmentOperator)) { 3263 } else if (identical("^=", assignmentOperator)) {
3260 return accessor.buildCompoundAssignment(caretName, value, 3264 return accessor.buildCompoundAssignment(caretName, value,
3261 offset: offsetForToken(token), voidContext: voidContext); 3265 offset: offsetForToken(token), voidContext: voidContext);
3262 } else if (identical("|=", assignmentOperator)) { 3266 } else if (identical("|=", assignmentOperator)) {
3263 return accessor.buildCompoundAssignment(barName, value, 3267 return accessor.buildCompoundAssignment(barName, value,
3264 offset: offsetForToken(token), voidContext: voidContext); 3268 offset: offsetForToken(token), voidContext: voidContext);
3265 } else if (identical("~/=", assignmentOperator)) { 3269 } else if (identical("~/=", assignmentOperator)) {
3266 return accessor.buildCompoundAssignment(mustacheName, value, 3270 return accessor.buildCompoundAssignment(mustacheName, value,
3267 offset: offsetForToken(token), voidContext: voidContext); 3271 offset: offsetForToken(token), voidContext: voidContext);
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
3551 if (starToken == null) { 3555 if (starToken == null) {
3552 return AsyncMarker.Async; 3556 return AsyncMarker.Async;
3553 } else { 3557 } else {
3554 assert(identical(starToken.stringValue, "*")); 3558 assert(identical(starToken.stringValue, "*"));
3555 return AsyncMarker.AsyncStar; 3559 return AsyncMarker.AsyncStar;
3556 } 3560 }
3557 } else { 3561 } else {
3558 return internalError("Unknown async modifier: $asyncToken"); 3562 return internalError("Unknown async modifier: $asyncToken");
3559 } 3563 }
3560 } 3564 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698