| 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 (Element element in compiler.codegenWorld.checkedClasses) { |
| 387 if (!requiresNativeIsCheck(type)) continue; | 387 if (!requiresNativeIsCheck(element)) continue; |
| 388 String name = compiler.namer.operatorIs(type); | 388 String name = compiler.namer.operatorIs(element); |
| 389 objectProperties[name] = 'function() { return false; }'; | 389 objectProperties[name] = 'function() { return false; }'; |
| 390 } | 390 } |
| 391 } | 391 } |
| 392 | 392 |
| 393 void assembleCode(CodeBuffer targetBuffer) { | 393 void assembleCode(CodeBuffer targetBuffer) { |
| 394 if (nativeClasses.isEmpty()) return; | 394 if (nativeClasses.isEmpty()) return; |
| 395 emitDynamicDispatchMetadata(); | 395 emitDynamicDispatchMetadata(); |
| 396 targetBuffer.add('$defineNativeClassName = ' | 396 targetBuffer.add('$defineNativeClassName = ' |
| 397 '$defineNativeClassFunction;\n\n'); | 397 '$defineNativeClassFunction;\n\n'); |
| 398 | 398 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 if (!first) targetBuffer.add(",\n"); | 432 if (!first) targetBuffer.add(",\n"); |
| 433 targetBuffer.add(" $name: $function"); | 433 targetBuffer.add(" $name: $function"); |
| 434 first = false; | 434 first = false; |
| 435 }); | 435 }); |
| 436 targetBuffer.add("\n});\n\n"); | 436 targetBuffer.add("\n});\n\n"); |
| 437 } | 437 } |
| 438 targetBuffer.add('$nativeBuffer'); | 438 targetBuffer.add('$nativeBuffer'); |
| 439 targetBuffer.add('\n'); | 439 targetBuffer.add('\n'); |
| 440 } | 440 } |
| 441 } | 441 } |
| OLD | NEW |