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

Unified Diff: pkg/compiler/lib/src/js_backend/namer.dart

Issue 1224603002: dart2js: Use separate namespace for constants. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/js_backend/namer.dart
diff --git a/pkg/compiler/lib/src/js_backend/namer.dart b/pkg/compiler/lib/src/js_backend/namer.dart
index 8d33b516333baa3075cac0edccff54f52b6eb77f..9ce0b81c84ef8461f7b45a656acece7e8fba51d7 100644
--- a/pkg/compiler/lib/src/js_backend/namer.dart
+++ b/pkg/compiler/lib/src/js_backend/namer.dart
@@ -387,12 +387,17 @@ class Namer {
final Map<String, jsAst.Name> userInstanceOperators =
new HashMap<String, jsAst.Name>();
+ /// Used to disambiguate names for constants in [constantName].
+ final Set<String> usedConstantNames = new Set<String>();
+
Set<String> getUsedNames(NamingScope scope) {
if (scope == NamingScope.global) {
return usedGlobalNames;
- } else {
- assert(scope == NamingScope.instance);
+ } else if (scope == NamingScope.instance){
return usedInstanceNames;
+ } else {
+ assert(scope == NamingScope.constant);
+ return usedConstantNames;
}
}
@@ -425,9 +430,11 @@ class Namer {
Map<String, String> getSuggestedNames(NamingScope scope) {
if (scope == NamingScope.global) {
return suggestedGlobalNames;
- } else {
- assert(scope == NamingScope.instance);
+ } else if (scope == NamingScope.instance) {
return suggestedInstanceNames;
+ } else {
+ assert(scope == NamingScope.constant);
+ return const {};
}
}
@@ -524,7 +531,7 @@ class Namer {
jsAst.Name result = constantNames[constant];
if (result == null) {
String longName = constantLongName(constant);
- result = getFreshName(NamingScope.global, longName);
+ result = getFreshName(NamingScope.constant, longName);
constantNames[constant] = result;
}
return result;
@@ -1976,5 +1983,6 @@ class FunctionTypeNamer extends BaseDartTypeVisitor {
enum NamingScope {
global,
- instance
+ instance,
+ constant
}
« no previous file with comments | « no previous file | pkg/js_ast/test/printer_callback_test.dart » ('j') | pkg/js_ast/test/printer_callback_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698