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 class NativeEmitter { | 5 class NativeEmitter { |
| 6 | 6 |
| 7 CodeEmitterTask emitter; | 7 CodeEmitterTask emitter; |
| 8 CodeBuffer nativeBuffer; | 8 CodeBuffer nativeBuffer; |
| 9 | 9 |
| 10 // Classes that participate in dynamic dispatch. These are the | 10 // Classes that participate in dynamic dispatch. These are the |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 376 } | 376 } |
| 377 | 377 |
| 378 bool requiresNativeIsCheck(Element element) { | 378 bool requiresNativeIsCheck(Element element) { |
| 379 if (!element.isClass()) return false; | 379 if (!element.isClass()) return false; |
| 380 ClassElement cls = element; | 380 ClassElement cls = element; |
| 381 if (cls.isNative()) return true; | 381 if (cls.isNative()) return true; |
| 382 return isSupertypeOfNativeClass(element); | 382 return isSupertypeOfNativeClass(element); |
| 383 } | 383 } |
| 384 | 384 |
| 385 void emitIsChecks(Map<String, String> objectProperties) { | 385 void emitIsChecks(Map<String, String> objectProperties) { |
| 386 for (Element type in compiler.codegenWorld.isChecks) { | 386 for (Type type in compiler.codegenWorld.isChecks) { |
|
ngeoffray
2012/08/30 13:17:46
Shouldn't you use checkedClasses here also? otherw
karlklose
2012/09/05 09:36:01
Done.
| |
| 387 if (!requiresNativeIsCheck(type)) continue; | 387 Element element = type.element; |
| 388 String name = compiler.namer.operatorIs(type); | 388 if (!requiresNativeIsCheck(element)) continue; |
| 389 String name = compiler.namer.operatorIs(element); | |
| 389 objectProperties[name] = 'function() { return false; }'; | 390 objectProperties[name] = 'function() { return false; }'; |
| 390 } | 391 } |
| 391 } | 392 } |
| 392 | 393 |
| 393 void assembleCode(CodeBuffer targetBuffer) { | 394 void assembleCode(CodeBuffer targetBuffer) { |
| 394 if (nativeClasses.isEmpty()) return; | 395 if (nativeClasses.isEmpty()) return; |
| 395 emitDynamicDispatchMetadata(); | 396 emitDynamicDispatchMetadata(); |
| 396 targetBuffer.add('$defineNativeClassName = ' | 397 targetBuffer.add('$defineNativeClassName = ' |
| 397 '$defineNativeClassFunction;\n\n'); | 398 '$defineNativeClassFunction;\n\n'); |
| 398 | 399 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 432 if (!first) targetBuffer.add(",\n"); | 433 if (!first) targetBuffer.add(",\n"); |
| 433 targetBuffer.add(" $name: $function"); | 434 targetBuffer.add(" $name: $function"); |
| 434 first = false; | 435 first = false; |
| 435 }); | 436 }); |
| 436 targetBuffer.add("\n});\n\n"); | 437 targetBuffer.add("\n});\n\n"); |
| 437 } | 438 } |
| 438 targetBuffer.add('$nativeBuffer'); | 439 targetBuffer.add('$nativeBuffer'); |
| 439 targetBuffer.add('\n'); | 440 targetBuffer.add('\n'); |
| 440 } | 441 } |
| 441 } | 442 } |
| OLD | NEW |