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

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

Issue 11412245: MalformedType used for all invalid type annotations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Bug fixes Created 8 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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; 5 library elements;
6 6
7 import 'dart:uri'; 7 import 'dart:uri';
8 8
9 // TODO(ahe): Rename prefix to 'api' when VM bug is fixed. 9 // TODO(ahe): Rename prefix to 'api' when VM bug is fixed.
10 import '../../compiler.dart' as api_e; 10 import '../../compiler.dart' as api_e;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 bool isLibrary() => identical(kind, ElementKind.LIBRARY); 195 bool isLibrary() => identical(kind, ElementKind.LIBRARY);
196 bool impliesType() => (kind.category & ElementCategory.IMPLIES_TYPE) != 0; 196 bool impliesType() => (kind.category & ElementCategory.IMPLIES_TYPE) != 0;
197 bool isExtendable() => (kind.category & ElementCategory.IS_EXTENDABLE) != 0; 197 bool isExtendable() => (kind.category & ElementCategory.IS_EXTENDABLE) != 0;
198 198
199 /** See [ErroneousElement] for documentation. */ 199 /** See [ErroneousElement] for documentation. */
200 bool isErroneous() => false; 200 bool isErroneous() => false;
201 201
202 /** See [AmbiguousElement] for documentation. */ 202 /** See [AmbiguousElement] for documentation. */
203 bool isAmbiguous() => false; 203 bool isAmbiguous() => false;
204 204
205 bool isMalformed() => false;
206
207 /** 205 /**
208 * Is [:true:] if this element has a corresponding patch. 206 * Is [:true:] if this element has a corresponding patch.
209 * 207 *
210 * If [:true:] this element has a non-null [patch] field. 208 * If [:true:] this element has a non-null [patch] field.
211 * 209 *
212 * See [:patch_parser.dart:] for a description of the terminology. 210 * See [:patch_parser.dart:] for a description of the terminology.
213 */ 211 */
214 bool get isPatched => false; 212 bool get isPatched => false;
215 213
216 /** 214 /**
(...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 class VoidElement extends Element { 1339 class VoidElement extends Element {
1342 VoidElement(Element enclosing) 1340 VoidElement(Element enclosing)
1343 : super(const SourceString('void'), ElementKind.VOID, enclosing); 1341 : super(const SourceString('void'), ElementKind.VOID, enclosing);
1344 DartType computeType(compiler) => compiler.types.voidType; 1342 DartType computeType(compiler) => compiler.types.voidType;
1345 Node parseNode(_) { 1343 Node parseNode(_) {
1346 throw 'internal error: parseNode on void'; 1344 throw 'internal error: parseNode on void';
1347 } 1345 }
1348 bool impliesType() => true; 1346 bool impliesType() => true;
1349 } 1347 }
1350 1348
1351 class MalformedTypeElement extends Element {
1352 final TypeAnnotation typeNode;
1353
1354 MalformedTypeElement(this.typeNode, Element enclosing)
1355 : super(const SourceString('malformed'),
1356 ElementKind.MALFORMED_TYPE,
1357 enclosing);
1358
1359 DartType computeType(compiler) => compiler.types.malformedType;
1360
1361 Node parseNode(_) => typeNode;
1362
1363 bool impliesType() => true;
1364
1365 bool isMalformed() => true;
1366 }
1367
1368 /** 1349 /**
1369 * [TypeDeclarationElement] defines the common interface for class/interface 1350 * [TypeDeclarationElement] defines the common interface for class/interface
1370 * declarations and typedefs. 1351 * declarations and typedefs.
1371 */ 1352 */
1372 abstract class TypeDeclarationElement implements Element { 1353 abstract class TypeDeclarationElement implements Element {
1373 // TODO(johnniwinther): This class should eventually be a mixin. 1354 // TODO(johnniwinther): This class should eventually be a mixin.
1374 1355
1375 /** 1356 /**
1376 * The type variables declared on this declaration. The type variables are not 1357 * The type variables declared on this declaration. The type variables are not
1377 * available until the type of the element has been computed through 1358 * available until the type of the element has been computed through
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
1800 } else if (patch != null) { 1781 } else if (patch != null) {
1801 return 'origin ${super.toString()}'; 1782 return 'origin ${super.toString()}';
1802 } else { 1783 } else {
1803 return super.toString(); 1784 return super.toString();
1804 } 1785 }
1805 } 1786 }
1806 } 1787 }
1807 1788
1808 class Elements { 1789 class Elements {
1809 static bool isUnresolved(Element e) { 1790 static bool isUnresolved(Element e) {
1810 return e == null || e.isErroneous() || e.isMalformed(); 1791 return e == null || e.isErroneous();
1811 } 1792 }
1812 static bool isErroneousElement(Element e) => e != null && e.isErroneous(); 1793 static bool isErroneousElement(Element e) => e != null && e.isErroneous();
1813 static bool isMalformedElement(Element e) => e != null && e.isMalformed();
1814 1794
1815 static bool isClass(Element e) => e != null && e.kind == ElementKind.CLASS; 1795 static bool isClass(Element e) => e != null && e.kind == ElementKind.CLASS;
1816 static bool isTypedef(Element e) { 1796 static bool isTypedef(Element e) {
1817 return e != null && e.kind == ElementKind.TYPEDEF; 1797 return e != null && e.kind == ElementKind.TYPEDEF;
1818 } 1798 }
1819 1799
1820 static bool isLocal(Element element) { 1800 static bool isLocal(Element element) {
1821 return !Elements.isUnresolved(element) 1801 return !Elements.isUnresolved(element)
1822 && !element.isInstanceMember() 1802 && !element.isInstanceMember()
1823 && !isStaticOrTopLevelField(element) 1803 && !isStaticOrTopLevelField(element)
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
2149 2129
2150 MetadataAnnotation ensureResolved(Compiler compiler) { 2130 MetadataAnnotation ensureResolved(Compiler compiler) {
2151 if (resolutionState == STATE_NOT_STARTED) { 2131 if (resolutionState == STATE_NOT_STARTED) {
2152 compiler.resolver.resolveMetadataAnnotation(this); 2132 compiler.resolver.resolveMetadataAnnotation(this);
2153 } 2133 }
2154 return this; 2134 return this;
2155 } 2135 }
2156 2136
2157 String toString() => 'MetadataAnnotation($value, $resolutionState)'; 2137 String toString() => 'MetadataAnnotation($value, $resolutionState)';
2158 } 2138 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698