Chromium Code Reviews| 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; |
| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 /// int y; | 112 /// int y; |
| 113 /// FooClosure(this.y); | 113 /// FooClosure(this.y); |
| 114 /// call(x) => this.y + x; | 114 /// call(x) => this.y + x; |
| 115 /// } | 115 /// } |
| 116 /// | 116 /// |
| 117 /// and then to execute this closure, for example: | 117 /// and then to execute this closure, for example: |
| 118 /// | 118 /// |
| 119 /// var foo = new FooClosure(1); | 119 /// var foo = new FooClosure(1); |
| 120 /// foo.call(2); | 120 /// foo.call(2); |
| 121 /// | 121 /// |
| 122 /// if y is modified elsewhere within its scope, accesses to y anywhere in the | 122 /// if y is modified elsewhere within its scope, accesses to y anywhere in the |
|
Siggi Cherem (dart-lang)
2017/06/15 00:12:24
just noticed, maybe quote `y` here as well.
Emily Fortuna
2017/06/15 00:13:35
thx!
| |
| 123 /// code will be controlled via a box object. | 123 /// code will be controlled via a box object. |
| 124 /// | |
| 125 /// Because in these examples `y` was declared in some other, outer scope, but | |
| 126 /// used in the inner scope of this closure, we say `y` is a "captured" | |
| 127 /// variable. | |
| 124 /// TODO(efortuna): Make interface simpler in subsequent refactorings. | 128 /// TODO(efortuna): Make interface simpler in subsequent refactorings. |
| 125 class ClosureRepresentationInfo { | 129 class ClosureRepresentationInfo { |
| 126 const ClosureRepresentationInfo(); | 130 const ClosureRepresentationInfo(); |
| 127 | 131 |
| 128 /// The original local function before any translation. | 132 /// The original local function before any translation. |
| 129 /// | 133 /// |
| 130 /// Will be null for methods. | 134 /// Will be null for methods. |
| 131 Local get closureEntity => null; | 135 Local get closureEntity => null; |
| 132 | 136 |
| 137 /// The entity for the class used to represent the rewritten closure in the | |
| 138 /// emitted JavaScript. | |
| 139 /// | |
| 133 /// Closures are rewritten in the form of classes that have fields to control | 140 /// Closures are rewritten in the form of classes that have fields to control |
| 134 /// the redirection and editing of variables that are "captured" inside a | 141 /// the redirection and editing of captured variables. |
| 135 /// scope (declared in an outer scope but used in an inside scope). So this | |
| 136 /// returns the class entity that represents this particular rewritten | |
| 137 /// closure. | |
| 138 ClassEntity get closureClassEntity => null; | 142 ClassEntity get closureClassEntity => null; |
| 139 | 143 |
| 140 /// The function that implements the [local] function as a `call` method on | 144 /// The function that implements the [local] function as a `call` method on |
| 141 /// the closure class. | 145 /// the closure class. |
| 142 FunctionEntity get callMethod => null; | 146 FunctionEntity get callMethod => null; |
| 143 | 147 |
| 144 /// As shown in the example in the comments at the top of this class, we | 148 /// As shown in the example in the comments at the top of this class, we |
| 145 /// create fields in the closure class for each captured variable. This is an | 149 /// create fields in the closure class for each captured variable. This is an |
| 146 /// accessor to that set of fields. | 150 /// accessor to that set of fields. |
| 147 List<Local> get createdFieldEntities => const <Local>[]; | 151 List<Local> get createdFieldEntities => const <Local>[]; |
| (...skipping 1296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1444 /// | 1448 /// |
| 1445 /// Move the below classes to a JS model eventually. | 1449 /// Move the below classes to a JS model eventually. |
| 1446 /// | 1450 /// |
| 1447 abstract class JSEntity implements MemberEntity { | 1451 abstract class JSEntity implements MemberEntity { |
| 1448 Local get declaredEntity; | 1452 Local get declaredEntity; |
| 1449 } | 1453 } |
| 1450 | 1454 |
| 1451 abstract class PrivatelyNamedJSEntity implements JSEntity { | 1455 abstract class PrivatelyNamedJSEntity implements JSEntity { |
| 1452 Entity get rootOfScope; | 1456 Entity get rootOfScope; |
| 1453 } | 1457 } |
| OLD | NEW |