| 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 // (5) No stub generated, call is direct. | 210 // (5) No stub generated, call is direct. |
| 211 // | 211 // |
| 212 // We need to pay attention if this stub is for a function that has been | 212 // We need to pay attention if this stub is for a function that has been |
| 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 { |
| 221 ClosureClassElement cls = member.enclosingClass; | 221 var enclosingClass = member.enclosingClass; |
| 222 if (cls.supertype.element == _commonElements.boundClosureClass) { | 222 if (enclosingClass != null && enclosingClass.isClosure) { |
| 223 failedAt(cls.methodElement, 'Bound closure1.'); | 223 if (enclosingClass is ClosureClassElement) { |
| 224 } | 224 // TODO(redemption): What is the equivalent invariant for J-entities? |
| 225 if (cls.methodElement.isInstanceMember) { | 225 var methodElement = enclosingClass.methodElement; |
| 226 failedAt(cls.methodElement, 'Bound closure2.'); | 226 if (enclosingClass.supertype.element == |
| 227 _commonElements.boundClosureClass) { |
| 228 failedAt(methodElement, 'Bound closure1.'); |
| 229 } |
| 230 if (methodElement.isInstanceMember) { |
| 231 failedAt(methodElement, 'Bound closure2.'); |
| 232 } |
| 233 } |
| 227 } | 234 } |
| 228 } | 235 } |
| 229 | 236 |
| 230 // The set of selectors that apply to `member`. For example, for | 237 // The set of selectors that apply to `member`. For example, for |
| 231 // a member `foo(x, [y])` the following selectors may apply: | 238 // a member `foo(x, [y])` the following selectors may apply: |
| 232 // `foo(x)`, and `foo(x, y)`. | 239 // `foo(x)`, and `foo(x, y)`. |
| 233 Map<Selector, SelectorConstraints> selectors; | 240 Map<Selector, SelectorConstraints> selectors; |
| 234 // The set of selectors that apply to `member` if it's name was `call`. | 241 // The set of selectors that apply to `member` if it's name was `call`. |
| 235 // This happens when a member is torn off. In that case calls to the | 242 // This happens when a member is torn off. In that case calls to the |
| 236 // function use the name `call`, and we must be able to handle every | 243 // 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... |
| 305 generateParameterStub(member, selector, null); | 312 generateParameterStub(member, selector, null); |
| 306 if (stub != null) { | 313 if (stub != null) { |
| 307 stubs.add(stub); | 314 stubs.add(stub); |
| 308 } | 315 } |
| 309 } | 316 } |
| 310 } | 317 } |
| 311 | 318 |
| 312 return stubs; | 319 return stubs; |
| 313 } | 320 } |
| 314 } | 321 } |
| OLD | NEW |