| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 runtime_types; | 5 library runtime_types; |
| 6 | 6 |
| 7 import 'dart2jslib.dart'; | 7 import 'dart2jslib.dart'; |
| 8 import 'elements/elements.dart'; | 8 import 'elements/elements.dart'; |
| 9 import 'tree/tree.dart'; | 9 import 'tree/tree.dart'; |
| 10 import 'universe/universe.dart'; | 10 import 'universe/universe.dart'; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 buffer.add(stringify(variable, hasValue)); | 57 buffer.add(stringify(variable, hasValue)); |
| 58 isFirst = false; | 58 isFirst = false; |
| 59 currentVariable++; | 59 currentVariable++; |
| 60 }); | 60 }); |
| 61 return buffer.toString(); | 61 return buffer.toString(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 /** | 64 /** |
| 65 * Generate a string representation template for this element, using '#' to | 65 * Generate a string representation template for this element, using '#' to |
| 66 * denote the place for the type argument input. If there are more type | 66 * denote the place for the type argument input. If there are more type |
| 67 * variables than [numberOfInputs], 'Dynamic' is used as the value for these | 67 * variables than [numberOfInputs], 'dynamic' is used as the value for these |
| 68 * arguments. | 68 * arguments. |
| 69 */ | 69 */ |
| 70 String generateRuntimeTypeString(ClassElement element, int numberOfInputs) { | 70 String generateRuntimeTypeString(ClassElement element, int numberOfInputs) { |
| 71 String elementName = getName(element); | 71 String elementName = getName(element); |
| 72 if (element.typeVariables.isEmpty()) return "'$elementName'"; | 72 if (element.typeVariables.isEmpty()) return "$elementName"; |
| 73 String stringify(_, bool hasValue) => hasValue ? "' + # + '" : "Dynamic"; | 73 String stringify(_, bool hasValue) => hasValue ? "' + # + '" : "dynamic"; |
| 74 String arguments = stringifyTypeVariables(element.typeVariables, | 74 String arguments = stringifyTypeVariables(element.typeVariables, |
| 75 numberOfInputs, | 75 numberOfInputs, |
| 76 stringify); | 76 stringify); |
| 77 return "'$elementName<$arguments>'"; | 77 return "$elementName<$arguments>"; |
| 78 } | 78 } |
| 79 | 79 |
| 80 /** | 80 /** |
| 81 * Generate a string template for the runtime type fields that contain the | 81 * Generate a string template for the runtime type fields that contain the |
| 82 * type descriptions of the reified type arguments, using '#' to denote the | 82 * type descriptions of the reified type arguments, using '#' to denote the |
| 83 * place for the type argument value, or [:null:] if there are more than | 83 * place for the type argument value, or [:null:] if there are more than |
| 84 * [numberOfInputs] type variables. | 84 * [numberOfInputs] type variables. |
| 85 */ | 85 */ |
| 86 static String generateTypeVariableString(ClassElement element, | 86 static String generateTypeVariableString(ClassElement element, |
| 87 int numberOfInputs) { | 87 int numberOfInputs) { |
| 88 String stringify(TypeVariableType variable, bool hasValue) { | 88 String stringify(TypeVariableType variable, bool hasValue) { |
| 89 return "'${variable.name.slowToString()}': #"; | 89 return "'${variable.name.slowToString()}': #"; |
| 90 } | 90 } |
| 91 return stringifyTypeVariables(element.typeVariables, numberOfInputs, | 91 return stringifyTypeVariables(element.typeVariables, numberOfInputs, |
| 92 stringify); | 92 stringify); |
| 93 } | 93 } |
| 94 } | 94 } |
| OLD | NEW |