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

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

Issue 209383005: Revert "Rename [call$...] properties to [$...] in compiled code." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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
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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 assert(reservedGlobalObjectNames.length == 25); 214 assert(reservedGlobalObjectNames.length == 25);
215 _jsVariableReserved.addAll(reservedGlobalHelperFunctions); 215 _jsVariableReserved.addAll(reservedGlobalHelperFunctions);
216 } 216 }
217 return _jsVariableReserved; 217 return _jsVariableReserved;
218 } 218 }
219 219
220 final String currentIsolate = r'$'; 220 final String currentIsolate = r'$';
221 final String getterPrefix = r'get$'; 221 final String getterPrefix = r'get$';
222 final String setterPrefix = r'set$'; 222 final String setterPrefix = r'set$';
223 final String metadataField = '@'; 223 final String metadataField = '@';
224 final String callPrefix = 'call';
225 final String callCatchAllName = r'call$catchAll'; 224 final String callCatchAllName = r'call$catchAll';
226 final String reflectableField = r'$reflectable'; 225 final String reflectableField = r'$reflectable';
227 final String defaultValuesField = r'$defaultValues'; 226 final String defaultValuesField = r'$defaultValues';
228 final String methodsWithOptionalArgumentsField = 227 final String methodsWithOptionalArgumentsField =
229 r'$methodsWithOptionalArguments'; 228 r'$methodsWithOptionalArguments';
230 229
231 final String classDescriptorProperty = r'^'; 230 final String classDescriptorProperty = r'^';
232 231
233 // Name of property in a class description for the native dispatch metadata. 232 // Name of property in a class description for the native dispatch metadata.
234 final String nativeSpecProperty = '%'; 233 final String nativeSpecProperty = '%';
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 * [STATIC_CLOSURE_NAME_NAME]. 283 * [STATIC_CLOSURE_NAME_NAME].
285 */ 284 */
286 String get STATIC_CLOSURE_NAME_NAME => r'$name'; 285 String get STATIC_CLOSURE_NAME_NAME => r'$name';
287 String get closureInvocationSelectorName => Compiler.CALL_OPERATOR_NAME; 286 String get closureInvocationSelectorName => Compiler.CALL_OPERATOR_NAME;
288 bool get shouldMinify => false; 287 bool get shouldMinify => false;
289 288
290 String getNameForJsGetName(Node node, String name) { 289 String getNameForJsGetName(Node node, String name) {
291 switch (name) { 290 switch (name) {
292 case 'GETTER_PREFIX': return getterPrefix; 291 case 'GETTER_PREFIX': return getterPrefix;
293 case 'SETTER_PREFIX': return setterPrefix; 292 case 'SETTER_PREFIX': return setterPrefix;
294 case 'CALL_PREFIX': return callPrefix;
295 case 'CALL_CATCH_ALL': return callCatchAllName; 293 case 'CALL_CATCH_ALL': return callCatchAllName;
296 case 'REFLECTABLE': return reflectableField; 294 case 'REFLECTABLE': return reflectableField;
297 case 'CLASS_DESCRIPTOR_PROPERTY': return classDescriptorProperty; 295 case 'CLASS_DESCRIPTOR_PROPERTY': return classDescriptorProperty;
298 default: 296 default:
299 compiler.reportError( 297 compiler.reportError(
300 node, MessageKind.GENERIC, 298 node, MessageKind.GENERIC,
301 {'text': 'Error: Namer has no name for "$name".'}); 299 {'text': 'Error: Namer has no name for "$name".'});
302 return 'BROKEN'; 300 return 'BROKEN';
303 } 301 }
304 } 302 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 // Selector.fromElement(element))? 376 // Selector.fromElement(element))?
379 String elementName = element.name; 377 String elementName = element.name;
380 String name = operatorNameToIdentifier(elementName); 378 String name = operatorNameToIdentifier(elementName);
381 if (name != elementName) return getMappedOperatorName(name); 379 if (name != elementName) return getMappedOperatorName(name);
382 380
383 LibraryElement library = element.getLibrary(); 381 LibraryElement library = element.getLibrary();
384 if (element.isGenerativeConstructorBody()) { 382 if (element.isGenerativeConstructorBody()) {
385 name = Elements.reconstructConstructorNameSourceString(element); 383 name = Elements.reconstructConstructorNameSourceString(element);
386 } 384 }
387 FunctionSignature signature = element.functionSignature; 385 FunctionSignature signature = element.functionSignature;
388 // We don't mangle the closure invoking function name because it 386 String methodName =
389 // is generated by string concatenation in applyFunction from 387 '${privateName(library, name)}\$${signature.parameterCount}';
390 // js_helper.dart. To keep code size down, we potentially shorten
391 // the prefix though.
392 String methodName;
393 if (name == closureInvocationSelectorName) {
394 methodName = '$callPrefix\$${signature.parameterCount}';
395 } else {
396 methodName = '${privateName(library, name)}\$${signature.parameterCount}';
397 }
398 if (signature.optionalParametersAreNamed && 388 if (signature.optionalParametersAreNamed &&
399 !signature.optionalParameters.isEmpty) { 389 !signature.optionalParameters.isEmpty) {
400 StringBuffer buffer = new StringBuffer(); 390 StringBuffer buffer = new StringBuffer();
401 signature.orderedOptionalParameters.forEach((Element element) { 391 signature.orderedOptionalParameters.forEach((Element element) {
402 buffer.write('\$${safeName(element.name)}'); 392 buffer.write('\$${safeName(element.name)}');
403 }); 393 });
404 methodName = '$methodName$buffer'; 394 methodName = '$methodName$buffer';
405 } 395 }
406 if (name == closureInvocationSelectorName) return methodName; 396 if (name == closureInvocationSelectorName) return methodName;
407 return getMappedInstanceName(methodName); 397 return getMappedInstanceName(methodName);
408 } 398 }
409 399
410 String publicInstanceMethodNameByArity(String name, int arity) { 400 String publicInstanceMethodNameByArity(String name, int arity) {
411 String newName = operatorNameToIdentifier(name); 401 String newName = operatorNameToIdentifier(name);
412 if (newName != name) return getMappedOperatorName(newName); 402 if (newName != name) return getMappedOperatorName(newName);
413 assert(!isPrivateName(name)); 403 assert(!isPrivateName(name));
414 // We don't mangle the closure invoking function name because it 404 // We don't mangle the closure invoking function name because it
415 // is generated by string concatenation in applyFunction from 405 // is generated by string concatenation in applyFunction from
416 // js_helper.dart. To keep code size down, we potentially shorten 406 // js_helper.dart.
417 // the prefix though. 407 String proposedName = '$name\$$arity';
418 if (name == closureInvocationSelectorName) return '$callPrefix\$$arity'; 408 if (name == closureInvocationSelectorName) return proposedName;
419 409 return getMappedInstanceName(proposedName);
420 return getMappedInstanceName('$name\$$arity');
421 } 410 }
422 411
423 String invocationName(Selector selector) { 412 String invocationName(Selector selector) {
424 if (selector.isGetter()) { 413 if (selector.isGetter()) {
425 String proposedName = privateName(selector.library, selector.name); 414 String proposedName = privateName(selector.library, selector.name);
426 return '$getterPrefix${getMappedInstanceName(proposedName)}'; 415 return '$getterPrefix${getMappedInstanceName(proposedName)}';
427 } else if (selector.isSetter()) { 416 } else if (selector.isSetter()) {
428 String proposedName = privateName(selector.library, selector.name); 417 String proposedName = privateName(selector.library, selector.name);
429 return '$setterPrefix${getMappedInstanceName(proposedName)}'; 418 return '$setterPrefix${getMappedInstanceName(proposedName)}';
430 } else { 419 } else {
431 String name = selector.name; 420 String name = selector.name;
432 if (selector.kind == SelectorKind.OPERATOR 421 if (selector.kind == SelectorKind.OPERATOR
433 || selector.kind == SelectorKind.INDEX) { 422 || selector.kind == SelectorKind.INDEX) {
434 name = operatorNameToIdentifier(name); 423 name = operatorNameToIdentifier(name);
435 assert(name != selector.name); 424 assert(name != selector.name);
436 return getMappedOperatorName(name); 425 return getMappedOperatorName(name);
437 } 426 }
438 assert(name == operatorNameToIdentifier(name)); 427 assert(name == operatorNameToIdentifier(name));
439 StringBuffer buffer = new StringBuffer(); 428 StringBuffer buffer = new StringBuffer();
440 for (String argumentName in selector.getOrderedNamedArguments()) { 429 for (String argumentName in selector.getOrderedNamedArguments()) {
441 buffer.write('\$${safeName(argumentName)}'); 430 buffer.write('\$${safeName(argumentName)}');
442 } 431 }
443 String suffix = '\$${selector.argumentCount}$buffer'; 432 String suffix = '\$${selector.argumentCount}$buffer';
444 // We don't mangle the closure invoking function name because it 433 // We don't mangle the closure invoking function name because it
445 // is generated by string concatenation in applyFunction from 434 // is generated by string concatenation in applyFunction from
446 // js_helper.dart. We potentially shorten the prefix though. 435 // js_helper.dart.
447 if (selector.isClosureCall()) { 436 if (selector.isClosureCall()) {
448 return "$callPrefix$suffix"; 437 return "$name$suffix";
449 } else { 438 } else {
450 String proposedName = privateName(selector.library, name); 439 String proposedName = privateName(selector.library, name);
451 return getMappedInstanceName('$proposedName$suffix'); 440 return getMappedInstanceName('$proposedName$suffix');
452 } 441 }
453 } 442 }
454 } 443 }
455 444
456 /** 445 /**
457 * Returns the internal name used for an invocation mirror of this selector. 446 * Returns the internal name used for an invocation mirror of this selector.
458 */ 447 */
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after
1396 if (!first) { 1385 if (!first) {
1397 sb.write('_'); 1386 sb.write('_');
1398 } 1387 }
1399 sb.write('_'); 1388 sb.write('_');
1400 visit(link.head); 1389 visit(link.head);
1401 first = true; 1390 first = true;
1402 } 1391 }
1403 } 1392 }
1404 } 1393 }
1405 } 1394 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/js_backend/minify_namer.dart ('k') | sdk/lib/_internal/lib/js_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698