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

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

Issue 10915104: Move namer into javascript backend. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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/compiler.dart » ('j') | lib/compiler/implementation/compiler.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/closure.dart
diff --git a/lib/compiler/implementation/closure.dart b/lib/compiler/implementation/closure.dart
index 0f21ce55181a5e922cccf32d27c19157d01655e2..7e6d34ce9bb2b3fcf3466077efdf0cb6df3e8dc4 100644
--- a/lib/compiler/implementation/closure.dart
+++ b/lib/compiler/implementation/closure.dart
@@ -444,13 +444,44 @@ class ClosureTranslator extends AbstractVisitor {
scopeData.boxedLoopVariables = result;
}
+ /** Returns a non-unique name for the given closure element. */
+ String closureName(Element element) {
floitsch 2012/09/05 21:27:46 code directly copied from the Namer. The name giv
+ List<String> parts = <String>[];
+ SourceString ownName = element.name;
+ if (ownName == null || ownName.stringValue == "") {
+ parts.add("anon");
+ } else {
+ parts.add(ownName.slowToString());
+ }
+ for (Element enclosingElement = element.enclosingElement;
+ enclosingElement != null &&
+ (enclosingElement.kind === ElementKind.GENERATIVE_CONSTRUCTOR_BODY
+ || enclosingElement.kind === ElementKind.CLASS
+ || enclosingElement.kind === ElementKind.FUNCTION
+ || enclosingElement.kind === ElementKind.GETTER
+ || 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;
+ }
+ return Strings.join(parts, "_");
+ }
+
ClosureClassMap globalizeClosure(FunctionExpression node, Element element) {
- SourceString closureName =
- new SourceString(compiler.namer.closureName(element));
+ SourceString closureName = new SourceString(closureName(element));
ClassElement globalizedElement = new ClosureClassElement(
closureName, compiler, element, element.getCompilationUnit());
FunctionElement callElement =
- new FunctionElement.from(Namer.CLOSURE_INVOCATION_NAME,
+ new FunctionElement.from(Compiler.CALL_OPERATOR_NAME,
element,
globalizedElement);
globalizedElement.backendMembers =
« no previous file with comments | « no previous file | lib/compiler/implementation/compiler.dart » ('j') | lib/compiler/implementation/compiler.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698