| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 part of dart2js.js_emitter.program_builder; | 5 part of dart2js.js_emitter.program_builder; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * [member] is a field (instance, static, or top level). | 8 * [member] is a field (instance, static, or top level). |
| 9 * | 9 * |
| 10 * [name] is the field name that the [Namer] has picked for this field's | 10 * [name] is the field name that the [Namer] has picked for this field's |
| 11 * storage, that is, the JavaScript property name. | 11 * storage, that is, the JavaScript property name. |
| 12 * | 12 * |
| 13 * [accessorName] is the name of the accessor. For instance fields this is | 13 * [accessorName] is the name of the accessor. For instance fields this is |
| 14 * mostly the same as [name] except when [member] is shadowing a field in its | 14 * mostly the same as [name] except when [member] is shadowing a field in its |
| 15 * superclass. For other fields, they are rarely the same. | 15 * superclass. For other fields, they are rarely the same. |
| 16 * | 16 * |
| 17 * [needsGetter] and [needsSetter] represent if a getter or a setter | 17 * [needsGetter] and [needsSetter] represent if a getter or a setter |
| 18 * respectively is needed. There are many factors in this, for example, if the | 18 * respectively is needed. There are many factors in this, for example, if the |
| 19 * accessor can be inlined. | 19 * accessor can be inlined. |
| 20 * | 20 * |
| 21 * [needsCheckedSetter] indicates that a checked getter is needed, and in this | 21 * [needsCheckedSetter] indicates that a checked getter is needed, and in this |
| 22 * case, [needsSetter] is always false. [needsCheckedSetter] is only true when | 22 * case, [needsSetter] is always false. [needsCheckedSetter] is only true when |
| 23 * type assertions are enabled (checked mode). | 23 * type assertions are enabled (checked mode). |
| 24 */ | 24 */ |
| 25 typedef void AcceptField( | 25 typedef AcceptField = ( |
| 26 VariableElement member, | 26 VariableElement member, |
| 27 js.Name name, | 27 js.Name name, |
| 28 js.Name accessorName, | 28 js.Name accessorName, |
| 29 bool needsGetter, | 29 bool needsGetter, |
| 30 bool needsSetter, | 30 bool needsSetter, |
| 31 bool needsCheckedSetter); | 31 bool needsCheckedSetter) -> void; |
| 32 | 32 |
| 33 class FieldVisitor { | 33 class FieldVisitor { |
| 34 final Compiler compiler; | 34 final Compiler compiler; |
| 35 final Namer namer; | 35 final Namer namer; |
| 36 | 36 |
| 37 JavaScriptBackend get backend => compiler.backend; | 37 JavaScriptBackend get backend => compiler.backend; |
| 38 | 38 |
| 39 FieldVisitor(this.compiler, this.namer); | 39 FieldVisitor(this.compiler, this.namer); |
| 40 | 40 |
| 41 /** | 41 /** |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 field is ClosureFieldElement; | 161 field is ClosureFieldElement; |
| 162 } | 162 } |
| 163 | 163 |
| 164 bool canAvoidGeneratedCheckedSetter(VariableElement member) { | 164 bool canAvoidGeneratedCheckedSetter(VariableElement member) { |
| 165 // We never generate accessors for top-level/static fields. | 165 // We never generate accessors for top-level/static fields. |
| 166 if (!member.isInstanceMember) return true; | 166 if (!member.isInstanceMember) return true; |
| 167 DartType type = member.type; | 167 DartType type = member.type; |
| 168 return type.treatAsDynamic || type.isObject; | 168 return type.treatAsDynamic || type.isObject; |
| 169 } | 169 } |
| 170 } | 170 } |
| OLD | NEW |