Fix folder for stable rustc (#797)

This commit is contained in:
강동윤 2020-05-25 22:53:48 +09:00 committed by GitHub
parent 13a67a4848
commit 84f1759910
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 103 additions and 12 deletions

View File

@ -13,5 +13,5 @@ edition = "2018"
swc_atoms = { version = "0.2", path = "../../atoms" } swc_atoms = { version = "0.2", path = "../../atoms" }
swc_common = { version = "0.5.9", path = "../../common" } swc_common = { version = "0.5.9", path = "../../common" }
swc_ecma_ast = { version = "0.20.0", path ="../ast" } swc_ecma_ast = { version = "0.20.0", path ="../ast" }
swc_ecma_visit_macros = { version = "0.3.0", path ="./macros" } swc_ecma_visit_macros = { version = "0.4.0", path ="./macros" }
num-bigint = { version = "0.2", features = ["serde"] } num-bigint = { version = "0.2", features = ["serde"] }

View File

@ -1,6 +1,6 @@
[package] [package]
name = "swc_ecma_visit_macros" name = "swc_ecma_visit_macros"
version = "0.3.0" version = "0.4.0"
authors = ["강동윤 <kdy1997.dev@gmail.com>"] authors = ["강동윤 <kdy1997.dev@gmail.com>"]
license = "Apache-2.0/MIT" license = "Apache-2.0/MIT"
repository = "https://github.com/swc-project/swc.git" repository = "https://github.com/swc-project/swc.git"

View File

@ -778,7 +778,18 @@ fn create_method_body(mode: Mode, ty: &Type) -> Block {
_ => {} _ => {}
} }
return q!( return match mode {
Mode::Folder => q!(
Vars { ident },
({
match n {
Some(n) => Some(_visitor.ident(n)),
None => None,
}
})
)
.parse(),
Mode::Visitor => q!(
Vars { ident }, Vars { ident },
({ ({
match n { match n {
@ -787,7 +798,8 @@ fn create_method_body(mode: Mode, ty: &Type) -> Block {
} }
}) })
) )
.parse(); .parse(),
};
} }
_ => unimplemented!("generic parameter other than type"), _ => unimplemented!("generic parameter other than type"),
} }

View File

@ -0,0 +1,29 @@
use std::any::Any;
use swc_ecma_visit_macros::define;
/// Visitable nodes.
pub trait Node: Any {}
impl<T: ?Sized> Node for T where T: Any {}
pub struct Item {
// pub field: usize,
// pub inner: Option<Box<Item>>,
pub opt_vec: Option<Vec<Item>>,
pub vec_opt: Vec<Option<Item>>,
}
pub enum Enum {
Item(Item),
}
define!({
pub struct Item {
// pub field: usize,
// pub inner: Option<Box<Item>>,
pub opt_vec: Option<Vec<Item>>,
pub vec_opt: Vec<Option<Item>>,
}
pub enum Enum {
Item(Item),
}
});

View File

@ -0,0 +1,25 @@
use std::any::Any;
use swc_ecma_visit_macros::define;
/// Visitable nodes.
pub trait Node: Any {}
impl<T: ?Sized> Node for T where T: Any {}
pub struct Item {
pub opt_vec1: Option<Vec<Item>>,
pub opt_vec2: Option<Vec<Enum>>,
}
pub enum Enum {
Item(Item),
}
define!({
pub struct Item {
pub opt_vec1: Option<Vec<Item>>,
pub opt_vec2: Option<Vec<Enum>>,
}
pub enum Enum {
Item(Item),
}
});

View File

@ -0,0 +1,25 @@
use std::any::Any;
use swc_ecma_visit_macros::define;
/// Visitable nodes.
pub trait Node: Any {}
impl<T: ?Sized> Node for T where T: Any {}
pub struct Item {
pub vec_opt1: Vec<Option<Item>>,
pub vec_opt2: Vec<Option<Enum>>,
}
pub enum Enum {
Item(Item),
}
define!({
pub struct Item {
pub vec_opt1: Vec<Option<Item>>,
pub vec_opt2: Vec<Option<Enum>>,
}
pub enum Enum {
Item(Item),
}
});