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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart

Issue 23567019: Change how we generate bound closures to handler boud closures due to super getters: we need to pas… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/ssa/codegen.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of js_backend; 5 part of js_backend;
6 6
7 /** 7 /**
8 * A function element that represents a closure call. The signature is copied 8 * A function element that represents a closure call. The signature is copied
9 * from the given element. 9 * from the given element.
10 */ 10 */
(...skipping 2529 matching lines...) Expand 10 before | Expand all | Expand 10 after
2540 // its stubs we simply create a fake element with the correct name. 2540 // its stubs we simply create a fake element with the correct name.
2541 // Note: the callElement will not have any enclosingElement. 2541 // Note: the callElement will not have any enclosingElement.
2542 FunctionElement callElement = 2542 FunctionElement callElement =
2543 new ClosureInvocationElement(namer.closureInvocationSelectorName, 2543 new ClosureInvocationElement(namer.closureInvocationSelectorName,
2544 member); 2544 member);
2545 2545
2546 String invocationName = namer.instanceMethodName(callElement); 2546 String invocationName = namer.instanceMethodName(callElement);
2547 2547
2548 List<String> parameters = <String>[]; 2548 List<String> parameters = <String>[];
2549 List<jsAst.Expression> arguments = <jsAst.Expression>[]; 2549 List<jsAst.Expression> arguments = <jsAst.Expression>[];
2550 arguments.add(js('this')[fieldNames[0]]);
2550 if (inInterceptor) { 2551 if (inInterceptor) {
2551 arguments.add(js('this')[fieldNames[2]]); 2552 arguments.add(js('this')[fieldNames[2]]);
2552 } 2553 }
2553 for (int i = 0; i < parameterCount; i++) { 2554 for (int i = 0; i < parameterCount; i++) {
2554 String name = 'p$i'; 2555 String name = 'p$i';
2555 parameters.add(name); 2556 parameters.add(name);
2556 arguments.add(js(name)); 2557 arguments.add(js(name));
2557 } 2558 }
2558 2559
2559 jsAst.Expression fun = js.fun( 2560 jsAst.Expression fun = js.fun(
2560 parameters, 2561 parameters,
2561 js.return_( 2562 js.return_(
2562 js('this')[fieldNames[0]][js('this')[fieldNames[1]]](arguments))); 2563 js('this')[fieldNames[1]]['call'](arguments)));
2563 boundClosureBuilder.addProperty(invocationName, fun); 2564 boundClosureBuilder.addProperty(invocationName, fun);
2564 2565
2565 addParameterStubs(callElement, boundClosureBuilder.addProperty); 2566 addParameterStubs(callElement, boundClosureBuilder.addProperty);
2566 2567
2567 void emitFunctionTypeSignature(Element method, FunctionType methodType) { 2568 void emitFunctionTypeSignature(Element method, FunctionType methodType) {
2568 jsAst.Expression encoding = backend.rti.getSignatureEncoding( 2569 jsAst.Expression encoding = backend.rti.getSignatureEncoding(
2569 methodType, js('this')[fieldNames[0]]); 2570 methodType, js('this')[fieldNames[0]]);
2570 String operatorSignature = namer.operatorSignature(); 2571 String operatorSignature = namer.operatorSignature();
2571 boundClosureBuilder.addProperty(operatorSignature, encoding); 2572 boundClosureBuilder.addProperty(operatorSignature, encoding);
2572 } 2573 }
(...skipping 19 matching lines...) Expand all
2592 } 2593 }
2593 } 2594 }
2594 2595
2595 // And finally the getter. 2596 // And finally the getter.
2596 String getterName = namer.getterName(member); 2597 String getterName = namer.getterName(member);
2597 String targetName = namer.instanceMethodName(member); 2598 String targetName = namer.instanceMethodName(member);
2598 2599
2599 List<String> parameters = <String>[]; 2600 List<String> parameters = <String>[];
2600 List<jsAst.Expression> arguments = <jsAst.Expression>[]; 2601 List<jsAst.Expression> arguments = <jsAst.Expression>[];
2601 arguments.add(js('this')); 2602 arguments.add(js('this'));
2602 arguments.add(js.string(targetName)); 2603 String className = backend.namer.isolateAccess(classElement);
ahe 2013/09/16 12:26:40 Use elementAccess, not isolateAccess.
ngeoffray 2013/09/16 12:34:35 Done.
2604 jsAst.VariableUse classReference = new jsAst.VariableUse(className);
ahe 2013/09/16 12:26:40 And then don't wrap it in VariableUse.
ngeoffray 2013/09/16 12:34:35 Done.
2605 jsAst.PropertyAccess prototype =
2606 new jsAst.PropertyAccess.field(classReference, "prototype");
2607 jsAst.PropertyAccess method =
2608 new jsAst.PropertyAccess.field(prototype, targetName);
ahe 2013/09/16 12:26:40 The above lines can be written as: jsAst.Property
ngeoffray 2013/09/16 12:34:35 Done.
2609
2610 arguments.add(method);
2603 if (inInterceptor) { 2611 if (inInterceptor) {
2604 String receiverArg = fieldNames[2]; 2612 String receiverArg = fieldNames[2];
2605 parameters.add(receiverArg); 2613 parameters.add(receiverArg);
2606 arguments.add(js(receiverArg)); 2614 arguments.add(js(receiverArg));
2607 } else { 2615 } else {
2608 // Put null in the intercepted receiver field. 2616 // Put null in the intercepted receiver field.
2609 arguments.add(new jsAst.LiteralNull()); 2617 arguments.add(new jsAst.LiteralNull());
2610 } 2618 }
2619 arguments.add(js.string(targetName));
2611 2620
2612 jsAst.Expression getterFunction = js.fun( 2621 jsAst.Expression getterFunction = js.fun(
2613 parameters, js.return_(js(closureClass).newWith(arguments))); 2622 parameters, js.return_(js(closureClass).newWith(arguments)));
2614 2623
2615 defineStub(getterName, getterFunction); 2624 defineStub(getterName, getterFunction);
2616 } 2625 }
2617 2626
2618 /** 2627 /**
2619 * Documentation wanted -- johnniwinther 2628 * Documentation wanted -- johnniwinther
2620 * 2629 *
(...skipping 1574 matching lines...) Expand 10 before | Expand all | Expand 10 after
4195 4204
4196 const String HOOKS_API_USAGE = """ 4205 const String HOOKS_API_USAGE = """
4197 // The code supports the following hooks: 4206 // The code supports the following hooks:
4198 // dartPrint(message) - if this function is defined it is called 4207 // dartPrint(message) - if this function is defined it is called
4199 // instead of the Dart [print] method. 4208 // instead of the Dart [print] method.
4200 // dartMainRunner(main) - if this function is defined, the Dart [main] 4209 // dartMainRunner(main) - if this function is defined, the Dart [main]
4201 // method will not be invoked directly. 4210 // method will not be invoked directly.
4202 // Instead, a closure that will invoke [main] is 4211 // Instead, a closure that will invoke [main] is
4203 // passed to [dartMainRunner]. 4212 // passed to [dartMainRunner].
4204 """; 4213 """;
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/ssa/codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698