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