Chromium Code Reviews| 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.constant; | 8 library engine.constant; |
| 9 | 9 |
| 10 import 'dart:collection'; | 10 import 'dart:collection'; |
| 11 | 11 |
| 12 import 'package:analyzer/src/generated/engine.dart'; | 12 import 'package:analyzer/src/generated/engine.dart'; |
| 13 import 'package:analyzer/src/generated/utilities_general.dart'; | 13 import 'package:analyzer/src/generated/utilities_general.dart'; |
| 14 import 'package:analyzer/src/task/dart.dart'; | 14 import 'package:analyzer/src/task/dart.dart'; |
| 15 | 15 |
| 16 import 'ast.dart'; | 16 import 'ast.dart'; |
| 17 import 'element.dart'; | 17 import 'element.dart'; |
| 18 import 'engine.dart' show AnalysisEngine, RecordingErrorListener; | 18 import 'engine.dart' show AnalysisEngine, RecordingErrorListener; |
| 19 import 'error.dart'; | 19 import 'error.dart'; |
| 20 import 'java_core.dart'; | 20 import 'java_core.dart'; |
| 21 import 'resolver.dart' show TypeProvider; | 21 import 'resolver.dart' show TypeProvider, TypeSystem, TypeSystemImpl; |
| 22 import 'scanner.dart' show Token, TokenType; | 22 import 'scanner.dart' show Token, TokenType; |
| 23 import 'source.dart' show Source; | 23 import 'source.dart' show Source; |
| 24 import 'utilities_collection.dart'; | 24 import 'utilities_collection.dart'; |
| 25 import 'utilities_dart.dart' show ParameterKind; | 25 import 'utilities_dart.dart' show ParameterKind; |
| 26 | 26 |
| 27 /** | 27 /** |
| 28 * Callback used by [ReferenceFinder] to report that a dependency was found. | 28 * Callback used by [ReferenceFinder] to report that a dependency was found. |
| 29 */ | 29 */ |
| 30 typedef void ReferenceFinderCallback(ConstantEvaluationTarget dependency); | 30 typedef void ReferenceFinderCallback(ConstantEvaluationTarget dependency); |
| 31 | 31 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 "(?!${ConstantValueComputer._RESERVED_WORD_RE}\\b(?!\\\$))[a-zA-Z\$][\\w\$ ]*"; | 210 "(?!${ConstantValueComputer._RESERVED_WORD_RE}\\b(?!\\\$))[a-zA-Z\$][\\w\$ ]*"; |
| 211 | 211 |
| 212 /** | 212 /** |
| 213 * RegExp that validates a non-empty non-private symbol. | 213 * RegExp that validates a non-empty non-private symbol. |
| 214 * From sdk/lib/internal/symbol.dart. | 214 * From sdk/lib/internal/symbol.dart. |
| 215 */ | 215 */ |
| 216 static RegExp _PUBLIC_SYMBOL_PATTERN = new RegExp( | 216 static RegExp _PUBLIC_SYMBOL_PATTERN = new RegExp( |
| 217 "^(?:${ConstantValueComputer._OPERATOR_RE}\$|$_PUBLIC_IDENTIFIER_RE(?:=?\$ |[.](?!\$)))+?\$"); | 217 "^(?:${ConstantValueComputer._OPERATOR_RE}\$|$_PUBLIC_IDENTIFIER_RE(?:=?\$ |[.](?!\$)))+?\$"); |
| 218 | 218 |
| 219 /** | 219 /** |
| 220 * The type provider used to access the known types. | 220 * The type system. This is used to gues the types of constants when their |
|
Brian Wilkerson
2015/06/16 21:35:19
"gues" --> "guess"
| |
| 221 * exact value is unknown. | |
| 221 */ | 222 */ |
| 222 final TypeProvider typeProvider; | 223 final TypeSystem typeSystem; |
| 223 | 224 |
| 224 /** | 225 /** |
| 225 * The set of variables declared on the command line using '-D'. | 226 * The set of variables declared on the command line using '-D'. |
| 226 */ | 227 */ |
| 227 final DeclaredVariables _declaredVariables; | 228 final DeclaredVariables _declaredVariables; |
| 228 | 229 |
| 229 /** | 230 /** |
| 230 * Validator used to verify correct dependency analysis when running unit | 231 * Validator used to verify correct dependency analysis when running unit |
| 231 * tests. | 232 * tests. |
| 232 */ | 233 */ |
| 233 final ConstantEvaluationValidator validator; | 234 final ConstantEvaluationValidator validator; |
| 234 | 235 |
| 235 /** | 236 /** |
| 236 * Initialize a newly created [ConstantEvaluationEngine]. The [typeProvider] | 237 * Initialize a newly created [ConstantEvaluationEngine]. The [typeProvider] |
| 237 * is used to access known types. [_declaredVariables] is the set of | 238 * is used to access known types. [_declaredVariables] is the set of |
| 238 * variables declared on the command line using '-D'. The [validator], if | 239 * variables declared on the command line using '-D'. The [validator], if |
| 239 * given, is used to verify correct dependency analysis when running unit | 240 * given, is used to verify correct dependency analysis when running unit |
| 240 * tests. | 241 * tests. |
| 241 */ | 242 */ |
| 242 ConstantEvaluationEngine(this.typeProvider, this._declaredVariables, | 243 ConstantEvaluationEngine(TypeProvider typeProvider, this._declaredVariables, |
| 243 {ConstantEvaluationValidator validator}) | 244 {ConstantEvaluationValidator validator}) |
| 244 : validator = validator != null | 245 : validator = validator != null |
| 245 ? validator | 246 ? validator |
| 246 : new ConstantEvaluationValidator_ForProduction(); | 247 : new ConstantEvaluationValidator_ForProduction(), |
| 248 typeSystem = new TypeSystemImpl(typeProvider); | |
| 249 | |
| 250 /** | |
| 251 * The type provider used to access the known types. | |
| 252 */ | |
| 253 TypeProvider get typeProvider => typeSystem.typeProvider; | |
| 247 | 254 |
| 248 /** | 255 /** |
| 249 * Check that the arguments to a call to fromEnvironment() are correct. The | 256 * Check that the arguments to a call to fromEnvironment() are correct. The |
| 250 * [arguments] are the AST nodes of the arguments. The [argumentValues] are | 257 * [arguments] are the AST nodes of the arguments. The [argumentValues] are |
| 251 * the values of the unnamed arguments. The [namedArgumentValues] are the | 258 * the values of the unnamed arguments. The [namedArgumentValues] are the |
| 252 * values of the named arguments. The [expectedDefaultValueType] is the | 259 * values of the named arguments. The [expectedDefaultValueType] is the |
| 253 * allowed type of the "defaultValue" parameter (if present). Note: | 260 * allowed type of the "defaultValue" parameter (if present). Note: |
| 254 * "defaultValue" is always allowed to be null. Return `true` if the arguments | 261 * "defaultValue" is always allowed to be null. Return `true` if the arguments |
| 255 * are correct, `false` if there is an error. | 262 * are correct, `false` if there is an error. |
| 256 */ | 263 */ |
| (...skipping 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1424 this._dartObjectComputer = | 1431 this._dartObjectComputer = |
| 1425 new DartObjectComputer(_errorReporter, evaluationEngine.typeProvider); | 1432 new DartObjectComputer(_errorReporter, evaluationEngine.typeProvider); |
| 1426 } | 1433 } |
| 1427 | 1434 |
| 1428 /** | 1435 /** |
| 1429 * Convenience getter to gain access to the [evalationEngine]'s type | 1436 * Convenience getter to gain access to the [evalationEngine]'s type |
| 1430 * provider. | 1437 * provider. |
| 1431 */ | 1438 */ |
| 1432 TypeProvider get _typeProvider => evaluationEngine.typeProvider; | 1439 TypeProvider get _typeProvider => evaluationEngine.typeProvider; |
| 1433 | 1440 |
| 1441 /** | |
| 1442 * Convenience getter to gain access to the [evaluationEngine]'s type system. | |
| 1443 */ | |
| 1444 TypeSystem get _typeSystem => evaluationEngine.typeSystem; | |
| 1445 | |
| 1434 @override | 1446 @override |
| 1435 DartObjectImpl visitAdjacentStrings(AdjacentStrings node) { | 1447 DartObjectImpl visitAdjacentStrings(AdjacentStrings node) { |
| 1436 DartObjectImpl result = null; | 1448 DartObjectImpl result = null; |
| 1437 for (StringLiteral string in node.strings) { | 1449 for (StringLiteral string in node.strings) { |
| 1438 if (result == null) { | 1450 if (result == null) { |
| 1439 result = string.accept(this); | 1451 result = string.accept(this); |
| 1440 } else { | 1452 } else { |
| 1441 result = | 1453 result = |
| 1442 _dartObjectComputer.concatenate(node, result, string.accept(this)); | 1454 _dartObjectComputer.concatenate(node, result, string.accept(this)); |
| 1443 } | 1455 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1536 return conditionResult; | 1548 return conditionResult; |
| 1537 } | 1549 } |
| 1538 if (conditionResult.isTrue) { | 1550 if (conditionResult.isTrue) { |
| 1539 return thenResult; | 1551 return thenResult; |
| 1540 } else if (conditionResult.isFalse) { | 1552 } else if (conditionResult.isFalse) { |
| 1541 return elseResult; | 1553 return elseResult; |
| 1542 } | 1554 } |
| 1543 ParameterizedType thenType = thenResult.type; | 1555 ParameterizedType thenType = thenResult.type; |
| 1544 ParameterizedType elseType = elseResult.type; | 1556 ParameterizedType elseType = elseResult.type; |
| 1545 return new DartObjectImpl.validWithUnknownValue( | 1557 return new DartObjectImpl.validWithUnknownValue( |
| 1546 thenType.getLeastUpperBound(elseType) as InterfaceType); | 1558 _typeSystem.getLeastUpperBound(thenType, elseType) as InterfaceType); |
| 1547 } | 1559 } |
| 1548 | 1560 |
| 1549 @override | 1561 @override |
| 1550 DartObjectImpl visitDoubleLiteral(DoubleLiteral node) => | 1562 DartObjectImpl visitDoubleLiteral(DoubleLiteral node) => |
| 1551 new DartObjectImpl(_typeProvider.doubleType, new DoubleState(node.value)); | 1563 new DartObjectImpl(_typeProvider.doubleType, new DoubleState(node.value)); |
| 1552 | 1564 |
| 1553 @override | 1565 @override |
| 1554 DartObjectImpl visitInstanceCreationExpression( | 1566 DartObjectImpl visitInstanceCreationExpression( |
| 1555 InstanceCreationExpression node) { | 1567 InstanceCreationExpression node) { |
| 1556 if (!node.isConst) { | 1568 if (!node.isConst) { |
| (...skipping 3703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5260 return BoolState.from(_element == rightElement); | 5272 return BoolState.from(_element == rightElement); |
| 5261 } else if (rightOperand is DynamicState) { | 5273 } else if (rightOperand is DynamicState) { |
| 5262 return BoolState.UNKNOWN_VALUE; | 5274 return BoolState.UNKNOWN_VALUE; |
| 5263 } | 5275 } |
| 5264 return BoolState.FALSE_STATE; | 5276 return BoolState.FALSE_STATE; |
| 5265 } | 5277 } |
| 5266 | 5278 |
| 5267 @override | 5279 @override |
| 5268 String toString() => _element == null ? "-unknown-" : _element.name; | 5280 String toString() => _element == null ? "-unknown-" : _element.name; |
| 5269 } | 5281 } |
| OLD | NEW |