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

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

Issue 10915054: Mark the local for this as used if a constructor call needs type variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add test and address comments. Created 8 years, 3 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("leg.dart"); 8 #import("leg.dart");
9 #import("scanner/scannerlib.dart"); 9 #import("scanner/scannerlib.dart");
10 #import("tree/tree.dart"); 10 #import("tree/tree.dart");
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 } 310 }
311 311
312 visitSendSet(SendSet node) { 312 visitSendSet(SendSet node) {
313 Element element = elements[node]; 313 Element element = elements[node];
314 if (Elements.isLocal(element)) { 314 if (Elements.isLocal(element)) {
315 mutatedVariables.add(element); 315 mutatedVariables.add(element);
316 } 316 }
317 super.visitSendSet(node); 317 super.visitSendSet(node);
318 } 318 }
319 319
320 visitNewExpression(NewExpression node) {
321 bool hasTypeVariable(DartType type) {
322 if (type is TypeVariableType) {
323 return true;
324 } else if (type is InterfaceType) {
325 InterfaceType ifcType = type;
326 for (DartType argument in ifcType.arguments) {
327 if (hasTypeVariable(argument)) {
328 return true;
329 }
330 }
331 }
332 return false;
333 }
334 TypeAnnotation annotation = node.send.getTypeAnnotation();
335 DartType type = elements.getType(annotation);
336 if (hasTypeVariable(type)) {
337 if (closureData.thisElement !== null) {
floitsch 2012/09/03 14:04:15 Add comment why this is necessary. Maybe find a mo
338 useLocal(closureData.thisElement);
339 }
340 }
341 node.visitChildren(this);
342 }
343
320 // If variables that are declared in the [node] scope are captured and need 344 // If variables that are declared in the [node] scope are captured and need
321 // to be boxed create a box-element and update the [capturingScopes] in the 345 // to be boxed create a box-element and update the [capturingScopes] in the
322 // current [closureData]. 346 // current [closureData].
323 // The boxed variables are updated in the [capturedVariableMapping]. 347 // The boxed variables are updated in the [capturedVariableMapping].
324 void attachCapturedScopeVariables(Node node) { 348 void attachCapturedScopeVariables(Node node) {
325 Element box = null; 349 Element box = null;
326 Map<Element, Element> scopeMapping = new Map<Element, Element>(); 350 Map<Element, Element> scopeMapping = new Map<Element, Element>();
327 for (Element element in scopeVariables) { 351 for (Element element in scopeVariables) {
328 // No need to box non-assignable elements. 352 // No need to box non-assignable elements.
329 if (!element.isAssignable()) continue; 353 if (!element.isAssignable()) continue;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 } 523 }
500 524
501 visitTryStatement(TryStatement node) { 525 visitTryStatement(TryStatement node) {
502 // TODO(ngeoffray): implement finer grain state. 526 // TODO(ngeoffray): implement finer grain state.
503 bool oldInTryStatement = inTryStatement; 527 bool oldInTryStatement = inTryStatement;
504 inTryStatement = true; 528 inTryStatement = true;
505 node.visitChildren(this); 529 node.visitChildren(this);
506 inTryStatement = oldInTryStatement; 530 inTryStatement = oldInTryStatement;
507 } 531 }
508 } 532 }
OLDNEW
« no previous file with comments | « no previous file | lib/compiler/implementation/resolver.dart » ('j') | tests/language/closure_type_variables_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698