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

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

Issue 1413923003: Remove uses of DartObjectImpl (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 2 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/js_codegen.dart ('k') | lib/src/utils.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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 new ErrorReporter( 102 new ErrorReporter(
103 new RecordingErrorListener(), unit.element.source)); 103 new RecordingErrorListener(), unit.element.source));
104 104
105 // TODO(jmesserly): this is used to determine if the field initialization is 105 // TODO(jmesserly): this is used to determine if the field initialization is
106 // side effect free. We should make the check more general, as things like 106 // side effect free. We should make the check more general, as things like
107 // list/map literals/regexp are also side effect free and fairly common 107 // list/map literals/regexp are also side effect free and fairly common
108 // to use as field initializers. 108 // to use as field initializers.
109 bool isFieldInitConstant(VariableDeclaration field) => 109 bool isFieldInitConstant(VariableDeclaration field) =>
110 field.initializer == null || computeConstant(field) != null; 110 field.initializer == null || computeConstant(field) != null;
111 111
112 DartObjectImpl computeConstant(VariableDeclaration field) { 112 DartObject computeConstant(VariableDeclaration field) {
113 // If the constant is already computed by ConstantEvaluator, just return it. 113 // If the constant is already computed by ConstantEvaluator, just return it.
114 VariableElementImpl element = field.element; 114 VariableElementImpl element = field.element;
115 var result = element.evaluationResult; 115 var result = element.evaluationResult;
116 if (result != null) return result.value; 116 if (result != null) return result.value;
117 117
118 // ConstantEvaluator will not compute constants for non-const fields, 118 // ConstantEvaluator will not compute constants for non-const fields,
119 // so run ConstantVisitor for those to figure out if the initializer is 119 // so run ConstantVisitor for those to figure out if the initializer is
120 // actually a constant (and therefore side effect free to evaluate). 120 // actually a constant (and therefore side effect free to evaluate).
121 assert(!field.isConst); 121 assert(!field.isConst);
122 122
123 var initializer = field.initializer; 123 var initializer = field.initializer;
124 if (initializer == null) return null; 124 if (initializer == null) return null;
125 return initializer.accept(_constantVisitor); 125 return initializer.accept(_constantVisitor);
126 } 126 }
127 } 127 }
OLDNEW
« no previous file with comments | « lib/src/codegen/js_codegen.dart ('k') | lib/src/utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698