OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 /// Analysis to determine how to generate code for typed JavaScript interop. | 5 /// Analysis to determine how to generate code for typed JavaScript interop. |
6 library compiler.src.js_backend.js_interop_analysis; | 6 library compiler.src.js_backend.js_interop_analysis; |
7 | 7 |
8 import '../common/names.dart' show Identifiers; | 8 import '../common/names.dart' show Identifiers; |
9 import '../compiler.dart' show Compiler; | 9 import '../compiler.dart' show Compiler; |
10 import '../diagnostics/messages.dart' show MessageKind; | 10 import '../diagnostics/messages.dart' show MessageKind; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 processJsInteropAnnotation(element); | 113 processJsInteropAnnotation(element); |
114 if (!backend.isJsInterop(element)) return; | 114 if (!backend.isJsInterop(element)) return; |
115 if (element is FunctionElement) { | 115 if (element is FunctionElement) { |
116 _checkFunctionParameters(element); | 116 _checkFunctionParameters(element); |
117 } | 117 } |
118 | 118 |
119 if (!element.isClass) return; | 119 if (!element.isClass) return; |
120 | 120 |
121 ClassElement classElement = element; | 121 ClassElement classElement = element; |
122 | 122 |
| 123 // Skip classes that are completely unreachable. This should only happen |
| 124 // when all of jsinterop types are unreachable from main. |
| 125 if (!backend.compiler.world.isImplemented(classElement)) return; |
| 126 |
123 if (!classElement | 127 if (!classElement |
124 .implementsInterface(helpers.jsJavaScriptObjectClass)) { | 128 .implementsInterface(helpers.jsJavaScriptObjectClass)) { |
125 backend.reporter.reportErrorMessage(classElement, | 129 backend.reporter.reportErrorMessage(classElement, |
126 MessageKind.JS_INTEROP_CLASS_CANNOT_EXTEND_DART_CLASS, { | 130 MessageKind.JS_INTEROP_CLASS_CANNOT_EXTEND_DART_CLASS, { |
127 'cls': classElement.name, | 131 'cls': classElement.name, |
128 'superclass': classElement.superclass.name | 132 'superclass': classElement.superclass.name |
129 }); | 133 }); |
130 } | 134 } |
131 | 135 |
132 classElement.forEachMember( | 136 classElement.forEachMember( |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 var name = backend.namer.invocationName(selector); | 188 var name = backend.namer.invocationName(selector); |
185 statements.add(js.statement( | 189 statements.add(js.statement( |
186 'Function.prototype.# = function(#) { return this(#) }', | 190 'Function.prototype.# = function(#) { return this(#) }', |
187 [name, parameters, parameters])); | 191 [name, parameters, parameters])); |
188 } | 192 } |
189 }); | 193 }); |
190 }); | 194 }); |
191 return new jsAst.Block(statements); | 195 return new jsAst.Block(statements); |
192 } | 196 } |
193 } | 197 } |
OLD | NEW |