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 15 matching lines...) Expand all Loading... |
26 String get name => 'JavaScript patch resolver'; | 26 String get name => 'JavaScript patch resolver'; |
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 if (!element.isConstructor || |
| 37 !element.isFromEnvironmentConstructor) { |
| 38 // Note: currently we allow a handful of 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. |
37 reporter.reportErrorMessage( | 42 reporter.reportErrorMessage( |
38 element, MessageKind.PATCH_EXTERNAL_WITHOUT_IMPLEMENTATION); | 43 element, MessageKind.PATCH_EXTERNAL_WITHOUT_IMPLEMENTATION); |
39 } | 44 } |
40 return element; | 45 return element; |
41 } | 46 } |
42 | 47 |
43 void checkMatchingPatchParameters(FunctionElement origin, | 48 void checkMatchingPatchParameters(FunctionElement origin, |
44 List<Element> originParameters, List<Element> patchParameters) { | 49 List<Element> originParameters, List<Element> patchParameters) { |
45 bool isUnnamedListConstructor = origin is ConstructorElement && | 50 bool isUnnamedListConstructor = origin is ConstructorElement && |
46 compiler.commonElements.isUnnamedListConstructor(origin); | 51 compiler.commonElements.isUnnamedListConstructor(origin); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 'originParameterCount': originSignature.optionalParameterCount, | 181 'originParameterCount': originSignature.optionalParameterCount, |
177 'patchParameterCount': patchSignature.optionalParameterCount | 182 'patchParameterCount': patchSignature.optionalParameterCount |
178 }); | 183 }); |
179 }); | 184 }); |
180 } else { | 185 } else { |
181 checkMatchingPatchParameters(origin, originSignature.optionalParameters, | 186 checkMatchingPatchParameters(origin, originSignature.optionalParameters, |
182 patchSignature.optionalParameters); | 187 patchSignature.optionalParameters); |
183 } | 188 } |
184 } | 189 } |
185 } | 190 } |
OLD | NEW |