Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(583)

Side by Side Diff: pkg/compiler/lib/src/js_emitter/parameter_stub_generator.dart

Issue 2642063003: Use entities in class_stub_generator. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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' 7 import '../closure.dart' show ClosureClassElement;
8 show ClosureClassElement;
9 import '../common.dart'; 8 import '../common.dart';
10 import '../compiler.dart' show Compiler; 9 import '../compiler.dart' show Compiler;
11 import '../constants/values.dart'; 10 import '../constants/values.dart';
12 import '../elements/elements.dart' 11 import '../elements/elements.dart'
13 show 12 show
14 ClassElement, 13 ClassElement,
15 FunctionElement, 14 FunctionElement,
16 FunctionSignature, 15 FunctionSignature,
17 MethodElement, 16 MethodElement,
18 ParameterElement; 17 ParameterElement;
19 import '../js/js.dart' as jsAst; 18 import '../js/js.dart' as jsAst;
20 import '../js/js.dart' show js; 19 import '../js/js.dart' show js;
21 import '../js_backend/js_backend.dart' 20 import '../js_backend/js_backend.dart'
22 show 21 show JavaScriptBackend, JavaScriptConstantCompiler, Namer;
23 JavaScriptBackend,
24 JavaScriptConstantCompiler,
25 Namer;
26 import '../universe/call_structure.dart' show CallStructure; 22 import '../universe/call_structure.dart' show CallStructure;
27 import '../universe/selector.dart' show Selector; 23 import '../universe/selector.dart' show Selector;
28 import '../universe/world_builder.dart' 24 import '../universe/world_builder.dart' show SelectorConstraints;
29 show SelectorConstraints;
30 import '../world.dart' show ClosedWorld; 25 import '../world.dart' show ClosedWorld;
31 26
32 import 'model.dart'; 27 import 'model.dart';
33 28
34 import 'code_emitter_task.dart' show CodeEmitterTask, Emitter; 29 import 'code_emitter_task.dart' show CodeEmitterTask, Emitter;
35 30
36 class ParameterStubGenerator { 31 class ParameterStubGenerator {
37 static final Set<Selector> emptySelectorSet = new Set<Selector>(); 32 static final Set<Selector> emptySelectorSet = new Set<Selector>();
38 33
39 final Namer namer; 34 final Namer namer;
(...skipping 21 matching lines...) Expand all
61 * 56 *
62 * Returns null if no stub is needed. 57 * Returns null if no stub is needed.
63 * 58 *
64 * Members may be invoked in two ways: directly, or through a closure. In the 59 * Members may be invoked in two ways: directly, or through a closure. In the
65 * latter case the caller invokes the closure's `call` method. This method 60 * latter case the caller invokes the closure's `call` method. This method
66 * accepts two selectors. The returned stub method has the corresponding 61 * accepts two selectors. The returned stub method has the corresponding
67 * name [ParameterStubMethod.name] and [ParameterStubMethod.callName] set if 62 * name [ParameterStubMethod.name] and [ParameterStubMethod.callName] set if
68 * the input selector is non-null (and the member needs a stub). 63 * the input selector is non-null (and the member needs a stub).
69 */ 64 */
70 ParameterStubMethod generateParameterStub( 65 ParameterStubMethod generateParameterStub(
71 FunctionElement member, Selector selector, Selector callSelector) { 66 MethodElement member, Selector selector, Selector callSelector) {
72 CallStructure callStructure = selector.callStructure; 67 CallStructure callStructure = selector.callStructure;
73 FunctionSignature parameters = member.functionSignature; 68 FunctionSignature parameters = member.functionSignature;
74 int positionalArgumentCount = callStructure.positionalArgumentCount; 69 int positionalArgumentCount = callStructure.positionalArgumentCount;
75 if (positionalArgumentCount == parameters.parameterCount) { 70 if (positionalArgumentCount == parameters.parameterCount) {
76 assert(callStructure.isUnnamed); 71 assert(callStructure.isUnnamed);
77 return null; 72 return null;
78 } 73 }
79 if (parameters.optionalParametersAreNamed && 74 if (parameters.optionalParametersAreNamed &&
80 callStructure.namedArgumentCount == parameters.optionalParameterCount) { 75 callStructure.namedArgumentCount == parameters.optionalParameterCount) {
81 // If the selector has the same number of named arguments as the element, 76 // If the selector has the same number of named arguments as the element,
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 generateParameterStub(member, selector, null); 302 generateParameterStub(member, selector, null);
308 if (stub != null) { 303 if (stub != null) {
309 stubs.add(stub); 304 stubs.add(stub);
310 } 305 }
311 } 306 }
312 } 307 }
313 308
314 return stubs; 309 return stubs;
315 } 310 }
316 } 311 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698