Skip to content

Commit 24dd4ab

Browse files
committed
fix: update for Astro changes
1 parent e67e08b commit 24dd4ab

6 files changed

Lines changed: 273 additions & 6 deletions

File tree

crates/oxc_ast/src/generated/assert_layouts.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,13 +1825,13 @@ const _: () = {
18251825
assert!(offset_of!(AstroRoot, body) == 16);
18261826

18271827
// Padding: 0 bytes
1828-
assert!(size_of::<AstroFrontmatter>() == 136);
1828+
assert!(size_of::<AstroFrontmatter>() == 152);
18291829
assert!(align_of::<AstroFrontmatter>() == 8);
18301830
assert!(offset_of!(AstroFrontmatter, span) == 0);
18311831
assert!(offset_of!(AstroFrontmatter, program) == 8);
18321832

18331833
// Padding: 0 bytes
1834-
assert!(size_of::<AstroScript>() == 136);
1834+
assert!(size_of::<AstroScript>() == 152);
18351835
assert!(align_of::<AstroScript>() == 8);
18361836
assert!(offset_of!(AstroScript, span) == 0);
18371837
assert!(offset_of!(AstroScript, program) == 8);
@@ -3667,13 +3667,13 @@ const _: () = if cfg!(target_family = "wasm") || align_of::<u64>() == 8 {
36673667
assert!(offset_of!(AstroRoot, body) == 12);
36683668

36693669
// Padding: 0 bytes
3670-
assert!(size_of::<AstroFrontmatter>() == 96);
3670+
assert!(size_of::<AstroFrontmatter>() == 104);
36713671
assert!(align_of::<AstroFrontmatter>() == 4);
36723672
assert!(offset_of!(AstroFrontmatter, span) == 0);
36733673
assert!(offset_of!(AstroFrontmatter, program) == 8);
36743674

36753675
// Padding: 0 bytes
3676-
assert!(size_of::<AstroScript>() == 96);
3676+
assert!(size_of::<AstroScript>() == 104);
36773677
assert!(align_of::<AstroScript>() == 4);
36783678
assert!(offset_of!(AstroScript, span) == 0);
36793679
assert!(offset_of!(AstroScript, program) == 8);

crates/oxc_ast/src/generated/ast_kind.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,11 @@ impl AstKind<'_> {
630630
Self::JSDocNullableType(it) => it.node_id(),
631631
Self::JSDocNonNullableType(it) => it.node_id(),
632632
Self::JSDocUnknownType(it) => it.node_id(),
633+
Self::AstroRoot(_) => NodeId::DUMMY,
634+
Self::AstroFrontmatter(_) => NodeId::DUMMY,
635+
Self::AstroScript(_) => NodeId::DUMMY,
636+
Self::AstroDoctype(_) => NodeId::DUMMY,
637+
Self::AstroComment(_) => NodeId::DUMMY,
633638
}
634639
}
635640

@@ -829,6 +834,11 @@ impl AstKind<'_> {
829834
Self::JSDocNullableType(it) => it.set_node_id(node_id),
830835
Self::JSDocNonNullableType(it) => it.set_node_id(node_id),
831836
Self::JSDocUnknownType(it) => it.set_node_id(node_id),
837+
Self::AstroRoot(_) => {}
838+
Self::AstroFrontmatter(_) => {}
839+
Self::AstroScript(_) => {}
840+
Self::AstroDoctype(_) => {}
841+
Self::AstroComment(_) => {}
832842
}
833843
}
834844
}

crates/oxc_ast/src/generated/derive_dummy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2047,7 +2047,7 @@ impl<'a> Dummy<'a> for JSXIdentifier<'a> {
20472047
impl<'a> Dummy<'a> for JSXChild<'a> {
20482048
/// Create a dummy [`JSXChild`].
20492049
///
2050-
/// Has cost of making 1 allocation (40 bytes).
2050+
/// Has cost of making 1 allocation (24 bytes).
20512051
fn dummy(allocator: &'a Allocator) -> Self {
20522052
Self::AstroDoctype(Dummy::dummy(allocator))
20532053
}

crates/oxc_minifier/src/generated/ancestor.rs

