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

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

Issue 12018015: Implement substitution for type variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. 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 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 String newName = getMappedGlobalName('${getName(element)}\$bailout'); 516 String newName = getMappedGlobalName('${getName(element)}\$bailout');
517 return '$CURRENT_ISOLATE.$newName'; 517 return '$CURRENT_ISOLATE.$newName';
518 } 518 }
519 519
520 String isolateLazyInitializerAccess(Element element) { 520 String isolateLazyInitializerAccess(Element element) {
521 return "$CURRENT_ISOLATE.${getLazyInitializerName(element)}"; 521 return "$CURRENT_ISOLATE.${getLazyInitializerName(element)}";
522 } 522 }
523 523
524 String operatorIsPrefix() => r'$is'; 524 String operatorIsPrefix() => r'$is';
525 525
526 String operatorAsPrefix() => r'$as';
527
526 String operatorIs(Element element) { 528 String operatorIs(Element element) {
527 // TODO(erikcorry): Reduce from $isx to ix when we are minifying. 529 // TODO(erikcorry): Reduce from is$x to ix when we are minifying.
ngeoffray 2013/01/30 13:06:00 is$x -> $isX
karlklose 2013/01/30 15:37:18 Done.
530 // TODO(karlklose): The runtime type system implementation in js_helper
531 // needs to know this name, because it uses a JS-call to read the field.
ngeoffray 2013/01/30 13:06:00 Why the TODO?
karlklose 2013/01/30 15:37:18 Leftover of the merge. Removed.
528 return '${operatorIsPrefix()}${getName(element)}'; 532 return '${operatorIsPrefix()}${getName(element)}';
529 } 533 }
530 534
531 /* 535 /*
532 * Returns a name that does not clash with reserved JS keywords, 536 * Returns a name that does not clash with reserved JS keywords,
533 * and also ensures it won't clash with other identifiers. 537 * and also ensures it won't clash with other identifiers.
534 */ 538 */
535 String safeName(String name) { 539 String safeName(String name) {
536 if (jsReserved.contains(name) || name.startsWith(r'$')) { 540 if (jsReserved.contains(name) || name.startsWith(r'$')) {
537 name = '\$$name'; 541 name = '\$$name';
538 } 542 }
539 assert(!jsReserved.contains(name)); 543 assert(!jsReserved.contains(name));
540 return name; 544 return name;
541 } 545 }
542 546
547 String substitutionName(Element element) {
548 // TODO(karlklose): The runtime type system implementation in js_helper
549 // needs to know this name, because it uses a JS-call to read the field.
ngeoffray 2013/01/30 13:06:00 Ditto.
karlklose 2013/01/30 15:37:18 Done.
550 return '${operatorAsPrefix()}${getName(element)}';
551 }
552
543 String oneShotInterceptorName(Selector selector) { 553 String oneShotInterceptorName(Selector selector) {
544 // TODO(ngeoffray): What to do about typed selectors? We could 554 // TODO(ngeoffray): What to do about typed selectors? We could
545 // filter them out, or keep them and hope the generated one shot 555 // filter them out, or keep them and hope the generated one shot
546 // interceptor takes advantage of the type. 556 // interceptor takes advantage of the type.
547 String cached = oneShotInterceptorNames[selector]; 557 String cached = oneShotInterceptorNames[selector];
548 if (cached != null) return cached; 558 if (cached != null) return cached;
549 SourceString name = operatorNameToIdentifier(selector.name); 559 SourceString name = operatorNameToIdentifier(selector.name);
550 String result = getFreshName(name.slowToString(), usedGlobalNames); 560 String result = getFreshName(name.slowToString(), usedGlobalNames);
551 oneShotInterceptorNames[selector] = result; 561 oneShotInterceptorNames[selector] = result;
552 return result; 562 return result;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 return const SourceString(r'$or'); 605 return const SourceString(r'$or');
596 } else if (value == '-') { 606 } else if (value == '-') {
597 return const SourceString(r'$sub'); 607 return const SourceString(r'$sub');
598 } else if (value == 'unary-') { 608 } else if (value == 'unary-') {
599 return const SourceString(r'$negate'); 609 return const SourceString(r'$negate');
600 } else { 610 } else {
601 return name; 611 return name;
602 } 612 }
603 } 613 }
604 } 614 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698