| 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 return NativeBehavior.ofJsCall( |
| 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; | |
| 614 } | 611 } |
| 615 | 612 |
| 616 /** | 613 /** |
| 617 * Handles JS-embedded global calls, which can be an instantiation point for | 614 * Handles JS-embedded global calls, which can be an instantiation point for |
| 618 * types. | 615 * types. |
| 619 * | 616 * |
| 620 * For example, the following code instantiates and returns a String class | 617 * For example, the following code instantiates and returns a String class |
| 621 * | 618 * |
| 622 * JS_EMBEDDED_GLOBAL('String', 'foo') | 619 * JS_EMBEDDED_GLOBAL('String', 'foo') |
| 623 * | 620 * |
| 624 */ | 621 */ |
| 625 NativeBehavior resolveJsEmbeddedGlobalCall( | 622 NativeBehavior resolveJsEmbeddedGlobalCall( |
| 626 Send node, ForeignResolver resolver) { | 623 Send node, ForeignResolver resolver) { |
| 627 NativeBehavior behavior = NativeBehavior.ofJsEmbeddedGlobalCall( | 624 return NativeBehavior.ofJsEmbeddedGlobalCall( |
| 628 node, reporter, compiler.parsingContext, compiler.coreTypes, resolver); | 625 node, reporter, compiler.parsingContext, compiler.coreTypes, resolver); |
| 629 // TODO(johnniwinther): Move registration to the world impact application. | |
| 630 registerNativeBehavior(behavior, node); | |
| 631 return behavior; | |
| 632 } | 626 } |
| 633 | 627 |
| 634 /** | 628 /** |
| 635 * Handles JS-compiler builtin calls, which can be an instantiation point for | 629 * Handles JS-compiler builtin calls, which can be an instantiation point for |
| 636 * types. | 630 * types. |
| 637 * | 631 * |
| 638 * For example, the following code instantiates and returns a String class | 632 * For example, the following code instantiates and returns a String class |
| 639 * | 633 * |
| 640 * JS_BUILTIN('String', 'int2string', 0) | 634 * JS_BUILTIN('String', 'int2string', 0) |
| 641 * | 635 * |
| 642 */ | 636 */ |
| 643 NativeBehavior resolveJsBuiltinCall(Send node, ForeignResolver resolver) { | 637 NativeBehavior resolveJsBuiltinCall(Send node, ForeignResolver resolver) { |
| 644 NativeBehavior behavior = NativeBehavior.ofJsBuiltinCall( | 638 return NativeBehavior.ofJsBuiltinCall( |
| 645 node, reporter, compiler.parsingContext, compiler.coreTypes, resolver); | 639 node, reporter, compiler.parsingContext, compiler.coreTypes, resolver); |
| 646 // TODO(johnniwinther): Move registration to the world impact application. | |
| 647 registerNativeBehavior(behavior, node); | |
| 648 return behavior; | |
| 649 } | 640 } |
| 650 } | 641 } |
| 651 | 642 |
| 652 class NativeCodegenEnqueuer extends NativeEnqueuerBase { | 643 class NativeCodegenEnqueuer extends NativeEnqueuerBase { |
| 653 final CodeEmitterTask emitter; | 644 final CodeEmitterTask emitter; |
| 654 | 645 |
| 655 final Set<ClassElement> doneAddSubtypes = new Set<ClassElement>(); | 646 final Set<ClassElement> doneAddSubtypes = new Set<ClassElement>(); |
| 656 | 647 |
| 657 NativeCodegenEnqueuer(Enqueuer world, Compiler compiler, this.emitter) | 648 NativeCodegenEnqueuer(Enqueuer world, Compiler compiler, this.emitter) |
| 658 : super(world, compiler, compiler.options.enableNativeLiveTypeAnalysis); | 649 : super(world, compiler, compiler.options.enableNativeLiveTypeAnalysis); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 List<Element> directSubtypes = | 695 List<Element> directSubtypes = |
| 705 emitter.directSubtypes.putIfAbsent(superclass, () => <ClassElement>[]); | 696 emitter.directSubtypes.putIfAbsent(superclass, () => <ClassElement>[]); |
| 706 directSubtypes.add(cls); | 697 directSubtypes.add(cls); |
| 707 } | 698 } |
| 708 | 699 |
| 709 void logSummary(log(message)) { | 700 void logSummary(log(message)) { |
| 710 log('Compiled ${registeredClasses.length} native classes, ' | 701 log('Compiled ${registeredClasses.length} native classes, ' |
| 711 '${unusedClasses.length} native classes omitted.'); | 702 '${unusedClasses.length} native classes omitted.'); |
| 712 } | 703 } |
| 713 } | 704 } |
| OLD | NEW |