| 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 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 // with language/prefix6_negative_test.dart where we have an instance | 1177 // with language/prefix6_negative_test.dart where we have an instance |
| 1178 // method without its corresponding class. | 1178 // method without its corresponding class. |
| 1179 return; | 1179 return; |
| 1180 } | 1180 } |
| 1181 | 1181 |
| 1182 String libraryName = | 1182 String libraryName = |
| 1183 (!compiler.enableMinification || backend.mustRetainLibraryNames) ? | 1183 (!compiler.enableMinification || backend.mustRetainLibraryNames) ? |
| 1184 library.getLibraryName() : | 1184 library.getLibraryName() : |
| 1185 ""; | 1185 ""; |
| 1186 | 1186 |
| 1187 jsAst.Fun metadata = task.metadataEmitter.buildMetadataFunction(library); | 1187 jsAst.Fun metadata = task.metadataCollector.buildMetadataFunction(library); |
| 1188 | 1188 |
| 1189 jsAst.ObjectInitializer initializers = descriptor.toObjectInitializer(); | 1189 jsAst.ObjectInitializer initializers = descriptor.toObjectInitializer(); |
| 1190 | 1190 |
| 1191 compiler.dumpInfoTask.registerElementAst(library, metadata); | 1191 compiler.dumpInfoTask.registerElementAst(library, metadata); |
| 1192 compiler.dumpInfoTask.registerElementAst(library, initializers); | 1192 compiler.dumpInfoTask.registerElementAst(library, initializers); |
| 1193 output | 1193 output |
| 1194 ..add('["$libraryName",$_') | 1194 ..add('["$libraryName",$_') |
| 1195 ..add('"${uri}",$_'); | 1195 ..add('"${uri}",$_'); |
| 1196 if (metadata != null) { | 1196 if (metadata != null) { |
| 1197 output.addBuffer(jsAst.prettyPrint(metadata, | 1197 output.addBuffer(jsAst.prettyPrint(metadata, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1246 void emitTypedefs() { | 1246 void emitTypedefs() { |
| 1247 OutputUnit mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit; | 1247 OutputUnit mainOutputUnit = compiler.deferredLoadTask.mainOutputUnit; |
| 1248 | 1248 |
| 1249 // Emit all required typedef declarations into the main output unit. | 1249 // Emit all required typedef declarations into the main output unit. |
| 1250 // TODO(karlklose): unify required classes and typedefs to declarations | 1250 // TODO(karlklose): unify required classes and typedefs to declarations |
| 1251 // and have builders for each kind. | 1251 // and have builders for each kind. |
| 1252 for (TypedefElement typedef in typedefsNeededForReflection) { | 1252 for (TypedefElement typedef in typedefsNeededForReflection) { |
| 1253 LibraryElement library = typedef.library; | 1253 LibraryElement library = typedef.library; |
| 1254 // TODO(karlklose): add a TypedefBuilder and move this code there. | 1254 // TODO(karlklose): add a TypedefBuilder and move this code there. |
| 1255 DartType type = typedef.alias; | 1255 DartType type = typedef.alias; |
| 1256 int typeIndex = task.metadataEmitter.reifyType(type); | 1256 int typeIndex = task.metadataCollector.reifyType(type); |
| 1257 ClassBuilder builder = new ClassBuilder(typedef, namer); | 1257 ClassBuilder builder = new ClassBuilder(typedef, namer); |
| 1258 builder.addProperty(embeddedNames.TYPEDEF_TYPE_PROPERTY_NAME, | 1258 builder.addProperty(embeddedNames.TYPEDEF_TYPE_PROPERTY_NAME, |
| 1259 js.number(typeIndex)); | 1259 js.number(typeIndex)); |
| 1260 builder.addProperty(embeddedNames.TYPEDEF_PREDICATE_PROPERTY_NAME, | 1260 builder.addProperty(embeddedNames.TYPEDEF_PREDICATE_PROPERTY_NAME, |
| 1261 js.boolean(true)); | 1261 js.boolean(true)); |
| 1262 | 1262 |
| 1263 // We can be pretty sure that the objectClass is initialized, since | 1263 // We can be pretty sure that the objectClass is initialized, since |
| 1264 // typedefs are only emitted with reflection, which requires lots of | 1264 // typedefs are only emitted with reflection, which requires lots of |
| 1265 // classes. | 1265 // classes. |
| 1266 assert(compiler.objectClass != null); | 1266 assert(compiler.objectClass != null); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1507 } | 1507 } |
| 1508 | 1508 |
| 1509 // Static field initializations require the classes and compile-time | 1509 // Static field initializations require the classes and compile-time |
| 1510 // constants to be set up. | 1510 // constants to be set up. |
| 1511 emitStaticNonFinalFieldInitializations(mainOutput, mainOutputUnit); | 1511 emitStaticNonFinalFieldInitializations(mainOutput, mainOutputUnit); |
| 1512 interceptorEmitter.emitTypeToInterceptorMap(program, mainOutput); | 1512 interceptorEmitter.emitTypeToInterceptorMap(program, mainOutput); |
| 1513 emitLazilyInitializedStaticFields(mainOutput); | 1513 emitLazilyInitializedStaticFields(mainOutput); |
| 1514 | 1514 |
| 1515 mainOutput.add('\n'); | 1515 mainOutput.add('\n'); |
| 1516 | 1516 |
| 1517 emitMetadata(task.metadataEmitter.globalMetadata, mainOutput); | 1517 emitMetadata(task.metadataCollector.globalMetadata, mainOutput); |
| 1518 | 1518 |
| 1519 isolateProperties = isolatePropertiesName; | 1519 isolateProperties = isolatePropertiesName; |
| 1520 // The following code should not use the short-hand for the | 1520 // The following code should not use the short-hand for the |
| 1521 // initialStatics. | 1521 // initialStatics. |
| 1522 mainOutput.add('${namer.currentIsolate}$_=${_}null$N'); | 1522 mainOutput.add('${namer.currentIsolate}$_=${_}null$N'); |
| 1523 | 1523 |
| 1524 emitFinishIsolateConstructorInvocation(mainOutput); | 1524 emitFinishIsolateConstructorInvocation(mainOutput); |
| 1525 mainOutput.add( | 1525 mainOutput.add( |
| 1526 '${namer.currentIsolate}$_=${_}new ${namer.isolateName}()$N'); | 1526 '${namer.currentIsolate}$_=${_}new ${namer.isolateName}()$N'); |
| 1527 | 1527 |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2053 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { | 2053 for (Element element in compiler.enqueuer.codegen.newlyEnqueuedElements) { |
| 2054 if (element.isInstanceMember) { | 2054 if (element.isInstanceMember) { |
| 2055 cachedClassBuilders.remove(element.enclosingClass); | 2055 cachedClassBuilders.remove(element.enclosingClass); |
| 2056 | 2056 |
| 2057 nativeEmitter.cachedBuilders.remove(element.enclosingClass); | 2057 nativeEmitter.cachedBuilders.remove(element.enclosingClass); |
| 2058 | 2058 |
| 2059 } | 2059 } |
| 2060 } | 2060 } |
| 2061 } | 2061 } |
| 2062 } | 2062 } |
| OLD | NEW |