Chromium Code Reviews| 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'; |
| 11 import '../elements/elements.dart' | 11 import '../elements/elements.dart' |
| 12 show | 12 show |
| 13 ClassElement, | 13 ClassElement, |
| 14 FunctionElement, | 14 FunctionElement, |
| 15 FunctionSignature, | 15 FunctionSignature, |
| 16 MethodElement, | 16 MethodElement, |
| 17 ParameterElement; | 17 ParameterElement; |
| 18 import '../elements/entities.dart'; | |
| 19 import '../elements/names.dart'; | |
| 18 import '../js/js.dart' as jsAst; | 20 import '../js/js.dart' as jsAst; |
| 19 import '../js/js.dart' show js; | 21 import '../js/js.dart' show js; |
| 20 import '../js_backend/constant_handler_javascript.dart' | 22 import '../js_backend/constant_handler_javascript.dart' |
| 21 show JavaScriptConstantCompiler; | 23 show JavaScriptConstantCompiler; |
| 22 import '../js_backend/namer.dart' show Namer; | 24 import '../js_backend/namer.dart' show Namer; |
| 23 import '../js_backend/native_data.dart'; | 25 import '../js_backend/native_data.dart'; |
| 24 import '../js_backend/interceptor_data.dart'; | 26 import '../js_backend/interceptor_data.dart'; |
| 25 import '../universe/call_structure.dart' show CallStructure; | 27 import '../universe/call_structure.dart' show CallStructure; |
| 26 import '../universe/selector.dart' show Selector; | 28 import '../universe/selector.dart' show Selector; |
| 27 import '../universe/world_builder.dart' | 29 import '../universe/world_builder.dart' |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 // (3) foo$3$d(a, b, d) => foo$4$c$d(a, b, null, d); | 218 // (3) foo$3$d(a, b, d) => foo$4$c$d(a, b, null, d); |
| 217 // (4) No stub generated, call is direct. | 219 // (4) No stub generated, call is direct. |
| 218 // (5) No stub generated, call is direct. | 220 // (5) No stub generated, call is direct. |
| 219 // | 221 // |
| 220 // We need to pay attention if this stub is for a function that has been | 222 // We need to pay attention if this stub is for a function that has been |
| 221 // invoked from a subclass. Then we cannot just redirect, since that | 223 // invoked from a subclass. Then we cannot just redirect, since that |
| 222 // would invoke the methods of the subclass. We have to compile to: | 224 // would invoke the methods of the subclass. We have to compile to: |
| 223 // (1) foo$2(a, b) => MyClass.foo$4$c$d.call(this, a, b, null, null) | 225 // (1) foo$2(a, b) => MyClass.foo$4$c$d.call(this, a, b, null, null) |
| 224 // (2) foo$3$c(a, b, c) => MyClass.foo$4$c$d(this, a, b, c, null); | 226 // (2) foo$3$c(a, b, c) => MyClass.foo$4$c$d(this, a, b, c, null); |
| 225 // (3) foo$3$d(a, b, d) => MyClass.foo$4$c$d(this, a, b, null, d); | 227 // (3) foo$3$d(a, b, d) => MyClass.foo$4$c$d(this, a, b, null, d); |
| 226 List<ParameterStubMethod> generateParameterStubs(MethodElement member, | 228 List<ParameterStubMethod> generateParameterStubs(FunctionEntity member, |
| 227 {bool canTearOff: true}) { | 229 {bool canTearOff: true}) { |
| 228 if (member.enclosingElement.isClosure) { | 230 if (member.enclosingClass != null && member.enclosingClass.isClosure) { |
|
Siggi Cherem (dart-lang)
2017/05/30 22:10:20
I just noticed that we added `isClosure` to classE
Johnni Winther
2017/05/31 08:19:31
If anything, it belongs in the J-model.
| |
| 229 ClosureClassElement cls = member.enclosingElement; | 231 ClosureClassElement cls = member.enclosingClass; |
| 230 if (cls.supertype.element == _commonElements.boundClosureClass) { | 232 if (cls.supertype.element == _commonElements.boundClosureClass) { |
| 231 throw new SpannableAssertionFailure( | 233 throw new SpannableAssertionFailure( |
| 232 cls.methodElement, 'Bound closure1.'); | 234 cls.methodElement, 'Bound closure1.'); |
| 233 } | 235 } |
| 234 if (cls.methodElement.isInstanceMember) { | 236 if (cls.methodElement.isInstanceMember) { |
| 235 throw new SpannableAssertionFailure( | 237 throw new SpannableAssertionFailure( |
| 236 cls.methodElement, 'Bound closure2.'); | 238 cls.methodElement, 'Bound closure2.'); |
| 237 } | 239 } |
| 238 } | 240 } |
| 239 | 241 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 276 // For example, for the call-selector `call(x, y)` the renamed selector | 278 // For example, for the call-selector `call(x, y)` the renamed selector |
| 277 // for member `foo` would be `foo(x, y)`. | 279 // for member `foo` would be `foo(x, y)`. |
| 278 Set<Selector> renamedCallSelectors = | 280 Set<Selector> renamedCallSelectors = |
| 279 callSelectors.isEmpty ? emptySelectorSet : new Set<Selector>(); | 281 callSelectors.isEmpty ? emptySelectorSet : new Set<Selector>(); |
| 280 | 282 |
| 281 Set<Selector> untypedSelectors = new Set<Selector>(); | 283 Set<Selector> untypedSelectors = new Set<Selector>(); |
| 282 | 284 |
| 283 // Start with the callSelectors since they imply the generation of the | 285 // Start with the callSelectors since they imply the generation of the |
| 284 // non-call version. | 286 // non-call version. |
| 285 for (Selector selector in callSelectors.keys) { | 287 for (Selector selector in callSelectors.keys) { |
| 286 Selector renamedSelector = | 288 Selector renamedSelector = new Selector.call( |
| 287 new Selector.call(member.memberName, selector.callStructure); | 289 new Name(member.name, member.library), selector.callStructure); |
| 288 renamedCallSelectors.add(renamedSelector); | 290 renamedCallSelectors.add(renamedSelector); |
| 289 | 291 |
| 290 if (!renamedSelector.appliesUnnamed(member)) { | 292 if (!renamedSelector.appliesUnnamed(member)) { |
| 291 continue; | 293 continue; |
| 292 } | 294 } |
| 293 | 295 |
| 294 if (untypedSelectors.add(renamedSelector)) { | 296 if (untypedSelectors.add(renamedSelector)) { |
| 295 ParameterStubMethod stub = | 297 ParameterStubMethod stub = |
| 296 generateParameterStub(member, renamedSelector, selector); | 298 generateParameterStub(member, renamedSelector, selector); |
| 297 if (stub != null) { | 299 if (stub != null) { |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 315 generateParameterStub(member, selector, null); | 317 generateParameterStub(member, selector, null); |
| 316 if (stub != null) { | 318 if (stub != null) { |
| 317 stubs.add(stub); | 319 stubs.add(stub); |
| 318 } | 320 } |
| 319 } | 321 } |
| 320 } | 322 } |
| 321 | 323 |
| 322 return stubs; | 324 return stubs; |
| 323 } | 325 } |
| 324 } | 326 } |
| OLD | NEW |