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

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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 // Generate the constructor. 114 // Generate the constructor.
115 buffer.add("'': function $constructorName("); 115 buffer.add("'': function $constructorName(");
116 buffer.add(Strings.join(argumentNames, ", ")); 116 buffer.add(Strings.join(argumentNames, ", "));
117 buffer.add(") {\n"); 117 buffer.add(") {\n");
118 for (int i = 0; i < fields.length; i++) { 118 for (int i = 0; i < fields.length; i++) {
119 buffer.add(" this.${fields[i]} = ${argumentNames[i]};\n"); 119 buffer.add(" this.${fields[i]} = ${argumentNames[i]};\n");
120 } 120 }
121 buffer.add(' }'); 121 buffer.add(' }');
122 } 122 }
123 123
124 void emitClassFields(ClassElement classElement, CodeBuffer buffer) { 124 void emitClassFields(ClassElement classElement, CodeBuffer buffer,
125 /* Do nothing. */ 125 {bool emitEndingComma: true}) {
126 if (emitEndingComma) buffer.add(', ');
126 } 127 }
127 128
128 void emitClassGettersSetters(ClassElement classElement, CodeBuffer buffer, 129 void emitClassGettersSetters(ClassElement classElement, CodeBuffer buffer,
129 {bool omitLeadingComma: false}) { 130 {bool emitLeadingComma: true}) {
130 emitComma() { 131 emitComma() {
131 if (!omitLeadingComma) { 132 if (emitLeadingComma) {
132 buffer.add(",\n "); 133 buffer.add(",\n ");
133 } else { 134 } else {
134 omitLeadingComma = false; 135 emitLeadingComma = true;
135 } 136 }
136 } 137 }
137 138
138 visitClassFields(classElement, (Element member, 139 visitClassFields(classElement, (Element member,
139 String name, 140 String name,
140 String accessorName, 141 String accessorName,
141 bool needsGetter, 142 bool needsGetter,
142 bool needsSetter, 143 bool needsSetter,
143 bool needsCheckedSetter) { 144 bool needsCheckedSetter) {
144 if (needsGetter) { 145 if (needsGetter) {
145 emitComma(); 146 emitComma();
146 generateGetter(member, name, accessorName, buffer); 147 generateGetter(member, name, accessorName, buffer);
147 } 148 }
148 if (needsSetter) { 149 if (needsSetter) {
149 emitComma(); 150 emitComma();
150 generateSetter(member, name, accessorName, buffer); 151 generateSetter(member, name, accessorName, buffer);
151 } 152 }
152 if (needsCheckedSetter) { 153 if (needsCheckedSetter) {
153 assert(!needsSetter); 154 assert(!needsSetter);
154 emitComma(); 155 emitComma();
155 generateCheckedSetter(member, name, accessorName, buffer); 156 generateCheckedSetter(member, name, accessorName, buffer);
156 } 157 }
157 }); 158 });
158 } 159 }
159 } 160 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698