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

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

Issue 1762283003: Various cleanup (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: 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
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/src/generated/ast.dart';
6 import 'package:analyzer/src/generated/constant.dart'; 6 import 'package:analyzer/src/generated/constant.dart';
7 import 'package:analyzer/src/generated/element.dart'; 7 import 'package:analyzer/src/generated/element.dart';
8 import 'package:analyzer/src/generated/error.dart' 8 import 'package:analyzer/src/generated/error.dart'
9 show AnalysisErrorListener, ErrorReporter; 9 show AnalysisErrorListener, ErrorReporter;
10 import 'package:analyzer/src/generated/resolver.dart' show TypeProvider; 10 import 'package:analyzer/src/generated/resolver.dart' show TypeProvider;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 // make sure the local isn't mutated in the context. 44 // make sure the local isn't mutated in the context.
45 return !_isPotentiallyMutated(function, e, context); 45 return !_isPotentiallyMutated(function, e, context);
46 } 46 }
47 } 47 }
48 } 48 }
49 return false; 49 return false;
50 } 50 }
51 51
52 /// Returns true if the local variable is potentially mutated within [context]. 52 /// Returns true if the local variable is potentially mutated within [context].
53 /// This accounts for closures that may have been created outside of [context]. 53 /// This accounts for closures that may have been created outside of [context].
54 bool _isPotentiallyMutated(FunctionBody function, VariableElement e, [AstNode co ntext]) { 54 bool _isPotentiallyMutated(FunctionBody function, VariableElement e,
55 [AstNode context]) {
55 if (function.isPotentiallyMutatedInClosure(e)) return true; 56 if (function.isPotentiallyMutatedInClosure(e)) return true;
56 if (function.isPotentiallyMutatedInScope(e)) { 57 if (function.isPotentiallyMutatedInScope(e)) {
57 // Need to visit the context looking for assignment to this local. 58 // Need to visit the context looking for assignment to this local.
58 if (context != null) { 59 if (context != null) {
59 var visitor = new _AssignmentFinder(e); 60 var visitor = new _AssignmentFinder(e);
60 context.accept(visitor); 61 context.accept(visitor);
61 return visitor._potentiallyMutated; 62 return visitor._potentiallyMutated;
62 } 63 }
63 return true; 64 return true;
64 } 65 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 // ConstantEvaluator will not compute constants for non-const fields, 121 // ConstantEvaluator will not compute constants for non-const fields,
121 // so run ConstantVisitor for those to figure out if the initializer is 122 // so run ConstantVisitor for those to figure out if the initializer is
122 // actually a constant (and therefore side effect free to evaluate). 123 // actually a constant (and therefore side effect free to evaluate).
123 assert(!field.isConst); 124 assert(!field.isConst);
124 125
125 var initializer = field.initializer; 126 var initializer = field.initializer;
126 if (initializer == null) return null; 127 if (initializer == null) return null;
127 return initializer.accept(_constantVisitor); 128 return initializer.accept(_constantVisitor);
128 } 129 }
129 } 130 }
OLDNEW
« no previous file with comments | « lib/src/codegen/js_metalet.dart ('k') | lib/src/compiler.dart » ('j') | lib/src/compiler.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698