Chromium Code Reviews| 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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 533 emitIsChecks(objectProperties); | 533 emitIsChecks(objectProperties); |
| 534 | 534 |
| 535 // In order to have the toString method on every native class, | 535 // In order to have the toString method on every native class, |
| 536 // we must patch the JS Object prototype with a helper method. | 536 // we must patch the JS Object prototype with a helper method. |
| 537 String toStringName = backend.namer.publicInstanceMethodNameByArity( | 537 String toStringName = backend.namer.publicInstanceMethodNameByArity( |
| 538 const SourceString('toString'), 0); | 538 const SourceString('toString'), 0); |
| 539 objectProperties[toStringName] = | 539 objectProperties[toStringName] = |
| 540 'function() { return $toStringHelperName(this); }'; | 540 'function() { return $toStringHelperName(this); }'; |
| 541 | 541 |
| 542 // Same as above, but for hashCode. | 542 // Same as above, but for hashCode. |
| 543 String hashCodeName = backend.namer.publicGetterName( | 543 String hashCodeName = backend.namer.publicGetterName(new SourceString('hashC ode')); |
|
sra1
2012/12/07 06:03:18
const SourceString(...)
erikcorry
2012/12/10 08:36:01
Done.
| |
| 544 const SourceString('hashCode')); | |
| 545 objectProperties[hashCodeName] = | 544 objectProperties[hashCodeName] = |
| 546 'function() { return $hashCodeHelperName(this); }'; | 545 'function() { return $hashCodeHelperName(this); }'; |
| 547 | 546 |
| 548 // If the native emitter has been asked to take care of the | 547 // If the native emitter has been asked to take care of the |
| 549 // noSuchMethod handlers, we do that now. | 548 // noSuchMethod handlers, we do that now. |
| 550 if (handleNoSuchMethod) { | 549 if (handleNoSuchMethod) { |
| 551 emitter.emitNoSuchMethodHandlers((String name, CodeBuffer buffer) { | 550 emitter.emitNoSuchMethodHandlers((String name, CodeBuffer buffer) { |
| 552 objectProperties[name] = buffer.toString(); | 551 objectProperties[name] = buffer.toString(); |
| 553 }); | 552 }); |
| 554 } | 553 } |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 566 if (!first) targetBuffer.add(",\n"); | 565 if (!first) targetBuffer.add(",\n"); |
| 567 targetBuffer.add(" $name: $function"); | 566 targetBuffer.add(" $name: $function"); |
| 568 first = false; | 567 first = false; |
| 569 }); | 568 }); |
| 570 targetBuffer.add("\n});\n\n"); | 569 targetBuffer.add("\n});\n\n"); |
| 571 } | 570 } |
| 572 targetBuffer.add(nativeBuffer); | 571 targetBuffer.add(nativeBuffer); |
| 573 targetBuffer.add('\n'); | 572 targetBuffer.add('\n'); |
| 574 } | 573 } |
| 575 } | 574 } |
| OLD | NEW |