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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_backend/emitter_no_eval.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 CodeEmitterNoEvalTask extends CodeEmitterTask { 7 class CodeEmitterNoEvalTask extends CodeEmitterTask {
8 CodeEmitterNoEvalTask(Compiler compiler, 8 CodeEmitterNoEvalTask(Compiler compiler,
9 Namer namer, 9 Namer namer,
10 bool generateSourceMap) 10 bool generateSourceMap)
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 // Generate the constructor. 126 // Generate the constructor.
127 buffer.add("'': function $constructorName("); 127 buffer.add("'': function $constructorName(");
128 buffer.add(Strings.join(argumentNames, ", ")); 128 buffer.add(Strings.join(argumentNames, ", "));
129 buffer.add(") {\n"); 129 buffer.add(") {\n");
130 for (int i = 0; i < fields.length; i++) { 130 for (int i = 0; i < fields.length; i++) {
131 buffer.add(" this.${fields[i]} = ${argumentNames[i]};\n"); 131 buffer.add(" this.${fields[i]} = ${argumentNames[i]};\n");
132 } 132 }
133 buffer.add(' }'); 133 buffer.add(' }');
134 } 134 }
135 135
136 void emitClassFields(ClassElement classElement, CodeBuffer buffer) { 136 void emitClassFields(ClassElement classElement, CodeBuffer buffer,
137 /* Do nothing. */ 137 {bool emitEndingComma: true}) {
138 if (emitEndingComma) buffer.add(', ');
138 } 139 }
139 140
140 void emitClassGettersSetters(ClassElement classElement, CodeBuffer buffer, 141 void emitClassGettersSetters(ClassElement classElement,
141 {bool omitLeadingComma: false}) { 142 CodeBuffer buffer,
143 bool emitLeadingComma) {
142 emitComma() { 144 emitComma() {
143 if (!omitLeadingComma) { 145 if (emitLeadingComma) {
144 buffer.add(",\n "); 146 buffer.add(",\n ");
145 } else { 147 } else {
146 omitLeadingComma = false; 148 emitLeadingComma = true;
147 } 149 }
148 } 150 }
149 151
150 visitClassFields(classElement, (Element member, 152 visitClassFields(classElement, (Element member,
151 String name, 153 String name,
152 String accessorName, 154 String accessorName,
153 bool needsGetter, 155 bool needsGetter,
154 bool needsSetter, 156 bool needsSetter,
155 bool needsCheckedSetter) { 157 bool needsCheckedSetter) {
156 if (needsGetter) { 158 if (needsGetter) {
157 emitComma(); 159 emitComma();
158 generateGetter(member, name, accessorName, buffer); 160 generateGetter(member, name, accessorName, buffer);
159 } 161 }
160 if (needsSetter) { 162 if (needsSetter) {
161 emitComma(); 163 emitComma();
162 generateSetter(member, name, accessorName, buffer); 164 generateSetter(member, name, accessorName, buffer);
163 } 165 }
164 if (needsCheckedSetter) { 166 if (needsCheckedSetter) {
165 assert(!needsSetter); 167 assert(!needsSetter);
166 emitComma(); 168 emitComma();
167 generateCheckedSetter(member, name, accessorName, buffer); 169 generateCheckedSetter(member, name, accessorName, buffer);
168 } 170 }
169 }); 171 });
170 } 172 }
171 } 173 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698