| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 dart2js.js_emitter; | 5 part of dart2js.js_emitter; |
| 6 | 6 |
| 7 | 7 |
| 8 class OldEmitter implements Emitter { | 8 class OldEmitter implements Emitter { |
| 9 final Compiler compiler; | 9 final Compiler compiler; |
| 10 final CodeEmitterTask task; | 10 final CodeEmitterTask task; |
| (...skipping 1488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1499 | 1499 |
| 1500 // Emit all required typedef declarations into the main output unit. | 1500 // Emit all required typedef declarations into the main output unit. |
| 1501 // TODO(karlklose): unify required classes and typedefs to declarations | 1501 // TODO(karlklose): unify required classes and typedefs to declarations |
| 1502 // and have builders for each kind. | 1502 // and have builders for each kind. |
| 1503 for (TypedefElement typedef in typedefsNeededForReflection) { | 1503 for (TypedefElement typedef in typedefsNeededForReflection) { |
| 1504 OutputUnit mainUnit = compiler.deferredLoadTask.mainOutputUnit; | 1504 OutputUnit mainUnit = compiler.deferredLoadTask.mainOutputUnit; |
| 1505 LibraryElement library = typedef.library; | 1505 LibraryElement library = typedef.library; |
| 1506 // TODO(karlklose): add a TypedefBuilder and move this code there. | 1506 // TODO(karlklose): add a TypedefBuilder and move this code there. |
| 1507 DartType type = typedef.alias; | 1507 DartType type = typedef.alias; |
| 1508 int typeIndex = metadataEmitter.reifyType(type); | 1508 int typeIndex = metadataEmitter.reifyType(type); |
| 1509 String typeReference = | 1509 ClassBuilder builder = new ClassBuilder(typedef, namer); |
| 1510 encoding.encodeTypedefFieldDescriptor(typeIndex); | 1510 builder.addProperty(embeddedNames.TYPEDEF_TYPE_PROPERTY_NAME, |
| 1511 jsAst.Property descriptor = new jsAst.Property( | 1511 js.number(typeIndex)); |
| 1512 js.string(namer.classDescriptorProperty), | 1512 builder.addProperty(embeddedNames.TYPEDEF_PREDICATE_PROPERTY_NAME, |
| 1513 js.string(typeReference)); | 1513 js.boolean(true)); |
| 1514 jsAst.Node declaration = new jsAst.ObjectInitializer([descriptor]); | 1514 |
| 1515 // We can be pretty sure that the objectClass is initialized, since |
| 1516 // typedefs are only emitted with reflection, which requires lots of |
| 1517 // classes. |
| 1518 assert(compiler.objectClass != null); |
| 1519 builder.superName = namer.getNameOfClass(compiler.objectClass); |
| 1520 jsAst.Node declaration = builder.toObjectInitializer(); |
| 1515 String mangledName = namer.getNameX(typedef); | 1521 String mangledName = namer.getNameX(typedef); |
| 1516 String reflectionName = getReflectionName(typedef, mangledName); | 1522 String reflectionName = getReflectionName(typedef, mangledName); |
| 1517 getElementDescriptor(library) | 1523 getElementDescriptor(library) |
| 1518 ..addProperty(mangledName, declaration) | 1524 ..addProperty(mangledName, declaration) |
| 1519 ..addProperty("+$reflectionName", js.string('')); | 1525 ..addProperty("+$reflectionName", js.string('')); |
| 1520 // Also emit a trivial constructor for CSP mode. | 1526 // Also emit a trivial constructor for CSP mode. |
| 1521 String constructorName = mangledName; | 1527 String constructorName = mangledName; |
| 1522 jsAst.Expression constructorAst = js('function() {}'); | 1528 jsAst.Expression constructorAst = js('function() {}'); |
| 1523 List<String> fieldNames = []; | 1529 List<String> fieldNames = []; |
| 1524 emitPrecompiledConstructor(mainOutputUnit, | 1530 emitPrecompiledConstructor(mainOutputUnit, |
| (...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2276 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { | 2282 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { |
| 2277 if (element.isInstanceMember) { | 2283 if (element.isInstanceMember) { |
| 2278 cachedClassBuilders.remove(element.enclosingClass); | 2284 cachedClassBuilders.remove(element.enclosingClass); |
| 2279 | 2285 |
| 2280 nativeEmitter.cachedBuilders.remove(element.enclosingClass); | 2286 nativeEmitter.cachedBuilders.remove(element.enclosingClass); |
| 2281 | 2287 |
| 2282 } | 2288 } |
| 2283 } | 2289 } |
| 2284 } | 2290 } |
| 2285 } | 2291 } |
| OLD | NEW |