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

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

Issue 1160223006: Fix DDC errors on DDC (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: address comments Created 5 years, 6 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/dependency_graph.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 library dev_compiler.src.codegen.side_effect_analysis; 5 library dev_compiler.src.codegen.side_effect_analysis;
6 6
7 import 'package:analyzer/src/generated/ast.dart'; 7 import 'package:analyzer/src/generated/ast.dart';
8 import 'package:analyzer/src/generated/constant.dart'; 8 import 'package:analyzer/src/generated/constant.dart';
9 import 'package:analyzer/src/generated/element.dart'; 9 import 'package:analyzer/src/generated/element.dart';
10 import 'package:analyzer/src/generated/error.dart' show ErrorReporter; 10 import 'package:analyzer/src/generated/error.dart' show ErrorReporter;
(...skipping 18 matching lines...) Expand all
29 /// 29 ///
30 /// This method is conservative: it should never return `true` unless it is 30 /// This method is conservative: it should never return `true` unless it is
31 /// certain the [node] is stateless, because generated code may rely on the 31 /// certain the [node] is stateless, because generated code may rely on the
32 /// correctness of a `true` value. However it may return `false` for things 32 /// correctness of a `true` value. However it may return `false` for things
33 /// that are in fact, stateless. 33 /// that are in fact, stateless.
34 bool isStateless(Expression node, [AstNode context]) { 34 bool isStateless(Expression node, [AstNode context]) {
35 // `this` and `super` cannot be reassigned. 35 // `this` and `super` cannot be reassigned.
36 if (node is ThisExpression || node is SuperExpression) return true; 36 if (node is ThisExpression || node is SuperExpression) return true;
37 if (node is SimpleIdentifier) { 37 if (node is SimpleIdentifier) {
38 var e = node.staticElement; 38 var e = node.staticElement;
39 if (e is PropertyAccessorElement) e = e.variable; 39 if (e is PropertyAccessorElement) e =
40 (e as PropertyAccessorElement).variable;
40 if (e is VariableElement && !e.isSynthetic) { 41 if (e is VariableElement && !e.isSynthetic) {
41 if (e.isFinal) return true; 42 if (e.isFinal) return true;
42 if (e is LocalVariableElement || e is ParameterElement) { 43 if (e is LocalVariableElement || e is ParameterElement) {
43 // make sure the local isn't mutated in the context. 44 // make sure the local isn't mutated in the context.
44 return !_isPotentiallyMutated(e, context); 45 return !_isPotentiallyMutated(e, context);
45 } 46 }
46 } 47 }
47 } 48 }
48 return false; 49 return false;
49 } 50 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 // ConstantEvaluator will not compute constants for non-const fields, 115 // ConstantEvaluator will not compute constants for non-const fields,
115 // so run ConstantVisitor for those to figure out if the initializer is 116 // so run ConstantVisitor for those to figure out if the initializer is
116 // actually a constant (and therefore side effect free to evaluate). 117 // actually a constant (and therefore side effect free to evaluate).
117 assert(!field.isConst); 118 assert(!field.isConst);
118 119
119 var initializer = field.initializer; 120 var initializer = field.initializer;
120 if (initializer == null) return null; 121 if (initializer == null) return null;
121 return initializer.accept(_constantVisitor); 122 return initializer.accept(_constantVisitor);
122 } 123 }
123 } 124 }
OLDNEW
« no previous file with comments | « lib/src/codegen/reify_coercions.dart ('k') | lib/src/dependency_graph.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698