Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(visit): Pre-generate visitor code #9262

Merged
merged 214 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from 209 commits
Commits
Show all changes
214 commits
Select commit Hold shift + click to select a range
74821a7
Add a crate
kdy1 Jul 16, 2024
2c49432
cargo lockfile
kdy1 Jul 16, 2024
5169f32
publish false
kdy1 Jul 16, 2024
c18bea3
Deps
kdy1 Jul 16, 2024
d386614
Dep
kdy1 Jul 16, 2024
5c386df
cargo lockfile
kdy1 Jul 16, 2024
6e67b09
cli args
kdy1 Jul 16, 2024
827bb52
Dep
kdy1 Jul 16, 2024
98bf3d2
cargo lockfile
kdy1 Jul 16, 2024
0321557
main
kdy1 Jul 16, 2024
2dc66fc
collect inputs
kdy1 Jul 16, 2024
f9f64d5
more main
kdy1 Jul 16, 2024
583e31a
inputs
kdy1 Jul 16, 2024
89e4ff0
all_types
kdy1 Jul 16, 2024
2ee674a
generator
kdy1 Jul 16, 2024
4453e38
syn/full
kdy1 Jul 16, 2024
cd7fac3
Rename
kdy1 Jul 16, 2024
19d5e45
cargo lockfile
kdy1 Jul 16, 2024
50c1b3d
cargo alias
kdy1 Jul 16, 2024
a71a805
more
kdy1 Jul 16, 2024
44b3d65
WIP: `qualify_types`
kdy1 Jul 16, 2024
4f5c755
`for_each_use_item`
kdy1 Jul 16, 2024
2d32a66
dep
kdy1 Jul 16, 2024
d653ce6
cargo lockfile
kdy1 Jul 16, 2024
48fdab6
Finish `qualify_types`
kdy1 Jul 16, 2024
0324763
Dep
kdy1 Jul 16, 2024
d871ce9
visit-mut
kdy1 Jul 16, 2024
f12edb6
cargo fmt
kdy1 Jul 16, 2024
bceabfb
More
kdy1 Jul 16, 2024
2b98545
more work
kdy1 Jul 16, 2024
f58ddee
codegen
kdy1 Jul 16, 2024
80560ce
use generated
kdy1 Jul 16, 2024
faf512d
More work
kdy1 Jul 16, 2024
dad825c
fix
kdy1 Jul 16, 2024
7c48632
more
kdy1 Jul 16, 2024
c6ca39c
more
kdy1 Jul 16, 2024
c0f7fe4
more
kdy1 Jul 16, 2024
85cfa46
more
kdy1 Jul 16, 2024
288a5e2
More work
kdy1 Jul 16, 2024
47fb082
fix
kdy1 Jul 16, 2024
6b073d5
cmt
kdy1 Jul 16, 2024
dcdd7b9
dep
kdy1 Jul 16, 2024
246a743
cargo lockfile
kdy1 Jul 16, 2024
8541496
snake case
kdy1 Jul 16, 2024
f331671
fix codegen
kdy1 Jul 16, 2024
cbdf3fd
more
kdy1 Jul 16, 2024
a9055e5
receiver
kdy1 Jul 16, 2024
4f36aca
doc
kdy1 Jul 16, 2024
c09e99a
doc
kdy1 Jul 16, 2024
d3b3489
sort
kdy1 Jul 16, 2024
1641014
doc
kdy1 Jul 16, 2024
0cadb7d
`default_visit_body`
kdy1 Jul 16, 2024
b86b4f5
named struct
kdy1 Jul 16, 2024
9947a33
more
kdy1 Jul 16, 2024
28c965d
codegen
kdy1 Jul 16, 2024
4e0133d
Default impl is done
kdy1 Jul 16, 2024
9a7a84e
fix more
kdy1 Jul 16, 2024
bd607ea
Default impl
kdy1 Jul 16, 2024
30175ec
Optimize
kdy1 Jul 16, 2024
a944bf8
Optimize
kdy1 Jul 16, 2024
b75f204
Optimize
kdy1 Jul 16, 2024
4556f50
Fix regression caused by optimization
kdy1 Jul 16, 2024
a7d0551
fixup
kdy1 Jul 16, 2024
cbda27c
More opt
kdy1 Jul 16, 2024
d9ba498
Fix `qualify_types`
kdy1 Jul 16, 2024
0f60d3c
more work
kdy1 Jul 16, 2024
e31ff37
Improve
kdy1 Jul 16, 2024
e12305e
More fix
kdy1 Jul 16, 2024
84ee538
lint
kdy1 Jul 16, 2024
64be349
AstPath
kdy1 Jul 16, 2024
9d62d15
more work for ast path
kdy1 Jul 16, 2024
65a269c
fileds enums
kdy1 Jul 16, 2024
5a52790
fix
kdy1 Jul 16, 2024
1491adc
More ast path work
kdy1 Jul 16, 2024
e9785fc
more work
kdy1 Jul 16, 2024
774d723
vector fields
kdy1 Jul 16, 2024
487ab76
'ast
kdy1 Jul 16, 2024
091da68
lifetime
kdy1 Jul 16, 2024
039e637
Add cfg
kdy1 Jul 16, 2024
27ed382
Fix FQ
kdy1 Jul 16, 2024
97b8ac0
GEN
kdy1 Jul 16, 2024
636df89
`run_visitor_codegen`
kdy1 Jul 17, 2024
100d504
Fix
kdy1 Jul 17, 2024
343afff
Fix
kdy1 Jul 17, 2024
d793722
codegen
kdy1 Jul 17, 2024
0cb0c6c
leaf_types
kdy1 Jul 17, 2024
df2eb27
Skip leaf types
kdy1 Jul 17, 2024
1db9afe
Visitor methods for leaf types
kdy1 Jul 17, 2024
8436746
Rename
kdy1 Jul 17, 2024
5d8663f
fmt
kdy1 Jul 17, 2024
2ebf041
WIP: `FieldType`
kdy1 Jul 17, 2024
7592931
FieldType
kdy1 Jul 17, 2024
e7fc498
Refactor
kdy1 Jul 17, 2024
2cfe6eb
WIP: `implement_visit_with_for_non_leaf_types`
kdy1 Jul 17, 2024
6fa3d50
leaf types
kdy1 Jul 17, 2024
084cae1
More work
kdy1 Jul 17, 2024
318ac91
Option
kdy1 Jul 17, 2024
eadbd2b
node types
kdy1 Jul 17, 2024
995e3c5
feature
kdy1 Jul 17, 2024
a8dfc11
Options
kdy1 Jul 17, 2024
b7f2f0c
Use qualified
kdy1 Jul 17, 2024
5d1dae4
unused
kdy1 Jul 17, 2024
58f54d3
visit_wwith
kdy1 Jul 17, 2024
e17ba31
Rename & should_skip
kdy1 Jul 17, 2024
5be237a
all types
kdy1 Jul 17, 2024
3391739
Fix typo
kdy1 Jul 17, 2024
426205d
should_skip
kdy1 Jul 17, 2024
5ad8a7f
GENERATED
kdy1 Jul 17, 2024
96035bd
Method name
kdy1 Jul 17, 2024
d28464d
More visitwith
kdy1 Jul 17, 2024
03a73f3
`field_only_types`
kdy1 Jul 17, 2024
818775d
Fix `VisitWith` impls
kdy1 Jul 17, 2024
29ae8da
fixup
kdy1 Jul 17, 2024
7d5cbdf
Use visit_with<V>
kdy1 Jul 17, 2024
1378f14
{}
kdy1 Jul 17, 2024
78536df
Fix arg types
kdy1 Jul 17, 2024
2fa1cf1
Rename
kdy1 Jul 17, 2024
1982c61
fix
kdy1 Jul 17, 2024
9c91f7f
opt_vec
kdy1 Jul 17, 2024
e8bfea2
unit fields
kdy1 Jul 17, 2024
660859d
Generic impls
kdy1 Jul 17, 2024
15c599a
attributes
kdy1 Jul 17, 2024
d4729f7
receiver
kdy1 Jul 17, 2024
793dbbb
Remove `self.`
kdy1 Jul 17, 2024
e1984c3
indent
kdy1 Jul 17, 2024
bc71e6e
Box deref
kdy1 Jul 17, 2024
4cd161a
plural
kdy1 Jul 17, 2024
3c94916
BigIntValue
kdy1 Jul 17, 2024
274f69a
Fix bigint issue
kdy1 Jul 17, 2024
d8a092e
Impl visit for `[T]`
kdy1 Jul 17, 2024
fa8e9fa
Vec<T> => [T]
kdy1 Jul 17, 2024
fb27db0
refactor
kdy1 Jul 17, 2024
842fd5a
lint
kdy1 Jul 17, 2024
90e5924
Use `&[T]` in visitor
kdy1 Jul 17, 2024
8b0219b
Use `&[T]` in visitor
kdy1 Jul 17, 2024
398e298
Fix generic impl
kdy1 Jul 17, 2024
3fc4ea0
`declare_visit_trait`: tems
kdy1 Jul 17, 2024
b08c18b
vectors
kdy1 Jul 17, 2024
1b20faa
More implementors for VisitMut
kdy1 Jul 17, 2024
b2fca3d
fix
kdy1 Jul 17, 2024
954cb97
fix <V>
kdy1 Jul 17, 2024
15702bb
Fix either impl
kdy1 Jul 17, 2024
d83d8ef
`else_block`
kdy1 Jul 17, 2024
2c85465
&mut **self
kdy1 Jul 17, 2024
093d52a
V as #trait_name
kdy1 Jul 17, 2024
d4082ae
#[inline]
kdy1 Jul 17, 2024
0307c13
Fix `Optional`
kdy1 Jul 17, 2024
af266a9
Init VisitAll
kdy1 Jul 17, 2024
c17de61
prefix
kdy1 Jul 17, 2024
418c217
doc
kdy1 Jul 17, 2024
d74583f
Visitall
kdy1 Jul 17, 2024
859eb37
VisitAll
kdy1 Jul 17, 2024
b340fed
fix `VisitAll`
kdy1 Jul 17, 2024
b579fb2
swap args
kdy1 Jul 17, 2024
98289ee
Fix recursion
kdy1 Jul 17, 2024
2de5be2
Use &[T] for VisitAll
kdy1 Jul 17, 2024
bd900e6
VisitAllWith for Vec<T>
kdy1 Jul 17, 2024
27388c8
AstPath
kdy1 Jul 17, 2024
9b79906
variant
kdy1 Jul 17, 2024
d774e4b
#visit_with_name
kdy1 Jul 17, 2024
05ea4e3
field enums
kdy1 Jul 17, 2024
d271c1c
traits for field neums
kdy1 Jul 17, 2024
de8da9a
swc_visit::ParentKind for AstParentKind
kdy1 Jul 17, 2024
dc9db2d
method
kdy1 Jul 17, 2024
b049b85
Call set_index
kdy1 Jul 17, 2024
a2cd64d
Fix astpath
kdy1 Jul 17, 2024
386360b
Fix return type
kdy1 Jul 17, 2024
fb8dfd3
set_index
kdy1 Jul 17, 2024
4030e9c
fixup
kdy1 Jul 17, 2024
66aba01
#fields_enum_name
kdy1 Jul 17, 2024
3154bea
Hide set_inde
kdy1 Jul 17, 2024
37eb77f
Move to module
kdy1 Jul 17, 2024
aeb8be6
Move to module
kdy1 Jul 17, 2024
0874ca8
_ => {}
kdy1 Jul 17, 2024
14f5fa3
__field_kind
kdy1 Jul 17, 2024
4830de6
__ast_path
kdy1 Jul 17, 2024
f8f973d
deref
kdy1 Jul 17, 2024
8dcb40b
Some work for ast path
kdy1 Jul 17, 2024
ec527a6
kind: vec
kdy1 Jul 17, 2024
83d0af8
enum variant
kdy1 Jul 17, 2024
8b66261
Check for variant
kdy1 Jul 17, 2024
866cde7
lint
kdy1 Jul 17, 2024
44c676c
fix visibility
kdy1 Jul 17, 2024
b9985e6
Move
kdy1 Jul 17, 2024
1ce4d05
CI
kdy1 Jul 17, 2024
d481dfd
test
kdy1 Jul 17, 2024
7dbdc37
test
kdy1 Jul 17, 2024
706b07c
codegen
kdy1 Jul 17, 2024
f0db7c3
CSS
kdy1 Jul 17, 2024
2357f78
Fix CSS AST
kdy1 Jul 17, 2024
4e9da62
Fix all
kdy1 Jul 17, 2024
81c3e16
License
kdy1 Jul 17, 2024
4cd995c
Fix tool
kdy1 Jul 17, 2024
001e3fc
Fix tool
kdy1 Jul 17, 2024
6225d34
Update snapshot
kdy1 Jul 17, 2024
c0d49cf
Log rustfmt
kdy1 Jul 17, 2024
74b2fe4
canonicalize
kdy1 Jul 17, 2024
cdc19b1
Udpate
kdy1 Jul 17, 2024
bbdef94
AstParentNodeRef, AstParentKind
kdy1 Jul 17, 2024
eb71063
Inline macro
kdy1 Jul 17, 2024
9586d8e
GEN
kdy1 Jul 17, 2024
bbc1a70
lint
kdy1 Jul 17, 2024
e8116e7
Merge branch 'main' into codegen
kdy1 Jul 17, 2024
5615262
Merge branch 'main' into codegen
swc-bot Jul 17, 2024
39c30a4
feature
kdy1 Jul 17, 2024
fd3d1fb
visitor
kdy1 Jul 17, 2024
22fea8f
fix
kdy1 Jul 17, 2024
788da1e
fix
kdy1 Jul 17, 2024
761eaf6
fix
kdy1 Jul 17, 2024
bf1232e
Fix imports
kdy1 Jul 17, 2024
ff0a645
fix
kdy1 Jul 17, 2024
15ecdc3
real fix
kdy1 Jul 17, 2024
2cd1553
autoinherit
kdy1 Jul 17, 2024
3f76bea
swc_core
kdy1 Jul 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[alias]
xtask = "run --package xtask --"
codegen = "run --package generate-code --"
xtask = "run --package xtask --"

