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

Side by Side Diff: lib/compiler/implementation/emitter.dart

Issue 10179001: Use shorter names for constructor arguments. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Make sure mangling is correct and update tests. Created 8 years, 8 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
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 6 * A function element that represents a closure call. The signature is copied
7 * from the given element. 7 * from the given element.
8 */ 8 */
9 class ClosureInvocationElement extends FunctionElement { 9 class ClosureInvocationElement extends FunctionElement {
10 ClosureInvocationElement(SourceString name, 10 ClosureInvocationElement(SourceString name,
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 StringBuffer argumentsBuffer, 230 StringBuffer argumentsBuffer,
231 StringBuffer bodyBuffer) { 231 StringBuffer bodyBuffer) {
232 bool isFirst = true; 232 bool isFirst = true;
233 void generateFieldInit(ClassElement enclosingClass, Element member) { 233 void generateFieldInit(ClassElement enclosingClass, Element member) {
234 // TODO(floitsch): make sure there are no name clashes. 234 // TODO(floitsch): make sure there are no name clashes.
235 String className = namer.getName(enclosingClass); 235 String className = namer.getName(enclosingClass);
236 if (!isFirst) argumentsBuffer.add(', '); 236 if (!isFirst) argumentsBuffer.add(', ');
237 isFirst = false; 237 isFirst = false;
238 String memberName = namer.instanceFieldName(member.getLibrary(), 238 String memberName = namer.instanceFieldName(member.getLibrary(),
239 member.name); 239 member.name);
240 argumentsBuffer.add('${className}_$memberName'); 240 String parameter;
241 bodyBuffer.add(' this.$memberName = ${className}_$memberName;\n'); 241 if (classElement === enclosingClass) {
242 parameter = memberName;
243 } else {
244 parameter = '${className}_$memberName';
245 }
246 argumentsBuffer.add(parameter);
247 bodyBuffer.add(' this.$memberName = $parameter;\n');
242 } 248 }
243 249
244 classElement.forEachInstanceField(generateFieldInit, 250 classElement.forEachInstanceField(generateFieldInit,
245 includeBackendMembers: true, 251 includeBackendMembers: true,
246 includeSuperMembers: true); 252 includeSuperMembers: true);
247 } 253 }
248 254
249 void emitInherits(ClassElement cls, StringBuffer buffer) { 255 void emitInherits(ClassElement cls, StringBuffer buffer) {
250 ClassElement superclass = cls.superclass; 256 ClassElement superclass = cls.superclass;
251 if (superclass !== null) { 257 if (superclass !== null) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 if (compiler.universe.instantiatedClasses.contains(classElement)) { 292 if (compiler.universe.instantiatedClasses.contains(classElement)) {
287 generateFieldInits(classElement, buffer, bodyBuffer); 293 generateFieldInits(classElement, buffer, bodyBuffer);
288 } 294 }
289 buffer.add(') {\n'); 295 buffer.add(') {\n');
290 buffer.add(bodyBuffer); 296 buffer.add(bodyBuffer);
291 buffer.add('};\n'); 297 buffer.add('};\n');
292 298
293 emitInherits(classElement, buffer); 299 emitInherits(classElement, buffer);
294 300
295 String attachTo(String name) => '$className.prototype.$name'; 301 String attachTo(String name) => '$className.prototype.$name';
296 302
297 classElement.forEachMember(includeBackendMembers: true, 303 classElement.forEachMember(includeBackendMembers: true,
298 f: (ClassElement enclosing, Element member) { 304 f: (ClassElement enclosing, Element member) {
299 if (member.isInstanceMember()) { 305 if (member.isInstanceMember()) {
300 addInstanceMember(member, attachTo, buffer); 306 addInstanceMember(member, attachTo, buffer);
301 } 307 }
302 }); 308 });
303 309
304 generateTypeTests(classElement, (Element other) { 310 generateTypeTests(classElement, (Element other) {
305 buffer.add('${attachTo(namer.operatorIs(other))} = '); 311 buffer.add('${attachTo(namer.operatorIs(other))} = ');
306 if (nativeEmitter.requiresNativeIsCheck(other)) { 312 if (nativeEmitter.requiresNativeIsCheck(other)) {
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 Selector.SETTER); 657 Selector.SETTER);
652 } 658 }
653 } else { 659 } else {
654 String jsName = namer.setterName(null, setterName); 660 String jsName = namer.setterName(null, setterName);
655 generateMethod('set ${setterName.slowToString()}', jsName, 661 generateMethod('set ${setterName.slowToString()}', jsName,
656 Selector.SETTER); 662 Selector.SETTER);
657 } 663 }
658 }); 664 });
659 } 665 }
660 666
661 String buildIsolateSetup(StringBuffer buffer, 667 String buildIsolateSetup(StringBuffer buffer,
662 Element appMain, 668 Element appMain,
663 Element isolateMain) { 669 Element isolateMain) {
664 String mainAccess = "${namer.isolateAccess(appMain)}"; 670 String mainAccess = "${namer.isolateAccess(appMain)}";
665 String currentIsolate = "${namer.CURRENT_ISOLATE}"; 671 String currentIsolate = "${namer.CURRENT_ISOLATE}";
666 String mainEnsureGetter = ''; 672 String mainEnsureGetter = '';
667 // Since we pass the closurized version of the main method to 673 // Since we pass the closurized version of the main method to
668 // the isolate method, we must make sure that it exists. 674 // the isolate method, we must make sure that it exists.
669 if (!compiler.universe.staticFunctionsNeedingGetter.contains(appMain)) { 675 if (!compiler.universe.staticFunctionsNeedingGetter.contains(appMain)) {
670 String invocationName = 676 String invocationName =
671 "${namer.closureInvocationName(Selector.INVOCATION_0)}"; 677 "${namer.closureInvocationName(Selector.INVOCATION_0)}";
672 mainEnsureGetter = "$mainAccess.$invocationName = $mainAccess"; 678 mainEnsureGetter = "$mainAccess.$invocationName = $mainAccess";
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 mainBuffer.add( 740 mainBuffer.add(
735 'var ${namer.CURRENT_ISOLATE} = new ${namer.ISOLATE}();\n'); 741 'var ${namer.CURRENT_ISOLATE} = new ${namer.ISOLATE}();\n');
736 nativeEmitter.emitDynamicDispatchMetadata(); 742 nativeEmitter.emitDynamicDispatchMetadata();
737 nativeEmitter.assembleCode(mainBuffer); 743 nativeEmitter.assembleCode(mainBuffer);
738 emitMain(mainBuffer); 744 emitMain(mainBuffer);
739 compiler.assembledCode = mainBuffer.toString(); 745 compiler.assembledCode = mainBuffer.toString();
740 }); 746 });
741 return compiler.assembledCode; 747 return compiler.assembledCode;
742 } 748 }
743 } 749 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698