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

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

Issue 12294028: Fix warnings spotted by dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 * Assigns JavaScript identifiers to Dart variables, class-names and members. 8 * Assigns JavaScript identifiers to Dart variables, class-names and members.
9 */ 9 */
10 class Namer implements ClosureNamer { 10 class Namer implements ClosureNamer {
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 ConstructorBodyElement bodyElement = element; 316 ConstructorBodyElement bodyElement = element;
317 name = bodyElement.constructor.name; 317 name = bodyElement.constructor.name;
318 } 318 }
319 FunctionSignature signature = element.computeSignature(compiler); 319 FunctionSignature signature = element.computeSignature(compiler);
320 String methodName = 320 String methodName =
321 '${privateName(library, name)}\$${signature.parameterCount}'; 321 '${privateName(library, name)}\$${signature.parameterCount}';
322 if (signature.optionalParametersAreNamed && 322 if (signature.optionalParametersAreNamed &&
323 !signature.optionalParameters.isEmpty) { 323 !signature.optionalParameters.isEmpty) {
324 StringBuffer buffer = new StringBuffer(); 324 StringBuffer buffer = new StringBuffer();
325 signature.orderedOptionalParameters.forEach((Element element) { 325 signature.orderedOptionalParameters.forEach((Element element) {
326 buffer.add('\$${safeName(element.name.slowToString())}'); 326 buffer.write('\$${safeName(element.name.slowToString())}');
327 }); 327 });
328 methodName = '$methodName$buffer'; 328 methodName = '$methodName$buffer';
329 } 329 }
330 if (name == closureInvocationSelectorName) return methodName; 330 if (name == closureInvocationSelectorName) return methodName;
331 return getMappedInstanceName(methodName); 331 return getMappedInstanceName(methodName);
332 } 332 }
333 333
334 String publicInstanceMethodNameByArity(SourceString name, int arity) { 334 String publicInstanceMethodNameByArity(SourceString name, int arity) {
335 SourceString newName = operatorNameToIdentifier(name); 335 SourceString newName = operatorNameToIdentifier(name);
336 if (newName != name) return getMappedOperatorName(newName.slowToString()); 336 if (newName != name) return getMappedOperatorName(newName.slowToString());
(...skipping 18 matching lines...) Expand all
355 SourceString name = selector.name; 355 SourceString name = selector.name;
356 if (selector.kind == SelectorKind.OPERATOR 356 if (selector.kind == SelectorKind.OPERATOR
357 || selector.kind == SelectorKind.INDEX) { 357 || selector.kind == SelectorKind.INDEX) {
358 name = operatorNameToIdentifier(name); 358 name = operatorNameToIdentifier(name);
359 assert(name != selector.name); 359 assert(name != selector.name);
360 return getMappedOperatorName(name.slowToString()); 360 return getMappedOperatorName(name.slowToString());
361 } 361 }
362 assert(name == operatorNameToIdentifier(name)); 362 assert(name == operatorNameToIdentifier(name));
363 StringBuffer buffer = new StringBuffer(); 363 StringBuffer buffer = new StringBuffer();
364 for (SourceString argumentName in selector.getOrderedNamedArguments()) { 364 for (SourceString argumentName in selector.getOrderedNamedArguments()) {
365 buffer.add(r'$'); 365 buffer.write(r'$');
366 argumentName.printOn(buffer); 366 argumentName.printOn(buffer);
367 } 367 }
368 String suffix = '\$${selector.argumentCount}$buffer'; 368 String suffix = '\$${selector.argumentCount}$buffer';
369 // We don't mangle the closure invoking function name because it 369 // We don't mangle the closure invoking function name because it
370 // is generated by string concatenation in applyFunction from 370 // is generated by string concatenation in applyFunction from
371 // js_helper.dart. 371 // js_helper.dart.
372 if (selector.isClosureCall()) { 372 if (selector.isClosureCall()) {
373 return "${name.slowToString()}$suffix"; 373 return "${name.slowToString()}$suffix";
374 } else { 374 } else {
375 String proposedName = privateName(selector.library, name); 375 String proposedName = privateName(selector.library, name);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 return getName(element); 541 return getName(element);
542 } 542 }
543 // Use the unminified names here to construct the interceptor names. This 543 // Use the unminified names here to construct the interceptor names. This
544 // helps ensure that they don't all suddenly change names due to a name 544 // helps ensure that they don't all suddenly change names due to a name
545 // clash in the minifier, which would affect the diff size. Sort the names 545 // clash in the minifier, which would affect the diff size. Sort the names
546 // of the classes to ensure name is stable and predicatble for the suggested 546 // of the classes to ensure name is stable and predicatble for the suggested
547 // names. 547 // names.
548 StringBuffer buffer = new StringBuffer('${element.name.slowToString()}\$'); 548 StringBuffer buffer = new StringBuffer('${element.name.slowToString()}\$');
549 List<String> names = classes.map((cls) => cls.name.slowToString()).toList(); 549 List<String> names = classes.map((cls) => cls.name.slowToString()).toList();
550 names.sort(); 550 names.sort();
551 names.forEach(buffer.add); 551 names.forEach(buffer.write);
552 return getMappedGlobalName(buffer.toString()); 552 return getMappedGlobalName(buffer.toString());
553 } 553 }
554 554
555 String getBailoutName(Element element) { 555 String getBailoutName(Element element) {
556 String name = bailoutNames[element]; 556 String name = bailoutNames[element];
557 if (name != null) return name; 557 if (name != null) return name;
558 bool global = !element.isInstanceMember(); 558 bool global = !element.isInstanceMember();
559 // Despite the name of the variable, this gets the minified name when we 559 // Despite the name of the variable, this gets the minified name when we
560 // are minifying, but it doesn't really make much difference. The 560 // are minifying, but it doesn't really make much difference. The
561 // important thing is that it is a unique name. We add $bailout and, if we 561 // important thing is that it is a unique name. We add $bailout and, if we
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 return const SourceString(r'$or'); 756 return const SourceString(r'$or');
757 } else if (value == '-') { 757 } else if (value == '-') {
758 return const SourceString(r'$sub'); 758 return const SourceString(r'$sub');
759 } else if (value == 'unary-') { 759 } else if (value == 'unary-') {
760 return const SourceString(r'$negate'); 760 return const SourceString(r'$negate');
761 } else { 761 } else {
762 return name; 762 return name;
763 } 763 }
764 } 764 }
765 } 765 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698