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

Side by Side Diff: pkg/compiler/lib/src/js_backend/namer.dart

Issue 1232463007: dart2js: Rename "current isolate" to "static state (holder)". (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments. Created 5 years, 5 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
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 * Names are generated through three stages: 10 * Names are generated through three stages:
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 _jsVariableReserved.addAll(reservedGlobalSymbols); 314 _jsVariableReserved.addAll(reservedGlobalSymbols);
315 _jsVariableReserved.addAll(reservedGlobalObjectNames); 315 _jsVariableReserved.addAll(reservedGlobalObjectNames);
316 // 26 letters in the alphabet, 25 not counting I. 316 // 26 letters in the alphabet, 25 not counting I.
317 assert(reservedGlobalObjectNames.length == 25); 317 assert(reservedGlobalObjectNames.length == 25);
318 _jsVariableReserved.addAll(reservedGlobalHelperFunctions); 318 _jsVariableReserved.addAll(reservedGlobalHelperFunctions);
319 } 319 }
320 return _jsVariableReserved; 320 return _jsVariableReserved;
321 } 321 }
322 322
323 final String asyncPrefix = r"$async$"; 323 final String asyncPrefix = r"$async$";
324 final String currentIsolate = r'$'; 324 final String staticStateHolder = r'$';
325 final String getterPrefix = r'get$'; 325 final String getterPrefix = r'get$';
326 final String lazyGetterPrefix = r'$get$'; 326 final String lazyGetterPrefix = r'$get$';
327 final String setterPrefix = r'set$'; 327 final String setterPrefix = r'set$';
328 final String superPrefix = r'super$'; 328 final String superPrefix = r'super$';
329 final String metadataField = '@'; 329 final String metadataField = '@';
330 final String callPrefix = 'call'; 330 final String callPrefix = 'call';
331 final String callCatchAllName = r'call*'; 331 final String callCatchAllName = r'call*';
332 final String callNameField = r'$callName'; 332 final String callNameField = r'$callName';
333 final String reflectableField = r'$reflectable'; 333 final String reflectableField = r'$reflectable';
334 final String reflectionInfoField = r'$reflectionInfo'; 334 final String reflectionInfoField = r'$reflectionInfo';
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 /// parameters. 1306 /// parameters.
1307 /// 1307 ///
1308 /// The name is not necessarily unique to [method], since a static method 1308 /// The name is not necessarily unique to [method], since a static method
1309 /// may share its name with an instance method. 1309 /// may share its name with an instance method.
1310 jsAst.Name methodPropertyName(Element method) { 1310 jsAst.Name methodPropertyName(Element method) {
1311 return method.isInstanceMember 1311 return method.isInstanceMember
1312 ? instanceMethodName(method) 1312 ? instanceMethodName(method)
1313 : globalPropertyName(method); 1313 : globalPropertyName(method);
1314 } 1314 }
1315 1315
1316 /// Returns true if [element] is stored on current isolate ('$'). We intend 1316 /// Returns true if [element] is stored in the static state holder
1317 /// to store only mutable static state in [currentIsolate], constants are 1317 /// ([staticStateHolder]). We intend to store only mutable static state
1318 /// stored in 'C', and functions, accessors, classes, etc. are stored in one 1318 /// there, whereas constants are stored in 'C'. Functions, accessors,
1319 /// of the other objects in [reservedGlobalObjectNames]. 1319 /// classes, etc. are stored in one of the other objects in
1320 bool isPropertyOfCurrentIsolate(Element element) { 1320 /// [reservedGlobalObjectNames].
1321 bool _isPropertyOfStaticStateHolder(Element element) {
1321 // TODO(ahe): Make sure this method's documentation is always true and 1322 // TODO(ahe): Make sure this method's documentation is always true and
1322 // remove the word "intend". 1323 // remove the word "intend".
1323 return 1324 return
1324 // TODO(ahe): Re-write these tests to be positive (so it only returns 1325 // TODO(ahe): Re-write these tests to be positive (so it only returns
1325 // true for static/top-level mutable fields). Right now, a number of 1326 // true for static/top-level mutable fields). Right now, a number of
1326 // other elements, such as bound closures also live in [currentIsolate]. 1327 // other elements, such as bound closures also live in
1328 // [staticStateHolder].
1327 !element.isAccessor && 1329 !element.isAccessor &&
1328 !element.isClass && 1330 !element.isClass &&
1329 !element.isTypedef && 1331 !element.isTypedef &&
1330 !element.isConstructor && 1332 !element.isConstructor &&
1331 !element.isFunction && 1333 !element.isFunction &&
1332 !element.isLibrary; 1334 !element.isLibrary;
1333 } 1335 }
1334 1336
1335 /// Returns [currentIsolate] or one of [reservedGlobalObjectNames]. 1337 /// Returns [staticStateHolder] or one of [reservedGlobalObjectNames].
1336 String globalObjectFor(Element element) { 1338 String globalObjectFor(Element element) {
1337 if (isPropertyOfCurrentIsolate(element)) return currentIsolate; 1339 if (_isPropertyOfStaticStateHolder(element)) return staticStateHolder;
1338 LibraryElement library = element.library; 1340 LibraryElement library = element.library;
1339 if (library == backend.interceptorsLibrary) return 'J'; 1341 if (library == backend.interceptorsLibrary) return 'J';
1340 if (library.isInternalLibrary) return 'H'; 1342 if (library.isInternalLibrary) return 'H';
1341 if (library.isPlatformLibrary) { 1343 if (library.isPlatformLibrary) {
1342 if ('${library.canonicalUri}' == 'dart:html') return 'W'; 1344 if ('${library.canonicalUri}' == 'dart:html') return 'W';
1343 return 'P'; 1345 return 'P';
1344 } 1346 }
1345 return userGlobalObjects[ 1347 return userGlobalObjects[
1346 library.getLibraryOrScriptName().hashCode % userGlobalObjects.length]; 1348 library.getLibraryOrScriptName().hashCode % userGlobalObjects.length];
1347 } 1349 }
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
1979 } 1981 }
1980 } 1982 }
1981 } 1983 }
1982 } 1984 }
1983 1985
1984 enum NamingScope { 1986 enum NamingScope {
1985 global, 1987 global,
1986 instance, 1988 instance,
1987 constant 1989 constant
1988 } 1990 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart ('k') | pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698