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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 processJsInteropAnnotation(element); | 109 processJsInteropAnnotation(element); |
110 if (!element.isJsInterop) return; | 110 if (!element.isJsInterop) return; |
111 if (element is FunctionElement) { | 111 if (element is FunctionElement) { |
112 _checkFunctionParameters(element); | 112 _checkFunctionParameters(element); |
113 } | 113 } |
114 | 114 |
115 if (!element.isClass) return; | 115 if (!element.isClass) return; |
116 | 116 |
117 ClassElement classElement = element; | 117 ClassElement classElement = element; |
118 | 118 |
| 119 // Skip classes that are completely unreachable. This should only happen |
| 120 // when all of jsinterop types are unreachable from main. |
| 121 if (!backend.compiler.world.isImplemented(classElement)) return; |
| 122 |
119 if (!classElement | 123 if (!classElement |
120 .implementsInterface(backend.jsJavaScriptObjectClass)) { | 124 .implementsInterface(backend.jsJavaScriptObjectClass)) { |
121 backend.reporter.reportErrorMessage(classElement, | 125 backend.reporter.reportErrorMessage(classElement, |
122 MessageKind.JS_INTEROP_CLASS_CANNOT_EXTEND_DART_CLASS, { | 126 MessageKind.JS_INTEROP_CLASS_CANNOT_EXTEND_DART_CLASS, { |
123 'cls': classElement.name, | 127 'cls': classElement.name, |
124 'superclass': classElement.superclass.name | 128 'superclass': classElement.superclass.name |
125 }); | 129 }); |
126 } | 130 } |
127 | 131 |
128 classElement.forEachMember( | 132 classElement.forEachMember( |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 var name = backend.namer.invocationName(selector); | 184 var name = backend.namer.invocationName(selector); |
181 statements.add(js.statement( | 185 statements.add(js.statement( |
182 'Function.prototype.# = function(#) { return this(#) }', | 186 'Function.prototype.# = function(#) { return this(#) }', |
183 [name, parameters, parameters])); | 187 [name, parameters, parameters])); |
184 } | 188 } |
185 }); | 189 }); |
186 }); | 190 }); |
187 return new jsAst.Block(statements); | 191 return new jsAst.Block(statements); |
188 } | 192 } |
189 } | 193 } |
OLD | NEW |