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

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

Issue 15381002: Fix a pretty bad bug of a class inheriting a patched class. The fix is (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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 | « no previous file | sdk/lib/_internal/compiler/implementation/compile_time_constants.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 "scanner/scannerlib.dart" show Token; 10 import "scanner/scannerlib.dart" show Token;
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 Element boxElement = updatedElement.enclosingElement; 338 Element boxElement = updatedElement.enclosingElement;
339 assert(boxElement.kind == ElementKind.VARIABLE); 339 assert(boxElement.kind == ElementKind.VARIABLE);
340 boxes.add(boxElement); 340 boxes.add(boxElement);
341 } 341 }
342 }); 342 });
343 ClassElement closureElement = data.closureClassElement; 343 ClassElement closureElement = data.closureClassElement;
344 assert(closureElement != null || 344 assert(closureElement != null ||
345 (fieldCaptures.isEmpty && boxes.isEmpty)); 345 (fieldCaptures.isEmpty && boxes.isEmpty));
346 void addElement(Element element, SourceString name) { 346 void addElement(Element element, SourceString name) {
347 Element fieldElement = new ClosureFieldElement(name, closureElement); 347 Element fieldElement = new ClosureFieldElement(name, closureElement);
348 closureElement.addBackendMember(fieldElement); 348 closureElement.addMember(fieldElement, compiler);
349 data.capturedFieldMapping[fieldElement] = element; 349 data.capturedFieldMapping[fieldElement] = element;
350 freeVariableMapping[element] = fieldElement; 350 freeVariableMapping[element] = fieldElement;
351 } 351 }
352 // Add the box elements first so we get the same ordering. 352 // Add the box elements first so we get the same ordering.
353 // TODO(sra): What is the canonical order of multiple boxes? 353 // TODO(sra): What is the canonical order of multiple boxes?
354 for (Element capturedElement in boxes) { 354 for (Element capturedElement in boxes) {
355 addElement(capturedElement, capturedElement.name); 355 addElement(capturedElement, capturedElement.name);
356 } 356 }
357 for (Element capturedElement in 357 for (Element capturedElement in
358 Elements.sortedByPosition(fieldCaptures)) { 358 Elements.sortedByPosition(fieldCaptures)) {
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 } 653 }
654 654
655 ClosureClassMap globalizeClosure(FunctionExpression node, Element element) { 655 ClosureClassMap globalizeClosure(FunctionExpression node, Element element) {
656 SourceString closureName = new SourceString(computeClosureName(element)); 656 SourceString closureName = new SourceString(computeClosureName(element));
657 ClassElement globalizedElement = new ClosureClassElement( 657 ClassElement globalizedElement = new ClosureClassElement(
658 node, closureName, compiler, element, element.getCompilationUnit()); 658 node, closureName, compiler, element, element.getCompilationUnit());
659 FunctionElement callElement = 659 FunctionElement callElement =
660 new FunctionElementX.from(Compiler.CALL_OPERATOR_NAME, 660 new FunctionElementX.from(Compiler.CALL_OPERATOR_NAME,
661 element, 661 element,
662 globalizedElement); 662 globalizedElement);
663 globalizedElement.addBackendMember(callElement); 663 globalizedElement.addMember(callElement, compiler);
664 // The nested function's 'this' is the same as the one for the outer 664 // The nested function's 'this' is the same as the one for the outer
665 // function. It could be [null] if we are inside a static method. 665 // function. It could be [null] if we are inside a static method.
666 Element thisElement = closureData.thisElement; 666 Element thisElement = closureData.thisElement;
667 return new ClosureClassMap(element, globalizedElement, 667 return new ClosureClassMap(element, globalizedElement,
668 callElement, thisElement); 668 callElement, thisElement);
669 } 669 }
670 670
671 void visitInvokable(Element element, Expression node, void visitChildren()) { 671 void visitInvokable(Element element, Expression node, void visitChildren()) {
672 bool oldInsideClosure = insideClosure; 672 bool oldInsideClosure = insideClosure;
673 Element oldFunctionElement = currentElement; 673 Element oldFunctionElement = currentElement;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 } 767 }
768 768
769 visitTryStatement(TryStatement node) { 769 visitTryStatement(TryStatement node) {
770 // TODO(ngeoffray): implement finer grain state. 770 // TODO(ngeoffray): implement finer grain state.
771 bool oldInTryStatement = inTryStatement; 771 bool oldInTryStatement = inTryStatement;
772 inTryStatement = true; 772 inTryStatement = true;
773 node.visitChildren(this); 773 node.visitChildren(this);
774 inTryStatement = oldInTryStatement; 774 inTryStatement = oldInTryStatement;
775 } 775 }
776 } 776 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/compile_time_constants.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698