Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Side by Side Diff: pkg/analyzer/lib/src/generated/constant.dart

Issue 640813004: Handle non-factory redirects in constant evaluation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/all_the_rest.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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';
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 } 784 }
785 } 785 }
786 } 786 }
787 } else if (initializer is SuperConstructorInvocation) { 787 } else if (initializer is SuperConstructorInvocation) {
788 SuperConstructorInvocation superConstructorInvocation = initializer; 788 SuperConstructorInvocation superConstructorInvocation = initializer;
789 SimpleIdentifier name = superConstructorInvocation.constructorName; 789 SimpleIdentifier name = superConstructorInvocation.constructorName;
790 if (name != null) { 790 if (name != null) {
791 superName = name.name; 791 superName = name.name;
792 } 792 }
793 superArguments = superConstructorInvocation.argumentList.arguments; 793 superArguments = superConstructorInvocation.argumentList.arguments;
794 } else if (initializer is RedirectingConstructorInvocation) {
795 // This is a redirecting constructor, so just evaluate the constructor
796 // it redirects to.
797 ConstructorElement constructor = initializer.staticElement;
798 if (constructor != null && constructor.isConst) {
799 return _evaluateConstructorCall(
800 node, initializer.argumentList.arguments, constructor,
801 initializerVisitor, errorReporter);
802 }
794 } 803 }
795 } 804 }
796 // Evaluate explicit or implicit call to super(). 805 // Evaluate explicit or implicit call to super().
797 InterfaceType superclass = definingClass.superclass; 806 InterfaceType superclass = definingClass.superclass;
798 if (superclass != null && !superclass.isObject) { 807 if (superclass != null && !superclass.isObject) {
799 ConstructorElement superConstructor = superclass.lookUpConstructor(superNa me, constructor.library); 808 ConstructorElement superConstructor = superclass.lookUpConstructor(superNa me, constructor.library);
800 if (superConstructor != null) { 809 if (superConstructor != null) {
801 if (superArguments == null) { 810 if (superArguments == null) {
802 superArguments = new NodeList<Expression>(null); 811 superArguments = new NodeList<Expression>(null);
803 } 812 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 identifier.staticElement = node.staticElement; 917 identifier.staticElement = node.staticElement;
909 return identifier; 918 return identifier;
910 } 919 }
911 920
912 @override 921 @override
913 SuperConstructorInvocation visitSuperConstructorInvocation(SuperConstructorInv ocation node) { 922 SuperConstructorInvocation visitSuperConstructorInvocation(SuperConstructorInv ocation node) {
914 SuperConstructorInvocation invocation = super.visitSuperConstructorInvocatio n(node); 923 SuperConstructorInvocation invocation = super.visitSuperConstructorInvocatio n(node);
915 invocation.staticElement = node.staticElement; 924 invocation.staticElement = node.staticElement;
916 return invocation; 925 return invocation;
917 } 926 }
927
928 @override
929 RedirectingConstructorInvocation visitRedirectingConstructorInvocation(
930 RedirectingConstructorInvocation node) {
931 RedirectingConstructorInvocation invocation =
932 super.visitRedirectingConstructorInvocation(node);
933 invocation.staticElement = node.staticElement;
934 return invocation;
935 }
918 } 936 }
919 937
920 /** 938 /**
921 * Instances of the class `ConstantVisitor` evaluate constant expressions to pro duce their 939 * Instances of the class `ConstantVisitor` evaluate constant expressions to pro duce their
922 * compile-time value. According to the Dart Language Specification: <blockquote > A constant 940 * compile-time value. According to the Dart Language Specification: <blockquote > A constant
923 * expression is one of the following: 941 * expression is one of the following:
924 * * A literal number. 942 * * A literal number.
925 * * A literal boolean. 943 * * A literal boolean.
926 * * A literal string where any interpolated expression is a compile-time consta nt that evaluates 944 * * A literal string where any interpolated expression is a compile-time consta nt that evaluates
927 * to a numeric, string or boolean value or to <b>null</b>. 945 * to a numeric, string or boolean value or to <b>null</b>.
(...skipping 3523 matching lines...) Expand 10 before | Expand all | Expand 10 after
4451 // The declaration will be null when the constructor is not defined in the compilation 4469 // The declaration will be null when the constructor is not defined in the compilation
4452 // units that were used to produce the constructorDeclarationMap. In such cases, the 4470 // units that were used to produce the constructorDeclarationMap. In such cases, the
4453 // constructor should already have its initializer AST's stored in it, but we don't bother 4471 // constructor should already have its initializer AST's stored in it, but we don't bother
4454 // to check because there's nothing we can do about it at this point. 4472 // to check because there's nothing we can do about it at this point.
4455 if (constructorDeclaration != null) { 4473 if (constructorDeclaration != null) {
4456 _referenceGraph.addEdge(_source, constructorDeclaration); 4474 _referenceGraph.addEdge(_source, constructorDeclaration);
4457 } 4475 }
4458 } 4476 }
4459 return null; 4477 return null;
4460 } 4478 }
4479
4480 @override
4481 Object visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node) {
4482 super.visitRedirectingConstructorInvocation(node);
4483 ConstructorElement target = node.staticElement;
4484 if (target != null && target.isConst) {
4485 ConstructorDeclaration targetDeclaration = _constructorDeclarationMap[targ et];
4486 if (targetDeclaration != null) {
4487 _referenceGraph.addEdge(_source, targetDeclaration);
4488 }
4489 }
4490 return null;
4491 }
4461 } 4492 }
4462 4493
4463 /** 4494 /**
4464 * Instances of the class `StringState` represent the state of an object represe nting a 4495 * Instances of the class `StringState` represent the state of an object represe nting a
4465 * string. 4496 * string.
4466 */ 4497 */
4467 class StringState extends InstanceState { 4498 class StringState extends InstanceState {
4468 /** 4499 /**
4469 * The value of this instance. 4500 * The value of this instance.
4470 */ 4501 */
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
4656 4687
4657 @override 4688 @override
4658 String get typeName => "Type"; 4689 String get typeName => "Type";
4659 4690
4660 @override 4691 @override
4661 int get hashCode => _element == null ? 0 : _element.hashCode; 4692 int get hashCode => _element == null ? 0 : _element.hashCode;
4662 4693
4663 @override 4694 @override
4664 String toString() => _element == null ? "-unknown-" : _element.name; 4695 String toString() => _element == null ? "-unknown-" : _element.name;
4665 } 4696 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/all_the_rest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698