Merge branch '8013p' of https://github.com/rwldrn/jquery into rwldrn-8013p
[jquery.git] / build / lib / squeeze-more.js
1 var jsp = require("./parse-js"),
2     pro = require("./process"),
3     slice = jsp.slice,
4     member = jsp.member,
5     PRECEDENCE = jsp.PRECEDENCE,
6     OPERATORS = jsp.OPERATORS;
7
8 function ast_squeeze_more(ast) {
9         var w = pro.ast_walker(), walk = w.walk;
10         return w.with_walkers({
11                 "call": function(expr, args) {
12                         if (expr[0] == "dot" && expr[2] == "toString" && args.length == 0) {
13                                 // foo.toString()  ==>  foo+""
14                                 return [ "binary", "+", expr[1], [ "string", "" ]];
15                         }
16                 }
17         }, function() {
18                 return walk(ast);
19         });
20 };
21
22 exports.ast_squeeze_more = ast_squeeze_more;