| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 dart2js.js_backend.patch_resolver; | 5 library dart2js.js_backend.patch_resolver; |
| 6 | 6 |
| 7 import '../dart2jslib.dart'; | 7 import '../dart2jslib.dart'; |
| 8 import '../dart_types.dart'; | 8 import '../dart_types.dart'; |
| 9 import '../elements/elements.dart'; | 9 import '../elements/elements.dart'; |
| 10 import '../elements/modelx.dart'; | 10 import '../elements/modelx.dart'; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 checkMatchingPatchSignatures(element, patch); | 27 checkMatchingPatchSignatures(element, patch); |
| 28 element = patch; | 28 element = patch; |
| 29 } else { | 29 } else { |
| 30 compiler.reportError( | 30 compiler.reportError( |
| 31 element, MessageKind.PATCH_EXTERNAL_WITHOUT_IMPLEMENTATION); | 31 element, MessageKind.PATCH_EXTERNAL_WITHOUT_IMPLEMENTATION); |
| 32 } | 32 } |
| 33 return element; | 33 return element; |
| 34 } | 34 } |
| 35 | 35 |
| 36 void checkMatchingPatchParameters(FunctionElement origin, | 36 void checkMatchingPatchParameters(FunctionElement origin, |
| 37 Link<Element> originParameters, | 37 List<Element> originParameters, |
| 38 Link<Element> patchParameters) { | 38 List<Element> patchParameters) { |
| 39 while (!originParameters.isEmpty) { | 39 |
| 40 ParameterElementX originParameter = originParameters.head; | 40 assert(originParameters.length == patchParameters.length); |
| 41 ParameterElementX patchParameter = patchParameters.head; | 41 for (int index = 0; index < originParameters.length; index++) { |
| 42 ParameterElementX originParameter = originParameters[index]; |
| 43 ParameterElementX patchParameter = patchParameters[index]; |
| 42 // TODO(johnniwinther): Remove the conditional patching when we never | 44 // TODO(johnniwinther): Remove the conditional patching when we never |
| 43 // resolve the same method twice. | 45 // resolve the same method twice. |
| 44 if (!originParameter.isPatched) { | 46 if (!originParameter.isPatched) { |
| 45 originParameter.applyPatch(patchParameter); | 47 originParameter.applyPatch(patchParameter); |
| 46 } else { | 48 } else { |
| 47 assert(invariant(origin, originParameter.patch == patchParameter, | 49 assert(invariant(origin, originParameter.patch == patchParameter, |
| 48 message: "Inconsistent repatch of $originParameter.")); | 50 message: "Inconsistent repatch of $originParameter.")); |
| 49 } | 51 } |
| 50 DartType originParameterType = originParameter.computeType(compiler); | 52 DartType originParameterType = originParameter.computeType(compiler); |
| 51 DartType patchParameterType = patchParameter.computeType(compiler); | 53 DartType patchParameterType = patchParameter.computeType(compiler); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 79 originParameter.parseNode(compiler), | 81 originParameter.parseNode(compiler), |
| 80 MessageKind.PATCH_PARAMETER_MISMATCH, | 82 MessageKind.PATCH_PARAMETER_MISMATCH, |
| 81 {'methodName': origin.name, | 83 {'methodName': origin.name, |
| 82 'originParameter': originParameterText, | 84 'originParameter': originParameterText, |
| 83 'patchParameter': patchParameterText}); | 85 'patchParameter': patchParameterText}); |
| 84 compiler.reportInfo(patchParameter, | 86 compiler.reportInfo(patchParameter, |
| 85 MessageKind.PATCH_POINT_TO_PARAMETER, | 87 MessageKind.PATCH_POINT_TO_PARAMETER, |
| 86 {'parameterName': patchParameter.name}); | 88 {'parameterName': patchParameter.name}); |
| 87 } | 89 } |
| 88 } | 90 } |
| 89 | |
| 90 originParameters = originParameters.tail; | |
| 91 patchParameters = patchParameters.tail; | |
| 92 } | 91 } |
| 93 } | 92 } |
| 94 | 93 |
| 95 void checkMatchingPatchSignatures(FunctionElement origin, | 94 void checkMatchingPatchSignatures(FunctionElement origin, |
| 96 FunctionElement patch) { | 95 FunctionElement patch) { |
| 97 // TODO(johnniwinther): Show both origin and patch locations on errors. | 96 // TODO(johnniwinther): Show both origin and patch locations on errors. |
| 98 FunctionExpression originTree = origin.node; | 97 FunctionExpression originTree = origin.node; |
| 99 FunctionSignature originSignature = origin.functionSignature; | 98 FunctionSignature originSignature = origin.functionSignature; |
| 100 FunctionExpression patchTree = patch.node; | 99 FunctionExpression patchTree = patch.node; |
| 101 FunctionSignature patchSignature = patch.functionSignature; | 100 FunctionSignature patchSignature = patch.functionSignature; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 'patchParameterCount': patchSignature.optionalParameterCount}); | 148 'patchParameterCount': patchSignature.optionalParameterCount}); |
| 150 }); | 149 }); |
| 151 } else { | 150 } else { |
| 152 checkMatchingPatchParameters(origin, | 151 checkMatchingPatchParameters(origin, |
| 153 originSignature.optionalParameters, | 152 originSignature.optionalParameters, |
| 154 patchSignature.optionalParameters); | 153 patchSignature.optionalParameters); |
| 155 } | 154 } |
| 156 } | 155 } |
| 157 | 156 |
| 158 } | 157 } |
| OLD | NEW |