Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(350)

Side by Side Diff: pkg/compiler/lib/src/native/enqueue.dart

Issue 1892183002: Refactor Parsing to remove compiler dependency (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/compiler/lib/src/native/behavior.dart ('k') | pkg/compiler/lib/src/parser/parser_task.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 backend.nativeData.setNativeMemberName(element, name); 459 backend.nativeData.setNativeMemberName(element, name);
460 } 460 }
461 } 461 }
462 462
463 bool isIdentifier(String s) => _identifier.hasMatch(s); 463 bool isIdentifier(String s) => _identifier.hasMatch(s);
464 464
465 bool isNativeMethod(FunctionElementX element) { 465 bool isNativeMethod(FunctionElementX element) {
466 if (!backend.canLibraryUseNative(element.library)) return false; 466 if (!backend.canLibraryUseNative(element.library)) return false;
467 // Native method? 467 // Native method?
468 return reporter.withCurrentElement(element, () { 468 return reporter.withCurrentElement(element, () {
469 Node node = element.parseNode(resolution.parsing); 469 Node node = element.parseNode(resolution.parsingContext);
470 if (node is! FunctionExpression) return false; 470 if (node is! FunctionExpression) return false;
471 FunctionExpression functionExpression = node; 471 FunctionExpression functionExpression = node;
472 node = functionExpression.body; 472 node = functionExpression.body;
473 Token token = node.getBeginToken(); 473 Token token = node.getBeginToken();
474 if (identical(token.stringValue, 'native')) return true; 474 if (identical(token.stringValue, 'native')) return true;
475 return false; 475 return false;
476 }); 476 });
477 } 477 }
478 478
479 void registerNativeBehavior(NativeBehavior nativeBehavior, cause) { 479 void registerNativeBehavior(NativeBehavior nativeBehavior, cause) {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 * Handles JS-calls, which can be an instantiation point for types. 608 * Handles JS-calls, which can be an instantiation point for types.
609 * 609 *
610 * For example, the following code instantiates and returns native classes 610 * For example, the following code instantiates and returns native classes
611 * that are `_DOMWindowImpl` or a subtype. 611 * that are `_DOMWindowImpl` or a subtype.
612 * 612 *
613 * JS('_DOMWindowImpl', 'window') 613 * JS('_DOMWindowImpl', 'window')
614 * 614 *
615 */ 615 */
616 void registerJsCall(Send node, ForeignResolver resolver) { 616 void registerJsCall(Send node, ForeignResolver resolver) {
617 NativeBehavior behavior = NativeBehavior.ofJsCall( 617 NativeBehavior behavior = NativeBehavior.ofJsCall(
618 node, reporter, compiler.parsing, compiler.coreTypes, resolver); 618 node, reporter, compiler.parsingContext, compiler.coreTypes, resolver);
619 registerNativeBehavior(behavior, node); 619 registerNativeBehavior(behavior, node);
620 nativeBehaviors[node] = behavior; 620 nativeBehaviors[node] = behavior;
621 } 621 }
622 622
623 /** 623 /**
624 * Handles JS-embedded global calls, which can be an instantiation point for 624 * Handles JS-embedded global calls, which can be an instantiation point for
625 * types. 625 * types.
626 * 626 *
627 * For example, the following code instantiates and returns a String class 627 * For example, the following code instantiates and returns a String class
628 * 628 *
629 * JS_EMBEDDED_GLOBAL('String', 'foo') 629 * JS_EMBEDDED_GLOBAL('String', 'foo')
630 * 630 *
631 */ 631 */
632 void registerJsEmbeddedGlobalCall(Send node, ForeignResolver resolver) { 632 void registerJsEmbeddedGlobalCall(Send node, ForeignResolver resolver) {
633 NativeBehavior behavior = NativeBehavior.ofJsEmbeddedGlobalCall( 633 NativeBehavior behavior = NativeBehavior.ofJsEmbeddedGlobalCall(
634 node, reporter, compiler.parsing, compiler.coreTypes, resolver); 634 node, reporter, compiler.parsingContext, compiler.coreTypes, resolver);
635 registerNativeBehavior(behavior, node); 635 registerNativeBehavior(behavior, node);
636 nativeBehaviors[node] = behavior; 636 nativeBehaviors[node] = behavior;
637 } 637 }
638 638
639 /** 639 /**
640 * Handles JS-compiler builtin calls, which can be an instantiation point for 640 * Handles JS-compiler builtin calls, which can be an instantiation point for
641 * types. 641 * types.
642 * 642 *
643 * For example, the following code instantiates and returns a String class 643 * For example, the following code instantiates and returns a String class
644 * 644 *
645 * JS_BUILTIN('String', 'int2string', 0) 645 * JS_BUILTIN('String', 'int2string', 0)
646 * 646 *
647 */ 647 */
648 void registerJsBuiltinCall(Send node, ForeignResolver resolver) { 648 void registerJsBuiltinCall(Send node, ForeignResolver resolver) {
649 NativeBehavior behavior = NativeBehavior.ofJsBuiltinCall( 649 NativeBehavior behavior = NativeBehavior.ofJsBuiltinCall(
650 node, reporter, compiler.parsing, compiler.coreTypes, resolver); 650 node, reporter, compiler.parsingContext, compiler.coreTypes, resolver);
651 registerNativeBehavior(behavior, node); 651 registerNativeBehavior(behavior, node);
652 nativeBehaviors[node] = behavior; 652 nativeBehaviors[node] = behavior;
653 } 653 }
654 } 654 }
655 655
656 class NativeCodegenEnqueuer extends NativeEnqueuerBase { 656 class NativeCodegenEnqueuer extends NativeEnqueuerBase {
657 final CodeEmitterTask emitter; 657 final CodeEmitterTask emitter;
658 658
659 final Set<ClassElement> doneAddSubtypes = new Set<ClassElement>(); 659 final Set<ClassElement> doneAddSubtypes = new Set<ClassElement>();
660 660
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 List<Element> directSubtypes = 708 List<Element> directSubtypes =
709 emitter.directSubtypes.putIfAbsent(superclass, () => <ClassElement>[]); 709 emitter.directSubtypes.putIfAbsent(superclass, () => <ClassElement>[]);
710 directSubtypes.add(cls); 710 directSubtypes.add(cls);
711 } 711 }
712 712
713 void logSummary(log(message)) { 713 void logSummary(log(message)) {
714 log('Compiled ${registeredClasses.length} native classes, ' 714 log('Compiled ${registeredClasses.length} native classes, '
715 '${unusedClasses.length} native classes omitted.'); 715 '${unusedClasses.length} native classes omitted.');
716 } 716 }
717 } 717 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/native/behavior.dart ('k') | pkg/compiler/lib/src/parser/parser_task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698