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

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

Issue 1198293002: dart2js: Use an abstract Name class for names in the generated JavaScript ast. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix new emitter. Created 5 years, 6 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 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 118
119 var body; // List or jsAst.Statement. 119 var body; // List or jsAst.Statement.
120 if (member.hasFixedBackendName) { 120 if (member.hasFixedBackendName) {
121 body = emitterTask.nativeEmitter.generateParameterStubStatements( 121 body = emitterTask.nativeEmitter.generateParameterStubStatements(
122 member, isInterceptedMethod, namer.invocationName(selector), 122 member, isInterceptedMethod, namer.invocationName(selector),
123 parametersBuffer, argumentsBuffer, 123 parametersBuffer, argumentsBuffer,
124 indexOfLastOptionalArgumentInParameters); 124 indexOfLastOptionalArgumentInParameters);
125 } else if (member.isInstanceMember) { 125 } else if (member.isInstanceMember) {
126 if (needsSuperGetter(member)) { 126 if (needsSuperGetter(member)) {
127 ClassElement superClass = member.enclosingClass; 127 ClassElement superClass = member.enclosingClass;
128 String methodName = namer.instanceMethodName(member); 128 jsAst.Name methodName = namer.instanceMethodName(member);
129 // When redirecting, we must ensure that we don't end up in a subclass. 129 // When redirecting, we must ensure that we don't end up in a subclass.
130 // We thus can't just invoke `this.foo$1.call(filledInArguments)`. 130 // We thus can't just invoke `this.foo$1.call(filledInArguments)`.
131 // Instead we need to call the statically resolved target. 131 // Instead we need to call the statically resolved target.
132 // `<class>.prototype.bar$1.call(this, argument0, ...)`. 132 // `<class>.prototype.bar$1.call(this, argument0, ...)`.
133 body = js.statement( 133 body = js.statement(
134 'return #.#.call(this, #);', 134 'return #.#.call(this, #);',
135 [backend.emitter.prototypeAccess(superClass, 135 [backend.emitter.prototypeAccess(superClass,
136 hasBeenInstantiated: true), 136 hasBeenInstantiated: true),
137 methodName, 137 methodName,
138 argumentsBuffer]); 138 argumentsBuffer]);
139 } else { 139 } else {
140 body = js.statement( 140 body = js.statement(
141 'return this.#(#);', 141 'return this.#(#);',
142 [namer.instanceMethodName(member), argumentsBuffer]); 142 [namer.instanceMethodName(member), argumentsBuffer]);
143 } 143 }
144 } else { 144 } else {
145 body = js.statement('return #(#)', 145 body = js.statement('return #(#)',
146 [emitter.staticFunctionAccess(member), argumentsBuffer]); 146 [emitter.staticFunctionAccess(member), argumentsBuffer]);
147 } 147 }
148 148
149 jsAst.Fun function = js('function(#) { #; }', [parametersBuffer, body]); 149 jsAst.Fun function = js('function(#) { #; }', [parametersBuffer, body]);
150 150
151 String name = namer.invocationName(selector); 151 jsAst.Name name = namer.invocationName(selector);
152 String callName = 152 jsAst.Name callName =
153 (callSelector != null) ? namer.invocationName(callSelector) : null; 153 (callSelector != null) ? namer.invocationName(callSelector) : null;
154 return new ParameterStubMethod(name, callName, function); 154 return new ParameterStubMethod(name, callName, function);
155 } 155 }
156 156
157 // We fill the lists depending on possible/invoked selectors. For example, 157 // We fill the lists depending on possible/invoked selectors. For example,
158 // take method foo: 158 // take method foo:
159 // foo(a, b, {c, d}); 159 // foo(a, b, {c, d});
160 // 160 //
161 // We may have multiple ways of calling foo: 161 // We may have multiple ways of calling foo:
162 // (1) foo(1, 2); 162 // (1) foo(1, 2);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 generateParameterStub(member, selector, null); 274 generateParameterStub(member, selector, null);
275 if (stub != null) { 275 if (stub != null) {
276 stubs.add(stub); 276 stubs.add(stub);
277 } 277 }
278 } 278 }
279 } 279 }
280 280
281 return stubs; 281 return stubs;
282 } 282 }
283 } 283 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698