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

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

Issue 12250002: dart2js: In minified mode shorter getter and setter names. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 var needsSetter = ${needsSetterCode('lastCharCode')}; 187 var needsSetter = ${needsSetterCode('lastCharCode')};
188 var renaming = ${isRenaming('lastCharCode')}; 188 var renaming = ${isRenaming('lastCharCode')};
189 var accessorName = field = field.substring(0, len - 1); 189 var accessorName = field = field.substring(0, len - 1);
190 if (renaming) { 190 if (renaming) {
191 var divider = field.indexOf(":"); 191 var divider = field.indexOf(":");
192 accessorName = field.substring(0, divider); 192 accessorName = field.substring(0, divider);
193 field = field.substring(divider + 1); 193 field = field.substring(divider + 1);
194 } 194 }
195 if (needsGetter) { 195 if (needsGetter) {
196 var getterString = "return this." + field + ";"; 196 var getterString = "return this." + field + ";";
197 prototype["get\$" + accessorName] = new Function(getterString); 197 prototype["${namer.getterPrefix}" + accessorName] =
198 new Function(getterString);
198 } 199 }
199 if (needsSetter) { 200 if (needsSetter) {
200 var setterString = "this." + field + " = v;"; 201 var setterString = "this." + field + " = v;";
201 prototype["set\$" + accessorName] = new Function("v", setterString); 202 prototype["${namer.setterPrefix}" + accessorName] =
203 new Function("v", setterString);
202 } 204 }
203 } 205 }
204 return field; 206 return field;
205 }"""; 207 }""";
206 } 208 }
207 209
208 String get defineClassFunction { 210 String get defineClassFunction {
209 // First the class name, then the field names in an array and the members 211 // First the class name, then the field names in an array and the members
210 // (inside an Object literal). 212 // (inside an Object literal).
211 // The caller can also pass in the constructor as a function if needed. 213 // The caller can also pass in the constructor as a function if needed.
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 element.name, 679 element.name,
678 element.getLibrary(), 680 element.getLibrary(),
679 signature.requiredParameterCount + i, 681 signature.requiredParameterCount + i,
680 <SourceString>[])); 682 <SourceString>[]));
681 } 683 }
682 return selectors; 684 return selectors;
683 } 685 }
684 686
685 bool instanceFieldNeedsGetter(Element member) { 687 bool instanceFieldNeedsGetter(Element member) {
686 assert(member.isField()); 688 assert(member.isField());
689 if (member.fieldAccessNeverThrows()) return false;
ngeoffray 2013/02/12 22:01:53 I'd really prefer to have a "member is ClosureFiel
687 return compiler.codegenWorld.hasInvokedGetter(member, compiler); 690 return compiler.codegenWorld.hasInvokedGetter(member, compiler);
688 } 691 }
689 692
690 bool instanceFieldNeedsSetter(Element member) { 693 bool instanceFieldNeedsSetter(Element member) {
691 assert(member.isField()); 694 assert(member.isField());
695 if (member.fieldAccessNeverThrows()) return false;
692 return (!member.modifiers.isFinalOrConst()) 696 return (!member.modifiers.isFinalOrConst())
693 && compiler.codegenWorld.hasInvokedSetter(member, compiler); 697 && compiler.codegenWorld.hasInvokedSetter(member, compiler);
694 } 698 }
695 699
696 String compiledFieldName(Element member) { 700 String compiledFieldName(Element member) {
697 assert(member.isField()); 701 assert(member.isField());
698 return member.hasFixedBackendName() 702 return member.hasFixedBackendName()
699 ? member.fixedBackendName() 703 ? member.fixedBackendName()
700 : namer.getName(member); 704 : namer.getName(member);
701 } 705 }
(...skipping 1714 matching lines...) Expand 10 before | Expand all | Expand 10 after
2416 """; 2420 """;
2417 const String HOOKS_API_USAGE = """ 2421 const String HOOKS_API_USAGE = """
2418 // The code supports the following hooks: 2422 // The code supports the following hooks:
2419 // dartPrint(message) - if this function is defined it is called 2423 // dartPrint(message) - if this function is defined it is called
2420 // instead of the Dart [print] method. 2424 // instead of the Dart [print] method.
2421 // dartMainRunner(main) - if this function is defined, the Dart [main] 2425 // dartMainRunner(main) - if this function is defined, the Dart [main]
2422 // method will not be invoked directly. 2426 // method will not be invoked directly.
2423 // Instead, a closure that will invoke [main] is 2427 // Instead, a closure that will invoke [main] is
2424 // passed to [dartMainRunner]. 2428 // passed to [dartMainRunner].
2425 """; 2429 """;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698