"use strict";
-var KEYWORDS = 'break case catch const continue debugger default delete do else finally for function if in instanceof new return switch throw try typeof var void while with';
-var KEYWORDS_ATOM = 'false null true';
-var RESERVED_WORDS = 'abstract boolean byte char class double enum export extends final float goto implements import int interface let long native package private protected public short static super synchronized this throws transient volatile yield'
- + " " + KEYWORDS_ATOM + " " + KEYWORDS;
-var KEYWORDS_BEFORE_EXPRESSION = 'return new delete throw else case';
+var KEYWORDS = "break case catch const continue debugger default delete do else finally for function if in instanceof new return switch throw try typeof var void while with";
+var KEYWORDS_ATOM = "false null true";
+var RESERVED_WORDS = [
+ "abstract boolean byte char class double enum export extends final float goto implements import int interface let long native package private protected public short static super synchronized this throws transient volatile yield",
+ KEYWORDS_ATOM,
+ KEYWORDS,
+].join(" ");
+var KEYWORDS_BEFORE_EXPRESSION = "return new delete throw else case";
KEYWORDS = makePredicate(KEYWORDS);
RESERVED_WORDS = makePredicate(RESERVED_WORDS);
var skip_multiline_comment = with_eof_error("Unterminated multiline comment", function() {
var regex_allowed = S.regex_allowed;
var i = find("*/", true);
- var text = S.text.substring(S.pos, i).replace(/\r\n|\r|\u2028|\u2029/g, '\n');
+ var text = S.text.substring(S.pos, i).replace(/\r\n|\r|\u2028|\u2029/g, "\n");
// update stream position
forward(text.length /* doesn't count \r\n as 2 char while S.pos - i does */ + 2);
S.comments_before.push(token("comment2", text, true));
function names_in_use(scope, options) {
var names = scope.names_in_use;
if (!names) {
- scope.names_in_use = names = Object.create(scope.mangled_names || null);
+ scope.names_in_use = names = Object.create(null);
scope.cname_holes = [];
var cache = options.cache && options.cache.props;
scope.enclosed.forEach(function(def) {
name = base54(holes[i]);
if (names[name]) continue;
holes.splice(i, 1);
- scope.names_in_use[name] = true;
+ in_use[name] = true;
return name;
}
while (true) {
if (!names[name]) break;
holes.push(scope.cname);
}
- scope.names_in_use[name] = true;
+ in_use[name] = true;
return name;
}
var lname = -1;
if (options.cache && options.cache.props) {
- var mangled_names = this.mangled_names = Object.create(null);
+ var mangled_names = names_in_use(this, options);
options.cache.props.each(function(mangled_name) {
mangled_names[mangled_name] = true;
});
AST_Toplevel.DEFMETHOD("find_colliding_names", function(options) {
var cache = options.cache && options.cache.props;
- var avoid = Object.create(null);
+ var avoid = Object.create(RESERVED_WORDS);
options.reserved.forEach(to_avoid);
this.globals.each(add_def);
this.walk(new TreeWalker(function(node) {
var name;
do {
name = base54(cname++);
- } while (avoid[name] || RESERVED_WORDS[name]);
+ } while (avoid[name]);
return name;
}