Chromium Code Reviews| 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 272 if (nativeAncestor != null) { | 272 if (nativeAncestor != null) { |
| 273 map | 273 map |
| 274 .putIfAbsent(nativeAncestor, () => <ClassElement>[]) | 274 .putIfAbsent(nativeAncestor, () => <ClassElement>[]) |
| 275 .add(classElement); | 275 .add(classElement); |
| 276 } | 276 } |
| 277 } | 277 } |
| 278 return map; | 278 return map; |
| 279 } | 279 } |
| 280 | 280 |
| 281 ClassBuilder generateNativeClass(ClassElement classElement) { | 281 ClassBuilder generateNativeClass(ClassElement classElement) { |
| 282 ClassBuilder builder; | |
| 283 if (compiler.hasIncrementalSupport) { | |
| 284 builder = cachedBuilders[classElement]; | |
| 285 if (builder != null) return builder; | |
| 286 builder = new ClassBuilder(classElement, backend.namer); | |
| 287 cachedBuilders[classElement] = builder; | |
| 288 } else { | |
| 289 builder = new ClassBuilder(classElement, backend.namer); | |
| 290 } | |
| 291 | |
| 292 // TODO(sra): Issue #13731- this is commented out as part of custom element | 282 // TODO(sra): Issue #13731- this is commented out as part of custom element |
| 293 // constructor work. | 283 // constructor work. |
| 294 //assert(!classElement.hasBackendMembers); | 284 //assert(!classElement.hasBackendMembers); |
| 295 nativeClasses.add(classElement); | 285 nativeClasses.add(classElement); |
| 296 | 286 |
| 297 ClassElement superclass = classElement.superclass; | 287 ClassElement superclass = classElement.superclass; |
| 298 assert(superclass != null); | 288 assert(superclass != null); |
| 299 // Fix superclass. TODO(sra): make native classes inherit from Interceptor. | 289 // Fix superclass. TODO(sra): make native classes inherit from Interceptor. |
| 300 assert(superclass != compiler.objectClass); | 290 assert(superclass != compiler.objectClass); |
| 301 if (superclass == compiler.objectClass) { | 291 if (superclass == compiler.objectClass) { |
| 302 superclass = backend.jsInterceptorClass; | 292 superclass = backend.jsInterceptorClass; |
| 303 } | 293 } |
| 304 | 294 |
| 305 String superName = backend.namer.getNameOfClass(superclass); | 295 String superName = backend.namer.getNameOfClass(superclass); |
| 306 | 296 |
| 297 ClassBuilder builder; | |
| 298 if (compiler.hasIncrementalSupport) { | |
| 299 builder = cachedBuilders[classElement]; | |
| 300 if (builder != null) return builder; | |
| 301 builder = new ClassBuilder(classElement, backend.namer); | |
| 302 cachedBuilders[classElement] = builder; | |
| 303 } else { | |
| 304 builder = new ClassBuilder(classElement, backend.namer); | |
| 305 } | |
| 306 builder.superName = superName; | |
|
floitsch
2014/11/25 15:17:13
Line 306 is new. The rest is copied from above.
| |
| 307 | |
| 307 emitterTask.oldEmitter.classEmitter.emitClassConstructor( | 308 emitterTask.oldEmitter.classEmitter.emitClassConstructor( |
| 308 classElement, builder); | 309 classElement, builder); |
| 309 bool hasFields = emitterTask.oldEmitter.classEmitter.emitFields( | 310 bool hasFields = emitterTask.oldEmitter.classEmitter.emitFields( |
| 310 classElement, builder, superName, classIsNative: true); | 311 classElement, builder, classIsNative: true); |
| 311 int propertyCount = builder.properties.length; | 312 int propertyCount = builder.properties.length; |
| 312 emitterTask.oldEmitter.classEmitter.emitClassGettersSetters( | 313 emitterTask.oldEmitter.classEmitter.emitClassGettersSetters( |
| 313 classElement, builder); | 314 classElement, builder); |
| 314 emitterTask.oldEmitter.classEmitter.emitInstanceMembers( | 315 emitterTask.oldEmitter.classEmitter.emitInstanceMembers( |
| 315 classElement, builder); | 316 classElement, builder); |
| 316 emitterTask.typeTestEmitter.emitIsTests(classElement, builder); | 317 emitterTask.typeTestEmitter.emitIsTests(classElement, builder); |
| 317 | 318 |
| 318 if (!hasFields && | 319 if (!hasFields && |
| 319 builder.properties.length == propertyCount && | 320 builder.properties.length == propertyCount && |
| 320 superclass is! MixinApplicationElement) { | 321 superclass is! MixinApplicationElement) { |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 471 if (emitterTask.compiler.enableMinification) targetBuffer.add(';'); | 472 if (emitterTask.compiler.enableMinification) targetBuffer.add(';'); |
| 472 targetBuffer.add(jsAst.prettyPrint( | 473 targetBuffer.add(jsAst.prettyPrint( |
| 473 new jsAst.ExpressionStatement(init), compiler)); | 474 new jsAst.ExpressionStatement(init), compiler)); |
| 474 targetBuffer.add('\n'); | 475 targetBuffer.add('\n'); |
| 475 } | 476 } |
| 476 | 477 |
| 477 targetBuffer.add(nativeBuffer); | 478 targetBuffer.add(nativeBuffer); |
| 478 targetBuffer.add('\n'); | 479 targetBuffer.add('\n'); |
| 479 } | 480 } |
| 480 } | 481 } |
| OLD | NEW |