| 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 NativeEmitter { | 7 class NativeEmitter { |
| 8 | 8 |
| 9 final Map<Element, ClassBuilder> cachedBuilders; | 9 final Map<Element, ClassBuilder> cachedBuilders; |
| 10 | 10 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 Set<ClassElement> nonleafClasses = new Set<ClassElement>(); | 105 Set<ClassElement> nonleafClasses = new Set<ClassElement>(); |
| 106 | 106 |
| 107 Map<ClassElement, List<ClassElement>> extensionPoints = | 107 Map<ClassElement, List<ClassElement>> extensionPoints = |
| 108 computeExtensionPoints(preOrder); | 108 computeExtensionPoints(preOrder); |
| 109 | 109 |
| 110 neededClasses.add(compiler.objectClass); | 110 neededClasses.add(compiler.objectClass); |
| 111 | 111 |
| 112 Set<ClassElement> neededByConstant = | 112 Set<ClassElement> neededByConstant = |
| 113 emitterTask.interceptorsReferencedFromConstants(); | 113 emitterTask.interceptorsReferencedFromConstants(); |
| 114 Set<ClassElement> modifiedClasses = | 114 Set<ClassElement> modifiedClasses = |
| 115 emitterTask.typeTestEmitter.classesModifiedByEmitRuntimeTypeSupport(); | 115 emitterTask.typeTestRegistry.classesModifiedByEmitRuntimeTypeSupport(); |
| 116 | 116 |
| 117 for (ClassElement classElement in preOrder.reversed) { | 117 for (ClassElement classElement in preOrder.reversed) { |
| 118 // Post-order traversal ensures we visit the subclasses before their | 118 // Post-order traversal ensures we visit the subclasses before their |
| 119 // superclass. This makes it easy to tell if a class is needed because a | 119 // superclass. This makes it easy to tell if a class is needed because a |
| 120 // subclass is needed. | 120 // subclass is needed. |
| 121 ClassBuilder builder = builders[classElement]; | 121 ClassBuilder builder = builders[classElement]; |
| 122 bool needed = false; | 122 bool needed = false; |
| 123 if (builder == null) { | 123 if (builder == null) { |
| 124 // Mixin applications (native+mixin) are non-native, so [classElement] | 124 // Mixin applications (native+mixin) are non-native, so [classElement] |
| 125 // has already been emitted as a regular class. Mark [classElement] as | 125 // has already been emitted as a regular class. Mark [classElement] as |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 | 306 |
| 307 emitterTask.oldEmitter.classEmitter.emitClassConstructor( | 307 emitterTask.oldEmitter.classEmitter.emitClassConstructor( |
| 308 classElement, builder); | 308 classElement, builder); |
| 309 bool hasFields = emitterTask.oldEmitter.classEmitter.emitFields( | 309 bool hasFields = emitterTask.oldEmitter.classEmitter.emitFields( |
| 310 classElement, builder, superName, classIsNative: true); | 310 classElement, builder, superName, classIsNative: true); |
| 311 int propertyCount = builder.properties.length; | 311 int propertyCount = builder.properties.length; |
| 312 emitterTask.oldEmitter.classEmitter.emitClassGettersSetters( | 312 emitterTask.oldEmitter.classEmitter.emitClassGettersSetters( |
| 313 classElement, builder); | 313 classElement, builder); |
| 314 emitterTask.oldEmitter.classEmitter.emitInstanceMembers( | 314 emitterTask.oldEmitter.classEmitter.emitInstanceMembers( |
| 315 classElement, builder); | 315 classElement, builder); |
| 316 emitterTask.typeTestEmitter.emitIsTests(classElement, builder); | 316 emitterTask.oldEmitter.typeTestEmitter.emitIsTests(classElement, builder); |
| 317 | 317 |
| 318 if (!hasFields && | 318 if (!hasFields && |
| 319 builder.properties.length == propertyCount && | 319 builder.properties.length == propertyCount && |
| 320 superclass is! MixinApplicationElement) { | 320 superclass is! MixinApplicationElement) { |
| 321 builder.isTrivial = true; | 321 builder.isTrivial = true; |
| 322 } | 322 } |
| 323 | 323 |
| 324 return builder; | 324 return builder; |
| 325 } | 325 } |
| 326 | 326 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 if (emitterTask.compiler.enableMinification) targetBuffer.add(';'); | 471 if (emitterTask.compiler.enableMinification) targetBuffer.add(';'); |
| 472 targetBuffer.add(jsAst.prettyPrint( | 472 targetBuffer.add(jsAst.prettyPrint( |
| 473 new jsAst.ExpressionStatement(init), compiler)); | 473 new jsAst.ExpressionStatement(init), compiler)); |
| 474 targetBuffer.add('\n'); | 474 targetBuffer.add('\n'); |
| 475 } | 475 } |
| 476 | 476 |
| 477 targetBuffer.add(nativeBuffer); | 477 targetBuffer.add(nativeBuffer); |
| 478 targetBuffer.add('\n'); | 478 targetBuffer.add('\n'); |
| 479 } | 479 } |
| 480 } | 480 } |
| OLD | NEW |