Chromium Code Reviews| Index: lib/compiler/implementation/runtime_types.dart |
| diff --git a/lib/compiler/implementation/runtime_types.dart b/lib/compiler/implementation/runtime_types.dart |
| index cd7f49ae66a5a7f62f6783d2b074de79ccb7f1a7..0ef0f57e9aba2230dfb08687eec9efb6d9276a26 100644 |
| --- a/lib/compiler/implementation/runtime_types.dart |
| +++ b/lib/compiler/implementation/runtime_types.dart |
| @@ -11,6 +11,24 @@ |
| #import('util/util.dart'); |
| class RuntimeTypeInformation { |
| + /** |
| + * Names used for elements in runtime type information. This map is kept to |
| + * detect elements with the same name and add a library prefix to them. |
|
kasperl
2012/10/11 13:18:51
You're not really adding a library prefix to them.
karlklose
2012/10/11 13:29:42
Done.
|
| + */ |
| + final Map<String, Element> usedNames = new Map<String, Element>(); |
| + |
| + /** Get a unique name for the element. */ |
| + String getName(Element element) { |
| + String guess = element.name.slowToString(); |
| + String name = guess; |
| + int id = 0; |
| + while (usedNames.containsKey(name) && usedNames[name] != element) { |
| + name = '$guess@$id'; |
|
kasperl
2012/10/11 13:18:51
You need to increase id in here.
karlklose
2012/10/11 13:29:42
Done.
|
| + } |
| + usedNames[name] = element; |
| + return name; |
| + } |
| + |
| bool hasTypeArguments(DartType type) { |
| if (type is InterfaceType) { |
| InterfaceType interfaceType = type; |
| @@ -48,9 +66,8 @@ class RuntimeTypeInformation { |
| * variables than [numberOfInputs], 'Dynamic' is used as the value for these |
| * arguments. |
| */ |
| - static String generateRuntimeTypeString(ClassElement element, |
| - int numberOfInputs) { |
| - String elementName = element.name.slowToString(); |
| + String generateRuntimeTypeString(ClassElement element, int numberOfInputs) { |
| + String elementName = getName(element); |
| if (element.typeVariables.isEmpty()) return "'$elementName'"; |
| String stringify(_, bool hasValue) => hasValue ? "' + # + '" : "Dynamic"; |
| String arguments = stringifyTypeVariables(element.typeVariables, |