OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |