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 CodeBuffer nativeBuffer; | 8 CodeBuffer nativeBuffer; |
9 | 9 |
10 // Classes that participate in dynamic dispatch. These are the | 10 // Classes that participate in dynamic dispatch. These are the |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
405 // Because of native classes, we have to generate some is checks | 405 // Because of native classes, we have to generate some is checks |
406 // by calling a method, instead of accessing a property. So we | 406 // by calling a method, instead of accessing a property. So we |
407 // attach to the JS Object prototype these methods that return | 407 // attach to the JS Object prototype these methods that return |
408 // false, and will be overridden by subclasses when they have to | 408 // false, and will be overridden by subclasses when they have to |
409 // return true. | 409 // return true. |
410 Map<String, String> objectProperties = new Map<String, String>(); | 410 Map<String, String> objectProperties = new Map<String, String>(); |
411 emitIsChecks(objectProperties); | 411 emitIsChecks(objectProperties); |
412 | 412 |
413 // In order to have the toString method on every native class, | 413 // In order to have the toString method on every native class, |
414 // we must patch the JS Object prototype with a helper method. | 414 // we must patch the JS Object prototype with a helper method. |
415 String toStringName = backend.namer.instanceMethodName( | 415 String toStringName = backend.namer.instanceMethodNameByArity( |
ahe
2012/09/13 14:29:10
Maybe rename to publicInstanceMethodByArity?
ngeoffray
2012/09/17 12:21:01
Done.
| |
416 null, const SourceString('toString'), 0); | 416 const SourceString('toString'), 0); |
417 objectProperties[toStringName] = | 417 objectProperties[toStringName] = |
418 'function() { return $toStringHelperName(this); }'; | 418 'function() { return $toStringHelperName(this); }'; |
419 | 419 |
420 // If the native emitter has been asked to take care of the | 420 // If the native emitter has been asked to take care of the |
421 // noSuchMethod handlers, we do that now. | 421 // noSuchMethod handlers, we do that now. |
422 if (handleNoSuchMethod) { | 422 if (handleNoSuchMethod) { |
423 emitter.emitNoSuchMethodHandlers((String name, CodeBuffer buffer) { | 423 emitter.emitNoSuchMethodHandlers((String name, CodeBuffer buffer) { |
424 objectProperties[name] = buffer.toString(); | 424 objectProperties[name] = buffer.toString(); |
425 }); | 425 }); |
426 } | 426 } |
(...skipping 11 matching lines...) Expand all Loading... | |
438 if (!first) targetBuffer.add(",\n"); | 438 if (!first) targetBuffer.add(",\n"); |
439 targetBuffer.add(" $name: $function"); | 439 targetBuffer.add(" $name: $function"); |
440 first = false; | 440 first = false; |
441 }); | 441 }); |
442 targetBuffer.add("\n});\n\n"); | 442 targetBuffer.add("\n});\n\n"); |
443 } | 443 } |
444 targetBuffer.add('$nativeBuffer'); | 444 targetBuffer.add('$nativeBuffer'); |
445 targetBuffer.add('\n'); | 445 targetBuffer.add('\n'); |
446 } | 446 } |
447 } | 447 } |
OLD | NEW |