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; |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 FunctionElement resolveExternalFunction(FunctionElementX element) { | 28 FunctionElement resolveExternalFunction(FunctionElementX element) { |
29 if (element.isPatched) { | 29 if (element.isPatched) { |
30 FunctionElementX patch = element.patch; | 30 FunctionElementX patch = element.patch; |
31 reporter.withCurrentElement(patch, () { | 31 reporter.withCurrentElement(patch, () { |
32 patch.computeType(resolution); | 32 patch.computeType(resolution); |
33 }); | 33 }); |
34 checkMatchingPatchSignatures(element, patch); | 34 checkMatchingPatchSignatures(element, patch); |
35 element = patch; | 35 element = patch; |
36 } else { | 36 } else { |
| 37 if (element.isConstructor) { |
| 38 // Note: currently we allow a couple external methods without a patch, |
| 39 // namely the *.fromEnvironment const constructors in int, bool, and |
| 40 // String. In the future we might also represent native DOM methods in |
| 41 // dart:html this way. |
| 42 ConstructorElementX constructor = element; |
| 43 if (constructor.isFromEnvironmentConstructor) return element; |
| 44 } |
37 reporter.reportErrorMessage( | 45 reporter.reportErrorMessage( |
38 element, MessageKind.PATCH_EXTERNAL_WITHOUT_IMPLEMENTATION); | 46 element, MessageKind.PATCH_EXTERNAL_WITHOUT_IMPLEMENTATION); |
39 } | 47 } |
40 return element; | 48 return element; |
41 } | 49 } |
42 | 50 |
43 void checkMatchingPatchParameters(FunctionElement origin, | 51 void checkMatchingPatchParameters(FunctionElement origin, |
44 List<Element> originParameters, List<Element> patchParameters) { | 52 List<Element> originParameters, List<Element> patchParameters) { |
45 bool isUnnamedListConstructor = origin is ConstructorElement && | 53 bool isUnnamedListConstructor = origin is ConstructorElement && |
46 compiler.commonElements.isUnnamedListConstructor(origin); | 54 compiler.commonElements.isUnnamedListConstructor(origin); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 'originParameterCount': originSignature.optionalParameterCount, | 184 'originParameterCount': originSignature.optionalParameterCount, |
177 'patchParameterCount': patchSignature.optionalParameterCount | 185 'patchParameterCount': patchSignature.optionalParameterCount |
178 }); | 186 }); |
179 }); | 187 }); |
180 } else { | 188 } else { |
181 checkMatchingPatchParameters(origin, originSignature.optionalParameters, | 189 checkMatchingPatchParameters(origin, originSignature.optionalParameters, |
182 patchSignature.optionalParameters); | 190 patchSignature.optionalParameters); |
183 } | 191 } |
184 } | 192 } |
185 } | 193 } |
OLD | NEW |