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 '../common.dart'; | 7 import '../common.dart'; |
8 import '../common/resolution.dart' show Resolution; | 8 import '../common/resolution.dart' show Resolution; |
9 import '../compiler.dart' show Compiler; | 9 import '../compiler.dart' show Compiler; |
10 import '../constants/constructors.dart'; | 10 import '../constants/constructors.dart'; |
(...skipping 1642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1653 } | 1653 } |
1654 | 1654 |
1655 /// [ResolvedAst] contains info that define the semantics of an element. | 1655 /// [ResolvedAst] contains info that define the semantics of an element. |
1656 abstract class ResolvedAst { | 1656 abstract class ResolvedAst { |
1657 /// The element whose semantics is defined. | 1657 /// The element whose semantics is defined. |
1658 Element get element; | 1658 Element get element; |
1659 | 1659 |
1660 /// The kind of semantics definition used for this object. | 1660 /// The kind of semantics definition used for this object. |
1661 ResolvedAstKind get kind; | 1661 ResolvedAstKind get kind; |
1662 | 1662 |
1663 /// The AST node for [element]. This only available of [kind] is | 1663 /// The root AST node for the declaration of [element]. This only available if |
1664 /// `ResolvedAstKind.PARSED`. | 1664 /// [kind] is `ResolvedAstKind.PARSED`. |
1665 Node get node; | 1665 Node get node; |
1666 | 1666 |
| 1667 /// The AST node for the 'body' of [element]. |
| 1668 /// |
| 1669 /// For functions and constructors this is the root AST node of the method |
| 1670 /// body, and for variables this is the root AST node of the initializer, if |
| 1671 /// available. |
| 1672 /// |
| 1673 /// This only available if [kind] is `ResolvedAstKind.PARSED`. |
| 1674 Node get body; |
| 1675 |
1667 /// The [TreeElements] containing the resolution data for [node]. This only | 1676 /// The [TreeElements] containing the resolution data for [node]. This only |
1668 /// available of [kind] is `ResolvedAstKind.PARSED`. | 1677 /// available of [kind] is `ResolvedAstKind.PARSED`. |
1669 TreeElements get elements; | 1678 TreeElements get elements; |
1670 } | 1679 } |
1671 | 1680 |
1672 /// [ResolvedAst] implementation used for elements whose semantics is defined in | 1681 /// [ResolvedAst] implementation used for elements whose semantics is defined in |
1673 /// terms an AST and a [TreeElements]. | 1682 /// terms an AST and a [TreeElements]. |
1674 class ParsedResolvedAst implements ResolvedAst { | 1683 class ParsedResolvedAst implements ResolvedAst { |
1675 final Element element; | 1684 final Element element; |
1676 final Node node; | 1685 final Node node; |
| 1686 final Node body; |
1677 final TreeElements elements; | 1687 final TreeElements elements; |
1678 | 1688 |
1679 ParsedResolvedAst(this.element, this.node, this.elements); | 1689 ParsedResolvedAst(this.element, this.node, this.body, this.elements); |
1680 | 1690 |
1681 ResolvedAstKind get kind => ResolvedAstKind.PARSED; | 1691 ResolvedAstKind get kind => ResolvedAstKind.PARSED; |
1682 | 1692 |
1683 String toString() => '$kind:$element:$node'; | 1693 String toString() => '$kind:$element:$node'; |
1684 } | 1694 } |
1685 | 1695 |
1686 /// [ResolvedAst] implementation used for synthesized elements whose semantics | 1696 /// [ResolvedAst] implementation used for synthesized elements whose semantics |
1687 /// is not defined in terms an AST and a [TreeElements]. | 1697 /// is not defined in terms an AST and a [TreeElements]. |
1688 class SynthesizedResolvedAst implements ResolvedAst { | 1698 class SynthesizedResolvedAst implements ResolvedAst { |
1689 final Element element; | 1699 final Element element; |
1690 final ResolvedAstKind kind; | 1700 final ResolvedAstKind kind; |
1691 | 1701 |
1692 SynthesizedResolvedAst(this.element, this.kind); | 1702 SynthesizedResolvedAst(this.element, this.kind); |
1693 | 1703 |
1694 @override | 1704 @override |
1695 TreeElements get elements { | 1705 TreeElements get elements { |
1696 throw new UnsupportedError('$this does not provide a TreeElements'); | 1706 throw new UnsupportedError('$this does not provide a TreeElements'); |
1697 } | 1707 } |
1698 | 1708 |
1699 @override | 1709 @override |
1700 Node get node { | 1710 Node get node { |
1701 throw new UnsupportedError('$this does not have an AST'); | 1711 throw new UnsupportedError('$this does not have a root AST node'); |
| 1712 } |
| 1713 |
| 1714 @override |
| 1715 Node get body { |
| 1716 throw new UnsupportedError('$this does not have a body AST node'); |
1702 } | 1717 } |
1703 | 1718 |
1704 String toString() => '$kind:$element'; | 1719 String toString() => '$kind:$element'; |
1705 } | 1720 } |
1706 | 1721 |
1707 /// A [MemberSignature] is a member of an interface. | 1722 /// A [MemberSignature] is a member of an interface. |
1708 /// | 1723 /// |
1709 /// A signature is either a method or a getter or setter, possibly implicitly | 1724 /// A signature is either a method or a getter or setter, possibly implicitly |
1710 /// defined by a field declarations. Fields themselves are not members of an | 1725 /// defined by a field declarations. Fields themselves are not members of an |
1711 /// interface. | 1726 /// interface. |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1776 /// by a field. | 1791 /// by a field. |
1777 bool get isDeclaredByField; | 1792 bool get isDeclaredByField; |
1778 | 1793 |
1779 /// Returns `true` if this member is abstract. | 1794 /// Returns `true` if this member is abstract. |
1780 bool get isAbstract; | 1795 bool get isAbstract; |
1781 | 1796 |
1782 /// If abstract, [implementation] points to the overridden concrete member, | 1797 /// If abstract, [implementation] points to the overridden concrete member, |
1783 /// if any. Otherwise [implementation] points to the member itself. | 1798 /// if any. Otherwise [implementation] points to the member itself. |
1784 Member get implementation; | 1799 Member get implementation; |
1785 } | 1800 } |
OLD | NEW |