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

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: Added comment. 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
« no previous file with comments | « frog/leg/emitter.dart ('k') | frog/leg/ssa/builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/leg/namer.dart
diff --git a/frog/leg/namer.dart b/frog/leg/namer.dart
index 55329a67c63f30f2f71f83bc6f58bb0cfac7c6f9..711c92f32d8bf74f020f7fc1ccfcf4b06440bac9 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) {
+ if (element.kind == ElementKind.CONSTRUCTOR_BODY) {
+ ConstructorBodyElement bodyElement = element;
+ return constructorBodyName(element.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);
+ }
}
« no previous file with comments | « frog/leg/emitter.dart ('k') | frog/leg/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698