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

Side by Side Diff: dart/frog/leg/emitter.dart

Issue 9114053: Record names of constructors and use that to implement Object.toString. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 11 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | dart/frog/leg/lib/core.dart » ('j') | dart/frog/leg/lib/core.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * Generates the code for all used classes in the program. Static fields (even 6 * Generates the code for all used classes in the program. Static fields (even
7 * in classes) are ignored, since they can be treated as non-class elements. 7 * in classes) are ignored, since they can be treated as non-class elements.
8 * 8 *
9 * The code for the containing (used) methods must exist in the [:universe:]. 9 * The code for the containing (used) methods must exist in the [:universe:].
10 */ 10 */
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 StringBuffer buffer, 93 StringBuffer buffer,
94 Set<ClassElement> seenClasses) { 94 Set<ClassElement> seenClasses) {
95 if (seenClasses.contains(classElement)) return; 95 if (seenClasses.contains(classElement)) return;
96 seenClasses.add(classElement); 96 seenClasses.add(classElement);
97 ClassElement superClass = classElement.superClass; 97 ClassElement superClass = classElement.superClass;
98 if (superClass !== null) { 98 if (superClass !== null) {
99 generateClass(classElement.superClass, buffer, seenClasses); 99 generateClass(classElement.superClass, buffer, seenClasses);
100 } 100 }
101 101
102 String className = namer.isolatePropertyAccess(classElement); 102 String className = namer.isolatePropertyAccess(classElement);
103 buffer.add('$className = function('); 103 buffer.add('$className = function ${classElement.name}(');
Lasse Reichstein 2012/01/11 09:49:16 I like having the name on the function for debuggi
ahe 2012/01/11 11:01:23 It is readable on IE (with some additional tricks)
104 StringBuffer bodyBuffer = new StringBuffer(); 104 StringBuffer bodyBuffer = new StringBuffer();
105 generateFieldInits(classElement, buffer, bodyBuffer); 105 generateFieldInits(classElement, buffer, bodyBuffer);
106 buffer.add(') {\n'); 106 buffer.add(') {\n');
107 buffer.add(bodyBuffer); 107 buffer.add(bodyBuffer);
108 buffer.add('};\n'); 108 buffer.add('};\n');
Lasse Reichstein 2012/01/11 09:49:16 E.g., here: buffer.add('$className.\$name = "${
109 if (superClass !== null) { 109 if (superClass !== null) {
110 addInheritFunctionIfNecessary(buffer); 110 addInheritFunctionIfNecessary(buffer);
111 String superName = namer.isolatePropertyAccess(superClass); 111 String superName = namer.isolatePropertyAccess(superClass);
112 buffer.add('${inheritsName}($className, $superName);\n'); 112 buffer.add('${inheritsName}($className, $superName);\n');
113 } 113 }
114 String prototype = '$className.prototype'; 114 String prototype = '$className.prototype';
115 115
116 for (Element member in classElement.members) { 116 for (Element member in classElement.members) {
117 if (member.isInstanceMember()) { 117 if (member.isInstanceMember()) {
118 addInstanceMember(member, prototype, buffer); 118 addInstanceMember(member, prototype, buffer);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 compileIsolateStatic(buffer, 155 compileIsolateStatic(buffer,
156 compiler.universe.generatedBailoutCode, 156 compiler.universe.generatedBailoutCode,
157 namer.isolateBailoutPropertyAccess); 157 namer.isolateBailoutPropertyAccess);
158 buffer.add('var ${namer.currentIsolate} = new ${namer.isolate}();\n'); 158 buffer.add('var ${namer.currentIsolate} = new ${namer.isolate}();\n');
159 buffer.add('${namer.currentIsolate}.main();\n'); 159 buffer.add('${namer.currentIsolate}.main();\n');
160 compiler.assembledCode = buffer.toString(); 160 compiler.assembledCode = buffer.toString();
161 }); 161 });
162 return compiler.assembledCode; 162 return compiler.assembledCode;
163 } 163 }
164 } 164 }
OLDNEW
« no previous file with comments | « no previous file | dart/frog/leg/lib/core.dart » ('j') | dart/frog/leg/lib/core.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698