OLD | NEW |
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 Loading... |
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, |
137 /* Do nothing. */ | 137 CodeBuffer buffer, |
| 138 bool emitEndingComma) { |
| 139 if (emitEndingComma) buffer.add(', '); |
138 } | 140 } |
139 | 141 |
140 void emitClassGettersSetters(ClassElement classElement, CodeBuffer buffer, | 142 void emitClassGettersSetters(ClassElement classElement, |
141 {bool omitLeadingComma: false}) { | 143 CodeBuffer buffer, |
| 144 bool emitLeadingComma) { |
142 emitComma() { | 145 emitComma() { |
143 if (!omitLeadingComma) { | 146 if (emitLeadingComma) { |
144 buffer.add(",\n "); | 147 buffer.add(",\n "); |
145 } else { | 148 } else { |
146 omitLeadingComma = false; | 149 emitLeadingComma = true; |
147 } | 150 } |
148 } | 151 } |
149 | 152 |
150 visitClassFields(classElement, (Element member, | 153 visitClassFields(classElement, (Element member, |
151 String name, | 154 String name, |
152 String accessorName, | 155 String accessorName, |
153 bool needsGetter, | 156 bool needsGetter, |
154 bool needsSetter, | 157 bool needsSetter, |
155 bool needsCheckedSetter) { | 158 bool needsCheckedSetter) { |
156 if (needsGetter) { | 159 if (needsGetter) { |
157 emitComma(); | 160 emitComma(); |
158 generateGetter(member, name, accessorName, buffer); | 161 generateGetter(member, name, accessorName, buffer); |
159 } | 162 } |
160 if (needsSetter) { | 163 if (needsSetter) { |
161 emitComma(); | 164 emitComma(); |
162 generateSetter(member, name, accessorName, buffer); | 165 generateSetter(member, name, accessorName, buffer); |
163 } | 166 } |
164 if (needsCheckedSetter) { | 167 if (needsCheckedSetter) { |
165 assert(!needsSetter); | 168 assert(!needsSetter); |
166 emitComma(); | 169 emitComma(); |
167 generateCheckedSetter(member, name, accessorName, buffer); | 170 generateCheckedSetter(member, name, accessorName, buffer); |
168 } | 171 } |
169 }); | 172 }); |
170 } | 173 } |
171 } | 174 } |
OLD | NEW |