| 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 part of dart2js.js_emitter; | 5 part of dart2js.js_emitter; |
| 6 | 6 |
| 7 class ParameterStubGenerator { | 7 class ParameterStubGenerator { |
| 8 static final Set<Selector> emptySelectorSet = new Set<Selector>(); | 8 static final Set<Selector> emptySelectorSet = new Set<Selector>(); |
| 9 | 9 |
| 10 final Namer namer; | 10 final Namer namer; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 compiler.internalError(cls.methodElement, 'Bound closure1.'); | 193 compiler.internalError(cls.methodElement, 'Bound closure1.'); |
| 194 } | 194 } |
| 195 if (cls.methodElement.isInstanceMember) { | 195 if (cls.methodElement.isInstanceMember) { |
| 196 compiler.internalError(cls.methodElement, 'Bound closure2.'); | 196 compiler.internalError(cls.methodElement, 'Bound closure2.'); |
| 197 } | 197 } |
| 198 } | 198 } |
| 199 | 199 |
| 200 // The set of selectors that apply to `member`. For example, for | 200 // The set of selectors that apply to `member`. For example, for |
| 201 // a member `foo(x, [y])` the following selectors may apply: | 201 // a member `foo(x, [y])` the following selectors may apply: |
| 202 // `foo(x)`, and `foo(x, y)`. | 202 // `foo(x)`, and `foo(x, y)`. |
| 203 Map<Selector, TypeMaskSet> selectors; | 203 Map<Selector, ReceiverMaskSet> selectors; |
| 204 // The set of selectors that apply to `member` if it's name was `call`. | 204 // The set of selectors that apply to `member` if it's name was `call`. |
| 205 // This happens when a member is torn off. In that case calls to the | 205 // This happens when a member is torn off. In that case calls to the |
| 206 // function use the name `call`, and we must be able to handle every | 206 // function use the name `call`, and we must be able to handle every |
| 207 // `call` invocation that matches the signature. For example, for | 207 // `call` invocation that matches the signature. For example, for |
| 208 // a member `foo(x, [y])` the following selectors would be possible | 208 // a member `foo(x, [y])` the following selectors would be possible |
| 209 // call-selectors: `call(x)`, and `call(x, y)`. | 209 // call-selectors: `call(x)`, and `call(x, y)`. |
| 210 Map<Selector, TypeMaskSet> callSelectors; | 210 Map<Selector, ReceiverMaskSet> callSelectors; |
| 211 | 211 |
| 212 // Only instance members (not static methods) need stubs. | 212 // Only instance members (not static methods) need stubs. |
| 213 if (member.isInstanceMember) { | 213 if (member.isInstanceMember) { |
| 214 selectors = compiler.codegenWorld.invocationsByName(member.name); | 214 selectors = compiler.codegenWorld.invocationsByName(member.name); |
| 215 } | 215 } |
| 216 | 216 |
| 217 if (canTearOff) { | 217 if (canTearOff) { |
| 218 String call = namer.closureInvocationSelectorName; | 218 String call = namer.closureInvocationSelectorName; |
| 219 callSelectors = compiler.codegenWorld.invocationsByName(call); | 219 callSelectors = compiler.codegenWorld.invocationsByName(call); |
| 220 } | 220 } |
| 221 | 221 |
| 222 assert(emptySelectorSet.isEmpty); | 222 assert(emptySelectorSet.isEmpty); |
| 223 if (selectors == null) selectors = const <Selector, TypeMaskSet>{}; | 223 if (selectors == null) selectors = const <Selector, ReceiverMaskSet>{}; |
| 224 if (callSelectors == null) callSelectors = const <Selector, TypeMaskSet>{}; | 224 if (callSelectors == null) callSelectors = |
| 225 const <Selector, ReceiverMaskSet>{}; |
| 225 | 226 |
| 226 List<ParameterStubMethod> stubs = <ParameterStubMethod>[]; | 227 List<ParameterStubMethod> stubs = <ParameterStubMethod>[]; |
| 227 | 228 |
| 228 if (selectors.isEmpty && callSelectors.isEmpty) { | 229 if (selectors.isEmpty && callSelectors.isEmpty) { |
| 229 return stubs; | 230 return stubs; |
| 230 } | 231 } |
| 231 | 232 |
| 232 // For every call-selector the corresponding selector with the name of the | 233 // For every call-selector the corresponding selector with the name of the |
| 233 // member. | 234 // member. |
| 234 // | 235 // |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 generateParameterStub(member, selector, null); | 275 generateParameterStub(member, selector, null); |
| 275 if (stub != null) { | 276 if (stub != null) { |
| 276 stubs.add(stub); | 277 stubs.add(stub); |
| 277 } | 278 } |
| 278 } | 279 } |
| 279 } | 280 } |
| 280 | 281 |
| 281 return stubs; | 282 return stubs; |
| 282 } | 283 } |
| 283 } | 284 } |
| OLD | NEW |