| 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 CodeEmitterTask emitter; | 9 CodeEmitterTask emitter; |
| 10 CodeBuffer nativeBuffer; | 10 CodeBuffer nativeBuffer; |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 // The element type is a function type either directly or through | 463 // The element type is a function type either directly or through |
| 464 // typedef(s). | 464 // typedef(s). |
| 465 return false; | 465 return false; |
| 466 } | 466 } |
| 467 | 467 |
| 468 if (!element.isClass()) { | 468 if (!element.isClass()) { |
| 469 compiler.cancel("Is check does not handle element", element: element); | 469 compiler.cancel("Is check does not handle element", element: element); |
| 470 return false; | 470 return false; |
| 471 } | 471 } |
| 472 | 472 |
| 473 if (backend.classesMixedIntoNativeClasses.contains(element)) return true; |
| 474 |
| 473 return subtypes[element] != null; | 475 return subtypes[element] != null; |
| 474 } | 476 } |
| 475 | 477 |
| 476 bool requiresNativeIsCheck(Element element) { | 478 bool requiresNativeIsCheck(Element element) { |
| 477 // TODO(sra): Remove this function. It determines if a native type may | 479 // TODO(sra): Remove this function. It determines if a native type may |
| 478 // satisfy a check against [element], in whcih case an interceptor must be | 480 // satisfy a check against [element], in which case an interceptor must be |
| 479 // used. We should also use an interceptor if the check can't be satisfied | 481 // used. We should also use an interceptor if the check can't be satisfied |
| 480 // by a native class in case we get a natibe instance that tries to spoof | 482 // by a native class in case we get a native instance that tries to spoof |
| 481 // the type info. i.e the criteria for whether or not to use an interceptor | 483 // the type info. i.e the criteria for whether or not to use an interceptor |
| 482 // is whether the receiver can be native, not the type of the test. | 484 // is whether the receiver can be native, not the type of the test. |
| 483 if (!element.isClass()) return false; | 485 if (!element.isClass()) return false; |
| 484 ClassElement cls = element; | 486 ClassElement cls = element; |
| 485 if (cls.isNative()) return true; | 487 if (Elements.isNativeOrExtendsNative(cls)) return true; |
| 486 return isSupertypeOfNativeClass(element); | 488 return isSupertypeOfNativeClass(element); |
| 487 } | 489 } |
| 488 | 490 |
| 489 void assembleCode(CodeBuffer targetBuffer) { | 491 void assembleCode(CodeBuffer targetBuffer) { |
| 490 List<jsAst.Property> objectProperties = <jsAst.Property>[]; | 492 List<jsAst.Property> objectProperties = <jsAst.Property>[]; |
| 491 | 493 |
| 492 void addProperty(String name, jsAst.Expression value) { | 494 void addProperty(String name, jsAst.Expression value) { |
| 493 objectProperties.add(new jsAst.Property(js.string(name), value)); | 495 objectProperties.add(new jsAst.Property(js.string(name), value)); |
| 494 } | 496 } |
| 495 | 497 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 519 if (emitter.compiler.enableMinification) targetBuffer.add(';'); | 521 if (emitter.compiler.enableMinification) targetBuffer.add(';'); |
| 520 targetBuffer.add(jsAst.prettyPrint( | 522 targetBuffer.add(jsAst.prettyPrint( |
| 521 new jsAst.ExpressionStatement(init), compiler)); | 523 new jsAst.ExpressionStatement(init), compiler)); |
| 522 targetBuffer.add('\n'); | 524 targetBuffer.add('\n'); |
| 523 } | 525 } |
| 524 | 526 |
| 525 targetBuffer.add(nativeBuffer); | 527 targetBuffer.add(nativeBuffer); |
| 526 targetBuffer.add('\n'); | 528 targetBuffer.add('\n'); |
| 527 } | 529 } |
| 528 } | 530 } |
| OLD | NEW |