| 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 StringBuffer nativeBuffer; | 8 StringBuffer nativeBuffer; |
| 9 | 9 |
| 10 // Classes that participate in dynamic dispatch. These are the | 10 // Classes that participate in dynamic dispatch. These are the |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 } | 353 } |
| 354 | 354 |
| 355 bool requiresNativeIsCheck(Element element) { | 355 bool requiresNativeIsCheck(Element element) { |
| 356 if (!element.isClass()) return false; | 356 if (!element.isClass()) return false; |
| 357 ClassElement cls = element; | 357 ClassElement cls = element; |
| 358 if (cls.isNative()) return true; | 358 if (cls.isNative()) return true; |
| 359 return isSupertypeOfNativeClass(element); | 359 return isSupertypeOfNativeClass(element); |
| 360 } | 360 } |
| 361 | 361 |
| 362 void emitIsChecks(StringBuffer checkBuffer) { | 362 void emitIsChecks(StringBuffer checkBuffer) { |
| 363 for (Element type in compiler.universe.isChecks) { | 363 for (Element type in compiler.codegenWorld.isChecks) { |
| 364 if (!requiresNativeIsCheck(type)) continue; | 364 if (!requiresNativeIsCheck(type)) continue; |
| 365 String name = compiler.namer.operatorIs(type); | 365 String name = compiler.namer.operatorIs(type); |
| 366 checkBuffer.add("$defPropName(Object.prototype, '$name', "); | 366 checkBuffer.add("$defPropName(Object.prototype, '$name', "); |
| 367 checkBuffer.add('function() { return false; });\n'); | 367 checkBuffer.add('function() { return false; });\n'); |
| 368 } | 368 } |
| 369 } | 369 } |
| 370 | 370 |
| 371 void assembleCode(StringBuffer targetBuffer) { | 371 void assembleCode(StringBuffer targetBuffer) { |
| 372 if (nativeClasses.isEmpty()) return; | 372 if (nativeClasses.isEmpty()) return; |
| 373 emitDynamicDispatchMetadata(); | 373 emitDynamicDispatchMetadata(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 385 String toStringName = compiler.namer.instanceMethodName( | 385 String toStringName = compiler.namer.instanceMethodName( |
| 386 null, const SourceString('toString'), 0); | 386 null, const SourceString('toString'), 0); |
| 387 objectProperties.add("$defPropName(Object.prototype, '$toStringName', "); | 387 objectProperties.add("$defPropName(Object.prototype, '$toStringName', "); |
| 388 objectProperties.add( | 388 objectProperties.add( |
| 389 'function() { return $toStringHelperName(this); });\n'); | 389 'function() { return $toStringHelperName(this); });\n'); |
| 390 | 390 |
| 391 targetBuffer.add('$defineNativeClassName = $defineNativeClassFunction;\n'); | 391 targetBuffer.add('$defineNativeClassName = $defineNativeClassFunction;\n'); |
| 392 targetBuffer.add('$objectProperties$nativeBuffer\n'); | 392 targetBuffer.add('$objectProperties$nativeBuffer\n'); |
| 393 } | 393 } |
| 394 } | 394 } |
| OLD | NEW |