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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/world.dart

Issue 12033049: Disallow mixing in classes that use 'super'. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge from master. Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/warnings.dart ('k') | tests/language/language.status » ('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) 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 part of dart2js; 5 part of dart2js;
6 6
7 class World { 7 class World {
8 final Compiler compiler; 8 final Compiler compiler;
9 final Map<ClassElement, Set<ClassElement>> subtypes; 9 final Map<ClassElement, Set<ClassElement>> subtypes;
10 final Map<ClassElement, Set<MixinApplicationElement>> mixinUses;
10 final Map<ClassElement, Set<ClassElement>> typesImplementedBySubclasses; 11 final Map<ClassElement, Set<ClassElement>> typesImplementedBySubclasses;
11 final Set<ClassElement> classesNeedingRti; 12 final Set<ClassElement> classesNeedingRti;
12 final Map<ClassElement, Set<ClassElement>> rtiDependencies; 13 final Map<ClassElement, Set<ClassElement>> rtiDependencies;
13 final FunctionSet userDefinedGetters; 14 final FunctionSet userDefinedGetters;
14 final FunctionSet userDefinedSetters; 15 final FunctionSet userDefinedSetters;
15 16
16 World(Compiler compiler) 17 World(Compiler compiler)
17 : subtypes = new Map<ClassElement, Set<ClassElement>>(), 18 : subtypes = new Map<ClassElement, Set<ClassElement>>(),
19 mixinUses = new Map<ClassElement, Set<MixinApplicationElement>>(),
18 typesImplementedBySubclasses = 20 typesImplementedBySubclasses =
19 new Map<ClassElement, Set<ClassElement>>(), 21 new Map<ClassElement, Set<ClassElement>>(),
20 userDefinedGetters = new FunctionSet(compiler), 22 userDefinedGetters = new FunctionSet(compiler),
21 userDefinedSetters = new FunctionSet(compiler), 23 userDefinedSetters = new FunctionSet(compiler),
22 classesNeedingRti = new Set<ClassElement>(), 24 classesNeedingRti = new Set<ClassElement>(),
23 rtiDependencies = new Map<ClassElement, Set<ClassElement>>(), 25 rtiDependencies = new Map<ClassElement, Set<ClassElement>>(),
24 this.compiler = compiler; 26 this.compiler = compiler;
25 27
26 void populate() { 28 void populate() {
27 void addSubtypes(ClassElement cls) { 29 void addSubtypes(ClassElement cls) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 potentiallyAddForRti(itf.element); 88 potentiallyAddForRti(itf.element);
87 } 89 }
88 } 90 }
89 }); 91 });
90 } 92 }
91 93
92 bool needsRti(ClassElement cls) { 94 bool needsRti(ClassElement cls) {
93 return classesNeedingRti.contains(cls) || compiler.enabledRuntimeType; 95 return classesNeedingRti.contains(cls) || compiler.enabledRuntimeType;
94 } 96 }
95 97
98 void registerMixinUse(MixinApplicationElement mixinApplication,
99 ClassElement mixin) {
100 Set<MixinApplicationElement> users =
101 mixinUses.putIfAbsent(mixin, () =>
102 new Set<MixinApplicationElement>());
103 users.add(mixinApplication);
104 }
105
96 void registerRtiDependency(Element element, Element dependency) { 106 void registerRtiDependency(Element element, Element dependency) {
97 // We're not dealing with typedef for now. 107 // We're not dealing with typedef for now.
98 if (!element.isClass() || !dependency.isClass()) return; 108 if (!element.isClass() || !dependency.isClass()) return;
99 Set<ClassElement> classes = 109 Set<ClassElement> classes =
100 rtiDependencies.putIfAbsent(element, () => new Set<ClassElement>()); 110 rtiDependencies.putIfAbsent(element, () => new Set<ClassElement>());
101 classes.add(dependency); 111 classes.add(dependency);
102 } 112 }
103 113
104 void recordUserDefinedGetter(Element element) { 114 void recordUserDefinedGetter(Element element) {
105 assert(element.isGetter()); 115 assert(element.isGetter());
(...skipping 20 matching lines...) Expand all
126 return subclasses.contains(type.element); 136 return subclasses.contains(type.element);
127 } 137 }
128 138
129 bool hasNoOverridingMember(Element element) { 139 bool hasNoOverridingMember(Element element) {
130 ClassElement cls = element.getEnclosingClass(); 140 ClassElement cls = element.getEnclosingClass();
131 Set<ClassElement> subclasses = compiler.world.subtypes[cls]; 141 Set<ClassElement> subclasses = compiler.world.subtypes[cls];
132 // TODO(ngeoffray): Implement the full thing. 142 // TODO(ngeoffray): Implement the full thing.
133 return subclasses == null || subclasses.isEmpty; 143 return subclasses == null || subclasses.isEmpty;
134 } 144 }
135 145
136
137
138 void registerUsedElement(Element element) { 146 void registerUsedElement(Element element) {
139 if (element.isMember()) { 147 if (element.isMember()) {
140 if (element.isGetter()) { 148 if (element.isGetter()) {
141 // We're collecting user-defined getters to let the codegen know which 149 // We're collecting user-defined getters to let the codegen know which
142 // field accesses might have side effects. 150 // field accesses might have side effects.
143 recordUserDefinedGetter(element); 151 recordUserDefinedGetter(element);
144 } else if (element.isSetter()) { 152 } else if (element.isSetter()) {
145 recordUserDefinedSetter(element); 153 recordUserDefinedSetter(element);
146 } 154 }
147 } 155 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 final SourceString name; 223 final SourceString name;
216 224
217 MemberSet(SourceString this.name) : elements = new Set<Element>(); 225 MemberSet(SourceString this.name) : elements = new Set<Element>();
218 226
219 void add(Element element) { 227 void add(Element element) {
220 elements.add(element); 228 elements.add(element);
221 } 229 }
222 230
223 bool get isEmpty => elements.isEmpty; 231 bool get isEmpty => elements.isEmpty;
224 } 232 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/warnings.dart ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698