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

Side by Side Diff: pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart

Issue 787603003: Generative constructors in the new dart backend. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments, set element for constructors in frontend_ast_to_backend_ast, adjust status-file 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
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 tree_ir_nodes; 5 library tree_ir_nodes;
6 6
7 import '../constants/expressions.dart'; 7 import '../constants/expressions.dart';
8 import '../constants/values.dart' as values; 8 import '../constants/values.dart' as values;
9 import '../cps_ir/cps_ir_nodes.dart' as cps_ir; 9 import '../cps_ir/cps_ir_nodes.dart' as cps_ir;
10 import '../dart_types.dart' show DartType, GenericType; 10 import '../dart_types.dart' show DartType, GenericType;
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 506
507 /** 507 /**
508 * A return exit from the function. 508 * A return exit from the function.
509 * 509 *
510 * In contrast to the CPS-based IR, the return value is an arbitrary 510 * In contrast to the CPS-based IR, the return value is an arbitrary
511 * expression. 511 * expression.
512 */ 512 */
513 class Return extends Statement { 513 class Return extends Statement {
514 /// Should not be null. Use [Constant] with [NullConstantValue] for void 514 /// Should not be null. Use [Constant] with [NullConstantValue] for void
515 /// returns. 515 /// returns.
516 /// Even in constructors this holds true. Take special care when translating
517 /// back to dart, where `return null;` in a constructor is an error.
516 Expression value; 518 Expression value;
517 519
518 Statement get next => null; 520 Statement get next => null;
519 void set next(Statement s) => throw 'UNREACHABLE'; 521 void set next(Statement s) => throw 'UNREACHABLE';
520 522
521 Return(this.value); 523 Return(this.value);
522 524
523 accept(StatementVisitor visitor) => visitor.visitReturn(this); 525 accept(StatementVisitor visitor) => visitor.visitReturn(this);
524 accept1(StatementVisitor1 visitor, arg) => visitor.visitReturn(this, arg); 526 accept1(StatementVisitor1 visitor, arg) => visitor.visitReturn(this, arg);
525 } 527 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 FunctionDefinition(this.element, this.parameters, this.body, 600 FunctionDefinition(this.element, this.parameters, this.body,
599 this.localConstants, this.defaultParameterValues); 601 this.localConstants, this.defaultParameterValues);
600 602
601 /// Returns `true` if this function is abstract. 603 /// Returns `true` if this function is abstract.
602 /// 604 ///
603 /// If `true` [body] is `null` and [localConstants] is empty. 605 /// If `true` [body] is `null` and [localConstants] is empty.
604 bool get isAbstract => body == null; 606 bool get isAbstract => body == null;
605 applyPass(Pass pass) => pass.rewriteFunctionDefinition(this); 607 applyPass(Pass pass) => pass.rewriteFunctionDefinition(this);
606 } 608 }
607 609
610 abstract class Initializer implements Expression {}
611
612 class FieldInitializer extends Initializer {
613 final FieldElement element;
614 Statement body;
615 bool processed = false;
616
617 FieldInitializer(this.element, this.body);
618
619 accept(ExpressionVisitor visitor) => visitor.visitFieldInitializer(this);
620 accept1(ExpressionVisitor1 visitor, arg) {
621 return visitor.visitFieldInitializer(this, arg);
622 }
623 }
624
625 class SuperInitializer extends Initializer {
626 final ConstructorElement target;
627 final Selector selector;
628 final List<Statement> arguments;
629 bool processed = false;
630
631 SuperInitializer(this.target, this.selector, this.arguments);
632 accept(ExpressionVisitor visitor) => visitor.visitSuperInitializer(this);
633 accept1(ExpressionVisitor1 visitor, arg) {
634 return visitor.visitSuperInitializer(this, arg);
635 }
636 }
637
638 class ConstructorDefinition extends FunctionDefinition {
639 final List<Initializer> initializers;
640
641 ConstructorDefinition(ConstructorElement element,
642 List<Variable> parameters,
643 Statement body,
644 this.initializers,
645 List<ConstDeclaration> localConstants,
646 List<ConstantExpression> defaultParameterValues)
647 : super(element, parameters, body, localConstants,
648 defaultParameterValues);
649
650 applyPass(Pass pass) => pass.rewriteConstructorDefinition(this);
651 }
652
608 abstract class ExpressionVisitor<E> { 653 abstract class ExpressionVisitor<E> {
609 E visitExpression(Expression e) => e.accept(this); 654 E visitExpression(Expression e) => e.accept(this);
610 E visitVariable(Variable node); 655 E visitVariable(Variable node);
611 E visitInvokeStatic(InvokeStatic node); 656 E visitInvokeStatic(InvokeStatic node);
612 E visitInvokeMethod(InvokeMethod node); 657 E visitInvokeMethod(InvokeMethod node);
613 E visitInvokeSuperMethod(InvokeSuperMethod node); 658 E visitInvokeSuperMethod(InvokeSuperMethod node);
614 E visitInvokeConstructor(InvokeConstructor node); 659 E visitInvokeConstructor(InvokeConstructor node);
615 E visitConcatenateStrings(ConcatenateStrings node); 660 E visitConcatenateStrings(ConcatenateStrings node);
616 E visitConstant(Constant node); 661 E visitConstant(Constant node);
617 E visitThis(This node); 662 E visitThis(This node);
618 E visitReifyTypeVar(ReifyTypeVar node); 663 E visitReifyTypeVar(ReifyTypeVar node);
619 E visitConditional(Conditional node); 664 E visitConditional(Conditional node);
620 E visitLogicalOperator(LogicalOperator node); 665 E visitLogicalOperator(LogicalOperator node);
621 E visitNot(Not node); 666 E visitNot(Not node);
622 E visitLiteralList(LiteralList node); 667 E visitLiteralList(LiteralList node);
623 E visitLiteralMap(LiteralMap node); 668 E visitLiteralMap(LiteralMap node);
624 E visitTypeOperator(TypeOperator node); 669 E visitTypeOperator(TypeOperator node);
625 E visitFunctionExpression(FunctionExpression node); 670 E visitFunctionExpression(FunctionExpression node);
671 E visitFieldInitializer(FieldInitializer node);
672 E visitSuperInitializer(SuperInitializer node);
626 } 673 }
627 674
628 abstract class ExpressionVisitor1<E, A> { 675 abstract class ExpressionVisitor1<E, A> {
629 E visitExpression(Expression e, A arg) => e.accept1(this, arg); 676 E visitExpression(Expression e, A arg) => e.accept1(this, arg);
630 E visitVariable(Variable node, A arg); 677 E visitVariable(Variable node, A arg);
631 E visitInvokeStatic(InvokeStatic node, A arg); 678 E visitInvokeStatic(InvokeStatic node, A arg);
632 E visitInvokeMethod(InvokeMethod node, A arg); 679 E visitInvokeMethod(InvokeMethod node, A arg);
633 E visitInvokeSuperMethod(InvokeSuperMethod node, A arg); 680 E visitInvokeSuperMethod(InvokeSuperMethod node, A arg);
634 E visitInvokeConstructor(InvokeConstructor node, A arg); 681 E visitInvokeConstructor(InvokeConstructor node, A arg);
635 E visitConcatenateStrings(ConcatenateStrings node, A arg); 682 E visitConcatenateStrings(ConcatenateStrings node, A arg);
636 E visitConstant(Constant node, A arg); 683 E visitConstant(Constant node, A arg);
637 E visitThis(This node, A arg); 684 E visitThis(This node, A arg);
638 E visitReifyTypeVar(ReifyTypeVar node, A arg); 685 E visitReifyTypeVar(ReifyTypeVar node, A arg);
639 E visitConditional(Conditional node, A arg); 686 E visitConditional(Conditional node, A arg);
640 E visitLogicalOperator(LogicalOperator node, A arg); 687 E visitLogicalOperator(LogicalOperator node, A arg);
641 E visitNot(Not node, A arg); 688 E visitNot(Not node, A arg);
642 E visitLiteralList(LiteralList node, A arg); 689 E visitLiteralList(LiteralList node, A arg);
643 E visitLiteralMap(LiteralMap node, A arg); 690 E visitLiteralMap(LiteralMap node, A arg);
644 E visitTypeOperator(TypeOperator node, A arg); 691 E visitTypeOperator(TypeOperator node, A arg);
645 E visitFunctionExpression(FunctionExpression node, A arg); 692 E visitFunctionExpression(FunctionExpression node, A arg);
693 E visitFieldInitializer(FieldInitializer node, A arg);
694 E visitSuperInitializer(SuperInitializer node, A arg);
646 } 695 }
647 696
648 abstract class StatementVisitor<S> { 697 abstract class StatementVisitor<S> {
649 S visitStatement(Statement s) => s.accept(this); 698 S visitStatement(Statement s) => s.accept(this);
650 S visitLabeledStatement(LabeledStatement node); 699 S visitLabeledStatement(LabeledStatement node);
651 S visitAssign(Assign node); 700 S visitAssign(Assign node);
652 S visitReturn(Return node); 701 S visitReturn(Return node);
653 S visitBreak(Break node); 702 S visitBreak(Break node);
654 S visitContinue(Continue node); 703 S visitContinue(Continue node);
655 S visitIf(If node); 704 S visitIf(If node);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 839
791 visitFunctionDeclaration(FunctionDeclaration node) { 840 visitFunctionDeclaration(FunctionDeclaration node) {
792 visitFunctionDefinition(node.definition); 841 visitFunctionDefinition(node.definition);
793 visitStatement(node.next); 842 visitStatement(node.next);
794 } 843 }
795 844
796 visitExpressionStatement(ExpressionStatement node) { 845 visitExpressionStatement(ExpressionStatement node) {
797 visitExpression(node.expression); 846 visitExpression(node.expression);
798 visitStatement(node.next); 847 visitStatement(node.next);
799 } 848 }
849
850 visitFieldInitializer(FieldInitializer node) {
851 visitStatement(node.body);
852 }
853
854 visitSuperInitializer(SuperInitializer node) {
855 node.arguments.forEach(visitStatement);
856 }
800 } 857 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart ('k') | pkg/compiler/lib/src/tree_ir/tree_ir_tracer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698