| 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 'java_core.dart'; | 10 import 'java_core.dart'; |
| 11 import 'java_engine.dart' show ObjectUtilities; | 11 import 'java_engine.dart' show ObjectUtilities; |
| 12 import 'source.dart' show Source; | 12 import 'source.dart' show Source; |
| 13 import 'error.dart' show AnalysisError, ErrorCode, CompileTimeErrorCode; | 13 import 'error.dart' show AnalysisError, ErrorCode, CompileTimeErrorCode; |
| 14 import 'scanner.dart' show Token, TokenType; | 14 import 'scanner.dart' show Token, TokenType; |
| 15 import 'ast.dart'; | 15 import 'ast.dart'; |
| 16 import 'element.dart'; | 16 import 'element.dart'; |
| 17 import 'resolver.dart' show TypeProvider; | 17 import 'resolver.dart' show TypeProvider; |
| 18 import 'engine.dart' show AnalysisEngine; | 18 import 'engine.dart' show AnalysisEngine; |
| 19 import 'utilities_dart.dart' show ParameterKind; | 19 import 'utilities_dart.dart' show ParameterKind; |
| 20 import 'utilities_collection.dart' show DirectedGraph; | 20 import 'utilities_collection.dart'; |
| 21 | 21 |
| 22 /** | 22 /** |
| 23 * Instances of the class `ConstantEvaluator` evaluate constant expressions to p
roduce their | 23 * Instances of the class `ConstantEvaluator` evaluate constant expressions to p
roduce their |
| 24 * compile-time value. According to the Dart Language Specification: <blockquote
> A constant | 24 * compile-time value. According to the Dart Language Specification: <blockquote
> A constant |
| 25 * expression is one of the following: | 25 * expression is one of the following: |
| 26 * * A literal number. | 26 * * A literal number. |
| 27 * * A literal boolean. | 27 * * A literal boolean. |
| 28 * * A literal string where any interpolated expression is a compile-time consta
nt that evaluates | 28 * * A literal string where any interpolated expression is a compile-time consta
nt that evaluates |
| 29 * to a numeric, string or boolean value or to <b>null</b>. | 29 * to a numeric, string or boolean value or to <b>null</b>. |
| 30 * * A literal symbol. | 30 * * A literal symbol. |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 */ | 305 */ |
| 306 void add(CompilationUnit unit) { | 306 void add(CompilationUnit unit) { |
| 307 unit.accept(_constantFinder); | 307 unit.accept(_constantFinder); |
| 308 } | 308 } |
| 309 | 309 |
| 310 /** | 310 /** |
| 311 * Compute values for all of the constant variables in the compilation units t
hat were added. | 311 * Compute values for all of the constant variables in the compilation units t
hat were added. |
| 312 */ | 312 */ |
| 313 void computeValues() { | 313 void computeValues() { |
| 314 _declarationMap = _constantFinder.variableMap; | 314 _declarationMap = _constantFinder.variableMap; |
| 315 for (MapEntry<VariableElement, VariableDeclaration> entry in getMapEntrySet(
_declarationMap)) { | 315 for (MapIterator<VariableElement, VariableDeclaration> iter = SingleMapItera
tor.forMap(_declarationMap); iter.moveNext();) { |
| 316 VariableElement element = entry.getKey(); | 316 VariableElement element = iter.key; |
| 317 ReferenceFinder referenceFinder = new ReferenceFinder(element, _referenceG
raph); | 317 ReferenceFinder referenceFinder = new ReferenceFinder(element, _referenceG
raph); |
| 318 _referenceGraph.addNode(element); | 318 _referenceGraph.addNode(element); |
| 319 entry.getValue().initializer.accept(referenceFinder); | 319 iter.value.initializer.accept(referenceFinder); |
| 320 } | 320 } |
| 321 while (!_referenceGraph.isEmpty) { | 321 while (!_referenceGraph.isEmpty) { |
| 322 VariableElement element = _referenceGraph.removeSink(); | 322 VariableElement element = _referenceGraph.removeSink(); |
| 323 while (element != null) { | 323 while (element != null) { |
| 324 _computeValueFor(element); | 324 _computeValueFor(element); |
| 325 element = _referenceGraph.removeSink(); | 325 element = _referenceGraph.removeSink(); |
| 326 } | 326 } |
| 327 if (!_referenceGraph.isEmpty) { | 327 if (!_referenceGraph.isEmpty) { |
| 328 List<VariableElement> variablesInCycle = _referenceGraph.findCycle(); | 328 List<VariableElement> variablesInCycle = _referenceGraph.findCycle(); |
| 329 if (variablesInCycle == null) { | 329 if (variablesInCycle == null) { |
| (...skipping 3601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3931 if (object is! MapState) { | 3931 if (object is! MapState) { |
| 3932 return false; | 3932 return false; |
| 3933 } | 3933 } |
| 3934 Map<DartObjectImpl, DartObjectImpl> otherElements = (object as MapState)._en
tries; | 3934 Map<DartObjectImpl, DartObjectImpl> otherElements = (object as MapState)._en
tries; |
| 3935 int count = _entries.length; | 3935 int count = _entries.length; |
| 3936 if (otherElements.length != count) { | 3936 if (otherElements.length != count) { |
| 3937 return false; | 3937 return false; |
| 3938 } else if (count == 0) { | 3938 } else if (count == 0) { |
| 3939 return true; | 3939 return true; |
| 3940 } | 3940 } |
| 3941 for (MapEntry<DartObjectImpl, DartObjectImpl> entry in getMapEntrySet(_entri
es)) { | 3941 for (MapIterator<DartObjectImpl, DartObjectImpl> iter = SingleMapIterator.fo
rMap(_entries); iter.moveNext();) { |
| 3942 DartObjectImpl key = entry.getKey(); | 3942 DartObjectImpl key = iter.key; |
| 3943 DartObjectImpl value = entry.getValue(); | 3943 DartObjectImpl value = iter.value; |
| 3944 DartObjectImpl otherValue = otherElements[key]; | 3944 DartObjectImpl otherValue = otherElements[key]; |
| 3945 if (value != otherValue) { | 3945 if (value != otherValue) { |
| 3946 return false; | 3946 return false; |
| 3947 } | 3947 } |
| 3948 } | 3948 } |
| 3949 return true; | 3949 return true; |
| 3950 } | 3950 } |
| 3951 | 3951 |
| 3952 @override | 3952 @override |
| 3953 String get typeName => "Map"; | 3953 String get typeName => "Map"; |
| 3954 | 3954 |
| 3955 @override | 3955 @override |
| 3956 Map<Object, Object> get value { | 3956 Map<Object, Object> get value { |
| 3957 Map<Object, Object> result = new Map<Object, Object>(); | 3957 Map<Object, Object> result = new Map<Object, Object>(); |
| 3958 for (MapEntry<DartObjectImpl, DartObjectImpl> entry in getMapEntrySet(_entri
es)) { | 3958 for (MapIterator<DartObjectImpl, DartObjectImpl> iter = SingleMapIterator.fo
rMap(_entries); iter.moveNext();) { |
| 3959 DartObjectImpl key = entry.getKey(); | 3959 DartObjectImpl key = iter.key; |
| 3960 DartObjectImpl value = entry.getValue(); | 3960 DartObjectImpl value = iter.value; |
| 3961 if (!key.hasExactValue || !value.hasExactValue) { | 3961 if (!key.hasExactValue || !value.hasExactValue) { |
| 3962 return null; | 3962 return null; |
| 3963 } | 3963 } |
| 3964 result[key.value] = value.value; | 3964 result[key.value] = value.value; |
| 3965 } | 3965 } |
| 3966 return result; | 3966 return result; |
| 3967 } | 3967 } |
| 3968 | 3968 |
| 3969 @override | 3969 @override |
| 3970 bool get hasExactValue { | 3970 bool get hasExactValue { |
| 3971 for (MapEntry<DartObjectImpl, DartObjectImpl> entry in getMapEntrySet(_entri
es)) { | 3971 for (MapIterator<DartObjectImpl, DartObjectImpl> iter = SingleMapIterator.fo
rMap(_entries); iter.moveNext();) { |
| 3972 if (!entry.getKey().hasExactValue || !entry.getValue().hasExactValue) { | 3972 if (!iter.key.hasExactValue || !iter.value.hasExactValue) { |
| 3973 return false; | 3973 return false; |
| 3974 } | 3974 } |
| 3975 } | 3975 } |
| 3976 return true; | 3976 return true; |
| 3977 } | 3977 } |
| 3978 | 3978 |
| 3979 @override | 3979 @override |
| 3980 int get hashCode { | 3980 int get hashCode { |
| 3981 int value = 0; | 3981 int value = 0; |
| 3982 for (DartObjectImpl key in _entries.keys.toSet()) { | 3982 for (DartObjectImpl key in _entries.keys.toSet()) { |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4329 | 4329 |
| 4330 @override | 4330 @override |
| 4331 String get typeName => "Type"; | 4331 String get typeName => "Type"; |
| 4332 | 4332 |
| 4333 @override | 4333 @override |
| 4334 int get hashCode => _element == null ? 0 : _element.hashCode; | 4334 int get hashCode => _element == null ? 0 : _element.hashCode; |
| 4335 | 4335 |
| 4336 @override | 4336 @override |
| 4337 String toString() => _element == null ? "-unknown-" : _element.name; | 4337 String toString() => _element == null ? "-unknown-" : _element.name; |
| 4338 } | 4338 } |
| OLD | NEW |