| 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"); |
| 11 #import("util/util.dart"); | 11 #import("util/util.dart"); |
| 12 | 12 |
| 13 class ClosureTask extends CompilerTask { | 13 class ClosureTask extends CompilerTask { |
| 14 Map<Node, ClosureClassMap> closureMappingCache; | 14 Map<Node, ClosureClassMap> closureMappingCache; |
| 15 ClosureTask(Compiler compiler) | 15 ClosureTask(Compiler compiler) |
| 16 : closureMappingCache = new Map<Node, ClosureClassMap>(), | 16 : closureMappingCache = new Map<Node, ClosureClassMap>(), |
| 17 super(compiler); | 17 super(compiler); |
| 18 | 18 |
| 19 String get name() => "Closure Simplifier"; | 19 String get name => "Closure Simplifier"; |
| 20 | 20 |
| 21 ClosureClassMap computeClosureToClassMapping(FunctionExpression node, | 21 ClosureClassMap computeClosureToClassMapping(FunctionExpression node, |
| 22 TreeElements elements) { | 22 TreeElements elements) { |
| 23 return measure(() { | 23 return measure(() { |
| 24 ClosureClassMap cached = closureMappingCache[node]; | 24 ClosureClassMap cached = closureMappingCache[node]; |
| 25 if (cached !== null) return cached; | 25 if (cached !== null) return cached; |
| 26 | 26 |
| 27 ClosureTranslator translator = | 27 ClosureTranslator translator = |
| 28 new ClosureTranslator(compiler, elements, closureMappingCache); | 28 new ClosureTranslator(compiler, elements, closureMappingCache); |
| 29 // The translator will store the computed closure-mappings inside the | 29 // The translator will store the computed closure-mappings inside the |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 } | 499 } |
| 500 | 500 |
| 501 visitTryStatement(TryStatement node) { | 501 visitTryStatement(TryStatement node) { |
| 502 // TODO(ngeoffray): implement finer grain state. | 502 // TODO(ngeoffray): implement finer grain state. |
| 503 bool oldInTryStatement = inTryStatement; | 503 bool oldInTryStatement = inTryStatement; |
| 504 inTryStatement = true; | 504 inTryStatement = true; |
| 505 node.visitChildren(this); | 505 node.visitChildren(this); |
| 506 inTryStatement = oldInTryStatement; | 506 inTryStatement = oldInTryStatement; |
| 507 } | 507 } |
| 508 } | 508 } |
| OLD | NEW |