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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_backend/native_emitter.dart

Issue 11415114: Do not generate empty native classes. Fixes issue 6872. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of js_backend; 5 part of js_backend;
6 6
7 class NativeEmitter { 7 class NativeEmitter {
8 8
9 CodeEmitterTask emitter; 9 CodeEmitterTask emitter;
10 CodeBuffer nativeBuffer; 10 CodeBuffer nativeBuffer;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 String quotedName = classElement.nativeName.slowToString(); 159 String quotedName = classElement.nativeName.slowToString();
160 if (isNativeLiteral(quotedName)) { 160 if (isNativeLiteral(quotedName)) {
161 generateNativeLiteral(classElement); 161 generateNativeLiteral(classElement);
162 // The native literal kind needs to be dealt with specially when 162 // The native literal kind needs to be dealt with specially when
163 // generating code for it. 163 // generating code for it.
164 return; 164 return;
165 } 165 }
166 166
167 CodeBuffer fieldBuffer = new CodeBuffer(); 167 CodeBuffer fieldBuffer = new CodeBuffer();
168 CodeBuffer getterSetterBuffer = new CodeBuffer(); 168 CodeBuffer getterSetterBuffer = new CodeBuffer();
169 CodeBuffer methodBuffer = new CodeBuffer();
169 170
170 emitter.emitClassFields(classElement, fieldBuffer); 171 emitter.emitClassFields(
171 emitter.emitClassGettersSetters(classElement, getterSetterBuffer, 172 classElement, fieldBuffer, emitEndingComma: false);
172 omitLeadingComma: true); 173 emitter.emitClassGettersSetters(
173 174 classElement, getterSetterBuffer, emitLeadingComma: false);
174 CodeBuffer methodBuffer = new CodeBuffer(); 175 emitter.emitInstanceMembers(
175 emitter.emitInstanceMembers(classElement, methodBuffer, false); 176 classElement, methodBuffer, emitLeadingComma: false);
176 177
177 if (methodBuffer.isEmpty 178 if (methodBuffer.isEmpty
178 && fieldBuffer.isEmpty 179 && fieldBuffer.isEmpty
179 && getterSetterBuffer.isEmpty) { 180 && getterSetterBuffer.isEmpty) {
180 return; 181 return;
181 } 182 }
182 183
183 String nativeName = toNativeName(classElement); 184 String nativeName = toNativeName(classElement);
184 nativeBuffer.add("$defineNativeClassName('$nativeName', "); 185 nativeBuffer.add("$defineNativeClassName('$nativeName', ");
185 nativeBuffer.add('{'); 186 nativeBuffer.add('{');
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 if (!first) targetBuffer.add(",\n"); 500 if (!first) targetBuffer.add(",\n");
500 targetBuffer.add(" $name: $function"); 501 targetBuffer.add(" $name: $function");
501 first = false; 502 first = false;
502 }); 503 });
503 targetBuffer.add("\n});\n\n"); 504 targetBuffer.add("\n});\n\n");
504 } 505 }
505 targetBuffer.add(nativeBuffer); 506 targetBuffer.add(nativeBuffer);
506 targetBuffer.add('\n'); 507 targetBuffer.add('\n');
507 } 508 }
508 } 509 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698