| 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 28 matching lines...) Expand all Loading... |
| 39 if (metadata.isEmpty) return null; | 39 if (metadata.isEmpty) return null; |
| 40 return js.fun( | 40 return js.fun( |
| 41 [], [js.return_(new jsAst.ArrayInitializer.from(metadata))]); | 41 [], [js.return_(new jsAst.ArrayInitializer.from(metadata))]); |
| 42 }); | 42 }); |
| 43 } | 43 } |
| 44 | 44 |
| 45 List<int> reifyDefaultArguments(FunctionElement function) { | 45 List<int> reifyDefaultArguments(FunctionElement function) { |
| 46 FunctionSignature signature = function.computeSignature(compiler); | 46 FunctionSignature signature = function.computeSignature(compiler); |
| 47 if (signature.optionalParameterCount == 0) return const []; | 47 if (signature.optionalParameterCount == 0) return const []; |
| 48 List<int> defaultValues = <int>[]; | 48 List<int> defaultValues = <int>[]; |
| 49 for (Element element in signature.optionalParameters) { | 49 for (Element element in signature.orderedOptionalParameters) { |
| 50 Constant value = | 50 Constant value = |
| 51 compiler.constantHandler.initialVariableValues[element]; | 51 compiler.constantHandler.initialVariableValues[element]; |
| 52 String stringRepresentation = (value == null) | 52 String stringRepresentation = (value == null) |
| 53 ? "null" | 53 ? "null" |
| 54 : jsAst.prettyPrint(task.constantReference(value), compiler) | 54 : jsAst.prettyPrint(task.constantReference(value), compiler) |
| 55 .getText(); | 55 .getText(); |
| 56 defaultValues.add(addGlobalMetadata(stringRepresentation)); | 56 defaultValues.add(addGlobalMetadata(stringRepresentation)); |
| 57 } | 57 } |
| 58 return defaultValues; | 58 return defaultValues; |
| 59 } | 59 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 // TODO(ahe): Why is metadata sometimes null? | 126 // TODO(ahe): Why is metadata sometimes null? |
| 127 if (link != null) { | 127 if (link != null) { |
| 128 for (; !link.isEmpty; link = link.tail) { | 128 for (; !link.isEmpty; link = link.tail) { |
| 129 metadata.add(reifyMetadata(link.head)); | 129 metadata.add(reifyMetadata(link.head)); |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 return metadata; | 132 return metadata; |
| 133 }); | 133 }); |
| 134 } | 134 } |
| 135 } | 135 } |
| OLD | NEW |