Added node modules

This commit is contained in:
John Crepezzi 2012-02-06 14:09:01 -05:00
parent ca9d4c18f7
commit d1e0644a4e
575 changed files with 77900 additions and 6 deletions

75
node_modules/uglify-js/lib/object-ast.js generated vendored Normal file
View file

@ -0,0 +1,75 @@
var jsp = require("./parse-js"),
pro = require("./process");
var BY_TYPE = {};
function HOP(obj, prop) {
return Object.prototype.hasOwnProperty.call(obj, prop);
};
function AST_Node(parent) {
this.parent = parent;
};
AST_Node.prototype.init = function(){};
function DEFINE_NODE_CLASS(type, props, methods) {
var base = methods && methods.BASE || AST_Node;
if (!base) base = AST_Node;
function D(parent, data) {
base.apply(this, arguments);
if (props) props.forEach(function(name, i){
this["_" + name] = data[i];
});
this.init();
};
var P = D.prototype = new AST_Node;
P.node_type = function(){ return type };
if (props) props.forEach(function(name){
var propname = "_" + name;
P["set_" + name] = function(val) {
this[propname] = val;
return this;
};
P["get_" + name] = function() {
return this[propname];
};
});
if (type != null) BY_TYPE[type] = D;
if (methods) for (var i in methods) if (HOP(methods, i)) {
P[i] = methods[i];
}
return D;
};
var AST_String_Node = DEFINE_NODE_CLASS("string", ["value"]);
var AST_Number_Node = DEFINE_NODE_CLASS("num", ["value"]);
var AST_Name_Node = DEFINE_NODE_CLASS("name", ["value"]);
var AST_Statlist_Node = DEFINE_NODE_CLASS(null, ["body"]);
var AST_Root_Node = DEFINE_NODE_CLASS("toplevel", null, { BASE: AST_Statlist_Node });
var AST_Block_Node = DEFINE_NODE_CLASS("block", null, { BASE: AST_Statlist_Node });
var AST_Splice_Node = DEFINE_NODE_CLASS("splice", null, { BASE: AST_Statlist_Node });
var AST_Var_Node = DEFINE_NODE_CLASS("var", ["definitions"]);
var AST_Const_Node = DEFINE_NODE_CLASS("const", ["definitions"]);
var AST_Try_Node = DEFINE_NODE_CLASS("try", ["body", "catch", "finally"]);
var AST_Throw_Node = DEFINE_NODE_CLASS("throw", ["exception"]);
var AST_New_Node = DEFINE_NODE_CLASS("new", ["constructor", "arguments"]);
var AST_Switch_Node = DEFINE_NODE_CLASS("switch", ["expression", "branches"]);
var AST_Switch_Branch_Node = DEFINE_NODE_CLASS(null, ["expression", "body"]);
var AST_Break_Node = DEFINE_NODE_CLASS("break", ["label"]);
var AST_Continue_Node = DEFINE_NODE_CLASS("continue", ["label"]);
var AST_Assign_Node = DEFINE_NODE_CLASS("assign", ["operator", "lvalue", "rvalue"]);
var AST_Dot_Node = DEFINE_NODE_CLASS("dot", ["expression", "name"]);
var AST_Call_Node = DEFINE_NODE_CLASS("call", ["function", "arguments"]);
var AST_Lambda_Node = DEFINE_NODE_CLASS(null, ["name", "arguments", "body"])
var AST_Function_Node = DEFINE_NODE_CLASS("function", null, AST_Lambda_Node);
var AST_Defun_Node = DEFINE_NODE_CLASS("defun", null, AST_Lambda_Node);
var AST_If_Node = DEFINE_NODE_CLASS("if", ["condition", "then", "else"]);

1342
node_modules/uglify-js/lib/parse-js.js generated vendored Normal file

File diff suppressed because it is too large Load diff

2011
node_modules/uglify-js/lib/process.js generated vendored Normal file

File diff suppressed because it is too large Load diff

69
node_modules/uglify-js/lib/squeeze-more.js generated vendored Normal file
View file

@ -0,0 +1,69 @@
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, 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[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(pro.ast_add_scope(ast));
});
};
exports.ast_squeeze_more = ast_squeeze_more;