Lines changed: 142 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,10 @@ pub(crate) enum AncestorType {
323323
TSInstantiationExpressionTypeArguments = 299,
324324
JSDocNullableTypeTypeAnnotation = 300,
325325
JSDocNonNullableTypeTypeAnnotation = 301,
326+
AstroRootFrontmatter = 302,
327+
AstroRootBody = 303,
328+
AstroFrontmatterProgram = 304,
329+
AstroScriptProgram = 305,
326330
}
327331

328332
/// Ancestor type used in AST traversal.
@@ -907,6 +911,12 @@ pub enum Ancestor<'a, 't> {
907911
AncestorType::JSDocNullableTypeTypeAnnotation as u16,
908912
JSDocNonNullableTypeTypeAnnotation(JSDocNonNullableTypeWithoutTypeAnnotation<'a, 't>) =
909913
AncestorType::JSDocNonNullableTypeTypeAnnotation as u16,
914+
AstroRootFrontmatter(AstroRootWithoutFrontmatter<'a, 't>) =
915+
AncestorType::AstroRootFrontmatter as u16,
916+
AstroRootBody(AstroRootWithoutBody<'a, 't>) = AncestorType::AstroRootBody as u16,
917+
AstroFrontmatterProgram(AstroFrontmatterWithoutProgram<'a, 't>) =
918+
AncestorType::AstroFrontmatterProgram as u16,
919+
AstroScriptProgram(AstroScriptWithoutProgram<'a, 't>) = AncestorType::AstroScriptProgram as u16,
910920
}
911921

