| 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 '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/resolution.dart' show Resolution, Parsing; | 8 import '../common/resolution.dart' show Resolution, Parsing; |
| 9 import '../compiler.dart' show Compiler; | 9 import '../compiler.dart' show Compiler; |
| 10 import '../constants/constant_constructors.dart'; | 10 import '../constants/constant_constructors.dart'; |
| (...skipping 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1539 message: "Type has not been computed for $this.")); | 1539 message: "Type has not been computed for $this.")); |
| 1540 return variables.type; | 1540 return variables.type; |
| 1541 } | 1541 } |
| 1542 | 1542 |
| 1543 bool get isInstanceMember => isClassMember && !isStatic; | 1543 bool get isInstanceMember => isClassMember && !isStatic; |
| 1544 | 1544 |
| 1545 // Note: cachedNode.beginToken will not be correct in all | 1545 // Note: cachedNode.beginToken will not be correct in all |
| 1546 // cases, for example, for function typed parameters. | 1546 // cases, for example, for function typed parameters. |
| 1547 Token get position => token; | 1547 Token get position => token; |
| 1548 | 1548 |
| 1549 accept(ElementVisitor visitor, arg) { | |
| 1550 return visitor.visitVariableElement(this, arg); | |
| 1551 } | |
| 1552 | |
| 1553 DeclarationSite get declarationSite => variables; | 1549 DeclarationSite get declarationSite => variables; |
| 1554 } | 1550 } |
| 1555 | 1551 |
| 1556 class LocalVariableElementX extends VariableElementX | 1552 class LocalVariableElementX extends VariableElementX |
| 1557 implements LocalVariableElement { | 1553 implements LocalVariableElement { |
| 1558 LocalVariableElementX(String name, ExecutableElement enclosingElement, | 1554 LocalVariableElementX(String name, ExecutableElement enclosingElement, |
| 1559 VariableList variables, Token token) | 1555 VariableList variables, Token token) |
| 1560 : super(name, ElementKind.VARIABLE, enclosingElement, variables, token) { | 1556 : super(name, ElementKind.VARIABLE, enclosingElement, variables, token) { |
| 1561 createDefinitions(variables.definitions); | 1557 createDefinitions(variables.definitions); |
| 1562 } | 1558 } |
| 1563 | 1559 |
| 1564 ExecutableElement get executableContext => enclosingElement; | 1560 ExecutableElement get executableContext => enclosingElement; |
| 1565 | 1561 |
| 1566 MemberElement get memberContext => executableContext.memberContext; | 1562 MemberElement get memberContext => executableContext.memberContext; |
| 1567 | 1563 |
| 1568 bool get isLocal => true; | 1564 bool get isLocal => true; |
| 1565 |
| 1566 accept(ElementVisitor visitor, arg) { |
| 1567 return visitor.visitLocalVariableElement(this, arg); |
| 1568 } |
| 1569 } | 1569 } |
| 1570 | 1570 |
| 1571 class FieldElementX extends VariableElementX | 1571 class FieldElementX extends VariableElementX |
| 1572 with AnalyzableElementX | 1572 with AnalyzableElementX |
| 1573 implements FieldElement { | 1573 implements FieldElement { |
| 1574 List<FunctionElement> nestedClosures = new List<FunctionElement>(); | 1574 List<FunctionElement> nestedClosures = new List<FunctionElement>(); |
| 1575 | 1575 |
| 1576 FieldElementX( | 1576 FieldElementX( |
| 1577 Identifier name, Element enclosingElement, VariableList variables) | 1577 Identifier name, Element enclosingElement, VariableList variables) |
| 1578 : super(name.source, ElementKind.FIELD, enclosingElement, variables, | 1578 : super(name.source, ElementKind.FIELD, enclosingElement, variables, |
| (...skipping 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2746 '', // Name. | 2746 '', // Name. |
| 2747 ElementKind.GENERATIVE_CONSTRUCTOR, | 2747 ElementKind.GENERATIVE_CONSTRUCTOR, |
| 2748 modifiers, | 2748 modifiers, |
| 2749 enumClass); | 2749 enumClass); |
| 2750 | 2750 |
| 2751 @override | 2751 @override |
| 2752 bool get hasNode => true; | 2752 bool get hasNode => true; |
| 2753 | 2753 |
| 2754 @override | 2754 @override |
| 2755 FunctionExpression parseNode(Parsing parsing) => node; | 2755 FunctionExpression parseNode(Parsing parsing) => node; |
| 2756 |
| 2757 @override |
| 2758 SourceSpan get sourcePosition => enclosingClass.sourcePosition; |
| 2756 } | 2759 } |
| 2757 | 2760 |
| 2758 class EnumMethodElementX extends MethodElementX { | 2761 class EnumMethodElementX extends MethodElementX { |
| 2759 final FunctionExpression node; | 2762 final FunctionExpression node; |
| 2760 | 2763 |
| 2761 EnumMethodElementX( | 2764 EnumMethodElementX( |
| 2762 String name, EnumClassElementX enumClass, Modifiers modifiers, this.node) | 2765 String name, EnumClassElementX enumClass, Modifiers modifiers, this.node) |
| 2763 : super(name, ElementKind.FUNCTION, modifiers, enumClass, true); | 2766 : super(name, ElementKind.FUNCTION, modifiers, enumClass, true); |
| 2764 | 2767 |
| 2765 @override | 2768 @override |
| 2766 bool get hasNode => true; | 2769 bool get hasNode => true; |
| 2767 | 2770 |
| 2768 @override | 2771 @override |
| 2769 FunctionExpression parseNode(Parsing parsing) => node; | 2772 FunctionExpression parseNode(Parsing parsing) => node; |
| 2773 |
| 2774 @override |
| 2775 SourceSpan get sourcePosition => enclosingClass.sourcePosition; |
| 2770 } | 2776 } |
| 2771 | 2777 |
| 2772 class EnumFormalElementX extends InitializingFormalElementX { | 2778 class EnumFormalElementX extends InitializingFormalElementX { |
| 2773 EnumFormalElementX( | 2779 EnumFormalElementX( |
| 2774 ConstructorElement constructor, | 2780 ConstructorElement constructor, |
| 2775 VariableDefinitions variables, | 2781 VariableDefinitions variables, |
| 2776 Identifier identifier, | 2782 Identifier identifier, |
| 2777 EnumFieldElementX fieldElement) | 2783 EnumFieldElementX fieldElement) |
| 2778 : super(constructor, variables, identifier, null, fieldElement) { | 2784 : super(constructor, variables, identifier, null, fieldElement) { |
| 2779 typeCache = fieldElement.type; | 2785 typeCache = fieldElement.type; |
| 2780 } | 2786 } |
| 2787 |
| 2788 @override |
| 2789 SourceSpan get sourcePosition => enclosingClass.sourcePosition; |
| 2781 } | 2790 } |
| 2782 | 2791 |
| 2783 class EnumFieldElementX extends FieldElementX { | 2792 class EnumFieldElementX extends FieldElementX { |
| 2784 EnumFieldElementX(Identifier name, EnumClassElementX enumClass, | 2793 EnumFieldElementX(Identifier name, EnumClassElementX enumClass, |
| 2785 VariableList variableList, Node definition, | 2794 VariableList variableList, Node definition, |
| 2786 [Expression initializer]) | 2795 [Expression initializer]) |
| 2787 : super(name, enumClass, variableList) { | 2796 : super(name, enumClass, variableList) { |
| 2788 definitionsCache = new VariableDefinitions( | 2797 definitionsCache = new VariableDefinitions( |
| 2789 null, variableList.modifiers, new NodeList.singleton(definition)); | 2798 null, variableList.modifiers, new NodeList.singleton(definition)); |
| 2790 initializerCache = initializer; | 2799 initializerCache = initializer; |
| 2791 } | 2800 } |
| 2801 |
| 2802 @override |
| 2803 SourceSpan get sourcePosition => enclosingClass.sourcePosition; |
| 2804 } |
| 2805 |
| 2806 class EnumConstantElementX extends EnumFieldElementX |
| 2807 implements EnumConstantElement { |
| 2808 final int index; |
| 2809 |
| 2810 EnumConstantElementX( |
| 2811 Identifier name, |
| 2812 EnumClassElementX enumClass, |
| 2813 VariableList variableList, |
| 2814 Node definition, |
| 2815 Expression initializer, |
| 2816 this.index) |
| 2817 : super(name, enumClass, variableList, definition, initializer); |
| 2818 |
| 2819 @override |
| 2820 SourceSpan get sourcePosition { |
| 2821 return new SourceSpan( |
| 2822 enclosingClass.sourcePosition.uri, |
| 2823 position.charOffset, position.charEnd); |
| 2824 } |
| 2792 } | 2825 } |
| 2793 | 2826 |
| 2794 abstract class MixinApplicationElementX extends BaseClassElementX | 2827 abstract class MixinApplicationElementX extends BaseClassElementX |
| 2795 with MixinApplicationElementCommon | 2828 with MixinApplicationElementCommon |
| 2796 implements MixinApplicationElement { | 2829 implements MixinApplicationElement { |
| 2797 Link<ConstructorElement> constructors = new Link<ConstructorElement>(); | 2830 Link<ConstructorElement> constructors = new Link<ConstructorElement>(); |
| 2798 | 2831 |
| 2799 InterfaceType mixinType; | 2832 InterfaceType mixinType; |
| 2800 | 2833 |
| 2801 MixinApplicationElementX(String name, Element enclosing, int id) | 2834 MixinApplicationElementX(String name, Element enclosing, int id) |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3081 /// The element whose node defines this element. | 3114 /// The element whose node defines this element. |
| 3082 /// | 3115 /// |
| 3083 /// For patched functions the defining element is the patch element found | 3116 /// For patched functions the defining element is the patch element found |
| 3084 /// through [implementation] since its node define the implementation of the | 3117 /// through [implementation] since its node define the implementation of the |
| 3085 /// function. For patched classes the defining element is the origin element | 3118 /// function. For patched classes the defining element is the origin element |
| 3086 /// found through [declaration] since its node define the inheritance relation | 3119 /// found through [declaration] since its node define the inheritance relation |
| 3087 /// for the class. For unpatched elements the defining element is the element | 3120 /// for the class. For unpatched elements the defining element is the element |
| 3088 /// itself. | 3121 /// itself. |
| 3089 AstElement get definingElement; | 3122 AstElement get definingElement; |
| 3090 | 3123 |
| 3091 bool get hasResolvedAst => definingElement.hasTreeElements; | 3124 bool get hasResolvedAst { |
| 3125 return definingElement.hasNode && definingElement.hasTreeElements; |
| 3126 } |
| 3092 | 3127 |
| 3093 ResolvedAst get resolvedAst { | 3128 ResolvedAst get resolvedAst { |
| 3094 return new ResolvedAst( | 3129 return new ResolvedAst( |
| 3095 declaration, definingElement.node, definingElement.treeElements); | 3130 declaration, definingElement.node, definingElement.treeElements); |
| 3096 } | 3131 } |
| 3097 } | 3132 } |
| OLD | NEW |