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

Side by Side Diff: pkg/analyzer/lib/src/generated/resolver.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 library engine.resolver; 5 library engine.resolver;
6 6
7 import "dart:math" as math; 7 import "dart:math" as math;
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analyzer/src/generated/utilities_collection.dart'; 10 import 'package:analyzer/src/generated/utilities_collection.dart';
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 ErrorCode dataErrorCode = data.errorCode; 1155 ErrorCode dataErrorCode = data.errorCode;
1156 if (identical(dataErrorCode, 1156 if (identical(dataErrorCode,
1157 CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION) || 1157 CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION) ||
1158 identical( 1158 identical(
1159 dataErrorCode, CompileTimeErrorCode.CONST_EVAL_THROWS_IDBZE) || 1159 dataErrorCode, CompileTimeErrorCode.CONST_EVAL_THROWS_IDBZE) ||
1160 identical(dataErrorCode, 1160 identical(dataErrorCode,
1161 CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING) || 1161 CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING) ||
1162 identical(dataErrorCode, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL) || 1162 identical(dataErrorCode, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL) ||
1163 identical(dataErrorCode, CompileTimeErrorCode.CONST_EVAL_TYPE_INT) || 1163 identical(dataErrorCode, CompileTimeErrorCode.CONST_EVAL_TYPE_INT) ||
1164 identical(dataErrorCode, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM) || 1164 identical(dataErrorCode, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM) ||
1165 identical(dataErrorCode, CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_C ONSTANT) || 1165 identical(dataErrorCode,
1166 CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT) ||
1166 identical(dataErrorCode, 1167 identical(dataErrorCode,
1167 CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMA TCH) || 1168 CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_FIELD_TYPE_MISMA TCH) ||
1168 identical(dataErrorCode, 1169 identical(dataErrorCode,
1169 CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMA TCH) || 1170 CheckedModeCompileTimeErrorCode.CONST_CONSTRUCTOR_PARAM_TYPE_MISMA TCH) ||
1170 identical(dataErrorCode, 1171 identical(dataErrorCode,
1171 CheckedModeCompileTimeErrorCode.VARIABLE_TYPE_MISMATCH)) { 1172 CheckedModeCompileTimeErrorCode.VARIABLE_TYPE_MISMATCH)) {
1172 _errorReporter.reportError(data); 1173 _errorReporter.reportError(data);
1173 } else if (errorCode != null) { 1174 } else if (errorCode != null) {
1174 _errorReporter.reportError(new AnalysisError.con2( 1175 _errorReporter.reportError(new AnalysisError.con2(
1175 data.source, data.offset, data.length, errorCode)); 1176 data.source, data.offset, data.length, errorCode));
(...skipping 9733 matching lines...) Expand 10 before | Expand all | Expand 10 after
10909 // 10910 //
10910 // We do not visit the label because it needs to be visited in the context 10911 // We do not visit the label because it needs to be visited in the context
10911 // of the statement. 10912 // of the statement.
10912 // 10913 //
10913 node.accept(elementResolver); 10914 node.accept(elementResolver);
10914 node.accept(typeAnalyzer); 10915 node.accept(typeAnalyzer);
10915 return null; 10916 return null;
10916 } 10917 }
10917 10918
10918 @override 10919 @override
10920 Object visitDefaultFormalParameter(DefaultFormalParameter node) {
10921 super.visitDefaultFormalParameter(node);
10922 FormalParameterList parent = node.parent;
10923 AstNode grandparent = parent.parent;
10924 if (grandparent is ConstructorDeclaration &&
10925 grandparent.constKeyword != null) {
10926 // For const constructors, we need to clone the ASTs for default formal
10927 // parameters, so that we can use them during constant evaluation.
10928 ParameterElement element = node.element;
10929 (element as ConstVariableElement).constantInitializer =
10930 new ConstantAstCloner().cloneNode(node.defaultValue);
10931 }
10932 return null;
10933 }
10934
10935 @override
10919 Object visitDoStatement(DoStatement node) { 10936 Object visitDoStatement(DoStatement node) {
10920 _overrideManager.enterScope(); 10937 _overrideManager.enterScope();
10921 try { 10938 try {
10922 super.visitDoStatement(node); 10939 super.visitDoStatement(node);
10923 } finally { 10940 } finally {
10924 _overrideManager.exitScope(); 10941 _overrideManager.exitScope();
10925 } 10942 }
10926 // TODO(brianwilkerson) If the loop can only be exited because the condition 10943 // TODO(brianwilkerson) If the loop can only be exited because the condition
10927 // is false, then propagateFalseState(node.getCondition()); 10944 // is false, then propagateFalseState(node.getCondition());
10928 return null; 10945 return null;
(...skipping 4505 matching lines...) Expand 10 before | Expand all | Expand 10 after
15434 nonFields.add(node); 15451 nonFields.add(node);
15435 return null; 15452 return null;
15436 } 15453 }
15437 15454
15438 @override 15455 @override
15439 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this); 15456 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this);
15440 15457
15441 @override 15458 @override
15442 Object visitWithClause(WithClause node) => null; 15459 Object visitWithClause(WithClause node) => null;
15443 } 15460 }
OLDNEW
« pkg/analyzer/lib/src/generated/element.dart ('K') | « pkg/analyzer/lib/src/generated/element.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698