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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 // d needs both a getter and a setter. Then we produce: | 101 // d needs both a getter and a setter. Then we produce: |
102 // - a constructor (directly into the given [buffer]): | 102 // - a constructor (directly into the given [buffer]): |
103 // function A(b, c, d) { this.b = b, this.c = c, this.d = d; } | 103 // function A(b, c, d) { this.b = b, this.c = c, this.d = d; } |
104 // - getters and setters (stored in the [explicitGettersSetters] list): | 104 // - getters and setters (stored in the [explicitGettersSetters] list): |
105 // get$c : function() { return this.c; } | 105 // get$c : function() { return this.c; } |
106 // get$d : function() { return this.d; } | 106 // get$d : function() { return this.d; } |
107 // set$d : function(x) { this.d = x; } | 107 // set$d : function(x) { this.d = x; } |
108 List<String> fields = <String>[]; | 108 List<String> fields = <String>[]; |
109 visitClassFields(classElement, (Element member, | 109 visitClassFields(classElement, (Element member, |
110 String name, | 110 String name, |
111 String accessorName, | |
112 bool needsGetter, | 111 bool needsGetter, |
113 bool needsSetter, | 112 bool needsSetter, |
114 bool needsCheckedSetter) { | 113 bool needsCheckedSetter) { |
115 fields.add(name); | 114 fields.add(name); |
116 }); | 115 }); |
117 | 116 |
118 List<String> argumentNames = fields; | 117 List<String> argumentNames = fields; |
119 if (fields.length < ($z - $a)) { | 118 if (fields.length < ($z - $a)) { |
120 argumentNames = new List<String>(fields.length); | 119 argumentNames = new List<String>(fields.length); |
121 for (int i = 0; i < fields.length; i++) { | 120 for (int i = 0; i < fields.length; i++) { |
(...skipping 23 matching lines...) Expand all Loading... |
145 emitComma() { | 144 emitComma() { |
146 if (emitLeadingComma) { | 145 if (emitLeadingComma) { |
147 buffer.add(",\n "); | 146 buffer.add(",\n "); |
148 } else { | 147 } else { |
149 emitLeadingComma = true; | 148 emitLeadingComma = true; |
150 } | 149 } |
151 } | 150 } |
152 | 151 |
153 visitClassFields(classElement, (Element member, | 152 visitClassFields(classElement, (Element member, |
154 String name, | 153 String name, |
155 String accessorName, | |
156 bool needsGetter, | 154 bool needsGetter, |
157 bool needsSetter, | 155 bool needsSetter, |
158 bool needsCheckedSetter) { | 156 bool needsCheckedSetter) { |
159 if (needsGetter) { | 157 if (needsGetter) { |
160 emitComma(); | 158 emitComma(); |
161 generateGetter(member, name, accessorName, buffer); | 159 generateGetter(member, name, buffer); |
162 } | 160 } |
163 if (needsSetter) { | 161 if (needsSetter) { |
164 emitComma(); | 162 emitComma(); |
165 generateSetter(member, name, accessorName, buffer); | 163 generateSetter(member, name, buffer); |
166 } | 164 } |
167 if (needsCheckedSetter) { | 165 if (needsCheckedSetter) { |
168 assert(!needsSetter); | 166 assert(!needsSetter); |
169 emitComma(); | 167 emitComma(); |
170 generateCheckedSetter(member, name, accessorName, buffer); | 168 generateCheckedSetter(member, name, buffer); |
171 } | 169 } |
172 }); | 170 }); |
173 } | 171 } |
174 } | 172 } |
OLD | NEW |