Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(643)

Unified Diff: lib/compiler/implementation/runtime_types.dart

Issue 11086074: Give different runtime type representations to different types with the same name. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..fd9353649fe0d18fb8952b8caf8c1c06cbd14ceb 100644
--- a/lib/compiler/implementation/runtime_types.dart
+++ b/lib/compiler/implementation/runtime_types.dart
@@ -11,6 +11,25 @@
#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 use a different name instead.
+ */
+ final Map<String, Element> usedNames = new Map<String, Element>();
+
+ /** Get a unique name for the element. */
+ String getName(Element element) {
ngeoffray 2012/10/15 12:57:55 This very much look like code dealt else where. Co
+ String guess = element.name.slowToString();
+ String name = guess;
+ int id = 0;
+ while (usedNames.containsKey(name) && usedNames[name] != element) {
+ name = '$guess@$id';
+ id++;
+ }
+ usedNames[name] = element;
+ return name;
+ }
+
bool hasTypeArguments(DartType type) {
if (type is InterfaceType) {
InterfaceType interfaceType = type;
@@ -48,9 +67,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);
ngeoffray 2012/10/15 12:57:55 Use the namer instead?
if (element.typeVariables.isEmpty()) return "'$elementName'";
String stringify(_, bool hasValue) => hasValue ? "' + # + '" : "Dynamic";
String arguments = stringifyTypeVariables(element.typeVariables,
« no previous file with comments | « no previous file | lib/compiler/implementation/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698