Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Enable mangling of global references #1326

Open
wants to merge 2 commits into
base: harmony
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Style updates
Update style and remove some commented code
AshleyScirra committed Oct 11, 2016
commit c8a71e279e5fa1a34798ca680341543d4e50b7ad
15 changes: 4 additions & 11 deletions lib/propmangle.js
Original file line number Diff line number Diff line change
@@ -84,7 +84,7 @@ function mangle_properties(ast, options) {
only_cache : false,
regex : null,
ignore_quoted : false,
treat_as_global : []
treat_as_global : [],
});

var reserved = options.reserved;
@@ -116,10 +116,6 @@ function mangle_properties(ast, options) {
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
ast.walk(new TreeWalker(function(node){
if (node instanceof AST_ObjectKeyVal) {
@@ -138,8 +134,7 @@ function mangle_properties(ast, options) {
node.expression instanceof AST_SymbolRef &&
node.expression.global() &&
is_global_alias(node.expression.name) &&
!is_global_alias(node.property))
{
!is_global_alias(node.property)) {
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.
if (mangle_globals &&
node.global() &&
!is_global_alias(node.name))
{
!is_global_alias(node.name)) {
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.
if (mangle_globals &&
node.global() &&
node.name in cache.global_defs)
{
node.name in cache.global_defs) {
var mangled_name = mangle(node.name);
node.name = mangled_name;
node.definition().mangled_name = mangled_name;