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 'common.dart'; | 7 import 'common.dart'; |
8 import 'common/names.dart' show Identifiers; | 8 import 'common/names.dart' show Identifiers; |
9 import 'common/resolution.dart' show ParsingContext, Resolution; | 9 import 'common/resolution.dart' show ParsingContext, Resolution; |
10 import 'common/tasks.dart' show CompilerTask; | 10 import 'common/tasks.dart' show CompilerTask; |
11 import 'compiler.dart' show Compiler; | 11 import 'compiler.dart' show Compiler; |
12 import 'constants/expressions.dart'; | 12 import 'constants/expressions.dart'; |
13 import 'dart_types.dart'; | 13 import 'dart_types.dart'; |
14 import 'elements/elements.dart'; | 14 import 'elements/elements.dart'; |
15 import 'elements/modelx.dart' | 15 import 'elements/modelx.dart' |
16 show BaseFunctionElementX, ClassElementX, ElementX, LocalFunctionElementX; | 16 show BaseFunctionElementX, ClassElementX, ElementX, LocalFunctionElementX; |
17 import 'elements/visitor.dart' show ElementVisitor; | 17 import 'elements/visitor.dart' show ElementVisitor; |
18 import 'js_backend/js_backend.dart' show JavaScriptBackend; | 18 import 'js_backend/js_backend.dart' show JavaScriptBackend; |
19 import 'resolution/tree_elements.dart' show TreeElements; | 19 import 'resolution/tree_elements.dart' show TreeElements; |
20 import 'tokens/token.dart' show Token; | 20 import 'tokens/token.dart' show Token; |
21 import 'tree/tree.dart'; | 21 import 'tree/tree.dart'; |
22 import 'util/util.dart'; | 22 import 'util/util.dart'; |
23 import 'universe/universe.dart' show Universe; | 23 import 'universe/universe.dart' show Universe; |
24 | 24 |
25 class ClosureTask extends CompilerTask { | 25 class ClosureTask extends CompilerTask { |
26 Map<Node, ClosureClassMap> closureMappingCache; | 26 Map<Node, ClosureClassMap> closureMappingCache; |
| 27 Compiler compiler; |
27 ClosureTask(Compiler compiler) | 28 ClosureTask(Compiler compiler) |
28 : closureMappingCache = new Map<Node, ClosureClassMap>(), | 29 : closureMappingCache = new Map<Node, ClosureClassMap>(), |
29 super(compiler); | 30 compiler = compiler, |
| 31 super(compiler.measurer); |
30 | 32 |
31 String get name => "Closure Simplifier"; | 33 String get name => "Closure Simplifier"; |
32 | 34 |
| 35 DiagnosticReporter get reporter => compiler.reporter; |
| 36 |
33 ClosureClassMap computeClosureToClassMapping(ResolvedAst resolvedAst) { | 37 ClosureClassMap computeClosureToClassMapping(ResolvedAst resolvedAst) { |
34 return measure(() { | 38 return measure(() { |
35 Element element = resolvedAst.element; | 39 Element element = resolvedAst.element; |
36 if (resolvedAst.kind != ResolvedAstKind.PARSED) { | 40 if (resolvedAst.kind != ResolvedAstKind.PARSED) { |
37 return new ClosureClassMap(null, null, null, new ThisLocal(element)); | 41 return new ClosureClassMap(null, null, null, new ThisLocal(element)); |
38 } | 42 } |
39 return reporter.withCurrentElement(element.implementation, () { | 43 return reporter.withCurrentElement(element.implementation, () { |
40 Node node = resolvedAst.node; | 44 Node node = resolvedAst.node; |
41 TreeElements elements = resolvedAst.elements; | 45 TreeElements elements = resolvedAst.elements; |
42 | 46 |
(...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1185 /// | 1189 /// |
1186 /// Move the below classes to a JS model eventually. | 1190 /// Move the below classes to a JS model eventually. |
1187 /// | 1191 /// |
1188 abstract class JSEntity implements Entity { | 1192 abstract class JSEntity implements Entity { |
1189 Entity get declaredEntity; | 1193 Entity get declaredEntity; |
1190 } | 1194 } |
1191 | 1195 |
1192 abstract class PrivatelyNamedJSEntity implements JSEntity { | 1196 abstract class PrivatelyNamedJSEntity implements JSEntity { |
1193 Entity get rootOfScope; | 1197 Entity get rootOfScope; |
1194 } | 1198 } |
OLD | NEW |