| 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/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/ast/visitor.dart'; | 10 import 'package:analyzer/dart/ast/visitor.dart'; |
| 11 import 'package:analyzer/dart/element/element.dart'; | 11 import 'package:analyzer/dart/element/element.dart'; |
| 12 import 'package:analyzer/dart/element/type.dart'; | 12 import 'package:analyzer/dart/element/type.dart'; |
| 13 import 'package:analyzer/src/dart/ast/utilities.dart'; | 13 import 'package:analyzer/src/dart/ast/utilities.dart'; |
| 14 import 'package:analyzer/src/dart/element/element.dart'; | 14 import 'package:analyzer/src/dart/element/element.dart'; |
| 15 import 'package:analyzer/src/dart/element/member.dart'; | 15 import 'package:analyzer/src/dart/element/member.dart'; |
| 16 import 'package:analyzer/src/generated/element_handle.dart' |
| 17 show ConstructorElementHandle; |
| 16 import 'package:analyzer/src/generated/engine.dart'; | 18 import 'package:analyzer/src/generated/engine.dart'; |
| 17 import 'package:analyzer/src/generated/engine.dart' | 19 import 'package:analyzer/src/generated/engine.dart' |
| 18 show AnalysisEngine, RecordingErrorListener; | 20 show AnalysisEngine, RecordingErrorListener; |
| 19 import 'package:analyzer/src/generated/error.dart'; | 21 import 'package:analyzer/src/generated/error.dart'; |
| 20 import 'package:analyzer/src/generated/java_core.dart'; | 22 import 'package:analyzer/src/generated/java_core.dart'; |
| 21 import 'package:analyzer/src/generated/resolver.dart' show TypeProvider; | 23 import 'package:analyzer/src/generated/resolver.dart' show TypeProvider; |
| 22 import 'package:analyzer/src/generated/scanner.dart' show Token, TokenType; | 24 import 'package:analyzer/src/generated/scanner.dart' show Token, TokenType; |
| 23 import 'package:analyzer/src/generated/source.dart' show Source; | 25 import 'package:analyzer/src/generated/source.dart' show Source; |
| 24 import 'package:analyzer/src/generated/type_system.dart' | 26 import 'package:analyzer/src/generated/type_system.dart' |
| 25 show TypeSystem, TypeSystemImpl; | 27 show TypeSystem, TypeSystemImpl; |
| 26 import 'package:analyzer/src/generated/utilities_collection.dart'; | 28 import 'package:analyzer/src/generated/utilities_collection.dart'; |
| 27 import 'package:analyzer/src/generated/utilities_dart.dart' show ParameterKind; | 29 import 'package:analyzer/src/generated/utilities_dart.dart' show ParameterKind; |
| 28 import 'package:analyzer/src/generated/utilities_general.dart'; | 30 import 'package:analyzer/src/generated/utilities_general.dart'; |
| 29 import 'package:analyzer/src/task/dart.dart'; | 31 import 'package:analyzer/src/task/dart.dart'; |
| 30 | 32 |
| 33 ConstructorElementImpl _getConstructorImpl(ConstructorElement constructor) { |
| 34 if (constructor is ConstructorElementHandle) { |
| 35 constructor = (constructor as ConstructorElementHandle).actualElement; |
| 36 } |
| 37 while (constructor is ConstructorMember) { |
| 38 constructor = (constructor as ConstructorMember).baseElement; |
| 39 } |
| 40 return constructor; |
| 41 } |
| 42 |
| 31 /** | 43 /** |
| 32 * Callback used by [ReferenceFinder] to report that a dependency was found. | 44 * Callback used by [ReferenceFinder] to report that a dependency was found. |
| 33 */ | 45 */ |
| 34 typedef void ReferenceFinderCallback(ConstantEvaluationTarget dependency); | 46 typedef void ReferenceFinderCallback(ConstantEvaluationTarget dependency); |
| 35 | 47 |
| 36 /** | 48 /** |
| 37 * The state of an object representing a boolean value. | 49 * The state of an object representing a boolean value. |
| 38 */ | 50 */ |
| 39 class BoolState extends InstanceState { | 51 class BoolState extends InstanceState { |
| 40 /** | 52 /** |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 String name = argumentValues[0].toStringValue(); | 344 String name = argumentValues[0].toStringValue(); |
| 333 return isValidPublicSymbol(name); | 345 return isValidPublicSymbol(name); |
| 334 } | 346 } |
| 335 | 347 |
| 336 /** | 348 /** |
| 337 * Compute the constant value associated with the given [constant]. | 349 * Compute the constant value associated with the given [constant]. |
| 338 */ | 350 */ |
| 339 void computeConstantValue(ConstantEvaluationTarget constant) { | 351 void computeConstantValue(ConstantEvaluationTarget constant) { |
| 340 validator.beforeComputeValue(constant); | 352 validator.beforeComputeValue(constant); |
| 341 if (constant is ParameterElementImpl) { | 353 if (constant is ParameterElementImpl) { |
| 342 if (constant.initializer != null) { | 354 Expression defaultValue = constant.constantInitializer; |
| 343 Expression defaultValue = constant.constantInitializer; | 355 if (defaultValue != null) { |
| 344 if (defaultValue != null) { | 356 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 345 RecordingErrorListener errorListener = new RecordingErrorListener(); | 357 ErrorReporter errorReporter = |
| 346 ErrorReporter errorReporter = | 358 new ErrorReporter(errorListener, constant.source); |
| 347 new ErrorReporter(errorListener, constant.source); | 359 DartObjectImpl dartObject = |
| 348 DartObjectImpl dartObject = | 360 defaultValue.accept(new ConstantVisitor(this, errorReporter)); |
| 349 defaultValue.accept(new ConstantVisitor(this, errorReporter)); | 361 constant.evaluationResult = |
| 350 constant.evaluationResult = | 362 new EvaluationResultImpl(dartObject, errorListener.errors); |
| 351 new EvaluationResultImpl(dartObject, errorListener.errors); | |
| 352 } | |
| 353 } | 363 } |
| 354 } else if (constant is VariableElementImpl) { | 364 } else if (constant is VariableElementImpl) { |
| 355 Expression constantInitializer = constant.constantInitializer; | 365 Expression constantInitializer = constant.constantInitializer; |
| 356 if (constantInitializer != null) { | 366 if (constantInitializer != null) { |
| 357 RecordingErrorListener errorListener = new RecordingErrorListener(); | 367 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 358 ErrorReporter errorReporter = | 368 ErrorReporter errorReporter = |
| 359 new ErrorReporter(errorListener, constant.source); | 369 new ErrorReporter(errorListener, constant.source); |
| 360 DartObjectImpl dartObject = constantInitializer | 370 DartObjectImpl dartObject = constantInitializer |
| 361 .accept(new ConstantVisitor(this, errorReporter)); | 371 .accept(new ConstantVisitor(this, errorReporter)); |
| 362 // Only check the type for truly const declarations (don't check final | 372 // Only check the type for truly const declarations (don't check final |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 } | 449 } |
| 440 | 450 |
| 441 /** | 451 /** |
| 442 * Determine which constant elements need to have their values computed | 452 * Determine which constant elements need to have their values computed |
| 443 * prior to computing the value of [constant], and report them using | 453 * prior to computing the value of [constant], and report them using |
| 444 * [callback]. | 454 * [callback]. |
| 445 */ | 455 */ |
| 446 void computeDependencies( | 456 void computeDependencies( |
| 447 ConstantEvaluationTarget constant, ReferenceFinderCallback callback) { | 457 ConstantEvaluationTarget constant, ReferenceFinderCallback callback) { |
| 448 ReferenceFinder referenceFinder = new ReferenceFinder(callback); | 458 ReferenceFinder referenceFinder = new ReferenceFinder(callback); |
| 459 if (constant is ConstructorElement) { |
| 460 constant = _getConstructorImpl(constant); |
| 461 } |
| 449 if (constant is VariableElementImpl) { | 462 if (constant is VariableElementImpl) { |
| 450 Expression initializer = constant.constantInitializer; | 463 Expression initializer = constant.constantInitializer; |
| 451 if (initializer != null) { | 464 if (initializer != null) { |
| 452 initializer.accept(referenceFinder); | 465 initializer.accept(referenceFinder); |
| 453 } | 466 } |
| 454 } else if (constant is ConstructorElementImpl) { | 467 } else if (constant is ConstructorElementImpl) { |
| 455 if (constant.isConst) { | 468 if (constant.isConst) { |
| 456 constant.isCycleFree = false; | 469 constant.isCycleFree = false; |
| 457 ConstructorElement redirectedConstructor = | 470 ConstructorElement redirectedConstructor = |
| 458 getConstRedirectedConstructor(constant); | 471 getConstRedirectedConstructor(constant); |
| 459 if (redirectedConstructor != null) { | 472 if (redirectedConstructor != null) { |
| 460 ConstructorElement redirectedConstructorBase = | 473 ConstructorElement redirectedConstructorBase = |
| 461 _getConstructorBase(redirectedConstructor); | 474 _getConstructorImpl(redirectedConstructor); |
| 462 callback(redirectedConstructorBase); | 475 callback(redirectedConstructorBase); |
| 463 return; | 476 return; |
| 464 } else if (constant.isFactory) { | 477 } else if (constant.isFactory) { |
| 465 // Factory constructor, but getConstRedirectedConstructor returned | 478 // Factory constructor, but getConstRedirectedConstructor returned |
| 466 // null. This can happen if we're visiting one of the special externa
l | 479 // null. This can happen if we're visiting one of the special externa
l |
| 467 // const factory constructors in the SDK, or if the code contains | 480 // const factory constructors in the SDK, or if the code contains |
| 468 // errors (such as delegating to a non-const constructor, or delegatin
g | 481 // errors (such as delegating to a non-const constructor, or delegatin
g |
| 469 // to a constructor that can't be resolved). In any of these cases, | 482 // to a constructor that can't be resolved). In any of these cases, |
| 470 // we'll evaluate calls to this constructor without having to refer to | 483 // we'll evaluate calls to this constructor without having to refer to |
| 471 // any other constants. So we don't need to report any dependencies. | 484 // any other constants. So we don't need to report any dependencies. |
| 472 return; | 485 return; |
| 473 } | 486 } |
| 474 bool superInvocationFound = false; | 487 bool superInvocationFound = false; |
| 475 List<ConstructorInitializer> initializers = | 488 List<ConstructorInitializer> initializers = |
| 476 constant.constantInitializers; | 489 constant.constantInitializers; |
| 477 for (ConstructorInitializer initializer in initializers) { | 490 for (ConstructorInitializer initializer in initializers) { |
| 478 if (initializer is SuperConstructorInvocation) { | 491 if (initializer is SuperConstructorInvocation) { |
| 479 superInvocationFound = true; | 492 superInvocationFound = true; |
| 480 } | 493 } |
| 481 initializer.accept(referenceFinder); | 494 initializer.accept(referenceFinder); |
| 482 } | 495 } |
| 483 if (!superInvocationFound) { | 496 if (!superInvocationFound) { |
| 484 // No explicit superconstructor invocation found, so we need to | 497 // No explicit superconstructor invocation found, so we need to |
| 485 // manually insert a reference to the implicit superconstructor. | 498 // manually insert a reference to the implicit superconstructor. |
| 486 InterfaceType superclass = | 499 InterfaceType superclass = |
| 487 (constant.returnType as InterfaceType).superclass; | 500 (constant.returnType as InterfaceType).superclass; |
| 488 if (superclass != null && !superclass.isObject) { | 501 if (superclass != null && !superclass.isObject) { |
| 489 ConstructorElement unnamedConstructor = | 502 ConstructorElement unnamedConstructor = |
| 490 _getConstructorBase(superclass.element.unnamedConstructor); | 503 _getConstructorImpl(superclass.element.unnamedConstructor); |
| 491 if (unnamedConstructor != null) { | 504 if (unnamedConstructor != null) { |
| 492 callback(unnamedConstructor); | 505 callback(unnamedConstructor); |
| 493 } | 506 } |
| 494 } | 507 } |
| 495 } | 508 } |
| 496 for (FieldElement field in constant.enclosingElement.fields) { | 509 for (FieldElement field in constant.enclosingElement.fields) { |
| 497 // Note: non-static const isn't allowed but we handle it anyway so | 510 // Note: non-static const isn't allowed but we handle it anyway so |
| 498 // that we won't be confused by incorrect code. | 511 // that we won't be confused by incorrect code. |
| 499 if ((field.isFinal || field.isConst) && | 512 if ((field.isFinal || field.isConst) && |
| 500 !field.isStatic && | 513 !field.isStatic && |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 } | 588 } |
| 576 return value; | 589 return value; |
| 577 } | 590 } |
| 578 | 591 |
| 579 DartObjectImpl evaluateConstructorCall( | 592 DartObjectImpl evaluateConstructorCall( |
| 580 AstNode node, | 593 AstNode node, |
| 581 NodeList<Expression> arguments, | 594 NodeList<Expression> arguments, |
| 582 ConstructorElement constructor, | 595 ConstructorElement constructor, |
| 583 ConstantVisitor constantVisitor, | 596 ConstantVisitor constantVisitor, |
| 584 ErrorReporter errorReporter) { | 597 ErrorReporter errorReporter) { |
| 585 if (!_getConstructorBase(constructor).isCycleFree) { | 598 if (!_getConstructorImpl(constructor).isCycleFree) { |
| 586 // It's not safe to evaluate this constructor, so bail out. | 599 // It's not safe to evaluate this constructor, so bail out. |
| 587 // TODO(paulberry): ensure that a reasonable error message is produced | 600 // TODO(paulberry): ensure that a reasonable error message is produced |
| 588 // in this case, as well as other cases involving constant expression | 601 // in this case, as well as other cases involving constant expression |
| 589 // circularities (e.g. "compile-time constant expression depends on | 602 // circularities (e.g. "compile-time constant expression depends on |
| 590 // itself") | 603 // itself") |
| 591 return new DartObjectImpl.validWithUnknownValue(constructor.returnType); | 604 return new DartObjectImpl.validWithUnknownValue(constructor.returnType); |
| 592 } | 605 } |
| 593 int argumentCount = arguments.length; | 606 int argumentCount = arguments.length; |
| 594 List<DartObjectImpl> argumentValues = | 607 List<DartObjectImpl> argumentValues = |
| 595 new List<DartObjectImpl>(argumentCount); | 608 new List<DartObjectImpl>(argumentCount); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 definingClass, new SymbolState(argumentValue)); | 678 definingClass, new SymbolState(argumentValue)); |
| 666 } | 679 } |
| 667 // Either it's an external const factory constructor that we can't | 680 // Either it's an external const factory constructor that we can't |
| 668 // emulate, or an error occurred (a cycle, or a const constructor trying | 681 // emulate, or an error occurred (a cycle, or a const constructor trying |
| 669 // to delegate to a non-const constructor). | 682 // to delegate to a non-const constructor). |
| 670 // In the former case, the best we can do is consider it an unknown value. | 683 // In the former case, the best we can do is consider it an unknown value. |
| 671 // In the latter case, the error has already been reported, so considering | 684 // In the latter case, the error has already been reported, so considering |
| 672 // it an unknown value will suppress further errors. | 685 // it an unknown value will suppress further errors. |
| 673 return new DartObjectImpl.validWithUnknownValue(definingClass); | 686 return new DartObjectImpl.validWithUnknownValue(definingClass); |
| 674 } | 687 } |
| 675 ConstructorElementImpl constructorBase = _getConstructorBase(constructor); | 688 ConstructorElementImpl constructorBase = _getConstructorImpl(constructor); |
| 676 validator.beforeGetConstantInitializers(constructorBase); | 689 validator.beforeGetConstantInitializers(constructorBase); |
| 677 List<ConstructorInitializer> initializers = | 690 List<ConstructorInitializer> initializers = |
| 678 constructorBase.constantInitializers; | 691 constructorBase.constantInitializers; |
| 679 if (initializers == null) { | 692 if (initializers == null) { |
| 680 // This can happen in some cases where there are compile errors in the | 693 // This can happen in some cases where there are compile errors in the |
| 681 // code being analyzed (for example if the code is trying to create a | 694 // code being analyzed (for example if the code is trying to create a |
| 682 // const instance using a non-const constructor, or the node we're | 695 // const instance using a non-const constructor, or the node we're |
| 683 // visiting is involved in a cycle). The error has already been reported, | 696 // visiting is involved in a cycle). The error has already been reported, |
| 684 // so consider it an unknown value to suppress further errors. | 697 // so consider it an unknown value to suppress further errors. |
| 685 return new DartObjectImpl.validWithUnknownValue(definingClass); | 698 return new DartObjectImpl.validWithUnknownValue(definingClass); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 ConstructorElement followConstantRedirectionChain( | 896 ConstructorElement followConstantRedirectionChain( |
| 884 ConstructorElement constructor) { | 897 ConstructorElement constructor) { |
| 885 HashSet<ConstructorElement> constructorsVisited = | 898 HashSet<ConstructorElement> constructorsVisited = |
| 886 new HashSet<ConstructorElement>(); | 899 new HashSet<ConstructorElement>(); |
| 887 while (true) { | 900 while (true) { |
| 888 ConstructorElement redirectedConstructor = | 901 ConstructorElement redirectedConstructor = |
| 889 getConstRedirectedConstructor(constructor); | 902 getConstRedirectedConstructor(constructor); |
| 890 if (redirectedConstructor == null) { | 903 if (redirectedConstructor == null) { |
| 891 break; | 904 break; |
| 892 } else { | 905 } else { |
| 893 ConstructorElement constructorBase = _getConstructorBase(constructor); | 906 ConstructorElement constructorBase = _getConstructorImpl(constructor); |
| 894 constructorsVisited.add(constructorBase); | 907 constructorsVisited.add(constructorBase); |
| 895 ConstructorElement redirectedConstructorBase = | 908 ConstructorElement redirectedConstructorBase = |
| 896 _getConstructorBase(redirectedConstructor); | 909 _getConstructorImpl(redirectedConstructor); |
| 897 if (constructorsVisited.contains(redirectedConstructorBase)) { | 910 if (constructorsVisited.contains(redirectedConstructorBase)) { |
| 898 // Cycle in redirecting factory constructors--this is not allowed | 911 // Cycle in redirecting factory constructors--this is not allowed |
| 899 // and is checked elsewhere--see | 912 // and is checked elsewhere--see |
| 900 // [ErrorVerifier.checkForRecursiveFactoryRedirect()]). | 913 // [ErrorVerifier.checkForRecursiveFactoryRedirect()]). |
| 901 break; | 914 break; |
| 902 } | 915 } |
| 903 } | 916 } |
| 904 constructor = redirectedConstructor; | 917 constructor = redirectedConstructor; |
| 905 } | 918 } |
| 906 return constructor; | 919 return constructor; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 984 } | 997 } |
| 985 | 998 |
| 986 /** | 999 /** |
| 987 * Determine whether the given string is a valid name for a public symbol | 1000 * Determine whether the given string is a valid name for a public symbol |
| 988 * (i.e. whether it is allowed for a call to the Symbol constructor). | 1001 * (i.e. whether it is allowed for a call to the Symbol constructor). |
| 989 */ | 1002 */ |
| 990 static bool isValidPublicSymbol(String name) => | 1003 static bool isValidPublicSymbol(String name) => |
| 991 name.isEmpty || | 1004 name.isEmpty || |
| 992 name == "void" || | 1005 name == "void" || |
| 993 new JavaPatternMatcher(_PUBLIC_SYMBOL_PATTERN, name).matches(); | 1006 new JavaPatternMatcher(_PUBLIC_SYMBOL_PATTERN, name).matches(); |
| 994 | |
| 995 static ConstructorElementImpl _getConstructorBase( | |
| 996 ConstructorElement constructor) { | |
| 997 while (constructor is ConstructorMember) { | |
| 998 constructor = (constructor as ConstructorMember).baseElement; | |
| 999 } | |
| 1000 return constructor; | |
| 1001 } | |
| 1002 } | 1007 } |
| 1003 | 1008 |
| 1004 /** | 1009 /** |
| 1005 * Interface used by unit tests to verify correct dependency analysis during | 1010 * Interface used by unit tests to verify correct dependency analysis during |
| 1006 * constant evaluation. | 1011 * constant evaluation. |
| 1007 */ | 1012 */ |
| 1008 abstract class ConstantEvaluationValidator { | 1013 abstract class ConstantEvaluationValidator { |
| 1009 /** | 1014 /** |
| 1010 * This method is called just before computing the constant value associated | 1015 * This method is called just before computing the constant value associated |
| 1011 * with [constant]. Unit tests will override this method to introduce | 1016 * with [constant]. Unit tests will override this method to introduce |
| (...skipping 4136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5148 /** | 5153 /** |
| 5149 * Initialize a newly created reference finder to find references from a given | 5154 * Initialize a newly created reference finder to find references from a given |
| 5150 * variable to other variables and to add those references to the given graph. | 5155 * variable to other variables and to add those references to the given graph. |
| 5151 * The [_callback] will be invoked for every dependency found. | 5156 * The [_callback] will be invoked for every dependency found. |
| 5152 */ | 5157 */ |
| 5153 ReferenceFinder(this._callback); | 5158 ReferenceFinder(this._callback); |
| 5154 | 5159 |
| 5155 @override | 5160 @override |
| 5156 Object visitInstanceCreationExpression(InstanceCreationExpression node) { | 5161 Object visitInstanceCreationExpression(InstanceCreationExpression node) { |
| 5157 if (node.isConst) { | 5162 if (node.isConst) { |
| 5158 ConstructorElement constructor = | 5163 ConstructorElement constructor = _getConstructorImpl(node.staticElement); |
| 5159 ConstantEvaluationEngine._getConstructorBase(node.staticElement); | |
| 5160 if (constructor != null) { | 5164 if (constructor != null) { |
| 5161 _callback(constructor); | 5165 _callback(constructor); |
| 5162 } | 5166 } |
| 5163 } | 5167 } |
| 5164 return super.visitInstanceCreationExpression(node); | 5168 return super.visitInstanceCreationExpression(node); |
| 5165 } | 5169 } |
| 5166 | 5170 |
| 5167 @override | 5171 @override |
| 5168 Object visitLabel(Label node) { | 5172 Object visitLabel(Label node) { |
| 5169 // We are visiting the "label" part of a named expression in a function | 5173 // We are visiting the "label" part of a named expression in a function |
| 5170 // call (presumably a constructor call), e.g. "const C(label: ...)". We | 5174 // call (presumably a constructor call), e.g. "const C(label: ...)". We |
| 5171 // don't want to visit the SimpleIdentifier for the label because that's a | 5175 // don't want to visit the SimpleIdentifier for the label because that's a |
| 5172 // reference to a function parameter that needs to be filled in; it's not a | 5176 // reference to a function parameter that needs to be filled in; it's not a |
| 5173 // constant whose value we depend on. | 5177 // constant whose value we depend on. |
| 5174 return null; | 5178 return null; |
| 5175 } | 5179 } |
| 5176 | 5180 |
| 5177 @override | 5181 @override |
| 5178 Object visitRedirectingConstructorInvocation( | 5182 Object visitRedirectingConstructorInvocation( |
| 5179 RedirectingConstructorInvocation node) { | 5183 RedirectingConstructorInvocation node) { |
| 5180 super.visitRedirectingConstructorInvocation(node); | 5184 super.visitRedirectingConstructorInvocation(node); |
| 5181 ConstructorElement target = | 5185 ConstructorElement target = _getConstructorImpl(node.staticElement); |
| 5182 ConstantEvaluationEngine._getConstructorBase(node.staticElement); | |
| 5183 if (target != null) { | 5186 if (target != null) { |
| 5184 _callback(target); | 5187 _callback(target); |
| 5185 } | 5188 } |
| 5186 return null; | 5189 return null; |
| 5187 } | 5190 } |
| 5188 | 5191 |
| 5189 @override | 5192 @override |
| 5190 Object visitSimpleIdentifier(SimpleIdentifier node) { | 5193 Object visitSimpleIdentifier(SimpleIdentifier node) { |
| 5191 Element element = node.staticElement; | 5194 Element element = node.staticElement; |
| 5192 if (element is PropertyAccessorElement) { | 5195 if (element is PropertyAccessorElement) { |
| 5193 element = (element as PropertyAccessorElement).variable; | 5196 element = (element as PropertyAccessorElement).variable; |
| 5194 } | 5197 } |
| 5195 if (element is VariableElement && element.isConst) { | 5198 if (element is VariableElement && element.isConst) { |
| 5196 _callback(element); | 5199 _callback(element); |
| 5197 } | 5200 } |
| 5198 return null; | 5201 return null; |
| 5199 } | 5202 } |
| 5200 | 5203 |
| 5201 @override | 5204 @override |
| 5202 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { | 5205 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { |
| 5203 super.visitSuperConstructorInvocation(node); | 5206 super.visitSuperConstructorInvocation(node); |
| 5204 ConstructorElement constructor = | 5207 ConstructorElement constructor = _getConstructorImpl(node.staticElement); |
| 5205 ConstantEvaluationEngine._getConstructorBase(node.staticElement); | |
| 5206 if (constructor != null) { | 5208 if (constructor != null) { |
| 5207 _callback(constructor); | 5209 _callback(constructor); |
| 5208 } | 5210 } |
| 5209 return null; | 5211 return null; |
| 5210 } | 5212 } |
| 5211 } | 5213 } |
| 5212 | 5214 |
| 5213 /** | 5215 /** |
| 5214 * The state of an object representing a string. | 5216 * The state of an object representing a string. |
| 5215 */ | 5217 */ |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5410 return BoolState.from(_element == rightElement); | 5412 return BoolState.from(_element == rightElement); |
| 5411 } else if (rightOperand is DynamicState) { | 5413 } else if (rightOperand is DynamicState) { |
| 5412 return BoolState.UNKNOWN_VALUE; | 5414 return BoolState.UNKNOWN_VALUE; |
| 5413 } | 5415 } |
| 5414 return BoolState.FALSE_STATE; | 5416 return BoolState.FALSE_STATE; |
| 5415 } | 5417 } |
| 5416 | 5418 |
| 5417 @override | 5419 @override |
| 5418 String toString() => _element == null ? "-unknown-" : _element.name; | 5420 String toString() => _element == null ? "-unknown-" : _element.name; |
| 5419 } | 5421 } |
| OLD | NEW |