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

Side by Side Diff: pkg/kernel/lib/transformations/closure/rewriter.dart

Issue 2716573002: closure conversion: Do not set Context.parent if the value is `null` (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
« no previous file with comments | « no previous file | pkg/kernel/testcases/closures/capture_closure.dart.expect » ('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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 kernel.transformations.closure.rewriter; 5 library kernel.transformations.closure.rewriter;
6 6
7 import '../../ast.dart'; 7 import '../../ast.dart';
8 import 'converter.dart' show ClosureConverter; 8 import 'converter.dart' show ClosureConverter;
9 9
10 /// Used by the [Context] to initialize and update the context variable 10 /// Used by the [Context] to initialize and update the context variable
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 65 }
66 66
67 void _insertStatement(Statement statement) { 67 void _insertStatement(Statement statement) {
68 _currentBlock.statements.insert(_insertionIndex++, statement); 68 _currentBlock.statements.insert(_insertionIndex++, statement);
69 statement.parent = _currentBlock; 69 statement.parent = _currentBlock;
70 } 70 }
71 71
72 void insertContextDeclaration(Class contextClass, Expression accessParent) { 72 void insertContextDeclaration(Class contextClass, Expression accessParent) {
73 _createDeclaration(contextClass); 73 _createDeclaration(contextClass);
74 _insertStatement(contextDeclaration); 74 _insertStatement(contextDeclaration);
75 _insertStatement(new ExpressionStatement(new PropertySet( 75 if (accessParent is! NullLiteral) {
76 new VariableGet(contextDeclaration), 76 _insertStatement(new ExpressionStatement(new PropertySet(
77 new Name('parent'), 77 new VariableGet(contextDeclaration),
78 accessParent))); 78 new Name('parent'),
79 accessParent)));
80 }
79 } 81 }
80 82
81 void insertExtendContext(Expression accessContext, Arguments arguments) { 83 void insertExtendContext(Expression accessContext, Arguments arguments) {
82 _insertStatement(new ExpressionStatement( 84 _insertStatement(new ExpressionStatement(
83 new MethodInvocation(accessContext, new Name('[]='), arguments))); 85 new MethodInvocation(accessContext, new Name('[]='), arguments)));
84 } 86 }
85 87
86 Block _currentBlock; 88 Block _currentBlock;
87 int _insertionIndex; 89 int _insertionIndex;
88 } 90 }
(...skipping 27 matching lines...) Expand all
116 Expression extendContext = 118 Expression extendContext =
117 new MethodInvocation(accessContext, new Name('[]='), arguments); 119 new MethodInvocation(accessContext, new Name('[]='), arguments);
118 Let parent = initializingExpression.parent; 120 Let parent = initializingExpression.parent;
119 Let binding = new Let( 121 Let binding = new Let(
120 new VariableDeclaration(null, initializer: extendContext), 122 new VariableDeclaration(null, initializer: extendContext),
121 initializingExpression); 123 initializingExpression);
122 parent.body = binding; 124 parent.body = binding;
123 binding.parent = parent; 125 binding.parent = parent;
124 } 126 }
125 } 127 }
OLDNEW
« no previous file with comments | « no previous file | pkg/kernel/testcases/closures/capture_closure.dart.expect » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698