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

Side by Side Diff: pkg/analyzer/lib/src/generated/constant.dart

Issue 1055543003: Rename ConstantValueComputer_InitializerCloner. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.constant; 8 library engine.constant;
9 9
10 import 'dart:collection'; 10 import 'dart:collection';
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 String toString() => value == null ? "-unknown-" : (value ? "true" : "false"); 137 String toString() => value == null ? "-unknown-" : (value ? "true" : "false");
138 138
139 /** 139 /**
140 * Return the boolean state representing the given boolean [value]. 140 * Return the boolean state representing the given boolean [value].
141 */ 141 */
142 static BoolState from(bool value) => 142 static BoolState from(bool value) =>
143 value ? BoolState.TRUE_STATE : BoolState.FALSE_STATE; 143 value ? BoolState.TRUE_STATE : BoolState.FALSE_STATE;
144 } 144 }
145 145
146 /** 146 /**
147 * An [AstCloner] that copies the necessary information from the AST to allow
148 * const constructor initializers to be evaluated.
149 */
150 class ConstantAstCloner extends AstCloner {
151 // TODO(brianwilkerson) Investigate replacing uses of this class with uses of
Brian Wilkerson 2015/04/01 16:39:21 I think we can remove the TODO: having one visitor
Paul Berry 2015/04/01 18:12:07 Done.
152 // AstCloner and ResolutionCopier.
153
154 ConstantAstCloner() : super(true);
155
156 @override
157 InstanceCreationExpression visitInstanceCreationExpression(
158 InstanceCreationExpression node) {
159 InstanceCreationExpression expression =
160 super.visitInstanceCreationExpression(node);
161 expression.evaluationResult = node.evaluationResult;
162 return expression;
163 }
164
165 @override
166 RedirectingConstructorInvocation visitRedirectingConstructorInvocation(
167 RedirectingConstructorInvocation node) {
168 RedirectingConstructorInvocation invocation =
169 super.visitRedirectingConstructorInvocation(node);
170 invocation.staticElement = node.staticElement;
171 return invocation;
172 }
173
174 @override
175 SimpleIdentifier visitSimpleIdentifier(SimpleIdentifier node) {
176 SimpleIdentifier identifier = super.visitSimpleIdentifier(node);
177 identifier.staticElement = node.staticElement;
178 return identifier;
179 }
180
181 @override
182 SuperConstructorInvocation visitSuperConstructorInvocation(
183 SuperConstructorInvocation node) {
184 SuperConstructorInvocation invocation =
185 super.visitSuperConstructorInvocation(node);
186 invocation.staticElement = node.staticElement;
187 return invocation;
188 }
189 }
190
191 /**
147 * Instances of the class `ConstantEvaluator` evaluate constant expressions to 192 * Instances of the class `ConstantEvaluator` evaluate constant expressions to
148 * produce their compile-time value. According to the Dart Language 193 * produce their compile-time value. According to the Dart Language
149 * Specification: 194 * Specification:
150 * <blockquote> 195 * <blockquote>
151 * A constant expression is one of the following: 196 * A constant expression is one of the following:
152 * * A literal number. 197 * * A literal number.
153 * * A literal boolean. 198 * * A literal boolean.
154 * * A literal string where any interpolated expression is a compile-time 199 * * A literal string where any interpolated expression is a compile-time
155 * constant that evaluates to a numeric, string or boolean value or to 200 * constant that evaluates to a numeric, string or boolean value or to
156 * <b>null</b>. 201 * <b>null</b>.
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 expression.argumentList.arguments, constructor, constantVisitor, 690 expression.argumentList.arguments, constructor, constantVisitor,
646 errorReporter); 691 errorReporter);
647 expression.evaluationResult = 692 expression.evaluationResult =
648 new EvaluationResultImpl.con2(result, errorListener.errors); 693 new EvaluationResultImpl.con2(result, errorListener.errors);
649 } else if (constNode is ConstructorDeclaration) { 694 } else if (constNode is ConstructorDeclaration) {
650 ConstructorDeclaration declaration = constNode; 695 ConstructorDeclaration declaration = constNode;
651 NodeList<ConstructorInitializer> initializers = declaration.initializers; 696 NodeList<ConstructorInitializer> initializers = declaration.initializers;
652 ConstructorElementImpl constructor = 697 ConstructorElementImpl constructor =
653 declaration.element as ConstructorElementImpl; 698 declaration.element as ConstructorElementImpl;
654 constructor.constantInitializers = 699 constructor.constantInitializers =
655 new ConstantValueComputer_InitializerCloner() 700 new ConstantAstCloner().cloneNodeList(initializers);
656 .cloneNodeList(initializers);
657 } else if (constNode is FormalParameter) { 701 } else if (constNode is FormalParameter) {
658 if (constNode is DefaultFormalParameter) { 702 if (constNode is DefaultFormalParameter) {
659 DefaultFormalParameter parameter = constNode; 703 DefaultFormalParameter parameter = constNode;
660 ParameterElement element = parameter.element; 704 ParameterElement element = parameter.element;
661 Expression defaultValue = parameter.defaultValue; 705 Expression defaultValue = parameter.defaultValue;
662 if (defaultValue != null) { 706 if (defaultValue != null) {
663 RecordingErrorListener errorListener = new RecordingErrorListener(); 707 RecordingErrorListener errorListener = new RecordingErrorListener();
664 ErrorReporter errorReporter = 708 ErrorReporter errorReporter =
665 new ErrorReporter(errorListener, element.source); 709 new ErrorReporter(errorListener, element.source);
666 DartObjectImpl dartObject = 710 DartObjectImpl dartObject =
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 /** 1126 /**
1083 * Determine whether the given string is a valid name for a public symbol 1127 * Determine whether the given string is a valid name for a public symbol
1084 * (i.e. whether it is allowed for a call to the Symbol constructor). 1128 * (i.e. whether it is allowed for a call to the Symbol constructor).
1085 */ 1129 */
1086 static bool isValidPublicSymbol(String name) => name.isEmpty || 1130 static bool isValidPublicSymbol(String name) => name.isEmpty ||
1087 name == "void" || 1131 name == "void" ||
1088 new JavaPatternMatcher(_PUBLIC_SYMBOL_PATTERN, name).matches(); 1132 new JavaPatternMatcher(_PUBLIC_SYMBOL_PATTERN, name).matches();
1089 } 1133 }
1090 1134
1091 /** 1135 /**
1092 * An [AstCloner] that copies the necessary information from the AST to allow
1093 * const constructor initializers to be evaluated.
1094 */
1095 class ConstantValueComputer_InitializerCloner extends AstCloner {
1096 // TODO(brianwilkerson) Investigate replacing uses of this class with uses of
1097 // AstCloner and ResolutionCopier.
1098
1099 ConstantValueComputer_InitializerCloner() : super(true);
1100
1101 @override
1102 InstanceCreationExpression visitInstanceCreationExpression(
1103 InstanceCreationExpression node) {
1104 InstanceCreationExpression expression =
1105 super.visitInstanceCreationExpression(node);
1106 expression.evaluationResult = node.evaluationResult;
1107 return expression;
1108 }
1109
1110 @override
1111 RedirectingConstructorInvocation visitRedirectingConstructorInvocation(
1112 RedirectingConstructorInvocation node) {
1113 RedirectingConstructorInvocation invocation =
1114 super.visitRedirectingConstructorInvocation(node);
1115 invocation.staticElement = node.staticElement;
1116 return invocation;
1117 }
1118
1119 @override
1120 SimpleIdentifier visitSimpleIdentifier(SimpleIdentifier node) {
1121 SimpleIdentifier identifier = super.visitSimpleIdentifier(node);
1122 identifier.staticElement = node.staticElement;
1123 return identifier;
1124 }
1125
1126 @override
1127 SuperConstructorInvocation visitSuperConstructorInvocation(
1128 SuperConstructorInvocation node) {
1129 SuperConstructorInvocation invocation =
1130 super.visitSuperConstructorInvocation(node);
1131 invocation.staticElement = node.staticElement;
1132 return invocation;
1133 }
1134 }
1135
1136 /**
1137 * A visitor used to evaluate constant expressions to produce their compile-time 1136 * A visitor used to evaluate constant expressions to produce their compile-time
1138 * value. According to the Dart Language Specification: <blockquote> A constant 1137 * value. According to the Dart Language Specification: <blockquote> A constant
1139 * expression is one of the following: 1138 * expression is one of the following:
1140 * 1139 *
1141 * * A literal number. 1140 * * A literal number.
1142 * * A literal boolean. 1141 * * A literal boolean.
1143 * * A literal string where any interpolated expression is a compile-time 1142 * * A literal string where any interpolated expression is a compile-time
1144 * constant that evaluates to a numeric, string or boolean value or to 1143 * constant that evaluates to a numeric, string or boolean value or to
1145 * <b>null</b>. 1144 * <b>null</b>.
1146 * * A literal symbol. 1145 * * A literal symbol.
(...skipping 3944 matching lines...) Expand 10 before | Expand all | Expand 10 after
5091 return BoolState.from(_element == rightElement); 5090 return BoolState.from(_element == rightElement);
5092 } else if (rightOperand is DynamicState) { 5091 } else if (rightOperand is DynamicState) {
5093 return BoolState.UNKNOWN_VALUE; 5092 return BoolState.UNKNOWN_VALUE;
5094 } 5093 }
5095 return BoolState.FALSE_STATE; 5094 return BoolState.FALSE_STATE;
5096 } 5095 }
5097 5096
5098 @override 5097 @override
5099 String toString() => _element == null ? "-unknown-" : _element.name; 5098 String toString() => _element == null ? "-unknown-" : _element.name;
5100 } 5099 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698