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

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

Issue 13527003: Make `this` available in closures if a type variable is used as expression. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add null check and test status for dart2dart Created 7 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 | « no previous file | tests/language/closure_type_variable_test.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 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 } 398 }
399 } else { 399 } else {
400 visit(definition); 400 visit(definition);
401 } 401 }
402 } 402 }
403 } 403 }
404 404
405 visitIdentifier(Identifier node) { 405 visitIdentifier(Identifier node) {
406 if (node.isThis()) { 406 if (node.isThis()) {
407 useLocal(closureData.thisElement); 407 useLocal(closureData.thisElement);
408 } else {
409 Element element = elements[node];
410 if (element != null && element.kind == ElementKind.TYPE_VARIABLE) {
411 useLocal(closureData.thisElement);
412 }
408 } 413 }
409 node.visitChildren(this); 414 node.visitChildren(this);
410 } 415 }
411 416
412 visitSend(Send node) { 417 visitSend(Send node) {
413 Element element = elements[node]; 418 Element element = elements[node];
414 if (Elements.isLocal(element)) { 419 if (Elements.isLocal(element)) {
415 useLocal(element); 420 useLocal(element);
416 } else if (node.receiver == null && 421 } else if (node.receiver == null &&
417 Elements.isInstanceSend(node, elements)) { 422 Elements.isInstanceSend(node, elements)) {
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 } 701 }
697 702
698 visitTryStatement(TryStatement node) { 703 visitTryStatement(TryStatement node) {
699 // TODO(ngeoffray): implement finer grain state. 704 // TODO(ngeoffray): implement finer grain state.
700 bool oldInTryStatement = inTryStatement; 705 bool oldInTryStatement = inTryStatement;
701 inTryStatement = true; 706 inTryStatement = true;
702 node.visitChildren(this); 707 node.visitChildren(this);
703 inTryStatement = oldInTryStatement; 708 inTryStatement = oldInTryStatement;
704 } 709 }
705 } 710 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/closure_type_variable_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698