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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart

Issue 1011383003: Use an explicit 'this' parameter instead of 'This' nodes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // IrNodes are kept in a separate library to have precise control over their 5 // IrNodes are kept in a separate library to have precise control over their
6 // dependencies on other parts of the system. 6 // dependencies on other parts of the system.
7 library dart2js.ir_nodes; 7 library dart2js.ir_nodes;
8 8
9 import '../constants/expressions.dart'; 9 import '../constants/expressions.dart';
10 import '../constants/values.dart' as values show ConstantValue; 10 import '../constants/values.dart' as values show ConstantValue;
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 635
636 values.ConstantValue get value => expression.value; 636 values.ConstantValue get value => expression.value;
637 637
638 accept(Visitor visitor) => visitor.visitConstant(this); 638 accept(Visitor visitor) => visitor.visitConstant(this);
639 } 639 }
640 640
641 class This extends Primitive { 641 class This extends Primitive {
642 This(); 642 This();
643 643
644 accept(Visitor visitor) => visitor.visitThis(this); 644 accept(Visitor visitor) => visitor.visitThis(this);
645 } 645 }
asgerf 2015/03/18 13:28:25 If the This class is not used anymore, then remove
sra1 2015/03/19 10:42:51 Done.
646 646
647 /// Reify the given type variable as a [Type]. 647 /// Reify the given type variable as a [Type].
648 /// This depends on the current binding of 'this'. 648 /// This depends on the current binding of 'this'.
649 class ReifyTypeVar extends Primitive implements DartSpecificNode { 649 class ReifyTypeVar extends Primitive implements DartSpecificNode {
650 final TypeVariableElement typeVariable; 650 final TypeVariableElement typeVariable;
651 651
652 ReifyTypeVar(this.typeVariable); 652 ReifyTypeVar(this.typeVariable);
653 653
654 values.ConstantValue get constant => null; 654 values.ConstantValue get constant => null;
655 655
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 super.hint = hint; 699 super.hint = hint;
700 } 700 }
701 701
702 // In addition to a parent pointer to the containing Continuation or 702 // In addition to a parent pointer to the containing Continuation or
703 // FunctionDefinition, parameters have an index into the list of parameters 703 // FunctionDefinition, parameters have an index into the list of parameters
704 // bound by the parent. This gives constant-time access to the continuation 704 // bound by the parent. This gives constant-time access to the continuation
705 // from the parent. 705 // from the parent.
706 int parentIndex; 706 int parentIndex;
707 707
708 accept(Visitor visitor) => visitor.visitParameter(this); 708 accept(Visitor visitor) => visitor.visitParameter(this);
709
710 String toString() => 'Parameter(${hint == null ? null : hint.name})';
709 } 711 }
710 712
711 /// Continuations are normally bound by 'let cont'. A continuation with one 713 /// Continuations are normally bound by 'let cont'. A continuation with one
712 /// parameter and no body is used to represent a function's return continuation. 714 /// parameter and no body is used to represent a function's return continuation.
713 /// The return continuation is bound by the Function, not by 'let cont'. 715 /// The return continuation is bound by the Function, not by 'let cont'.
714 class Continuation extends Definition<Continuation> implements InteriorNode { 716 class Continuation extends Definition<Continuation> implements InteriorNode {
715 final List<Parameter> parameters; 717 final List<Parameter> parameters;
716 Expression body = null; 718 Expression body = null;
717 719
718 // In addition to a parent pointer to the containing LetCont, continuations 720 // In addition to a parent pointer to the containing LetCont, continuations
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 final Continuation returnContinuation; 792 final Continuation returnContinuation;
791 RunnableBody(this.body, this.returnContinuation); 793 RunnableBody(this.body, this.returnContinuation);
792 accept(Visitor visitor) => visitor.visitRunnableBody(this); 794 accept(Visitor visitor) => visitor.visitRunnableBody(this);
793 } 795 }
794 796
795 /// A function definition, consisting of parameters and a body. The parameters 797 /// A function definition, consisting of parameters and a body. The parameters
796 /// include a distinguished continuation parameter (held by the body). 798 /// include a distinguished continuation parameter (held by the body).
797 class FunctionDefinition extends Node 799 class FunctionDefinition extends Node
798 implements ExecutableDefinition { 800 implements ExecutableDefinition {
799 final FunctionElement element; 801 final FunctionElement element;
802 final Parameter thisParameter;
800 /// Mixed list of [Parameter]s and [MutableVariable]s. 803 /// Mixed list of [Parameter]s and [MutableVariable]s.
801 final List<Definition> parameters; 804 final List<Definition> parameters;
802 final RunnableBody body; 805 final RunnableBody body;
803 final List<ConstDeclaration> localConstants; 806 final List<ConstDeclaration> localConstants;
804 807
805 /// Values for optional parameters. 808 /// Values for optional parameters.
806 final List<ConstantExpression> defaultParameterValues; 809 final List<ConstantExpression> defaultParameterValues;
807 810
808 FunctionDefinition(this.element, 811 FunctionDefinition(this.element,
812 this.thisParameter,
809 this.parameters, 813 this.parameters,
810 this.body, 814 this.body,
811 this.localConstants, 815 this.localConstants,
812 this.defaultParameterValues); 816 this.defaultParameterValues);
813 817
814 FunctionDefinition.abstract(this.element, 818 FunctionDefinition.abstract(this.element,
819 this.thisParameter,
815 this.parameters, 820 this.parameters,
816 this.defaultParameterValues) 821 this.defaultParameterValues)
817 : body = null, 822 : body = null,
818 localConstants = const <ConstDeclaration>[]; 823 localConstants = const <ConstDeclaration>[];
819 824
820 accept(Visitor visitor) => visitor.visitFunctionDefinition(this); 825 accept(Visitor visitor) => visitor.visitFunctionDefinition(this);
821 applyPass(Pass pass) => pass.rewriteFunctionDefinition(this); 826 applyPass(Pass pass) => pass.rewriteFunctionDefinition(this);
822 827
823 /// Returns `true` if this function is abstract or external. 828 /// Returns `true` if this function is abstract or external.
824 /// 829 ///
(...skipping 16 matching lines...) Expand all
841 final List<RunnableBody> arguments; 846 final List<RunnableBody> arguments;
842 final Selector selector; 847 final Selector selector;
843 SuperInitializer(this.target, this.arguments, this.selector); 848 SuperInitializer(this.target, this.arguments, this.selector);
844 accept(Visitor visitor) => visitor.visitSuperInitializer(this); 849 accept(Visitor visitor) => visitor.visitSuperInitializer(this);
845 } 850 }
846 851
847 class ConstructorDefinition extends FunctionDefinition { 852 class ConstructorDefinition extends FunctionDefinition {
848 final List<Initializer> initializers; 853 final List<Initializer> initializers;
849 854
850 ConstructorDefinition(ConstructorElement element, 855 ConstructorDefinition(ConstructorElement element,
856 Definition thisParameter, // only Dart
851 List<Definition> parameters, 857 List<Definition> parameters,
852 RunnableBody body, 858 RunnableBody body,
853 this.initializers, 859 this.initializers,
854 List<ConstDeclaration> localConstants, 860 List<ConstDeclaration> localConstants,
855 List<ConstantExpression> defaultParameterValues) 861 List<ConstantExpression> defaultParameterValues)
856 : super(element, parameters, body, localConstants, 862 : super(element, thisParameter, parameters, body, localConstants,
857 defaultParameterValues); 863 defaultParameterValues);
858 864
859 // 'Abstract' here means "has no body" and is used to represent external 865 // 'Abstract' here means "has no body" and is used to represent external
860 // constructors. 866 // constructors.
861 ConstructorDefinition.abstract( 867 ConstructorDefinition.abstract(
862 ConstructorElement element, 868 ConstructorElement element,
863 List<Definition> parameters, 869 List<Definition> parameters,
864 List<ConstantExpression> defaultParameterValues) 870 List<ConstantExpression> defaultParameterValues)
865 : initializers = null, 871 : initializers = null,
866 super.abstract(element, parameters, defaultParameterValues); 872 super.abstract(element, null, parameters, defaultParameterValues);
867 873
868 accept(Visitor visitor) => visitor.visitConstructorDefinition(this); 874 accept(Visitor visitor) => visitor.visitConstructorDefinition(this);
869 applyPass(Pass pass) => pass.rewriteConstructorDefinition(this); 875 applyPass(Pass pass) => pass.rewriteConstructorDefinition(this);
870 } 876 }
871 877
872 /// Converts the internal representation of a type to a Dart object of type 878 /// Converts the internal representation of a type to a Dart object of type
873 /// [Type]. 879 /// [Type].
874 class ReifyRuntimeType extends Primitive implements JsSpecificNode { 880 class ReifyRuntimeType extends Primitive implements JsSpecificNode {
875 /// Reference to the internal representation of a type (as produced, for 881 /// Reference to the internal representation of a type (as produced, for
876 /// example, by [ReadTypeVariable]). 882 /// example, by [ReadTypeVariable]).
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 } 1505 }
1500 1506
1501 void visitReifyRuntimeType(ReifyRuntimeType node) { 1507 void visitReifyRuntimeType(ReifyRuntimeType node) {
1502 visitReference(node.value); 1508 visitReference(node.value);
1503 } 1509 }
1504 1510
1505 void visitReadTypeVariable(ReadTypeVariable node) { 1511 void visitReadTypeVariable(ReadTypeVariable node) {
1506 visitReference(node.target); 1512 visitReference(node.target);
1507 } 1513 }
1508 } 1514 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698