mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
fix(traverse): change visit order for Function (#3685)
Alter `Traverse`'s visitation order for fields of `Function`, to match the change made to `Visit` in #3681.
This commit is contained in:
parent
6c1525eb9d
commit
90743e2a07
3 changed files with 265 additions and 265 deletions
|
|
@ -2328,6 +2328,7 @@ pub struct Function<'a> {
|
|||
pub id: Option<BindingIdentifier<'a>>,
|
||||
pub generator: bool,
|
||||
pub r#async: bool,
|
||||
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
|
||||
/// Declaring `this` in a Function <https://www.typescriptlang.org/docs/handbook/2/functions.html#declaring-this-in-a-function>
|
||||
///
|
||||
/// The JavaScript specification states that you cannot have a parameter called `this`,
|
||||
|
|
@ -2346,7 +2347,6 @@ pub struct Function<'a> {
|
|||
pub this_param: Option<TSThisParameter<'a>>,
|
||||
pub params: Box<'a, FormalParameters<'a>>,
|
||||
pub body: Option<Box<'a, FunctionBody<'a>>>,
|
||||
pub type_parameters: Option<Box<'a, TSTypeParameterDeclaration<'a>>>,
|
||||
pub return_type: Option<Box<'a, TSTypeAnnotation<'a>>>,
|
||||
/// Valid modifiers: `export`, `default`, `async`
|
||||
pub modifiers: Modifiers<'a>,
|
||||
|
|
|
|||
|
|
@ -140,10 +140,10 @@ pub(crate) enum AncestorType {
|
|||
ArrayPatternRest = 108,
|
||||
BindingRestElementArgument = 109,
|
||||
FunctionId = 110,
|
||||
FunctionThisParam = 111,
|
||||
FunctionParams = 112,
|
||||
FunctionBody = 113,
|
||||
FunctionTypeParameters = 114,
|
||||
FunctionTypeParameters = 111,
|
||||
FunctionThisParam = 112,
|
||||
FunctionParams = 113,
|
||||
FunctionBody = 114,
|
||||
FunctionReturnType = 115,
|
||||
FormalParametersItems = 116,
|
||||
FormalParametersRest = 117,
|
||||
|
|
@ -524,11 +524,11 @@ pub enum Ancestor<'a> {
|
|||
BindingRestElementArgument(BindingRestElementWithoutArgument<'a>) =
|
||||
AncestorType::BindingRestElementArgument as u16,
|
||||
FunctionId(FunctionWithoutId<'a>) = AncestorType::FunctionId as u16,
|
||||
FunctionTypeParameters(FunctionWithoutTypeParameters<'a>) =
|
||||
AncestorType::FunctionTypeParameters as u16,
|
||||
FunctionThisParam(FunctionWithoutThisParam<'a>) = AncestorType::FunctionThisParam as u16,
|
||||
FunctionParams(FunctionWithoutParams<'a>) = AncestorType::FunctionParams as u16,
|
||||
FunctionBody(FunctionWithoutBody<'a>) = AncestorType::FunctionBody as u16,
|
||||
FunctionTypeParameters(FunctionWithoutTypeParameters<'a>) =
|
||||
AncestorType::FunctionTypeParameters as u16,
|
||||
FunctionReturnType(FunctionWithoutReturnType<'a>) = AncestorType::FunctionReturnType as u16,
|
||||
FormalParametersItems(FormalParametersWithoutItems<'a>) =
|
||||
AncestorType::FormalParametersItems as u16,
|
||||
|
|
@ -1230,10 +1230,10 @@ impl<'a> Ancestor<'a> {
|
|||
matches!(
|
||||
self,
|
||||
Self::FunctionId(_)
|
||||
| Self::FunctionTypeParameters(_)
|
||||
| Self::FunctionThisParam(_)
|
||||
| Self::FunctionParams(_)
|
||||
| Self::FunctionBody(_)
|
||||
| Self::FunctionTypeParameters(_)
|
||||
| Self::FunctionReturnType(_)
|
||||
)
|
||||
}
|
||||
|
|
@ -5173,10 +5173,10 @@ pub(crate) const OFFSET_FUNCTION_SPAN: usize = offset_of!(Function, span);
|
|||
pub(crate) const OFFSET_FUNCTION_ID: usize = offset_of!(Function, id);
|
||||
pub(crate) const OFFSET_FUNCTION_GENERATOR: usize = offset_of!(Function, generator);
|
||||
pub(crate) const OFFSET_FUNCTION_ASYNC: usize = offset_of!(Function, r#async);
|
||||
pub(crate) const OFFSET_FUNCTION_TYPE_PARAMETERS: usize = offset_of!(Function, type_parameters);
|
||||
pub(crate) const OFFSET_FUNCTION_THIS_PARAM: usize = offset_of!(Function, this_param);
|
||||
pub(crate) const OFFSET_FUNCTION_PARAMS: usize = offset_of!(Function, params);
|
||||
pub(crate) const OFFSET_FUNCTION_BODY: usize = offset_of!(Function, body);
|
||||
pub(crate) const OFFSET_FUNCTION_TYPE_PARAMETERS: usize = offset_of!(Function, type_parameters);
|
||||
pub(crate) const OFFSET_FUNCTION_RETURN_TYPE: usize = offset_of!(Function, return_type);
|
||||
pub(crate) const OFFSET_FUNCTION_MODIFIERS: usize = offset_of!(Function, modifiers);
|
||||
pub(crate) const OFFSET_FUNCTION_SCOPE_ID: usize = offset_of!(Function, scope_id);
|
||||
|
|
@ -5206,6 +5206,14 @@ impl<'a> FunctionWithoutId<'a> {
|
|||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_ASYNC) as *const bool) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn type_parameters(&self) -> &Option<Box<'a, TSTypeParameterDeclaration<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_TYPE_PARAMETERS)
|
||||
as *const Option<Box<'a, TSTypeParameterDeclaration<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn this_param(&self) -> &Option<TSThisParameter<'a>> {
|
||||
unsafe {
|
||||
|
|
@ -5230,248 +5238,6 @@ impl<'a> FunctionWithoutId<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn type_parameters(&self) -> &Option<Box<'a, TSTypeParameterDeclaration<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_TYPE_PARAMETERS)
|
||||
as *const Option<Box<'a, TSTypeParameterDeclaration<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn return_type(&self) -> &Option<Box<'a, TSTypeAnnotation<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_RETURN_TYPE)
|
||||
as *const Option<Box<'a, TSTypeAnnotation<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn modifiers(&self) -> &Modifiers<'a> {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_MODIFIERS) as *const Modifiers<'a>) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn scope_id(&self) -> &Cell<Option<ScopeId>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_SCOPE_ID) as *const Cell<Option<ScopeId>>)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(transparent)]
|
||||
#[derive(Debug)]
|
||||
pub struct FunctionWithoutThisParam<'a>(pub(crate) *const Function<'a>);
|
||||
|
||||
impl<'a> FunctionWithoutThisParam<'a> {
|
||||
#[inline]
|
||||
pub fn r#type(&self) -> &FunctionType {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_TYPE) as *const FunctionType) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn span(&self) -> &Span {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_SPAN) as *const Span) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn id(&self) -> &Option<BindingIdentifier<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_ID)
|
||||
as *const Option<BindingIdentifier<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn generator(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_GENERATOR) as *const bool) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn r#async(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_ASYNC) as *const bool) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn params(&self) -> &Box<'a, FormalParameters<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_PARAMS)
|
||||
as *const Box<'a, FormalParameters<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn body(&self) -> &Option<Box<'a, FunctionBody<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_BODY)
|
||||
as *const Option<Box<'a, FunctionBody<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn type_parameters(&self) -> &Option<Box<'a, TSTypeParameterDeclaration<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_TYPE_PARAMETERS)
|
||||
as *const Option<Box<'a, TSTypeParameterDeclaration<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn return_type(&self) -> &Option<Box<'a, TSTypeAnnotation<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_RETURN_TYPE)
|
||||
as *const Option<Box<'a, TSTypeAnnotation<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn modifiers(&self) -> &Modifiers<'a> {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_MODIFIERS) as *const Modifiers<'a>) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn scope_id(&self) -> &Cell<Option<ScopeId>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_SCOPE_ID) as *const Cell<Option<ScopeId>>)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(transparent)]
|
||||
#[derive(Debug)]
|
||||
pub struct FunctionWithoutParams<'a>(pub(crate) *const Function<'a>);
|
||||
|
||||
impl<'a> FunctionWithoutParams<'a> {
|
||||
#[inline]
|
||||
pub fn r#type(&self) -> &FunctionType {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_TYPE) as *const FunctionType) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn span(&self) -> &Span {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_SPAN) as *const Span) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn id(&self) -> &Option<BindingIdentifier<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_ID)
|
||||
as *const Option<BindingIdentifier<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn generator(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_GENERATOR) as *const bool) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn r#async(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_ASYNC) as *const bool) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn this_param(&self) -> &Option<TSThisParameter<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_THIS_PARAM)
|
||||
as *const Option<TSThisParameter<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn body(&self) -> &Option<Box<'a, FunctionBody<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_BODY)
|
||||
as *const Option<Box<'a, FunctionBody<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn type_parameters(&self) -> &Option<Box<'a, TSTypeParameterDeclaration<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_TYPE_PARAMETERS)
|
||||
as *const Option<Box<'a, TSTypeParameterDeclaration<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn return_type(&self) -> &Option<Box<'a, TSTypeAnnotation<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_RETURN_TYPE)
|
||||
as *const Option<Box<'a, TSTypeAnnotation<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn modifiers(&self) -> &Modifiers<'a> {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_MODIFIERS) as *const Modifiers<'a>) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn scope_id(&self) -> &Cell<Option<ScopeId>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_SCOPE_ID) as *const Cell<Option<ScopeId>>)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(transparent)]
|
||||
#[derive(Debug)]
|
||||
pub struct FunctionWithoutBody<'a>(pub(crate) *const Function<'a>);
|
||||
|
||||
impl<'a> FunctionWithoutBody<'a> {
|
||||
#[inline]
|
||||
pub fn r#type(&self) -> &FunctionType {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_TYPE) as *const FunctionType) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn span(&self) -> &Span {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_SPAN) as *const Span) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn id(&self) -> &Option<BindingIdentifier<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_ID)
|
||||
as *const Option<BindingIdentifier<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn generator(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_GENERATOR) as *const bool) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn r#async(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_ASYNC) as *const bool) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn this_param(&self) -> &Option<TSThisParameter<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_THIS_PARAM)
|
||||
as *const Option<TSThisParameter<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn params(&self) -> &Box<'a, FormalParameters<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_PARAMS)
|
||||
as *const Box<'a, FormalParameters<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn type_parameters(&self) -> &Option<Box<'a, TSTypeParameterDeclaration<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_TYPE_PARAMETERS)
|
||||
as *const Option<Box<'a, TSTypeParameterDeclaration<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn return_type(&self) -> &Option<Box<'a, TSTypeAnnotation<'a>>> {
|
||||
unsafe {
|
||||
|
|
@ -5571,6 +5337,240 @@ impl<'a> FunctionWithoutTypeParameters<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[repr(transparent)]
|
||||
#[derive(Debug)]
|
||||
pub struct FunctionWithoutThisParam<'a>(pub(crate) *const Function<'a>);
|
||||
|
||||
impl<'a> FunctionWithoutThisParam<'a> {
|
||||
#[inline]
|
||||
pub fn r#type(&self) -> &FunctionType {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_TYPE) as *const FunctionType) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn span(&self) -> &Span {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_SPAN) as *const Span) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn id(&self) -> &Option<BindingIdentifier<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_ID)
|
||||
as *const Option<BindingIdentifier<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn generator(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_GENERATOR) as *const bool) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn r#async(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_ASYNC) as *const bool) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn type_parameters(&self) -> &Option<Box<'a, TSTypeParameterDeclaration<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_TYPE_PARAMETERS)
|
||||
as *const Option<Box<'a, TSTypeParameterDeclaration<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn params(&self) -> &Box<'a, FormalParameters<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_PARAMS)
|
||||
as *const Box<'a, FormalParameters<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn body(&self) -> &Option<Box<'a, FunctionBody<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_BODY)
|
||||
as *const Option<Box<'a, FunctionBody<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn return_type(&self) -> &Option<Box<'a, TSTypeAnnotation<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_RETURN_TYPE)
|
||||
as *const Option<Box<'a, TSTypeAnnotation<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn modifiers(&self) -> &Modifiers<'a> {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_MODIFIERS) as *const Modifiers<'a>) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn scope_id(&self) -> &Cell<Option<ScopeId>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_SCOPE_ID) as *const Cell<Option<ScopeId>>)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(transparent)]
|
||||
#[derive(Debug)]
|
||||
pub struct FunctionWithoutParams<'a>(pub(crate) *const Function<'a>);
|
||||
|
||||
impl<'a> FunctionWithoutParams<'a> {
|
||||
#[inline]
|
||||
pub fn r#type(&self) -> &FunctionType {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_TYPE) as *const FunctionType) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn span(&self) -> &Span {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_SPAN) as *const Span) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn id(&self) -> &Option<BindingIdentifier<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_ID)
|
||||
as *const Option<BindingIdentifier<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn generator(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_GENERATOR) as *const bool) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn r#async(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_ASYNC) as *const bool) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn type_parameters(&self) -> &Option<Box<'a, TSTypeParameterDeclaration<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_TYPE_PARAMETERS)
|
||||
as *const Option<Box<'a, TSTypeParameterDeclaration<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn this_param(&self) -> &Option<TSThisParameter<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_THIS_PARAM)
|
||||
as *const Option<TSThisParameter<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn body(&self) -> &Option<Box<'a, FunctionBody<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_BODY)
|
||||
as *const Option<Box<'a, FunctionBody<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn return_type(&self) -> &Option<Box<'a, TSTypeAnnotation<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_RETURN_TYPE)
|
||||
as *const Option<Box<'a, TSTypeAnnotation<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn modifiers(&self) -> &Modifiers<'a> {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_MODIFIERS) as *const Modifiers<'a>) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn scope_id(&self) -> &Cell<Option<ScopeId>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_SCOPE_ID) as *const Cell<Option<ScopeId>>)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(transparent)]
|
||||
#[derive(Debug)]
|
||||
pub struct FunctionWithoutBody<'a>(pub(crate) *const Function<'a>);
|
||||
|
||||
impl<'a> FunctionWithoutBody<'a> {
|
||||
#[inline]
|
||||
pub fn r#type(&self) -> &FunctionType {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_TYPE) as *const FunctionType) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn span(&self) -> &Span {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_SPAN) as *const Span) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn id(&self) -> &Option<BindingIdentifier<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_ID)
|
||||
as *const Option<BindingIdentifier<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn generator(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_GENERATOR) as *const bool) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn r#async(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_ASYNC) as *const bool) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn type_parameters(&self) -> &Option<Box<'a, TSTypeParameterDeclaration<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_TYPE_PARAMETERS)
|
||||
as *const Option<Box<'a, TSTypeParameterDeclaration<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn this_param(&self) -> &Option<TSThisParameter<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_THIS_PARAM)
|
||||
as *const Option<TSThisParameter<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn params(&self) -> &Box<'a, FormalParameters<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_PARAMS)
|
||||
as *const Box<'a, FormalParameters<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn return_type(&self) -> &Option<Box<'a, TSTypeAnnotation<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_RETURN_TYPE)
|
||||
as *const Option<Box<'a, TSTypeAnnotation<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn modifiers(&self) -> &Modifiers<'a> {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_MODIFIERS) as *const Modifiers<'a>) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn scope_id(&self) -> &Cell<Option<ScopeId>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_SCOPE_ID) as *const Cell<Option<ScopeId>>)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(transparent)]
|
||||
#[derive(Debug)]
|
||||
pub struct FunctionWithoutReturnType<'a>(pub(crate) *const Function<'a>);
|
||||
|
|
@ -5604,6 +5604,14 @@ impl<'a> FunctionWithoutReturnType<'a> {
|
|||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_ASYNC) as *const bool) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn type_parameters(&self) -> &Option<Box<'a, TSTypeParameterDeclaration<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_TYPE_PARAMETERS)
|
||||
as *const Option<Box<'a, TSTypeParameterDeclaration<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn this_param(&self) -> &Option<TSThisParameter<'a>> {
|
||||
unsafe {
|
||||
|
|
@ -5628,14 +5636,6 @@ impl<'a> FunctionWithoutReturnType<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn type_parameters(&self) -> &Option<Box<'a, TSTypeParameterDeclaration<'a>>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FUNCTION_TYPE_PARAMETERS)
|
||||
as *const Option<Box<'a, TSTypeParameterDeclaration<'a>>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn modifiers(&self) -> &Modifiers<'a> {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FUNCTION_MODIFIERS) as *const Modifiers<'a>) }
|
||||
|
|
|
|||
|
|
@ -2266,6 +2266,12 @@ pub(crate) unsafe fn walk_function<'a, Tr: Traverse<'a>>(
|
|||
{
|
||||
walk_binding_identifier(traverser, field as *mut _, ctx);
|
||||
}
|
||||
if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_FUNCTION_TYPE_PARAMETERS)
|
||||
as *mut Option<Box<TSTypeParameterDeclaration>>)
|
||||
{
|
||||
ctx.retag_stack(AncestorType::FunctionTypeParameters);
|
||||
walk_ts_type_parameter_declaration(traverser, (&mut **field) as *mut _, ctx);
|
||||
}
|
||||
if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_FUNCTION_THIS_PARAM)
|
||||
as *mut Option<TSThisParameter>)
|
||||
{
|
||||
|
|
@ -2285,12 +2291,6 @@ pub(crate) unsafe fn walk_function<'a, Tr: Traverse<'a>>(
|
|||
ctx.retag_stack(AncestorType::FunctionBody);
|
||||
walk_function_body(traverser, (&mut **field) as *mut _, ctx);
|
||||
}
|
||||
if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_FUNCTION_TYPE_PARAMETERS)
|
||||
as *mut Option<Box<TSTypeParameterDeclaration>>)
|
||||
{
|
||||
ctx.retag_stack(AncestorType::FunctionTypeParameters);
|
||||
walk_ts_type_parameter_declaration(traverser, (&mut **field) as *mut _, ctx);
|
||||
}
|
||||
if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_FUNCTION_RETURN_TYPE)
|
||||
as *mut Option<Box<TSTypeAnnotation>>)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue