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

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

Issue 861093002: Support intercepted getters, setters and index operations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Only reject instance members that need interceptors and disable a test that we do not support yet. Created 5 years, 10 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/cps_ir/cps_ir_nodes.dart ('k') | pkg/compiler/lib/src/js_backend/codegen/glue.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/codegen/codegen.dart
diff --git a/pkg/compiler/lib/src/js_backend/codegen/codegen.dart b/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
index d97abb45d0812d06cdc18b90137c920ec581bbec..f930b904228b355f43d9d46b2c0e0a86aba4ac5a 100644
--- a/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
+++ b/pkg/compiler/lib/src/js_backend/codegen/codegen.dart
@@ -170,12 +170,24 @@ class CodeGenerator extends tree_ir.Visitor<dynamic, js.Expression> {
Element target,
List<js.Expression> arguments) {
registry.registerStaticInvocation(target.declaration);
- js.Expression elementAccess = glue.staticFunctionAccess(target);
- List<js.Expression> compiledArguments =
- selector.makeArgumentsList(target.implementation,
- arguments,
- compileConstant);
- return new js.Call(elementAccess, compiledArguments);
+ if (target == glue.getInterceptorMethod) {
+ // This generates a call to the specialized interceptor function, which
+ // does not have a specialized element yet, but is emitted as a stub from
+ // the emitter in [InterceptorStubGenerator].
+ // TODO(karlklose): Either change [InvokeStatic] to take an [Entity]
+ // instead of an [Element] and model the getInterceptor functions as
+ // [Entity]s or add a specialized Tree-IR node for interceptor calls.
+ registry.registerUseInterceptor();
+ js.VariableUse interceptorLibrary = glue.getInterceptorLibrary();
+ return js.propertyCall(interceptorLibrary, selector.name, arguments);
+ } else {
+ js.Expression elementAccess = glue.staticFunctionAccess(target);
+ List<js.Expression> compiledArguments =
+ selector.makeArgumentsList(target.implementation,
+ arguments,
+ compileConstant);
+ return new js.Call(elementAccess, compiledArguments);
+ }
}
@override
@@ -189,10 +201,19 @@ class CodeGenerator extends tree_ir.Visitor<dynamic, js.Expression> {
void registerMethodInvoke(tree_ir.InvokeMethod node) {
Selector selector = node.selector;
- // TODO(sigurdm): We should find a better place to register the call.
- Selector call = new Selector.callClosureFrom(selector);
- registry.registerDynamicInvocation(call);
- registry.registerDynamicInvocation(selector);
+ if (selector.isGetter) {
+ registry.registerDynamicGetter(selector);
+ } else if (selector.isSetter) {
+ registry.registerDynamicSetter(selector);
+ } else {
+ assert(invariant(CURRENT_ELEMENT_SPANNABLE,
+ selector.isCall || selector.isOperator || selector.isIndex,
+ message: 'unexpected kind ${selector.kind}'));
+ // TODO(sigurdm): We should find a better place to register the call.
+ Selector call = new Selector.callClosureFrom(selector);
+ registry.registerDynamicInvocation(call);
+ registry.registerDynamicInvocation(selector);
+ }
}
@override
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart ('k') | pkg/compiler/lib/src/js_backend/codegen/glue.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698