Index: lib/compiler/implementation/js_backend/namer.dart |
=================================================================== |
--- lib/compiler/implementation/js_backend/namer.dart (revision 12238) |
+++ lib/compiler/implementation/js_backend/namer.dart (working copy) |
@@ -98,10 +98,32 @@ |
} |
} |
- String instanceMethodName(LibraryElement lib, SourceString name, int arity) { |
- return '${privateName(lib, name)}\$$arity'; |
+ String instanceMethodName(FunctionElement element) { |
+ SourceString name = element.name; |
+ LibraryElement lib = element.getLibrary(); |
+ if (element.kind == ElementKind.GENERATIVE_CONSTRUCTOR_BODY) { |
+ ConstructorBodyElement bodyElement = element; |
+ name = bodyElement.constructor.name; |
+ } |
+ FunctionSignature signature = element.computeSignature(compiler); |
+ String methodName = |
+ '${privateName(lib, name)}\$${signature.parameterCount}'; |
+ if (!signature.optionalParametersAreNamed) { |
+ return methodName; |
+ } else { |
+ StringBuffer buffer = new StringBuffer(methodName); |
kasperl
2012/09/12 11:34:48
I'd leave out the methodName here in the construct
ngeoffray
2012/09/12 11:40:06
Done.
|
+ signature.forEachOptionalParameter((Element element) { |
+ String jsName = JsNames.getValid(element.name.slowToString()); |
+ buffer.add('\$$jsName'); |
+ }); |
+ return buffer.toString(); |
+ } |
} |
+ String instanceMethodNameByArity(SourceString name, int arity) { |
+ return '${name.slowToString()}\$$arity'; |
+ } |
+ |
String instanceMethodInvocationName(LibraryElement lib, SourceString name, |
Selector selector) { |
// TODO(floitsch): mangle, while preserving uniqueness. |
@@ -207,16 +229,9 @@ |
*/ |
String getName(Element element) { |
if (element.isInstanceMember()) { |
- if (element.kind == ElementKind.GENERATIVE_CONSTRUCTOR_BODY) { |
- ConstructorBodyElement bodyElement = element; |
- SourceString name = bodyElement.constructor.name; |
- return instanceMethodName(element.getLibrary(), |
- name, bodyElement.parameterCount(compiler)); |
- } else if (element.kind == ElementKind.FUNCTION) { |
- FunctionElement functionElement = element; |
- return instanceMethodName(element.getLibrary(), |
- element.name, |
- functionElement.parameterCount(compiler)); |
+ if (element.kind == ElementKind.GENERATIVE_CONSTRUCTOR_BODY |
+ || element.kind == ElementKind.FUNCTION) { |
+ return instanceMethodName(element); |
} else if (element.kind == ElementKind.GETTER) { |
return getterName(element.getLibrary(), element.name); |
} else if (element.kind == ElementKind.SETTER) { |