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

Unified Diff: frog/leg/namer.dart

Issue 8888010: First instantiations of objects. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: small refactorings. 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..72df5be0b93e2ce515d9819b1c255eb069873141 100644
--- a/frog/leg/namer.dart
+++ b/frog/leg/namer.dart
@@ -30,6 +30,10 @@ class Namer {
assert(globals[element] === null);
String dartId = '${element.name}';
ngeoffray 2011/12/08 16:01:40 Please add a method getName that takes an element,
floitsch 2011/12/08 16:36:00 Done.
+ if (dartId == '') {
+ assert(element is FunctionElement);
ngeoffray 2011/12/08 16:01:40 element.kind == ElementKind.CONSTRUCTOR?
floitsch 2011/12/08 16:36:00 Done.
+ dartId = 'default';
+ }
// Prefix the dartId with '$' if the name is reserved.
if (jsReserved.contains(dartId)) {
dartId = "\$$dartId";
@@ -53,7 +57,7 @@ class Namer {
usedGlobals[dartId] = usedCount;
globals[element] = id;
return id;
- }
+ }
}
String isolateAccess(Element element) {
@@ -68,8 +72,19 @@ class Namer {
return "$isolate.prototype.$jsId";
}
- String methodName(Element element) {
+ String instanceName(Element element) {
+ if (element is ConstructorBodyElement) {
ngeoffray 2011/12/08 16:01:40 element.kind == ElementKind.CONSTRUCTOR_BODY
floitsch 2011/12/08 16:36:00 Done.
+ return constructorBodyName(element);
+ }
// TODO(floitsch): mangle if necessary.
return '${element.name}';
}
+
+ String constructorBodyName(Element element) {
ngeoffray 2011/12/08 16:01:40 assert(element.kind == ElementKind.BODY_CONSTRUCTO
floitsch 2011/12/08 16:36:00 Actually it must be a constructor. This is necessa
+ // TODO(floitsch): mangle if necessary. Make sure it doesn't collide with
+ // normal methods.
+ String candidate = '${element.name}';
+ if (candidate == '') candidate = 'default';
+ return candidate;
+ }
}

Powered by Google App Engine
This is Rietveld 408576698