| 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 updateLocal(boxedVariable, oldValue); | 195 updateLocal(boxedVariable, oldValue); |
| 196 } | 196 } |
| 197 updateLocal(boxElement, newBox); | 197 updateLocal(boxElement, newBox); |
| 198 } | 198 } |
| 199 | 199 |
| 200 /// Documentation wanted -- johnniwinther | 200 /// Documentation wanted -- johnniwinther |
| 201 /// | 201 /// |
| 202 /// Invariant: [function] must be an implementation element. | 202 /// Invariant: [function] must be an implementation element. |
| 203 void startFunction(MemberEntity element, ast.Node node, | 203 void startFunction(MemberEntity element, ast.Node node, |
| 204 {bool isGenerativeConstructorBody}) { | 204 {bool isGenerativeConstructorBody}) { |
| 205 assert(invariant( | 205 assert(!(element is MemberElement && !element.isImplementation), |
| 206 element, !(element is MemberElement && !element.isImplementation))); | 206 failedAt(element)); |
| 207 closureData = _closureToClassMapper.getMemberMap(element); | 207 closureData = _closureToClassMapper.getMemberMap(element); |
| 208 | 208 |
| 209 if (element is MethodElement) { | 209 if (element is MethodElement) { |
| 210 MethodElement functionElement = element; | 210 MethodElement functionElement = element; |
| 211 FunctionSignature params = functionElement.functionSignature; | 211 FunctionSignature params = functionElement.functionSignature; |
| 212 ClosureScope scopeData = closureData.capturingScopes[node]; | 212 ClosureScope scopeData = closureData.capturingScopes[node]; |
| 213 params.orderedForEachParameter((ParameterElement parameterElement) { | 213 params.orderedForEachParameter((ParameterElement parameterElement) { |
| 214 if (element.isGenerativeConstructorBody) { | 214 if (element.isGenerativeConstructorBody) { |
| 215 if (scopeData != null && | 215 if (scopeData != null && |
| 216 scopeData.isCapturedVariable(parameterElement)) { | 216 scopeData.isCapturedVariable(parameterElement)) { |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 return res; | 380 return res; |
| 381 } | 381 } |
| 382 | 382 |
| 383 HLocalValue getLocal(Local local, {SourceInformation sourceInformation}) { | 383 HLocalValue getLocal(Local local, {SourceInformation sourceInformation}) { |
| 384 // If the element is a parameter, we already have a | 384 // If the element is a parameter, we already have a |
| 385 // HParameterValue for it. We cannot create another one because | 385 // HParameterValue for it. We cannot create another one because |
| 386 // it could then have another name than the real parameter. And | 386 // it could then have another name than the real parameter. And |
| 387 // the other one would not know it is just a copy of the real | 387 // the other one would not know it is just a copy of the real |
| 388 // parameter. | 388 // parameter. |
| 389 if (local is ParameterElement) { | 389 if (local is ParameterElement) { |
| 390 assert(invariant(local, builder.parameters.containsKey(local), | 390 assert( |
| 391 message: "No local value for parameter $local in " | 391 builder.parameters.containsKey(local), |
| 392 "${builder.parameters}.")); | 392 failedAt(local, |
| 393 "No local value for parameter $local in ${builder.parameters}.")); |
| 393 return builder.parameters[local]; | 394 return builder.parameters[local]; |
| 394 } | 395 } |
| 395 | 396 |
| 396 return activationVariables.putIfAbsent(local, () { | 397 return activationVariables.putIfAbsent(local, () { |
| 397 HLocalValue localValue = new HLocalValue(local, commonMasks.nonNullType) | 398 HLocalValue localValue = new HLocalValue(local, commonMasks.nonNullType) |
| 398 ..sourceInformation = sourceInformation; | 399 ..sourceInformation = sourceInformation; |
| 399 builder.graph.entry.addAtExit(localValue); | 400 builder.graph.entry.addAtExit(localValue); |
| 400 return localValue; | 401 return localValue; |
| 401 }); | 402 }); |
| 402 } | 403 } |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 final MemberEntity memberContext; | 683 final MemberEntity memberContext; |
| 683 | 684 |
| 684 // Avoid slow Object.hashCode. | 685 // Avoid slow Object.hashCode. |
| 685 final int hashCode = _nextHashCode = (_nextHashCode + 1).toUnsigned(30); | 686 final int hashCode = _nextHashCode = (_nextHashCode + 1).toUnsigned(30); |
| 686 static int _nextHashCode = 0; | 687 static int _nextHashCode = 0; |
| 687 | 688 |
| 688 SyntheticLocal(this.name, this.executableContext, this.memberContext); | 689 SyntheticLocal(this.name, this.executableContext, this.memberContext); |
| 689 | 690 |
| 690 toString() => 'SyntheticLocal($name)'; | 691 toString() => 'SyntheticLocal($name)'; |
| 691 } | 692 } |
| OLD | NEW |