| 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 import 'common/names.dart' show Identifiers; | 5 import 'common/names.dart' show Identifiers; |
| 6 import 'common/resolution.dart' show ParsingContext, Resolution; | 6 import 'common/resolution.dart' show ParsingContext, Resolution; |
| 7 import 'common/tasks.dart' show CompilerTask; | 7 import 'common/tasks.dart' show CompilerTask, Measurer; |
| 8 import 'common.dart'; | 8 import 'common.dart'; |
| 9 import 'compiler.dart' show Compiler; | 9 import 'compiler.dart' show Compiler; |
| 10 import 'constants/expressions.dart'; | 10 import 'constants/expressions.dart'; |
| 11 import 'elements/elements.dart'; | 11 import 'elements/elements.dart'; |
| 12 import 'elements/entities.dart'; | 12 import 'elements/entities.dart'; |
| 13 import 'elements/entity_utils.dart' as utils; | 13 import 'elements/entity_utils.dart' as utils; |
| 14 import 'elements/modelx.dart' | 14 import 'elements/modelx.dart' |
| 15 show BaseFunctionElementX, ClassElementX, ElementX; | 15 show BaseFunctionElementX, ClassElementX, ElementX; |
| 16 import 'elements/resolution_types.dart'; | 16 import 'elements/resolution_types.dart'; |
| 17 import 'elements/types.dart'; | 17 import 'elements/types.dart'; |
| 18 import 'elements/visitor.dart' show ElementVisitor; | 18 import 'elements/visitor.dart' show ElementVisitor; |
| 19 import 'js_backend/js_backend.dart' show JavaScriptBackend; | 19 import 'js_backend/js_backend.dart' show JavaScriptBackend; |
| 20 import 'resolution/tree_elements.dart' show TreeElements; | 20 import 'resolution/tree_elements.dart' show TreeElements; |
| 21 import 'package:front_end/src/fasta/scanner.dart' show Token; | 21 import 'package:front_end/src/fasta/scanner.dart' show Token; |
| 22 import 'tree/tree.dart'; | 22 import 'tree/tree.dart'; |
| 23 import 'util/util.dart'; | 23 import 'util/util.dart'; |
| 24 import 'world.dart' show ClosedWorldRefiner; | 24 import 'world.dart' show ClosedWorldRefiner; |
| 25 | 25 |
| 26 abstract class ClosureConversionTask<T> extends CompilerTask |
| 27 implements ClosureDataLookup<T> { |
| 28 ClosureConversionTask(Measurer measurer) : super(measurer); |
| 29 |
| 30 //void analyzeClosures(); |
| 31 void convertClosures(Iterable<MemberEntity> processedEntities, |
| 32 ClosedWorldRefiner closedWorldRefiner); |
| 33 } |
| 34 |
| 26 /// Class that provides information for how closures are rewritten/represented | 35 /// Class that provides information for how closures are rewritten/represented |
| 27 /// to preserve Dart semantics when compiled to JavaScript. Given a particular | 36 /// to preserve Dart semantics when compiled to JavaScript. Given a particular |
| 28 /// node to look up, it returns a information about the internal representation | 37 /// node to look up, it returns a information about the internal representation |
| 29 /// of how closure conversion is implemented. T is an ir.Node or Node. | 38 /// of how closure conversion is implemented. T is an ir.Node or Node. |
| 30 abstract class ClosureDataLookup<T> { | 39 abstract class ClosureDataLookup<T> { |
| 31 /// Look up information about the variables that have been mutated and are | 40 /// Look up information about the variables that have been mutated and are |
| 32 /// used inside the scope of [node]. | 41 /// used inside the scope of [node]. |
| 33 // TODO(johnniwinther): Split this up into two functions, one for members and | 42 // TODO(johnniwinther): Split this up into two functions, one for members and |
| 34 // one for local functions. | 43 // one for local functions. |
| 35 ClosureRepresentationInfo getClosureRepresentationInfo(Entity member); | 44 ClosureRepresentationInfo getClosureRepresentationInfo(Entity member); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 /// Return true if [variable] has been captured and mutated (all other | 200 /// Return true if [variable] has been captured and mutated (all other |
| 192 /// variables do not require boxing). | 201 /// variables do not require boxing). |
| 193 bool isVariableBoxed(Local variable) => false; | 202 bool isVariableBoxed(Local variable) => false; |
| 194 | 203 |
| 195 // TODO(efortuna): Remove this method. The old system was using | 204 // TODO(efortuna): Remove this method. The old system was using |
| 196 // ClosureClassMaps for situations other than closure class maps, and that's | 205 // ClosureClassMaps for situations other than closure class maps, and that's |
| 197 // just confusing. | 206 // just confusing. |
| 198 bool get isClosure => false; | 207 bool get isClosure => false; |
| 199 } | 208 } |
| 200 | 209 |
| 201 class ClosureTask extends CompilerTask implements ClosureDataLookup<Node> { | 210 class ClosureTask extends ClosureConversionTask<Node> { |
| 202 Map<Node, ClosureScope> _closureInfoMap = <Node, ClosureScope>{}; | 211 Map<Node, ClosureScope> _closureInfoMap = <Node, ClosureScope>{}; |
| 203 Map<Element, ClosureClassMap> _closureMappingCache = | 212 Map<Element, ClosureClassMap> _closureMappingCache = |
| 204 <Element, ClosureClassMap>{}; | 213 <Element, ClosureClassMap>{}; |
| 205 Compiler compiler; | 214 Compiler compiler; |
| 206 ClosureTask(Compiler compiler) | 215 ClosureTask(Compiler compiler) |
| 207 : compiler = compiler, | 216 : compiler = compiler, |
| 208 super(compiler.measurer); | 217 super(compiler.measurer); |
| 209 | 218 |
| 210 String get name => "Closure Simplifier"; | 219 String get name => "Closure Simplifier"; |
| 211 | 220 |
| 212 DiagnosticReporter get reporter => compiler.reporter; | 221 DiagnosticReporter get reporter => compiler.reporter; |
| 213 | 222 |
| 223 void convertClosures(Iterable<MemberEntity> processedEntities, |
| 224 ClosedWorldRefiner closedWorldRefiner) { |
| 225 createClosureClasses(closedWorldRefiner); |
| 226 } |
| 227 |
| 214 ClosureAnalysisInfo getClosureAnalysisInfo(Node node) { | 228 ClosureAnalysisInfo getClosureAnalysisInfo(Node node) { |
| 215 var value = _closureInfoMap[node]; | 229 var value = _closureInfoMap[node]; |
| 216 return value == null ? const ClosureAnalysisInfo() : value; | 230 return value == null ? const ClosureAnalysisInfo() : value; |
| 217 } | 231 } |
| 218 | 232 |
| 219 ClosureRepresentationInfo getClosureRepresentationInfo(Element member) { | 233 ClosureRepresentationInfo getClosureRepresentationInfo(Element member) { |
| 220 return getClosureToClassMapping(member); | 234 return getClosureToClassMapping(member); |
| 221 } | 235 } |
| 222 | 236 |
| 223 LoopClosureRepresentationInfo getClosureRepresentationInfoForLoop( | 237 LoopClosureRepresentationInfo getClosureRepresentationInfoForLoop( |
| (...skipping 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1448 /// | 1462 /// |
| 1449 /// Move the below classes to a JS model eventually. | 1463 /// Move the below classes to a JS model eventually. |
| 1450 /// | 1464 /// |
| 1451 abstract class JSEntity implements MemberEntity { | 1465 abstract class JSEntity implements MemberEntity { |
| 1452 Local get declaredEntity; | 1466 Local get declaredEntity; |
| 1453 } | 1467 } |
| 1454 | 1468 |
| 1455 abstract class PrivatelyNamedJSEntity implements JSEntity { | 1469 abstract class PrivatelyNamedJSEntity implements JSEntity { |
| 1456 Entity get rootOfScope; | 1470 Entity get rootOfScope; |
| 1457 } | 1471 } |
| OLD | NEW |