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

Side by Side Diff: pkg/kernel/lib/frontend/accessors.dart

Issue 2668893003: Kernel: Do not try to use return value of []= (Closed)
Patch Set: Created 3 years, 10 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 /// A library to help transform compounds and null-aware accessors into 5 /// A library to help transform compounds and null-aware accessors into
6 /// let expressions. 6 /// let expressions.
7 library kernel.frontend.accessors; 7 library kernel.frontend.accessors;
8 8
9 import '../ast.dart'; 9 import '../ast.dart';
10 10
(...skipping 14 matching lines...) Expand all
25 /// The returned expression evaluates to the assigned value, unless 25 /// The returned expression evaluates to the assigned value, unless
26 /// [voidContext] is true, in which case it may evaluate to anything. 26 /// [voidContext] is true, in which case it may evaluate to anything.
27 Expression buildAssignment(Expression value, {bool voidContext: false}) { 27 Expression buildAssignment(Expression value, {bool voidContext: false}) {
28 return _finish(_makeSimpleWrite(value, voidContext)); 28 return _finish(_makeSimpleWrite(value, voidContext));
29 } 29 }
30 30
31 Expression buildNullAwareAssignment(Expression value, DartType type, 31 Expression buildNullAwareAssignment(Expression value, DartType type,
32 {bool voidContext: false}) { 32 {bool voidContext: false}) {
33 if (voidContext) { 33 if (voidContext) {
34 return _finish(new ConditionalExpression(buildIsNull(_makeRead()), 34 return _finish(new ConditionalExpression(buildIsNull(_makeRead()),
35 _makeWrite(value, voidContext), new NullLiteral(), type)); 35 _makeWrite(value, false), new NullLiteral(), type));
36 } 36 }
37 var tmp = new VariableDeclaration.forValue(_makeRead()); 37 var tmp = new VariableDeclaration.forValue(_makeRead());
38 return _finish(makeLet( 38 return _finish(makeLet(
39 tmp, 39 tmp,
40 new ConditionalExpression(buildIsNull(new VariableGet(tmp)), 40 new ConditionalExpression(buildIsNull(new VariableGet(tmp)),
41 _makeWrite(value, voidContext), new VariableGet(tmp), type))); 41 _makeWrite(value, false), new VariableGet(tmp), type)));
42 } 42 }
43 43
44 Expression buildCompoundAssignment(Name binaryOperator, Expression value, 44 Expression buildCompoundAssignment(Name binaryOperator, Expression value,
45 {int offset: TreeNode.noOffset, 45 {int offset: TreeNode.noOffset,
46 bool voidContext: false, 46 bool voidContext: false,
47 Procedure interfaceTarget}) { 47 Procedure interfaceTarget}) {
48 return _finish(_makeWrite( 48 return _finish(_makeWrite(
49 builtBinary = makeBinary( 49 builtBinary = makeBinary(
50 _makeRead(), binaryOperator, interfaceTarget, value, 50 _makeRead(), binaryOperator, interfaceTarget, value,
51 offset: offset), 51 offset: offset),
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 426
427 VariableDeclaration makeOrReuseVariable(Expression value) { 427 VariableDeclaration makeOrReuseVariable(Expression value) {
428 // TODO: Devise a way to remember if a variable declaration was reused 428 // TODO: Devise a way to remember if a variable declaration was reused
429 // or is fresh (hence needs a let binding). 429 // or is fresh (hence needs a let binding).
430 return new VariableDeclaration.forValue(value); 430 return new VariableDeclaration.forValue(value);
431 } 431 }
432 432
433 Expression wrapInvalid(Expression e) { 433 Expression wrapInvalid(Expression e) {
434 return new Let(new VariableDeclaration.forValue(e), new InvalidExpression()); 434 return new Let(new VariableDeclaration.forValue(e), new InvalidExpression());
435 } 435 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698