Chromium Code Reviews| Index: sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart |
| =================================================================== |
| --- sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart (revision 17466) |
| +++ sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart (working copy) |
| @@ -2095,6 +2095,50 @@ |
| } |
| } |
| + void emitOneShotInterceptors(CodeBuffer buffer) { |
|
kasperl
2013/01/24 07:19:14
How difficult would it be to build these one shot
ngeoffray
2013/01/24 08:39:15
As discussed, I agree it will be pretty neat to re
|
| + JavaScriptBackend backend = compiler.backend; |
| + for (Selector selector in backend.oneShotInterceptors) { |
|
sra1
2013/01/23 21:21:30
These need to be sorted to have stable output.
It
ngeoffray
2013/01/24 08:39:15
Issue filed: https://code.google.com/p/dart/issues
|
| + Set<ClassElement> classes = backend.getInterceptedClassesOn(selector); |
| + String oneShotInterceptorName = namer.oneShotInterceptorName(selector); |
| + String getInterceptorName = |
| + namer.getInterceptorName(backend.getInterceptorMethod, classes); |
| + |
| + List<js.Parameter> parameters = <js.Parameter>[]; |
| + List<js.Expression> arguments = <js.Expression>[]; |
| + parameters.add(new js.Parameter('receiver')); |
| + arguments.add(new js.VariableUse('receiver')); |
|
sra1
2013/01/23 21:21:30
also: js.use('receiver')
ngeoffray
2013/01/24 08:39:15
Done.
|
| + |
| + if (selector.isSetter()) { |
| + parameters.add(new js.Parameter('value')); |
| + arguments.add(new js.VariableUse('value')); |
| + } else { |
| + for (int i = 0; i < selector.argumentCount; i++) { |
| + String argName = 'a$i'; |
| + parameters.add(new js.Parameter(argName)); |
| + arguments.add(new js.VariableUse(argName)); |
| + } |
| + } |
| + |
| + String invocationName = backend.namer.invocationName(selector); |
| + js.Fun function = |
| + new js.Fun(parameters, |
| + new js.Block( |
| + <js.Statement>[ |
| + new js.Return( |
|
sra1
2013/01/23 21:21:30
also: js.return_(x)
ngeoffray
2013/01/24 08:39:15
Done.
|
| + js.use(isolateProperties) |
| + .dot(getInterceptorName) |
| + .callWith([js.use('receiver')]) |
| + .dot(invocationName) |
| + .callWith(arguments))])); |
| + |
| + js.PropertyAccess property = |
| + js.fieldAccess(js.use(isolateProperties), oneShotInterceptorName); |
| + |
| + buffer.add(js.prettyPrint(js.assign(property, function), compiler)); |
| + buffer.add(N); |
| + } |
| + } |
| + |
| String assembleProgram() { |
| measure(() { |
| computeNeededClasses(); |
| @@ -2124,6 +2168,7 @@ |
| // Static field initializations require the classes and compile-time |
| // constants to be set up. |
| emitStaticNonFinalFieldInitializations(mainBuffer); |
| + emitOneShotInterceptors(mainBuffer); |
| emitGetInterceptorMethods(mainBuffer); |
| emitLazilyInitializedStaticFields(mainBuffer); |