OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library dart2js.cps_ir.use_field_initializers; | 4 library dart2js.cps_ir.use_field_initializers; |
5 | 5 |
6 import 'cps_ir_nodes.dart'; | 6 import 'cps_ir_nodes.dart'; |
7 import 'optimizers.dart'; | 7 import 'optimizers.dart'; |
8 import '../elements/elements.dart'; | 8 import '../elements/elements.dart'; |
9 import '../js_backend/js_backend.dart'; | 9 import '../js_backend/js_backend.dart'; |
10 | 10 |
11 /// Eliminates [SetField] instructions when the value can instead be passed into | 11 /// Eliminates [SetField] instructions when the value can instead be passed into |
12 /// the field initializer of a [CreateInstance] instruction. | 12 /// the field initializer of a [CreateInstance] instruction. |
13 /// | 13 /// |
14 /// This compensates for a somewhat common pattern where fields are initialized | 14 /// This compensates for a somewhat common pattern where fields are initialized |
15 /// in the constructor body instead of using intializers. For example: | 15 /// in the constructor body instead of using initializers. For example: |
16 /// | 16 /// |
17 /// class Foo { | 17 /// class Foo { |
18 /// var x, y; | 18 /// var x, y; |
19 /// Foo(x, y) { | 19 /// Foo(x, y) { |
20 /// this.x = x; | 20 /// this.x = x; |
21 /// this.y = y; | 21 /// this.y = y; |
22 /// } | 22 /// } |
23 /// } | 23 /// } |
24 /// | 24 /// |
25 /// ==> (IR for Foo constructor) | 25 /// ==> (IR for Foo constructor) |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 } | 203 } |
204 | 204 |
205 class EscapeVisitor extends DeepRecursiveVisitor { | 205 class EscapeVisitor extends DeepRecursiveVisitor { |
206 final UseFieldInitializers main; | 206 final UseFieldInitializers main; |
207 EscapeVisitor(this.main); | 207 EscapeVisitor(this.main); |
208 | 208 |
209 processReference(Reference ref) { | 209 processReference(Reference ref) { |
210 main.escape(ref); | 210 main.escape(ref); |
211 } | 211 } |
212 } | 212 } |
OLD | NEW |