tree transformer api (WIP)

This commit is contained in:
Mihai Bazon
2012-09-22 13:32:32 +03:00
parent ec7f895b54
commit 76d88b59dc
4 changed files with 253 additions and 16 deletions

View File

@@ -9,15 +9,31 @@ var filename = process.argv[2];
var code = fs.readFileSync(filename, "utf8");
var ast = UglifyJS.parse(code);
ast.figure_out_scope();
ast = ast.squeeze(UglifyJS.Compressor());
ast.compute_char_frequency();
UglifyJS.base54.sort();
var tt = new UglifyJS.TreeTransformer(
function before(node, descend) {
if (node instanceof UglifyJS.AST_Var) {
//return new UglifyJS.AST_EmptyStatement(node);
return UglifyJS.MAP.skip;
}
},
function after(node) {
console.log("After ", node.TYPE);
}
);
ast.figure_out_scope();
ast.scope_warnings();
ast.mangle_names();
var x = ast.transform(tt);
sys.print(x.print_to_string({ beautify: true }));
sys.error(UglifyJS.base54.get());
sys.print(ast.print_to_string({ beautify: true }));
// ast.figure_out_scope();
// ast = ast.squeeze(UglifyJS.Compressor());
// ast.compute_char_frequency();
// UglifyJS.base54.sort();
// ast.figure_out_scope();
// ast.scope_warnings();
// ast.mangle_names();
// sys.error(UglifyJS.base54.get());
// sys.print(ast.print_to_string({ beautify: true }));