Skip to content
This repository has been archived by the owner on Jun 14, 2020. It is now read-only.

Commit

Permalink
Use latest UglifyJS and Node.js stuff. Fix sameTarget bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
Craga89 committed Mar 31, 2012
1 parent 8cb328c commit b0b49df
Show file tree
Hide file tree
Showing 11 changed files with 1,445 additions and 685 deletions.
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -30,9 +30,9 @@ QTIP_CSS_MIN = ${DIST_DIR}/jquery.qtip.min.css
QTIP_VER = `cat version.txt`
VER = sed s/@VERSION/${QTIP_VER}/

JS_ENGINE = `which nodejs node`
JS_ENGINE = `which node`
JS_LINT = ${JS_ENGINE} $(BUILD_DIR)/jslint-check.js
JS_MINIFIER = ${JS_ENGINE} ${BUILD_DIR}/uglify.js --extra
JS_MINIFIER = ${JS_ENGINE} ${BUILD_DIR}/uglify.js
CSS_MINIFIER = java -Xmx96m -jar ${BUILD_DIR}/yuicompressor.jar

DATE=`git log --pretty=format:'%ad' -1`
Expand Down
12 changes: 5 additions & 7 deletions build/jslint-check.js
@@ -1,5 +1,4 @@
var JSLINT = require("./lib/jslint").JSLINT,
print = require("sys").print,
src = require("fs").readFileSync("dist/jquery.qtip.js", "utf8");

JSLINT(src, { evil: true, forin: true, maxerr: 100 });
Expand All @@ -21,16 +20,15 @@ var e = JSLINT.errors, found = 0, w;
for ( var i = 0; i < e.length; i++ ) {
w = e[i];

if ( !ok[ w.reason ] ) {
found++;
print( "\n" + w.evidence + "\n" );
print( " Problem at line " + w.line + " character " + w.character + ": " + w.reason );
if (w && w.reason && w.evidence && !ok[ w.reason ] ) {
console.log( "\n" + w.evidence + "\n" );
console.log( " Problem at line " + w.line + " character " + w.character + ": " + w.reason );
}
}

if ( found > 0 ) {
print( "\n" + found + " Error(s) found.\n" );
console.log( "\n" + found + " Error(s) found.\n" );

} else {
print( "Success!\n" );
console.log( "Success!\n" );
}
420 changes: 268 additions & 152 deletions build/lib/parse-js.js

Large diffs are not rendered by default.

1,382 changes: 921 additions & 461 deletions build/lib/process.js

Large diffs are not rendered by default.

57 changes: 54 additions & 3 deletions build/lib/squeeze-more.js
Expand Up @@ -2,21 +2,72 @@ var jsp = require("./parse-js"),
pro = require("./process"),
slice = jsp.slice,
member = jsp.member,
curry = jsp.curry,
MAP = pro.MAP,
PRECEDENCE = jsp.PRECEDENCE,
OPERATORS = jsp.OPERATORS;

function ast_squeeze_more(ast) {
var w = pro.ast_walker(), walk = w.walk;
var w = pro.ast_walker(), walk = w.walk, scope;
function with_scope(s, cont) {
var save = scope, ret;
scope = s;
ret = cont();
scope = save;
return ret;
};
function _lambda(name, args, body) {
return [ this[0], name, args, with_scope(body.scope, curry(MAP, body, walk)) ];
};
return w.with_walkers({
"toplevel": function(body) {
return [ this[0], with_scope(this.scope, curry(MAP, body, walk)) ];
},
"function": _lambda,
"defun": _lambda,
"new": function(ctor, args) {
if (ctor[0] == "name") {
if (ctor[1] == "Array" && !scope.has("Array")) {
if (args.length != 1) {
return [ "array", args ];
} else {
return walk([ "call", [ "name", "Array" ], args ]);
}
} else if (ctor[1] == "Object" && !scope.has("Object")) {
if (!args.length) {
return [ "object", [] ];
} else {
return walk([ "call", [ "name", "Object" ], args ]);
}
} else if ((ctor[1] == "RegExp" || ctor[1] == "Function" || ctor[1] == "Error") && !scope.has(ctor[1])) {
return walk([ "call", [ "name", ctor[1] ], args]);
}
}
},
"call": function(expr, args) {
if (expr[0] == "dot" && expr[1][0] == "string" && args.length == 1
&& (args[0][1] > 0 && expr[2] == "substring" || expr[2] == "substr")) {
return [ "call", [ "dot", expr[1], "slice"], args];
}
if (expr[0] == "dot" && expr[2] == "toString" && args.length == 0) {
// foo.toString() ==> foo+""
return [ "binary", "+", expr[1], [ "string", "" ]];
}
if (expr[0] == "name") {
if (expr[1] == "Array" && args.length != 1 && !scope.has("Array")) {
return [ "array", args ];
}
if (expr[1] == "Object" && !args.length && !scope.has("Object")) {
return [ "object", [] ];
}
if (expr[1] == "String" && !scope.has("String")) {
return [ "binary", "+", args[0], [ "string", "" ]];
}
}
}
}, function() {
return walk(ast);
return walk(pro.ast_add_scope(ast));
});
};

exports.ast_squeeze_more = ast_squeeze_more;
exports.ast_squeeze_more = ast_squeeze_more;

0 comments on commit b0b49df

Please sign in to comment.