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

Side by Side Diff: lib/src/codegen/side_effect_analysis.dart

Issue 1797063002: Resolve obvious deprecation warnings on bleeding edge (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Add test Created 4 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
« no previous file with comments | « lib/src/codegen/reify_coercions.dart ('k') | lib/src/compiler.dart » ('j') | 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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 import 'package:analyzer/src/generated/ast.dart'; 5 import 'package:analyzer/dart/ast/ast.dart';
6 import 'package:analyzer/dart/ast/visitor.dart';
7 import 'package:analyzer/dart/element/element.dart';
6 import 'package:analyzer/src/generated/constant.dart'; 8 import 'package:analyzer/src/generated/constant.dart';
7 import 'package:analyzer/src/generated/element.dart';
8 import 'package:analyzer/src/generated/error.dart' 9 import 'package:analyzer/src/generated/error.dart'
9 show AnalysisErrorListener, ErrorReporter; 10 show AnalysisErrorListener, ErrorReporter;
10 import 'package:analyzer/src/generated/resolver.dart' show TypeProvider; 11 import 'package:analyzer/src/generated/resolver.dart' show TypeProvider;
11 import 'package:analyzer/src/generated/source.dart' show Source; 12 import 'package:analyzer/src/generated/source.dart' show Source;
12 13
13 /// True is the expression can be evaluated multiple times without causing 14 /// True is the expression can be evaluated multiple times without causing
14 /// code execution. This is true for final fields. This can be true for local 15 /// code execution. This is true for final fields. This can be true for local
15 /// variables, if: 16 /// variables, if:
16 /// * they are not assigned within the [context]. 17 /// * they are not assigned within the [context].
17 /// * they are not assigned in a function closure anywhere. 18 /// * they are not assigned in a function closure anywhere.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 108
108 // TODO(jmesserly): this is used to determine if the field initialization is 109 // TODO(jmesserly): this is used to determine if the field initialization is
109 // side effect free. We should make the check more general, as things like 110 // side effect free. We should make the check more general, as things like
110 // list/map literals/regexp are also side effect free and fairly common 111 // list/map literals/regexp are also side effect free and fairly common
111 // to use as field initializers. 112 // to use as field initializers.
112 bool isFieldInitConstant(VariableDeclaration field) => 113 bool isFieldInitConstant(VariableDeclaration field) =>
113 field.initializer == null || computeConstant(field) != null; 114 field.initializer == null || computeConstant(field) != null;
114 115
115 DartObject computeConstant(VariableDeclaration field) { 116 DartObject computeConstant(VariableDeclaration field) {
116 // If the constant is already computed by ConstantEvaluator, just return it. 117 // If the constant is already computed by ConstantEvaluator, just return it.
117 VariableElementImpl element = field.element; 118 VariableElement element = field.element;
118 var result = element.evaluationResult; 119 var result = element.constantValue;
119 if (result != null) return result.value; 120 if (result != null) return result;
120 121
121 // ConstantEvaluator will not compute constants for non-const fields, 122 // ConstantEvaluator will not compute constants for non-const fields,
122 // so run ConstantVisitor for those to figure out if the initializer is 123 // so run ConstantVisitor for those to figure out if the initializer is
123 // actually a constant (and therefore side effect free to evaluate). 124 // actually a constant (and therefore side effect free to evaluate).
124 assert(!field.isConst); 125 assert(!field.isConst);
125 126
126 var initializer = field.initializer; 127 var initializer = field.initializer;
127 if (initializer == null) return null; 128 if (initializer == null) return null;
128 return initializer.accept(_constantVisitor); 129 return initializer.accept(_constantVisitor);
129 } 130 }
130 } 131 }
OLDNEW
« no previous file with comments | « lib/src/codegen/reify_coercions.dart ('k') | lib/src/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698