OLD | NEW |
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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 Set<String> get jsVariableReserved { | 165 Set<String> get jsVariableReserved { |
166 if (_jsVariableReserved == null) { | 166 if (_jsVariableReserved == null) { |
167 _jsVariableReserved = new Set<String>(); | 167 _jsVariableReserved = new Set<String>(); |
168 _jsVariableReserved.addAll(javaScriptKeywords); | 168 _jsVariableReserved.addAll(javaScriptKeywords); |
169 _jsVariableReserved.addAll(reservedPropertySymbols); | 169 _jsVariableReserved.addAll(reservedPropertySymbols); |
170 _jsVariableReserved.addAll(reservedGlobalSymbols); | 170 _jsVariableReserved.addAll(reservedGlobalSymbols); |
171 } | 171 } |
172 return _jsVariableReserved; | 172 return _jsVariableReserved; |
173 } | 173 } |
174 | 174 |
175 final String CURRENT_ISOLATE = r'$'; | 175 final String CURRENT_ISOLATE; |
176 | 176 |
177 final String getterPrefix = r'get$'; | 177 final String getterPrefix = r'get$'; |
178 final String setterPrefix = r'set$'; | 178 final String setterPrefix = r'set$'; |
179 | 179 |
180 /** | 180 /** |
181 * Map from top-level or static elements to their unique identifiers provided | 181 * Map from top-level or static elements to their unique identifiers provided |
182 * by [getName]. | 182 * by [getName]. |
183 * | 183 * |
184 * Invariant: Keys must be declaration elements. | 184 * Invariant: Keys must be declaration elements. |
185 */ | 185 */ |
(...skipping 11 matching lines...) Expand all Loading... |
197 final Map<String, String> operatorNameMap; | 197 final Map<String, String> operatorNameMap; |
198 final Map<String, int> popularNameCounters; | 198 final Map<String, int> popularNameCounters; |
199 | 199 |
200 final Map<Element, String> bailoutNames; | 200 final Map<Element, String> bailoutNames; |
201 | 201 |
202 final Map<Constant, String> constantNames; | 202 final Map<Constant, String> constantNames; |
203 ConstantCanonicalHasher constantHasher; | 203 ConstantCanonicalHasher constantHasher; |
204 | 204 |
205 Namer(Compiler compiler) | 205 Namer(Compiler compiler) |
206 : compiler = compiler, | 206 : compiler = compiler, |
| 207 CURRENT_ISOLATE = compiler.globalJsName, |
207 globals = new Map<Element, String>(), | 208 globals = new Map<Element, String>(), |
208 shortPrivateNameOwners = new Map<String, LibraryElement>(), | 209 shortPrivateNameOwners = new Map<String, LibraryElement>(), |
209 bailoutNames = new Map<Element, String>(), | 210 bailoutNames = new Map<Element, String>(), |
210 usedGlobalNames = new Set<String>(), | 211 usedGlobalNames = new Set<String>(), |
211 usedInstanceNames = new Set<String>(), | 212 usedInstanceNames = new Set<String>(), |
212 instanceNameMap = new Map<String, String>(), | 213 instanceNameMap = new Map<String, String>(), |
213 operatorNameMap = new Map<String, String>(), | 214 operatorNameMap = new Map<String, String>(), |
214 globalNameMap = new Map<String, String>(), | 215 globalNameMap = new Map<String, String>(), |
215 suggestedGlobalNames = new Map<String, String>(), | 216 suggestedGlobalNames = new Map<String, String>(), |
216 suggestedInstanceNames = new Map<String, String>(), | 217 suggestedInstanceNames = new Map<String, String>(), |
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1152 hash = hash ^ (hash >> 6); | 1153 hash = hash ^ (hash >> 6); |
1153 return hash; | 1154 return hash; |
1154 } | 1155 } |
1155 | 1156 |
1156 static int _finish(int hash) { | 1157 static int _finish(int hash) { |
1157 hash = _MASK & (hash + (((_MASK >> 3) & hash) << 3)); | 1158 hash = _MASK & (hash + (((_MASK >> 3) & hash) << 3)); |
1158 hash = hash & (hash >> 11); | 1159 hash = hash & (hash >> 11); |
1159 return _MASK & (hash + (((_MASK >> 15) & hash) << 15)); | 1160 return _MASK & (hash + (((_MASK >> 15) & hash) << 15)); |
1160 } | 1161 } |
1161 } | 1162 } |
OLD | NEW |