| 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 MetadataEmitter extends CodeEmitterHelper { | 7 class MetadataEmitter extends CodeEmitterHelper { |
| 8 /// A list of JS expressions that represent metadata, parameter names and | 8 /// A list of JS expressions that represent metadata, parameter names and |
| 9 /// type, and return types. | 9 /// type, and return types. |
| 10 final List<String> globalMetadata = []; | 10 final List<String> globalMetadata = []; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 if (value == null) { | 62 if (value == null) { |
| 63 compiler.internalError(annotation, 'Annotation value is null.'); | 63 compiler.internalError(annotation, 'Annotation value is null.'); |
| 64 return -1; | 64 return -1; |
| 65 } | 65 } |
| 66 return addGlobalMetadata( | 66 return addGlobalMetadata( |
| 67 jsAst.prettyPrint(task.constantReference(value), compiler).getText()); | 67 jsAst.prettyPrint(task.constantReference(value), compiler).getText()); |
| 68 } | 68 } |
| 69 | 69 |
| 70 int reifyType(DartType type) { | 70 int reifyType(DartType type) { |
| 71 jsAst.Expression representation = | 71 jsAst.Expression representation = |
| 72 backend.rti.getTypeRepresentation(type, (variable) { | 72 backend.rti.getTypeRepresentation( |
| 73 return js.number( | 73 type, |
| 74 task.typeVariableHandler.reifyTypeVariable(variable.element)); | 74 (variable) { |
| 75 }); | 75 return js.number( |
| 76 task.typeVariableHandler.reifyTypeVariable(variable.element)); |
| 77 }, |
| 78 (TypedefType typedef) { |
| 79 return backend.isAccessibleByReflection(typedef.element); |
| 80 }); |
| 76 | 81 |
| 77 return addGlobalMetadata( | 82 return addGlobalMetadata( |
| 78 jsAst.prettyPrint(representation, compiler).getText()); | 83 jsAst.prettyPrint(representation, compiler).getText()); |
| 79 } | 84 } |
| 80 | 85 |
| 81 int reifyName(String name) { | 86 int reifyName(String name) { |
| 82 return addGlobalMetadata('"$name"'); | 87 return addGlobalMetadata('"$name"'); |
| 83 } | 88 } |
| 84 | 89 |
| 85 int addGlobalMetadata(String string) { | 90 int addGlobalMetadata(String string) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 112 // TODO(ahe): Why is metadata sometimes null? | 117 // TODO(ahe): Why is metadata sometimes null? |
| 113 if (link != null) { | 118 if (link != null) { |
| 114 for (; !link.isEmpty; link = link.tail) { | 119 for (; !link.isEmpty; link = link.tail) { |
| 115 metadata.add(reifyMetadata(link.head)); | 120 metadata.add(reifyMetadata(link.head)); |
| 116 } | 121 } |
| 117 } | 122 } |
| 118 return metadata; | 123 return metadata; |
| 119 }); | 124 }); |
| 120 } | 125 } |
| 121 } | 126 } |
| OLD | NEW |