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

Side by Side Diff: pkg/compiler/lib/src/elements/modelx.dart

Issue 1873823002: Update elements, nodes and visitors for serialization. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix LocalVariableElementZ.constant Created 4 years, 8 months 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
« no previous file with comments | « pkg/compiler/lib/src/elements/elements.dart ('k') | pkg/compiler/lib/src/elements/visitor.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 8 import '../common/resolution.dart' show
9 Resolution, 9 Resolution,
10 Parsing; 10 Parsing;
(...skipping 1579 matching lines...) Expand 10 before | Expand all | Expand 10 after
1590 message: "Type has not been computed for $this.")); 1590 message: "Type has not been computed for $this."));
1591 return variables.type; 1591 return variables.type;
1592 } 1592 }
1593 1593
1594 bool get isInstanceMember => isClassMember && !isStatic; 1594 bool get isInstanceMember => isClassMember && !isStatic;
1595 1595
1596 // Note: cachedNode.beginToken will not be correct in all 1596 // Note: cachedNode.beginToken will not be correct in all
1597 // cases, for example, for function typed parameters. 1597 // cases, for example, for function typed parameters.
1598 Token get position => token; 1598 Token get position => token;
1599 1599
1600 accept(ElementVisitor visitor, arg) {
1601 return visitor.visitVariableElement(this, arg);
1602 }
1603
1604 DeclarationSite get declarationSite => variables; 1600 DeclarationSite get declarationSite => variables;
1605 } 1601 }
1606 1602
1607 class LocalVariableElementX extends VariableElementX 1603 class LocalVariableElementX extends VariableElementX
1608 implements LocalVariableElement { 1604 implements LocalVariableElement {
1609 LocalVariableElementX(String name, 1605 LocalVariableElementX(String name,
1610 ExecutableElement enclosingElement, 1606 ExecutableElement enclosingElement,
1611 VariableList variables, 1607 VariableList variables,
1612 Token token) 1608 Token token)
1613 : super(name, ElementKind.VARIABLE, enclosingElement, variables, token) { 1609 : super(name, ElementKind.VARIABLE, enclosingElement, variables, token) {
1614 createDefinitions(variables.definitions); 1610 createDefinitions(variables.definitions);
1615 } 1611 }
1616 1612
1617 ExecutableElement get executableContext => enclosingElement; 1613 ExecutableElement get executableContext => enclosingElement;
1618 1614
1619 MemberElement get memberContext => executableContext.memberContext; 1615 MemberElement get memberContext => executableContext.memberContext;
1620 1616
1621 bool get isLocal => true; 1617 bool get isLocal => true;
1618
1619 accept(ElementVisitor visitor, arg) {
1620 return visitor.visitLocalVariableElement(this, arg);
1621 }
1622 } 1622 }
1623 1623
1624 class FieldElementX extends VariableElementX 1624 class FieldElementX extends VariableElementX
1625 with AnalyzableElementX implements FieldElement { 1625 with AnalyzableElementX implements FieldElement {
1626 List<FunctionElement> nestedClosures = new List<FunctionElement>(); 1626 List<FunctionElement> nestedClosures = new List<FunctionElement>();
1627 1627
1628 FieldElementX(Identifier name, 1628 FieldElementX(Identifier name,
1629 Element enclosingElement, 1629 Element enclosingElement,
1630 VariableList variables) 1630 VariableList variables)
1631 : super(name.source, ElementKind.FIELD, enclosingElement, 1631 : super(name.source, ElementKind.FIELD, enclosingElement,
(...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after
2836 : super('', // Name. 2836 : super('', // Name.
2837 ElementKind.GENERATIVE_CONSTRUCTOR, 2837 ElementKind.GENERATIVE_CONSTRUCTOR,
2838 modifiers, 2838 modifiers,
2839 enumClass); 2839 enumClass);
2840 2840
2841 @override 2841 @override
2842 bool get hasNode => true; 2842 bool get hasNode => true;
2843 2843
2844 @override 2844 @override
2845 FunctionExpression parseNode(Parsing parsing) => node; 2845 FunctionExpression parseNode(Parsing parsing) => node;
2846
2847 @override
2848 SourceSpan get sourcePosition => enclosingClass.sourcePosition;
2846 } 2849 }
2847 2850
2848 class EnumMethodElementX extends MethodElementX { 2851 class EnumMethodElementX extends MethodElementX {
2849 final FunctionExpression node; 2852 final FunctionExpression node;
2850 2853
2851 EnumMethodElementX(String name, 2854 EnumMethodElementX(String name,
2852 EnumClassElementX enumClass, 2855 EnumClassElementX enumClass,
2853 Modifiers modifiers, 2856 Modifiers modifiers,
2854 this.node) 2857 this.node)
2855 : super(name, ElementKind.FUNCTION, modifiers, enumClass, true); 2858 : super(name, ElementKind.FUNCTION, modifiers, enumClass, true);
2856 2859
2857 @override 2860 @override
2858 bool get hasNode => true; 2861 bool get hasNode => true;
2859 2862
2860 @override 2863 @override
2861 FunctionExpression parseNode(Parsing parsing) => node; 2864 FunctionExpression parseNode(Parsing parsing) => node;
2865
2866 @override
2867 SourceSpan get sourcePosition => enclosingClass.sourcePosition;
2862 } 2868 }
2863 2869
2864 class EnumFormalElementX extends InitializingFormalElementX { 2870 class EnumFormalElementX extends InitializingFormalElementX {
2865 EnumFormalElementX(ConstructorElement constructor, 2871 EnumFormalElementX(ConstructorElement constructor,
2866 VariableDefinitions variables, 2872 VariableDefinitions variables,
2867 Identifier identifier, 2873 Identifier identifier,
2868 EnumFieldElementX fieldElement) 2874 EnumFieldElementX fieldElement)
2869 : super(constructor, variables, identifier, null, fieldElement) { 2875 : super(constructor, variables, identifier, null, fieldElement) {
2870 typeCache = fieldElement.type; 2876 typeCache = fieldElement.type;
2871 } 2877 }
2878
2879 @override
2880 SourceSpan get sourcePosition => enclosingClass.sourcePosition;
2872 } 2881 }
2873 2882
2874 class EnumFieldElementX extends FieldElementX { 2883 class EnumFieldElementX extends FieldElementX {
2875 2884
2876 EnumFieldElementX(Identifier name, 2885 EnumFieldElementX(Identifier name,
2877 EnumClassElementX enumClass, 2886 EnumClassElementX enumClass,
2878 VariableList variableList, 2887 VariableList variableList,
2879 Node definition, 2888 Node definition,
2880 [Expression initializer]) 2889 [Expression initializer])
2881 : super(name, enumClass, variableList) { 2890 : super(name, enumClass, variableList) {
2882 definitionsCache = new VariableDefinitions(null, 2891 definitionsCache = new VariableDefinitions(null,
2883 variableList.modifiers, new NodeList.singleton(definition)); 2892 variableList.modifiers, new NodeList.singleton(definition));
2884 initializerCache = initializer; 2893 initializerCache = initializer;
2885 } 2894 }
2895
2896 @override
2897 SourceSpan get sourcePosition => enclosingClass.sourcePosition;
Siggi Cherem (dart-lang) 2016/04/08 16:18:24 why don't we keep the source-position of the enum-
Johnni Winther 2016/04/11 08:18:24 The enum fields are the synthetic `index` and `val
Siggi Cherem (dart-lang) 2016/04/11 16:28:18 Not sure I followed. If I write: enum C { v1,
Johnni Winther 2016/04/12 07:26:29 Yes. I'll update the comments.
2898 }
2899
2900 class EnumConstantElementX extends EnumFieldElementX
2901 implements EnumConstantElement {
2902 final int index;
2903
2904 EnumConstantElementX(
2905 Identifier name,
2906 EnumClassElementX enumClass,
2907 VariableList variableList,
2908 Node definition,
2909 Expression initializer,
2910 this.index)
2911 : super(name, enumClass, variableList, definition, initializer);
2912
2913 @override
2914 SourceSpan get sourcePosition {
2915 return new SourceSpan(
2916 enclosingClass.sourcePosition.uri,
2917 position.charOffset, position.charEnd);
2918 }
2886 } 2919 }
2887 2920
2888 abstract class MixinApplicationElementX extends BaseClassElementX 2921 abstract class MixinApplicationElementX extends BaseClassElementX
2889 with MixinApplicationElementCommon 2922 with MixinApplicationElementCommon
2890 implements MixinApplicationElement { 2923 implements MixinApplicationElement {
2891 Link<ConstructorElement> constructors = new Link<ConstructorElement>(); 2924 Link<ConstructorElement> constructors = new Link<ConstructorElement>();
2892 2925
2893 InterfaceType mixinType; 2926 InterfaceType mixinType;
2894 2927
2895 MixinApplicationElementX(String name, Element enclosing, int id) 2928 MixinApplicationElementX(String name, Element enclosing, int id)
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
3181 /// The element whose node defines this element. 3214 /// The element whose node defines this element.
3182 /// 3215 ///
3183 /// For patched functions the defining element is the patch element found 3216 /// For patched functions the defining element is the patch element found
3184 /// through [implementation] since its node define the implementation of the 3217 /// through [implementation] since its node define the implementation of the
3185 /// function. For patched classes the defining element is the origin element 3218 /// function. For patched classes the defining element is the origin element
3186 /// found through [declaration] since its node define the inheritance relation 3219 /// found through [declaration] since its node define the inheritance relation
3187 /// for the class. For unpatched elements the defining element is the element 3220 /// for the class. For unpatched elements the defining element is the element
3188 /// itself. 3221 /// itself.
3189 AstElement get definingElement; 3222 AstElement get definingElement;
3190 3223
3191 bool get hasResolvedAst => definingElement.hasTreeElements; 3224 bool get hasResolvedAst {
3225 return definingElement.hasNode && definingElement.hasTreeElements;
3226 }
3192 3227
3193 ResolvedAst get resolvedAst { 3228 ResolvedAst get resolvedAst {
3194 return new ResolvedAst(declaration, 3229 return new ResolvedAst(declaration,
3195 definingElement.node, definingElement.treeElements); 3230 definingElement.node, definingElement.treeElements);
3196 } 3231 }
3197 3232
3198 } 3233 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/elements/elements.dart ('k') | pkg/compiler/lib/src/elements/visitor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698