| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library dart2js.js_emitter.metadata_collector; | 5 library dart2js.js_emitter.metadata_collector; |
| 6 | 6 |
| 7 import 'package:js_ast/src/precedence.dart' as js_precedence; | 7 import 'package:js_ast/src/precedence.dart' as js_precedence; |
| 8 | 8 |
| 9 import '../common.dart'; | 9 import '../common.dart'; |
| 10 import '../constants/values.dart'; | 10 import '../constants/values.dart'; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 return null; | 187 return null; |
| 188 } | 188 } |
| 189 return _buildMetadataFunction(element as LibraryElement); | 189 return _buildMetadataFunction(element as LibraryElement); |
| 190 } | 190 } |
| 191 | 191 |
| 192 jsAst.Fun buildClassMetadataFunction(ClassEntity cls) { | 192 jsAst.Fun buildClassMetadataFunction(ClassEntity cls) { |
| 193 if (!_mirrorsData.mustRetainMetadata || | 193 if (!_mirrorsData.mustRetainMetadata || |
| 194 !_mirrorsData.isClassReferencedFromMirrorSystem(cls)) { | 194 !_mirrorsData.isClassReferencedFromMirrorSystem(cls)) { |
| 195 return null; | 195 return null; |
| 196 } | 196 } |
| 197 // TODO(johnniwinther): Handle class entities. | 197 // TODO(redemption): Handle class entities. |
| 198 ClassElement element = cls; | 198 ClassElement element = cls; |
| 199 return _buildMetadataFunction(element); | 199 return _buildMetadataFunction(element); |
| 200 } | 200 } |
| 201 | 201 |
| 202 bool _mustEmitMetadataForMember(MemberEntity member) { | 202 bool _mustEmitMetadataForMember(MemberEntity member) { |
| 203 if (!_mirrorsData.mustRetainMetadata) { | 203 if (!_mirrorsData.mustRetainMetadata) { |
| 204 return false; | 204 return false; |
| 205 } | 205 } |
| 206 // TODO(johnniwinther): Handle member entities. | 206 // TODO(redemption): Handle member entities. |
| 207 MemberElement element = member; | 207 MemberElement element = member; |
| 208 return _mirrorsData.isMemberReferencedFromMirrorSystem(element); | 208 return _mirrorsData.isMemberReferencedFromMirrorSystem(element); |
| 209 } | 209 } |
| 210 | 210 |
| 211 jsAst.Fun buildFieldMetadataFunction(FieldEntity field) { | 211 jsAst.Fun buildFieldMetadataFunction(FieldEntity field) { |
| 212 if (!_mustEmitMetadataForMember(field)) return null; | 212 if (!_mustEmitMetadataForMember(field)) return null; |
| 213 // TODO(johnniwinther): Handle field entities. | 213 // TODO(redemption): Handle field entities. |
| 214 FieldElement element = field; | 214 FieldElement element = field; |
| 215 return _buildMetadataFunction(element); | 215 return _buildMetadataFunction(element); |
| 216 } | 216 } |
| 217 | 217 |
| 218 /// The metadata function returns the metadata associated with | 218 /// The metadata function returns the metadata associated with |
| 219 /// [element] in generated code. The metadata needs to be wrapped | 219 /// [element] in generated code. The metadata needs to be wrapped |
| 220 /// in a function as it refers to constants that may not have been | 220 /// in a function as it refers to constants that may not have been |
| 221 /// constructed yet. For example, a class is allowed to be | 221 /// constructed yet. For example, a class is allowed to be |
| 222 /// annotated with itself. The metadata function is used by | 222 /// annotated with itself. The metadata function is used by |
| 223 /// mirrors_patch to implement DeclarationMirror.metadata. | 223 /// mirrors_patch to implement DeclarationMirror.metadata. |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 if (token is _ForwardingMetadataEntry && !token.isBound) { | 471 if (token is _ForwardingMetadataEntry && !token.isBound) { |
| 472 _foundUnboundToken = true; | 472 _foundUnboundToken = true; |
| 473 } | 473 } |
| 474 } | 474 } |
| 475 | 475 |
| 476 bool findUnboundPlaceholders(jsAst.Node node) { | 476 bool findUnboundPlaceholders(jsAst.Node node) { |
| 477 node.accept(this); | 477 node.accept(this); |
| 478 return _foundUnboundToken; | 478 return _foundUnboundToken; |
| 479 } | 479 } |
| 480 } | 480 } |
| OLD | NEW |