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

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

Issue 10825180: Add JavaScript AST. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: updated. Created 8 years, 4 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 /** 5 /**
6 * Assigns JavaScript identifiers to Dart variables, class-names and members. 6 * Assigns JavaScript identifiers to Dart variables, class-names and members.
7 */ 7 */
8 class Namer { 8 class Namer {
9 final Compiler compiler; 9 final Compiler compiler;
10 10
(...skipping 24 matching lines...) Expand all
35 final String STATIC_CLOSURE_NAME_NAME = @'$name'; 35 final String STATIC_CLOSURE_NAME_NAME = @'$name';
36 final SourceString CLOSURE_INVOCATION_NAME = const SourceString(@'$call'); 36 final SourceString CLOSURE_INVOCATION_NAME = const SourceString(@'$call');
37 37
38 38
39 String closureInvocationName(Selector selector) { 39 String closureInvocationName(Selector selector) {
40 // TODO(floitsch): mangle, while not conflicting with instance names. 40 // TODO(floitsch): mangle, while not conflicting with instance names.
41 return instanceMethodInvocationName(null, CLOSURE_INVOCATION_NAME, 41 return instanceMethodInvocationName(null, CLOSURE_INVOCATION_NAME,
42 selector); 42 selector);
43 } 43 }
44 44
45 String breakLabelName(LabelElement label) {
46 return '\$${label.labelName}\$${label.target.nestingLevel}';
47 }
48
49 String implicitBreakLabelName(TargetElement target) {
50 return '\$${target.nestingLevel}';
51 }
52
53 // We sometimes handle continue targets differently from break targets,
54 // so we have special continue-only labels.
55 String continueLabelName(LabelElement label) {
56 return 'c\$${label.labelName}\$${label.target.nestingLevel}';
57 }
58
59 String implicitContinueLabelName(TargetElement target) {
60 return 'c\$${target.nestingLevel}';
61 }
62
45 /** Returns a non-unique name for the given closure element. */ 63 /** Returns a non-unique name for the given closure element. */
46 String closureName(Element element) { 64 String closureName(Element element) {
47 List<String> parts = <String>[]; 65 List<String> parts = <String>[];
48 SourceString ownName = element.name; 66 SourceString ownName = element.name;
49 if (ownName == null || ownName.stringValue == "") { 67 if (ownName == null || ownName.stringValue == "") {
50 parts.add("anon"); 68 parts.add("anon");
51 } else { 69 } else {
52 parts.add(ownName.slowToString()); 70 parts.add(ownName.slowToString());
53 } 71 }
54 for (Element enclosingElement = element.enclosingElement; 72 for (Element enclosingElement = element.enclosingElement;
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 } 292 }
275 293
276 String safeName(String name) { 294 String safeName(String name) {
277 if (jsReserved.contains(name) || name.startsWith('\$')) { 295 if (jsReserved.contains(name) || name.startsWith('\$')) {
278 name = "\$$name"; 296 name = "\$$name";
279 assert(!jsReserved.contains(name)); 297 assert(!jsReserved.contains(name));
280 } 298 }
281 return name; 299 return name;
282 } 300 }
283 } 301 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698