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

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

Issue 1504763003: Make NamedMixinApplicationElementX and EnumClassElementX implement DeclarationSite. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years 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 | « no previous file | pkg/compiler/lib/src/parser/element_listener.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 27 matching lines...) Expand all
38 import '../tokens/token_constants.dart' as Tokens show 38 import '../tokens/token_constants.dart' as Tokens show
39 EOF_TOKEN; 39 EOF_TOKEN;
40 import '../tree/tree.dart'; 40 import '../tree/tree.dart';
41 import '../util/util.dart'; 41 import '../util/util.dart';
42 42
43 import 'common.dart'; 43 import 'common.dart';
44 import 'elements.dart'; 44 import 'elements.dart';
45 import 'visitor.dart' show 45 import 'visitor.dart' show
46 ElementVisitor; 46 ElementVisitor;
47 47
48 /// Object that identifies a declaration site.
49 ///
50 /// For most elements, this is the element itself, but for variable declarations
51 /// where multi-declarations like `var a, b, c` are allowed, the declaration
52 /// site is a separate object.
53 // TODO(johnniwinther): Add [beginToken] and [endToken] getters.
48 abstract class DeclarationSite { 54 abstract class DeclarationSite {
49 } 55 }
50 56
51 abstract class ElementX extends Element with ElementCommon { 57 abstract class ElementX extends Element with ElementCommon {
52 static int elementHashCode = 0; 58 static int elementHashCode = 0;
53 59
54 final String name; 60 final String name;
55 final ElementKind kind; 61 final ElementKind kind;
56 final Element enclosingElement; 62 final Element enclosingElement;
57 final int hashCode = ++elementHashCode; 63 final int hashCode = ++elementHashCode;
(...skipping 2725 matching lines...) Expand 10 before | Expand all | Expand 10 after
2783 if (origin != null) { 2789 if (origin != null) {
2784 return 'patch ${super.toString()}'; 2790 return 'patch ${super.toString()}';
2785 } else if (patch != null) { 2791 } else if (patch != null) {
2786 return 'origin ${super.toString()}'; 2792 return 'origin ${super.toString()}';
2787 } else { 2793 } else {
2788 return super.toString(); 2794 return super.toString();
2789 } 2795 }
2790 } 2796 }
2791 } 2797 }
2792 2798
2793 class EnumClassElementX extends ClassElementX implements EnumClassElement { 2799 class EnumClassElementX extends ClassElementX
2800 implements EnumClassElement, DeclarationSite {
2794 final Enum node; 2801 final Enum node;
2795 List<FieldElement> _enumValues; 2802 List<FieldElement> _enumValues;
2796 2803
2797 EnumClassElementX(String name, Element enclosing, int id, this.node) 2804 EnumClassElementX(String name, Element enclosing, int id, this.node)
2798 : super(name, enclosing, id, STATE_NOT_STARTED); 2805 : super(name, enclosing, id, STATE_NOT_STARTED);
2799 2806
2800 @override 2807 @override
2801 bool get hasNode => true; 2808 bool get hasNode => true;
2802 2809
2803 @override 2810 @override
(...skipping 16 matching lines...) Expand all
2820 assert(invariant(this, _enumValues != null, 2827 assert(invariant(this, _enumValues != null,
2821 message: "enumValues has not been computed for $this.")); 2828 message: "enumValues has not been computed for $this."));
2822 return _enumValues; 2829 return _enumValues;
2823 } 2830 }
2824 2831
2825 void set enumValues(List<FieldElement> values) { 2832 void set enumValues(List<FieldElement> values) {
2826 assert(invariant(this, _enumValues == null, 2833 assert(invariant(this, _enumValues == null,
2827 message: "enumValues has already been computed for $this.")); 2834 message: "enumValues has already been computed for $this."));
2828 _enumValues = values; 2835 _enumValues = values;
2829 } 2836 }
2837
2838 @override
2839 DeclarationSite get declarationSite => this;
2830 } 2840 }
2831 2841
2832 class EnumConstructorElementX extends ConstructorElementX { 2842 class EnumConstructorElementX extends ConstructorElementX {
2833 final FunctionExpression node; 2843 final FunctionExpression node;
2834 2844
2835 EnumConstructorElementX(EnumClassElementX enumClass, 2845 EnumConstructorElementX(EnumClassElementX enumClass,
2836 Modifiers modifiers, 2846 Modifiers modifiers,
2837 this.node) 2847 this.node)
2838 : super('', // Name. 2848 : super('', // Name.
2839 ElementKind.GENERATIVE_CONSTRUCTOR, 2849 ElementKind.GENERATIVE_CONSTRUCTOR,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2880 VariableList variableList, 2890 VariableList variableList,
2881 Node definition, 2891 Node definition,
2882 [Expression initializer]) 2892 [Expression initializer])
2883 : super(name, enumClass, variableList) { 2893 : super(name, enumClass, variableList) {
2884 definitionsCache = new VariableDefinitions(null, 2894 definitionsCache = new VariableDefinitions(null,
2885 variableList.modifiers, new NodeList.singleton(definition)); 2895 variableList.modifiers, new NodeList.singleton(definition));
2886 initializerCache = initializer; 2896 initializerCache = initializer;
2887 } 2897 }
2888 } 2898 }
2889 2899
2890 class MixinApplicationElementX extends BaseClassElementX 2900 abstract class MixinApplicationElementX extends BaseClassElementX
2891 implements MixinApplicationElement { 2901 implements MixinApplicationElement {
2892 final Node node;
2893 final Modifiers modifiers;
2894 2902
2895 Link<ConstructorElement> constructors = new Link<ConstructorElement>(); 2903 Link<ConstructorElement> constructors = new Link<ConstructorElement>();
2896 2904
2897 InterfaceType mixinType; 2905 InterfaceType mixinType;
2898 2906
2899 MixinApplicationElementX(String name, Element enclosing, int id, 2907 MixinApplicationElementX(String name, Element enclosing, int id)
2900 this.node, this.modifiers)
2901 : super(name, enclosing, id, STATE_NOT_STARTED); 2908 : super(name, enclosing, id, STATE_NOT_STARTED);
2902 2909
2903 ClassElement get mixin => mixinType != null ? mixinType.element : null; 2910 ClassElement get mixin => mixinType != null ? mixinType.element : null;
2904 2911
2905 bool get isMixinApplication => true; 2912 bool get isMixinApplication => true;
2906 bool get isUnnamedMixinApplication => node is! NamedMixinApplication; 2913 bool get isUnnamedMixinApplication => node is! NamedMixinApplication;
2907 bool get hasConstructor => !constructors.isEmpty; 2914 bool get hasConstructor => !constructors.isEmpty;
2908 bool get hasLocalScopeMembers => !constructors.isEmpty; 2915 bool get hasLocalScopeMembers => !constructors.isEmpty;
2909 2916
2910 get patch => null; 2917 get patch => null;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2967 "creation."); 2974 "creation.");
2968 } 2975 }
2969 return createTypeVariables(named.typeParameters); 2976 return createTypeVariables(named.typeParameters);
2970 } 2977 }
2971 2978
2972 accept(ElementVisitor visitor, arg) { 2979 accept(ElementVisitor visitor, arg) {
2973 return visitor.visitMixinApplicationElement(this, arg); 2980 return visitor.visitMixinApplicationElement(this, arg);
2974 } 2981 }
2975 } 2982 }
2976 2983
2984 class NamedMixinApplicationElementX extends MixinApplicationElementX
2985 implements DeclarationSite {
2986 final NamedMixinApplication node;
2987
2988 NamedMixinApplicationElementX(
2989 String name,
2990 CompilationUnitElement enclosing,
2991 int id,
2992 this.node)
2993 : super(name, enclosing, id);
2994
2995 Modifiers get modifiers => node.modifiers;
2996
2997 DeclarationSite get declarationSite => this;
2998 }
2999
3000 class UnnamedMixinApplicationElementX extends MixinApplicationElementX {
3001 final Node node;
3002
3003 UnnamedMixinApplicationElementX(
3004 String name,
3005 CompilationUnitElement enclosing,
3006 int id,
3007 this.node)
3008 : super(name, enclosing, id);
3009
3010 bool get isAbstract => true;
3011 }
3012
2977 class LabelDefinitionX implements LabelDefinition { 3013 class LabelDefinitionX implements LabelDefinition {
2978 final Label label; 3014 final Label label;
2979 final String labelName; 3015 final String labelName;
2980 final JumpTarget target; 3016 final JumpTarget target;
2981 bool isBreakTarget = false; 3017 bool isBreakTarget = false;
2982 bool isContinueTarget = false; 3018 bool isContinueTarget = false;
2983 3019
2984 LabelDefinitionX(Label label, String labelName, this.target) 3020 LabelDefinitionX(Label label, String labelName, this.target)
2985 : this.label = label, 3021 : this.label = label,
2986 this.labelName = labelName; 3022 this.labelName = labelName;
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
3190 AstElement get definingElement; 3226 AstElement get definingElement;
3191 3227
3192 bool get hasResolvedAst => definingElement.hasTreeElements; 3228 bool get hasResolvedAst => definingElement.hasTreeElements;
3193 3229
3194 ResolvedAst get resolvedAst { 3230 ResolvedAst get resolvedAst {
3195 return new ResolvedAst(declaration, 3231 return new ResolvedAst(declaration,
3196 definingElement.node, definingElement.treeElements); 3232 definingElement.node, definingElement.treeElements);
3197 } 3233 }
3198 3234
3199 } 3235 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/parser/element_listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698