| 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 2828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2839 } | 2839 } |
| 2840 | 2840 |
| 2841 abstract class MixinApplicationElementX extends BaseClassElementX | 2841 abstract class MixinApplicationElementX extends BaseClassElementX |
| 2842 with MixinApplicationElementCommon | 2842 with MixinApplicationElementCommon |
| 2843 implements MixinApplicationElement { | 2843 implements MixinApplicationElement { |
| 2844 Link<ConstructorElement> constructors = const Link<ConstructorElement>(); | 2844 Link<ConstructorElement> constructors = const Link<ConstructorElement>(); |
| 2845 Link<Element> members = const Link<Element>(); | 2845 Link<Element> members = const Link<Element>(); |
| 2846 | 2846 |
| 2847 InterfaceType mixinType; | 2847 InterfaceType mixinType; |
| 2848 | 2848 |
| 2849 final ScopeX localScope = new ScopeX(); |
| 2850 |
| 2849 MixinApplicationElementX(String name, Element enclosing, int id) | 2851 MixinApplicationElementX(String name, Element enclosing, int id) |
| 2850 : super(name, enclosing, id, STATE_NOT_STARTED); | 2852 : super(name, enclosing, id, STATE_NOT_STARTED); |
| 2851 | 2853 |
| 2852 ClassElement get mixin => mixinType != null ? mixinType.element : null; | 2854 ClassElement get mixin => mixinType != null ? mixinType.element : null; |
| 2853 | 2855 |
| 2854 bool get isMixinApplication => true; | 2856 bool get isMixinApplication => true; |
| 2855 bool get hasConstructor => !constructors.isEmpty; | 2857 bool get hasConstructor => !constructors.isEmpty; |
| 2856 bool get hasLocalScopeMembers => !constructors.isEmpty; | 2858 bool get hasLocalScopeMembers { |
| 2859 return constructors.isNotEmpty || members.isNotEmpty; |
| 2860 } |
| 2857 | 2861 |
| 2858 get patch => null; | 2862 get patch => null; |
| 2859 get origin => null; | 2863 get origin => null; |
| 2860 | 2864 |
| 2861 bool get hasNode => true; | 2865 bool get hasNode => true; |
| 2862 | 2866 |
| 2863 Token get position => node.getBeginToken(); | 2867 Token get position => node.getBeginToken(); |
| 2864 | 2868 |
| 2865 Node parseNode(Parsing parsing) => node; | 2869 Node parseNode(Parsing parsing) => node; |
| 2866 | 2870 |
| 2867 void addMember(Element element, DiagnosticReporter reporter) { | 2871 void addMember(Element element, DiagnosticReporter reporter) { |
| 2868 members = members.prepend(element); | 2872 members = members.prepend(element); |
| 2873 addToScope(element, reporter); |
| 2869 } | 2874 } |
| 2870 | 2875 |
| 2871 void addToScope(Element element, DiagnosticReporter reporter) { | 2876 void addToScope(Element element, DiagnosticReporter reporter) { |
| 2872 reporter.internalError(this, 'Cannot add to scope of $this.'); | 2877 localScope.add(element, reporter); |
| 2873 } | 2878 } |
| 2874 | 2879 |
| 2875 void addConstructor(FunctionElement constructor) { | 2880 void addConstructor(FunctionElement constructor) { |
| 2876 constructors = constructors.prepend(constructor); | 2881 constructors = constructors.prepend(constructor); |
| 2877 } | 2882 } |
| 2878 | 2883 |
| 2879 void setDefaultConstructor( | 2884 void setDefaultConstructor( |
| 2880 FunctionElement constructor, DiagnosticReporter reporter) { | 2885 FunctionElement constructor, DiagnosticReporter reporter) { |
| 2881 assert(!hasConstructor); | 2886 assert(!hasConstructor); |
| 2882 addConstructor(constructor); | 2887 addConstructor(constructor); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2903 members.forEach(f); | 2908 members.forEach(f); |
| 2904 } | 2909 } |
| 2905 | 2910 |
| 2906 buildScope() { | 2911 buildScope() { |
| 2907 Scope parentScope = mixin?.buildScope(); | 2912 Scope parentScope = mixin?.buildScope(); |
| 2908 if (parentScope == null) { | 2913 if (parentScope == null) { |
| 2909 parentScope = new NoScope(); | 2914 parentScope = new NoScope(); |
| 2910 } | 2915 } |
| 2911 return new MixinApplicationScope(parentScope, this); | 2916 return new MixinApplicationScope(parentScope, this); |
| 2912 } | 2917 } |
| 2918 |
| 2919 Element localLookup(String name) { |
| 2920 for (Link<Element> link = constructors; !link.isEmpty; link = link.tail) { |
| 2921 if (link.head.name == name) return link.head; |
| 2922 } |
| 2923 return localScope.lookup(name); |
| 2924 } |
| 2913 } | 2925 } |
| 2914 | 2926 |
| 2915 class NamedMixinApplicationElementX extends MixinApplicationElementX | 2927 class NamedMixinApplicationElementX extends MixinApplicationElementX |
| 2916 implements DeclarationSite { | 2928 implements DeclarationSite { |
| 2917 final NamedMixinApplication node; | 2929 final NamedMixinApplication node; |
| 2918 | 2930 |
| 2919 NamedMixinApplicationElementX( | 2931 NamedMixinApplicationElementX( |
| 2920 String name, CompilationUnitElement enclosing, int id, this.node) | 2932 String name, CompilationUnitElement enclosing, int id, this.node) |
| 2921 : super(name, enclosing, id); | 2933 : super(name, enclosing, id); |
| 2922 | 2934 |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3155 | 3167 |
| 3156 bool get hasResolvedAst { | 3168 bool get hasResolvedAst { |
| 3157 return definingElement.hasNode && definingElement.hasTreeElements; | 3169 return definingElement.hasNode && definingElement.hasTreeElements; |
| 3158 } | 3170 } |
| 3159 | 3171 |
| 3160 ResolvedAst get resolvedAst { | 3172 ResolvedAst get resolvedAst { |
| 3161 return new ResolvedAst( | 3173 return new ResolvedAst( |
| 3162 declaration, definingElement.node, definingElement.treeElements); | 3174 declaration, definingElement.node, definingElement.treeElements); |
| 3163 } | 3175 } |
| 3164 } | 3176 } |
| OLD | NEW |