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 library dart2js.js_emitter.parameter_stub_generator; | 5 library dart2js.js_emitter.parameter_stub_generator; |
6 | 6 |
7 import '../closure.dart' show ClosureClassElement; | 7 import '../closure.dart' show ClosureClassElement; |
8 import '../common.dart'; | 8 import '../common.dart'; |
9 import '../common_elements.dart'; | 9 import '../common_elements.dart'; |
10 import '../constants/values.dart'; | 10 import '../constants/values.dart'; |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 // invoked from a subclass. Then we cannot just redirect, since that | 213 // invoked from a subclass. Then we cannot just redirect, since that |
214 // would invoke the methods of the subclass. We have to compile to: | 214 // would invoke the methods of the subclass. We have to compile to: |
215 // (1) foo$2(a, b) => MyClass.foo$4$c$d.call(this, a, b, null, null) | 215 // (1) foo$2(a, b) => MyClass.foo$4$c$d.call(this, a, b, null, null) |
216 // (2) foo$3$c(a, b, c) => MyClass.foo$4$c$d(this, a, b, c, null); | 216 // (2) foo$3$c(a, b, c) => MyClass.foo$4$c$d(this, a, b, c, null); |
217 // (3) foo$3$d(a, b, d) => MyClass.foo$4$c$d(this, a, b, null, d); | 217 // (3) foo$3$d(a, b, d) => MyClass.foo$4$c$d(this, a, b, null, d); |
218 List<ParameterStubMethod> generateParameterStubs(FunctionEntity member, | 218 List<ParameterStubMethod> generateParameterStubs(FunctionEntity member, |
219 {bool canTearOff: true}) { | 219 {bool canTearOff: true}) { |
220 if (member.enclosingClass != null && member.enclosingClass.isClosure) { | 220 if (member.enclosingClass != null && member.enclosingClass.isClosure) { |
221 ClosureClassElement cls = member.enclosingClass; | 221 ClosureClassElement cls = member.enclosingClass; |
222 if (cls.supertype.element == _commonElements.boundClosureClass) { | 222 if (cls.supertype.element == _commonElements.boundClosureClass) { |
223 throw new SpannableAssertionFailure( | 223 failedAt(cls.methodElement, 'Bound closure1.'); |
224 cls.methodElement, 'Bound closure1.'); | |
225 } | 224 } |
226 if (cls.methodElement.isInstanceMember) { | 225 if (cls.methodElement.isInstanceMember) { |
227 throw new SpannableAssertionFailure( | 226 failedAt(cls.methodElement, 'Bound closure2.'); |
228 cls.methodElement, 'Bound closure2.'); | |
229 } | 227 } |
230 } | 228 } |
231 | 229 |
232 // The set of selectors that apply to `member`. For example, for | 230 // The set of selectors that apply to `member`. For example, for |
233 // a member `foo(x, [y])` the following selectors may apply: | 231 // a member `foo(x, [y])` the following selectors may apply: |
234 // `foo(x)`, and `foo(x, y)`. | 232 // `foo(x)`, and `foo(x, y)`. |
235 Map<Selector, SelectorConstraints> selectors; | 233 Map<Selector, SelectorConstraints> selectors; |
236 // The set of selectors that apply to `member` if it's name was `call`. | 234 // The set of selectors that apply to `member` if it's name was `call`. |
237 // This happens when a member is torn off. In that case calls to the | 235 // This happens when a member is torn off. In that case calls to the |
238 // function use the name `call`, and we must be able to handle every | 236 // function use the name `call`, and we must be able to handle every |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 generateParameterStub(member, selector, null); | 305 generateParameterStub(member, selector, null); |
308 if (stub != null) { | 306 if (stub != null) { |
309 stubs.add(stub); | 307 stubs.add(stub); |
310 } | 308 } |
311 } | 309 } |
312 } | 310 } |
313 | 311 |
314 return stubs; | 312 return stubs; |
315 } | 313 } |
316 } | 314 } |
OLD | NEW |