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

Unified Diff: lib/src/codegen/js_names.dart

Issue 1111893002: small refactor: use JS.* prefix for our other JS extensions (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « lib/src/codegen/js_metalet.dart ('k') | lib/src/codegen/js_printer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/codegen/js_names.dart
diff --git a/lib/src/codegen/js_names.dart b/lib/src/codegen/js_names.dart
index ea3eed336713814fcd80e24c90e60caa6b5261f4..2ca5fe2ab47ab031366d4dd646d2d0e227491628 100644
--- a/lib/src/codegen/js_names.dart
+++ b/lib/src/codegen/js_names.dart
@@ -13,8 +13,8 @@ import 'package:dev_compiler/src/js/js_ast.dart';
/// generation without needing global knowledge. See [JSNamer].
///
// TODO(jmesserly): move into js_ast? add a boolean to Identifier?
-class JSTemporary extends Identifier {
- JSTemporary(String name) : super(name);
+class TemporaryId extends Identifier {
+ TemporaryId(String name) : super(name);
}
/// This class has two purposes:
@@ -28,10 +28,10 @@ class JSTemporary extends Identifier {
/// [Identifiers] are never renamed unless they are an invalid identifier, like
/// `function` or `instanceof`, and their `name` field controls whether they
/// refer to the same variable.
-class JSNamer extends LocalNamer {
+class TemporaryNamer extends LocalNamer {
final Map<Object, String> renames;
- JSNamer(Node node) : renames = new _RenameVisitor.build(node).renames;
+ TemporaryNamer(Node node) : renames = new _RenameVisitor.build(node).renames;
String getName(Identifier node) {
var rename = renames[identifierKey(node)];
@@ -152,9 +152,9 @@ class _RenameVisitor extends VariableDeclarationVisitor {
static String _findName(Object id, Set<String> usedNames) {
String name;
bool valid;
- if (id is JSTemporary) {
+ if (id is TemporaryId) {
name = id.name;
- valid = !invalidJSVariableName(name);
+ valid = !invalidVariableName(name);
} else {
name = id;
valid = false;
@@ -179,14 +179,14 @@ class _RenameVisitor extends VariableDeclarationVisitor {
}
bool needsRename(Identifier node) =>
- node is JSTemporary || node.allowRename && invalidJSVariableName(node.name);
+ node is TemporaryId || node.allowRename && invalidVariableName(node.name);
Object /*String|JSTemporary*/ identifierKey(Identifier node) =>
- node is JSTemporary ? node : node.name;
+ node is TemporaryId ? node : node.name;
/// Returns true for invalid JS variable names, such as keywords.
/// Also handles invalid variable names in strict mode, like "arguments".
-bool invalidJSVariableName(String keyword, {bool strictMode: true}) {
+bool invalidVariableName(String keyword, {bool strictMode: true}) {
switch (keyword) {
case "break":
case "case":
@@ -233,7 +233,7 @@ bool invalidJSVariableName(String keyword, {bool strictMode: true}) {
/// Returns true for invalid static method names in strict mode.
/// In particular, "caller" "callee" and "arguments" cannot be used.
-bool invalidJSStaticMethodName(String name) {
+bool invalidStaticMethodName(String name) {
switch (name) {
case "arguments":
case "caller":
« no previous file with comments | « lib/src/codegen/js_metalet.dart ('k') | lib/src/codegen/js_printer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698