912922
impl<'a, 't> Ancestor<'a, 't> {
@@ -1905,6 +1915,21 @@ impl<'a, 't> Ancestor<'a, 't> {
19051915
matches!(self, Self::JSDocNonNullableTypeTypeAnnotation(_))
19061916
}
19071917

1918+
#[inline]
1919+
pub fn is_astro_root(self) -> bool {
1920+
matches!(self, Self::AstroRootFrontmatter(_) | Self::AstroRootBody(_))
1921+
}
1922+
1923+
#[inline]
1924+
pub fn is_astro_frontmatter(self) -> bool {
1925+
matches!(self, Self::AstroFrontmatterProgram(_))
1926+
}
1927+
1928+
#[inline]
1929+
pub fn is_astro_script(self) -> bool {
1930+
matches!(self, Self::AstroScriptProgram(_))
1931+
}
1932+
19081933
#[inline]
19091934
pub fn is_parent_of_statement(self) -> bool {
19101935
matches!(
@@ -2123,7 +2148,10 @@ impl<'a, 't> Ancestor<'a, 't> {
21232148

21242149
#[inline]
21252150
pub fn is_parent_of_jsx_child(self) -> bool {
2126-
matches!(self, Self::JSXElementChildren(_) | Self::JSXFragmentChildren(_))
2151+
matches!(
2152+
self,
2153+
Self::JSXElementChildren(_) | Self::JSXFragmentChildren(_) | Self::AstroRootBody(_)
2154+
)
21272155
}
21282156

21292157
#[inline]
@@ -2559,6 +2587,10 @@ impl<'a, 't> GetAddress for Ancestor<'a, 't> {
25592587
Self::TSInstantiationExpressionTypeArguments(a) => a.address(),
25602588
Self::JSDocNullableTypeTypeAnnotation(a) => a.address(),
25612589
Self::JSDocNonNullableTypeTypeAnnotation(a) => a.address(),
2590+
Self::AstroRootFrontmatter(a) => a.address(),
2591+
Self::AstroRootBody(a) => a.address(),
2592+
Self::AstroFrontmatterProgram(a) => a.address(),
2593+
Self::AstroScriptProgram(a) => a.address(),
25622594
}
25632595
}
25642596
}
@@ -18569,3 +18601,112 @@ impl<'a, 't> GetAddress for JSDocNonNullableTypeWithoutTypeAnnotation<'a, 't> {
1856918601
unsafe { Address::from_ptr(self.0) }
1857018602
}
1857118603
}
18604+
18605+
pub(crate) const OFFSET_ASTRO_ROOT_SPAN: usize = offset_of!(AstroRoot, span);
18606+
pub(crate) const OFFSET_ASTRO_ROOT_FRONTMATTER: usize = offset_of!(AstroRoot, frontmatter);
18607+
pub(crate) const OFFSET_ASTRO_ROOT_BODY: usize = offset_of!(AstroRoot, body);
18608+
18609+
#[repr(transparent)]
18610+
#[derive(Clone, Copy, Debug)]
18611+
pub struct AstroRootWithoutFrontmatter<'a, 't>(
18612+
pub(crate) *const AstroRoot<'a>,
18613+
pub(crate) PhantomData<&'t ()>,
18614+
);
18615+
18616+
impl<'a, 't> AstroRootWithoutFrontmatter<'a, 't> {
18617+
#[inline]
18618+
pub fn span(self) -> &'t Span {
18619+
unsafe { &*((self.0 as *const u8).add(OFFSET_ASTRO_ROOT_SPAN) as *const Span) }
18620+
}
18621+
18622+
#[inline]
18623+
pub fn body(self) -> &'t Vec<'a, JSXChild<'a>> {
18624+
unsafe {
18625+
&*((self.0 as *const u8).add(OFFSET_ASTRO_ROOT_BODY) as *const Vec<'a, JSXChild<'a>>)
18626+
}
18627+
}
18628+
}
18629+
18630+
impl<'a, 't> GetAddress for AstroRootWithoutFrontmatter<'a, 't> {
18631+
#[inline]
18632+
fn address(&self) -> Address {
18633+
unsafe { Address::from_ptr(self.0) }
18634+
}
18635+
}
18636+
18637+
#[repr(transparent)]
18638+
#[derive(Clone, Copy, Debug)]
18639+
pub struct AstroRootWithoutBody<'a, 't>(
18640+
pub(crate) *const AstroRoot<'a>,
18641+
pub(crate) PhantomData<&'t ()>,
18642+
);
18643+
18644+
impl<'a, 't> AstroRootWithoutBody<'a, 't> {
18645+
#[inline]
18646+
pub fn span(self) -> &'t Span {
18647+
unsafe { &*((self.0 as *const u8).add(OFFSET_ASTRO_ROOT_SPAN) as *const Span) }
18648+
}
18649+
18650+
#[inline]
18651+
pub fn frontmatter(self) -> &'t Option<Box<'a, AstroFrontmatter<'a>>> {
18652+
unsafe {
18653+
&*((self.0 as *const u8).add(OFFSET_ASTRO_ROOT_FRONTMATTER)
18654+
as *const Option<Box<'a, AstroFrontmatter<'a>>>)
18655+
}
18656+
}
18657+
}
18658+
18659+
impl<'a, 't> GetAddress for AstroRootWithoutBody<'a, 't> {
18660+
#[inline]
18661+
fn address(&self) -> Address {
18662+
unsafe { Address::from_ptr(self.0) }
18663+
}
18664+
}
18665+
18666+
pub(crate) const OFFSET_ASTRO_FRONTMATTER_SPAN: usize = offset_of!(AstroFrontmatter, span);
18667+
pub(crate) const OFFSET_ASTRO_FRONTMATTER_PROGRAM: usize = offset_of!(AstroFrontmatter, program);
18668+
18669+
#[repr(transparent)]
18670+
#[derive(Clone, Copy, Debug)]
18671+
pub struct AstroFrontmatterWithoutProgram<'a, 't>(
18672+
pub(crate) *const AstroFrontmatter<'a>,
18673+
pub(crate) PhantomData<&'t ()>,
18674+
);
18675+
18676+
impl<'a, 't> AstroFrontmatterWithoutProgram<'a, 't> {
18677+
#[inline]
18678+
pub fn span(self) -> &'t Span {
18679+
unsafe { &*((self.0 as *const u8).add(OFFSET_ASTRO_FRONTMATTER_SPAN) as *const Span) }
18680+
}
18681+
}
18682+
18683+
impl<'a, 't> GetAddress for AstroFrontmatterWithoutProgram<'a, 't> {
18684+
#[inline]
18685+
fn address(&self) -> Address {
18686+
unsafe { Address::from_ptr(self.0) }
18687+
}
18688+
}
18689+
18690+
pub(crate) const OFFSET_ASTRO_SCRIPT_SPAN: usize = offset_of!(AstroScript, span);
18691+
pub(crate) const OFFSET_ASTRO_SCRIPT_PROGRAM: usize = offset_of!(AstroScript, program);
18692+
18693+
#[repr(transparent)]
18694+
#[derive(Clone, Copy, Debug)]
18695+
pub struct AstroScriptWithoutProgram<'a, 't>(
18696+
pub(crate) *const AstroScript<'a>,
18697+
pub(crate) PhantomData<&'t ()>,
18698+
);
18699+
18700+
impl<'a, 't> AstroScriptWithoutProgram<'a, 't> {
18701+
#[inline]
18702+
pub fn span(self) -> &'t Span {
18703+
unsafe { &*((self.0 as *const u8).add(OFFSET_ASTRO_SCRIPT_SPAN) as *const Span) }
18704+
}
18705+
}
18706+
18707+
impl<'a, 't> GetAddress for AstroScriptWithoutProgram<'a, 't> {
18708+
#[inline]
18709+
fn address(&self) -> Address {
18710+
unsafe { Address::from_ptr(self.0) }
18711+
}
18712+
}

