OLD | NEW |
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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 if (enclosingElement != null && !isTopLevel()) { | 348 if (enclosingElement != null && !isTopLevel()) { |
349 String holderName = enclosingElement.name != null | 349 String holderName = enclosingElement.name != null |
350 ? enclosingElement.name.slowToString() | 350 ? enclosingElement.name.slowToString() |
351 : '${enclosingElement.kind}?'; | 351 : '${enclosingElement.kind}?'; |
352 return '$kind($holderName#${nameText})'; | 352 return '$kind($holderName#${nameText})'; |
353 } else { | 353 } else { |
354 return '$kind(${nameText})'; | 354 return '$kind(${nameText})'; |
355 } | 355 } |
356 } | 356 } |
357 | 357 |
358 bool _isNative = false; | 358 String _nativeName = null; |
359 void setNative() { _isNative = true; } | 359 bool isNative() => _nativeName != null; |
360 bool isNative() => _isNative; | 360 String nativeName() => _nativeName; |
| 361 /// Marks this element as a native element. |
| 362 void setNative(String name) { _nativeName = name; } |
361 | 363 |
362 FunctionElement asFunctionElement() => null; | 364 FunctionElement asFunctionElement() => null; |
363 | 365 |
364 static bool isInvalid(Element e) => e == null || e.isErroneous(); | 366 static bool isInvalid(Element e) => e == null || e.isErroneous(); |
365 | 367 |
366 bool isAbstract(Compiler compiler) => modifiers.isAbstract(); | 368 bool isAbstract(Compiler compiler) => modifiers.isAbstract(); |
367 } | 369 } |
368 | 370 |
369 /** | 371 /** |
370 * Represents an unresolvable or duplicated element. | 372 * Represents an unresolvable or duplicated element. |
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1380 } | 1382 } |
1381 } | 1383 } |
1382 | 1384 |
1383 abstract class ClassElement extends ScopeContainerElement | 1385 abstract class ClassElement extends ScopeContainerElement |
1384 implements TypeDeclarationElement { | 1386 implements TypeDeclarationElement { |
1385 final int id; | 1387 final int id; |
1386 InterfaceType type; | 1388 InterfaceType type; |
1387 DartType supertype; | 1389 DartType supertype; |
1388 DartType defaultClass; | 1390 DartType defaultClass; |
1389 Link<DartType> interfaces; | 1391 Link<DartType> interfaces; |
1390 SourceString nativeName; | 1392 SourceString nativeTagInfo; |
1391 int supertypeLoadState; | 1393 int supertypeLoadState; |
1392 int resolutionState; | 1394 int resolutionState; |
1393 | 1395 |
1394 // backendMembers are members that have been added by the backend to simplify | 1396 // backendMembers are members that have been added by the backend to simplify |
1395 // compilation. They don't have any user-side counter-part. | 1397 // compilation. They don't have any user-side counter-part. |
1396 Link<Element> backendMembers = const Link<Element>(); | 1398 Link<Element> backendMembers = const Link<Element>(); |
1397 | 1399 |
1398 Link<DartType> allSupertypes; | 1400 Link<DartType> allSupertypes; |
1399 | 1401 |
1400 // Lazily applied patch of class members. | 1402 // Lazily applied patch of class members. |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1717 * account. | 1719 * account. |
1718 */ | 1720 */ |
1719 bool isSubclassOf(ClassElement cls) { | 1721 bool isSubclassOf(ClassElement cls) { |
1720 for (ClassElement s = this; s != null; s = s.superclass) { | 1722 for (ClassElement s = this; s != null; s = s.superclass) { |
1721 if (identical(s, cls)) return true; | 1723 if (identical(s, cls)) return true; |
1722 } | 1724 } |
1723 return false; | 1725 return false; |
1724 } | 1726 } |
1725 | 1727 |
1726 bool isInterface() => false; | 1728 bool isInterface() => false; |
1727 bool isNative() => nativeName != null; | 1729 bool isNative() => nativeTagInfo != null; |
1728 int get hashCode => id; | 1730 int get hashCode => id; |
1729 | 1731 |
1730 Scope buildScope() => new ClassScope(enclosingElement.buildScope(), this); | 1732 Scope buildScope() => new ClassScope(enclosingElement.buildScope(), this); |
1731 | 1733 |
1732 Link<DartType> get allSupertypesAndSelf { | 1734 Link<DartType> get allSupertypesAndSelf { |
1733 return allSupertypes.prepend(new InterfaceType(this)); | 1735 return allSupertypes.prepend(new InterfaceType(this)); |
1734 } | 1736 } |
1735 | 1737 |
1736 String toString() { | 1738 String toString() { |
1737 if (origin != null) { | 1739 if (origin != null) { |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2075 | 2077 |
2076 MetadataAnnotation ensureResolved(Compiler compiler) { | 2078 MetadataAnnotation ensureResolved(Compiler compiler) { |
2077 if (resolutionState == STATE_NOT_STARTED) { | 2079 if (resolutionState == STATE_NOT_STARTED) { |
2078 compiler.resolver.resolveMetadataAnnotation(this); | 2080 compiler.resolver.resolveMetadataAnnotation(this); |
2079 } | 2081 } |
2080 return this; | 2082 return this; |
2081 } | 2083 } |
2082 | 2084 |
2083 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 2085 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
2084 } | 2086 } |
OLD | NEW |