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

Unified Diff: sdk/lib/_internal/compiler/implementation/resolution/members.dart

Issue 45143003: Implement JS_INTERCEPTOR_CONSTANT (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 | « no previous file | sdk/lib/_internal/compiler/implementation/ssa/builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/resolution/members.dart
diff --git a/sdk/lib/_internal/compiler/implementation/resolution/members.dart b/sdk/lib/_internal/compiler/implementation/resolution/members.dart
index 015402a3b49b7bc5a7b69fcfec5208f8db817a64..cbc31ee2ed7ec69c460043573db688f07e400ac3 100644
--- a/sdk/lib/_internal/compiler/implementation/resolution/members.dart
+++ b/sdk/lib/_internal/compiler/implementation/resolution/members.dart
@@ -1926,6 +1926,12 @@ class ResolverVisitor extends MappingVisitor<Element> {
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.
@@ -2622,10 +2628,17 @@ class ResolverVisitor extends MappingVisitor<Element> {
warnArgumentMismatch(node, target);
}
- if (target != null &&
- target.isForeign(compiler) &&
- selector.name == 'JS') {
- world.registerJsCall(node, this);
+ if (target != null && target.isForeign(compiler)) {
+ if (selector.name == 'JS') {
+ world.registerJsCall(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);
+ }
+ }
}
}
@@ -3042,8 +3055,28 @@ class ResolverVisitor extends MappingVisitor<Element> {
void analyzeConstant(Node node, {bool isConst: true}) {
addDeferredAction(enclosingElement, () {
- compiler.constantHandler.compileNodeWithDefinitions(
+ Constant constant = compiler.constantHandler.compileNodeWithDefinitions(
node, mapping, isConst: isConst);
+
+ // 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 (constant.isType()) {
+ TypeConstant typeConstant = constant;
+ if (typeConstant.representedType is InterfaceType) {
+ world.registerInstantiatedType(typeConstant.representedType,
+ mapping);
+ } else {
+ compiler.reportError(node,
+ MessageKind.WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT);
+ }
+ } else {
+ compiler.reportError(node,
+ MessageKind.WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT);
+ }
+ }
});
}
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698