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

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

Issue 1115993005: Clone AST nodes of default formal parameters prior to constant evaluation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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) 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 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 // No evaluation needs to be done; constructor declarations are only in 1141 // No evaluation needs to be done; constructor declarations are only in
1142 // the dependency graph to ensure that any constants referred to in 1142 // the dependency graph to ensure that any constants referred to in
1143 // initializer lists and parameter defaults are evaluated before 1143 // initializer lists and parameter defaults are evaluated before
1144 // invocations of the constructor. However we do need to annotate the 1144 // invocations of the constructor. However we do need to annotate the
1145 // element as being free of constant evaluation cycles so that later code 1145 // element as being free of constant evaluation cycles so that later code
1146 // will know that it is safe to evaluate. 1146 // will know that it is safe to evaluate.
1147 ConstructorElementImpl constructor = constNode.element; 1147 ConstructorElementImpl constructor = constNode.element;
1148 constructor.isCycleFree = true; 1148 constructor.isCycleFree = true;
1149 } else if (constNode is FormalParameter) { 1149 } else if (constNode is FormalParameter) {
1150 if (constNode is DefaultFormalParameter) { 1150 if (constNode is DefaultFormalParameter) {
1151 DefaultFormalParameter parameter = constNode; 1151 ParameterElement element = constNode.element;
1152 ParameterElement element = parameter.element; 1152 Expression defaultValue =
1153 Expression defaultValue = parameter.defaultValue; 1153 (element as PotentiallyConstVariableElement).constantInitializer;
1154 if (defaultValue != null) { 1154 if (defaultValue != null) {
1155 RecordingErrorListener errorListener = new RecordingErrorListener(); 1155 RecordingErrorListener errorListener = new RecordingErrorListener();
1156 ErrorReporter errorReporter = 1156 ErrorReporter errorReporter =
1157 new ErrorReporter(errorListener, element.source); 1157 new ErrorReporter(errorListener, element.source);
1158 DartObjectImpl dartObject = defaultValue 1158 DartObjectImpl dartObject = defaultValue
1159 .accept(new ConstantVisitor(evaluationEngine, errorReporter)); 1159 .accept(new ConstantVisitor(evaluationEngine, errorReporter));
1160 (element as ParameterElementImpl).evaluationResult = 1160 (element as ParameterElementImpl).evaluationResult =
1161 new EvaluationResultImpl.con2(dartObject, errorListener.errors); 1161 new EvaluationResultImpl.con2(dartObject, errorListener.errors);
1162 } 1162 }
1163 } 1163 }
(...skipping 4030 matching lines...) Expand 10 before | Expand all | Expand 10 after
5194 return BoolState.from(_element == rightElement); 5194 return BoolState.from(_element == rightElement);
5195 } else if (rightOperand is DynamicState) { 5195 } else if (rightOperand is DynamicState) {
5196 return BoolState.UNKNOWN_VALUE; 5196 return BoolState.UNKNOWN_VALUE;
5197 } 5197 }
5198 return BoolState.FALSE_STATE; 5198 return BoolState.FALSE_STATE;
5199 } 5199 }
5200 5200
5201 @override 5201 @override
5202 String toString() => _element == null ? "-unknown-" : _element.name; 5202 String toString() => _element == null ? "-unknown-" : _element.name;
5203 } 5203 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/element.dart » ('j') | pkg/analyzer/lib/src/generated/element.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698