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.element; | 8 library engine.element; |
9 | 9 |
10 import 'dart:collection'; | 10 import 'dart:collection'; |
(...skipping 4649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4660 * declaration are replaced with the actual type arguments from the defining t
ype, create a field | 4660 * declaration are replaced with the actual type arguments from the defining t
ype, create a field |
4661 * member representing the given field. Return the member that was created, or
the base field if | 4661 * member representing the given field. Return the member that was created, or
the base field if |
4662 * no member was created. | 4662 * no member was created. |
4663 * | 4663 * |
4664 * @param baseField the base field for which a member might be created | 4664 * @param baseField the base field for which a member might be created |
4665 * @param definingType the type defining the parameters and arguments to be us
ed in the | 4665 * @param definingType the type defining the parameters and arguments to be us
ed in the |
4666 * substitution | 4666 * substitution |
4667 * @return the field element that will return the correctly substituted types | 4667 * @return the field element that will return the correctly substituted types |
4668 */ | 4668 */ |
4669 static FieldElement from(FieldElement baseField, InterfaceType definingType) { | 4669 static FieldElement from(FieldElement baseField, InterfaceType definingType) { |
4670 if (baseField == null || definingType.typeArguments.length == 0) { | 4670 if (!_isChangedByTypeSubstitution(baseField, definingType)) { |
4671 return baseField; | |
4672 } | |
4673 DartType baseType = baseField.type; | |
4674 if (baseType == null) { | |
4675 return baseField; | |
4676 } | |
4677 List<DartType> argumentTypes = definingType.typeArguments; | |
4678 List<DartType> parameterTypes = definingType.element.type.typeArguments; | |
4679 DartType substitutedType = baseType.substitute2(argumentTypes, parameterType
s); | |
4680 if (baseType == substitutedType) { | |
4681 return baseField; | 4671 return baseField; |
4682 } | 4672 } |
4683 // TODO(brianwilkerson) Consider caching the substituted type in the instanc
e. It would use more | 4673 // TODO(brianwilkerson) Consider caching the substituted type in the instanc
e. It would use more |
4684 // memory but speed up some operations. We need to see how often the type is
being re-computed. | 4674 // memory but speed up some operations. We need to see how often the type is
being re-computed. |
4685 return new FieldMember(baseField, definingType); | 4675 return new FieldMember(baseField, definingType); |
4686 } | 4676 } |
4687 | 4677 |
4688 /** | 4678 /** |
| 4679 * Determine whether the given field's type is changed when type parameters fr
om the defining |
| 4680 * type's declaration are replaced with the actual type arguments from the def
ining type. |
| 4681 * |
| 4682 * @param baseField the base field |
| 4683 * @param definingType the type defining the parameters and arguments to be us
ed in the |
| 4684 * substitution |
| 4685 * @return true if the type is changed by type substitution. |
| 4686 */ |
| 4687 static bool _isChangedByTypeSubstitution(FieldElement baseField, InterfaceType
definingType) { |
| 4688 List<DartType> argumentTypes = definingType.typeArguments; |
| 4689 if (baseField != null && argumentTypes.length != 0) { |
| 4690 DartType baseType = baseField.type; |
| 4691 List<DartType> parameterTypes = definingType.element.type.typeArguments; |
| 4692 if (baseType != null) { |
| 4693 DartType substitutedType = baseType.substitute2(argumentTypes, parameter
Types); |
| 4694 if (baseType != substitutedType) { |
| 4695 return true; |
| 4696 } |
| 4697 } |
| 4698 // If the field has a propagated type, then we need to check whether the p
ropagated type |
| 4699 // needs substitution. |
| 4700 DartType basePropagatedType = baseField.propagatedType; |
| 4701 if (basePropagatedType != null) { |
| 4702 DartType substitutedPropagatedType = basePropagatedType.substitute2(argu
mentTypes, parameterTypes); |
| 4703 if (basePropagatedType != substitutedPropagatedType) { |
| 4704 return true; |
| 4705 } |
| 4706 } |
| 4707 } |
| 4708 return false; |
| 4709 } |
| 4710 |
| 4711 /** |
4689 * Initialize a newly created element to represent a field of the given parame
terized type. | 4712 * Initialize a newly created element to represent a field of the given parame
terized type. |
4690 * | 4713 * |
4691 * @param baseElement the element on which the parameterized element was creat
ed | 4714 * @param baseElement the element on which the parameterized element was creat
ed |
4692 * @param definingType the type in which the element is defined | 4715 * @param definingType the type in which the element is defined |
4693 */ | 4716 */ |
4694 FieldMember(FieldElement baseElement, InterfaceType definingType) : super(base
Element, definingType); | 4717 FieldMember(FieldElement baseElement, InterfaceType definingType) : super(base
Element, definingType); |
4695 | 4718 |
4696 @override | 4719 @override |
4697 accept(ElementVisitor visitor) => visitor.visitFieldElement(this); | 4720 accept(ElementVisitor visitor) => visitor.visitFieldElement(this); |
4698 | 4721 |
4699 @override | 4722 @override |
4700 FieldElement get baseElement => super.baseElement as FieldElement; | 4723 FieldElement get baseElement => super.baseElement as FieldElement; |
4701 | 4724 |
4702 @override | 4725 @override |
4703 ClassElement get enclosingElement => baseElement.enclosingElement; | 4726 ClassElement get enclosingElement => baseElement.enclosingElement; |
4704 | 4727 |
4705 @override | 4728 @override |
4706 PropertyAccessorElement get getter => PropertyAccessorMember.from(baseElement.
getter, definingType); | 4729 PropertyAccessorElement get getter => PropertyAccessorMember.from(baseElement.
getter, definingType); |
4707 | 4730 |
4708 @override | 4731 @override |
4709 DartType get propagatedType => substituteFor(baseElement.propagatedType); | 4732 DartType get propagatedType => substituteFor(baseElement.propagatedType); |
4710 | 4733 |
4711 @override | 4734 @override |
4712 PropertyAccessorElement get setter => PropertyAccessorMember.from(baseElement.
setter, definingType); | 4735 PropertyAccessorElement get setter => PropertyAccessorMember.from(baseElement.
setter, definingType); |
4713 | 4736 |
4714 @override | 4737 @override |
4715 bool get isStatic => baseElement.isStatic; | 4738 bool get isStatic => baseElement.isStatic; |
4716 | 4739 |
4717 @override | 4740 @override |
| 4741 String toString() { |
| 4742 JavaStringBuilder builder = new JavaStringBuilder(); |
| 4743 builder.append(type); |
| 4744 builder.append(" "); |
| 4745 builder.append(displayName); |
| 4746 return builder.toString(); |
| 4747 } |
| 4748 |
| 4749 @override |
4718 InterfaceType get definingType => super.definingType as InterfaceType; | 4750 InterfaceType get definingType => super.definingType as InterfaceType; |
4719 } | 4751 } |
4720 | 4752 |
4721 /** | 4753 /** |
4722 * The interface `FunctionElement` defines the behavior of elements representing
a function. | 4754 * The interface `FunctionElement` defines the behavior of elements representing
a function. |
4723 */ | 4755 */ |
4724 abstract class FunctionElement implements ExecutableElement, LocalElement { | 4756 abstract class FunctionElement implements ExecutableElement, LocalElement { |
4725 /** | 4757 /** |
4726 * The name of the method that can be implemented by a class to allow its inst
ances to be invoked | 4758 * The name of the method that can be implemented by a class to allow its inst
ances to be invoked |
4727 * as if they were a function. | 4759 * as if they were a function. |
(...skipping 2678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7406 } | 7438 } |
7407 } | 7439 } |
7408 return false; | 7440 return false; |
7409 } | 7441 } |
7410 } | 7442 } |
7411 | 7443 |
7412 /** | 7444 /** |
7413 * Combination of [AngularTagSelectorElementImpl] and [HasAttributeSelectorEleme
ntImpl]. | 7445 * Combination of [AngularTagSelectorElementImpl] and [HasAttributeSelectorEleme
ntImpl]. |
7414 */ | 7446 */ |
7415 class IsTagHasAttributeSelectorElementImpl extends AngularSelectorElementImpl { | 7447 class IsTagHasAttributeSelectorElementImpl extends AngularSelectorElementImpl { |
7416 final String tagName; | 7448 String _tagName; |
7417 | 7449 |
7418 final String attributeName; | 7450 String _attributeName; |
7419 | 7451 |
7420 IsTagHasAttributeSelectorElementImpl(this.tagName, this.attributeName) : super
(null, -1); | 7452 IsTagHasAttributeSelectorElementImpl(String tagName, String attributeName) : s
uper("${tagName}[${attributeName}]", -1) { |
| 7453 this._tagName = tagName; |
| 7454 this._attributeName = attributeName; |
| 7455 } |
7421 | 7456 |
7422 @override | 7457 @override |
7423 bool apply(XmlTagNode node) => node.tag == tagName && node.getAttribute(attrib
uteName) != null; | 7458 bool apply(XmlTagNode node) => node.tag == _tagName && node.getAttribute(_attr
ibuteName) != null; |
| 7459 |
| 7460 String get attributeName => _attributeName; |
| 7461 |
| 7462 String get tagName => _tagName; |
7424 } | 7463 } |
7425 | 7464 |
7426 /** | 7465 /** |
7427 * The interface `LabelElement` defines the behavior of elements representing a
label | 7466 * The interface `LabelElement` defines the behavior of elements representing a
label |
7428 * associated with a statement. | 7467 * associated with a statement. |
7429 */ | 7468 */ |
7430 abstract class LabelElement implements Element { | 7469 abstract class LabelElement implements Element { |
7431 /** | 7470 /** |
7432 * Return the executable element in which this label is defined. | 7471 * Return the executable element in which this label is defined. |
7433 * | 7472 * |
(...skipping 2459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9893 * type's declaration are replaced with the actual type arguments from the def
ining type, create a | 9932 * type's declaration are replaced with the actual type arguments from the def
ining type, create a |
9894 * property accessor member representing the given property accessor. Return t
he member that was | 9933 * property accessor member representing the given property accessor. Return t
he member that was |
9895 * created, or the base accessor if no member was created. | 9934 * created, or the base accessor if no member was created. |
9896 * | 9935 * |
9897 * @param baseAccessor the base property accessor for which a member might be
created | 9936 * @param baseAccessor the base property accessor for which a member might be
created |
9898 * @param definingType the type defining the parameters and arguments to be us
ed in the | 9937 * @param definingType the type defining the parameters and arguments to be us
ed in the |
9899 * substitution | 9938 * substitution |
9900 * @return the property accessor element that will return the correctly substi
tuted types | 9939 * @return the property accessor element that will return the correctly substi
tuted types |
9901 */ | 9940 */ |
9902 static PropertyAccessorElement from(PropertyAccessorElement baseAccessor, Inte
rfaceType definingType) { | 9941 static PropertyAccessorElement from(PropertyAccessorElement baseAccessor, Inte
rfaceType definingType) { |
9903 if (baseAccessor == null || definingType.typeArguments.length == 0) { | 9942 if (!_isChangedByTypeSubstitution(baseAccessor, definingType)) { |
9904 return baseAccessor; | |
9905 } | |
9906 FunctionType baseType = baseAccessor.type; | |
9907 List<DartType> argumentTypes = definingType.typeArguments; | |
9908 List<DartType> parameterTypes = definingType.element.type.typeArguments; | |
9909 FunctionType substitutedType = baseType.substitute2(argumentTypes, parameter
Types); | |
9910 if (baseType == substitutedType) { | |
9911 return baseAccessor; | 9943 return baseAccessor; |
9912 } | 9944 } |
9913 // TODO(brianwilkerson) Consider caching the substituted type in the instanc
e. It would use more | 9945 // TODO(brianwilkerson) Consider caching the substituted type in the instanc
e. It would use more |
9914 // memory but speed up some operations. We need to see how often the type is
being re-computed. | 9946 // memory but speed up some operations. We need to see how often the type is
being re-computed. |
9915 return new PropertyAccessorMember(baseAccessor, definingType); | 9947 return new PropertyAccessorMember(baseAccessor, definingType); |
9916 } | 9948 } |
9917 | 9949 |
9918 /** | 9950 /** |
| 9951 * Determine whether the given property accessor's type is changed when type p
arameters from the |
| 9952 * defining type's declaration are replaced with the actual type arguments fro
m the defining type. |
| 9953 * |
| 9954 * @param baseAccessor the base property accessor |
| 9955 * @param definingType the type defining the parameters and arguments to be us
ed in the |
| 9956 * substitution |
| 9957 * @return true if the type is changed by type substitution. |
| 9958 */ |
| 9959 static bool _isChangedByTypeSubstitution(PropertyAccessorElement baseAccessor,
InterfaceType definingType) { |
| 9960 List<DartType> argumentTypes = definingType.typeArguments; |
| 9961 if (baseAccessor != null && argumentTypes.length != 0) { |
| 9962 FunctionType baseType = baseAccessor.type; |
| 9963 List<DartType> parameterTypes = definingType.element.type.typeArguments; |
| 9964 FunctionType substitutedType = baseType.substitute2(argumentTypes, paramet
erTypes); |
| 9965 if (baseType != substitutedType) { |
| 9966 return true; |
| 9967 } |
| 9968 // If this property accessor is based on a field, that field might have a
propagated type. |
| 9969 // In which case we need to check whether the propagated type of the field
needs substitution. |
| 9970 PropertyInducingElement field = baseAccessor.variable; |
| 9971 if (!field.isSynthetic) { |
| 9972 DartType baseFieldType = field.propagatedType; |
| 9973 if (baseFieldType != null) { |
| 9974 DartType substitutedFieldType = baseFieldType.substitute2(argumentType
s, parameterTypes); |
| 9975 if (baseFieldType != substitutedFieldType) { |
| 9976 return true; |
| 9977 } |
| 9978 } |
| 9979 } |
| 9980 } |
| 9981 return false; |
| 9982 } |
| 9983 |
| 9984 /** |
9919 * Initialize a newly created element to represent a property accessor of the
given parameterized | 9985 * Initialize a newly created element to represent a property accessor of the
given parameterized |
9920 * type. | 9986 * type. |
9921 * | 9987 * |
9922 * @param baseElement the element on which the parameterized element was creat
ed | 9988 * @param baseElement the element on which the parameterized element was creat
ed |
9923 * @param definingType the type in which the element is defined | 9989 * @param definingType the type in which the element is defined |
9924 */ | 9990 */ |
9925 PropertyAccessorMember(PropertyAccessorElement baseElement, InterfaceType defi
ningType) : super(baseElement, definingType); | 9991 PropertyAccessorMember(PropertyAccessorElement baseElement, InterfaceType defi
ningType) : super(baseElement, definingType); |
9926 | 9992 |
9927 @override | 9993 @override |
9928 accept(ElementVisitor visitor) => visitor.visitPropertyAccessorElement(this); | 9994 accept(ElementVisitor visitor) => visitor.visitPropertyAccessorElement(this); |
(...skipping 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11319 | 11385 |
11320 @override | 11386 @override |
11321 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs) => id
entical(object, this); | 11387 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs) => id
entical(object, this); |
11322 | 11388 |
11323 @override | 11389 @override |
11324 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, Set<TypeImpl_
TypePair> visitedTypePairs) => isSubtypeOf(type); | 11390 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, Set<TypeImpl_
TypePair> visitedTypePairs) => isSubtypeOf(type); |
11325 | 11391 |
11326 @override | 11392 @override |
11327 bool internalIsSubtypeOf(DartType type, Set<TypeImpl_TypePair> visitedTypePair
s) => identical(type, this) || identical(type, DynamicTypeImpl.instance); | 11393 bool internalIsSubtypeOf(DartType type, Set<TypeImpl_TypePair> visitedTypePair
s) => identical(type, this) || identical(type, DynamicTypeImpl.instance); |
11328 } | 11394 } |
OLD | NEW |