| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 analyzer.src.generated.constant; | 5 library analyzer.src.generated.constant; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/dart/element/type.dart'; | 10 import 'package:analyzer/dart/element/type.dart'; |
| (...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1223 errorReporter)); | 1223 errorReporter)); |
| 1224 if (result != null) { | 1224 if (result != null) { |
| 1225 return EvaluationResult.forValue(result); | 1225 return EvaluationResult.forValue(result); |
| 1226 } | 1226 } |
| 1227 return EvaluationResult.forErrors(errorListener.errors); | 1227 return EvaluationResult.forErrors(errorListener.errors); |
| 1228 } | 1228 } |
| 1229 } | 1229 } |
| 1230 | 1230 |
| 1231 /** | 1231 /** |
| 1232 * A visitor used to traverse the AST structures of all of the compilation units | 1232 * A visitor used to traverse the AST structures of all of the compilation units |
| 1233 * being resolved and build the full set of dependencies for all constant |
| 1234 * expressions. |
| 1235 */ |
| 1236 class ConstantExpressionsDependenciesFinder extends RecursiveAstVisitor { |
| 1237 /** |
| 1238 * The constants whose values need to be computed. |
| 1239 */ |
| 1240 HashSet<ConstantEvaluationTarget> dependencies = |
| 1241 new HashSet<ConstantEvaluationTarget>(); |
| 1242 |
| 1243 @override |
| 1244 void visitListLiteral(ListLiteral node) { |
| 1245 if (node.constKeyword != null) { |
| 1246 _find(node); |
| 1247 } else { |
| 1248 super.visitListLiteral(node); |
| 1249 } |
| 1250 } |
| 1251 |
| 1252 @override |
| 1253 void visitMapLiteral(MapLiteral node) { |
| 1254 if (node.constKeyword != null) { |
| 1255 _find(node); |
| 1256 } else { |
| 1257 super.visitMapLiteral(node); |
| 1258 } |
| 1259 } |
| 1260 |
| 1261 @override |
| 1262 void visitSwitchCase(SwitchCase node) { |
| 1263 _find(node.expression); |
| 1264 node.statements.accept(this); |
| 1265 } |
| 1266 |
| 1267 void _find(Expression node) { |
| 1268 if (node != null) { |
| 1269 ReferenceFinder referenceFinder = new ReferenceFinder(dependencies.add); |
| 1270 node.accept(referenceFinder); |
| 1271 } |
| 1272 } |
| 1273 } |
| 1274 |
| 1275 /** |
| 1276 * A visitor used to traverse the AST structures of all of the compilation units |
| 1233 * being resolved and build tables of the constant variables, constant | 1277 * being resolved and build tables of the constant variables, constant |
| 1234 * constructors, constant constructor invocations, and annotations found in | 1278 * constructors, constant constructor invocations, and annotations found in |
| 1235 * those compilation units. | 1279 * those compilation units. |
| 1236 */ | 1280 */ |
| 1237 class ConstantFinder extends RecursiveAstVisitor<Object> { | 1281 class ConstantFinder extends RecursiveAstVisitor<Object> { |
| 1238 final AnalysisContext context; | 1282 final AnalysisContext context; |
| 1239 final Source source; | 1283 final Source source; |
| 1240 final Source librarySource; | 1284 final Source librarySource; |
| 1241 | 1285 |
| 1242 /** | 1286 /** |
| (...skipping 4154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5397 return BoolState.from(_element == rightElement); | 5441 return BoolState.from(_element == rightElement); |
| 5398 } else if (rightOperand is DynamicState) { | 5442 } else if (rightOperand is DynamicState) { |
| 5399 return BoolState.UNKNOWN_VALUE; | 5443 return BoolState.UNKNOWN_VALUE; |
| 5400 } | 5444 } |
| 5401 return BoolState.FALSE_STATE; | 5445 return BoolState.FALSE_STATE; |
| 5402 } | 5446 } |
| 5403 | 5447 |
| 5404 @override | 5448 @override |
| 5405 String toString() => _element == null ? "-unknown-" : _element.name; | 5449 String toString() => _element == null ? "-unknown-" : _element.name; |
| 5406 } | 5450 } |
| OLD | NEW |