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

Side by Side Diff: pkg/compiler/lib/src/js_backend/codegen/codegen.dart

Issue 861713002: Handle super-method invocations in CPS->JS backend. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 code_generator; 5 library code_generator;
6 6
7 import 'glue.dart'; 7 import 'glue.dart';
8 8
9 import '../../tree_ir/tree_ir_nodes.dart' as tree_ir; 9 import '../../tree_ir/tree_ir_nodes.dart' as tree_ir;
10 import '../../js/js.dart' as js; 10 import '../../js/js.dart' as js;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 // TODO: implement visitFunctionExpression 162 // TODO: implement visitFunctionExpression
163 } 163 }
164 164
165 js.Expression compileConstant(ParameterElement parameter) { 165 js.Expression compileConstant(ParameterElement parameter) {
166 return buildConstant(glue.getConstantForVariable(parameter).value); 166 return buildConstant(glue.getConstantForVariable(parameter).value);
167 } 167 }
168 168
169 js.Expression buildStaticInvoke(Selector selector, 169 js.Expression buildStaticInvoke(Selector selector,
170 Element target, 170 Element target,
171 List<js.Expression> arguments) { 171 List<js.Expression> arguments) {
172 registry.registerStaticInvocation(target.declaration); 172 registry.registerStaticInvocation(target);
sigurdm 2015/01/20 10:54:25 This should still be declaration.
asgerf 2015/01/20 13:07:50 Done.
173 js.Expression elementAccess = glue.staticFunctionAccess(target); 173 js.Expression elementAccess = glue.staticFunctionAccess(target);
174 List<js.Expression> compiledArguments = 174 List<js.Expression> compiledArguments =
175 selector.makeArgumentsList(target.implementation, 175 selector.makeArgumentsList(target.implementation,
176 arguments, 176 arguments,
177 compileConstant); 177 compileConstant);
178 return new js.Call(elementAccess, compiledArguments); 178 return new js.Call(elementAccess, compiledArguments);
179 } 179 }
180 180
181 @override 181 @override
182 js.Expression visitInvokeConstructor(tree_ir.InvokeConstructor node) { 182 js.Expression visitInvokeConstructor(tree_ir.InvokeConstructor node) {
183 if (node.constant != null) return giveup(node); 183 if (node.constant != null) return giveup(node);
184 registry.registerInstantiatedClass(node.target.enclosingClass);
184 return buildStaticInvoke(node.selector, 185 return buildStaticInvoke(node.selector,
185 node.target, 186 node.target,
186 visitArguments(node.arguments)); 187 visitArguments(node.arguments));
187 } 188 }
188 189
189 void registerMethodInvoke(tree_ir.InvokeMethod node) { 190 void registerMethodInvoke(tree_ir.InvokeMethod node) {
190 Selector selector = node.selector; 191 Selector selector = node.selector;
191 // TODO(sigurdm): We should find a better place to register the call. 192 // TODO(sigurdm): We should find a better place to register the call.
192 Selector call = new Selector.callClosureFrom(selector); 193 Selector call = new Selector.callClosureFrom(selector);
193 registry.registerDynamicInvocation(call); 194 registry.registerDynamicInvocation(call);
(...skipping 12 matching lines...) Expand all
206 js.Expression visitInvokeStatic(tree_ir.InvokeStatic node) { 207 js.Expression visitInvokeStatic(tree_ir.InvokeStatic node) {
207 if (node.target is! FunctionElement) { 208 if (node.target is! FunctionElement) {
208 giveup(node, 'static getters and setters are not supported.'); 209 giveup(node, 'static getters and setters are not supported.');
209 } 210 }
210 return buildStaticInvoke(node.selector, 211 return buildStaticInvoke(node.selector,
211 node.target, 212 node.target,
212 visitArguments(node.arguments)); 213 visitArguments(node.arguments));
213 } 214 }
214 215
215 @override 216 @override
216 js.Expression visitInvokeSuperMethod(tree_ir.InvokeSuperMethod node) { 217 js.Expression visitInvokeMethodDirectly(tree_ir.InvokeMethodDirectly node) {
217 return giveup(node); 218 registry.registerDirectInvocation(node.target);
sigurdm 2015/01/20 10:54:25 Register the declaration
asgerf 2015/01/20 13:07:50 Done.
218 // TODO: implement visitInvokeSuperMethod 219 return js.js('#.#.call(#, #)',
220 [glue.prototypeAccess(node.target.enclosingClass),
221 glue.invocationName(node.selector),
222 visitExpression(node.receiver),
223 visitArguments(node.arguments)]);
219 } 224 }
220 225
221 @override 226 @override
222 js.Expression visitLiteralList(tree_ir.LiteralList node) { 227 js.Expression visitLiteralList(tree_ir.LiteralList node) {
223 registry.registerInstantiatedClass(glue.listClass); 228 registry.registerInstantiatedClass(glue.listClass);
224 int length = node.values.length; 229 int length = node.values.length;
225 List<js.Expression> entries = node.values.map(visitExpression).toList(); 230 List<js.Expression> entries = node.values.map(visitExpression).toList();
226 return new js.ArrayInitializer(entries); 231 return new js.ArrayInitializer(entries);
227 } 232 }
228 233
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 void visitSetField(tree_ir.SetField node) { 452 void visitSetField(tree_ir.SetField node) {
448 js.PropertyAccess field = 453 js.PropertyAccess field =
449 new js.PropertyAccess.field( 454 new js.PropertyAccess.field(
450 visitExpression(node.object), 455 visitExpression(node.object),
451 glue.instanceFieldPropertyName(node.field)); 456 glue.instanceFieldPropertyName(node.field));
452 js.Assignment asn = new js.Assignment(field, visitExpression(node.value)); 457 js.Assignment asn = new js.Assignment(field, visitExpression(node.value));
453 accumulator.add(new js.ExpressionStatement(asn)); 458 accumulator.add(new js.ExpressionStatement(asn));
454 visitStatement(node.next); 459 visitStatement(node.next);
455 } 460 }
456 } 461 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698