| 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 '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/resolution.dart' show Resolution; | 8 import '../common/resolution.dart' show Resolution; |
| 9 import '../common/tasks.dart' show CompilerTask; | 9 import '../common/tasks.dart' show CompilerTask; |
| 10 import '../compiler.dart' show Compiler; | 10 import '../compiler.dart' show Compiler; |
| 11 import '../dart_types.dart'; | 11 import '../dart_types.dart'; |
| 12 import '../elements/elements.dart'; | 12 import '../elements/elements.dart'; |
| 13 import '../elements/modelx.dart'; | 13 import '../elements/modelx.dart'; |
| 14 import '../tree/tree.dart'; | 14 import '../tree/tree.dart'; |
| 15 | 15 |
| 16 class PatchResolverTask extends CompilerTask { | 16 class PatchResolverTask extends CompilerTask { |
| 17 PatchResolverTask(Compiler compiler) : super(compiler); | 17 PatchResolverTask(Compiler compiler) : super(compiler); |
| 18 | 18 |
| 19 Resolution get resolution => compiler.resolution; | 19 Resolution get resolution => compiler.resolution; |
| 20 | 20 |
| 21 String get name => 'JavaScript patch resolver'; | 21 String get name => 'JavaScript patch resolver'; |
| 22 | 22 |
| 23 FunctionElement resolveExternalFunction(FunctionElementX element) { | 23 FunctionElement resolveExternalFunction(FunctionElementX element) |
| 24 => measureElement(element, () { |
| 24 if (element.isPatched) { | 25 if (element.isPatched) { |
| 25 FunctionElementX patch = element.patch; | 26 FunctionElementX patch = element.patch; |
| 26 reporter.withCurrentElement(patch, () { | 27 reporter.withCurrentElement(patch, () { |
| 27 patch.computeType(resolution); | 28 patch.computeType(resolution); |
| 28 }); | 29 }); |
| 29 checkMatchingPatchSignatures(element, patch); | 30 checkMatchingPatchSignatures(element, patch); |
| 30 element = patch; | 31 element = patch; |
| 31 } else if (!compiler.backend.isJsInterop(element)) { | 32 } else if (!compiler.backend.isJsInterop(element)) { |
| 32 reporter.reportErrorMessage( | 33 reporter.reportErrorMessage( |
| 33 element, MessageKind.PATCH_EXTERNAL_WITHOUT_IMPLEMENTATION); | 34 element, MessageKind.PATCH_EXTERNAL_WITHOUT_IMPLEMENTATION); |
| 34 } | 35 } |
| 35 return element; | 36 return element; |
| 36 } | 37 }); |
| 37 | 38 |
| 38 void checkMatchingPatchParameters(FunctionElement origin, | 39 void checkMatchingPatchParameters(FunctionElement origin, |
| 39 List<Element> originParameters, List<Element> patchParameters) { | 40 List<Element> originParameters, List<Element> patchParameters) { |
| 40 assert(originParameters.length == patchParameters.length); | 41 assert(originParameters.length == patchParameters.length); |
| 41 for (int index = 0; index < originParameters.length; index++) { | 42 for (int index = 0; index < originParameters.length; index++) { |
| 42 ParameterElementX originParameter = originParameters[index]; | 43 ParameterElementX originParameter = originParameters[index]; |
| 43 ParameterElementX patchParameter = patchParameters[index]; | 44 ParameterElementX patchParameter = patchParameters[index]; |
| 44 // TODO(johnniwinther): Remove the conditional patching when we never | 45 // TODO(johnniwinther): Remove the conditional patching when we never |
| 45 // resolve the same method twice. | 46 // resolve the same method twice. |
| 46 if (!originParameter.isPatched) { | 47 if (!originParameter.isPatched) { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 'originParameterCount': originSignature.optionalParameterCount, | 153 'originParameterCount': originSignature.optionalParameterCount, |
| 153 'patchParameterCount': patchSignature.optionalParameterCount | 154 'patchParameterCount': patchSignature.optionalParameterCount |
| 154 }); | 155 }); |
| 155 }); | 156 }); |
| 156 } else { | 157 } else { |
| 157 checkMatchingPatchParameters(origin, originSignature.optionalParameters, | 158 checkMatchingPatchParameters(origin, originSignature.optionalParameters, |
| 158 patchSignature.optionalParameters); | 159 patchSignature.optionalParameters); |
| 159 } | 160 } |
| 160 } | 161 } |
| 161 } | 162 } |
| OLD | NEW |