| 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 class ConstantEmitter implements ConstantVisitor { | 5 class ConstantEmitter implements ConstantVisitor { |
| 6 final Compiler compiler; | 6 final Compiler compiler; |
| 7 final Namer namer; | 7 final Namer namer; |
| 8 | 8 |
| 9 CodeBuffer buffer; | 9 CodeBuffer buffer; |
| 10 bool shouldEmitCanonicalVersion; | 10 bool shouldEmitCanonicalVersion; |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 ClassElement classElement = constant.type.element; | 202 ClassElement classElement = constant.type.element; |
| 203 buffer.add("new "); | 203 buffer.add("new "); |
| 204 buffer.add(getJsConstructor(classElement)); | 204 buffer.add(getJsConstructor(classElement)); |
| 205 buffer.add("("); | 205 buffer.add("("); |
| 206 // The arguments of the JavaScript constructor for any given Dart class | 206 // The arguments of the JavaScript constructor for any given Dart class |
| 207 // are in the same order as the members of the class element. | 207 // are in the same order as the members of the class element. |
| 208 int emittedArgumentCount = 0; | 208 int emittedArgumentCount = 0; |
| 209 classElement.forEachInstanceField( | 209 classElement.forEachInstanceField( |
| 210 includeBackendMembers: true, | 210 includeBackendMembers: true, |
| 211 includeSuperMembers: true, | 211 includeSuperMembers: true, |
| 212 includeInjectedMembers: true, |
| 212 f: (ClassElement enclosing, Element field) { | 213 f: (ClassElement enclosing, Element field) { |
| 213 if (emittedArgumentCount != 0) buffer.add(", "); | 214 if (emittedArgumentCount != 0) buffer.add(", "); |
| 214 if (field.name == MapConstant.LENGTH_NAME) { | 215 if (field.name == MapConstant.LENGTH_NAME) { |
| 215 buffer.add(constant.keys.entries.length); | 216 buffer.add(constant.keys.entries.length); |
| 216 } else if (field.name == MapConstant.JS_OBJECT_NAME) { | 217 } else if (field.name == MapConstant.JS_OBJECT_NAME) { |
| 217 writeJsMap(); | 218 writeJsMap(); |
| 218 } else if (field.name == MapConstant.KEYS_NAME) { | 219 } else if (field.name == MapConstant.KEYS_NAME) { |
| 219 emitCanonicalVersionOfConstant(constant.keys, buffer); | 220 emitCanonicalVersionOfConstant(constant.keys, buffer); |
| 220 } else if (field.name == MapConstant.PROTO_VALUE) { | 221 } else if (field.name == MapConstant.PROTO_VALUE) { |
| 221 assert(constant.protoValue !== null); | 222 assert(constant.protoValue !== null); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 243 buffer.add(getJsConstructor(constant.type.element)); | 244 buffer.add(getJsConstructor(constant.type.element)); |
| 244 buffer.add("("); | 245 buffer.add("("); |
| 245 for (int i = 0; i < constant.fields.length; i++) { | 246 for (int i = 0; i < constant.fields.length; i++) { |
| 246 if (i != 0) buffer.add(", "); | 247 if (i != 0) buffer.add(", "); |
| 247 _visit(constant.fields[i]); | 248 _visit(constant.fields[i]); |
| 248 } | 249 } |
| 249 buffer.add(")"); | 250 buffer.add(")"); |
| 250 } | 251 } |
| 251 } | 252 } |
| 252 } | 253 } |
| OLD | NEW |