Style updates

Update style and remove some commented code
This commit is contained in:
Ashley (Scirra) 2016-10-11 13:17:40 +01:00
parent 58459d0e60
commit c8a71e279e

View File

@ -84,7 +84,7 @@ function mangle_properties(ast, options) {
only_cache : false, only_cache : false,
regex : null, regex : null,
ignore_quoted : false, ignore_quoted : false,
treat_as_global : [] treat_as_global : [],
}); });
var reserved = options.reserved; var reserved = options.reserved;
@ -116,10 +116,6 @@ function mangle_properties(ast, options) {
return treat_as_global.indexOf(name) >= 0; return treat_as_global.indexOf(name) >= 0;
} }
// TODO: don't know if this is necessary to get scope information?
//if (mangle_globals)
// ast.figure_out_scope();
// step 1: find candidates to mangle // step 1: find candidates to mangle
ast.walk(new TreeWalker(function(node){ ast.walk(new TreeWalker(function(node){
if (node instanceof AST_ObjectKeyVal) { if (node instanceof AST_ObjectKeyVal) {
@ -138,8 +134,7 @@ function mangle_properties(ast, options) {
node.expression instanceof AST_SymbolRef && node.expression instanceof AST_SymbolRef &&
node.expression.global() && node.expression.global() &&
is_global_alias(node.expression.name) && is_global_alias(node.expression.name) &&
!is_global_alias(node.property)) !is_global_alias(node.property)) {
{
cache.global_defs[node.property] = true; cache.global_defs[node.property] = true;
} }
} }
@ -154,8 +149,7 @@ function mangle_properties(ast, options) {
// be a local variable in scope), also treat it as a global definition. // be a local variable in scope), also treat it as a global definition.
if (mangle_globals && if (mangle_globals &&
node.global() && node.global() &&
!is_global_alias(node.name)) !is_global_alias(node.name)) {
{
cache.global_defs[node.name] = true; cache.global_defs[node.name] = true;
} }
} }
@ -188,8 +182,7 @@ function mangle_properties(ast, options) {
// and it's on our list of global definitions, then mangle it. // and it's on our list of global definitions, then mangle it.
if (mangle_globals && if (mangle_globals &&
node.global() && node.global() &&
node.name in cache.global_defs) node.name in cache.global_defs) {
{
var mangled_name = mangle(node.name); var mangled_name = mangle(node.name);
node.name = mangled_name; node.name = mangled_name;
node.definition().mangled_name = mangled_name; node.definition().mangled_name = mangled_name;