2017-05-03 15:35:00 +02:00
|
|
|
var fs = require("fs");
|
|
|
|
|
2018-09-20 02:56:13 +02:00
|
|
|
exports.FILES = [
|
2017-05-03 15:35:00 +02:00
|
|
|
"../lib/utils.js",
|
|
|
|
"../lib/ast.js",
|
|
|
|
"../lib/parse.js",
|
|
|
|
"../lib/transform.js",
|
|
|
|
"../lib/scope.js",
|
|
|
|
"../lib/output.js",
|
|
|
|
"../lib/compress.js",
|
|
|
|
"../lib/sourcemap.js",
|
|
|
|
"../lib/mozilla-ast.js",
|
|
|
|
"../lib/propmangle.js",
|
2017-08-14 05:01:11 +02:00
|
|
|
"../lib/minify.js",
|
2017-05-03 15:35:00 +02:00
|
|
|
"./exports.js",
|
2018-09-20 02:56:13 +02:00
|
|
|
].map(function(file) {
|
2017-05-03 15:35:00 +02:00
|
|
|
return require.resolve(file);
|
|
|
|
});
|
|
|
|
|
2017-08-14 05:01:11 +02:00
|
|
|
new Function("MOZ_SourceMap", "exports", function() {
|
2018-09-20 02:56:13 +02:00
|
|
|
var code = exports.FILES.map(function(file) {
|
2017-08-14 05:01:11 +02:00
|
|
|
return fs.readFileSync(file, "utf8");
|
|
|
|
});
|
|
|
|
code.push("exports.describe_ast = " + describe_ast.toString());
|
|
|
|
return code.join("\n\n");
|
2018-09-20 02:56:13 +02:00
|
|
|
}())(require("source-map"), exports);
|
2017-05-03 15:35:00 +02:00
|
|
|
|
2017-08-14 05:01:11 +02:00
|
|
|
function describe_ast() {
|
|
|
|
var out = OutputStream({ beautify: true });
|
2017-05-03 15:35:00 +02:00
|
|
|
function doitem(ctor) {
|
|
|
|
out.print("AST_" + ctor.TYPE);
|
2018-09-20 02:56:13 +02:00
|
|
|
var props = ctor.SELF_PROPS.filter(function(prop) {
|
2017-05-03 15:35:00 +02:00
|
|
|
return !/^\$/.test(prop);
|
|
|
|
});
|
|
|
|
if (props.length > 0) {
|
|
|
|
out.space();
|
2018-09-20 02:56:13 +02:00
|
|
|
out.with_parens(function() {
|
|
|
|
props.forEach(function(prop, i) {
|
2017-05-03 15:35:00 +02:00
|
|
|
if (i) out.space();
|
|
|
|
out.print(prop);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (ctor.documentation) {
|
|
|
|
out.space();
|
|
|
|
out.print_string(ctor.documentation);
|
|
|
|
}
|
|
|
|
if (ctor.SUBCLASSES.length > 0) {
|
|
|
|
out.space();
|
2018-09-20 02:56:13 +02:00
|
|
|
out.with_block(function() {
|
|
|
|
ctor.SUBCLASSES.forEach(function(ctor, i) {
|
2017-05-03 15:35:00 +02:00
|
|
|
out.indent();
|
|
|
|
doitem(ctor);
|
|
|
|
out.newline();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
2017-08-14 05:01:11 +02:00
|
|
|
doitem(AST_Node);
|
|
|
|
return out + "\n";
|
2017-05-03 15:35:00 +02:00
|
|
|
}
|
|
|
|
|
2017-08-14 05:01:11 +02:00
|
|
|
function infer_options(options) {
|
2018-09-20 02:56:13 +02:00
|
|
|
var result = exports.minify("", options);
|
2017-08-14 05:01:11 +02:00
|
|
|
return result.error && result.error.defs;
|
|
|
|
}
|
2017-05-03 15:35:00 +02:00
|
|
|
|
2018-09-20 02:56:13 +02:00
|
|
|
exports.default_options = function() {
|
2017-08-14 05:01:11 +02:00
|
|
|
var defs = {};
|
|
|
|
Object.keys(infer_options({ 0: 0 })).forEach(function(component) {
|
|
|
|
var options = {};
|
|
|
|
options[component] = { 0: 0 };
|
|
|
|
if (options = infer_options(options)) {
|
|
|
|
defs[component] = options;
|
2017-05-03 15:35:00 +02:00
|
|
|
}
|
2017-08-14 05:01:11 +02:00
|
|
|
});
|
|
|
|
return defs;
|
2017-05-03 15:35:00 +02:00
|
|
|
};
|