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

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

Issue 1068233002: Revert "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
« no previous file with comments | « pkg/analyzer2dart/lib/src/modely.dart ('k') | pkg/compiler/lib/src/common.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) 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 FieldElement, CapturedVariable { 96 implements VariableElement, 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>[];
152 } 149 }
153 150
154 // TODO(ahe): These classes continuously cause problems. We need to find 151 // TODO(ahe): These classes continuously cause problems. We need to find
155 // a more general solution. 152 // a more general solution.
156 class ClosureClassElement extends ClassElementX { 153 class ClosureClassElement extends ClassElementX {
157 DartType rawType; 154 DartType rawType;
158 DartType thisType; 155 DartType thisType;
159 FunctionType callType; 156 FunctionType callType;
160 /// Node that corresponds to this closure, used for source position. 157 /// Node that corresponds to this closure, used for source position.
161 final FunctionExpression node; 158 final FunctionExpression node;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 class BoxLocal extends Local { 219 class BoxLocal extends Local {
223 final String name; 220 final String name;
224 final ExecutableElement executableContext; 221 final ExecutableElement executableContext;
225 222
226 BoxLocal(this.name, this.executableContext); 223 BoxLocal(this.name, this.executableContext);
227 } 224 }
228 225
229 // TODO(ngeoffray, ahe): These classes continuously cause problems. We need to 226 // TODO(ngeoffray, ahe): These classes continuously cause problems. We need to
230 // find a more general solution. 227 // find a more general solution.
231 class BoxFieldElement extends ElementX 228 class BoxFieldElement extends ElementX
232 implements TypedElement, CapturedVariable, FieldElement { 229 implements TypedElement, CapturedVariable {
233 final BoxLocal box; 230 final BoxLocal box;
234 231
235 BoxFieldElement(String name, this.variableElement, BoxLocal box) 232 BoxFieldElement(String name, this.variableElement, BoxLocal box)
236 : this.box = box, 233 : this.box = box,
237 super(name, ElementKind.FIELD, box.executableContext); 234 super(name, ElementKind.FIELD, box.executableContext);
238 235
239 DartType computeType(Compiler compiler) => type; 236 DartType computeType(Compiler compiler) => type;
240 237
241 DartType get type => variableElement.type; 238 DartType get type => variableElement.type;
242 239
243 final VariableElement variableElement; 240 final VariableElement variableElement;
244 241
245 accept(ElementVisitor visitor) => visitor.visitBoxFieldElement(this); 242 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 }
273 } 243 }
274 244
275 /// A local variable used encode the direct (uncaptured) references to [this]. 245 /// A local variable used encode the direct (uncaptured) references to [this].
276 class ThisLocal extends Local { 246 class ThisLocal extends Local {
277 final ExecutableElement executableContext; 247 final ExecutableElement executableContext;
278 248
279 ThisLocal(this.executableContext); 249 ThisLocal(this.executableContext);
280 250
281 String get name => 'this'; 251 String get name => 'this';
282 252
283 ClassElement get enclosingClass => executableContext.enclosingClass; 253 ClassElement get enclosingClass => executableContext.enclosingClass;
284 } 254 }
285 255
286 /// Call method of a closure class. 256 /// Call method of a closure class.
287 class SynthesizedCallMethodElementX extends BaseFunctionElementX 257 class SynthesizedCallMethodElementX extends BaseFunctionElementX {
288 implements MethodElement {
289 final LocalFunctionElement expression; 258 final LocalFunctionElement expression;
290 259
291 SynthesizedCallMethodElementX(String name, 260 SynthesizedCallMethodElementX(String name,
292 LocalFunctionElementX other, 261 LocalFunctionElementX other,
293 ClosureClassElement enclosing) 262 ClosureClassElement enclosing)
294 : expression = other, 263 : expression = other,
295 super(name, other.kind, other.modifiers, enclosing, false) { 264 super(name, other.kind, other.modifiers, enclosing, false) {
296 asyncMarker = other.asyncMarker; 265 asyncMarker = other.asyncMarker;
297 functionSignatureCache = other.functionSignature; 266 functionSignatureCache = other.functionSignature;
298 } 267 }
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 1060
1092 String get name => typeVariable.name; 1061 String get name => typeVariable.name;
1093 1062
1094 int get hashCode => typeVariable.hashCode; 1063 int get hashCode => typeVariable.hashCode;
1095 1064
1096 bool operator ==(other) { 1065 bool operator ==(other) {
1097 if (other is! TypeVariableLocal) return false; 1066 if (other is! TypeVariableLocal) return false;
1098 return typeVariable == other.typeVariable; 1067 return typeVariable == other.typeVariable;
1099 } 1068 }
1100 } 1069 }
OLDNEW
« no previous file with comments | « pkg/analyzer2dart/lib/src/modely.dart ('k') | pkg/compiler/lib/src/common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698