| 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 "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 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 Elements.isInstanceSend(node, elements)) { | 508 Elements.isInstanceSend(node, elements)) { |
| 509 registerNeedsThis(); | 509 registerNeedsThis(); |
| 510 } else if (node.isSuperCall) { | 510 } else if (node.isSuperCall) { |
| 511 registerNeedsThis(); | 511 registerNeedsThis(); |
| 512 } else if (node.isIsCheck || node.isIsNotCheck || node.isTypeCast) { | 512 } else if (node.isIsCheck || node.isIsNotCheck || node.isTypeCast) { |
| 513 TypeAnnotation annotation = node.typeAnnotationFromIsCheckOrCast; | 513 TypeAnnotation annotation = node.typeAnnotationFromIsCheckOrCast; |
| 514 DartType type = elements.getType(annotation); | 514 DartType type = elements.getType(annotation); |
| 515 if (type != null && type.containsTypeVariables) { | 515 if (type != null && type.containsTypeVariables) { |
| 516 registerNeedsThis(); | 516 registerNeedsThis(); |
| 517 } | 517 } |
| 518 } else if (node.isParameterCheck) { | |
| 519 Element parameter = elements[node.receiver]; | |
| 520 FunctionElement enclosing = parameter.enclosingElement; | |
| 521 FunctionExpression function = enclosing.parseNode(compiler); | |
| 522 ClosureClassMap cached = closureMappingCache[function]; | |
| 523 if (!cached.parametersWithSentinel.containsKey(parameter)) { | |
| 524 SourceString parameterName = parameter.name; | |
| 525 String name = '${parameterName.slowToString()}_check'; | |
| 526 Element newElement = new CheckVariableElement(new SourceString(name), | |
| 527 parameter, | |
| 528 enclosing); | |
| 529 useLocal(newElement); | |
| 530 cached.parametersWithSentinel[parameter] = newElement; | |
| 531 } | |
| 532 } else if (node.isTypeTest) { | 518 } else if (node.isTypeTest) { |
| 533 DartType type = elements.getType(node.typeAnnotationFromIsCheckOrCast); | 519 DartType type = elements.getType(node.typeAnnotationFromIsCheckOrCast); |
| 534 analyzeType(type); | 520 analyzeType(type); |
| 535 } else if (node.isTypeCast) { | 521 } else if (node.isTypeCast) { |
| 536 DartType type = elements.getType(node.arguments.head); | 522 DartType type = elements.getType(node.arguments.head); |
| 537 analyzeType(type); | 523 analyzeType(type); |
| 538 } | 524 } |
| 539 node.visitChildren(this); | 525 node.visitChildren(this); |
| 540 } | 526 } |
| 541 | 527 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 } | 800 } |
| 815 | 801 |
| 816 visitTryStatement(TryStatement node) { | 802 visitTryStatement(TryStatement node) { |
| 817 // TODO(ngeoffray): implement finer grain state. | 803 // TODO(ngeoffray): implement finer grain state. |
| 818 bool oldInTryStatement = inTryStatement; | 804 bool oldInTryStatement = inTryStatement; |
| 819 inTryStatement = true; | 805 inTryStatement = true; |
| 820 node.visitChildren(this); | 806 node.visitChildren(this); |
| 821 inTryStatement = oldInTryStatement; | 807 inTryStatement = oldInTryStatement; |
| 822 } | 808 } |
| 823 } | 809 } |
| OLD | NEW |