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

Unified Diff: frog/leg/emitter.dart

Issue 8893001: Second try for instantiation of objects. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Clean up even more. 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/elements/elements.dart ('k') | frog/leg/namer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/leg/emitter.dart
diff --git a/frog/leg/emitter.dart b/frog/leg/emitter.dart
index 83f3cbcf6d1c1ab1e1ff59e3e431cb0b937d5572..ee3f81c8ab06c611196c4844822c2296c6de02c9 100644
--- a/frog/leg/emitter.dart
+++ b/frog/leg/emitter.dart
@@ -22,8 +22,9 @@ function(child, parent) {
}''';
bool addedInheritFunction = false;
+ final Namer namer;
- CodeEmitterTask(Compiler compiler) : super(compiler);
+ CodeEmitterTask(Compiler compiler) : namer = compiler.namer, super(compiler);
String get name() => 'CodeEmitter';
String get inheritsName() => '${compiler.namer.isolate}.\$inherits';
@@ -36,10 +37,20 @@ function(child, parent) {
buffer.add(';\n');
}
+ void addInstanceMember(Element member,
+ String prototype,
+ StringBuffer buffer) {
+ assert(member is FunctionElement);
+ assert(member.isInstanceMember());
+ String codeBlock = compiler.universe.generatedCode[member];
+ if (codeBlock !== null) {
+ buffer.add('$prototype.${namer.getName(member)} = $codeBlock;\n');
+ }
+ }
+
void generateClass(ClassElement classElement,
StringBuffer buffer,
Set<ClassElement> seenClasses) {
- Namer namer = compiler.namer;
if (seenClasses.contains(classElement)) return;
seenClasses.add(classElement);
Type supertype = classElement.supertype;
@@ -56,21 +67,23 @@ function(child, parent) {
buffer.add('${inheritsName}($className, $superName);\n');
}
String prototype = '$className.prototype';
- // TODO(floitsch): run through classElement.members() instead of [].
- for (Element member in []) {
- if (member.kind !== ElementKind.FUNCTION) continue;
- assert(member is FunctionElement);
- // TODO(floitsch): if (element.isStatic()) continue;
- String codeBlock = compiler.universe.generatedCode[member];
- assert(codeBlock !== null);
- buffer.add('$prototype.${namer.methodName(member)} = $codeBlock;\n');
+
+ for (Element member in classElement.members) {
+ if (member.isInstanceMember()) {
+ addInstanceMember(member, prototype, buffer);
+ }
+ }
+ for (Element member in classElement.backendMembers) {
+ if (member.isInstanceMember()) {
+ addInstanceMember(member, prototype, buffer);
+ }
}
Element synthesized = classElement.synthesizedConstructor;
if (synthesized !== null) {
String codeBlock = compiler.universe.generatedCode[synthesized];
assert(codeBlock !== null);
- buffer.add('$prototype.${synthesized.name} = $codeBlock;\n');
+ buffer.add('${namer.isolatePropertyAccess(synthesized)} = $codeBlock;\n');
}
}
@@ -84,13 +97,12 @@ function(child, parent) {
String assembleProgram() {
measure(() {
- Namer namer = compiler.namer;
StringBuffer buffer = new StringBuffer();
buffer.add('function ${namer.isolate}() {};\n\n');
compileClasses(buffer);
Map<Element, String> generatedCode = compiler.universe.generatedCode;
generatedCode.forEach((Element element, String codeBlock) {
- if (element.isStatic()) {
+ if (!element.isInstanceMember()) {
buffer.add('${namer.isolatePropertyAccess(element)} = ');
buffer.add(codeBlock);
buffer.add(';\n\n');
« no previous file with comments | « frog/leg/elements/elements.dart ('k') | frog/leg/namer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698