Chromium Code Reviews| 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 = |