| 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(johnniwinther): 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(MemberElement element) { | 202 bool _mustEmitMetadataForMember(MemberEntity member) { |
| 203 return _mirrorsData.mustRetainMetadata && | 203 if (!_mirrorsData.mustRetainMetadata) { |
| 204 _mirrorsData.isMemberReferencedFromMirrorSystem(element); | 204 return false; |
| 205 } |
| 206 // TODO(johnniwinther): Handle member entities. |
| 207 MemberElement element = member; |
| 208 return _mirrorsData.isMemberReferencedFromMirrorSystem(element); |
| 205 } | 209 } |
| 206 | 210 |
| 207 jsAst.Fun buildFieldMetadataFunction(FieldElement element) { | 211 jsAst.Fun buildFieldMetadataFunction(FieldEntity field) { |
| 208 if (!_mustEmitMetadataForMember(element)) return null; | 212 if (!_mustEmitMetadataForMember(field)) return null; |
| 213 // TODO(johnniwinther): Handle field entities. |
| 214 FieldElement element = field; |
| 209 return _buildMetadataFunction(element); | 215 return _buildMetadataFunction(element); |
| 210 } | 216 } |
| 211 | 217 |
| 212 /// The metadata function returns the metadata associated with | 218 /// The metadata function returns the metadata associated with |
| 213 /// [element] in generated code. The metadata needs to be wrapped | 219 /// [element] in generated code. The metadata needs to be wrapped |
| 214 /// 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 |
| 215 /// constructed yet. For example, a class is allowed to be | 221 /// constructed yet. For example, a class is allowed to be |
| 216 /// annotated with itself. The metadata function is used by | 222 /// annotated with itself. The metadata function is used by |
| 217 /// mirrors_patch to implement DeclarationMirror.metadata. | 223 /// mirrors_patch to implement DeclarationMirror.metadata. |
| 218 jsAst.Fun _buildMetadataFunction(Element element) { | 224 jsAst.Fun _buildMetadataFunction(Element element) { |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 if (token is _ForwardingMetadataEntry && !token.isBound) { | 471 if (token is _ForwardingMetadataEntry && !token.isBound) { |
| 466 _foundUnboundToken = true; | 472 _foundUnboundToken = true; |
| 467 } | 473 } |
| 468 } | 474 } |
| 469 | 475 |
| 470 bool findUnboundPlaceholders(jsAst.Node node) { | 476 bool findUnboundPlaceholders(jsAst.Node node) { |
| 471 node.accept(this); | 477 node.accept(this); |
| 472 return _foundUnboundToken; | 478 return _foundUnboundToken; |
| 473 } | 479 } |
| 474 } | 480 } |
| OLD | NEW |