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

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

Issue 954253002: dart2js: add compiler builtins to the core-runtime. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Move more foreigns to builtins. Created 5 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 | Annotate | Revision Log
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 part of native; 5 part of native;
6 6
7 /** 7 /**
8 * This could be an abstract class but we use it as a stub for the dart_backend. 8 * This could be an abstract class but we use it as a stub for the dart_backend.
9 */ 9 */
10 class NativeEnqueuer { 10 class NativeEnqueuer {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 * types. 47 * types.
48 * 48 *
49 * For example, the following code instantiates and returns a String class 49 * For example, the following code instantiates and returns a String class
50 * 50 *
51 * JS_EMBEDDED_GLOBAL('String', 'foo') 51 * JS_EMBEDDED_GLOBAL('String', 'foo')
52 * 52 *
53 */ 53 */
54 // TODO(sra): The entry from codegen will not have a resolver. 54 // TODO(sra): The entry from codegen will not have a resolver.
55 void registerJsEmbeddedGlobalCall(Send node, ResolverVisitor resolver) {} 55 void registerJsEmbeddedGlobalCall(Send node, ResolverVisitor resolver) {}
56 56
57 /**
58 * Handles JS-compiler builtin calls, which can be an instantiation point for
59 * types.
60 *
61 * For example, the following code instantiates and returns a String class
62 *
63 * JS_BUILTIN('String', 'int2string', 0)
64 *
65 */
66 // TODO(sra): The entry from codegen will not have a resolver.
67 void registerJsBuiltinCall(Send node, ResolverVisitor resolver) {}
68
57 /// Emits a summary information using the [log] function. 69 /// Emits a summary information using the [log] function.
58 void logSummary(log(message)) {} 70 void logSummary(log(message)) {}
59 71
60 // Do not use annotations in dart2dart. 72 // Do not use annotations in dart2dart.
61 ClassElement get annotationCreatesClass => null; 73 ClassElement get annotationCreatesClass => null;
62 ClassElement get annotationReturnsClass => null; 74 ClassElement get annotationReturnsClass => null;
63 ClassElement get annotationJsNameClass => null; 75 ClassElement get annotationJsNameClass => null;
64 } 76 }
65 77
66 78
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 } 497 }
486 498
487 void registerJsEmbeddedGlobalCall(Send node, ResolverVisitor resolver) { 499 void registerJsEmbeddedGlobalCall(Send node, ResolverVisitor resolver) {
488 NativeBehavior behavior = 500 NativeBehavior behavior =
489 NativeBehavior.ofJsEmbeddedGlobalCall(node, compiler, resolver); 501 NativeBehavior.ofJsEmbeddedGlobalCall(node, compiler, resolver);
490 processNativeBehavior(behavior, node); 502 processNativeBehavior(behavior, node);
491 nativeBehaviors[node] = behavior; 503 nativeBehaviors[node] = behavior;
492 flushQueue(); 504 flushQueue();
493 } 505 }
494 506
507 void registerJsBuiltinCall(Send node, ResolverVisitor resolver) {
508 NativeBehavior behavior =
509 NativeBehavior.ofJsBuiltinCall(node, compiler, resolver);
510 processNativeBehavior(behavior, node);
511 nativeBehaviors[node] = behavior;
512 flushQueue();
513 }
514
495 NativeBehavior getNativeBehaviorOf(Send node) => nativeBehaviors[node]; 515 NativeBehavior getNativeBehaviorOf(Send node) => nativeBehaviors[node];
496 516
497 processNativeBehavior(NativeBehavior behavior, cause) { 517 processNativeBehavior(NativeBehavior behavior, cause) {
498 // TODO(ahe): Is this really a global dependency? 518 // TODO(ahe): Is this really a global dependency?
499 Registry registry = compiler.globalDependencies; 519 Registry registry = compiler.globalDependencies;
500 bool allUsedBefore = unusedClasses.isEmpty; 520 bool allUsedBefore = unusedClasses.isEmpty;
501 for (var type in behavior.typesInstantiated) { 521 for (var type in behavior.typesInstantiated) {
502 if (matchedTypeConstraints.contains(type)) continue; 522 if (matchedTypeConstraints.contains(type)) continue;
503 matchedTypeConstraints.add(type); 523 matchedTypeConstraints.add(type);
504 if (type is SpecialType) { 524 if (type is SpecialType) {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 superclass, 683 superclass,
664 () => <ClassElement>[]); 684 () => <ClassElement>[]);
665 directSubtypes.add(cls); 685 directSubtypes.add(cls);
666 } 686 }
667 687
668 void logSummary(log(message)) { 688 void logSummary(log(message)) {
669 log('Compiled ${registeredClasses.length} native classes, ' 689 log('Compiled ${registeredClasses.length} native classes, '
670 '${unusedClasses.length} native classes omitted.'); 690 '${unusedClasses.length} native classes omitted.');
671 } 691 }
672 } 692 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698