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

Side by Side Diff: lib/compiler/implementation/ssa/builder.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, 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 | 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 class Interceptors { 5 class Interceptors {
6 Compiler compiler; 6 Compiler compiler;
7 Interceptors(Compiler this.compiler); 7 Interceptors(Compiler this.compiler);
8 8
9 SourceString mapOperatorToMethodName(Operator op) { 9 SourceString mapOperatorToMethodName(Operator op) {
10 String name = op.source.stringValue; 10 String name = op.source.stringValue;
(...skipping 2355 matching lines...) Expand 10 before | Expand all | Expand 10 after
2366 target = new HInvokeStatic(Selector.GETTER, inputs); 2366 target = new HInvokeStatic(Selector.GETTER, inputs);
2367 add(target); 2367 add(target);
2368 inputs = <HInstruction>[target]; 2368 inputs = <HInstruction>[target];
2369 } 2369 }
2370 addDynamicSendArgumentsToList(node, inputs); 2370 addDynamicSendArgumentsToList(node, inputs);
2371 push(new HInvokeClosure(selector, inputs)); 2371 push(new HInvokeClosure(selector, inputs));
2372 } 2372 }
2373 } 2373 }
2374 2374
2375 visitSend(Send node) { 2375 visitSend(Send node) {
2376 if (node.isSuperCall) { 2376 node.analyse(
2377 if (node.isPropertyAccess) { 2377 methodInterceptionEnabled: this.methodInterceptionEnabled,
2378 compiler.unimplemented('super property read', node: node); 2378 elements: this.elements,
2379 } 2379 superRead: (Send node) {
2380 visitSuperSend(node); 2380 compiler.unimplemented('super property read', node: node);
2381 } else if (node.isOperator && methodInterceptionEnabled) { 2381 },
2382 visitOperatorSend(node); 2382 superSend: visitSuperSend,
2383 } else if (node.isPropertyAccess) { 2383 operatorSend: visitOperatorSend,
2384 generateGetter(node, elements[node]); 2384 getterSend: (Send node) {
2385 } else if (Elements.isClosureSend(node, elements)) { 2385 generateGetter(node, elements[node]);
2386 visitClosureSend(node); 2386 },
2387 } else { 2387 closureSend: visitClosureSend,
2388 Element element = elements[node]; 2388 dynamicSend: visitDynamicSend,
2389 if (element === null) { 2389 foreignSend: handleForeignSend,
2390 // Example: f() with 'f' unbound. 2390 staticSend: visitStaticSend,
2391 // This can only happen inside an instance method. 2391 internalError: (String reason) {
2392 visitDynamicSend(node); 2392 compiler.internalError(reason, node: node);
2393 } else if (element.kind == ElementKind.CLASS) { 2393 }
2394 compiler.internalError("Cannot generate code for send", node: node); 2394 );
2395 } else if (element.isInstanceMember()) {
2396 // Example: f() with 'f' bound to instance method.
2397 visitDynamicSend(node);
2398 } else if (element.kind === ElementKind.FOREIGN) {
2399 handleForeignSend(node);
2400 } else if (!element.isInstanceMember()) {
2401 // Example: A.f() or f() with 'f' bound to a static function.
2402 // Also includes new A() or new A.named() which is treated like a
2403 // static call to a factory.
2404 visitStaticSend(node);
2405 } else {
2406 compiler.internalError("Cannot generate code for send", node: node);
2407 }
2408 }
2409 } 2395 }
2410 2396
2411 // TODO(karlklose): share with resolver. 2397 // TODO(karlklose): share with resolver.
2412 TypeAnnotation getTypeAnnotationFromSend(Send send) { 2398 TypeAnnotation getTypeAnnotationFromSend(Send send) {
2413 if (send.selector is TypeAnnotation) { 2399 if (send.selector is TypeAnnotation) {
2414 return send.selector; 2400 return send.selector;
2415 } else if (send.selector is Send) { 2401 } else if (send.selector is Send) {
2416 Send selector = send.selector; 2402 Send selector = send.selector;
2417 if (selector.receiver is TypeAnnotation) { 2403 if (selector.receiver is TypeAnnotation) {
2418 return selector.receiver; 2404 return selector.receiver;
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after
3366 <HInstruction>[target, input], 3352 <HInstruction>[target, input],
3367 HType.STRING)); 3353 HType.STRING));
3368 return builder.pop(); 3354 return builder.pop();
3369 } 3355 }
3370 3356
3371 HInstruction result(Node node) { 3357 HInstruction result(Node node) {
3372 flushLiterals(node); 3358 flushLiterals(node);
3373 return prefix; 3359 return prefix;
3374 } 3360 }
3375 } 3361 }
OLDNEW
« no previous file with comments | « no previous file | lib/compiler/implementation/tree/nodes.dart » ('j') | lib/compiler/implementation/tree/nodes.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698