Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 elements.modelx; | 5 library elements.modelx; |
| 6 | 6 |
| 7 import 'elements.dart'; | 7 import 'elements.dart'; |
| 8 import '../../compiler.dart' as api; | 8 import '../../compiler.dart' as api; |
| 9 import '../tree/tree.dart'; | 9 import '../tree/tree.dart'; |
| 10 import '../util/util.dart'; | 10 import '../util/util.dart'; |
| (...skipping 1712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1723 int get hashCode => id; | 1723 int get hashCode => id; |
| 1724 ClassElement get patch => super.patch; | 1724 ClassElement get patch => super.patch; |
| 1725 ClassElement get origin => super.origin; | 1725 ClassElement get origin => super.origin; |
| 1726 ClassElement get declaration => super.declaration; | 1726 ClassElement get declaration => super.declaration; |
| 1727 ClassElement get implementation => super.implementation; | 1727 ClassElement get implementation => super.implementation; |
| 1728 | 1728 |
| 1729 bool get hasBackendMembers => !backendMembers.isEmpty; | 1729 bool get hasBackendMembers => !backendMembers.isEmpty; |
| 1730 | 1730 |
| 1731 bool get isUnnamedMixinApplication => false; | 1731 bool get isUnnamedMixinApplication => false; |
| 1732 | 1732 |
| 1733 // TODO(johnniwinther): Add [thisType] getter similar to [rawType]. | 1733 void computeThisAndRawType(Compiler compiler, Link<DartType> typeVariables) { |
| 1734 InterfaceType computeType(Compiler compiler) { | |
| 1735 if (thisType == null) { | 1734 if (thisType == null) { |
| 1736 if (origin == null) { | 1735 if (origin == null) { |
| 1737 Link<DartType> parameters = computeTypeParameters(compiler); | 1736 Link<DartType> parameters = typeVariables; |
| 1738 thisType = new InterfaceType(this, parameters); | 1737 thisType = new InterfaceType(this, parameters); |
| 1739 if (parameters.isEmpty) { | 1738 if (parameters.isEmpty) { |
| 1740 rawTypeCache = thisType; | 1739 rawTypeCache = thisType; |
| 1741 } else { | 1740 } else { |
| 1742 var dynamicParameters = const Link<DartType>(); | 1741 var dynamicParameters = const Link<DartType>(); |
| 1743 parameters.forEach((_) { | 1742 parameters.forEach((_) { |
| 1744 dynamicParameters = | 1743 dynamicParameters = |
| 1745 dynamicParameters.prepend(compiler.types.dynamicType); | 1744 dynamicParameters.prepend(compiler.types.dynamicType); |
| 1746 }); | 1745 }); |
| 1747 rawTypeCache = new InterfaceType(this, dynamicParameters); | 1746 rawTypeCache = new InterfaceType(this, dynamicParameters); |
| 1748 } | 1747 } |
| 1749 } else { | 1748 } else { |
| 1750 thisType = origin.computeType(compiler); | 1749 thisType = origin.computeType(compiler); |
| 1751 rawTypeCache = origin.rawType; | 1750 rawTypeCache = origin.rawType; |
| 1752 } | 1751 } |
| 1753 } | 1752 } |
| 1753 } | |
| 1754 | |
| 1755 // TODO(johnniwinther): Add [thisType] getter similar to [rawType]. | |
| 1756 InterfaceType computeType(Compiler compiler) { | |
| 1757 if (thisType == null) { | |
| 1758 computeThisAndRawType(compiler, computeTypeParameters(compiler)); | |
| 1759 } | |
| 1754 return thisType; | 1760 return thisType; |
| 1755 } | 1761 } |
| 1756 | 1762 |
| 1757 InterfaceType get rawType { | 1763 InterfaceType get rawType { |
| 1758 assert(invariant(this, rawTypeCache != null, | 1764 assert(invariant(this, rawTypeCache != null, |
| 1759 message: 'Raw type has not been computed for $this')); | 1765 message: 'Raw type has not been computed for $this')); |
| 1760 return rawTypeCache; | 1766 return rawTypeCache; |
| 1761 } | 1767 } |
| 1762 | 1768 |
| 1763 Link<DartType> computeTypeParameters(Compiler compiler); | 1769 Link<DartType> computeTypeParameters(Compiler compiler); |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2249 constructors = constructors.prepend(constructor); | 2255 constructors = constructors.prepend(constructor); |
| 2250 } | 2256 } |
| 2251 | 2257 |
| 2252 void setDefaultConstructor(FunctionElement constructor, Compiler compiler) { | 2258 void setDefaultConstructor(FunctionElement constructor, Compiler compiler) { |
| 2253 assert(!hasConstructor); | 2259 assert(!hasConstructor); |
| 2254 addConstructor(constructor); | 2260 addConstructor(constructor); |
| 2255 } | 2261 } |
| 2256 | 2262 |
| 2257 Link<DartType> computeTypeParameters(Compiler compiler) { | 2263 Link<DartType> computeTypeParameters(Compiler compiler) { |
| 2258 NamedMixinApplication named = node.asNamedMixinApplication(); | 2264 NamedMixinApplication named = node.asNamedMixinApplication(); |
| 2259 if (named == null) return const Link<DartType>(); | 2265 assert(invariant(this, named != null, |
|
ahe
2013/11/28 15:28:26
I'd really prefer if we didn't add redundant asser
Johnni Winther
2013/12/03 15:57:38
Done.
| |
| 2266 message: "computeTypeParameters called for unnamed mixin application")); | |
| 2260 return TypeDeclarationElementX.createTypeVariables( | 2267 return TypeDeclarationElementX.createTypeVariables( |
| 2261 this, named.typeParameters); | 2268 this, named.typeParameters); |
| 2262 } | 2269 } |
| 2263 } | 2270 } |
| 2264 | 2271 |
| 2265 class LabelElementX extends ElementX implements LabelElement { | 2272 class LabelElementX extends ElementX implements LabelElement { |
| 2266 | 2273 |
| 2267 // We store the original label here so it can be returned by [parseNode]. | 2274 // We store the original label here so it can be returned by [parseNode]. |
| 2268 final Label label; | 2275 final Label label; |
| 2269 final String labelName; | 2276 final String labelName; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2324 | 2331 |
| 2325 Token position() => statement.getBeginToken(); | 2332 Token position() => statement.getBeginToken(); |
| 2326 String toString() => statement.toString(); | 2333 String toString() => statement.toString(); |
| 2327 } | 2334 } |
| 2328 | 2335 |
| 2329 class TypeVariableElementX extends ElementX implements TypeVariableElement { | 2336 class TypeVariableElementX extends ElementX implements TypeVariableElement { |
| 2330 final Node cachedNode; | 2337 final Node cachedNode; |
| 2331 TypeVariableType type; | 2338 TypeVariableType type; |
| 2332 DartType bound; | 2339 DartType bound; |
| 2333 | 2340 |
| 2334 TypeVariableElementX(name, Element enclosing, this.cachedNode, | 2341 TypeVariableElementX(String name, Element enclosing, this.cachedNode, |
| 2335 [this.type, this.bound]) | 2342 [this.type, this.bound]) |
| 2336 : super(name, ElementKind.TYPE_VARIABLE, enclosing); | 2343 : super(name, ElementKind.TYPE_VARIABLE, enclosing); |
| 2337 | 2344 |
| 2338 TypeVariableType computeType(compiler) => type; | 2345 TypeVariableType computeType(compiler) => type; |
| 2339 | 2346 |
| 2340 Node parseNode(compiler) => cachedNode; | 2347 Node parseNode(compiler) => cachedNode; |
| 2341 | 2348 |
| 2342 String toString() => "${enclosingElement.toString()}.${name}"; | 2349 String toString() => "${enclosingElement.toString()}.${name}"; |
| 2343 | 2350 |
| 2344 Token position() => cachedNode.getBeginToken(); | 2351 Token position() => cachedNode.getBeginToken(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2386 | 2393 |
| 2387 MetadataAnnotation ensureResolved(Compiler compiler) { | 2394 MetadataAnnotation ensureResolved(Compiler compiler) { |
| 2388 if (resolutionState == STATE_NOT_STARTED) { | 2395 if (resolutionState == STATE_NOT_STARTED) { |
| 2389 compiler.resolver.resolveMetadataAnnotation(this); | 2396 compiler.resolver.resolveMetadataAnnotation(this); |
| 2390 } | 2397 } |
| 2391 return this; | 2398 return this; |
| 2392 } | 2399 } |
| 2393 | 2400 |
| 2394 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 2401 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
| 2395 } | 2402 } |
| OLD | NEW |