Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 import 'dart:collection' show Queue; | 5 import 'dart:collection' show Queue; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/backend_api.dart' show ForeignResolver; | 8 import '../common/backend_api.dart' show ForeignResolver; |
| 9 import '../common/registry.dart' show Registry; | 9 import '../common/registry.dart' show Registry; |
| 10 import '../common/resolution.dart' show Resolution; | 10 import '../common/resolution.dart' show Resolution; |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 599 /** | 599 /** |
| 600 * Handles JS-calls, which can be an instantiation point for types. | 600 * Handles JS-calls, which can be an instantiation point for types. |
| 601 * | 601 * |
| 602 * For example, the following code instantiates and returns native classes | 602 * For example, the following code instantiates and returns native classes |
| 603 * that are `_DOMWindowImpl` or a subtype. | 603 * that are `_DOMWindowImpl` or a subtype. |
| 604 * | 604 * |
| 605 * JS('_DOMWindowImpl', 'window') | 605 * JS('_DOMWindowImpl', 'window') |
| 606 * | 606 * |
| 607 */ | 607 */ |
| 608 NativeBehavior resolveJsCall(Send node, ForeignResolver resolver) { | 608 NativeBehavior resolveJsCall(Send node, ForeignResolver resolver) { |
| 609 NativeBehavior behavior = NativeBehavior.ofJsCall( | 609 NativeBehavior behavior = NativeBehavior.ofJsCall( |
|
Siggi Cherem (dart-lang)
2016/05/10 01:06:18
nit: remove the extra var... possibly remove {} to
Johnni Winther
2016/05/10 09:26:42
Done.
| |
| 610 node, reporter, compiler.parsingContext, compiler.coreTypes, resolver); | 610 node, reporter, compiler.parsingContext, compiler.coreTypes, resolver); |
| 611 // TODO(johnniwinther): Move registration to the world impact application. | |
| 612 registerNativeBehavior(behavior, node); | |
| 613 return behavior; | 611 return behavior; |
| 614 } | 612 } |
| 615 | 613 |
| 616 /** | 614 /** |
| 617 * Handles JS-embedded global calls, which can be an instantiation point for | 615 * Handles JS-embedded global calls, which can be an instantiation point for |
| 618 * types. | 616 * types. |
| 619 * | 617 * |
| 620 * For example, the following code instantiates and returns a String class | 618 * For example, the following code instantiates and returns a String class |
| 621 * | 619 * |
| 622 * JS_EMBEDDED_GLOBAL('String', 'foo') | 620 * JS_EMBEDDED_GLOBAL('String', 'foo') |
| 623 * | 621 * |
| 624 */ | 622 */ |
| 625 NativeBehavior resolveJsEmbeddedGlobalCall( | 623 NativeBehavior resolveJsEmbeddedGlobalCall( |
| 626 Send node, ForeignResolver resolver) { | 624 Send node, ForeignResolver resolver) { |
| 627 NativeBehavior behavior = NativeBehavior.ofJsEmbeddedGlobalCall( | 625 NativeBehavior behavior = NativeBehavior.ofJsEmbeddedGlobalCall( |
| 628 node, reporter, compiler.parsingContext, compiler.coreTypes, resolver); | 626 node, reporter, compiler.parsingContext, compiler.coreTypes, resolver); |
| 629 // TODO(johnniwinther): Move registration to the world impact application. | |
| 630 registerNativeBehavior(behavior, node); | |
| 631 return behavior; | 627 return behavior; |
| 632 } | 628 } |
| 633 | 629 |
| 634 /** | 630 /** |
| 635 * Handles JS-compiler builtin calls, which can be an instantiation point for | 631 * Handles JS-compiler builtin calls, which can be an instantiation point for |
| 636 * types. | 632 * types. |
| 637 * | 633 * |
| 638 * For example, the following code instantiates and returns a String class | 634 * For example, the following code instantiates and returns a String class |
| 639 * | 635 * |
| 640 * JS_BUILTIN('String', 'int2string', 0) | 636 * JS_BUILTIN('String', 'int2string', 0) |
| 641 * | 637 * |
| 642 */ | 638 */ |
| 643 NativeBehavior resolveJsBuiltinCall(Send node, ForeignResolver resolver) { | 639 NativeBehavior resolveJsBuiltinCall(Send node, ForeignResolver resolver) { |
| 644 NativeBehavior behavior = NativeBehavior.ofJsBuiltinCall( | 640 NativeBehavior behavior = NativeBehavior.ofJsBuiltinCall( |
| 645 node, reporter, compiler.parsingContext, compiler.coreTypes, resolver); | 641 node, reporter, compiler.parsingContext, compiler.coreTypes, resolver); |
| 646 // TODO(johnniwinther): Move registration to the world impact application. | |
| 647 registerNativeBehavior(behavior, node); | |
| 648 return behavior; | 642 return behavior; |
| 649 } | 643 } |
| 650 } | 644 } |
| 651 | 645 |
| 652 class NativeCodegenEnqueuer extends NativeEnqueuerBase { | 646 class NativeCodegenEnqueuer extends NativeEnqueuerBase { |
| 653 final CodeEmitterTask emitter; | 647 final CodeEmitterTask emitter; |
| 654 | 648 |
| 655 final Set<ClassElement> doneAddSubtypes = new Set<ClassElement>(); | 649 final Set<ClassElement> doneAddSubtypes = new Set<ClassElement>(); |
| 656 | 650 |
| 657 NativeCodegenEnqueuer(Enqueuer world, Compiler compiler, this.emitter) | 651 NativeCodegenEnqueuer(Enqueuer world, Compiler compiler, this.emitter) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 704 List<Element> directSubtypes = | 698 List<Element> directSubtypes = |
| 705 emitter.directSubtypes.putIfAbsent(superclass, () => <ClassElement>[]); | 699 emitter.directSubtypes.putIfAbsent(superclass, () => <ClassElement>[]); |
| 706 directSubtypes.add(cls); | 700 directSubtypes.add(cls); |
| 707 } | 701 } |
| 708 | 702 |
| 709 void logSummary(log(message)) { | 703 void logSummary(log(message)) { |
| 710 log('Compiled ${registeredClasses.length} native classes, ' | 704 log('Compiled ${registeredClasses.length} native classes, ' |
| 711 '${unusedClasses.length} native classes omitted.'); | 705 '${unusedClasses.length} native classes omitted.'); |
| 712 } | 706 } |
| 713 } | 707 } |
| OLD | NEW |