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

Side by Side Diff: dart/frog/leg/ssa/closure.dart

Issue 9417031: Mock up all remaining core library implementation classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 10 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 class ClosureFieldElement extends Element { 5 class ClosureFieldElement extends Element {
6 ClosureFieldElement(SourceString name, ClassElement enclosing) 6 ClosureFieldElement(SourceString name, ClassElement enclosing)
7 : super(name, ElementKind.FIELD, enclosing); 7 : super(name, ElementKind.FIELD, enclosing);
8 8
9 bool isInstanceMember() => true; 9 bool isInstanceMember() => true;
10 bool isAssignable() => false; 10 bool isAssignable() => false;
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 compiler.coreLibrary.find(const SourceString('Object')); 302 compiler.coreLibrary.find(const SourceString('Object'));
303 globalizedElement.supertype = new SimpleType(Types.OBJECT, objectClass); 303 globalizedElement.supertype = new SimpleType(Types.OBJECT, objectClass);
304 // The nested function's 'this' is the same as the one for the outer 304 // The nested function's 'this' is the same as the one for the outer
305 // function. It could be [null] if we are inside a static method. 305 // function. It could be [null] if we are inside a static method.
306 Element thisElement = closureData.thisElement; 306 Element thisElement = closureData.thisElement;
307 return new ClosureData(element, globalizedElement, 307 return new ClosureData(element, globalizedElement,
308 callElement, thisElement); 308 callElement, thisElement);
309 } 309 }
310 310
311 visitFunctionExpression(FunctionExpression node) { 311 visitFunctionExpression(FunctionExpression node) {
312 FunctionElement element = elements[node]; 312 Element element = elements[node];
313 if (element.kind === ElementKind.PARAMETER) {
314 // TODO(ahe): This is a hack. This method should *not* call
315 // visitChildren.
ngeoffray 2012/02/17 10:03:50 Please explain the hack: a parameter with a functi
316 return node.name.accept(this);
317 }
313 bool isClosure = (closureData !== null); 318 bool isClosure = (closureData !== null);
314 319
315 if (isClosure) closures.add(node); 320 if (isClosure) closures.add(node);
316 321
317 bool oldInsideClosure = insideClosure; 322 bool oldInsideClosure = insideClosure;
318 FunctionElement oldFunctionElement = currentFunctionElement; 323 FunctionElement oldFunctionElement = currentFunctionElement;
319 ClosureData oldClosureData = closureData; 324 ClosureData oldClosureData = closureData;
320 List<Element> oldScopeVariables = scopeVariables; 325 List<Element> oldScopeVariables = scopeVariables;
321 326
322 327
(...skipping 30 matching lines...) Expand all
353 if (!insideClosure && closureData.thisElement !== null) { 358 if (!insideClosure && closureData.thisElement !== null) {
354 declareLocal(closureData.thisElement); 359 declareLocal(closureData.thisElement);
355 } 360 }
356 // If we are inside a named closure we have to declare ourselve. For 361 // If we are inside a named closure we have to declare ourselve. For
357 // simplicity we declare the local even if the closure does not have a name 362 // simplicity we declare the local even if the closure does not have a name
358 // It will simply not be used. 363 // It will simply not be used.
359 if (insideClosure) { 364 if (insideClosure) {
360 declareLocal(element); 365 declareLocal(element);
361 } 366 }
362 367
368 // TODO(ahe): This is problematic. The backend should not repeat
369 // the work of the resolver. It is the resolver's job to create
370 // parameters, etc. Other phases should only visit statements.
ngeoffray 2012/02/17 10:03:50 Not sure I understand this comment, because the ba
ahe 2012/02/17 16:26:46 The backend should run through "element.computePar
363 node.visitChildren(this); 371 node.visitChildren(this);
364 372
365 attachCapturedScopeVariables(node); 373 attachCapturedScopeVariables(node);
366 374
367 closureDataCache[node] = closureData; 375 closureDataCache[node] = closureData;
368 376
369 ClosureData savedClosureData = closureData; 377 ClosureData savedClosureData = closureData;
370 bool savedInsideClosure = insideClosure; 378 bool savedInsideClosure = insideClosure;
371 379
372 // Restore old values. 380 // Restore old values.
(...skipping 14 matching lines...) Expand all
387 } 395 }
388 } 396 }
389 397
390 visitTryStatement(TryStatement node) { 398 visitTryStatement(TryStatement node) {
391 // TODO(ngeoffray): implement finer grain state. 399 // TODO(ngeoffray): implement finer grain state.
392 inTryCatchOrFinally = true; 400 inTryCatchOrFinally = true;
393 node.visitChildren(this); 401 node.visitChildren(this);
394 inTryCatchOrFinally = false; 402 inTryCatchOrFinally = false;
395 } 403 }
396 } 404 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698