tree transformer api (WIP)
This commit is contained in:
@@ -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 }));
|
||||
|
||||
Reference in New Issue
Block a user