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

Unified Diff: lib/compiler/implementation/js_backend/namer.dart

Issue 10911211: Runtime support for the new parameter specification. (Closed) Base URL: http://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
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 suffix = new StringBuffer();
+ signature.forEachOptionalParameter((Element element) {
+ String jsName = JsNames.getValid(element.name.slowToString());
+ suffix.add('\$$jsName');
+ });
+ return '$methodName$suffix';
+ }
}
+ String instanceMethodNameByArity(SourceString name, int arity) {
+ return '${name.slowToString()}\$$arity';
ahe 2012/09/13 14:29:10 assert(!name.isPrivate());
ngeoffray 2012/09/17 12:21:01 Done.
+ }
+
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) {

Powered by Google App Engine
This is Rietveld 408576698