crates/oxc_minifier/src/generated/traverse.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2481,6 +2481,41 @@ pub trait Traverse<'a> {
24812481
fn exit_js_doc_unknown_type(&mut self, node: &mut JSDocUnknownType, ctx: &mut TraverseCtx<'a>) {
24822482
}
24832483

2484+
#[inline]
2485+
fn enter_astro_root(&mut self, node: &mut AstroRoot<'a>, ctx: &mut TraverseCtx<'a>) {}
2486+
#[inline]
2487+
fn exit_astro_root(&mut self, node: &mut AstroRoot<'a>, ctx: &mut TraverseCtx<'a>) {}
2488+
2489+
#[inline]
2490+
fn enter_astro_frontmatter(
2491+
&mut self,
2492+
node: &mut AstroFrontmatter<'a>,
2493+
ctx: &mut TraverseCtx<'a>,
2494+
) {
2495+
}
2496+
#[inline]
2497+
fn exit_astro_frontmatter(
2498+
&mut self,
2499+
node: &mut AstroFrontmatter<'a>,
2500+
ctx: &mut TraverseCtx<'a>,
2501+
) {
2502+
}
2503+
2504+
#[inline]
2505+
fn enter_astro_script(&mut self, node: &mut AstroScript<'a>, ctx: &mut TraverseCtx<'a>) {}
2506+
#[inline]
2507+
fn exit_astro_script(&mut self, node: &mut AstroScript<'a>, ctx: &mut TraverseCtx<'a>) {}
2508+
2509+
#[inline]
2510+
fn enter_astro_doctype(&mut self, node: &mut AstroDoctype<'a>, ctx: &mut TraverseCtx<'a>) {}
2511+
#[inline]
2512+
fn exit_astro_doctype(&mut self, node: &mut AstroDoctype<'a>, ctx: &mut TraverseCtx<'a>) {}
2513+
2514+
#[inline]
2515+
fn enter_astro_comment(&mut self, node: &mut AstroComment<'a>, ctx: &mut TraverseCtx<'a>) {}
2516+
#[inline]
2517+
fn exit_astro_comment(&mut self, node: &mut AstroComment<'a>, ctx: &mut TraverseCtx<'a>) {}
2518+
24842519
#[inline]
24852520
fn enter_statements(&mut self, node: &mut Vec<'a, Statement<'a>>, ctx: &mut TraverseCtx<'a>) {}
24862521
#[inline]

crates/oxc_minifier/src/generated/walk.rs

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3699,6 +3699,9 @@ unsafe fn walk_jsx_child<'a, Tr: Traverse<'a>>(
36993699
walk_jsx_expression_container(traverser, (&mut **node) as *mut _, ctx)
37003700
}
37013701
JSXChild::Spread(node) => walk_jsx_spread_child(traverser, (&mut **node) as *mut _, ctx),
3702+
JSXChild::AstroScript(node) => walk_astro_script(traverser, (&mut **node) as *mut _, ctx),
3703+
JSXChild::AstroDoctype(node) => walk_astro_doctype(traverser, (&mut **node) as *mut _, ctx),
3704+
JSXChild::AstroComment(node) => walk_astro_comment(traverser, (&mut **node) as *mut _, ctx),
37023705
}
37033706
traverser.exit_jsx_child(&mut *node, ctx);
37043707
}
@@ -5728,6 +5731,84 @@ unsafe fn walk_js_doc_unknown_type<'a, Tr: Traverse<'a>>(
57285731
traverser.exit_js_doc_unknown_type(&mut *node, ctx);
57295732
}
57305733