[build]

Expand Down
57 changes: 41 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ members = [
"crates/swc_transform_common",
"crates/swc_typescript",
"crates/swc_fast_ts_strip",
"tools/generate-code",
]
resolver = "2"

[workspace.package]
license = "Apache-2.0"
repository = "https://github.com/swc-project/swc.git"


[workspace.dependencies]
# bytecheck version should be in sync with rkyv version. Do not bump individually.
bytecheck = "0.6.10"
Expand Down
8 changes: 4 additions & 4 deletions crates/swc_css_ast/src/at_rule.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use is_macro::Is;
use string_enum::StringEnum;
use swc_atoms::{Atom, JsWord};
use swc_atoms::Atom;
use swc_common::{ast_node, util::take::Take, EqIgnoreSpan, Span};

use crate::{
Expand Down Expand Up @@ -37,8 +37,8 @@ impl PartialEq<str> for AtRuleName {
}
}

impl PartialEq<JsWord> for AtRuleName {
fn eq(&self, other: &JsWord) -> bool {
impl PartialEq<Atom> for AtRuleName {
fn eq(&self, other: &Atom) -> bool {
match self {
AtRuleName::DashedIdent(v) => v.value == *other,
AtRuleName::Ident(v) => v.value == *other,
Expand Down Expand Up @@ -858,7 +858,7 @@ pub enum SizeFeatureName {
#[derive(Eq, Hash)]
pub struct ExtensionName {
pub span: Span,
pub value: JsWord,
pub value: Atom,
pub raw: Option<Atom>,
}

Expand Down
10 changes: 5 additions & 5 deletions crates/swc_css_ast/src/base.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use is_macro::Is;
use swc_atoms::JsWord;
use swc_atoms::Atom;
use swc_common::{ast_node, util::take::Take, EqIgnoreSpan, Span};

use crate::{
Expand Down Expand Up @@ -128,8 +128,8 @@ impl PartialEq<&'_ str> for FunctionName {
}
}

impl PartialEq<JsWord> for FunctionName {
fn eq(&self, other: &JsWord) -> bool {
impl PartialEq<Atom> for FunctionName {
fn eq(&self, other: &Atom) -> bool {
match self {
FunctionName::DashedIdent(v) => v.value == *other,
FunctionName::Ident(v) => v.value == *other,
Expand Down Expand Up @@ -324,8 +324,8 @@ impl PartialEq<str> for DeclarationName {
}
}

impl PartialEq<JsWord> for DeclarationName {
fn eq(&self, other: &JsWord) -> bool {
impl PartialEq<Atom> for DeclarationName {
fn eq(&self, other: &Atom) -> bool {
match self {
DeclarationName::DashedIdent(v) => v.value == *other,
DeclarationName::Ident(v) => v.value == *other,
Expand Down
8 changes: 4 additions & 4 deletions crates/swc_css_ast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ mod value;
/// # Examples
///
/// ```
/// use swc_atoms::JsWord;
/// use swc_atoms::Atom;
/// use swc_atoms::js_word;
/// use swc_css_ast::*;
///
/// assert!(matches_eq_ignore_ascii_case!(JsWord::from("A"), "a"));
/// assert!(matches_eq_ignore_ascii_case!(Atom::from("A"), "a"));
/// assert!(matches_eq_ignore_ascii_case!("A", "a"));
/// ```
#[macro_export]
Expand All @@ -40,11 +40,11 @@ macro_rules! matches_eq_ignore_ascii_case {
/// # Examples
///
/// ```
/// use swc_atoms::JsWord;
/// use swc_atoms::Atom;
/// use swc_atoms::js_word;
/// use swc_css_ast::*;
///
/// assert!(matches_eq!(JsWord::from("a"), "a"));
/// assert!(matches_eq!(Atom::from("a"), "a"));
/// assert!(matches_eq!("a", "a"));
/// ```
#[macro_export]
Expand Down
4 changes: 2 additions & 2 deletions crates/swc_css_ast/src/selector.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use is_macro::Is;
use string_enum::StringEnum;
use swc_atoms::{Atom, JsWord};
use swc_atoms::Atom;
use swc_common::{ast_node, util::take::Take, EqIgnoreSpan, Span};

use crate::{Delimiter, Ident, ListOfComponentValues, Str, TokenAndSpan};
Expand Down Expand Up @@ -413,7 +413,7 @@ pub enum PseudoElementSelectorChildren {
pub struct CustomHighlightName {
pub span: Span,

pub value: JsWord,
pub value: Atom,
pub raw: Option<Atom>,
}

Expand Down
16 changes: 8 additions & 8 deletions crates/swc_css_ast/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
use is_macro::Is;
#[cfg(feature = "serde-impl")]
use serde::{Deserialize, Serialize};
use swc_atoms::{Atom, JsWord};
use swc_atoms::Atom;
use swc_common::{ast_node, util::take::Take, EqIgnoreSpan, Span};

#[ast_node("PreservedToken")]
Expand Down Expand Up @@ -70,7 +70,7 @@ pub struct DimensionToken {
pub value: f64,
pub raw_value: Atom,

pub unit: JsWord,
pub unit: Atom,

#[cfg_attr(feature = "serde-impl", serde(rename = "type"))]
pub type_flag: NumberType,
Expand All @@ -95,35 +95,35 @@ pub struct DimensionToken {
#[cfg_attr(feature = "serde-impl", derive(serde::Serialize, serde::Deserialize))]
pub enum Token {
Ident {
value: JsWord,
value: Atom,
raw: Atom,
},
Function {
value: JsWord,
value: Atom,
raw: Atom,
},
/// `@`
AtKeyword {
value: JsWord,
value: Atom,
raw: Atom,
},
/// `#`
Hash {
is_id: bool,

value: JsWord,
value: Atom,
raw: Atom,
},
String {
value: JsWord,
value: Atom,
raw: Atom,
},
BadString {
raw: Atom,
},
/// `url(value)`
Url {
value: JsWord,
value: Atom,
/// Name and value
raw: Box<UrlKeyValue>,
},
Expand Down
Loading
Loading