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

Side by Side Diff: pkg/compiler/lib/src/closure.dart

Issue 1062913003: Extract CallStructure from Selector. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 | Annotate | Revision Log
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 library closureToClassMapper; 5 library closureToClassMapper;
6 6
7 import "elements/elements.dart"; 7 import "elements/elements.dart";
8 import "dart2jslib.dart"; 8 import "dart2jslib.dart";
9 import "dart_types.dart"; 9 import "dart_types.dart";
10 import "js_backend/js_backend.dart" show JavaScriptBackend; 10 import "js_backend/js_backend.dart" show JavaScriptBackend;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } 86 }
87 } 87 }
88 88
89 /// Common interface for [BoxFieldElement] and [ClosureFieldElement] as 89 /// Common interface for [BoxFieldElement] and [ClosureFieldElement] as
90 /// non-elements. 90 /// non-elements.
91 abstract class CapturedVariable {} 91 abstract class CapturedVariable {}
92 92
93 // TODO(ahe): These classes continuously cause problems. We need to 93 // TODO(ahe): These classes continuously cause problems. We need to
94 // find a more general solution. 94 // find a more general solution.
95 class ClosureFieldElement extends ElementX 95 class ClosureFieldElement extends ElementX
96 implements VariableElement, CapturedVariable { 96 implements FieldElement, CapturedVariable {
97 /// The [BoxLocal] or [LocalElement] being accessed through the field. 97 /// The [BoxLocal] or [LocalElement] being accessed through the field.
98 final Local local; 98 final Local local;
99 99
100 ClosureFieldElement(String name, 100 ClosureFieldElement(String name,
101 this.local, 101 this.local,
102 ClosureClassElement enclosing) 102 ClosureClassElement enclosing)
103 : super(name, ElementKind.FIELD, enclosing); 103 : super(name, ElementKind.FIELD, enclosing);
104 104
105 /// Use [closureClass] instead. 105 /// Use [closureClass] instead.
106 @deprecated 106 @deprecated
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 return element.type; 139 return element.type;
140 } 140 }
141 return const DynamicType(); 141 return const DynamicType();
142 } 142 }
143 143
144 String toString() => "ClosureFieldElement($name)"; 144 String toString() => "ClosureFieldElement($name)";
145 145
146 accept(ElementVisitor visitor) => visitor.visitClosureFieldElement(this); 146 accept(ElementVisitor visitor) => visitor.visitClosureFieldElement(this);
147 147
148 Element get analyzableElement => closureClass.methodElement.analyzableElement; 148 Element get analyzableElement => closureClass.methodElement.analyzableElement;
149
150 @override
151 List<FunctionElement> get nestedClosures => const <FunctionElement>[];
149 } 152 }
150 153
151 // TODO(ahe): These classes continuously cause problems. We need to find 154 // TODO(ahe): These classes continuously cause problems. We need to find
152 // a more general solution. 155 // a more general solution.
153 class ClosureClassElement extends ClassElementX { 156 class ClosureClassElement extends ClassElementX {
154 DartType rawType; 157 DartType rawType;
155 DartType thisType; 158 DartType thisType;
156 FunctionType callType; 159 FunctionType callType;
157 /// Node that corresponds to this closure, used for source position. 160 /// Node that corresponds to this closure, used for source position.
158 final FunctionExpression node; 161 final FunctionExpression node;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 class BoxLocal extends Local { 222 class BoxLocal extends Local {
220 final String name; 223 final String name;
221 final ExecutableElement executableContext; 224 final ExecutableElement executableContext;
222 225
223 BoxLocal(this.name, this.executableContext); 226 BoxLocal(this.name, this.executableContext);
224 } 227 }
225 228
226 // TODO(ngeoffray, ahe): These classes continuously cause problems. We need to 229 // TODO(ngeoffray, ahe): These classes continuously cause problems. We need to
227 // find a more general solution. 230 // find a more general solution.
228 class BoxFieldElement extends ElementX 231 class BoxFieldElement extends ElementX
229 implements TypedElement, CapturedVariable { 232 implements TypedElement, CapturedVariable, FieldElement {
230 final BoxLocal box; 233 final BoxLocal box;
231 234
232 BoxFieldElement(String name, this.variableElement, BoxLocal box) 235 BoxFieldElement(String name, this.variableElement, BoxLocal box)
233 : this.box = box, 236 : this.box = box,
234 super(name, ElementKind.FIELD, box.executableContext); 237 super(name, ElementKind.FIELD, box.executableContext);
235 238
236 DartType computeType(Compiler compiler) => type; 239 DartType computeType(Compiler compiler) => type;
237 240
238 DartType get type => variableElement.type; 241 DartType get type => variableElement.type;
239 242
240 final VariableElement variableElement; 243 final VariableElement variableElement;
241 244
242 accept(ElementVisitor visitor) => visitor.visitBoxFieldElement(this); 245 accept(ElementVisitor visitor) => visitor.visitBoxFieldElement(this);
246
247 @override
248 bool get hasNode => false;
249
250 @override
251 bool get hasResolvedAst => false;
252
253 @override
254 Expression get initializer {
255 throw new UnsupportedError("BoxFieldElement.initializer");
256 }
257
258 @override
259 MemberElement get memberContext => box.executableContext.memberContext;
260
261 @override
262 List<FunctionElement> get nestedClosures => const <FunctionElement>[];
263
264 @override
265 Node get node {
266 throw new UnsupportedError("BoxFieldElement.node");
267 }
268
269 @override
270 ResolvedAst get resolvedAst {
271 throw new UnsupportedError("BoxFieldElement.resolvedAst");
272 }
243 } 273 }
244 274
245 /// A local variable used encode the direct (uncaptured) references to [this]. 275 /// A local variable used encode the direct (uncaptured) references to [this].
246 class ThisLocal extends Local { 276 class ThisLocal extends Local {
247 final ExecutableElement executableContext; 277 final ExecutableElement executableContext;
248 278
249 ThisLocal(this.executableContext); 279 ThisLocal(this.executableContext);
250 280
251 String get name => 'this'; 281 String get name => 'this';
252 282
253 ClassElement get enclosingClass => executableContext.enclosingClass; 283 ClassElement get enclosingClass => executableContext.enclosingClass;
254 } 284 }
255 285
256 /// Call method of a closure class. 286 /// Call method of a closure class.
257 class SynthesizedCallMethodElementX extends BaseFunctionElementX { 287 class SynthesizedCallMethodElementX extends BaseFunctionElementX
288 implements MethodElement {
258 final LocalFunctionElement expression; 289 final LocalFunctionElement expression;
259 290
260 SynthesizedCallMethodElementX(String name, 291 SynthesizedCallMethodElementX(String name,
261 LocalFunctionElementX other, 292 LocalFunctionElementX other,
262 ClosureClassElement enclosing) 293 ClosureClassElement enclosing)
263 : expression = other, 294 : expression = other,
264 super(name, other.kind, other.modifiers, enclosing, false) { 295 super(name, other.kind, other.modifiers, enclosing, false) {
265 asyncMarker = other.asyncMarker; 296 asyncMarker = other.asyncMarker;
266 functionSignatureCache = other.functionSignature; 297 functionSignatureCache = other.functionSignature;
267 } 298 }
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 1091
1061 String get name => typeVariable.name; 1092 String get name => typeVariable.name;
1062 1093
1063 int get hashCode => typeVariable.hashCode; 1094 int get hashCode => typeVariable.hashCode;
1064 1095
1065 bool operator ==(other) { 1096 bool operator ==(other) {
1066 if (other is! TypeVariableLocal) return false; 1097 if (other is! TypeVariableLocal) return false;
1067 return typeVariable == other.typeVariable; 1098 return typeVariable == other.typeVariable;
1068 } 1099 }
1069 } 1100 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698