Skip to content

Commit

Permalink
u
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Sep 4, 2024
1 parent d06d157 commit 8fc0432
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 58 deletions.
12 changes: 1 addition & 11 deletions crates/oxc_ast/src/ast/ts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,10 @@ export interface TSIndexSignatureName extends Span {
pub struct TSThisParameter<'a> {
#[serde(flatten)]
pub span: Span,
pub this: TSThisParameterKeyword,
pub this_span: Span,
pub type_annotation: Option<Box<'a, TSTypeAnnotation<'a>>>,
}

#[ast]
#[derive(Debug, Hash)]
#[generate_derive(CloneIn, GetSpan, GetSpanMut)]
#[cfg_attr(feature = "serialize", derive(Serialize, Tsify))]
#[serde(tag = "type", rename_all = "camelCase")]
pub struct TSThisParameterKeyword {
#[serde(flatten)]
pub span: Span,
}

/// Enum Declaration
///
/// `const_opt` enum `BindingIdentifier` { `EnumBody_opt` }
Expand Down
12 changes: 2 additions & 10 deletions crates/oxc_ast/src/generated/assert_layouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -788,13 +788,9 @@ const _: () = {
assert!(size_of::<TSThisParameter>() == 24usize);
assert!(align_of::<TSThisParameter>() == 8usize);
assert!(offset_of!(TSThisParameter, span) == 0usize);
assert!(offset_of!(TSThisParameter, this) == 8usize);
assert!(offset_of!(TSThisParameter, this_span) == 8usize);
assert!(offset_of!(TSThisParameter, type_annotation) == 16usize);

assert!(size_of::<TSThisParameterKeyword>() == 8usize);
assert!(align_of::<TSThisParameterKeyword>() == 4usize);
assert!(offset_of!(TSThisParameterKeyword, span) == 0usize);

assert!(size_of::<TSEnumDeclaration>() == 80usize);
assert!(align_of::<TSEnumDeclaration>() == 8usize);
assert!(offset_of!(TSEnumDeclaration, span) == 0usize);
Expand Down Expand Up @@ -2346,13 +2342,9 @@ const _: () = {
assert!(size_of::<TSThisParameter>() == 20usize);
assert!(align_of::<TSThisParameter>() == 4usize);
assert!(offset_of!(TSThisParameter, span) == 0usize);
assert!(offset_of!(TSThisParameter, this) == 8usize);
assert!(offset_of!(TSThisParameter, this_span) == 8usize);
assert!(offset_of!(TSThisParameter, type_annotation) == 16usize);

assert!(size_of::<TSThisParameterKeyword>() == 8usize);
assert!(align_of::<TSThisParameterKeyword>() == 4usize);
assert!(offset_of!(TSThisParameterKeyword, span) == 0usize);

assert!(size_of::<TSEnumDeclaration>() == 52usize);
assert!(align_of::<TSEnumDeclaration>() == 4usize);
assert!(offset_of!(TSEnumDeclaration, span) == 0usize);
Expand Down
16 changes: 10 additions & 6 deletions crates/oxc_ast/src/generated/ast_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7878,19 +7878,23 @@ impl<'a> AstBuilder<'a> {
///
/// ## Parameters
/// - span: The [`Span`] covering this node
/// - this
/// - this_span
/// - type_annotation
#[inline]
pub fn ts_this_parameter<T1>(
self,
span: Span,
this: TSThisParameterKeyword,
this_span: Span,
type_annotation: T1,
) -> TSThisParameter<'a>
where
T1: IntoIn<'a, Option<Box<'a, TSTypeAnnotation<'a>>>>,
{
TSThisParameter { span, this, type_annotation: type_annotation.into_in(self.allocator) }
TSThisParameter {
span,
this_span,
type_annotation: type_annotation.into_in(self.allocator),
}
}

/// Builds a [`TSThisParameter`] and stores it in the memory arena.
Expand All @@ -7899,19 +7903,19 @@ impl<'a> AstBuilder<'a> {
///
/// ## Parameters
/// - span: The [`Span`] covering this node
/// - this
/// - this_span
/// - type_annotation
#[inline]
pub fn alloc_ts_this_parameter<T1>(
self,
span: Span,
this: TSThisParameterKeyword,
this_span: Span,
type_annotation: T1,
) -> Box<'a, TSThisParameter<'a>>
where
T1: IntoIn<'a, Option<Box<'a, TSTypeAnnotation<'a>>>>,
{
Box::new_in(self.ts_this_parameter(span, this, type_annotation), self.allocator)
Box::new_in(self.ts_this_parameter(span, this_span, type_annotation), self.allocator)
}

/// Builds a [`TSEnumDeclaration`]
Expand Down
9 changes: 1 addition & 8 deletions crates/oxc_ast/src/generated/derive_clone_in.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2278,19 +2278,12 @@ impl<'old_alloc, 'new_alloc> CloneIn<'new_alloc> for TSThisParameter<'old_alloc>
fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned {
TSThisParameter {
span: self.span.clone_in(allocator),
this: self.this.clone_in(allocator),
this_span: self.this_span.clone_in(allocator),
type_annotation: self.type_annotation.clone_in(allocator),
}
}
}

impl<'alloc> CloneIn<'alloc> for TSThisParameterKeyword {
type Cloned = TSThisParameterKeyword;
fn clone_in(&self, allocator: &'alloc Allocator) -> Self::Cloned {
TSThisParameterKeyword { span: self.span.clone_in(allocator) }
}
}

impl<'old_alloc, 'new_alloc> CloneIn<'new_alloc> for TSEnumDeclaration<'old_alloc> {
type Cloned = TSEnumDeclaration<'new_alloc>;
fn clone_in(&self, allocator: &'new_alloc Allocator) -> Self::Cloned {
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_ast/src/generated/derive_content_eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2378,7 +2378,7 @@ impl<'a> ContentEq for ModuleExportName<'a> {

impl<'a> ContentEq for TSThisParameter<'a> {
fn content_eq(&self, other: &Self) -> bool {
self.this.content_eq(&other.this) && self.type_annotation.content_eq(&other.type_annotation)
self.type_annotation.content_eq(&other.type_annotation)
}
}

Expand Down
7 changes: 0 additions & 7 deletions crates/oxc_ast/src/generated/derive_get_span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1259,13 +1259,6 @@ impl<'a> GetSpan for TSThisParameter<'a> {
}
}

impl GetSpan for TSThisParameterKeyword {
#[inline]
fn span(&self) -> Span {
self.span
}
}

impl<'a> GetSpan for TSEnumDeclaration<'a> {
#[inline]
fn span(&self) -> Span {
Expand Down
7 changes: 0 additions & 7 deletions crates/oxc_ast/src/generated/derive_get_span_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1259,13 +1259,6 @@ impl<'a> GetSpanMut for TSThisParameter<'a> {
}
}

impl GetSpanMut for TSThisParameterKeyword {
#[inline]
fn span_mut(&mut self) -> &mut Span {
&mut self.span
}
}

impl<'a> GetSpanMut for TSEnumDeclaration<'a> {
#[inline]
fn span_mut(&mut self) -> &mut Span {
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_parser/src/ts/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ impl<'a> ParserImpl<'a> {

let this_span = self.start_span();
self.bump_any();
let this = TSThisParameterKeyword { span: self.end_span(this_span) };
let this = self.end_span(this_span);

let type_annotation = self.parse_ts_type_annotation()?;
Ok(self.ast.ts_this_parameter(self.end_span(span), this, type_annotation))
Expand Down
9 changes: 3 additions & 6 deletions crates/oxc_traverse/src/generated/ancestor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9285,7 +9285,7 @@ impl<'a, 't> JSXSpreadChildWithoutExpression<'a, 't> {
}

pub(crate) const OFFSET_TS_THIS_PARAMETER_SPAN: usize = offset_of!(TSThisParameter, span);
pub(crate) const OFFSET_TS_THIS_PARAMETER_THIS: usize = offset_of!(TSThisParameter, this);
pub(crate) const OFFSET_TS_THIS_PARAMETER_THIS_SPAN: usize = offset_of!(TSThisParameter, this_span);
pub(crate) const OFFSET_TS_THIS_PARAMETER_TYPE_ANNOTATION: usize =
offset_of!(TSThisParameter, type_annotation);

Expand All @@ -9303,11 +9303,8 @@ impl<'a, 't> TSThisParameterWithoutTypeAnnotation<'a, 't> {
}

#[inline]
pub fn this(self) -> &'t TSThisParameterKeyword {
unsafe {
&*((self.0 as *const u8).add(OFFSET_TS_THIS_PARAMETER_THIS)
as *const TSThisParameterKeyword)
}
pub fn this_span(self) -> &'t Span {
unsafe { &*((self.0 as *const u8).add(OFFSET_TS_THIS_PARAMETER_THIS_SPAN) as *const Span) }
}
}

Expand Down
3 changes: 2 additions & 1 deletion tasks/ast_tools/src/derives/content_eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ define_derive! {
pub struct DeriveContentEq;
}

const IGNORE_FIELDS: [(/* field name */ &str, /* field type */ &str); 5] = [
const IGNORE_FIELDS: [(/* field name */ &str, /* field type */ &str); 6] = [
("span", "Span"),
("trailing_comma", "Span"),
("this_span", "Span"),
("scope_id", "ScopeId"),
("symbol_id", "SymbolId"),
("reference_id", "ReferenceId"),
Expand Down

0 comments on commit 8fc0432

Please sign in to comment.