| 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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 bool requiresNativeIsCheck(Element element) { | 390 bool requiresNativeIsCheck(Element element) { |
| 391 if (!element.isClass()) return false; | 391 if (!element.isClass()) return false; |
| 392 ClassElement cls = element; | 392 ClassElement cls = element; |
| 393 if (cls.isNative()) return true; | 393 if (cls.isNative()) return true; |
| 394 return isSupertypeOfNativeClass(element); | 394 return isSupertypeOfNativeClass(element); |
| 395 } | 395 } |
| 396 | 396 |
| 397 void emitIsChecks(Map<String, String> objectProperties) { | 397 void emitIsChecks(Map<String, String> objectProperties) { |
| 398 for (Element element in emitter.checkedClasses) { | 398 for (Element element in emitter.checkedClasses) { |
| 399 if (!requiresNativeIsCheck(element)) continue; | 399 if (!requiresNativeIsCheck(element)) continue; |
| 400 if (element.isObject(compiler)) return; | 400 if (element.isObject(compiler)) continue; |
| 401 String name = backend.namer.operatorIs(element); | 401 String name = backend.namer.operatorIs(element); |
| 402 objectProperties[name] = 'function() { return false; }'; | 402 objectProperties[name] = 'function() { return false; }'; |
| 403 } | 403 } |
| 404 } | 404 } |
| 405 | 405 |
| 406 void assembleCode(CodeBuffer targetBuffer) { | 406 void assembleCode(CodeBuffer targetBuffer) { |
| 407 if (nativeClasses.isEmpty()) return; | 407 if (nativeClasses.isEmpty()) return; |
| 408 emitDynamicDispatchMetadata(); | 408 emitDynamicDispatchMetadata(); |
| 409 targetBuffer.add('$defineNativeClassName = ' | 409 targetBuffer.add('$defineNativeClassName = ' |
| 410 '$defineNativeClassFunction;\n\n'); | 410 '$defineNativeClassFunction;\n\n'); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 if (!first) targetBuffer.add(",\n"); | 451 if (!first) targetBuffer.add(",\n"); |
| 452 targetBuffer.add(" $name: $function"); | 452 targetBuffer.add(" $name: $function"); |
| 453 first = false; | 453 first = false; |
| 454 }); | 454 }); |
| 455 targetBuffer.add("\n});\n\n"); | 455 targetBuffer.add("\n});\n\n"); |
| 456 } | 456 } |
| 457 targetBuffer.add('$nativeBuffer'); | 457 targetBuffer.add('$nativeBuffer'); |
| 458 targetBuffer.add('\n'); | 458 targetBuffer.add('\n'); |
| 459 } | 459 } |
| 460 } | 460 } |
| OLD | NEW |