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 import '../closure.dart'; | 5 import '../closure.dart'; |
6 import '../common.dart'; | 6 import '../common.dart'; |
7 import '../elements/elements.dart'; | 7 import '../elements/elements.dart'; |
8 import '../elements/entities.dart'; | 8 import '../elements/entities.dart'; |
9 import '../elements/types.dart'; | 9 import '../elements/types.dart'; |
10 import '../io/source_information.dart'; | 10 import '../io/source_information.dart'; |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 // The box is passed as a parameter to a generative | 147 // The box is passed as a parameter to a generative |
148 // constructor body. | 148 // constructor body. |
149 box = builder.addParameter(closureInfo.context, commonMasks.nonNullType); | 149 box = builder.addParameter(closureInfo.context, commonMasks.nonNullType); |
150 } else { | 150 } else { |
151 box = createBox(); | 151 box = createBox(); |
152 } | 152 } |
153 // Add the box to the known locals. | 153 // Add the box to the known locals. |
154 directLocals[closureInfo.context] = box; | 154 directLocals[closureInfo.context] = box; |
155 // Make sure that accesses to the boxed locals go into the box. We also | 155 // Make sure that accesses to the boxed locals go into the box. We also |
156 // need to make sure that parameters are copied into the box if necessary. | 156 // need to make sure that parameters are copied into the box if necessary. |
157 closureInfo.forEachCapturedVariable( | 157 closureInfo.forEachCapturedVariable((_from, _to) { |
158 (LocalVariableElement from, BoxFieldElement to) { | 158 LocalVariableElement from = _from; |
| 159 BoxFieldElement to = _to; |
159 // The [from] can only be a parameter for function-scopes and not | 160 // The [from] can only be a parameter for function-scopes and not |
160 // loop scopes. | 161 // loop scopes. |
161 if (from.isRegularParameter && !forGenerativeConstructorBody) { | 162 if (from.isRegularParameter && !forGenerativeConstructorBody) { |
162 // Now that the redirection is set up, the update to the local will | 163 // Now that the redirection is set up, the update to the local will |
163 // write the parameter value into the box. | 164 // write the parameter value into the box. |
164 // Store the captured parameter in the box. Get the current value | 165 // Store the captured parameter in the box. Get the current value |
165 // before we put the redirection in place. | 166 // before we put the redirection in place. |
166 // We don't need to update the local for a generative | 167 // We don't need to update the local for a generative |
167 // constructor body, because it receives a box that already | 168 // constructor body, because it receives a box that already |
168 // contains the updates as the last parameter. | 169 // contains the updates as the last parameter. |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 final MemberEntity memberContext; | 674 final MemberEntity memberContext; |
674 | 675 |
675 // Avoid slow Object.hashCode. | 676 // Avoid slow Object.hashCode. |
676 final int hashCode = _nextHashCode = (_nextHashCode + 1).toUnsigned(30); | 677 final int hashCode = _nextHashCode = (_nextHashCode + 1).toUnsigned(30); |
677 static int _nextHashCode = 0; | 678 static int _nextHashCode = 0; |
678 | 679 |
679 SyntheticLocal(this.name, this.executableContext, this.memberContext); | 680 SyntheticLocal(this.name, this.executableContext, this.memberContext); |
680 | 681 |
681 toString() => 'SyntheticLocal($name)'; | 682 toString() => 'SyntheticLocal($name)'; |
682 } | 683 } |
OLD | NEW |