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

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

Issue 10574046: Remove static fields in the namer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove spurious "else". Created 8 years, 6 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
11 static final CLOSURE_INVOCATION_NAME = const SourceString('\$call');
12 static final STATIC_CLOSURE_NAME_NAME = '\$name';
13 static final OPERATOR_EQUALS = const SourceString('operator\$eq');
14
15 static Set<String> _jsReserved = null; 11 static Set<String> _jsReserved = null;
16 Set<String> get jsReserved() { 12 Set<String> get jsReserved() {
17 if (_jsReserved === null) { 13 if (_jsReserved === null) {
18 _jsReserved = new Set<String>(); 14 _jsReserved = new Set<String>();
19 _jsReserved.addAll(JsNames.javaScriptKeywords); 15 _jsReserved.addAll(JsNames.javaScriptKeywords);
20 _jsReserved.addAll(JsNames.reservedPropertySymbols); 16 _jsReserved.addAll(JsNames.reservedPropertySymbols);
21 } 17 }
22 return _jsReserved; 18 return _jsReserved;
23 } 19 }
24 20
25 Map<Element, String> globals; 21 Map<Element, String> globals;
26 Map<String, int> usedGlobals; 22 Map<String, int> usedGlobals;
27 Map<String, LibraryElement> shortPrivateNameOwners; 23 Map<String, LibraryElement> shortPrivateNameOwners;
28 24
29 Namer(this.compiler) 25 Namer(this.compiler)
30 : globals = new Map<Element, String>(), 26 : globals = new Map<Element, String>(),
31 usedGlobals = new Map<String, int>(), 27 usedGlobals = new Map<String, int>(),
32 shortPrivateNameOwners = new Map<String, LibraryElement>(); 28 shortPrivateNameOwners = new Map<String, LibraryElement>();
33 29
34 final String CURRENT_ISOLATE = "\$"; 30 final String CURRENT_ISOLATE = "\$";
35 final String ISOLATE = "Isolate"; 31 final String ISOLATE = "Isolate";
36 final String ISOLATE_PROPERTIES = "\$isolateProperties"; 32 final String ISOLATE_PROPERTIES = "\$isolateProperties";
33 /** Some closures must contain their name. The name is stored in
34 * [STATIC_CLOSURE_NAME_NAME]. */
35 final String STATIC_CLOSURE_NAME_NAME = '\$name';
ahe 2012/06/20 19:45:52 Raw string?
floitsch 2012/06/20 20:29:30 Done.
36 final SourceString CLOSURE_INVOCATION_NAME = const SourceString('\$call');
ahe 2012/06/20 19:45:52 Ditto.
floitsch 2012/06/20 20:29:30 Done.
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 privateName(LibraryElement lib, SourceString name) { 45 String privateName(LibraryElement lib, SourceString name) {
46 if (name.isPrivate()) { 46 if (name.isPrivate()) {
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 } 239 }
240 240
241 String safeName(String name) { 241 String safeName(String name) {
242 if (jsReserved.contains(name) || name.startsWith('\$')) { 242 if (jsReserved.contains(name) || name.startsWith('\$')) {
243 name = "\$$name"; 243 name = "\$$name";
244 assert(!jsReserved.contains(name)); 244 assert(!jsReserved.contains(name));
245 } 245 }
246 return name; 246 return name;
247 } 247 }
248 } 248 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698