| 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 ConstantEmitter implements ConstantVisitor { | 7 class ConstantEmitter implements ConstantVisitor { |
| 8 final Compiler compiler; | 8 final Compiler compiler; |
| 9 final Namer namer; | 9 final Namer namer; |
| 10 | 10 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 } else { | 202 } else { |
| 203 SourceString helperSourceName = | 203 SourceString helperSourceName = |
| 204 const SourceString('createRuntimeType'); | 204 const SourceString('createRuntimeType'); |
| 205 Element helper = compiler.findHelper(helperSourceName); | 205 Element helper = compiler.findHelper(helperSourceName); |
| 206 JavaScriptBackend backend = compiler.backend; | 206 JavaScriptBackend backend = compiler.backend; |
| 207 String helperName = backend.namer.getName(helper); | 207 String helperName = backend.namer.getName(helper); |
| 208 DartType type = constant.representedType; | 208 DartType type = constant.representedType; |
| 209 Element element = type.element; | 209 Element element = type.element; |
| 210 String typeName; | 210 String typeName; |
| 211 if (type.kind == TypeKind.INTERFACE) { | 211 if (type.kind == TypeKind.INTERFACE) { |
| 212 typeName = backend.rti.generateRuntimeTypeString(element, 0); | 212 typeName = |
| 213 backend.rti.getStringRepresentation(type, expandRawType: true); |
| 213 } else { | 214 } else { |
| 214 assert(type.kind == TypeKind.TYPEDEF); | 215 assert(type.kind == TypeKind.TYPEDEF); |
| 215 typeName = element.name.slowToString(); | 216 typeName = element.name.slowToString(); |
| 216 } | 217 } |
| 217 buffer.add("${namer.CURRENT_ISOLATE}.$helperName('$typeName')"); | 218 buffer.add("${namer.CURRENT_ISOLATE}.$helperName('$typeName')"); |
| 218 } | 219 } |
| 219 } | 220 } |
| 220 | 221 |
| 221 void visitConstructed(ConstructedConstant constant) { | 222 void visitConstructed(ConstructedConstant constant) { |
| 222 if (shouldEmitCanonicalVersion) { | 223 if (shouldEmitCanonicalVersion) { |
| 223 emitCanonicalVersion(constant); | 224 emitCanonicalVersion(constant); |
| 224 } else { | 225 } else { |
| 225 shouldEmitCanonicalVersion = true; | 226 shouldEmitCanonicalVersion = true; |
| 226 | 227 |
| 227 buffer.add("new "); | 228 buffer.add("new "); |
| 228 buffer.add(getJsConstructor(constant.type.element)); | 229 buffer.add(getJsConstructor(constant.type.element)); |
| 229 buffer.add("("); | 230 buffer.add("("); |
| 230 for (int i = 0; i < constant.fields.length; i++) { | 231 for (int i = 0; i < constant.fields.length; i++) { |
| 231 if (i != 0) buffer.add(", "); | 232 if (i != 0) buffer.add(", "); |
| 232 _visit(constant.fields[i]); | 233 _visit(constant.fields[i]); |
| 233 } | 234 } |
| 234 buffer.add(")"); | 235 buffer.add(")"); |
| 235 } | 236 } |
| 236 } | 237 } |
| 237 } | 238 } |
| OLD | NEW |