5734+
unsafe fn walk_astro_root<'a, Tr: Traverse<'a>>(
5735+
traverser: &mut Tr,
5736+
node: *mut AstroRoot<'a>,
5737+
ctx: &mut TraverseCtx<'a>,
5738+
) {
5739+
traverser.enter_astro_root(&mut *node, ctx);
5740+
let pop_token = ctx.push_stack(Ancestor::AstroRootFrontmatter(
5741+
ancestor::AstroRootWithoutFrontmatter(node, PhantomData),
5742+
));
5743+
if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_ASTRO_ROOT_FRONTMATTER)
5744+
as *mut Option<Box<AstroFrontmatter>>)
5745+
{
5746+
walk_astro_frontmatter(traverser, (&mut **field) as *mut _, ctx);
5747+
}
5748+
ctx.retag_stack(AncestorType::AstroRootBody);
5749+
for item in
5750+
&mut *((node as *mut u8).add(ancestor::OFFSET_ASTRO_ROOT_BODY) as *mut Vec<JSXChild>)
5751+
{
5752+
walk_jsx_child(traverser, item as *mut _, ctx);
5753+
}
5754+
ctx.pop_stack(pop_token);
5755+
traverser.exit_astro_root(&mut *node, ctx);
5756+
}
5757+
5758+
unsafe fn walk_astro_frontmatter<'a, Tr: Traverse<'a>>(
5759+
traverser: &mut Tr,
5760+
node: *mut AstroFrontmatter<'a>,
5761+
ctx: &mut TraverseCtx<'a>,
5762+
) {
5763+
traverser.enter_astro_frontmatter(&mut *node, ctx);
5764+
let pop_token = ctx.push_stack(Ancestor::AstroFrontmatterProgram(
5765+
ancestor::AstroFrontmatterWithoutProgram(node, PhantomData),
5766+
));
5767+
walk_program(
5768+
traverser,
5769+
(node as *mut u8).add(ancestor::OFFSET_ASTRO_FRONTMATTER_PROGRAM) as *mut Program,
5770+
ctx,
5771+
);
5772+
ctx.pop_stack(pop_token);
5773+
traverser.exit_astro_frontmatter(&mut *node, ctx);
5774+
}
5775+
5776+
unsafe fn walk_astro_script<'a, Tr: Traverse<'a>>(
5777+
traverser: &mut Tr,
5778+
node: *mut AstroScript<'a>,
5779+
ctx: &mut TraverseCtx<'a>,
5780+
) {
5781+
traverser.enter_astro_script(&mut *node, ctx);
5782+
let pop_token = ctx.push_stack(Ancestor::AstroScriptProgram(
5783+
ancestor::AstroScriptWithoutProgram(node, PhantomData),
5784+
));
5785+
walk_program(
5786+
traverser,
5787+
(node as *mut u8).add(ancestor::OFFSET_ASTRO_SCRIPT_PROGRAM) as *mut Program,
5788+
ctx,
5789+
);
5790+
ctx.pop_stack(pop_token);
5791+
traverser.exit_astro_script(&mut *node, ctx);
5792+
}
5793+
5794+
unsafe fn walk_astro_doctype<'a, Tr: Traverse<'a>>(
5795+
traverser: &mut Tr,
5796+
node: *mut AstroDoctype<'a>,
5797+
ctx: &mut TraverseCtx<'a>,
5798+
) {
5799+
traverser.enter_astro_doctype(&mut *node, ctx);
5800+
traverser.exit_astro_doctype(&mut *node, ctx);
5801+
}
5802+
5803+
unsafe fn walk_astro_comment<'a, Tr: Traverse<'a>>(
5804+
traverser: &mut Tr,
5805+
node: *mut AstroComment<'a>,
5806+
ctx: &mut TraverseCtx<'a>,
5807+
) {
5808+
traverser.enter_astro_comment(&mut *node, ctx);
5809+
traverser.exit_astro_comment(&mut *node, ctx);
5810+
}
5811+
57315812
unsafe fn walk_statements<'a, Tr: Traverse<'a>>(
57325813
traverser: &mut Tr,
57335814
stmts: *mut Vec<'a, Statement<'a>>,

0 commit comments

Comments
 (0)