Skip to content

Commit 62216fe

Browse files
committed
fix(ast): Box this_param in TSCallSignatureDeclaration
1 parent 2eb1f88 commit 62216fe

8 files changed

Lines changed: 42 additions & 49 deletions

File tree

crates/oxc_ast/src/ast/ts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ pub struct TSCallSignatureDeclaration<'a> {
10161016
pub span: Span,
10171017
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
10181018
#[estree(skip)]
1019-
pub this_param: Option<TSThisParameter<'a>>,
1019+
pub this_param: Option<Box<'a, TSThisParameter<'a>>>,
10201020
#[estree(via = TSCallSignatureDeclarationFormalParameters)]
10211021
pub params: Box<'a, FormalParameters<'a>>,
10221022
pub return_type: Option<Box<'a, TSTypeAnnotation<'a>>>,

crates/oxc_ast/src/generated/assert_layouts.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,13 +1161,13 @@ const _: () = {
11611161
assert!(offset_of!(TSIndexSignature, readonly) == 48);
11621162
assert!(offset_of!(TSIndexSignature, r#static) == 49);
11631163

1164-
assert!(size_of::<TSCallSignatureDeclaration>() == 64);
1164+
assert!(size_of::<TSCallSignatureDeclaration>() == 40);
11651165
assert!(align_of::<TSCallSignatureDeclaration>() == 8);
11661166
assert!(offset_of!(TSCallSignatureDeclaration, span) == 0);
11671167
assert!(offset_of!(TSCallSignatureDeclaration, type_parameters) == 8);
11681168
assert!(offset_of!(TSCallSignatureDeclaration, this_param) == 16);
1169-
assert!(offset_of!(TSCallSignatureDeclaration, params) == 48);
1170-
assert!(offset_of!(TSCallSignatureDeclaration, return_type) == 56);
1169+
assert!(offset_of!(TSCallSignatureDeclaration, params) == 24);
1170+
assert!(offset_of!(TSCallSignatureDeclaration, return_type) == 32);
11711171

11721172
assert!(size_of::<TSMethodSignatureKind>() == 1);
11731173
assert!(align_of::<TSMethodSignatureKind>() == 1);
@@ -2554,13 +2554,13 @@ const _: () = {
25542554
assert!(offset_of!(TSIndexSignature, readonly) == 28);
25552555
assert!(offset_of!(TSIndexSignature, r#static) == 29);
25562556

2557-
assert!(size_of::<TSCallSignatureDeclaration>() == 44);
2557+
assert!(size_of::<TSCallSignatureDeclaration>() == 24);
25582558
assert!(align_of::<TSCallSignatureDeclaration>() == 4);
25592559
assert!(offset_of!(TSCallSignatureDeclaration, span) == 0);
25602560
assert!(offset_of!(TSCallSignatureDeclaration, type_parameters) == 8);
25612561
assert!(offset_of!(TSCallSignatureDeclaration, this_param) == 12);
2562-
assert!(offset_of!(TSCallSignatureDeclaration, params) == 36);
2563-
assert!(offset_of!(TSCallSignatureDeclaration, return_type) == 40);
2562+
assert!(offset_of!(TSCallSignatureDeclaration, params) == 16);
2563+
assert!(offset_of!(TSCallSignatureDeclaration, return_type) == 20);
25642564

25652565
assert!(size_of::<TSMethodSignatureKind>() == 1);
25662566
assert!(align_of::<TSMethodSignatureKind>() == 1);

crates/oxc_ast/src/generated/ast_builder.rs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12388,18 +12388,19 @@ impl<'a> AstBuilder<'a> {
1238812388
/// * `params`
1238912389
/// * `return_type`
1239012390
#[inline]
12391-
pub fn ts_signature_call_signature_declaration<T1, T2, T3>(
12391+
pub fn ts_signature_call_signature_declaration<T1, T2, T3, T4>(
1239212392
self,
1239312393
span: Span,
1239412394
type_parameters: T1,
12395-
this_param: Option<TSThisParameter<'a>>,
12396-
params: T2,
12397-
return_type: T3,
12395+
this_param: T2,
12396+
params: T3,
12397+
return_type: T4,
1239812398
) -> TSSignature<'a>
1239912399
where
1240012400
T1: IntoIn<'a, Option<Box<'a, TSTypeParameterDeclaration<'a>>>>,
12401-
T2: IntoIn<'a, Box<'a, FormalParameters<'a>>>,
12402-
T3: IntoIn<'a, Option<Box<'a, TSTypeAnnotation<'a>>>>,
12401+
T2: IntoIn<'a, Option<Box<'a, TSThisParameter<'a>>>>,
12402+
T3: IntoIn<'a, Box<'a, FormalParameters<'a>>>,
12403+
T4: IntoIn<'a, Option<Box<'a, TSTypeAnnotation<'a>>>>,
1240312404
{
1240412405
TSSignature::TSCallSignatureDeclaration(self.alloc_ts_call_signature_declaration(
1240512406
span,
@@ -12643,23 +12644,24 @@ impl<'a> AstBuilder<'a> {
1264312644
/// * `params`
1264412645
/// * `return_type`
1264512646
#[inline]
12646-
pub fn ts_call_signature_declaration<T1, T2, T3>(
12647+
pub fn ts_call_signature_declaration<T1, T2, T3, T4>(
1264712648
self,
1264812649
span: Span,
1264912650
type_parameters: T1,
12650-
this_param: Option<TSThisParameter<'a>>,
12651-
params: T2,
12652-
return_type: T3,
12651+
this_param: T2,
12652+
params: T3,
12653+
return_type: T4,
1265312654
) -> TSCallSignatureDeclaration<'a>
1265412655
where
1265512656
T1: IntoIn<'a, Option<Box<'a, TSTypeParameterDeclaration<'a>>>>,
12656-
T2: IntoIn<'a, Box<'a, FormalParameters<'a>>>,
12657-
T3: IntoIn<'a, Option<Box<'a, TSTypeAnnotation<'a>>>>,
12657+
T2: IntoIn<'a, Option<Box<'a, TSThisParameter<'a>>>>,
12658+
T3: IntoIn<'a, Box<'a, FormalParameters<'a>>>,
12659+
T4: IntoIn<'a, Option<Box<'a, TSTypeAnnotation<'a>>>>,
1265812660
{
1265912661
TSCallSignatureDeclaration {
1266012662
span,
1266112663
type_parameters: type_parameters.into_in(self.allocator),
12662-
this_param,
12664+
this_param: this_param.into_in(self.allocator),
1266312665
params: params.into_in(self.allocator),
1266412666
return_type: return_type.into_in(self.allocator),
1266512667
}
@@ -12677,18 +12679,19 @@ impl<'a> AstBuilder<'a> {
1267712679
/// * `params`
1267812680
/// * `return_type`
1267912681
#[inline]
12680-
pub fn alloc_ts_call_signature_declaration<T1, T2, T3>(
12682+
pub fn alloc_ts_call_signature_declaration<T1, T2, T3, T4>(
1268112683
self,
1268212684
span: Span,
1268312685
type_parameters: T1,
12684-
this_param: Option<TSThisParameter<'a>>,
12685-
params: T2,
12686-
return_type: T3,
12686+
this_param: T2,
12687+
params: T3,
12688+
return_type: T4,
1268712689
) -> Box<'a, TSCallSignatureDeclaration<'a>>
1268812690
where
1268912691
T1: IntoIn<'a, Option<Box<'a, TSTypeParameterDeclaration<'a>>>>,
12690-
T2: IntoIn<'a, Box<'a, FormalParameters<'a>>>,
12691-
T3: IntoIn<'a, Option<Box<'a, TSTypeAnnotation<'a>>>>,
12692+
T2: IntoIn<'a, Option<Box<'a, TSThisParameter<'a>>>>,
12693+
T3: IntoIn<'a, Box<'a, FormalParameters<'a>>>,
12694+
T4: IntoIn<'a, Option<Box<'a, TSTypeAnnotation<'a>>>>,
1269212695
{
1269312696
Box::new_in(
1269412697
self.ts_call_signature_declaration(

crates/oxc_ast/src/serialize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ pub struct TSCallSignatureDeclarationFormalParameters<'a, 'b>(
12061206
impl ESTree for TSCallSignatureDeclarationFormalParameters<'_, '_> {
12071207
fn serialize<S: Serializer>(&self, serializer: S) {
12081208
let v = self.0;
1209-
serialize_formal_params_with_this_param(v.this_param.as_ref(), &v.params, serializer);
1209+
serialize_formal_params_with_this_param(v.this_param.as_deref(), &v.params, serializer);
12101210
}
12111211
}
12121212

crates/oxc_traverse/src/generated/ancestor.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13005,10 +13005,10 @@ impl<'a, 't> TSCallSignatureDeclarationWithoutTypeParameters<'a, 't> {
1300513005
}
1300613006

1300713007
#[inline]
13008-
pub fn this_param(self) -> &'t Option<TSThisParameter<'a>> {
13008+
pub fn this_param(self) -> &'t Option<Box<'a, TSThisParameter<'a>>> {
1300913009
unsafe {
1301013010
&*((self.0 as *const u8).add(OFFSET_TS_CALL_SIGNATURE_DECLARATION_THIS_PARAM)
13011-
as *const Option<TSThisParameter<'a>>)
13011+
as *const Option<Box<'a, TSThisParameter<'a>>>)
1301213012
}
1301313013
}
1301413014

@@ -13107,10 +13107,10 @@ impl<'a, 't> TSCallSignatureDeclarationWithoutParams<'a, 't> {
1310713107
}
1310813108

1310913109
#[inline]
13110-
pub fn this_param(self) -> &'t Option<TSThisParameter<'a>> {
13110+
pub fn this_param(self) -> &'t Option<Box<'a, TSThisParameter<'a>>> {
1311113111
unsafe {
1311213112
&*((self.0 as *const u8).add(OFFSET_TS_CALL_SIGNATURE_DECLARATION_THIS_PARAM)
13113-
as *const Option<TSThisParameter<'a>>)
13113+
as *const Option<Box<'a, TSThisParameter<'a>>>)
1311413114
}
1311513115
}
1311613116

@@ -13154,10 +13154,10 @@ impl<'a, 't> TSCallSignatureDeclarationWithoutReturnType<'a, 't> {
1315413154
}
1315513155

1315613156
#[inline]
13157-
pub fn this_param(self) -> &'t Option<TSThisParameter<'a>> {
13157+
pub fn this_param(self) -> &'t Option<Box<'a, TSThisParameter<'a>>> {
1315813158
unsafe {
1315913159
&*((self.0 as *const u8).add(OFFSET_TS_CALL_SIGNATURE_DECLARATION_THIS_PARAM)
13160-
as *const Option<TSThisParameter<'a>>)
13160+
as *const Option<Box<'a, TSThisParameter<'a>>>)
1316113161
}
1316213162
}
1316313163

crates/oxc_traverse/src/generated/walk.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4758,10 +4758,10 @@ unsafe fn walk_ts_call_signature_declaration<'a, Tr: Traverse<'a>>(
47584758
}
47594759
if let Some(field) = &mut *((node as *mut u8)
47604760
.add(ancestor::OFFSET_TS_CALL_SIGNATURE_DECLARATION_THIS_PARAM)
4761-
as *mut Option<TSThisParameter>)
4761+
as *mut Option<Box<TSThisParameter>>)
47624762
{
47634763
ctx.retag_stack(AncestorType::TSCallSignatureDeclarationThisParam);
4764-
walk_ts_this_parameter(traverser, field as *mut _, ctx);
4764+
walk_ts_this_parameter(traverser, (&mut **field) as *mut _, ctx);
47654765
}
47664766
ctx.retag_stack(AncestorType::TSCallSignatureDeclarationParams);
47674767
walk_formal_parameters(

napi/parser/deserialize-js.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,7 +1682,7 @@ function deserializeTSIndexSignature(pos) {
16821682
}
16831683

16841684
function deserializeTSCallSignatureDeclaration(pos) {
1685-
const params = deserializeBoxFormalParameters(pos + 48);
1685+
const params = deserializeBoxFormalParameters(pos + 24);
16861686
const thisParam = deserializeOptionBoxTSThisParameter(pos + 16);
16871687
if (thisParam !== null) params.unshift(thisParam);
16881688
return {
@@ -1691,7 +1691,7 @@ function deserializeTSCallSignatureDeclaration(pos) {
16911691
end: deserializeU32(pos + 4),
16921692
typeParameters: deserializeOptionBoxTSTypeParameterDeclaration(pos + 8),
16931693
params,
1694-
returnType: deserializeOptionBoxTSTypeAnnotation(pos + 56),
1694+
returnType: deserializeOptionBoxTSTypeAnnotation(pos + 32),
16951695
};
16961696
}
16971697

@@ -5492,11 +5492,6 @@ function deserializeVecTSIndexSignatureName(pos) {
54925492
return arr;
54935493
}
54945494

5495-
function deserializeOptionTSThisParameter(pos) {
5496-
if (uint8[pos] === 0) return null;
5497-
return deserializeTSThisParameter(pos + 8);
5498-
}
5499-
55005495
function deserializeOptionTSModuleDeclarationBody(pos) {
55015496
if (uint8[pos] === 2) return null;
55025497
return deserializeTSModuleDeclarationBody(pos);

napi/parser/deserialize-ts.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,7 +1830,7 @@ function deserializeTSIndexSignature(pos) {
18301830
}
18311831

18321832
function deserializeTSCallSignatureDeclaration(pos) {
1833-
const params = deserializeBoxFormalParameters(pos + 48);
1833+
const params = deserializeBoxFormalParameters(pos + 24);
18341834
const thisParam = deserializeOptionBoxTSThisParameter(pos + 16);
18351835
if (thisParam !== null) params.unshift(thisParam);
18361836
return {
@@ -1839,7 +1839,7 @@ function deserializeTSCallSignatureDeclaration(pos) {
18391839
end: deserializeU32(pos + 4),
18401840
typeParameters: deserializeOptionBoxTSTypeParameterDeclaration(pos + 8),
18411841
params,
1842-
returnType: deserializeOptionBoxTSTypeAnnotation(pos + 56),
1842+
returnType: deserializeOptionBoxTSTypeAnnotation(pos + 32),
18431843
};
18441844
}
18451845

@@ -5640,11 +5640,6 @@ function deserializeVecTSIndexSignatureName(pos) {
56405640
return arr;
56415641
}
56425642

5643-
function deserializeOptionTSThisParameter(pos) {
5644-
if (uint8[pos] === 0) return null;
5645-
return deserializeTSThisParameter(pos + 8);
5646-
}
5647-
56485643
function deserializeOptionTSModuleDeclarationBody(pos) {
56495644
if (uint8[pos] === 2) return null;
56505645
return deserializeTSModuleDeclarationBody(pos);

0 commit comments

Comments
 (0)