Chromium Code Reviews| Index: frog/leg/namer.dart |
| diff --git a/frog/leg/namer.dart b/frog/leg/namer.dart |
| index 55329a67c63f30f2f71f83bc6f58bb0cfac7c6f9..7c83e9b68da94039cd1b478a8a9bcc9a3567e5b1 100644 |
| --- a/frog/leg/namer.dart |
| +++ b/frog/leg/namer.dart |
| @@ -26,10 +26,20 @@ class Namer { |
| String get currentIsolate() => "currentIsolate"; |
| String get isolate() => "Isolate"; |
| + String getName(Element element) { |
| + String name = '${element.name}'; |
| + if (name == '') { |
| + assert(element.kind == ElementKind.CONSTRUCTOR || |
| + element.kind == ElementKind.CONSTRUCTOR_BODY); |
| + return 'default'; |
| + } |
| + return name; |
| + } |
| + |
| String define(Element element) { |
| assert(globals[element] === null); |
| - String dartId = '${element.name}'; |
| + String dartId = getName(element); |
| // Prefix the dartId with '$' if the name is reserved. |
| if (jsReserved.contains(dartId)) { |
| dartId = "\$$dartId"; |
| @@ -53,7 +63,7 @@ class Namer { |
| usedGlobals[dartId] = usedCount; |
| globals[element] = id; |
| return id; |
| - } |
| + } |
| } |
| String isolateAccess(Element element) { |
| @@ -68,8 +78,24 @@ class Namer { |
| return "$isolate.prototype.$jsId"; |
| } |
| - String methodName(Element element) { |
| + String instanceName(Element element) { |
|
ngeoffray
2011/12/09 14:27:44
Why do you need instanceName and constructorBodyNa
floitsch
2011/12/09 15:24:57
Still need constructorBodyName, since the super-ca
|
| + if (element.kind == ElementKind.CONSTRUCTOR_BODY) { |
| + ConstructorBodyElement bodyElement = element; |
| + return constructorBodyName(bodyElement.constructor); |
| + } |
| // TODO(floitsch): mangle if necessary. |
| return '${element.name}'; |
| } |
| + |
| + /** |
| + * The element must be a constructor element. This way we can find the |
| + * body method when we only have the constructor-element (as is the case |
| + * when doing the super-initialization. |
| + */ |
| + String constructorBodyName(FunctionElement element) { |
| + assert(element.kind == ElementKind.CONSTRUCTOR); |
| + // TODO(floitsch): mangle if necessary. Make sure it doesn't collide with |
| + // normal methods. |
| + return getName(element); |
| + } |
| } |