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

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: Cosmetic changes (comments). 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 26 matching lines...) Expand all
37 final String STATIC_CLOSURE_NAME_NAME = @'$name'; 37 final String STATIC_CLOSURE_NAME_NAME = @'$name';
38 final SourceString CLOSURE_INVOCATION_NAME = const SourceString(@'$call'); 38 final SourceString CLOSURE_INVOCATION_NAME = const SourceString(@'$call');
39 39
40 40
41 String closureInvocationName(Selector selector) { 41 String closureInvocationName(Selector selector) {
42 // TODO(floitsch): mangle, while not conflicting with instance names. 42 // TODO(floitsch): mangle, while not conflicting with instance names.
43 return instanceMethodInvocationName(null, CLOSURE_INVOCATION_NAME, 43 return instanceMethodInvocationName(null, CLOSURE_INVOCATION_NAME,
44 selector); 44 selector);
45 } 45 }
46 46
47 String breakLabelName(LabelElement label) {
48 return '\$${label.labelName}\$${label.target.nestingLevel}';
49 }
50
51 String implicitBreakLabelName(TargetElement target) {
52 return '\$${target.nestingLevel}';
53 }
54
55 // We sometimes handle continue targets differently from break targets,
56 // so we have special continue-only labels.
57 String continueLabelName(LabelElement label) {
58 return 'c\$${label.labelName}\$${label.target.nestingLevel}';
59 }
60
61 String implicitContinueLabelName(TargetElement target) {
62 return 'c\$${target.nestingLevel}';
63 }
64
47 /** Returns a non-unique name for the given closure element. */ 65 /** Returns a non-unique name for the given closure element. */
48 String closureName(Element element) { 66 String closureName(Element element) {
49 List<String> parts = <String>[]; 67 List<String> parts = <String>[];
50 SourceString ownName = element.name; 68 SourceString ownName = element.name;
51 if (ownName == null || ownName.stringValue == "") { 69 if (ownName == null || ownName.stringValue == "") {
52 parts.add("anon"); 70 parts.add("anon");
53 } else { 71 } else {
54 parts.add(ownName.slowToString()); 72 parts.add(ownName.slowToString());
55 } 73 }
56 for (Element enclosingElement = element.enclosingElement; 74 for (Element enclosingElement = element.enclosingElement;
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 } 301 }
284 302
285 String safeName(String name) { 303 String safeName(String name) {
286 if (jsReserved.contains(name) || name.startsWith('\$')) { 304 if (jsReserved.contains(name) || name.startsWith('\$')) {
287 name = "\$$name"; 305 name = "\$$name";
288 assert(!jsReserved.contains(name)); 306 assert(!jsReserved.contains(name));
289 } 307 }
290 return name; 308 return name;
291 } 309 }
292 } 310 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698