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

Side by Side Diff: lib/compiler/implementation/tree/nodes.dart

Issue 10441044: Refactor common logic of SsaBuilder.visitSend. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 interface Visitor<R> { 5 interface Visitor<R> {
6 R visitBlock(Block node); 6 R visitBlock(Block node);
7 R visitBreakStatement(BreakStatement node); 7 R visitBreakStatement(BreakStatement node);
8 R visitCascade(Cascade node); 8 R visitCascade(Cascade node);
9 R visitCascadeReceiver(CascadeReceiver node); 9 R visitCascadeReceiver(CascadeReceiver node);
10 R visitCaseMatch(CaseMatch node); 10 R visitCaseMatch(CaseMatch node);
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 return argumentsNode.getEndToken(); 286 return argumentsNode.getEndToken();
287 } 287 }
288 if (selector !== null) return selector.getEndToken(); 288 if (selector !== null) return selector.getEndToken();
289 return receiver.getBeginToken(); 289 return receiver.getBeginToken();
290 } 290 }
291 291
292 Send copyWithReceiver(Node newReceiver) { 292 Send copyWithReceiver(Node newReceiver) {
293 assert(receiver === null); 293 assert(receiver === null);
294 return new Send(newReceiver, selector, argumentsNode); 294 return new Send(newReceiver, selector, argumentsNode);
295 } 295 }
296
297 analyse([
ahe 2012/05/29 10:24:00 It concerns that I don't see how this can avoid cr
Anton Muhin 2012/05/31 18:56:38 Done.
298 bool methodInterceptionEnabled,
299 TreeElements elements,
300 superRead(Send node),
301 superSend(Send node),
302 operatorSend(Send node),
303 getterSend(Send node),
304 closureSend(Send node),
305 dynamicSend(Send node),
306 foreignSend(Send node),
307 staticSend(Send node),
308 internalError(String reason)]) {
309 if (isSuperCall) {
310 if (isPropertyAccess) {
311 return superRead(this);
312 } else {
313 return superSend(this);
314 }
315 } else if (isOperator && methodInterceptionEnabled) {
316 return operatorSend(this);
317 } else if (isPropertyAccess) {
318 return getterSend(this);
319 } else if (Elements.isClosureSend(this, elements)) {
320 return closureSend(this);
321 } else {
322 Element element = elements[this];
323 if (element === null) {
324 // Example: f() with 'f' unbound.
325 // This can only happen inside an instance method.
326 return dynamicSend(this);
327 } else if (element.kind == ElementKind.CLASS) {
328 internalError("Cannot generate code for send");
329 } else if (element.isInstanceMember()) {
330 // Example: f() with 'f' bound to instance method.
331 return dynamicSend(this);
332 } else if (element.kind === ElementKind.FOREIGN) {
333 return foreignSend(this);
334 } else if (!element.isInstanceMember()) {
335 // Example: A.f() or f() with 'f' bound to a static function.
336 // Also includes new A() or new A.named() which is treated like a
337 // static call to a factory.
338 return staticSend(this);
339 } else {
340 internalError("Cannot generate code for send");
341 }
342 }
343 }
296 } 344 }
297 345
298 class Postfix extends NodeList { 346 class Postfix extends NodeList {
299 Postfix() : super(nodes: const EmptyLink<Node>()); 347 Postfix() : super(nodes: const EmptyLink<Node>());
300 Postfix.singleton(Node argument) : super.singleton(argument); 348 Postfix.singleton(Node argument) : super.singleton(argument);
301 } 349 }
302 350
303 class Prefix extends NodeList { 351 class Prefix extends NodeList {
304 Prefix() : super(nodes: const EmptyLink<Node>()); 352 Prefix() : super(nodes: const EmptyLink<Node>());
305 Prefix.singleton(Node argument) : super.singleton(argument); 353 Prefix.singleton(Node argument) : super.singleton(argument);
(...skipping 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after
1700 * argument). 1748 * argument).
1701 * 1749 *
1702 * TODO(ahe): This method is controversial, the team needs to discuss 1750 * TODO(ahe): This method is controversial, the team needs to discuss
1703 * if top-level methods are acceptable and what naming conventions to 1751 * if top-level methods are acceptable and what naming conventions to
1704 * use. 1752 * use.
1705 */ 1753 */
1706 initializerDo(Node node, f(Node node)) { 1754 initializerDo(Node node, f(Node node)) {
1707 SendSet send = node.asSendSet(); 1755 SendSet send = node.asSendSet();
1708 if (send !== null) return f(send.arguments.head); 1756 if (send !== null) return f(send.arguments.head);
1709 } 1757 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698