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

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

Issue 768553002: Add support for (unintercepted) method calls to the cps js emitter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/codegen/glue.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 compileConstant); 178 compileConstant);
179 return new js.Call(elementAccess, compiledArguments); 179 return new js.Call(elementAccess, compiledArguments);
180 } 180 }
181 181
182 @override 182 @override
183 js.Expression visitInvokeConstructor(tree_ir.InvokeConstructor node) { 183 js.Expression visitInvokeConstructor(tree_ir.InvokeConstructor node) {
184 if (node.constant != null) return giveup(node); 184 if (node.constant != null) return giveup(node);
185 return buildStaticInvoke(node.selector, node.target, node.arguments); 185 return buildStaticInvoke(node.selector, node.target, node.arguments);
186 } 186 }
187 187
188 void registerMethodInvoke(tree_ir.InvokeMethod node) {
189 Selector selector = node.selector;
190 // TODO(sigurdm): We should find a better place to register the call.
191 Selector call = new Selector.callClosureFrom(selector);
192 registry.registerDynamicInvocation(call);
193 registry.registerDynamicInvocation(selector);
194 }
195
188 @override 196 @override
189 js.Expression visitInvokeMethod(tree_ir.InvokeMethod node) { 197 js.Expression visitInvokeMethod(tree_ir.InvokeMethod node) {
190 return giveup(node); 198 // TODO(sigurdm): Handle intercepted invocations.
191 // TODO: implement visitInvokeMethod 199 if (glue.isIntercepted(node.selector)) giveup(node);
200 js.Expression receiver = visitExpression(node.receiver);
201
202 List<js.Expression> arguments = visitArguments(node.arguments);
203
204 String methodName = glue.invocationName(node.selector);
205 registerMethodInvoke(node);
206
207 return jsPropertyCall(receiver, methodName, arguments);
208 }
209
210 js.Call jsPropertyCall(js.Expression receiver,
floitsch 2014/11/27 13:20:12 Maybe move this to the js-builder? or as a named c
sigurdm 2014/11/27 14:31:18 Done.
211 String fieldName,
212 List<js.Expression> arguments) {
213 return new js.Call(new js.PropertyAccess.field(receiver, fieldName),
214 arguments);
192 } 215 }
193 216
194 @override 217 @override
195 js.Expression visitInvokeStatic(tree_ir.InvokeStatic node) { 218 js.Expression visitInvokeStatic(tree_ir.InvokeStatic node) {
196 return buildStaticInvoke(node.selector, node.target, node.arguments); 219 return buildStaticInvoke(node.selector, node.target, node.arguments);
197 } 220 }
198 221
199 @override 222 @override
200 js.Expression visitInvokeSuperMethod(tree_ir.InvokeSuperMethod node) { 223 js.Expression visitInvokeSuperMethod(tree_ir.InvokeSuperMethod node) {
201 return giveup(node); 224 return giveup(node);
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 accumulator.add( 398 accumulator.add(
376 buildWhile(new js.LiteralBool(true), node.body, node.label, node)); 399 buildWhile(new js.LiteralBool(true), node.body, node.label, node));
377 } 400 }
378 401
379 @override 402 @override
380 void visitReturn(tree_ir.Return node) { 403 void visitReturn(tree_ir.Return node) {
381 accumulator.add(new js.Return(visitExpression(node.value))); 404 accumulator.add(new js.Return(visitExpression(node.value)));
382 } 405 }
383 406
384 } 407 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/codegen/glue.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698