| 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 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 // Because of native classes, we have to generate some is checks | 469 // Because of native classes, we have to generate some is checks |
| 470 // by calling a method, instead of accessing a property. So we | 470 // by calling a method, instead of accessing a property. So we |
| 471 // attach to the JS Object prototype these methods that return | 471 // attach to the JS Object prototype these methods that return |
| 472 // false, and will be overridden by subclasses when they have to | 472 // false, and will be overridden by subclasses when they have to |
| 473 // return true. | 473 // return true. |
| 474 void emitIsChecks() { | 474 void emitIsChecks() { |
| 475 for (ClassElement element in | 475 for (ClassElement element in |
| 476 Elements.sortedByPosition(emitter.checkedClasses)) { | 476 Elements.sortedByPosition(emitter.checkedClasses)) { |
| 477 if (!requiresNativeIsCheck(element)) continue; | 477 if (!requiresNativeIsCheck(element)) continue; |
| 478 if (element.isObject(compiler)) continue; | 478 if (element.isObject(compiler)) continue; |
| 479 // Add function for the is-test. |
| 479 String name = backend.namer.operatorIs(element); | 480 String name = backend.namer.operatorIs(element); |
| 480 addProperty(name, | 481 addProperty(name, |
| 481 js.fun([], js.return_(js['false']))); | 482 js.fun([], js.return_(js['false']))); |
| 483 // Add a function for the (trivial) substitution. |
| 484 addProperty(backend.namer.substitutionName(element), |
| 485 js.fun([], js.return_(js['null']))); |
| 482 } | 486 } |
| 483 } | 487 } |
| 484 emitIsChecks(); | 488 emitIsChecks(); |
| 485 | 489 |
| 486 jsAst.Expression makeCallOnThis(String functionName) { | 490 jsAst.Expression makeCallOnThis(String functionName) { |
| 487 // Because we know the function is intercepted, we need an extra | 491 // Because we know the function is intercepted, we need an extra |
| 488 // parameter. | 492 // parameter. |
| 489 return js.fun(['_'], js.return_(js['$functionName(this)'])); | 493 return js.fun(['_'], js.return_(js['$functionName(this)'])); |
| 490 } | 494 } |
| 491 | 495 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 if (emitter.compiler.enableMinification) targetBuffer.add(';'); | 536 if (emitter.compiler.enableMinification) targetBuffer.add(';'); |
| 533 targetBuffer.add(jsAst.prettyPrint( | 537 targetBuffer.add(jsAst.prettyPrint( |
| 534 new jsAst.ExpressionStatement(init), compiler)); | 538 new jsAst.ExpressionStatement(init), compiler)); |
| 535 targetBuffer.add('\n'); | 539 targetBuffer.add('\n'); |
| 536 } | 540 } |
| 537 | 541 |
| 538 targetBuffer.add(nativeBuffer); | 542 targetBuffer.add(nativeBuffer); |
| 539 targetBuffer.add('\n'); | 543 targetBuffer.add('\n'); |
| 540 } | 544 } |
| 541 } | 545 } |
| OLD | NEW |