| 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 'java_core.dart'; | 11 import 'java_core.dart'; |
| 11 import 'java_engine.dart' show ObjectUtilities; | 12 import 'java_engine.dart' show ObjectUtilities; |
| 12 import 'source.dart' show Source; | 13 import 'source.dart' show Source; |
| 13 import 'error.dart' show AnalysisError, ErrorCode, CompileTimeErrorCode; | 14 import 'error.dart' show AnalysisError, ErrorCode, CompileTimeErrorCode; |
| 14 import 'scanner.dart' show Token, TokenType; | 15 import 'scanner.dart' show Token, TokenType; |
| 15 import 'ast.dart'; | 16 import 'ast.dart'; |
| 16 import 'element.dart'; | 17 import 'element.dart'; |
| 17 import 'resolver.dart' show TypeProvider; | 18 import 'resolver.dart' show TypeProvider; |
| 18 import 'engine.dart' show AnalysisEngine; | 19 import 'engine.dart' show AnalysisEngine; |
| 19 import 'utilities_dart.dart' show ParameterKind; | 20 import 'utilities_dart.dart' show ParameterKind; |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 | 223 |
| 223 /** | 224 /** |
| 224 * Instances of the class `ConstantFinder` are used to traverse the AST structur
es of all of | 225 * Instances of the class `ConstantFinder` are used to traverse the AST structur
es of all of |
| 225 * the compilation units being resolved and build a table mapping constant varia
ble elements to the | 226 * the compilation units being resolved and build a table mapping constant varia
ble elements to the |
| 226 * declarations of those variables. | 227 * declarations of those variables. |
| 227 */ | 228 */ |
| 228 class ConstantFinder extends RecursiveAstVisitor<Object> { | 229 class ConstantFinder extends RecursiveAstVisitor<Object> { |
| 229 /** | 230 /** |
| 230 * A table mapping constant variable elements to the declarations of those var
iables. | 231 * A table mapping constant variable elements to the declarations of those var
iables. |
| 231 */ | 232 */ |
| 232 final Map<VariableElement, VariableDeclaration> variableMap = new Map<Variable
Element, VariableDeclaration>(); | 233 final HashMap<VariableElement, VariableDeclaration> variableMap = new HashMap<
VariableElement, VariableDeclaration>(); |
| 233 | 234 |
| 234 /** | 235 /** |
| 235 * A table mapping constant constructors to the declarations of those construc
tors. | 236 * A table mapping constant constructors to the declarations of those construc
tors. |
| 236 */ | 237 */ |
| 237 final Map<ConstructorElement, ConstructorDeclaration> constructorMap = new Map
<ConstructorElement, ConstructorDeclaration>(); | 238 final HashMap<ConstructorElement, ConstructorDeclaration> constructorMap = new
HashMap<ConstructorElement, ConstructorDeclaration>(); |
| 238 | 239 |
| 239 /** | 240 /** |
| 240 * A collection of constant constructor invocations. | 241 * A collection of constant constructor invocations. |
| 241 */ | 242 */ |
| 242 final List<InstanceCreationExpression> constructorInvocations = new List<Insta
nceCreationExpression>(); | 243 final List<InstanceCreationExpression> constructorInvocations = new List<Insta
nceCreationExpression>(); |
| 243 | 244 |
| 244 @override | 245 @override |
| 245 Object visitConstructorDeclaration(ConstructorDeclaration node) { | 246 Object visitConstructorDeclaration(ConstructorDeclaration node) { |
| 246 super.visitConstructorDeclaration(node); | 247 super.visitConstructorDeclaration(node); |
| 247 if (node.constKeyword != null) { | 248 if (node.constKeyword != null) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 | 299 |
| 299 /** | 300 /** |
| 300 * A graph in which the nodes are the constants, and the edges are from each c
onstant to the other | 301 * A graph in which the nodes are the constants, and the edges are from each c
onstant to the other |
| 301 * constants that are referenced by it. | 302 * constants that are referenced by it. |
| 302 */ | 303 */ |
| 303 DirectedGraph<AstNode> referenceGraph = new DirectedGraph<AstNode>(); | 304 DirectedGraph<AstNode> referenceGraph = new DirectedGraph<AstNode>(); |
| 304 | 305 |
| 305 /** | 306 /** |
| 306 * A table mapping constant variables to the declarations of those variables. | 307 * A table mapping constant variables to the declarations of those variables. |
| 307 */ | 308 */ |
| 308 Map<VariableElement, VariableDeclaration> _variableDeclarationMap; | 309 HashMap<VariableElement, VariableDeclaration> _variableDeclarationMap; |
| 309 | 310 |
| 310 /** | 311 /** |
| 311 * A table mapping constant constructors to the declarations of those construc
tors. | 312 * A table mapping constant constructors to the declarations of those construc
tors. |
| 312 */ | 313 */ |
| 313 Map<ConstructorElement, ConstructorDeclaration> constructorDeclarationMap; | 314 HashMap<ConstructorElement, ConstructorDeclaration> constructorDeclarationMap; |
| 314 | 315 |
| 315 /** | 316 /** |
| 316 * A collection of constant constructor invocations. | 317 * A collection of constant constructor invocations. |
| 317 */ | 318 */ |
| 318 List<InstanceCreationExpression> _constructorInvocations; | 319 List<InstanceCreationExpression> _constructorInvocations; |
| 319 | 320 |
| 320 /** | 321 /** |
| 321 * Initialize a newly created constant value computer. | 322 * Initialize a newly created constant value computer. |
| 322 * | 323 * |
| 323 * @param typeProvider the type provider used to access known types | 324 * @param typeProvider the type provider used to access known types |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 } else { | 485 } else { |
| 485 // Should not happen. | 486 // Should not happen. |
| 486 AnalysisEngine.instance.logger.logError("Constant value computer trying to
compute the value of a node which is not a VariableDeclaration, InstanceCreatio
nExpression, FormalParameter, or ConstructorDeclaration"); | 487 AnalysisEngine.instance.logger.logError("Constant value computer trying to
compute the value of a node which is not a VariableDeclaration, InstanceCreatio
nExpression, FormalParameter, or ConstructorDeclaration"); |
| 487 return; | 488 return; |
| 488 } | 489 } |
| 489 } | 490 } |
| 490 | 491 |
| 491 ValidResult _evaluateConstructorCall(NodeList<Expression> arguments, Construct
orElement constructor, ConstantVisitor constantVisitor) { | 492 ValidResult _evaluateConstructorCall(NodeList<Expression> arguments, Construct
orElement constructor, ConstantVisitor constantVisitor) { |
| 492 int argumentCount = arguments.length; | 493 int argumentCount = arguments.length; |
| 493 List<DartObjectImpl> argumentValues = new List<DartObjectImpl>(argumentCount
); | 494 List<DartObjectImpl> argumentValues = new List<DartObjectImpl>(argumentCount
); |
| 494 Map<String, DartObjectImpl> namedArgumentValues = new Map<String, DartObject
Impl>(); | 495 HashMap<String, DartObjectImpl> namedArgumentValues = new HashMap<String, Da
rtObjectImpl>(); |
| 495 for (int i = 0; i < argumentCount; i++) { | 496 for (int i = 0; i < argumentCount; i++) { |
| 496 Expression argument = arguments[i]; | 497 Expression argument = arguments[i]; |
| 497 if (argument is NamedExpression) { | 498 if (argument is NamedExpression) { |
| 498 NamedExpression namedExpression = argument; | 499 NamedExpression namedExpression = argument; |
| 499 String name = namedExpression.name.label.name; | 500 String name = namedExpression.name.label.name; |
| 500 namedArgumentValues[name] = constantVisitor._valueOf(namedExpression.exp
ression); | 501 namedArgumentValues[name] = constantVisitor._valueOf(namedExpression.exp
ression); |
| 501 argumentValues[i] = constantVisitor.null2; | 502 argumentValues[i] = constantVisitor.null2; |
| 502 } else { | 503 } else { |
| 503 argumentValues[i] = constantVisitor._valueOf(argument); | 504 argumentValues[i] = constantVisitor._valueOf(argument); |
| 504 } | 505 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 527 beforeGetConstantInitializers(constructor); | 528 beforeGetConstantInitializers(constructor); |
| 528 ConstructorElementImpl constructorBase = _getConstructorBase(constructor) as
ConstructorElementImpl; | 529 ConstructorElementImpl constructorBase = _getConstructorBase(constructor) as
ConstructorElementImpl; |
| 529 List<ConstructorInitializer> initializers = constructorBase.constantInitiali
zers; | 530 List<ConstructorInitializer> initializers = constructorBase.constantInitiali
zers; |
| 530 if (initializers == null) { | 531 if (initializers == null) { |
| 531 // This can happen in some cases where there are compile errors in the cod
e being analyzed | 532 // This can happen in some cases where there are compile errors in the cod
e being analyzed |
| 532 // (for example if the code is trying to create a const instance using a n
on-const | 533 // (for example if the code is trying to create a const instance using a n
on-const |
| 533 // constructor, or the node we're visiting is involved in a cycle). The e
rror has already | 534 // constructor, or the node we're visiting is involved in a cycle). The e
rror has already |
| 534 // been reported, so consider it an unknown value to suppress further erro
rs. | 535 // been reported, so consider it an unknown value to suppress further erro
rs. |
| 535 return constantVisitor._validWithUnknownValue(definingClass); | 536 return constantVisitor._validWithUnknownValue(definingClass); |
| 536 } | 537 } |
| 537 Map<String, DartObjectImpl> fieldMap = new Map<String, DartObjectImpl>(); | 538 HashMap<String, DartObjectImpl> fieldMap = new HashMap<String, DartObjectImp
l>(); |
| 538 Map<String, DartObjectImpl> parameterMap = new Map<String, DartObjectImpl>()
; | 539 HashMap<String, DartObjectImpl> parameterMap = new HashMap<String, DartObjec
tImpl>(); |
| 539 List<ParameterElement> parameters = constructorBase.parameters; | 540 List<ParameterElement> parameters = constructorBase.parameters; |
| 540 int parameterCount = parameters.length; | 541 int parameterCount = parameters.length; |
| 541 for (int i = 0; i < parameterCount; i++) { | 542 for (int i = 0; i < parameterCount; i++) { |
| 542 ParameterElement parameter = parameters[i]; | 543 ParameterElement parameter = parameters[i]; |
| 543 while (parameter is ParameterMember) { | 544 while (parameter is ParameterMember) { |
| 544 parameter = (parameter as ParameterMember).baseElement; | 545 parameter = (parameter as ParameterMember).baseElement; |
| 545 } | 546 } |
| 546 DartObjectImpl argumentValue = null; | 547 DartObjectImpl argumentValue = null; |
| 547 if (parameter.parameterKind == ParameterKind.NAMED) { | 548 if (parameter.parameterKind == ParameterKind.NAMED) { |
| 548 argumentValue = namedArgumentValues[parameter.name]; | 549 argumentValue = namedArgumentValues[parameter.name]; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 if (superConstructor != null) { | 604 if (superConstructor != null) { |
| 604 if (superArguments == null) { | 605 if (superArguments == null) { |
| 605 superArguments = new NodeList<Expression>(null); | 606 superArguments = new NodeList<Expression>(null); |
| 606 } | 607 } |
| 607 _evaluateSuperConstructorCall(fieldMap, superConstructor, superArguments
, initializerVisitor); | 608 _evaluateSuperConstructorCall(fieldMap, superConstructor, superArguments
, initializerVisitor); |
| 608 } | 609 } |
| 609 } | 610 } |
| 610 return constantVisitor._valid(definingClass, new GenericState(fieldMap)); | 611 return constantVisitor._valid(definingClass, new GenericState(fieldMap)); |
| 611 } | 612 } |
| 612 | 613 |
| 613 void _evaluateSuperConstructorCall(Map<String, DartObjectImpl> fieldMap, Const
ructorElement superConstructor, NodeList<Expression> superArguments, ConstantVis
itor initializerVisitor) { | 614 void _evaluateSuperConstructorCall(HashMap<String, DartObjectImpl> fieldMap, C
onstructorElement superConstructor, NodeList<Expression> superArguments, Constan
tVisitor initializerVisitor) { |
| 614 if (superConstructor != null && superConstructor.isConst) { | 615 if (superConstructor != null && superConstructor.isConst) { |
| 615 ValidResult evaluationResult = _evaluateConstructorCall(superArguments, su
perConstructor, initializerVisitor); | 616 ValidResult evaluationResult = _evaluateConstructorCall(superArguments, su
perConstructor, initializerVisitor); |
| 616 fieldMap[GenericState.SUPERCLASS_FIELD] = evaluationResult.value; | 617 fieldMap[GenericState.SUPERCLASS_FIELD] = evaluationResult.value; |
| 617 } | 618 } |
| 618 } | 619 } |
| 619 | 620 |
| 620 /** | 621 /** |
| 621 * Attempt to follow the chain of factory redirections until a constructor is
reached which is not | 622 * Attempt to follow the chain of factory redirections until a constructor is
reached which is not |
| 622 * a const factory constructor. | 623 * a const factory constructor. |
| 623 * | 624 * |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 /** | 752 /** |
| 752 * The type provider used to access the known types. | 753 * The type provider used to access the known types. |
| 753 */ | 754 */ |
| 754 final TypeProvider _typeProvider; | 755 final TypeProvider _typeProvider; |
| 755 | 756 |
| 756 /** | 757 /** |
| 757 * An shared object representing the value 'null'. | 758 * An shared object representing the value 'null'. |
| 758 */ | 759 */ |
| 759 DartObjectImpl _nullObject; | 760 DartObjectImpl _nullObject; |
| 760 | 761 |
| 761 Map<String, DartObjectImpl> _lexicalEnvironment; | 762 HashMap<String, DartObjectImpl> _lexicalEnvironment; |
| 762 | 763 |
| 763 /** | 764 /** |
| 764 * Initialize a newly created constant visitor. | 765 * Initialize a newly created constant visitor. |
| 765 * | 766 * |
| 766 * @param typeProvider the type provider used to access known types | 767 * @param typeProvider the type provider used to access known types |
| 767 * @param lexicalEnvironment values which should override simpleIdentifiers, o
r null if no | 768 * @param lexicalEnvironment values which should override simpleIdentifiers, o
r null if no |
| 768 * overriding is necessary. | 769 * overriding is necessary. |
| 769 */ | 770 */ |
| 770 ConstantVisitor.con1(this._typeProvider) { | 771 ConstantVisitor.con1(this._typeProvider) { |
| 771 this._lexicalEnvironment = null; | 772 this._lexicalEnvironment = null; |
| 772 } | 773 } |
| 773 | 774 |
| 774 /** | 775 /** |
| 775 * Initialize a newly created constant visitor. | 776 * Initialize a newly created constant visitor. |
| 776 * | 777 * |
| 777 * @param typeProvider the type provider used to access known types | 778 * @param typeProvider the type provider used to access known types |
| 778 * @param lexicalEnvironment values which should override simpleIdentifiers, o
r null if no | 779 * @param lexicalEnvironment values which should override simpleIdentifiers, o
r null if no |
| 779 * overriding is necessary. | 780 * overriding is necessary. |
| 780 */ | 781 */ |
| 781 ConstantVisitor.con2(this._typeProvider, Map<String, DartObjectImpl> lexicalEn
vironment) { | 782 ConstantVisitor.con2(this._typeProvider, HashMap<String, DartObjectImpl> lexic
alEnvironment) { |
| 782 this._lexicalEnvironment = lexicalEnvironment; | 783 this._lexicalEnvironment = lexicalEnvironment; |
| 783 } | 784 } |
| 784 | 785 |
| 785 @override | 786 @override |
| 786 EvaluationResultImpl visitAdjacentStrings(AdjacentStrings node) { | 787 EvaluationResultImpl visitAdjacentStrings(AdjacentStrings node) { |
| 787 EvaluationResultImpl result = null; | 788 EvaluationResultImpl result = null; |
| 788 for (StringLiteral string in node.strings) { | 789 for (StringLiteral string in node.strings) { |
| 789 if (result == null) { | 790 if (result == null) { |
| 790 result = string.accept(this); | 791 result = string.accept(this); |
| 791 } else { | 792 } else { |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 } | 940 } |
| 940 return _valid(_typeProvider.listType, new ListState(new List.from(elements))
); | 941 return _valid(_typeProvider.listType, new ListState(new List.from(elements))
); |
| 941 } | 942 } |
| 942 | 943 |
| 943 @override | 944 @override |
| 944 EvaluationResultImpl visitMapLiteral(MapLiteral node) { | 945 EvaluationResultImpl visitMapLiteral(MapLiteral node) { |
| 945 if (node.constKeyword == null) { | 946 if (node.constKeyword == null) { |
| 946 return new ErrorResult.con1(node, CompileTimeErrorCode.MISSING_CONST_IN_MA
P_LITERAL); | 947 return new ErrorResult.con1(node, CompileTimeErrorCode.MISSING_CONST_IN_MA
P_LITERAL); |
| 947 } | 948 } |
| 948 ErrorResult result = null; | 949 ErrorResult result = null; |
| 949 Map<DartObjectImpl, DartObjectImpl> map = new Map<DartObjectImpl, DartObject
Impl>(); | 950 HashMap<DartObjectImpl, DartObjectImpl> map = new HashMap<DartObjectImpl, Da
rtObjectImpl>(); |
| 950 for (MapLiteralEntry entry in node.entries) { | 951 for (MapLiteralEntry entry in node.entries) { |
| 951 EvaluationResultImpl keyResult = entry.key.accept(this); | 952 EvaluationResultImpl keyResult = entry.key.accept(this); |
| 952 EvaluationResultImpl valueResult = entry.value.accept(this); | 953 EvaluationResultImpl valueResult = entry.value.accept(this); |
| 953 result = _union(result, keyResult); | 954 result = _union(result, keyResult); |
| 954 result = _union(result, valueResult); | 955 result = _union(result, valueResult); |
| 955 if (keyResult is ValidResult && valueResult is ValidResult) { | 956 if (keyResult is ValidResult && valueResult is ValidResult) { |
| 956 map[keyResult.value] = valueResult.value; | 957 map[keyResult.value] = valueResult.value; |
| 957 } | 958 } |
| 958 } | 959 } |
| 959 if (result != null) { | 960 if (result != null) { |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1432 } | 1433 } |
| 1433 | 1434 |
| 1434 @override | 1435 @override |
| 1435 double get doubleValue { | 1436 double get doubleValue { |
| 1436 if (_state is DoubleState) { | 1437 if (_state is DoubleState) { |
| 1437 return (_state as DoubleState).value; | 1438 return (_state as DoubleState).value; |
| 1438 } | 1439 } |
| 1439 return null; | 1440 return null; |
| 1440 } | 1441 } |
| 1441 | 1442 |
| 1442 Map<String, DartObjectImpl> get fields => _state.fields; | 1443 HashMap<String, DartObjectImpl> get fields => _state.fields; |
| 1443 | 1444 |
| 1444 @override | 1445 @override |
| 1445 int get intValue { | 1446 int get intValue { |
| 1446 if (_state is IntState) { | 1447 if (_state is IntState) { |
| 1447 return (_state as IntState).value; | 1448 return (_state as IntState).value; |
| 1448 } | 1449 } |
| 1449 return null; | 1450 return null; |
| 1450 } | 1451 } |
| 1451 | 1452 |
| 1452 @override | 1453 @override |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1722 } | 1723 } |
| 1723 | 1724 |
| 1724 /** | 1725 /** |
| 1725 * Instances of the class `DeclaredVariables` provide access to the values of va
riables that | 1726 * Instances of the class `DeclaredVariables` provide access to the values of va
riables that |
| 1726 * have been defined on the command line using the `-D` option. | 1727 * have been defined on the command line using the `-D` option. |
| 1727 */ | 1728 */ |
| 1728 class DeclaredVariables { | 1729 class DeclaredVariables { |
| 1729 /** | 1730 /** |
| 1730 * A table mapping the names of declared variables to their values. | 1731 * A table mapping the names of declared variables to their values. |
| 1731 */ | 1732 */ |
| 1732 Map<String, String> _declaredVariables = new Map<String, String>(); | 1733 HashMap<String, String> _declaredVariables = new HashMap<String, String>(); |
| 1733 | 1734 |
| 1734 /** | 1735 /** |
| 1735 * Define a variable with the given name to have the given value. | 1736 * Define a variable with the given name to have the given value. |
| 1736 * | 1737 * |
| 1737 * @param variableName the name of the variable being defined | 1738 * @param variableName the name of the variable being defined |
| 1738 * @param value the value of the variable | 1739 * @param value the value of the variable |
| 1739 */ | 1740 */ |
| 1740 void define(String variableName, String value) { | 1741 void define(String variableName, String value) { |
| 1741 _declaredVariables[variableName] = value; | 1742 _declaredVariables[variableName] = value; |
| 1742 } | 1743 } |
| (...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2814 } | 2815 } |
| 2815 | 2816 |
| 2816 /** | 2817 /** |
| 2817 * Instances of the class `GenericState` represent the state of an object repres
enting a Dart | 2818 * Instances of the class `GenericState` represent the state of an object repres
enting a Dart |
| 2818 * object for which there is no more specific state. | 2819 * object for which there is no more specific state. |
| 2819 */ | 2820 */ |
| 2820 class GenericState extends InstanceState { | 2821 class GenericState extends InstanceState { |
| 2821 /** | 2822 /** |
| 2822 * The values of the fields of this instance. | 2823 * The values of the fields of this instance. |
| 2823 */ | 2824 */ |
| 2824 final Map<String, DartObjectImpl> _fieldMap; | 2825 final HashMap<String, DartObjectImpl> _fieldMap; |
| 2825 | 2826 |
| 2826 /** | 2827 /** |
| 2827 * Pseudo-field that we use to represent fields in the superclass. | 2828 * Pseudo-field that we use to represent fields in the superclass. |
| 2828 */ | 2829 */ |
| 2829 static String SUPERCLASS_FIELD = "(super)"; | 2830 static String SUPERCLASS_FIELD = "(super)"; |
| 2830 | 2831 |
| 2831 /** | 2832 /** |
| 2832 * A state that can be used to represent an object whose state is not known. | 2833 * A state that can be used to represent an object whose state is not known. |
| 2833 */ | 2834 */ |
| 2834 static GenericState UNKNOWN_VALUE = new GenericState(new Map<String, DartObjec
tImpl>()); | 2835 static GenericState UNKNOWN_VALUE = new GenericState(new HashMap<String, DartO
bjectImpl>()); |
| 2835 | 2836 |
| 2836 /** | 2837 /** |
| 2837 * Initialize a newly created state to represent a newly created object. | 2838 * Initialize a newly created state to represent a newly created object. |
| 2838 * | 2839 * |
| 2839 * @param fieldMap the values of the fields of this instance | 2840 * @param fieldMap the values of the fields of this instance |
| 2840 */ | 2841 */ |
| 2841 GenericState(this._fieldMap); | 2842 GenericState(this._fieldMap); |
| 2842 | 2843 |
| 2843 @override | 2844 @override |
| 2844 StringState convertToString() => StringState.UNKNOWN_VALUE; | 2845 StringState convertToString() => StringState.UNKNOWN_VALUE; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2867 } | 2868 } |
| 2868 for (String fieldName in otherFields) { | 2869 for (String fieldName in otherFields) { |
| 2869 if (state._fieldMap[fieldName] != _fieldMap[fieldName]) { | 2870 if (state._fieldMap[fieldName] != _fieldMap[fieldName]) { |
| 2870 return false; | 2871 return false; |
| 2871 } | 2872 } |
| 2872 } | 2873 } |
| 2873 return true; | 2874 return true; |
| 2874 } | 2875 } |
| 2875 | 2876 |
| 2876 @override | 2877 @override |
| 2877 Map<String, DartObjectImpl> get fields => _fieldMap; | 2878 HashMap<String, DartObjectImpl> get fields => _fieldMap; |
| 2878 | 2879 |
| 2879 @override | 2880 @override |
| 2880 String get typeName => "user defined type"; | 2881 String get typeName => "user defined type"; |
| 2881 | 2882 |
| 2882 @override | 2883 @override |
| 2883 int get hashCode { | 2884 int get hashCode { |
| 2884 int hashCode = 0; | 2885 int hashCode = 0; |
| 2885 for (DartObjectImpl value in _fieldMap.values) { | 2886 for (DartObjectImpl value in _fieldMap.values) { |
| 2886 hashCode += value.hashCode; | 2887 hashCode += value.hashCode; |
| 2887 } | 2888 } |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3007 * @param rightOperand the right-hand operand of the operation | 3008 * @param rightOperand the right-hand operand of the operation |
| 3008 * @return the result of invoking the '==' operator on this object with the gi
ven argument | 3009 * @return the result of invoking the '==' operator on this object with the gi
ven argument |
| 3009 * @throws EvaluationException if the operator is not appropriate for an objec
t of this kind | 3010 * @throws EvaluationException if the operator is not appropriate for an objec
t of this kind |
| 3010 */ | 3011 */ |
| 3011 BoolState equalEqual(InstanceState rightOperand); | 3012 BoolState equalEqual(InstanceState rightOperand); |
| 3012 | 3013 |
| 3013 /** | 3014 /** |
| 3014 * If this represents a generic dart object, return a map from its fieldnames
to their values. | 3015 * If this represents a generic dart object, return a map from its fieldnames
to their values. |
| 3015 * Otherwise return null. | 3016 * Otherwise return null. |
| 3016 */ | 3017 */ |
| 3017 Map<String, DartObjectImpl> get fields => null; | 3018 HashMap<String, DartObjectImpl> get fields => null; |
| 3018 | 3019 |
| 3019 /** | 3020 /** |
| 3020 * Return the name of the type of this value. | 3021 * Return the name of the type of this value. |
| 3021 * | 3022 * |
| 3022 * @return the name of the type of this value | 3023 * @return the name of the type of this value |
| 3023 */ | 3024 */ |
| 3024 String get typeName; | 3025 String get typeName; |
| 3025 | 3026 |
| 3026 /** | 3027 /** |
| 3027 * Return this object's value if it can be represented exactly, or `null` if e
ither the | 3028 * Return this object's value if it can be represented exactly, or `null` if e
ither the |
| (...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3835 } | 3836 } |
| 3836 | 3837 |
| 3837 /** | 3838 /** |
| 3838 * The unique instance of the class `ListState` represents the state of an objec
t representing | 3839 * The unique instance of the class `ListState` represents the state of an objec
t representing |
| 3839 * a map. | 3840 * a map. |
| 3840 */ | 3841 */ |
| 3841 class MapState extends InstanceState { | 3842 class MapState extends InstanceState { |
| 3842 /** | 3843 /** |
| 3843 * The entries in the map. | 3844 * The entries in the map. |
| 3844 */ | 3845 */ |
| 3845 final Map<DartObjectImpl, DartObjectImpl> _entries; | 3846 final HashMap<DartObjectImpl, DartObjectImpl> _entries; |
| 3846 | 3847 |
| 3847 /** | 3848 /** |
| 3848 * Initialize a newly created state to represent a map with the given entries. | 3849 * Initialize a newly created state to represent a map with the given entries. |
| 3849 * | 3850 * |
| 3850 * @param entries the entries in the map | 3851 * @param entries the entries in the map |
| 3851 */ | 3852 */ |
| 3852 MapState(this._entries); | 3853 MapState(this._entries); |
| 3853 | 3854 |
| 3854 @override | 3855 @override |
| 3855 StringState convertToString() => StringState.UNKNOWN_VALUE; | 3856 StringState convertToString() => StringState.UNKNOWN_VALUE; |
| 3856 | 3857 |
| 3857 @override | 3858 @override |
| 3858 BoolState equalEqual(InstanceState rightOperand) { | 3859 BoolState equalEqual(InstanceState rightOperand) { |
| 3859 assertBoolNumStringOrNull(rightOperand); | 3860 assertBoolNumStringOrNull(rightOperand); |
| 3860 if (rightOperand is DynamicState) { | 3861 if (rightOperand is DynamicState) { |
| 3861 return BoolState.UNKNOWN_VALUE; | 3862 return BoolState.UNKNOWN_VALUE; |
| 3862 } | 3863 } |
| 3863 return BoolState.from(this == rightOperand); | 3864 return BoolState.from(this == rightOperand); |
| 3864 } | 3865 } |
| 3865 | 3866 |
| 3866 @override | 3867 @override |
| 3867 bool operator ==(Object object) { | 3868 bool operator ==(Object object) { |
| 3868 if (object is! MapState) { | 3869 if (object is! MapState) { |
| 3869 return false; | 3870 return false; |
| 3870 } | 3871 } |
| 3871 Map<DartObjectImpl, DartObjectImpl> otherElements = (object as MapState)._en
tries; | 3872 HashMap<DartObjectImpl, DartObjectImpl> otherElements = (object as MapState)
._entries; |
| 3872 int count = _entries.length; | 3873 int count = _entries.length; |
| 3873 if (otherElements.length != count) { | 3874 if (otherElements.length != count) { |
| 3874 return false; | 3875 return false; |
| 3875 } else if (count == 0) { | 3876 } else if (count == 0) { |
| 3876 return true; | 3877 return true; |
| 3877 } | 3878 } |
| 3878 for (MapEntry<DartObjectImpl, DartObjectImpl> entry in getMapEntrySet(_entri
es)) { | 3879 for (MapEntry<DartObjectImpl, DartObjectImpl> entry in getMapEntrySet(_entri
es)) { |
| 3879 DartObjectImpl key = entry.getKey(); | 3880 DartObjectImpl key = entry.getKey(); |
| 3880 DartObjectImpl value = entry.getValue(); | 3881 DartObjectImpl value = entry.getValue(); |
| 3881 DartObjectImpl otherValue = otherElements[key]; | 3882 DartObjectImpl otherValue = otherElements[key]; |
| 3882 if (value != otherValue) { | 3883 if (value != otherValue) { |
| 3883 return false; | 3884 return false; |
| 3884 } | 3885 } |
| 3885 } | 3886 } |
| 3886 return true; | 3887 return true; |
| 3887 } | 3888 } |
| 3888 | 3889 |
| 3889 @override | 3890 @override |
| 3890 String get typeName => "Map"; | 3891 String get typeName => "Map"; |
| 3891 | 3892 |
| 3892 @override | 3893 @override |
| 3893 Map<Object, Object> get value { | 3894 Map<Object, Object> get value { |
| 3894 Map<Object, Object> result = new Map<Object, Object>(); | 3895 HashMap<Object, Object> result = new HashMap<Object, Object>(); |
| 3895 for (MapEntry<DartObjectImpl, DartObjectImpl> entry in getMapEntrySet(_entri
es)) { | 3896 for (MapEntry<DartObjectImpl, DartObjectImpl> entry in getMapEntrySet(_entri
es)) { |
| 3896 DartObjectImpl key = entry.getKey(); | 3897 DartObjectImpl key = entry.getKey(); |
| 3897 DartObjectImpl value = entry.getValue(); | 3898 DartObjectImpl value = entry.getValue(); |
| 3898 if (!key.hasExactValue || !value.hasExactValue) { | 3899 if (!key.hasExactValue || !value.hasExactValue) { |
| 3899 return null; | 3900 return null; |
| 3900 } | 3901 } |
| 3901 result[key.value] = value.value; | 3902 result[key.value] = value.value; |
| 3902 } | 3903 } |
| 3903 return result; | 3904 return result; |
| 3904 } | 3905 } |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4096 | 4097 |
| 4097 /** | 4098 /** |
| 4098 * A graph in which the nodes are the constant variables and the edges are fro
m each variable to | 4099 * A graph in which the nodes are the constant variables and the edges are fro
m each variable to |
| 4099 * the other constant variables that are referenced in the head's initializer. | 4100 * the other constant variables that are referenced in the head's initializer. |
| 4100 */ | 4101 */ |
| 4101 final DirectedGraph<AstNode> _referenceGraph; | 4102 final DirectedGraph<AstNode> _referenceGraph; |
| 4102 | 4103 |
| 4103 /** | 4104 /** |
| 4104 * A table mapping constant variables to the declarations of those variables. | 4105 * A table mapping constant variables to the declarations of those variables. |
| 4105 */ | 4106 */ |
| 4106 final Map<VariableElement, VariableDeclaration> _variableDeclarationMap; | 4107 final HashMap<VariableElement, VariableDeclaration> _variableDeclarationMap; |
| 4107 | 4108 |
| 4108 /** | 4109 /** |
| 4109 * A table mapping constant constructors to the declarations of those construc
tors. | 4110 * A table mapping constant constructors to the declarations of those construc
tors. |
| 4110 */ | 4111 */ |
| 4111 final Map<ConstructorElement, ConstructorDeclaration> _constructorDeclarationM
ap; | 4112 final HashMap<ConstructorElement, ConstructorDeclaration> _constructorDeclarat
ionMap; |
| 4112 | 4113 |
| 4113 /** | 4114 /** |
| 4114 * Initialize a newly created reference finder to find references from the giv
en variable to other | 4115 * Initialize a newly created reference finder to find references from the giv
en variable to other |
| 4115 * variables and to add those references to the given graph. | 4116 * variables and to add those references to the given graph. |
| 4116 * | 4117 * |
| 4117 * @param source the element representing the variable whose initializer will
be visited | 4118 * @param source the element representing the variable whose initializer will
be visited |
| 4118 * @param referenceGraph a graph recording which variables (heads) reference w
hich other variables | 4119 * @param referenceGraph a graph recording which variables (heads) reference w
hich other variables |
| 4119 * (tails) in their initializers | 4120 * (tails) in their initializers |
| 4120 * @param variableDeclarationMap A table mapping constant variables to the dec
larations of those | 4121 * @param variableDeclarationMap A table mapping constant variables to the dec
larations of those |
| 4121 * variables. | 4122 * variables. |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4805 ErrorResult _error(AstNode node, ErrorCode code) => new ErrorResult.con1(node,
code); | 4806 ErrorResult _error(AstNode node, ErrorCode code) => new ErrorResult.con1(node,
code); |
| 4806 | 4807 |
| 4807 /** | 4808 /** |
| 4808 * Return a result object representing the given value. | 4809 * Return a result object representing the given value. |
| 4809 * | 4810 * |
| 4810 * @param value the value to be represented as a result object | 4811 * @param value the value to be represented as a result object |
| 4811 * @return a result object representing the given value | 4812 * @return a result object representing the given value |
| 4812 */ | 4813 */ |
| 4813 ValidResult _valueOf(DartObjectImpl value) => new ValidResult(value); | 4814 ValidResult _valueOf(DartObjectImpl value) => new ValidResult(value); |
| 4814 } | 4815 } |
| OLD | NEW |