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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/elements/modelx.dart

Issue 88153003: Add synthetic type variables to unnamed mixin applications. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 7 years 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
OLDNEW
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 1752 matching lines...) Expand 10 before | Expand all | Expand 10 after
1763 int get hashCode => id; 1763 int get hashCode => id;
1764 ClassElement get patch => super.patch; 1764 ClassElement get patch => super.patch;
1765 ClassElement get origin => super.origin; 1765 ClassElement get origin => super.origin;
1766 ClassElement get declaration => super.declaration; 1766 ClassElement get declaration => super.declaration;
1767 ClassElement get implementation => super.implementation; 1767 ClassElement get implementation => super.implementation;
1768 1768
1769 bool get hasBackendMembers => !backendMembers.isEmpty; 1769 bool get hasBackendMembers => !backendMembers.isEmpty;
1770 1770
1771 bool get isUnnamedMixinApplication => false; 1771 bool get isUnnamedMixinApplication => false;
1772 1772
1773 // TODO(johnniwinther): Add [thisType] getter similar to [rawType]. 1773 void computeThisAndRawType(Compiler compiler, Link<DartType> typeVariables) {
1774 InterfaceType computeType(Compiler compiler) {
1775 if (thisType == null) { 1774 if (thisType == null) {
1776 if (origin == null) { 1775 if (origin == null) {
1777 Link<DartType> parameters = computeTypeParameters(compiler); 1776 Link<DartType> parameters = typeVariables;
1778 thisType = new InterfaceType(this, parameters); 1777 thisType = new InterfaceType(this, parameters);
1779 if (parameters.isEmpty) { 1778 if (parameters.isEmpty) {
1780 rawTypeCache = thisType; 1779 rawTypeCache = thisType;
1781 } else { 1780 } else {
1782 var dynamicParameters = const Link<DartType>(); 1781 var dynamicParameters = const Link<DartType>();
1783 parameters.forEach((_) { 1782 parameters.forEach((_) {
1784 dynamicParameters = 1783 dynamicParameters =
1785 dynamicParameters.prepend(compiler.types.dynamicType); 1784 dynamicParameters.prepend(compiler.types.dynamicType);
1786 }); 1785 });
1787 rawTypeCache = new InterfaceType(this, dynamicParameters); 1786 rawTypeCache = new InterfaceType(this, dynamicParameters);
1788 } 1787 }
1789 } else { 1788 } else {
1790 thisType = origin.computeType(compiler); 1789 thisType = origin.computeType(compiler);
1791 rawTypeCache = origin.rawType; 1790 rawTypeCache = origin.rawType;
1792 } 1791 }
1793 } 1792 }
1793 }
1794
1795 // TODO(johnniwinther): Add [thisType] getter similar to [rawType].
1796 InterfaceType computeType(Compiler compiler) {
1797 if (thisType == null) {
1798 computeThisAndRawType(compiler, computeTypeParameters(compiler));
1799 }
1794 return thisType; 1800 return thisType;
1795 } 1801 }
1796 1802
1797 InterfaceType get rawType { 1803 InterfaceType get rawType {
1798 assert(invariant(this, rawTypeCache != null, 1804 assert(invariant(this, rawTypeCache != null,
1799 message: 'Raw type has not been computed for $this')); 1805 message: 'Raw type has not been computed for $this'));
1800 return rawTypeCache; 1806 return rawTypeCache;
1801 } 1807 }
1802 1808
1803 Link<DartType> computeTypeParameters(Compiler compiler); 1809 Link<DartType> computeTypeParameters(Compiler compiler);
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
2289 constructors = constructors.prepend(constructor); 2295 constructors = constructors.prepend(constructor);
2290 } 2296 }
2291 2297
2292 void setDefaultConstructor(FunctionElement constructor, Compiler compiler) { 2298 void setDefaultConstructor(FunctionElement constructor, Compiler compiler) {
2293 assert(!hasConstructor); 2299 assert(!hasConstructor);
2294 addConstructor(constructor); 2300 addConstructor(constructor);
2295 } 2301 }
2296 2302
2297 Link<DartType> computeTypeParameters(Compiler compiler) { 2303 Link<DartType> computeTypeParameters(Compiler compiler) {
2298 NamedMixinApplication named = node.asNamedMixinApplication(); 2304 NamedMixinApplication named = node.asNamedMixinApplication();
2299 if (named == null) return const Link<DartType>(); 2305 if (named == null) {
2306 throw new SpannableAssertionFailure(node,
2307 "Type variables on unnamed mixin applications must be set on "
2308 "creation.");
2309 }
2300 return TypeDeclarationElementX.createTypeVariables( 2310 return TypeDeclarationElementX.createTypeVariables(
2301 this, named.typeParameters); 2311 this, named.typeParameters);
2302 } 2312 }
2303 2313
2304 accept(ElementVisitor visitor) => visitor.visitMixinApplicationElement(this); 2314 accept(ElementVisitor visitor) => visitor.visitMixinApplicationElement(this);
2305 } 2315 }
2306 2316
2307 class LabelElementX extends ElementX implements LabelElement { 2317 class LabelElementX extends ElementX implements LabelElement {
2308 2318
2309 // We store the original label here so it can be returned by [parseNode]. 2319 // We store the original label here so it can be returned by [parseNode].
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2370 String toString() => statement.toString(); 2380 String toString() => statement.toString();
2371 2381
2372 accept(ElementVisitor visitor) => visitor.visitTargetElement(this); 2382 accept(ElementVisitor visitor) => visitor.visitTargetElement(this);
2373 } 2383 }
2374 2384
2375 class TypeVariableElementX extends ElementX implements TypeVariableElement { 2385 class TypeVariableElementX extends ElementX implements TypeVariableElement {
2376 final Node cachedNode; 2386 final Node cachedNode;
2377 TypeVariableType type; 2387 TypeVariableType type;
2378 DartType bound; 2388 DartType bound;
2379 2389
2380 TypeVariableElementX(name, Element enclosing, this.cachedNode, 2390 TypeVariableElementX(String name, Element enclosing, this.cachedNode,
2381 [this.type, this.bound]) 2391 [this.type, this.bound])
2382 : super(name, ElementKind.TYPE_VARIABLE, enclosing); 2392 : super(name, ElementKind.TYPE_VARIABLE, enclosing);
2383 2393
2384 TypeVariableType computeType(compiler) => type; 2394 TypeVariableType computeType(compiler) => type;
2385 2395
2386 Node parseNode(compiler) => cachedNode; 2396 Node parseNode(compiler) => cachedNode;
2387 2397
2388 String toString() => "${enclosingElement.toString()}.${name}"; 2398 String toString() => "${enclosingElement.toString()}.${name}";
2389 2399
2390 Token position() => cachedNode.getBeginToken(); 2400 Token position() => cachedNode.getBeginToken();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2434 2444
2435 MetadataAnnotation ensureResolved(Compiler compiler) { 2445 MetadataAnnotation ensureResolved(Compiler compiler) {
2436 if (resolutionState == STATE_NOT_STARTED) { 2446 if (resolutionState == STATE_NOT_STARTED) {
2437 compiler.resolver.resolveMetadataAnnotation(this); 2447 compiler.resolver.resolveMetadataAnnotation(this);
2438 } 2448 }
2439 return this; 2449 return this;
2440 } 2450 }
2441 2451
2442 String toString() => 'MetadataAnnotation($value, $resolutionState)'; 2452 String toString() => 'MetadataAnnotation($value, $resolutionState)';
2443 } 2453 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698