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

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

Issue 492463004: New analyzer snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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 | « pkg/analyzer/lib/src/generated/ast.dart ('k') | pkg/analyzer/lib/src/generated/resolver.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.element; 8 library engine.element;
9 9
10 import 'dart:collection'; 10 import 'dart:collection';
(...skipping 2864 matching lines...) Expand 10 before | Expand all | Expand 10 after
2875 } 2875 }
2876 2876
2877 @override 2877 @override
2878 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs) => id entical(object, this); 2878 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs) => id entical(object, this);
2879 2879
2880 @override 2880 @override
2881 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, Set<TypeImpl_ TypePair> visitedTypePairs) { 2881 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, Set<TypeImpl_ TypePair> visitedTypePairs) {
2882 // T is S 2882 // T is S
2883 if (identical(this, type)) { 2883 if (identical(this, type)) {
2884 return true; 2884 return true;
2885 } else if (type is UnionType) {
2886 throw new NotImplementedException("No known use case");
2887 } 2885 }
2888 // else 2886 // else
2889 return withDynamic; 2887 return withDynamic;
2890 } 2888 }
2891 2889
2892 @override 2890 @override
2893 bool internalIsSubtypeOf(DartType type, Set<TypeImpl_TypePair> visitedTypePair s) => true; 2891 bool internalIsSubtypeOf(DartType type, Set<TypeImpl_TypePair> visitedTypePair s) => true;
2894 } 2892 }
2895 2893
2896 /** 2894 /**
(...skipping 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after
4256 @override 4254 @override
4257 bool get isGenerator => hasModifier(Modifier.GENERATOR); 4255 bool get isGenerator => hasModifier(Modifier.GENERATOR);
4258 4256
4259 @override 4257 @override
4260 bool get isOperator => false; 4258 bool get isOperator => false;
4261 4259
4262 @override 4260 @override
4263 bool get isSynchronous => !hasModifier(Modifier.ASYNCHRONOUS); 4261 bool get isSynchronous => !hasModifier(Modifier.ASYNCHRONOUS);
4264 4262
4265 /** 4263 /**
4264 * Set whether this method's body is asynchronous to correspond to the given v alue.
4265 *
4266 * @param isAsynchronous `true` if the method's body is asynchronous
4267 */
4268 void set asynchronous(bool isAsynchronous) {
4269 setModifier(Modifier.ASYNCHRONOUS, isAsynchronous);
4270 }
4271
4272 /**
4266 * Set the functions defined within this executable element to the given funct ions. 4273 * Set the functions defined within this executable element to the given funct ions.
4267 * 4274 *
4268 * @param functions the functions defined within this executable element 4275 * @param functions the functions defined within this executable element
4269 */ 4276 */
4270 void set functions(List<FunctionElement> functions) { 4277 void set functions(List<FunctionElement> functions) {
4271 for (FunctionElement function in functions) { 4278 for (FunctionElement function in functions) {
4272 (function as FunctionElementImpl).enclosingElement = this; 4279 (function as FunctionElementImpl).enclosingElement = this;
4273 } 4280 }
4274 this._functions = functions; 4281 this._functions = functions;
4275 } 4282 }
4276 4283
4277 /** 4284 /**
4285 * Set whether this method's body is a generator to correspond to the given va lue.
4286 *
4287 * @param isGenerator `true` if the method's body is a generator
4288 */
4289 void set generator(bool isGenerator) {
4290 setModifier(Modifier.GENERATOR, isGenerator);
4291 }
4292
4293 /**
4278 * Set the labels defined within this executable element to the given labels. 4294 * Set the labels defined within this executable element to the given labels.
4279 * 4295 *
4280 * @param labels the labels defined within this executable element 4296 * @param labels the labels defined within this executable element
4281 */ 4297 */
4282 void set labels(List<LabelElement> labels) { 4298 void set labels(List<LabelElement> labels) {
4283 for (LabelElement label in labels) { 4299 for (LabelElement label in labels) {
4284 (label as LabelElementImpl).enclosingElement = this; 4300 (label as LabelElementImpl).enclosingElement = this;
4285 } 4301 }
4286 this._labels = labels; 4302 this._labels = labels;
4287 } 4303 }
(...skipping 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after
5482 } 5498 }
5483 5499
5484 @override 5500 @override
5485 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, Set<TypeImpl_ TypePair> visitedTypePairs) { 5501 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, Set<TypeImpl_ TypePair> visitedTypePairs) {
5486 // trivial base cases 5502 // trivial base cases
5487 if (type == null) { 5503 if (type == null) {
5488 return false; 5504 return false;
5489 } else if (identical(this, type) || type.isDynamic || type.isDartCoreFunctio n || type.isObject) { 5505 } else if (identical(this, type) || type.isDynamic || type.isDartCoreFunctio n || type.isObject) {
5490 return true; 5506 return true;
5491 } else if (type is UnionType) { 5507 } else if (type is UnionType) {
5492 throw new NotImplementedException("No known use case"); 5508 return (type as UnionTypeImpl).internalUnionTypeIsMoreSpecificThan(this, w ithDynamic, visitedTypePairs);
5493 } else if (type is! FunctionType) { 5509 } else if (type is! FunctionType) {
5494 return false; 5510 return false;
5495 } else if (this == type) { 5511 } else if (this == type) {
5496 return true; 5512 return true;
5497 } 5513 }
5498 FunctionType t = this; 5514 FunctionType t = this;
5499 FunctionType s = type as FunctionType; 5515 FunctionType s = type as FunctionType;
5500 List<DartType> tTypes = t.normalParameterTypes; 5516 List<DartType> tTypes = t.normalParameterTypes;
5501 List<DartType> tOpTypes = t.optionalParameterTypes; 5517 List<DartType> tOpTypes = t.optionalParameterTypes;
5502 List<DartType> sTypes = s.normalParameterTypes; 5518 List<DartType> sTypes = s.normalParameterTypes;
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
5709 return result; 5725 return result;
5710 } 5726 }
5711 5727
5712 @override 5728 @override
5713 bool internalIsSubtypeOf(DartType type, Set<TypeImpl_TypePair> visitedTypePair s) { 5729 bool internalIsSubtypeOf(DartType type, Set<TypeImpl_TypePair> visitedTypePair s) {
5714 // trivial base cases 5730 // trivial base cases
5715 if (type == null) { 5731 if (type == null) {
5716 return false; 5732 return false;
5717 } else if (identical(this, type) || type.isDynamic || type.isDartCoreFunctio n || type.isObject) { 5733 } else if (identical(this, type) || type.isDynamic || type.isDartCoreFunctio n || type.isObject) {
5718 return true; 5734 return true;
5735 } else if (type is UnionType) {
5736 return (type as UnionTypeImpl).internalUnionTypeIsSuperTypeOf(this, visite dTypePairs);
5719 } else if (type is! FunctionType) { 5737 } else if (type is! FunctionType) {
5720 return false; 5738 return false;
5721 } else if (this == type) { 5739 } else if (this == type) {
5722 return true; 5740 return true;
5723 } 5741 }
5724 FunctionType t = this; 5742 FunctionType t = this;
5725 FunctionType s = type as FunctionType; 5743 FunctionType s = type as FunctionType;
5726 List<DartType> tTypes = t.normalParameterTypes; 5744 List<DartType> tTypes = t.normalParameterTypes;
5727 List<DartType> tOpTypes = t.optionalParameterTypes; 5745 List<DartType> tOpTypes = t.optionalParameterTypes;
5728 List<DartType> sTypes = s.normalParameterTypes; 5746 List<DartType> sTypes = s.normalParameterTypes;
(...skipping 1524 matching lines...) Expand 10 before | Expand all | Expand 10 after
7253 @override 7271 @override
7254 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, Set<TypeImpl_ TypePair> visitedTypePairs) { 7272 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, Set<TypeImpl_ TypePair> visitedTypePairs) {
7255 // 7273 //
7256 // S is dynamic. 7274 // S is dynamic.
7257 // The test to determine whether S is dynamic is done here because dynamic i s not an instance of 7275 // The test to determine whether S is dynamic is done here because dynamic i s not an instance of
7258 // InterfaceType. 7276 // InterfaceType.
7259 // 7277 //
7260 if (identical(type, DynamicTypeImpl.instance)) { 7278 if (identical(type, DynamicTypeImpl.instance)) {
7261 return true; 7279 return true;
7262 } else if (type is UnionType) { 7280 } else if (type is UnionType) {
7263 throw new NotImplementedException("No known use case"); 7281 return (type as UnionTypeImpl).internalUnionTypeIsMoreSpecificThan(this, w ithDynamic, visitedTypePairs);
7264 } else if (type is! InterfaceType) { 7282 } else if (type is! InterfaceType) {
7265 return false; 7283 return false;
7266 } 7284 }
7267 return _isMoreSpecificThan(type as InterfaceType, new HashSet<ClassElement>( ), withDynamic, visitedTypePairs); 7285 return _isMoreSpecificThan(type as InterfaceType, new HashSet<ClassElement>( ), withDynamic, visitedTypePairs);
7268 } 7286 }
7269 7287
7270 @override 7288 @override
7271 bool internalIsSubtypeOf(DartType type, Set<TypeImpl_TypePair> visitedTypePair s) { 7289 bool internalIsSubtypeOf(DartType type, Set<TypeImpl_TypePair> visitedTypePair s) {
7272 // 7290 //
7273 // T is a subtype of S, written T <: S, iff [bottom/dynamic]T << S 7291 // T is a subtype of S, written T <: S, iff [bottom/dynamic]T << S
7274 // 7292 //
7275 if (type.isDynamic) { 7293 if (type.isDynamic) {
7276 return true; 7294 return true;
7277 } else if (type is TypeParameterType) { 7295 } else if (type is TypeParameterType) {
7278 return false; 7296 return false;
7297 } else if (type is UnionType) {
7298 return (type as UnionTypeImpl).internalUnionTypeIsSuperTypeOf(this, visite dTypePairs);
7279 } else if (type is FunctionType) { 7299 } else if (type is FunctionType) {
7280 // This implementation assumes transitivity 7300 // This implementation assumes transitivity
7281 // for function type subtyping on the RHS, but a literal reading 7301 // for function type subtyping on the RHS, but a literal reading
7282 // of the spec does not specify this. More precisely: if T <: F1 and F1 <: F2 and 7302 // of the spec does not specify this. More precisely: if T <: F1 and F1 <: F2 and
7283 // F1 and F2 are function types, then we assume T <: F2. 7303 // F1 and F2 are function types, then we assume T <: F2.
7284 // 7304 //
7285 // From the Function Types section of the spec: 7305 // From the Function Types section of the spec:
7286 // 7306 //
7287 // If a type I includes an instance method named call(), and the type of call() 7307 // If a type I includes an instance method named call(), and the type of call()
7288 // is the function type F, then I is considered to be a subtype of F. 7308 // is the function type F, then I is considered to be a subtype of F.
(...skipping 3857 matching lines...) Expand 10 before | Expand all | Expand 10 after
11146 */ 11166 */
11147 UnionTypeImpl(this._types) : super(null, null); 11167 UnionTypeImpl(this._types) : super(null, null);
11148 11168
11149 @override 11169 @override
11150 bool operator ==(Object other) { 11170 bool operator ==(Object other) {
11151 if (other == null || other is! UnionType) { 11171 if (other == null || other is! UnionType) {
11152 return false; 11172 return false;
11153 } else if (identical(this, other)) { 11173 } else if (identical(this, other)) {
11154 return true; 11174 return true;
11155 } else { 11175 } else {
11156 return javaSetEquals(this._types, (other as UnionType).elements); 11176 return javaSetEquals(_types, (other as UnionType).elements);
11157 } 11177 }
11158 } 11178 }
11159 11179
11160 @override 11180 @override
11181 String get displayName {
11182 JavaStringBuilder builder = new JavaStringBuilder();
11183 String prefix = "{";
11184 for (DartType t in _types) {
11185 builder.append(prefix);
11186 builder.append(t.displayName);
11187 prefix = ",";
11188 }
11189 builder.append("}");
11190 return builder.toString();
11191 }
11192
11193 @override
11161 Set<DartType> get elements => _types; 11194 Set<DartType> get elements => _types;
11162 11195
11163 @override 11196 @override
11164 int get hashCode => this._types.hashCode; 11197 int get hashCode => _types.hashCode;
11165 11198
11166 @override 11199 @override
11167 DartType substitute2(List<DartType> argumentTypes, List<DartType> parameterTyp es) { 11200 DartType substitute2(List<DartType> argumentTypes, List<DartType> parameterTyp es) {
11168 // I can't think of any reason to substitute into a union type, since 11201 List<DartType> out = new List<DartType>();
11169 // they should only appear at the top level and not be be nested inside 11202 for (DartType t in _types) {
11170 // other types. 11203 out.add(t.substitute2(argumentTypes, parameterTypes));
11171 // 11204 }
11172 // If there were a reason, then the implementation is to form a new union ty pe 11205 return union(new List.from(out));
11173 // by mapping the substitution over the elements of this union type.
11174 throw new NotImplementedException("No known use case.");
11175 } 11206 }
11176 11207
11177 @override 11208 @override
11178 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs) { 11209 void appendTo(JavaStringBuilder builder) {
11179 // TODO(collinsn): I understand why we have the [visitedElementPairs] 11210 String prefix = "{";
11180 // in subtyping definitions: the user code could have inheritance loops, e.g . 11211 for (DartType t in _types) {
11181 // 11212 builder.append(prefix);
11182 // class A extends B {} 11213 (t as TypeImpl).appendTo(builder);
11183 // class B extends A {} 11214 prefix = ",";
11184 // 11215 }
11185 // However, I don't see how a type equality comparison could cause a loop, s ince type 11216 builder.append("}");
11186 // equality should be structural. For example, we have
11187 //
11188 // G<X1,...,Xm> = H<Y1,...,Yn>
11189 //
11190 // when [G = H /\ m = n /\ for all i. Xi = Yi]. Assuming there is no way to build
11191 // loopy generics (which would break [toString()]), each of the equality com parisons
11192 // above are on something structurally smaller.
11193 throw new NotImplementedException("I don't believe there is any concern abou t infinite loops in type equality comparisons.");
11194 } 11217 }
11195 11218
11196 @override 11219 @override
11220 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs) => th is == object;
11221
11222 @override
11197 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, Set<TypeImpl_ TypePair> visitedTypePairs) { 11223 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, Set<TypeImpl_ TypePair> visitedTypePairs) {
11198 // I can't think of any reason to use [isMoreSpecificThan] for union types. 11224 // TODO(collinsn): what version of subtyping do we want?
11199 throw new NotImplementedException("No known use case."); 11225 //
11226 // The more unsound version: any.
11227 /*
11228 for (Type t : types) {
11229 if (((TypeImpl) t).internalIsMoreSpecificThan(type, withDynamic, visitedTy pePairs)) {
11230 return true;
11231 }
11232 }
11233 return false;
11234 */
11235 // The less unsound version: all.
11236 for (DartType t in _types) {
11237 if (!(t as TypeImpl).internalIsMoreSpecificThan(type, withDynamic, visited TypePairs)) {
11238 return false;
11239 }
11240 }
11241 return true;
11200 } 11242 }
11201 11243
11202 @override 11244 @override
11203 bool internalIsSubtypeOf(DartType type, Set<TypeImpl_TypePair> visitedTypePair s) { 11245 bool internalIsSubtypeOf(DartType type, Set<TypeImpl_TypePair> visitedTypePair s) {
11204 // TODO(collinsn): what version of subtyping do we want? 11246 // TODO(collinsn): what version of subtyping do we want?
11205 // 11247 //
11206 // The more unsound version: any. 11248 // The more unsound version: any.
11207 /* 11249 /*
11208 for (Type t : this.types) { 11250 for (Type t : types) {
11209 if (((TypeImpl) t).internalIsSubtypeOf(type, visitedTypePairs)) { 11251 if (((TypeImpl) t).internalIsSubtypeOf(type, visitedTypePairs)) {
11210 return true; 11252 return true;
11211 } 11253 }
11212 } 11254 }
11213 return false; 11255 return false;
11214 */ 11256 */
11215 // The less unsound version: all. 11257 // The less unsound version: all.
11216 for (DartType t in this._types) { 11258 for (DartType t in _types) {
11217 if (!(t as TypeImpl).internalIsSubtypeOf(type, visitedTypePairs)) { 11259 if (!(t as TypeImpl).internalIsSubtypeOf(type, visitedTypePairs)) {
11218 return false; 11260 return false;
11219 } 11261 }
11220 } 11262 }
11221 return true; 11263 return true;
11222 } 11264 }
11223 11265
11224 /** 11266 /**
11225 * The super type test for union types is uniform in non-union subtypes. So, o ther 11267 * The more-specific-than test for union types on the RHS is uniform in non-un ion LHSs. So, other
11226 * `TypeImpl`s can call this method to implement @ internalIsSubtypeOf} for un ion types. 11268 * `TypeImpl`s can call this method to implement `internalIsMoreSpecificThan` for
11269 * union types.
11270 *
11271 * @param type
11272 * @param visitedTypePairs
11273 * @return true if `type` is more specific than this union type
11274 */
11275 bool internalUnionTypeIsMoreSpecificThan(DartType type, bool withDynamic, Set< TypeImpl_TypePair> visitedTypePairs) {
11276 // This implementation does not make sense when [type] is a union type, at l east
11277 // for the "less unsound" version of [internalIsMoreSpecificThan] above.
11278 if (type is UnionType) {
11279 throw new IllegalArgumentException("Only non-union types are supported.");
11280 }
11281 for (DartType t in _types) {
11282 if ((type as TypeImpl).internalIsMoreSpecificThan(t, withDynamic, visitedT ypePairs)) {
11283 return true;
11284 }
11285 }
11286 return false;
11287 }
11288
11289 /**
11290 * The supertype test for union types is uniform in non-union subtypes. So, ot her `TypeImpl`
11291 * s can call this method to implement `internalIsSubtypeOf` for union types.
11227 * 11292 *
11228 * @param type 11293 * @param type
11229 * @param visitedTypePairs 11294 * @param visitedTypePairs
11230 * @return true if this union type is a super type of `type` 11295 * @return true if this union type is a super type of `type`
11231 */ 11296 */
11232 bool internalIsSuperTypeOf(DartType type, Set<TypeImpl_TypePair> visitedTypePa irs) { 11297 bool internalUnionTypeIsSuperTypeOf(DartType type, Set<TypeImpl_TypePair> visi tedTypePairs) {
11233 // This implementation does not make sense when [type] is a union type, at l east 11298 // This implementation does not make sense when [type] is a union type, at l east
11234 // for the "less unsound" version of [internalIsSubtypeOf] above. 11299 // for the "less unsound" version of [internalIsSubtypeOf] above.
11235 if (type is UnionType) { 11300 if (type is UnionType) {
11236 throw new IllegalArgumentException("Only non-union types are supported."); 11301 throw new IllegalArgumentException("Only non-union types are supported.");
11237 } 11302 }
11238 for (DartType t in this._types) { 11303 for (DartType t in _types) {
11239 if ((type as TypeImpl).internalIsSubtypeOf(t, visitedTypePairs)) { 11304 if ((type as TypeImpl).internalIsSubtypeOf(t, visitedTypePairs)) {
11240 return true; 11305 return true;
11241 } 11306 }
11242 } 11307 }
11243 return false; 11308 return false;
11244 } 11309 }
11245 } 11310 }
11246 11311
11247 /** 11312 /**
11248 * The interface `UriReferencedElement` defines the behavior of objects included into a 11313 * The interface `UriReferencedElement` defines the behavior of objects included into a
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
11574 11639
11575 @override 11640 @override
11576 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs) => id entical(object, this); 11641 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs) => id entical(object, this);
11577 11642
11578 @override 11643 @override
11579 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, Set<TypeImpl_ TypePair> visitedTypePairs) => isSubtypeOf(type); 11644 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, Set<TypeImpl_ TypePair> visitedTypePairs) => isSubtypeOf(type);
11580 11645
11581 @override 11646 @override
11582 bool internalIsSubtypeOf(DartType type, Set<TypeImpl_TypePair> visitedTypePair s) { 11647 bool internalIsSubtypeOf(DartType type, Set<TypeImpl_TypePair> visitedTypePair s) {
11583 if (type is UnionType) { 11648 if (type is UnionType) {
11584 throw new NotImplementedException("No known use case"); 11649 return (type as UnionTypeImpl).internalUnionTypeIsSuperTypeOf(this, visite dTypePairs);
11585 } 11650 }
11586 // The only subtype relations that pertain to void are therefore: 11651 // The only subtype relations that pertain to void are therefore:
11587 // void <: void (by reflexivity) 11652 // void <: void (by reflexivity)
11588 // bottom <: void (as bottom is a subtype of all types). 11653 // bottom <: void (as bottom is a subtype of all types).
11589 // void <: dynamic (as dynamic is a supertype of all types) 11654 // void <: dynamic (as dynamic is a supertype of all types)
11590 return identical(type, this) || identical(type, DynamicTypeImpl.instance); 11655 return identical(type, this) || identical(type, DynamicTypeImpl.instance);
11591 } 11656 }
11592 } 11657 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/ast.dart ('k') | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698