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

Unified Diff: dart/sdk/lib/_internal/compiler/implementation/closure.dart

Issue 10905211: Clean up operator names. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added test Created 8 years, 1 month 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
Index: dart/sdk/lib/_internal/compiler/implementation/closure.dart
diff --git a/dart/sdk/lib/_internal/compiler/implementation/closure.dart b/dart/sdk/lib/_internal/compiler/implementation/closure.dart
index 0465c22054ced087b4bed45cdefbeaa9d231a504..4d6be1c78fbc59b06ae6509edd36b22eb0652fd5 100644
--- a/dart/sdk/lib/_internal/compiler/implementation/closure.dart
+++ b/dart/sdk/lib/_internal/compiler/implementation/closure.dart
@@ -479,34 +479,29 @@ class ClosureTranslator extends Visitor {
/** Returns a non-unique name for the given closure element. */
String closureName(Element element) {
- List<String> parts = <String>[];
+ Link<String> parts = const Link<String>();
SourceString ownName = element.name;
if (ownName == null || ownName.stringValue == "") {
- parts.add("anon");
+ parts = parts.prepend("anon");
} else {
- parts.add(ownName.slowToString());
+ parts = parts.prepend(ownName.slowToString());
}
for (Element enclosingElement = element.enclosingElement;
enclosingElement != null &&
- (identical(enclosingElement.kind, ElementKind.GENERATIVE_CONSTRUCTOR_BODY)
+ (identical(enclosingElement.kind,
+ ElementKind.GENERATIVE_CONSTRUCTOR_BODY)
|| identical(enclosingElement.kind, ElementKind.CLASS)
|| identical(enclosingElement.kind, ElementKind.FUNCTION)
|| identical(enclosingElement.kind, ElementKind.GETTER)
|| identical(enclosingElement.kind, ElementKind.SETTER));
enclosingElement = enclosingElement.enclosingElement) {
- SourceString surroundingName = enclosingElement.name;
- if (surroundingName != null) {
- String surroundingNameString = surroundingName.slowToString();
- if (surroundingNameString != "") parts.add(surroundingNameString);
- }
- }
- // Invert the parts.
- for (int i = 0, j = parts.length - 1; i < j; i++, j--) {
- var tmp = parts[i];
- parts[i] = parts[j];
- parts[j] = tmp;
+ SourceString surroundingName =
+ Elements.operatorNameToIdentifier(enclosingElement.name);
+ parts = parts.prepend(surroundingName.slowToString());
}
- return Strings.join(parts, "_");
+ StringBuffer sb = new StringBuffer();
+ parts.printOn(sb, '_');
+ return sb.toString();
}
ClosureClassMap globalizeClosure(FunctionExpression node, Element element) {

Powered by Google App Engine
This is Rietveld 408576698