| | |
| | | var path = require("path"); |
| | | var UglifyJS = require("../tools/node"); |
| | | |
| | | var skip_keys = [ "cname", "fixed", "inlined", "parent_scope", "scope", "uses_eval", "uses_with" ]; |
| | | var skip_keys = [ "cname", "fixed", "in_arg", "inlined", "length_read", "parent_scope", "redef", "scope", "unused" ]; |
| | | var truthy_keys = [ "optional", "pure", "terminal", "uses_arguments", "uses_eval", "uses_with" ]; |
| | | |
| | | var files = {}; |
| | | var options = {}; |
| | | var short_forms = { |
| | |
| | | } else { |
| | | if (padding.length < name.length) padding = Array(name.length + 1).join(" "); |
| | | toplevels.push([ { |
| | | keep_fargs: "keep-fargs", |
| | | keep_fnames: "keep-fnames", |
| | | nameCache: "name-cache", |
| | | }[name] || name, option ]); |
| | |
| | | " -d, --define <expr>[=value] Global definitions.", |
| | | " -e, --enclose [arg[,...][:value[,...]]] Embed everything in a big function, with configurable argument(s) & value(s).", |
| | | " --ie Support non-standard Internet Explorer.", |
| | | " --keep-fargs Do not mangle/drop function arguments.", |
| | | " --keep-fnames Do not mangle/drop function names. Useful for code relying on Function.prototype.name.", |
| | | " --name-cache <file> File to hold mangled name mappings.", |
| | | " --rename Force symbol expansion.", |
| | |
| | | break; |
| | | case "no-annotations": |
| | | options.annotations = false; |
| | | break; |
| | | case "keep-fargs": |
| | | options.keep_fargs = true; |
| | | break; |
| | | case "keep-fnames": |
| | | options.keep_fnames = true; |
| | |
| | | case "thedef": |
| | | return symdef(value); |
| | | } |
| | | if (skip_key(key)) return; |
| | | if (skip_property(key, value)) return; |
| | | if (value instanceof UglifyJS.AST_Token) return; |
| | | if (value instanceof UglifyJS.Dictionary) return; |
| | | if (value instanceof UglifyJS.AST_Node) { |
| | |
| | | } |
| | | |
| | | function parse_js(value, options, flag) { |
| | | if (!options || typeof options != "object") options = {}; |
| | | if (!options || typeof options != "object") options = Object.create(null); |
| | | if (typeof value == "string") try { |
| | | UglifyJS.parse(value, { |
| | | expression: true |
| | |
| | | return options; |
| | | } |
| | | |
| | | function skip_key(key) { |
| | | return skip_keys.indexOf(key) >= 0; |
| | | function skip_property(key, value) { |
| | | return skip_keys.indexOf(key) >= 0 |
| | | // only skip truthy_keys if their value is falsy |
| | | || truthy_keys.indexOf(key) >= 0 && !value; |
| | | } |
| | | |
| | | function symdef(def) { |