mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
fix(ast): put decorators before everything else. (#4143)
Won't fix #4142 It is similar to #3994 but for those types that weren't relying on this order. It seems to be the right order. technically speaking it is a breaking change but I know as a fact that it won't have a big difference on our downstream. If you want it to be chronically correct feel free to merge as a breaking change.
This commit is contained in:
parent
fca9706ab3
commit
48947a26d2
12 changed files with 212 additions and 208 deletions
|
|
@ -1511,11 +1511,11 @@ pub struct FormalParameters<'a> {
|
|||
pub struct FormalParameter<'a> {
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
pub span: Span,
|
||||
pub decorators: Vec<'a, Decorator<'a>>,
|
||||
pub pattern: BindingPattern<'a>,
|
||||
pub accessibility: Option<TSAccessibility>,
|
||||
pub readonly: bool,
|
||||
pub r#override: bool,
|
||||
pub decorators: Vec<'a, Decorator<'a>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
|
|
@ -1776,11 +1776,11 @@ pub struct AccessorProperty<'a> {
|
|||
pub r#type: AccessorPropertyType,
|
||||
#[cfg_attr(feature = "serialize", serde(flatten))]
|
||||
pub span: Span,
|
||||
pub decorators: Vec<'a, Decorator<'a>>,
|
||||
pub key: PropertyKey<'a>,
|
||||
pub value: Option<Expression<'a>>,
|
||||
pub computed: bool,
|
||||
pub r#static: bool,
|
||||
pub decorators: Vec<'a, Decorator<'a>>,
|
||||
}
|
||||
|
||||
#[visited_node]
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ impl<'a> AstBuilder<'a> {
|
|||
span: Span,
|
||||
pattern: BindingPattern<'a>,
|
||||
) -> FormalParameter<'a> {
|
||||
self.formal_parameter(span, pattern, None, false, false, self.vec())
|
||||
self.formal_parameter(span, self.vec(), pattern, None, false, false)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
|||
|
|
@ -3814,26 +3814,26 @@ impl<'a> AstBuilder<'a> {
|
|||
pub fn formal_parameter(
|
||||
self,
|
||||
span: Span,
|
||||
decorators: Vec<'a, Decorator<'a>>,
|
||||
pattern: BindingPattern<'a>,
|
||||
accessibility: Option<TSAccessibility>,
|
||||
readonly: bool,
|
||||
r#override: bool,
|
||||
decorators: Vec<'a, Decorator<'a>>,
|
||||
) -> FormalParameter<'a> {
|
||||
FormalParameter { span, pattern, accessibility, readonly, r#override, decorators }
|
||||
FormalParameter { span, decorators, pattern, accessibility, readonly, r#override }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn alloc_formal_parameter(
|
||||
self,
|
||||
span: Span,
|
||||
decorators: Vec<'a, Decorator<'a>>,
|
||||
pattern: BindingPattern<'a>,
|
||||
accessibility: Option<TSAccessibility>,
|
||||
readonly: bool,
|
||||
r#override: bool,
|
||||
decorators: Vec<'a, Decorator<'a>>,
|
||||
) -> Box<'a, FormalParameter<'a>> {
|
||||
self.formal_parameter(span, pattern, accessibility, readonly, r#override, decorators)
|
||||
self.formal_parameter(span, decorators, pattern, accessibility, readonly, r#override)
|
||||
.into_in(self.allocator)
|
||||
}
|
||||
|
||||
|
|
@ -4131,14 +4131,14 @@ impl<'a> AstBuilder<'a> {
|
|||
self,
|
||||
r#type: AccessorPropertyType,
|
||||
span: Span,
|
||||
decorators: Vec<'a, Decorator<'a>>,
|
||||
key: PropertyKey<'a>,
|
||||
value: Option<Expression<'a>>,
|
||||
computed: bool,
|
||||
r#static: bool,
|
||||
decorators: Vec<'a, Decorator<'a>>,
|
||||
) -> ClassElement<'a> {
|
||||
ClassElement::AccessorProperty(self.alloc(
|
||||
self.accessor_property(r#type, span, key, value, computed, r#static, decorators),
|
||||
self.accessor_property(r#type, span, decorators, key, value, computed, r#static),
|
||||
))
|
||||
}
|
||||
|
||||
|
|
@ -4510,13 +4510,13 @@ impl<'a> AstBuilder<'a> {
|
|||
self,
|
||||
r#type: AccessorPropertyType,
|
||||
span: Span,
|
||||
decorators: Vec<'a, Decorator<'a>>,
|
||||
key: PropertyKey<'a>,
|
||||
value: Option<Expression<'a>>,
|
||||
computed: bool,
|
||||
r#static: bool,
|
||||
decorators: Vec<'a, Decorator<'a>>,
|
||||
) -> AccessorProperty<'a> {
|
||||
AccessorProperty { r#type, span, key, value, computed, r#static, decorators }
|
||||
AccessorProperty { r#type, span, decorators, key, value, computed, r#static }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
@ -4524,13 +4524,13 @@ impl<'a> AstBuilder<'a> {
|
|||
self,
|
||||
r#type: AccessorPropertyType,
|
||||
span: Span,
|
||||
decorators: Vec<'a, Decorator<'a>>,
|
||||
key: PropertyKey<'a>,
|
||||
value: Option<Expression<'a>>,
|
||||
computed: bool,
|
||||
r#static: bool,
|
||||
decorators: Vec<'a, Decorator<'a>>,
|
||||
) -> Box<'a, AccessorProperty<'a>> {
|
||||
self.accessor_property(r#type, span, key, value, computed, r#static, decorators)
|
||||
self.accessor_property(r#type, span, decorators, key, value, computed, r#static)
|
||||
.into_in(self.allocator)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -227,6 +227,16 @@ pub trait Visit<'a>: Sized {
|
|||
walk_formal_parameter(self, it);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_decorators(&mut self, it: &Vec<'a, Decorator<'a>>) {
|
||||
walk_decorators(self, it);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_decorator(&mut self, it: &Decorator<'a>) {
|
||||
walk_decorator(self, it);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_binding_pattern(&mut self, it: &BindingPattern<'a>) {
|
||||
walk_binding_pattern(self, it);
|
||||
|
|
@ -625,16 +635,6 @@ pub trait Visit<'a>: Sized {
|
|||
walk_js_doc_unknown_type(self, it);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_decorators(&mut self, it: &Vec<'a, Decorator<'a>>) {
|
||||
walk_decorators(self, it);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_decorator(&mut self, it: &Decorator<'a>) {
|
||||
walk_decorator(self, it);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_function_body(&mut self, it: &FunctionBody<'a>) {
|
||||
walk_function_body(self, it);
|
||||
|
|
@ -1745,8 +1745,23 @@ pub mod walk {
|
|||
pub fn walk_formal_parameter<'a, V: Visit<'a>>(visitor: &mut V, it: &FormalParameter<'a>) {
|
||||
let kind = AstKind::FormalParameter(visitor.alloc(it));
|
||||
visitor.enter_node(kind);
|
||||
visitor.visit_binding_pattern(&it.pattern);
|
||||
visitor.visit_decorators(&it.decorators);
|
||||
visitor.visit_binding_pattern(&it.pattern);
|
||||
visitor.leave_node(kind);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn walk_decorators<'a, V: Visit<'a>>(visitor: &mut V, it: &Vec<'a, Decorator<'a>>) {
|
||||
for el in it.iter() {
|
||||
visitor.visit_decorator(el);
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn walk_decorator<'a, V: Visit<'a>>(visitor: &mut V, it: &Decorator<'a>) {
|
||||
let kind = AstKind::Decorator(visitor.alloc(it));
|
||||
visitor.enter_node(kind);
|
||||
visitor.visit_expression(&it.expression);
|
||||
visitor.leave_node(kind);
|
||||
}
|
||||
|
||||
|
|
@ -2543,21 +2558,6 @@ pub mod walk {
|
|||
// NOTE: AstKind doesn't exists!
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn walk_decorators<'a, V: Visit<'a>>(visitor: &mut V, it: &Vec<'a, Decorator<'a>>) {
|
||||
for el in it.iter() {
|
||||
visitor.visit_decorator(el);
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn walk_decorator<'a, V: Visit<'a>>(visitor: &mut V, it: &Decorator<'a>) {
|
||||
let kind = AstKind::Decorator(visitor.alloc(it));
|
||||
visitor.enter_node(kind);
|
||||
visitor.visit_expression(&it.expression);
|
||||
visitor.leave_node(kind);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn walk_function_body<'a, V: Visit<'a>>(visitor: &mut V, it: &FunctionBody<'a>) {
|
||||
let kind = AstKind::FunctionBody(visitor.alloc(it));
|
||||
|
|
@ -3053,11 +3053,11 @@ pub mod walk {
|
|||
#[inline]
|
||||
pub fn walk_accessor_property<'a, V: Visit<'a>>(visitor: &mut V, it: &AccessorProperty<'a>) {
|
||||
// NOTE: AstKind doesn't exists!
|
||||
visitor.visit_decorators(&it.decorators);
|
||||
visitor.visit_property_key(&it.key);
|
||||
if let Some(value) = &it.value {
|
||||
visitor.visit_expression(value);
|
||||
}
|
||||
visitor.visit_decorators(&it.decorators);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
|||
|
|
@ -216,6 +216,16 @@ pub trait VisitMut<'a>: Sized {
|
|||
walk_formal_parameter(self, it);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_decorators(&mut self, it: &mut Vec<'a, Decorator<'a>>) {
|
||||
walk_decorators(self, it);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_decorator(&mut self, it: &mut Decorator<'a>) {
|
||||
walk_decorator(self, it);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_binding_pattern(&mut self, it: &mut BindingPattern<'a>) {
|
||||
walk_binding_pattern(self, it);
|
||||
|
|
@ -614,16 +624,6 @@ pub trait VisitMut<'a>: Sized {
|
|||
walk_js_doc_unknown_type(self, it);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_decorators(&mut self, it: &mut Vec<'a, Decorator<'a>>) {
|
||||
walk_decorators(self, it);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_decorator(&mut self, it: &mut Decorator<'a>) {
|
||||
walk_decorator(self, it);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_function_body(&mut self, it: &mut FunctionBody<'a>) {
|
||||
walk_function_body(self, it);
|
||||
|
|
@ -1770,8 +1770,23 @@ pub mod walk_mut {
|
|||
) {
|
||||
let kind = AstType::FormalParameter;
|
||||
visitor.enter_node(kind);
|
||||
visitor.visit_binding_pattern(&mut it.pattern);
|
||||
visitor.visit_decorators(&mut it.decorators);
|
||||
visitor.visit_binding_pattern(&mut it.pattern);
|
||||
visitor.leave_node(kind);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn walk_decorators<'a, V: VisitMut<'a>>(visitor: &mut V, it: &mut Vec<'a, Decorator<'a>>) {
|
||||
for el in it.iter_mut() {
|
||||
visitor.visit_decorator(el);
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn walk_decorator<'a, V: VisitMut<'a>>(visitor: &mut V, it: &mut Decorator<'a>) {
|
||||
let kind = AstType::Decorator;
|
||||
visitor.enter_node(kind);
|
||||
visitor.visit_expression(&mut it.expression);
|
||||
visitor.leave_node(kind);
|
||||
}
|
||||
|
||||
|
|
@ -2646,21 +2661,6 @@ pub mod walk_mut {
|
|||
// NOTE: AstType doesn't exists!
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn walk_decorators<'a, V: VisitMut<'a>>(visitor: &mut V, it: &mut Vec<'a, Decorator<'a>>) {
|
||||
for el in it.iter_mut() {
|
||||
visitor.visit_decorator(el);
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn walk_decorator<'a, V: VisitMut<'a>>(visitor: &mut V, it: &mut Decorator<'a>) {
|
||||
let kind = AstType::Decorator;
|
||||
visitor.enter_node(kind);
|
||||
visitor.visit_expression(&mut it.expression);
|
||||
visitor.leave_node(kind);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn walk_function_body<'a, V: VisitMut<'a>>(visitor: &mut V, it: &mut FunctionBody<'a>) {
|
||||
let kind = AstType::FunctionBody;
|
||||
|
|
@ -3186,11 +3186,11 @@ pub mod walk_mut {
|
|||
it: &mut AccessorProperty<'a>,
|
||||
) {
|
||||
// NOTE: AstType doesn't exists!
|
||||
visitor.visit_decorators(&mut it.decorators);
|
||||
visitor.visit_property_key(&mut it.key);
|
||||
if let Some(value) = &mut it.value {
|
||||
visitor.visit_expression(value);
|
||||
}
|
||||
visitor.visit_decorators(&mut it.decorators);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
|||
|
|
@ -444,11 +444,11 @@ impl<'a> IsolatedDeclarations<'a> {
|
|||
let new_element = self.ast.class_element_accessor_property(
|
||||
property.r#type,
|
||||
property.span,
|
||||
self.ast.vec(),
|
||||
self.ast.copy(&property.key),
|
||||
None,
|
||||
property.computed,
|
||||
property.r#static,
|
||||
self.ast.vec(),
|
||||
);
|
||||
elements.push(new_element);
|
||||
}
|
||||
|
|
@ -525,7 +525,7 @@ impl<'a> IsolatedDeclarations<'a> {
|
|||
) -> Box<'a, FormalParameters<'a>> {
|
||||
let pattern = BindingPattern { kind, type_annotation, optional: false };
|
||||
let parameter =
|
||||
self.ast.formal_parameter(SPAN, pattern, None, false, false, self.ast.vec());
|
||||
self.ast.formal_parameter(SPAN, self.ast.vec(), pattern, None, false, false);
|
||||
let items = self.ast.vec1(parameter);
|
||||
self.ast.alloc_formal_parameters(
|
||||
SPAN,
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ impl<'a> IsolatedDeclarations<'a> {
|
|||
);
|
||||
}
|
||||
|
||||
Some(self.ast.formal_parameter(param.span, pattern, None, false, false, self.ast.vec()))
|
||||
Some(self.ast.formal_parameter(param.span, self.ast.vec(), pattern, None, false, false))
|
||||
}
|
||||
|
||||
pub fn transform_formal_parameters(
|
||||
|
|
|
|||
|
|
@ -498,11 +498,11 @@ impl<'a> ParserImpl<'a> {
|
|||
Ok(self.ast.class_element_accessor_property(
|
||||
r#type,
|
||||
self.end_span(span),
|
||||
decorators,
|
||||
key,
|
||||
value,
|
||||
computed,
|
||||
r#static,
|
||||
decorators,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,11 +89,11 @@ impl<'a> ParserImpl<'a> {
|
|||
let decorators = self.consume_decorators();
|
||||
Ok(self.ast.formal_parameter(
|
||||
self.end_span(span),
|
||||
decorators,
|
||||
pattern,
|
||||
modifiers.accessibility(),
|
||||
modifiers.contains_readonly(),
|
||||
modifiers.contains_override(),
|
||||
decorators,
|
||||
))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ impl<'a> TypeScriptEnum<'a> {
|
|||
let id = ast.binding_pattern(kind, Option::<TSTypeAnnotation>::None, false);
|
||||
|
||||
// ((Foo) => {
|
||||
let params = ast.formal_parameter(SPAN, id, None, false, false, ast.vec());
|
||||
let params = ast.formal_parameter(SPAN, ast.vec(), id, None, false, false);
|
||||
let params = ast.vec1(params);
|
||||
let params = ast.alloc_formal_parameters(
|
||||
SPAN,
|
||||
|
|
|
|||
|
|
@ -147,8 +147,8 @@ pub(crate) enum AncestorType {
|
|||
FunctionReturnType = 115,
|
||||
FormalParametersItems = 116,
|
||||
FormalParametersRest = 117,
|
||||
FormalParameterPattern = 118,
|
||||
FormalParameterDecorators = 119,
|
||||
FormalParameterDecorators = 118,
|
||||
FormalParameterPattern = 119,
|
||||
FunctionBodyDirectives = 120,
|
||||
FunctionBodyStatements = 121,
|
||||
ArrowFunctionExpressionParams = 122,
|
||||
|
|
@ -172,9 +172,9 @@ pub(crate) enum AncestorType {
|
|||
PropertyDefinitionValue = 140,
|
||||
PropertyDefinitionTypeAnnotation = 141,
|
||||
StaticBlockBody = 142,
|
||||
AccessorPropertyKey = 143,
|
||||
AccessorPropertyValue = 144,
|
||||
AccessorPropertyDecorators = 145,
|
||||
AccessorPropertyDecorators = 143,
|
||||
AccessorPropertyKey = 144,
|
||||
AccessorPropertyValue = 145,
|
||||
ImportExpressionSource = 146,
|
||||
ImportExpressionArguments = 147,
|
||||
ImportDeclarationSpecifiers = 148,
|
||||
|
|
@ -537,10 +537,10 @@ pub enum Ancestor<'a> {
|
|||
AncestorType::FormalParametersItems as u16,
|
||||
FormalParametersRest(FormalParametersWithoutRest<'a>) =
|
||||
AncestorType::FormalParametersRest as u16,
|
||||
FormalParameterPattern(FormalParameterWithoutPattern<'a>) =
|
||||
AncestorType::FormalParameterPattern as u16,
|
||||
FormalParameterDecorators(FormalParameterWithoutDecorators<'a>) =
|
||||
AncestorType::FormalParameterDecorators as u16,
|
||||
FormalParameterPattern(FormalParameterWithoutPattern<'a>) =
|
||||
AncestorType::FormalParameterPattern as u16,
|
||||
FunctionBodyDirectives(FunctionBodyWithoutDirectives<'a>) =
|
||||
AncestorType::FunctionBodyDirectives as u16,
|
||||
FunctionBodyStatements(FunctionBodyWithoutStatements<'a>) =
|
||||
|
|
@ -578,11 +578,11 @@ pub enum Ancestor<'a> {
|
|||
PropertyDefinitionTypeAnnotation(PropertyDefinitionWithoutTypeAnnotation<'a>) =
|
||||
AncestorType::PropertyDefinitionTypeAnnotation as u16,
|
||||
StaticBlockBody(StaticBlockWithoutBody<'a>) = AncestorType::StaticBlockBody as u16,
|
||||
AccessorPropertyDecorators(AccessorPropertyWithoutDecorators<'a>) =
|
||||
AncestorType::AccessorPropertyDecorators as u16,
|
||||
AccessorPropertyKey(AccessorPropertyWithoutKey<'a>) = AncestorType::AccessorPropertyKey as u16,
|
||||
AccessorPropertyValue(AccessorPropertyWithoutValue<'a>) =
|
||||
AncestorType::AccessorPropertyValue as u16,
|
||||
AccessorPropertyDecorators(AccessorPropertyWithoutDecorators<'a>) =
|
||||
AncestorType::AccessorPropertyDecorators as u16,
|
||||
ImportExpressionSource(ImportExpressionWithoutSource<'a>) =
|
||||
AncestorType::ImportExpressionSource as u16,
|
||||
ImportExpressionArguments(ImportExpressionWithoutArguments<'a>) =
|
||||
|
|
@ -1254,7 +1254,7 @@ impl<'a> Ancestor<'a> {
|
|||
|
||||
#[inline]
|
||||
pub fn is_formal_parameter(&self) -> bool {
|
||||
matches!(self, Self::FormalParameterPattern(_) | Self::FormalParameterDecorators(_))
|
||||
matches!(self, Self::FormalParameterDecorators(_) | Self::FormalParameterPattern(_))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
@ -1327,9 +1327,9 @@ impl<'a> Ancestor<'a> {
|
|||
pub fn is_accessor_property(&self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
Self::AccessorPropertyKey(_)
|
||||
Self::AccessorPropertyDecorators(_)
|
||||
| Self::AccessorPropertyKey(_)
|
||||
| Self::AccessorPropertyValue(_)
|
||||
| Self::AccessorPropertyDecorators(_)
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -5726,24 +5726,32 @@ impl<'a> FormalParametersWithoutRest<'a> {
|
|||
}
|
||||
|
||||
pub(crate) const OFFSET_FORMAL_PARAMETER_SPAN: usize = offset_of!(FormalParameter, span);
|
||||
pub(crate) const OFFSET_FORMAL_PARAMETER_DECORATORS: usize =
|
||||
offset_of!(FormalParameter, decorators);
|
||||
pub(crate) const OFFSET_FORMAL_PARAMETER_PATTERN: usize = offset_of!(FormalParameter, pattern);
|
||||
pub(crate) const OFFSET_FORMAL_PARAMETER_ACCESSIBILITY: usize =
|
||||
offset_of!(FormalParameter, accessibility);
|
||||
pub(crate) const OFFSET_FORMAL_PARAMETER_READONLY: usize = offset_of!(FormalParameter, readonly);
|
||||
pub(crate) const OFFSET_FORMAL_PARAMETER_OVERRIDE: usize = offset_of!(FormalParameter, r#override);
|
||||
pub(crate) const OFFSET_FORMAL_PARAMETER_DECORATORS: usize =
|
||||
offset_of!(FormalParameter, decorators);
|
||||
|
||||
#[repr(transparent)]
|
||||
#[derive(Debug)]
|
||||
pub struct FormalParameterWithoutPattern<'a>(pub(crate) *const FormalParameter<'a>);
|
||||
pub struct FormalParameterWithoutDecorators<'a>(pub(crate) *const FormalParameter<'a>);
|
||||
|
||||
impl<'a> FormalParameterWithoutPattern<'a> {
|
||||
impl<'a> FormalParameterWithoutDecorators<'a> {
|
||||
#[inline]
|
||||
pub fn span(&self) -> &Span {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FORMAL_PARAMETER_SPAN) as *const Span) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn pattern(&self) -> &BindingPattern<'a> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FORMAL_PARAMETER_PATTERN)
|
||||
as *const BindingPattern<'a>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn accessibility(&self) -> &Option<TSAccessibility> {
|
||||
unsafe {
|
||||
|
|
@ -5761,31 +5769,23 @@ impl<'a> FormalParameterWithoutPattern<'a> {
|
|||
pub fn r#override(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FORMAL_PARAMETER_OVERRIDE) as *const bool) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn decorators(&self) -> &Vec<'a, Decorator<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FORMAL_PARAMETER_DECORATORS)
|
||||
as *const Vec<'a, Decorator<'a>>)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(transparent)]
|
||||
#[derive(Debug)]
|
||||
pub struct FormalParameterWithoutDecorators<'a>(pub(crate) *const FormalParameter<'a>);
|
||||
pub struct FormalParameterWithoutPattern<'a>(pub(crate) *const FormalParameter<'a>);
|
||||
|
||||
impl<'a> FormalParameterWithoutDecorators<'a> {
|
||||
impl<'a> FormalParameterWithoutPattern<'a> {
|
||||
#[inline]
|
||||
pub fn span(&self) -> &Span {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_FORMAL_PARAMETER_SPAN) as *const Span) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn pattern(&self) -> &BindingPattern<'a> {
|
||||
pub fn decorators(&self) -> &Vec<'a, Decorator<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_FORMAL_PARAMETER_PATTERN)
|
||||
as *const BindingPattern<'a>)
|
||||
&*((self.0 as *const u8).add(OFFSET_FORMAL_PARAMETER_DECORATORS)
|
||||
as *const Vec<'a, Decorator<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -7307,101 +7307,12 @@ impl<'a> StaticBlockWithoutBody<'a> {
|
|||
|
||||
pub(crate) const OFFSET_ACCESSOR_PROPERTY_TYPE: usize = offset_of!(AccessorProperty, r#type);
|
||||
pub(crate) const OFFSET_ACCESSOR_PROPERTY_SPAN: usize = offset_of!(AccessorProperty, span);
|
||||
pub(crate) const OFFSET_ACCESSOR_PROPERTY_DECORATORS: usize =
|
||||
offset_of!(AccessorProperty, decorators);
|
||||
pub(crate) const OFFSET_ACCESSOR_PROPERTY_KEY: usize = offset_of!(AccessorProperty, key);
|
||||
pub(crate) const OFFSET_ACCESSOR_PROPERTY_VALUE: usize = offset_of!(AccessorProperty, value);
|
||||
pub(crate) const OFFSET_ACCESSOR_PROPERTY_COMPUTED: usize = offset_of!(AccessorProperty, computed);
|
||||
pub(crate) const OFFSET_ACCESSOR_PROPERTY_STATIC: usize = offset_of!(AccessorProperty, r#static);
|
||||
pub(crate) const OFFSET_ACCESSOR_PROPERTY_DECORATORS: usize =
|
||||
offset_of!(AccessorProperty, decorators);
|
||||
|
||||
#[repr(transparent)]
|
||||
#[derive(Debug)]
|
||||
pub struct AccessorPropertyWithoutKey<'a>(pub(crate) *const AccessorProperty<'a>);
|
||||
|
||||
impl<'a> AccessorPropertyWithoutKey<'a> {
|
||||
#[inline]
|
||||
pub fn r#type(&self) -> &AccessorPropertyType {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_TYPE)
|
||||
as *const AccessorPropertyType)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn span(&self) -> &Span {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_SPAN) as *const Span) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn value(&self) -> &Option<Expression<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_VALUE)
|
||||
as *const Option<Expression<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn computed(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_COMPUTED) as *const bool) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn r#static(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_STATIC) as *const bool) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn decorators(&self) -> &Vec<'a, Decorator<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_DECORATORS)
|
||||
as *const Vec<'a, Decorator<'a>>)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(transparent)]
|
||||
#[derive(Debug)]
|
||||
pub struct AccessorPropertyWithoutValue<'a>(pub(crate) *const AccessorProperty<'a>);
|
||||
|
||||
impl<'a> AccessorPropertyWithoutValue<'a> {
|
||||
#[inline]
|
||||
pub fn r#type(&self) -> &AccessorPropertyType {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_TYPE)
|
||||
as *const AccessorPropertyType)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn span(&self) -> &Span {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_SPAN) as *const Span) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn key(&self) -> &PropertyKey<'a> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_KEY) as *const PropertyKey<'a>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn computed(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_COMPUTED) as *const bool) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn r#static(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_STATIC) as *const bool) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn decorators(&self) -> &Vec<'a, Decorator<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_DECORATORS)
|
||||
as *const Vec<'a, Decorator<'a>>)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(transparent)]
|
||||
#[derive(Debug)]
|
||||
|
|
@ -7447,6 +7358,95 @@ impl<'a> AccessorPropertyWithoutDecorators<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[repr(transparent)]
|
||||
#[derive(Debug)]
|
||||
pub struct AccessorPropertyWithoutKey<'a>(pub(crate) *const AccessorProperty<'a>);
|
||||
|
||||
impl<'a> AccessorPropertyWithoutKey<'a> {
|
||||
#[inline]
|
||||
pub fn r#type(&self) -> &AccessorPropertyType {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_TYPE)
|
||||
as *const AccessorPropertyType)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn span(&self) -> &Span {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_SPAN) as *const Span) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn decorators(&self) -> &Vec<'a, Decorator<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_DECORATORS)
|
||||
as *const Vec<'a, Decorator<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn value(&self) -> &Option<Expression<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_VALUE)
|
||||
as *const Option<Expression<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn computed(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_COMPUTED) as *const bool) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn r#static(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_STATIC) as *const bool) }
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(transparent)]
|
||||
#[derive(Debug)]
|
||||
pub struct AccessorPropertyWithoutValue<'a>(pub(crate) *const AccessorProperty<'a>);
|
||||
|
||||
impl<'a> AccessorPropertyWithoutValue<'a> {
|
||||
#[inline]
|
||||
pub fn r#type(&self) -> &AccessorPropertyType {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_TYPE)
|
||||
as *const AccessorPropertyType)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn span(&self) -> &Span {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_SPAN) as *const Span) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn decorators(&self) -> &Vec<'a, Decorator<'a>> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_DECORATORS)
|
||||
as *const Vec<'a, Decorator<'a>>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn key(&self) -> &PropertyKey<'a> {
|
||||
unsafe {
|
||||
&*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_KEY) as *const PropertyKey<'a>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn computed(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_COMPUTED) as *const bool) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn r#static(&self) -> &bool {
|
||||
unsafe { &*((self.0 as *const u8).add(OFFSET_ACCESSOR_PROPERTY_STATIC) as *const bool) }
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) const OFFSET_IMPORT_EXPRESSION_SPAN: usize = offset_of!(ImportExpression, span);
|
||||
pub(crate) const OFFSET_IMPORT_EXPRESSION_SOURCE: usize = offset_of!(ImportExpression, source);
|
||||
pub(crate) const OFFSET_IMPORT_EXPRESSION_ARGUMENTS: usize =
|
||||
|
|
|
|||
|
|
@ -2335,19 +2335,21 @@ pub(crate) unsafe fn walk_formal_parameter<'a, Tr: Traverse<'a>>(
|
|||
ctx: &mut TraverseCtx<'a>,
|
||||
) {
|
||||
traverser.enter_formal_parameter(&mut *node, ctx);
|
||||
ctx.push_stack(Ancestor::FormalParameterPattern(ancestor::FormalParameterWithoutPattern(node)));
|
||||
walk_binding_pattern(
|
||||
traverser,
|
||||
(node as *mut u8).add(ancestor::OFFSET_FORMAL_PARAMETER_PATTERN) as *mut BindingPattern,
|
||||
ctx,
|
||||
);
|
||||
ctx.retag_stack(AncestorType::FormalParameterDecorators);
|
||||
ctx.push_stack(Ancestor::FormalParameterDecorators(
|
||||
ancestor::FormalParameterWithoutDecorators(node),
|
||||
));
|
||||
for item in (*((node as *mut u8).add(ancestor::OFFSET_FORMAL_PARAMETER_DECORATORS)
|
||||
as *mut Vec<Decorator>))
|
||||
.iter_mut()
|
||||
{
|
||||
walk_decorator(traverser, item as *mut _, ctx);
|
||||
}
|
||||
ctx.retag_stack(AncestorType::FormalParameterPattern);
|
||||
walk_binding_pattern(
|
||||
traverser,
|
||||
(node as *mut u8).add(ancestor::OFFSET_FORMAL_PARAMETER_PATTERN) as *mut BindingPattern,
|
||||
ctx,
|
||||
);
|
||||
ctx.pop_stack();
|
||||
traverser.exit_formal_parameter(&mut *node, ctx);
|
||||
}
|
||||
|
|
@ -2695,7 +2697,16 @@ pub(crate) unsafe fn walk_accessor_property<'a, Tr: Traverse<'a>>(
|
|||
ctx: &mut TraverseCtx<'a>,
|
||||
) {
|
||||
traverser.enter_accessor_property(&mut *node, ctx);
|
||||
ctx.push_stack(Ancestor::AccessorPropertyKey(ancestor::AccessorPropertyWithoutKey(node)));
|
||||
ctx.push_stack(Ancestor::AccessorPropertyDecorators(
|
||||
ancestor::AccessorPropertyWithoutDecorators(node),
|
||||
));
|
||||
for item in (*((node as *mut u8).add(ancestor::OFFSET_ACCESSOR_PROPERTY_DECORATORS)
|
||||
as *mut Vec<Decorator>))
|
||||
.iter_mut()
|
||||
{
|
||||
walk_decorator(traverser, item as *mut _, ctx);
|
||||
}
|
||||
ctx.retag_stack(AncestorType::AccessorPropertyKey);
|
||||
walk_property_key(
|
||||
traverser,
|
||||
(node as *mut u8).add(ancestor::OFFSET_ACCESSOR_PROPERTY_KEY) as *mut PropertyKey,
|
||||
|
|
@ -2707,13 +2718,6 @@ pub(crate) unsafe fn walk_accessor_property<'a, Tr: Traverse<'a>>(
|
|||
ctx.retag_stack(AncestorType::AccessorPropertyValue);
|
||||
walk_expression(traverser, field as *mut _, ctx);
|
||||
}
|
||||
ctx.retag_stack(AncestorType::AccessorPropertyDecorators);
|
||||
for item in (*((node as *mut u8).add(ancestor::OFFSET_ACCESSOR_PROPERTY_DECORATORS)
|
||||
as *mut Vec<Decorator>))
|
||||
.iter_mut()
|
||||
{
|
||||
walk_decorator(traverser, item as *mut _, ctx);
|
||||
}
|
||||
ctx.pop_stack();
|
||||
traverser.exit_accessor_property(&mut *node, ctx);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue