| OLD | NEW |
| 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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 if (type is TypeVariableType) { | 367 if (type is TypeVariableType) { |
| 368 useLocal(type.element); | 368 useLocal(type.element); |
| 369 } else if (type is InterfaceType) { | 369 } else if (type is InterfaceType) { |
| 370 InterfaceType ifcType = type; | 370 InterfaceType ifcType = type; |
| 371 for (DartType argument in ifcType.arguments) { | 371 for (DartType argument in ifcType.arguments) { |
| 372 analyzeTypeVariables(argument); | 372 analyzeTypeVariables(argument); |
| 373 } | 373 } |
| 374 } | 374 } |
| 375 } | 375 } |
| 376 | 376 |
| 377 if (outermostFunctionElement.isInstanceMember() | 377 if (compiler.world.needsRti(outermostFunctionElement.enclosingElement)) { |
| 378 || outermostFunctionElement.isGenerativeConstructor()) { | 378 if (outermostFunctionElement.isInstanceMember() |
| 379 if (hasTypeVariable(type)) useLocal(closureData.thisElement); | 379 || outermostFunctionElement.isGenerativeConstructor()) { |
| 380 } else if (outermostFunctionElement.isFactoryConstructor()) { | 380 if (hasTypeVariable(type)) useLocal(closureData.thisElement); |
| 381 analyzeTypeVariables(type); | 381 } else if (outermostFunctionElement.isFactoryConstructor()) { |
| 382 analyzeTypeVariables(type); |
| 383 } |
| 382 } | 384 } |
| 383 | 385 |
| 384 node.visitChildren(this); | 386 node.visitChildren(this); |
| 385 } | 387 } |
| 386 | 388 |
| 387 // If variables that are declared in the [node] scope are captured and need | 389 // If variables that are declared in the [node] scope are captured and need |
| 388 // to be boxed create a box-element and update the [capturingScopes] in the | 390 // to be boxed create a box-element and update the [capturingScopes] in the |
| 389 // current [closureData]. | 391 // current [closureData]. |
| 390 // The boxed variables are updated in the [capturedVariableMapping]. | 392 // The boxed variables are updated in the [capturedVariableMapping]. |
| 391 void attachCapturedScopeVariables(Node node) { | 393 void attachCapturedScopeVariables(Node node) { |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 declareLocal(closureData.thisElement); | 542 declareLocal(closureData.thisElement); |
| 541 } | 543 } |
| 542 // If we are inside a named closure we have to declare ourselve. For | 544 // If we are inside a named closure we have to declare ourselve. For |
| 543 // simplicity we declare the local even if the closure does not have a | 545 // simplicity we declare the local even if the closure does not have a |
| 544 // name. | 546 // name. |
| 545 // It will simply not be used. | 547 // It will simply not be used. |
| 546 if (insideClosure) { | 548 if (insideClosure) { |
| 547 declareLocal(element); | 549 declareLocal(element); |
| 548 } | 550 } |
| 549 | 551 |
| 550 if (currentFunctionElement.isFactoryConstructor()) { | 552 if (currentFunctionElement.isFactoryConstructor() |
| 553 && compiler.world.needsRti(currentFunctionElement.enclosingElement)) { |
| 551 // Declare the type parameters in the scope. Generative | 554 // Declare the type parameters in the scope. Generative |
| 552 // constructors just use 'this'. | 555 // constructors just use 'this'. |
| 553 ClassElement cls = currentFunctionElement.enclosingElement; | 556 ClassElement cls = currentFunctionElement.enclosingElement; |
| 554 cls.typeVariables.forEach((TypeVariableType typeVariable) { | 557 cls.typeVariables.forEach((TypeVariableType typeVariable) { |
| 555 declareLocal(typeVariable.element); | 558 declareLocal(typeVariable.element); |
| 556 }); | 559 }); |
| 557 } | 560 } |
| 558 | 561 |
| 559 // TODO(ahe): This is problematic. The backend should not repeat | 562 // TODO(ahe): This is problematic. The backend should not repeat |
| 560 // the work of the resolver. It is the resolver's job to create | 563 // the work of the resolver. It is the resolver's job to create |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 } | 597 } |
| 595 | 598 |
| 596 visitTryStatement(TryStatement node) { | 599 visitTryStatement(TryStatement node) { |
| 597 // TODO(ngeoffray): implement finer grain state. | 600 // TODO(ngeoffray): implement finer grain state. |
| 598 bool oldInTryStatement = inTryStatement; | 601 bool oldInTryStatement = inTryStatement; |
| 599 inTryStatement = true; | 602 inTryStatement = true; |
| 600 node.visitChildren(this); | 603 node.visitChildren(this); |
| 601 inTryStatement = oldInTryStatement; | 604 inTryStatement = oldInTryStatement; |
| 602 } | 605 } |
| 603 } | 606 } |
| OLD | NEW |