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 'dart:uri'; | 7 import 'dart:uri'; |
| 8 | 8 |
| 9 import 'elements.dart'; | 9 import 'elements.dart'; |
| 10 import '../../compiler.dart' as api; | 10 import '../../compiler.dart' as api; |
| (...skipping 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1394 } | 1394 } |
| 1395 | 1395 |
| 1396 /** | 1396 /** |
| 1397 * Return [:true:] if this element is the [:Object:] class for the [compiler]. | 1397 * Return [:true:] if this element is the [:Object:] class for the [compiler]. |
| 1398 */ | 1398 */ |
| 1399 bool isObject(Compiler compiler) => | 1399 bool isObject(Compiler compiler) => |
| 1400 identical(declaration, compiler.objectClass); | 1400 identical(declaration, compiler.objectClass); |
| 1401 | 1401 |
| 1402 Link<DartType> get typeVariables => thisType.typeArguments; | 1402 Link<DartType> get typeVariables => thisType.typeArguments; |
| 1403 | 1403 |
| 1404 ClassElement ensureResolved(Compiler compiler) { | |
| 1405 if (resolutionState == STATE_NOT_STARTED) { | |
| 1406 compiler.resolver.resolveClass(this); | |
| 1407 } | |
| 1408 return this; | |
| 1409 } | |
| 1410 | |
| 1411 void addBackendMember(Element member) { | 1404 void addBackendMember(Element member) { |
| 1412 backendMembers = backendMembers.prepend(member); | 1405 backendMembers = backendMembers.prepend(member); |
| 1413 } | 1406 } |
| 1414 | 1407 |
| 1415 void reverseBackendMembers() { | 1408 void reverseBackendMembers() { |
| 1416 backendMembers = backendMembers.reverse(); | 1409 backendMembers = backendMembers.reverse(); |
| 1417 } | 1410 } |
| 1418 | 1411 |
| 1419 /** | 1412 /** |
| 1420 * Lookup local members in the class. This will ignore constructors. | 1413 * Lookup local members in the class. This will ignore constructors. |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1740 } | 1733 } |
| 1741 | 1734 |
| 1742 bool get hasConstructor { | 1735 bool get hasConstructor { |
| 1743 // Search in scope to be sure we search patched constructors. | 1736 // Search in scope to be sure we search patched constructors. |
| 1744 for (var element in localScope.values) { | 1737 for (var element in localScope.values) { |
| 1745 if (element.isConstructor()) return true; | 1738 if (element.isConstructor()) return true; |
| 1746 } | 1739 } |
| 1747 return false; | 1740 return false; |
| 1748 } | 1741 } |
| 1749 | 1742 |
| 1743 ClassElement ensureResolved(Compiler compiler) { | |
| 1744 if (resolutionState == STATE_NOT_STARTED) { | |
| 1745 compiler.resolver.resolveClass(this); | |
| 1746 } | |
| 1747 return this; | |
| 1748 } | |
| 1749 | |
| 1750 Scope buildScope() => new ClassScope(enclosingElement.buildScope(), this); | 1750 Scope buildScope() => new ClassScope(enclosingElement.buildScope(), this); |
| 1751 | 1751 |
| 1752 String toString() { | 1752 String toString() { |
| 1753 if (origin != null) { | 1753 if (origin != null) { |
| 1754 return 'patch ${super.toString()}'; | 1754 return 'patch ${super.toString()}'; |
| 1755 } else if (patch != null) { | 1755 } else if (patch != null) { |
| 1756 return 'origin ${super.toString()}'; | 1756 return 'origin ${super.toString()}'; |
| 1757 } else { | 1757 } else { |
| 1758 return super.toString(); | 1758 return super.toString(); |
| 1759 } | 1759 } |
| 1760 } | 1760 } |
| 1761 } | 1761 } |
| 1762 | 1762 |
| 1763 class MixinApplicationElementX extends BaseClassElementX { | 1763 class MixinApplicationElementX extends BaseClassElementX { |
| 1764 MixinApplicationElementX(SourceString name, | 1764 final MixinApplication cachedNode; |
|
ahe
2013/01/18 12:15:48
If it is final, you can just call it "node".
| |
| 1765 Element enclosing, | |
| 1766 int id, | |
| 1767 int initialState) | |
| 1768 : super(name, enclosing, id, initialState); | |
| 1769 | 1765 |
| 1770 // TODO(kasperl): The analyzer complains when I don't have these two | 1766 // TODO(kasperl): The analyzer complains when I don't have these two |
| 1771 // fields. This is pretty weird. I cannot replace them with getters. | 1767 // fields. This is pretty weird. I cannot replace them with getters. |
| 1772 final ClassElement patch = null; | 1768 final ClassElement patch = null; |
| 1773 final ClassElement origin = null; | 1769 final ClassElement origin = null; |
| 1774 | 1770 |
| 1771 MixinApplicationElementX(SourceString name, Element enclosing, int id, | |
| 1772 this.cachedNode) | |
| 1773 : super(name, enclosing, id, STATE_NOT_STARTED); | |
| 1774 | |
| 1775 bool get hasConstructor => false; | 1775 bool get hasConstructor => false; |
| 1776 bool get hasLocalScopeMembers => false; | 1776 bool get hasLocalScopeMembers => false; |
| 1777 | 1777 |
| 1778 Token position() => cachedNode.getBeginToken(); | |
| 1779 | |
| 1780 Node parseNode(DiagnosticListener listener) => cachedNode; | |
| 1781 | |
| 1782 ClassElement ensureResolved(Compiler compiler) { | |
| 1783 if (resolutionState == STATE_NOT_STARTED) { | |
| 1784 compiler.resolver.resolveMixinApplication(this); | |
| 1785 } | |
| 1786 return this; | |
| 1787 } | |
| 1788 | |
| 1778 Element localLookup(SourceString name) { | 1789 Element localLookup(SourceString name) { |
| 1779 // TODO(kasperl): Unimplemented for now. | 1790 // TODO(kasperl): Unimplemented for now. |
| 1780 return null; | 1791 return null; |
| 1781 } | 1792 } |
| 1782 | 1793 |
| 1783 void forEachLocalMember(void f(Element member)) { | 1794 void forEachLocalMember(void f(Element member)) { |
| 1784 // TODO(kasperl): Unimplemented for now. | 1795 // TODO(kasperl): Unimplemented for now. |
| 1785 } | 1796 } |
| 1786 | 1797 |
| 1787 void addMember(Element element, DiagnosticListener listener) { | 1798 void addMember(Element element, DiagnosticListener listener) { |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1919 | 1930 |
| 1920 MetadataAnnotation ensureResolved(Compiler compiler) { | 1931 MetadataAnnotation ensureResolved(Compiler compiler) { |
| 1921 if (resolutionState == STATE_NOT_STARTED) { | 1932 if (resolutionState == STATE_NOT_STARTED) { |
| 1922 compiler.resolver.resolveMetadataAnnotation(this); | 1933 compiler.resolver.resolveMetadataAnnotation(this); |
| 1923 } | 1934 } |
| 1924 return this; | 1935 return this; |
| 1925 } | 1936 } |
| 1926 | 1937 |
| 1927 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 1938 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
| 1928 } | 1939 } |
| OLD | NEW |