| 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 part of dart2js.js_emitter; | 5 part of dart2js.js_emitter; |
| 6 | 6 |
| 7 class MetadataCollector { | 7 class MetadataCollector { |
| 8 final Compiler _compiler; | 8 final Compiler _compiler; |
| 9 final Emitter _emitter; | 9 final Emitter _emitter; |
| 10 | 10 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 _backend.constants.getConstantForMetadata(annotation); | 84 _backend.constants.getConstantForMetadata(annotation); |
| 85 if (constant == null) { | 85 if (constant == null) { |
| 86 _compiler.internalError(annotation, 'Annotation value is null.'); | 86 _compiler.internalError(annotation, 'Annotation value is null.'); |
| 87 return -1; | 87 return -1; |
| 88 } | 88 } |
| 89 return addGlobalMetadata( | 89 return addGlobalMetadata( |
| 90 jsAst.prettyPrint( | 90 jsAst.prettyPrint( |
| 91 _emitter.constantReference(constant.value), _compiler).getText()); | 91 _emitter.constantReference(constant.value), _compiler).getText()); |
| 92 } | 92 } |
| 93 | 93 |
| 94 int reifyType(DartType type) { | 94 int reifyType(DartType type, {bool ignoreTypeVariables: false}) { |
| 95 return reifyTypeForOutputUnit(type, | 95 return reifyTypeForOutputUnit(type, |
| 96 _compiler.deferredLoadTask.mainOutputUnit); | 96 _compiler.deferredLoadTask.mainOutputUnit, |
| 97 ignoreTypeVariables: ignoreTypeVariables); |
| 97 } | 98 } |
| 98 | 99 |
| 99 int reifyTypeForOutputUnit(DartType type, OutputUnit outputUnit) { | 100 int reifyTypeForOutputUnit(DartType type, OutputUnit outputUnit, |
| 101 {bool ignoreTypeVariables: false}) { |
| 100 jsAst.Expression representation = | 102 jsAst.Expression representation = |
| 101 _backend.rti.getTypeRepresentation( | 103 _backend.rti.getTypeRepresentation( |
| 102 type, | 104 type, |
| 103 (variable) { | 105 (variable) { |
| 106 if (ignoreTypeVariables) return new jsAst.LiteralNull(); |
| 104 return js.number( | 107 return js.number( |
| 105 _typeVariableHandler.reifyTypeVariable( | 108 _typeVariableHandler.reifyTypeVariable( |
| 106 variable.element)); | 109 variable.element)); |
| 107 }, | 110 }, |
| 108 (TypedefType typedef) { | 111 (TypedefType typedef) { |
| 109 return _backend.isAccessibleByReflection(typedef.element); | 112 return _backend.isAccessibleByReflection(typedef.element); |
| 110 }); | 113 }); |
| 111 | 114 |
| 112 return addTypeInOutputUnit( | 115 return addTypeInOutputUnit( |
| 113 jsAst.prettyPrint(representation, _compiler).getText(), outputUnit); | 116 jsAst.prettyPrint(representation, _compiler).getText(), outputUnit); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 // TODO(ahe): Why is metadata sometimes null? | 149 // TODO(ahe): Why is metadata sometimes null? |
| 147 if (link != null) { | 150 if (link != null) { |
| 148 for (; !link.isEmpty; link = link.tail) { | 151 for (; !link.isEmpty; link = link.tail) { |
| 149 metadata.add(reifyMetadata(link.head)); | 152 metadata.add(reifyMetadata(link.head)); |
| 150 } | 153 } |
| 151 } | 154 } |
| 152 return metadata; | 155 return metadata; |
| 153 }); | 156 }); |
| 154 } | 157 } |
| 155 } | 158 } |
| OLD | NEW |