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

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

Issue 2016483002: Enable strong mode in DDC, fix all warnings/errors (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 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
« no previous file with comments | « lib/src/compiler/reify_coercions.dart ('k') | lib/src/compiler/type_utilities.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/dart/ast/ast.dart'; 5 import 'package:analyzer/dart/ast/ast.dart';
6 import 'package:analyzer/dart/ast/visitor.dart'; 6 import 'package:analyzer/dart/ast/visitor.dart';
7 import 'package:analyzer/dart/element/element.dart'; 7 import 'package:analyzer/dart/element/element.dart';
8 import 'package:analyzer/src/generated/constant.dart'; 8 import 'package:analyzer/src/generated/constant.dart';
9 import 'package:analyzer/src/generated/error.dart' 9 import 'package:analyzer/src/generated/error.dart'
10 show AnalysisErrorListener, ErrorReporter; 10 show AnalysisErrorListener, ErrorReporter;
(...skipping 20 matching lines...) Expand all
31 /// This method is conservative: it should never return `true` unless it is 31 /// This method is conservative: it should never return `true` unless it is
32 /// certain the [node] is stateless, because generated code may rely on the 32 /// certain the [node] is stateless, because generated code may rely on the
33 /// correctness of a `true` value. However it may return `false` for things 33 /// correctness of a `true` value. However it may return `false` for things
34 /// that are in fact, stateless. 34 /// that are in fact, stateless.
35 bool isStateless(FunctionBody function, Expression node, [AstNode context]) { 35 bool isStateless(FunctionBody function, Expression node, [AstNode context]) {
36 // `this` and `super` cannot be reassigned. 36 // `this` and `super` cannot be reassigned.
37 if (node is ThisExpression || node is SuperExpression) return true; 37 if (node is ThisExpression || node is SuperExpression) return true;
38 if (node is Identifier) { 38 if (node is Identifier) {
39 var e = node.staticElement; 39 var e = node.staticElement;
40 if (e is PropertyAccessorElement) { 40 if (e is PropertyAccessorElement) {
41 e = e.variable; 41 e = (e as PropertyAccessorElement).variable;
42 } 42 }
43 if (e is VariableElement && !e.isSynthetic) { 43 if (e is VariableElement && !e.isSynthetic) {
44 if (e.isFinal) return true; 44 if (e.isFinal) return true;
45 if (e is LocalVariableElement || e is ParameterElement) { 45 if (e is LocalVariableElement || e is ParameterElement) {
46 // make sure the local isn't mutated in the context. 46 // make sure the local isn't mutated in the context.
47 return !_isPotentiallyMutated(function, e, context); 47 return !_isPotentiallyMutated(function, e, context);
48 } 48 }
49 } 49 }
50 } 50 }
51 return false; 51 return false;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 // ConstantEvaluator will not compute constants for non-const fields, 129 // ConstantEvaluator will not compute constants for non-const fields,
130 // so run ConstantVisitor for those to figure out if the initializer is 130 // so run ConstantVisitor for those to figure out if the initializer is
131 // actually a constant (and therefore side effect free to evaluate). 131 // actually a constant (and therefore side effect free to evaluate).
132 assert(!field.isConst); 132 assert(!field.isConst);
133 133
134 var initializer = field.initializer; 134 var initializer = field.initializer;
135 if (initializer == null) return null; 135 if (initializer == null) return null;
136 return initializer.accept(_constantVisitor); 136 return initializer.accept(_constantVisitor);
137 } 137 }
138 } 138 }
OLDNEW
« no previous file with comments | « lib/src/compiler/reify_coercions.dart ('k') | lib/src/compiler/type_utilities.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698