| 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 } | 216 } |
| 217 } | 217 } |
| 218 HInstruction parameter = builder.addParameter(local, typeMask); | 218 HInstruction parameter = builder.addParameter(local, typeMask); |
| 219 builder.parameters[local] = parameter; | 219 builder.parameters[local] = parameter; |
| 220 directLocals[local] = parameter; | 220 directLocals[local] = parameter; |
| 221 }); | 221 }); |
| 222 | 222 |
| 223 enterScope(scopeData, | 223 enterScope(scopeData, |
| 224 forGenerativeConstructorBody: isGenerativeConstructorBody); | 224 forGenerativeConstructorBody: isGenerativeConstructorBody); |
| 225 | 225 |
| 226 // If the freeVariableMapping is not empty, then this function was a | |
| 227 // nested closure that captures variables. Redirect the captured | |
| 228 // variables to fields in the closure. | |
| 229 closureData.forEachFreeVariable((Local from, FieldEntity to) { | |
| 230 redirectElement(from, to); | |
| 231 }); | |
| 232 if (closureData.isClosure) { | 226 if (closureData.isClosure) { |
| 227 // If the freeVariableMapping is not empty, then this function was a |
| 228 // nested closure that captures variables. Redirect the captured |
| 229 // variables to fields in the closure. |
| 230 closureData.forEachFreeVariable((Local from, FieldEntity to) { |
| 231 redirectElement(from, to); |
| 232 }); |
| 233 // Inside closure redirect references to itself to [:this:]. | 233 // Inside closure redirect references to itself to [:this:]. |
| 234 HThis thisInstruction = | 234 HThis thisInstruction = |
| 235 new HThis(closureData.thisLocal, commonMasks.nonNullType); | 235 new HThis(closureData.thisLocal, commonMasks.nonNullType); |
| 236 builder.graph.thisInstruction = thisInstruction; | 236 builder.graph.thisInstruction = thisInstruction; |
| 237 builder.graph.entry.addAtEntry(thisInstruction); | 237 builder.graph.entry.addAtEntry(thisInstruction); |
| 238 updateLocal(closureData.closureEntity, thisInstruction); | 238 updateLocal(closureData.closureEntity, thisInstruction); |
| 239 } else if (element.isInstanceMember) { | 239 } else if (element.isInstanceMember) { |
| 240 // Once closures have been mapped to classes their instance members might | 240 // Once closures have been mapped to classes their instance members might |
| 241 // not have any thisElement if the closure was created inside a static | 241 // not have any thisElement if the closure was created inside a static |
| 242 // context. | 242 // context. |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 final MemberEntity memberContext; | 670 final MemberEntity memberContext; |
| 671 | 671 |
| 672 // Avoid slow Object.hashCode. | 672 // Avoid slow Object.hashCode. |
| 673 final int hashCode = _nextHashCode = (_nextHashCode + 1).toUnsigned(30); | 673 final int hashCode = _nextHashCode = (_nextHashCode + 1).toUnsigned(30); |
| 674 static int _nextHashCode = 0; | 674 static int _nextHashCode = 0; |
| 675 | 675 |
| 676 SyntheticLocal(this.name, this.executableContext, this.memberContext); | 676 SyntheticLocal(this.name, this.executableContext, this.memberContext); |
| 677 | 677 |
| 678 toString() => 'SyntheticLocal($name)'; | 678 toString() => 'SyntheticLocal($name)'; |
| 679 } | 679 } |
| OLD | NEW |