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

Unified Diff: pkg/compiler/lib/src/resolution/members.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/native/native.dart ('k') | pkg/compiler/lib/src/resolution/registry.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/resolution/members.dart
diff --git a/pkg/compiler/lib/src/resolution/members.dart b/pkg/compiler/lib/src/resolution/members.dart
index 85467006d13f4b8126daa2731ec47d13017b6105..34f051b2507ea646d8c944118e401eae43ef592e 100644
--- a/pkg/compiler/lib/src/resolution/members.dart
+++ b/pkg/compiler/lib/src/resolution/members.dart
@@ -125,12 +125,6 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> {
int allowedCategory = ElementCategory.VARIABLE | ElementCategory.FUNCTION
| ElementCategory.IMPLIES_TYPE;
- /**
- * Record of argument nodes to JS_INTERCEPTOR_CONSTANT for deferred
- * processing.
- */
- Set<Node> argumentsToJsInterceptorConstant = null;
-
/// When visiting the type declaration of the variable in a [ForIn] loop,
/// the initializer of the variable is implicit and we should not emit an
/// error when verifying that all final variables are initialized.
@@ -2058,7 +2052,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> {
} else {
analyzeConstantDeferred(node, enforceConst: false);
- // TODO(johnniwinther): Avoid the need for a [Selector] here.
+ registry.setConstant(node, semantics.constant);
registry.registerSendStructure(node, new GetStructure(semantics));
return new ConstantResult(node, semantics.constant);
}
@@ -2757,7 +2751,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> {
isIncompatibleInvoke = true;
} else {
registry.registerStaticUse(semantics.element);
- handleForeignCall(node, semantics.element, selector);
+ handleForeignCall(node, semantics.element, callStructure);
if (method == compiler.identicalFunction &&
argumentsResult.isValidAsConstant) {
result = new ConstantResult(node,
@@ -3110,23 +3104,11 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> {
}
// TODO(johnniwinther): Move this to the backend resolution callbacks.
- void handleForeignCall(Send node, Element target, Selector selector) {
+ void handleForeignCall(Send node,
+ Element target,
+ CallStructure callStructure) {
if (target != null && compiler.backend.isForeign(target)) {
- if (selector.name == 'JS') {
- registry.registerJsCall(node, this);
- } else if (selector.name == 'JS_EMBEDDED_GLOBAL') {
- registry.registerJsEmbeddedGlobalCall(node, this);
- } else if (selector.name == 'JS_BUILTIN') {
- registry.registerJsBuiltinCall(node, this);
- } else if (selector.name == 'JS_INTERCEPTOR_CONSTANT') {
- if (!node.argumentsNode.isEmpty) {
- Node argument = node.argumentsNode.nodes.head;
- if (argumentsToJsInterceptorConstant == null) {
- argumentsToJsInterceptorConstant = new Set<Node>();
- }
- argumentsToJsInterceptorConstant.add(argument);
- }
- }
+ registry.registerForeignCall(node, target, callStructure, this);
}
}
@@ -3975,27 +3957,6 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> {
if (value.isMap) {
checkConstMapKeysDontOverrideEquals(node, value);
}
-
- // 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 (argumentsToJsInterceptorConstant != null &&
- argumentsToJsInterceptorConstant.contains(node)) {
- if (value.isType) {
- TypeConstantValue typeConstant = value;
- if (typeConstant.representedType is InterfaceType) {
- registry.registerInstantiatedType(typeConstant.representedType);
- } else {
- compiler.reportErrorMessage(
- node,
- MessageKind.WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT);
- }
- } else {
- compiler.reportErrorMessage(
- node,
- MessageKind.WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT);
- }
- }
}
void analyzeConstantDeferred(Node node, {bool enforceConst: true}) {
« no previous file with comments | « pkg/compiler/lib/src/native/native.dart ('k') | pkg/compiler/lib/src/resolution/registry.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698