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

Side by Side Diff: frog/leg/ssa/builder.dart

Issue 9391004: Implement cycle-checking and code generation for redirecting constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments and add a test. Created 8 years, 10 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 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 * Run through the initializers and inline all field initializers. Returns the 540 * Run through the initializers and inline all field initializers. Returns the
541 * next constructor to analyze. 541 * next constructor to analyze.
542 */ 542 */
543 FunctionElement analyzeInitializers(Link<Node> initializers) { 543 FunctionElement analyzeInitializers(Link<Node> initializers) {
544 FunctionElement nextConstructor; 544 FunctionElement nextConstructor;
545 for (Link<Node> link = initializers; !link.isEmpty(); link = link.tail) { 545 for (Link<Node> link = initializers; !link.isEmpty(); link = link.tail) {
546 assert(link.head is Send); 546 assert(link.head is Send);
547 if (link.head is !SendSet) { 547 if (link.head is !SendSet) {
548 // A super initializer or constructor redirection. 548 // A super initializer or constructor redirection.
549 Send call = link.head; 549 Send call = link.head;
550 if (Initializers.isSuperConstructorCall(call)) { 550 assert(Initializers.isSuperConstructorCall(call) ||
551 assert(nextConstructor === null); 551 Initializers.isConstructorRedirect(call));
552 nextConstructor = elements[call]; 552 assert(nextConstructor === null);
553 // Visit arguments and map the corresponding parameter value to 553 nextConstructor = elements[call];
554 // the resulting HInstruction value. 554 // Visit arguments and map the corresponding parameter value to
555 forEachArgument(call, nextConstructor, (parameter, node) { 555 // the resulting HInstruction value.
556 visit(node); 556 forEachArgument(call, nextConstructor, (parameter, node) {
557 HInstruction value = pop(); 557 visit(node);
558 localsHandler.updateLocal(parameter, value); 558 HInstruction value = pop();
559 }); 559 localsHandler.updateLocal(parameter, value);
560 } else { 560 });
561 compiler.unimplemented('SsaBuilder.buildFactory redirect');
562 }
563 } else { 561 } else {
564 // A field initializer. 562 // A field initializer.
565 SendSet init = link.head; 563 SendSet init = link.head;
566 Link<Node> arguments = init.arguments; 564 Link<Node> arguments = init.arguments;
567 assert(!arguments.isEmpty() && arguments.tail.isEmpty()); 565 assert(!arguments.isEmpty() && arguments.tail.isEmpty());
568 visit(arguments.head); 566 visit(arguments.head);
569 // We treat the init field-elements like locals. In the context of 567 // We treat the init field-elements like locals. In the context of
570 // the factory this is correct, and simplifies dealing with 568 // the factory this is correct, and simplifies dealing with
571 // parameter-initializers (like A(this.x)). 569 // parameter-initializers (like A(this.x)).
572 localsHandler.updateLocal(elements[init], pop()); 570 localsHandler.updateLocal(elements[init], pop());
(...skipping 1380 matching lines...) Expand 10 before | Expand all | Expand 10 after
1953 } 1951 }
1954 1952
1955 visitCatchBlock(CatchBlock node) { 1953 visitCatchBlock(CatchBlock node) {
1956 visit(node.block); 1954 visit(node.block);
1957 } 1955 }
1958 1956
1959 visitTypedef(Typedef node) { 1957 visitTypedef(Typedef node) {
1960 compiler.unimplemented('SsaBuilder.visitTypedef', node: node); 1958 compiler.unimplemented('SsaBuilder.visitTypedef', node: node);
1961 } 1959 }
1962 } 1960 }
OLDNEW
« frog/leg/resolver.dart ('K') | « frog/leg/resolver.dart ('k') | frog/leg/tree/nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698