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

Unified Diff: frog/leg/namer.dart

Issue 8893001: Second try for instantiation of objects. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Changes to last attempt. Created 9 years 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: 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);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698