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

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 /// Enables debugging of fast/slow objects using V8-specific primitives. 7 /// Enables debugging of fast/slow objects using V8-specific primitives.
8 const DEBUG_FAST_OBJECTS = false; 8 const DEBUG_FAST_OBJECTS = false;
9 9
10 /** 10 /**
(...skipping 2550 matching lines...) Expand 10 before | Expand all | Expand 10 after
2561 // its stubs we simply create a fake element with the correct name. 2561 // its stubs we simply create a fake element with the correct name.
2562 // Note: the callElement will not have any enclosingElement. 2562 // Note: the callElement will not have any enclosingElement.
2563 FunctionElement callElement = 2563 FunctionElement callElement =
2564 new ClosureInvocationElement(namer.closureInvocationSelectorName, 2564 new ClosureInvocationElement(namer.closureInvocationSelectorName,
2565 member); 2565 member);
2566 2566
2567 String invocationName = namer.instanceMethodName(callElement); 2567 String invocationName = namer.instanceMethodName(callElement);
2568 2568
2569 List<String> parameters = <String>[]; 2569 List<String> parameters = <String>[];
2570 List<jsAst.Expression> arguments = <jsAst.Expression>[]; 2570 List<jsAst.Expression> arguments = <jsAst.Expression>[];
2571 arguments.add(js('this')[fieldNames[0]]);
2571 if (inInterceptor) { 2572 if (inInterceptor) {
2572 arguments.add(js('this')[fieldNames[2]]); 2573 arguments.add(js('this')[fieldNames[2]]);
2573 } 2574 }
2574 for (int i = 0; i < parameterCount; i++) { 2575 for (int i = 0; i < parameterCount; i++) {
2575 String name = 'p$i'; 2576 String name = 'p$i';
2576 parameters.add(name); 2577 parameters.add(name);
2577 arguments.add(js(name)); 2578 arguments.add(js(name));
2578 } 2579 }
2579 2580
2580 jsAst.Expression fun = js.fun( 2581 jsAst.Expression fun = js.fun(
2581 parameters, 2582 parameters,
2582 js.return_( 2583 js.return_(
2583 js('this')[fieldNames[0]][js('this')[fieldNames[1]]](arguments))); 2584 js('this')[fieldNames[1]]['call'](arguments)));
2584 boundClosureBuilder.addProperty(invocationName, fun); 2585 boundClosureBuilder.addProperty(invocationName, fun);
2585 2586
2586 addParameterStubs(callElement, boundClosureBuilder.addProperty); 2587 addParameterStubs(callElement, boundClosureBuilder.addProperty);
2587 2588
2588 void emitFunctionTypeSignature(Element method, FunctionType methodType) { 2589 void emitFunctionTypeSignature(Element method, FunctionType methodType) {
2589 jsAst.Expression encoding = backend.rti.getSignatureEncoding( 2590 jsAst.Expression encoding = backend.rti.getSignatureEncoding(
2590 methodType, js('this')[fieldNames[0]]); 2591 methodType, js('this')[fieldNames[0]]);
2591 String operatorSignature = namer.operatorSignature(); 2592 String operatorSignature = namer.operatorSignature();
2592 boundClosureBuilder.addProperty(operatorSignature, encoding); 2593 boundClosureBuilder.addProperty(operatorSignature, encoding);
2593 } 2594 }
(...skipping 20 matching lines...) Expand all
2614 } 2615 }
2615 } 2616 }
2616 2617
2617 // And finally the getter. 2618 // And finally the getter.
2618 String getterName = namer.getterName(member); 2619 String getterName = namer.getterName(member);
2619 String targetName = namer.instanceMethodName(member); 2620 String targetName = namer.instanceMethodName(member);
2620 2621
2621 List<String> parameters = <String>[]; 2622 List<String> parameters = <String>[];
2622 List<jsAst.Expression> arguments = <jsAst.Expression>[]; 2623 List<jsAst.Expression> arguments = <jsAst.Expression>[];
2623 arguments.add(js('this')); 2624 arguments.add(js('this'));
2624 arguments.add(js.string(targetName)); 2625 jsAst.PropertyAccess method =
2626 backend.namer.elementAccess(classElement)['prototype'][targetName];
2627
2628 arguments.add(method);
2625 if (inInterceptor) { 2629 if (inInterceptor) {
2626 String receiverArg = fieldNames[2]; 2630 String receiverArg = fieldNames[2];
2627 parameters.add(receiverArg); 2631 parameters.add(receiverArg);
2628 arguments.add(js(receiverArg)); 2632 arguments.add(js(receiverArg));
2629 } else { 2633 } else {
2630 // Put null in the intercepted receiver field. 2634 // Put null in the intercepted receiver field.
2631 arguments.add(new jsAst.LiteralNull()); 2635 arguments.add(new jsAst.LiteralNull());
2632 } 2636 }
2637 arguments.add(js.string(targetName));
2633 2638
2634 jsAst.Expression getterFunction = js.fun( 2639 jsAst.Expression getterFunction = js.fun(
2635 parameters, js.return_(js(closureClass).newWith(arguments))); 2640 parameters, js.return_(js(closureClass).newWith(arguments)));
2636 2641
2637 defineStub(getterName, getterFunction); 2642 defineStub(getterName, getterFunction);
2638 } 2643 }
2639 2644
2640 /** 2645 /**
2641 * Documentation wanted -- johnniwinther 2646 * Documentation wanted -- johnniwinther
2642 * 2647 *
(...skipping 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after
4302 4307
4303 const String HOOKS_API_USAGE = """ 4308 const String HOOKS_API_USAGE = """
4304 // The code supports the following hooks: 4309 // The code supports the following hooks:
4305 // dartPrint(message) - if this function is defined it is called 4310 // dartPrint(message) - if this function is defined it is called
4306 // instead of the Dart [print] method. 4311 // instead of the Dart [print] method.
4307 // dartMainRunner(main) - if this function is defined, the Dart [main] 4312 // dartMainRunner(main) - if this function is defined, the Dart [main]
4308 // method will not be invoked directly. 4313 // method will not be invoked directly.
4309 // Instead, a closure that will invoke [main] is 4314 // Instead, a closure that will invoke [main] is
4310 // passed to [dartMainRunner]. 4315 // passed to [dartMainRunner].
4311 """; 4316 """;
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