upgrade AST<->ESTree translation (#5554)
This commit is contained in:
@@ -192,6 +192,19 @@
|
|||||||
value: from_moz(M.value),
|
value: from_moz(M.value),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
StaticBlock: function(M) {
|
||||||
|
var start = my_start_token(M);
|
||||||
|
var end = my_end_token(M);
|
||||||
|
return new AST_ClassInit({
|
||||||
|
start: start,
|
||||||
|
end: end,
|
||||||
|
value: new AST_ClassInitBlock({
|
||||||
|
start: start,
|
||||||
|
end: end,
|
||||||
|
body: normalize_directives(M.body.map(from_moz)),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
},
|
||||||
ForOfStatement: function(M) {
|
ForOfStatement: function(M) {
|
||||||
return new (M.await ? AST_ForAwaitOf : AST_ForOf)({
|
return new (M.await ? AST_ForAwaitOf : AST_ForOf)({
|
||||||
start: my_start_token(M),
|
start: my_start_token(M),
|
||||||
@@ -714,6 +727,10 @@
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
def_to_moz(AST_ClassInit, function To_Moz_StaticBlock(M) {
|
||||||
|
return to_moz_scope("StaticBlock", M.value);
|
||||||
|
});
|
||||||
|
|
||||||
function To_Moz_ForOfStatement(is_await) {
|
function To_Moz_ForOfStatement(is_await) {
|
||||||
return function(M) {
|
return function(M) {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
"LICENSE"
|
"LICENSE"
|
||||||
],
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"acorn": "~8.2.1",
|
"acorn": "~8.7.1",
|
||||||
"semver": "~6.3.0"
|
"semver": "~6.3.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -9,19 +9,22 @@ function beautify(ast) {
|
|||||||
var beautified = UglifyJS.minify(ast, {
|
var beautified = UglifyJS.minify(ast, {
|
||||||
compress: false,
|
compress: false,
|
||||||
mangle: false,
|
mangle: false,
|
||||||
|
module: ufuzz.module,
|
||||||
output: {
|
output: {
|
||||||
|
ast: true,
|
||||||
beautify: true,
|
beautify: true,
|
||||||
braces: true,
|
braces: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (beautified.error) return beautified;
|
if (!beautified.error) {
|
||||||
return UglifyJS.minify(beautified.code, {
|
var verify = UglifyJS.minify(beautified.code, {
|
||||||
compress: false,
|
compress: false,
|
||||||
mangle: false,
|
mangle: false,
|
||||||
output: {
|
module: ufuzz.module,
|
||||||
ast: true,
|
});
|
||||||
},
|
if (verify.error) return verify;
|
||||||
});
|
}
|
||||||
|
return beautified;
|
||||||
}
|
}
|
||||||
|
|
||||||
function validate(ast) {
|
function validate(ast) {
|
||||||
@@ -35,6 +38,7 @@ function validate(ast) {
|
|||||||
return UglifyJS.minify(ast, {
|
return UglifyJS.minify(ast, {
|
||||||
compress: false,
|
compress: false,
|
||||||
mangle: false,
|
mangle: false,
|
||||||
|
module: ufuzz.module,
|
||||||
output: {
|
output: {
|
||||||
ast: true,
|
ast: true,
|
||||||
},
|
},
|
||||||
@@ -115,9 +119,13 @@ for (var round = 1; round <= num_iterations; round++) {
|
|||||||
var code = ufuzz.createTopLevelCode();
|
var code = ufuzz.createTopLevelCode();
|
||||||
minify_options.forEach(function(options) {
|
minify_options.forEach(function(options) {
|
||||||
var ok = true;
|
var ok = true;
|
||||||
var input = UglifyJS.minify(options ? UglifyJS.minify(code, JSON.parse(options)).code : code, {
|
var input = UglifyJS.minify(options ? function(options) {
|
||||||
|
options.module = ufuzz.module;
|
||||||
|
return UglifyJS.minify(code, options).code;
|
||||||
|
}(JSON.parse(options)) : code, {
|
||||||
compress: false,
|
compress: false,
|
||||||
mangle: false,
|
mangle: false,
|
||||||
|
module: ufuzz.module,
|
||||||
output: {
|
output: {
|
||||||
ast: true,
|
ast: true,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2095,7 +2095,11 @@ function createVarName(maybe, dontStore) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (require.main !== module) {
|
if (require.main !== module) {
|
||||||
exports.createTopLevelCode = createTopLevelCode;
|
exports.createTopLevelCode = function() {
|
||||||
|
var code = createTopLevelCode();
|
||||||
|
exports.module = async && has_await;
|
||||||
|
return code;
|
||||||
|
};
|
||||||
exports.num_iterations = num_iterations;
|
exports.num_iterations = num_iterations;
|
||||||
exports.verbose = verbose;
|
exports.verbose = verbose;
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user