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

Side by Side Diff: frog/leg/emitter.dart

Issue 9463046: Fix bug where the closure-invocation method was not mangled correctly. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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 | tests/language/language-leg.status » ('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 /** 5 /**
6 * A function element that represents a closure call. The signature is copied
7 * from the given element.
8 */
9 class ClosureInvocationElement extends FunctionElement {
10 ClosureInvocationElement(SourceString name,
11 FunctionElement other)
12 : super.from(name, other, null);
13
14 isInstanceMember() => true;
15 }
16
17 /**
6 * Generates the code for all used classes in the program. Static fields (even 18 * Generates the code for all used classes in the program. Static fields (even
7 * in classes) are ignored, since they can be treated as non-class elements. 19 * in classes) are ignored, since they can be treated as non-class elements.
8 * 20 *
9 * The code for the containing (used) methods must exist in the [:universe:]. 21 * The code for the containing (used) methods must exist in the [:universe:].
10 */ 22 */
11 class CodeEmitterTask extends CompilerTask { 23 class CodeEmitterTask extends CompilerTask {
12 static final String INHERIT_FUNCTION = ''' 24 static final String INHERIT_FUNCTION = '''
13 function(child, parent) { 25 function(child, parent) {
14 if (child.prototype.__proto__) { 26 if (child.prototype.__proto__) {
15 child.prototype.__proto__ = parent.prototype; 27 child.prototype.__proto__ = parent.prototype;
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 namer.isolateBailoutPropertyAccess); 500 namer.isolateBailoutPropertyAccess);
489 } 501 }
490 502
491 void emitStaticFunctionGetters(StringBuffer buffer) { 503 void emitStaticFunctionGetters(StringBuffer buffer) {
492 Set<FunctionElement> functionsNeedingGetter = 504 Set<FunctionElement> functionsNeedingGetter =
493 compiler.universe.staticFunctionsNeedingGetter; 505 compiler.universe.staticFunctionsNeedingGetter;
494 for (FunctionElement element in functionsNeedingGetter) { 506 for (FunctionElement element in functionsNeedingGetter) {
495 // The static function does not have the correct name. Since 507 // The static function does not have the correct name. Since
496 // [addParameterStubs] use the name to create its stubs we simply 508 // [addParameterStubs] use the name to create its stubs we simply
497 // create a fake element with the correct name. 509 // create a fake element with the correct name.
498 // Note: the callElement will not have the correct modifiers (in case 510 // Note: the callElement will not have any enclosingElement.
499 // of static functions) and will not have any enclosingElement.
500 FunctionElement callElement = 511 FunctionElement callElement =
501 new FunctionElement.from(Namer.CLOSURE_INVOCATION_NAME, 512 new ClosureInvocationElement(Namer.CLOSURE_INVOCATION_NAME, element);
502 element,
503 null);
504 String staticName = namer.isolatePropertyAccess(element); 513 String staticName = namer.isolatePropertyAccess(element);
505 int parameterCount = element.parameterCount(compiler); 514 int parameterCount = element.parameterCount(compiler);
506 String invocationName = 515 String invocationName =
507 namer.instanceMethodName(callElement.name, parameterCount); 516 namer.instanceMethodName(callElement.name, parameterCount);
508 buffer.add("$staticName.$invocationName = $staticName;\n"); 517 buffer.add("$staticName.$invocationName = $staticName;\n");
509 addParameterStubs(callElement, (name) => '$staticName.$name', buffer); 518 addParameterStubs(callElement, (name) => '$staticName.$name', buffer);
510 } 519 }
511 } 520 }
512 521
513 void emitDynamicFunctionGetter(StringBuffer buffer, 522 void emitDynamicFunctionGetter(StringBuffer buffer,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 ClassElement objectClass = 556 ClassElement objectClass =
548 compiler.coreLibrary.find(const SourceString('Object')); 557 compiler.coreLibrary.find(const SourceString('Object'));
549 String superName = namer.isolatePropertyAccess(objectClass); 558 String superName = namer.isolatePropertyAccess(objectClass);
550 buffer.add('${inheritsName}($isolateAccess, $superName);\n'); 559 buffer.add('${inheritsName}($isolateAccess, $superName);\n');
551 560
552 String prototype = "$isolateAccess.prototype"; 561 String prototype = "$isolateAccess.prototype";
553 562
554 // Now add the methods on the closure class. The instance method does not 563 // Now add the methods on the closure class. The instance method does not
555 // have the correct name. Since [addParameterStubs] use the name to create 564 // have the correct name. Since [addParameterStubs] use the name to create
556 // its stubs we simply create a fake element with the correct name. 565 // its stubs we simply create a fake element with the correct name.
557 // Note: the callElement will not have the correct modifiers (in case 566 // Note: the callElement will not have any enclosingElement.
558 // of static functions) and will not have any enclosingElement.
559 FunctionElement callElement = 567 FunctionElement callElement =
560 new FunctionElement.from(Namer.CLOSURE_INVOCATION_NAME, member, null); 568 new ClosureInvocationElement(Namer.CLOSURE_INVOCATION_NAME, member);
561 569
562 int parameterCount = member.parameterCount(compiler); 570 int parameterCount = member.parameterCount(compiler);
563 String invocationName = 571 String invocationName =
564 namer.instanceMethodName(callElement.name, parameterCount); 572 namer.instanceMethodName(callElement.name, parameterCount);
565 String targetName = namer.instanceMethodName(member.name, parameterCount); 573 String targetName = namer.instanceMethodName(member.name, parameterCount);
566 List<String> arguments = new List<String>(parameterCount); 574 List<String> arguments = new List<String>(parameterCount);
567 for (int i = 0; i < parameterCount; i++) { 575 for (int i = 0; i < parameterCount; i++) {
568 arguments[i] = "arg$i"; 576 arguments[i] = "arg$i";
569 } 577 }
570 String joinedArgs = Strings.join(arguments, ", "); 578 String joinedArgs = Strings.join(arguments, ", ");
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 emitCompileTimeConstants(buffer); 775 emitCompileTimeConstants(buffer);
768 emitStaticFinalFieldInitializations(buffer); 776 emitStaticFinalFieldInitializations(buffer);
769 buffer.add('var ${namer.CURRENT_ISOLATE} = new ${namer.ISOLATE}();\n'); 777 buffer.add('var ${namer.CURRENT_ISOLATE} = new ${namer.ISOLATE}();\n');
770 Element main = compiler.mainApp.find(Compiler.MAIN); 778 Element main = compiler.mainApp.find(Compiler.MAIN);
771 buffer.add('${namer.isolateAccess(main)}();\n'); 779 buffer.add('${namer.isolateAccess(main)}();\n');
772 compiler.assembledCode = buffer.toString(); 780 compiler.assembledCode = buffer.toString();
773 }); 781 });
774 return compiler.assembledCode; 782 return compiler.assembledCode;
775 } 783 }
776 } 784 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/language-leg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698