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, Measurer; | 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'; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 /// This returns the same information as ScopeInfo, but can be called in | 48 /// This returns the same information as ScopeInfo, but can be called in |
49 /// situations when you are sure you are dealing with a closure specifically. | 49 /// situations when you are sure you are dealing with a closure specifically. |
50 ClosureRepresentationInfo getClosureRepresentationInfo( | 50 ClosureRepresentationInfo getClosureRepresentationInfo( |
51 covariant Entity member); | 51 covariant Entity member); |
52 | 52 |
53 /// Look up information about a loop, in case any variables it declares need | 53 /// Look up information about a loop, in case any variables it declares need |
54 /// to be boxed/snapshotted. | 54 /// to be boxed/snapshotted. |
55 LoopClosureScope getLoopClosureScope(T loopNode); | 55 LoopClosureScope getLoopClosureScope(T loopNode); |
56 | 56 |
57 /// Accessor to the information about closures that the SSA builder will use. | 57 /// Accessor to the information about closures that the SSA builder will use. |
58 ClosureScope getClosureScope(T node); | 58 ClosureScope getClosureScope(MemberEntity entity); |
59 } | 59 } |
60 | 60 |
61 /// Class that represents one level of scoping information, whether this scope | 61 /// Class that represents one level of scoping information, whether this scope |
62 /// is a closure or not. This is specifically used to store information | 62 /// is a closure or not. This is specifically used to store information |
63 /// about the usage of variables in try or sync blocks, because they need to be | 63 /// about the usage of variables in try or sync blocks, because they need to be |
64 /// boxed. | 64 /// boxed. |
65 /// | 65 /// |
66 /// Variables that are used in a try must be treated as boxed because the | 66 /// Variables that are used in a try must be treated as boxed because the |
67 /// control flow can be non-linear. Also parameters to a `sync*` generator must | 67 /// control flow can be non-linear. Also parameters to a `sync*` generator must |
68 /// be boxed, because of the way we rewrite sync* functions. See also comments | 68 /// be boxed, because of the way we rewrite sync* functions. See also comments |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 | 260 |
261 String get name => "Closure Simplifier"; | 261 String get name => "Closure Simplifier"; |
262 | 262 |
263 DiagnosticReporter get reporter => compiler.reporter; | 263 DiagnosticReporter get reporter => compiler.reporter; |
264 | 264 |
265 void convertClosures(Iterable<MemberEntity> processedEntities, | 265 void convertClosures(Iterable<MemberEntity> processedEntities, |
266 ClosedWorldRefiner closedWorldRefiner) { | 266 ClosedWorldRefiner closedWorldRefiner) { |
267 createClosureClasses(closedWorldRefiner); | 267 createClosureClasses(closedWorldRefiner); |
268 } | 268 } |
269 | 269 |
270 ClosureScope getClosureScope(Node node) { | 270 ClosureScope _getClosureScope(Node node) { |
271 var value = _closureInfoMap[node]; | 271 var value = _closureInfoMap[node]; |
272 return value == null ? const ClosureScope() : value; | 272 return value == null ? const ClosureScope() : value; |
273 } | 273 } |
274 | 274 |
| 275 ClosureScope getClosureScope(covariant MemberElement member) { |
| 276 ResolvedAst resolvedAst = member.resolvedAst; |
| 277 if (resolvedAst.kind != ResolvedAstKind.PARSED) return const ClosureScope(); |
| 278 return _getClosureScope(resolvedAst.node); |
| 279 } |
| 280 |
275 ScopeInfo getScopeInfo(Element member) { | 281 ScopeInfo getScopeInfo(Element member) { |
276 return getClosureToClassMapping(member); | 282 return getClosureToClassMapping(member); |
277 } | 283 } |
278 | 284 |
279 ClosureRepresentationInfo getClosureRepresentationInfo(Element member) { | 285 ClosureRepresentationInfo getClosureRepresentationInfo(Element member) { |
280 return getClosureToClassMapping(member); | 286 return getClosureToClassMapping(member); |
281 } | 287 } |
282 | 288 |
283 LoopClosureScope getLoopClosureScope(Node loopNode) { | 289 LoopClosureScope getLoopClosureScope(Node loopNode) { |
284 var value = _closureInfoMap[loopNode]; | 290 var value = _closureInfoMap[loopNode]; |
(...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1532 /// | 1538 /// |
1533 /// Move the below classes to a JS model eventually. | 1539 /// Move the below classes to a JS model eventually. |
1534 /// | 1540 /// |
1535 abstract class JSEntity implements MemberEntity { | 1541 abstract class JSEntity implements MemberEntity { |
1536 Local get declaredEntity; | 1542 Local get declaredEntity; |
1537 } | 1543 } |
1538 | 1544 |
1539 abstract class PrivatelyNamedJSEntity implements JSEntity { | 1545 abstract class PrivatelyNamedJSEntity implements JSEntity { |
1540 Entity get rootOfScope; | 1546 Entity get rootOfScope; |
1541 } | 1547 } |
OLD | NEW |