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

Unified Diff: pkg/compiler/lib/src/js_backend/backend.dart

Issue 1384523003: Refactor resolution of foreign calls. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/enqueue.dart ('k') | pkg/compiler/lib/src/js_backend/js_backend.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_backend/backend.dart
diff --git a/pkg/compiler/lib/src/js_backend/backend.dart b/pkg/compiler/lib/src/js_backend/backend.dart
index ff254c9d16a06f3ac73183223177f15177a139dd..7bd99ee7525f6c2f48a2dd9ec2f0436ec362b645 100644
--- a/pkg/compiler/lib/src/js_backend/backend.dart
+++ b/pkg/compiler/lib/src/js_backend/backend.dart
@@ -1349,6 +1349,40 @@ class JavaScriptBackend extends Backend {
noSuchMethodRegistry.registerNoSuchMethod(noSuchMethod);
}
+ /// Called when resolving a call to a foreign function.
+ void registerForeignCall(Send node,
+ Element element,
+ CallStructure callStructure,
+ ForeignResolver resolver) {
+ native.NativeResolutionEnqueuer nativeEnqueuer =
+ compiler.enqueuer.resolution.nativeEnqueuer;
+ if (element.name == 'JS') {
+ nativeEnqueuer.registerJsCall(node, resolver);
+ } else if (element.name == 'JS_EMBEDDED_GLOBAL') {
+ nativeEnqueuer.registerJsEmbeddedGlobalCall(node, resolver);
+ } else if (element.name == 'JS_BUILTIN') {
+ nativeEnqueuer.registerJsBuiltinCall(node, resolver);
+ } else if (element.name == 'JS_INTERCEPTOR_CONSTANT') {
+ // The type constant that is an argument to JS_INTERCEPTOR_CONSTANT names
+ // a class that will be instantiated outside the program by attaching a
+ // native class dispatch record referencing the interceptor.
+ if (!node.argumentsNode.isEmpty) {
+ Node argument = node.argumentsNode.nodes.head;
+ ConstantExpression constant = resolver.getConstant(argument);
+ if (constant != null && constant.kind == ConstantExpressionKind.TYPE) {
+ TypeConstantExpression typeConstant = constant;
+ if (typeConstant.type is InterfaceType) {
+ resolver.registerInstantiatedType(typeConstant.type);
+ return;
+ }
+ }
+ }
+ compiler.reportErrorMessage(
+ node,
+ MessageKind.WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT);
+ }
+ }
+
void enableNoSuchMethod(Enqueuer world) {
enqueue(world, getCreateInvocationMirror(), compiler.globalDependencies);
world.registerInvocation(
« no previous file with comments | « pkg/compiler/lib/src/enqueue.dart ('k') | pkg/compiler/lib/src/js_backend/js_backend.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698