mirror of
https://github.com/swc-project/swc.git
synced 2024-12-22 21:21:31 +03:00
feat(es/ast): Implement Take
for more types (#2649)
This commit is contained in:
parent
04befab67a
commit
0414c31480
2
.github/workflows/bench.yml
vendored
2
.github/workflows/bench.yml
vendored
@ -47,7 +47,7 @@ jobs:
|
||||
cargo-bench-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Run benchmark
|
||||
run: cargo bench --all | tee output.txt
|
||||
run: cargo bench --all --exclude swc_plugin | tee output.txt
|
||||
|
||||
- name: Download previous benchmark results
|
||||
run: mkdir raw-data && curl -o raw-data/benchmark-data.json https://raw.githubusercontent.com/swc-project/raw-data/gh-pages/benchmark-data.json
|
||||
|
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -3191,7 +3191,7 @@ dependencies = [
|
||||
"swc_ecma_codegen",
|
||||
"swc_ecma_utils",
|
||||
"swc_ecma_visit",
|
||||
"swc_plugin",
|
||||
"swc_plugin_api",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -79,6 +79,7 @@ allow = [
|
||||
"CC0-1.0",
|
||||
"ISC",
|
||||
"Zlib",
|
||||
"MPL-2.0",
|
||||
]
|
||||
# List of explictly disallowed licenses
|
||||
# See https://spdx.org/licenses/ for list of possible licenses
|
||||
|
@ -269,3 +269,12 @@ pub struct StaticBlock {
|
||||
pub span: Span,
|
||||
pub body: BlockStmt,
|
||||
}
|
||||
|
||||
impl Take for StaticBlock {
|
||||
fn dummy() -> Self {
|
||||
StaticBlock {
|
||||
span: DUMMY_SP,
|
||||
body: Take::dummy(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -230,6 +230,15 @@ pub struct SpreadElement {
|
||||
pub expr: Box<Expr>,
|
||||
}
|
||||
|
||||
impl Take for SpreadElement {
|
||||
fn dummy() -> Self {
|
||||
SpreadElement {
|
||||
dot3_token: DUMMY_SP,
|
||||
expr: Take::dummy(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[ast_node("UnaryExpression")]
|
||||
#[derive(Eq, Hash, EqIgnoreSpan)]
|
||||
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
|
||||
@ -243,6 +252,16 @@ pub struct UnaryExpr {
|
||||
pub arg: Box<Expr>,
|
||||
}
|
||||
|
||||
impl Take for UnaryExpr {
|
||||
fn dummy() -> Self {
|
||||
UnaryExpr {
|
||||
span: DUMMY_SP,
|
||||
op: op!("!"),
|
||||
arg: Take::dummy(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[ast_node("UpdateExpression")]
|
||||
#[derive(Eq, Hash, EqIgnoreSpan)]
|
||||
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
|
||||
@ -258,6 +277,17 @@ pub struct UpdateExpr {
|
||||
pub arg: Box<Expr>,
|
||||
}
|
||||
|
||||
impl Take for UpdateExpr {
|
||||
fn dummy() -> Self {
|
||||
UpdateExpr {
|
||||
span: DUMMY_SP,
|
||||
op: op!("++"),
|
||||
prefix: false,
|
||||
arg: Take::dummy(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[ast_node("BinaryExpression")]
|
||||
#[derive(Eq, Hash, EqIgnoreSpan)]
|
||||
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
|
||||
@ -272,6 +302,17 @@ pub struct BinExpr {
|
||||
pub right: Box<Expr>,
|
||||
}
|
||||
|
||||
impl Take for BinExpr {
|
||||
fn dummy() -> Self {
|
||||
BinExpr {
|
||||
span: DUMMY_SP,
|
||||
op: op!("*"),
|
||||
left: Take::dummy(),
|
||||
right: Take::dummy(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Function expression.
|
||||
#[ast_node("FunctionExpression")]
|
||||
#[derive(Eq, Hash, EqIgnoreSpan)]
|
||||
@ -329,6 +370,17 @@ pub struct AssignExpr {
|
||||
pub right: Box<Expr>,
|
||||
}
|
||||
|
||||
impl Take for AssignExpr {
|
||||
fn dummy() -> Self {
|
||||
AssignExpr {
|
||||
span: DUMMY_SP,
|
||||
op: op!("="),
|
||||
left: Take::dummy(),
|
||||
right: Take::dummy(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[ast_node("MemberExpression")]
|
||||
#[derive(Eq, Hash, EqIgnoreSpan)]
|
||||
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
|
||||
@ -344,6 +396,17 @@ pub struct MemberExpr {
|
||||
pub computed: bool,
|
||||
}
|
||||
|
||||
impl Take for MemberExpr {
|
||||
fn dummy() -> Self {
|
||||
MemberExpr {
|
||||
span: DUMMY_SP,
|
||||
obj: Take::dummy(),
|
||||
prop: Take::dummy(),
|
||||
computed: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[ast_node("ConditionalExpression")]
|
||||
#[derive(Eq, Hash, EqIgnoreSpan)]
|
||||
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
|
||||
@ -359,6 +422,17 @@ pub struct CondExpr {
|
||||
pub alt: Box<Expr>,
|
||||
}
|
||||
|
||||
impl Take for CondExpr {
|
||||
fn dummy() -> Self {
|
||||
CondExpr {
|
||||
span: DUMMY_SP,
|
||||
test: Take::dummy(),
|
||||
cons: Take::dummy(),
|
||||
alt: Take::dummy(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[ast_node("CallExpression")]
|
||||
#[derive(Eq, Hash, EqIgnoreSpan)]
|
||||
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
|
||||
@ -402,6 +476,17 @@ pub struct NewExpr {
|
||||
// pub type_params: Option<TsTypeParamInstantiation>,
|
||||
}
|
||||
|
||||
impl Take for NewExpr {
|
||||
fn dummy() -> Self {
|
||||
NewExpr {
|
||||
span: DUMMY_SP,
|
||||
callee: Take::dummy(),
|
||||
args: Take::dummy(),
|
||||
type_args: Take::dummy(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[ast_node("SequenceExpression")]
|
||||
#[derive(Eq, Hash, EqIgnoreSpan)]
|
||||
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
|
||||
@ -412,6 +497,15 @@ pub struct SeqExpr {
|
||||
pub exprs: Vec<Box<Expr>>,
|
||||
}
|
||||
|
||||
impl Take for SeqExpr {
|
||||
fn dummy() -> Self {
|
||||
SeqExpr {
|
||||
span: DUMMY_SP,
|
||||
exprs: Take::dummy(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[ast_node("ArrowFunctionExpression")]
|
||||
#[derive(Eq, Hash, EqIgnoreSpan)]
|
||||
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
|
||||
@ -435,6 +529,20 @@ pub struct ArrowExpr {
|
||||
pub return_type: Option<TsTypeAnn>,
|
||||
}
|
||||
|
||||
impl Take for ArrowExpr {
|
||||
fn dummy() -> Self {
|
||||
ArrowExpr {
|
||||
span: DUMMY_SP,
|
||||
params: Take::dummy(),
|
||||
body: Take::dummy(),
|
||||
is_async: false,
|
||||
is_generator: false,
|
||||
type_params: Take::dummy(),
|
||||
return_type: Take::dummy(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[ast_node("YieldExpression")]
|
||||
#[derive(Eq, Hash, EqIgnoreSpan)]
|
||||
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
|
||||
@ -448,6 +556,16 @@ pub struct YieldExpr {
|
||||
pub delegate: bool,
|
||||
}
|
||||
|
||||
impl Take for YieldExpr {
|
||||
fn dummy() -> Self {
|
||||
YieldExpr {
|
||||
span: DUMMY_SP,
|
||||
arg: Take::dummy(),
|
||||
delegate: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[ast_node("MetaProperty")]
|
||||
#[derive(Eq, Hash, EqIgnoreSpan)]
|
||||
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
|
||||
@ -482,6 +600,16 @@ pub struct Tpl {
|
||||
pub quasis: Vec<TplElement>,
|
||||
}
|
||||
|
||||
impl Take for Tpl {
|
||||
fn dummy() -> Self {
|
||||
Tpl {
|
||||
span: DUMMY_SP,
|
||||
exprs: Take::dummy(),
|
||||
quasis: Take::dummy(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[ast_node("TaggedTemplateExpression")]
|
||||
#[derive(Eq, Hash, EqIgnoreSpan)]
|
||||
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
|
||||
@ -497,6 +625,17 @@ pub struct TaggedTpl {
|
||||
pub tpl: Tpl,
|
||||
}
|
||||
|
||||
impl Take for TaggedTpl {
|
||||
fn dummy() -> Self {
|
||||
TaggedTpl {
|
||||
span: DUMMY_SP,
|
||||
tag: Take::dummy(),
|
||||
type_params: Take::dummy(),
|
||||
tpl: Take::dummy(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[ast_node("TemplateElement")]
|
||||
#[derive(Eq, Hash, EqIgnoreSpan)]
|
||||
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
|
||||
@ -527,6 +666,14 @@ pub struct ParenExpr {
|
||||
#[serde(rename = "expression")]
|
||||
pub expr: Box<Expr>,
|
||||
}
|
||||
impl Take for ParenExpr {
|
||||
fn dummy() -> Self {
|
||||
ParenExpr {
|
||||
span: DUMMY_SP,
|
||||
expr: Take::dummy(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[ast_node]
|
||||
#[allow(variant_size_differences)]
|
||||
|
@ -145,6 +145,15 @@ pub struct Bool {
|
||||
pub value: bool,
|
||||
}
|
||||
|
||||
impl Take for Bool {
|
||||
fn dummy() -> Self {
|
||||
Bool {
|
||||
span: DUMMY_SP,
|
||||
value: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[ast_node("NullLiteral")]
|
||||
#[derive(Copy, Eq, Hash, EqIgnoreSpan)]
|
||||
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
|
||||
@ -152,6 +161,12 @@ pub struct Null {
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl Take for Null {
|
||||
fn dummy() -> Self {
|
||||
Null { span: DUMMY_SP }
|
||||
}
|
||||
}
|
||||
|
||||
#[ast_node("RegExpLiteral")]
|
||||
#[derive(Eq, Hash, EqIgnoreSpan)]
|
||||
pub struct Regex {
|
||||
|
@ -18,4 +18,4 @@ swc_ecma_ast = {version = "0.56.0", path = "../../ecmascript/ast"}
|
||||
swc_ecma_codegen = {version = "0.78.1", path = "../../ecmascript/codegen"}
|
||||
swc_ecma_utils = {version = "0.50.0", path = "../../ecmascript/utils"}
|
||||
swc_ecma_visit = {version = "0.42.0", path = "../../ecmascript/visit"}
|
||||
swc_plugin = {version = "0.10.0", path = "../"}
|
||||
swc_plugin_api = {version = "0.1.0", path = "../api"}
|
||||
|
Loading…
Reference in New Issue
Block a user