mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
refactor(traverse): simpler code for entering/exiting unconditional scopes (#4685)
Simplify generated code for visiting nodes which always have a scope.
This commit is contained in:
parent
83546d3230
commit
54f98973d1
2 changed files with 139 additions and 182 deletions
|
|
@ -78,6 +78,7 @@ function generateWalkForStruct(type, types) {
|
||||||
// but we don't take that into account.
|
// but we don't take that into account.
|
||||||
// Visitor should not do that though, so maybe it's OK.
|
// Visitor should not do that though, so maybe it's OK.
|
||||||
// In final version, we should not make `scope_id` fields `Cell`s to prevent this.
|
// In final version, we should not make `scope_id` fields `Cell`s to prevent this.
|
||||||
|
if (scopeArgs.if) {
|
||||||
enterScopeCode = `
|
enterScopeCode = `
|
||||||
let mut previous_scope_id = None;
|
let mut previous_scope_id = None;
|
||||||
if let Some(scope_id) = (*(${makeFieldCode(scopeIdField)})).get() {
|
if let Some(scope_id) = (*(${makeFieldCode(scopeIdField)})).get() {
|
||||||
|
|
@ -91,6 +92,14 @@ function generateWalkForStruct(type, types) {
|
||||||
ctx.set_current_scope_id(previous_scope_id);
|
ctx.set_current_scope_id(previous_scope_id);
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
} else {
|
||||||
|
enterScopeCode = `
|
||||||
|
let previous_scope_id = ctx.current_scope_id();
|
||||||
|
ctx.set_current_scope_id((*(${makeFieldCode(scopeIdField)})).get().unwrap());
|
||||||
|
`;
|
||||||
|
|
||||||
|
exitScopeCode = `ctx.set_current_scope_id(previous_scope_id);`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const fieldsCodes = visitedFields.map((field, index) => {
|
const fieldsCodes = visitedFields.map((field, index) => {
|
||||||
|
|
|
||||||
|
|
@ -29,14 +29,12 @@ pub(crate) unsafe fn walk_program<'a, Tr: Traverse<'a>>(
|
||||||
ctx: &mut TraverseCtx<'a>,
|
ctx: &mut TraverseCtx<'a>,
|
||||||
) {
|
) {
|
||||||
traverser.enter_program(&mut *node, ctx);
|
traverser.enter_program(&mut *node, ctx);
|
||||||
let mut previous_scope_id = None;
|
let previous_scope_id = ctx.current_scope_id();
|
||||||
if let Some(scope_id) = (*((node as *mut u8).add(ancestor::OFFSET_PROGRAM_SCOPE_ID)
|
ctx.set_current_scope_id(
|
||||||
as *mut Cell<Option<ScopeId>>))
|
(*((node as *mut u8).add(ancestor::OFFSET_PROGRAM_SCOPE_ID) as *mut Cell<Option<ScopeId>>))
|
||||||
.get()
|
.get()
|
||||||
{
|
.unwrap(),
|
||||||
previous_scope_id = Some(ctx.current_scope_id());
|
);
|
||||||
ctx.set_current_scope_id(scope_id);
|
|
||||||
}
|
|
||||||
ctx.push_stack(Ancestor::ProgramHashbang(ancestor::ProgramWithoutHashbang(node)));
|
ctx.push_stack(Ancestor::ProgramHashbang(ancestor::ProgramWithoutHashbang(node)));
|
||||||
if let Some(field) =
|
if let Some(field) =
|
||||||
&mut *((node as *mut u8).add(ancestor::OFFSET_PROGRAM_HASHBANG) as *mut Option<Hashbang>)
|
&mut *((node as *mut u8).add(ancestor::OFFSET_PROGRAM_HASHBANG) as *mut Option<Hashbang>)
|
||||||
|
|
@ -57,9 +55,7 @@ pub(crate) unsafe fn walk_program<'a, Tr: Traverse<'a>>(
|
||||||
ctx,
|
ctx,
|
||||||
);
|
);
|
||||||
ctx.pop_stack();
|
ctx.pop_stack();
|
||||||
if let Some(previous_scope_id) = previous_scope_id {
|
|
||||||
ctx.set_current_scope_id(previous_scope_id);
|
ctx.set_current_scope_id(previous_scope_id);
|
||||||
}
|
|
||||||
traverser.exit_program(&mut *node, ctx);
|
traverser.exit_program(&mut *node, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1404,14 +1400,13 @@ pub(crate) unsafe fn walk_block_statement<'a, Tr: Traverse<'a>>(
|
||||||
ctx: &mut TraverseCtx<'a>,
|
ctx: &mut TraverseCtx<'a>,
|
||||||
) {
|
) {
|
||||||
traverser.enter_block_statement(&mut *node, ctx);
|
traverser.enter_block_statement(&mut *node, ctx);
|
||||||
let mut previous_scope_id = None;
|
let previous_scope_id = ctx.current_scope_id();
|
||||||
if let Some(scope_id) = (*((node as *mut u8).add(ancestor::OFFSET_BLOCK_STATEMENT_SCOPE_ID)
|
ctx.set_current_scope_id(
|
||||||
|
(*((node as *mut u8).add(ancestor::OFFSET_BLOCK_STATEMENT_SCOPE_ID)
|
||||||
as *mut Cell<Option<ScopeId>>))
|
as *mut Cell<Option<ScopeId>>))
|
||||||
.get()
|
.get()
|
||||||
{
|
.unwrap(),
|
||||||
previous_scope_id = Some(ctx.current_scope_id());
|
);
|
||||||
ctx.set_current_scope_id(scope_id);
|
|
||||||
}
|
|
||||||
ctx.push_stack(Ancestor::BlockStatementBody(ancestor::BlockStatementWithoutBody(node)));
|
ctx.push_stack(Ancestor::BlockStatementBody(ancestor::BlockStatementWithoutBody(node)));
|
||||||
walk_statements(
|
walk_statements(
|
||||||
traverser,
|
traverser,
|
||||||
|
|
@ -1419,9 +1414,7 @@ pub(crate) unsafe fn walk_block_statement<'a, Tr: Traverse<'a>>(
|
||||||
ctx,
|
ctx,
|
||||||
);
|
);
|
||||||
ctx.pop_stack();
|
ctx.pop_stack();
|
||||||
if let Some(previous_scope_id) = previous_scope_id {
|
|
||||||
ctx.set_current_scope_id(previous_scope_id);
|
ctx.set_current_scope_id(previous_scope_id);
|
||||||
}
|
|
||||||
traverser.exit_block_statement(&mut *node, ctx);
|
traverser.exit_block_statement(&mut *node, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1920,14 +1913,13 @@ pub(crate) unsafe fn walk_switch_statement<'a, Tr: Traverse<'a>>(
|
||||||
(node as *mut u8).add(ancestor::OFFSET_SWITCH_STATEMENT_DISCRIMINANT) as *mut Expression,
|
(node as *mut u8).add(ancestor::OFFSET_SWITCH_STATEMENT_DISCRIMINANT) as *mut Expression,
|
||||||
ctx,
|
ctx,
|
||||||
);
|
);
|
||||||
let mut previous_scope_id = None;
|
let previous_scope_id = ctx.current_scope_id();
|
||||||
if let Some(scope_id) = (*((node as *mut u8).add(ancestor::OFFSET_SWITCH_STATEMENT_SCOPE_ID)
|
ctx.set_current_scope_id(
|
||||||
|
(*((node as *mut u8).add(ancestor::OFFSET_SWITCH_STATEMENT_SCOPE_ID)
|
||||||
as *mut Cell<Option<ScopeId>>))
|
as *mut Cell<Option<ScopeId>>))
|
||||||
.get()
|
.get()
|
||||||
{
|
.unwrap(),
|
||||||
previous_scope_id = Some(ctx.current_scope_id());
|
);
|
||||||
ctx.set_current_scope_id(scope_id);
|
|
||||||
}
|
|
||||||
ctx.retag_stack(AncestorType::SwitchStatementCases);
|
ctx.retag_stack(AncestorType::SwitchStatementCases);
|
||||||
for item in (*((node as *mut u8).add(ancestor::OFFSET_SWITCH_STATEMENT_CASES)
|
for item in (*((node as *mut u8).add(ancestor::OFFSET_SWITCH_STATEMENT_CASES)
|
||||||
as *mut Vec<SwitchCase>))
|
as *mut Vec<SwitchCase>))
|
||||||
|
|
@ -1936,9 +1928,7 @@ pub(crate) unsafe fn walk_switch_statement<'a, Tr: Traverse<'a>>(
|
||||||
walk_switch_case(traverser, item as *mut _, ctx);
|
walk_switch_case(traverser, item as *mut _, ctx);
|
||||||
}
|
}
|
||||||
ctx.pop_stack();
|
ctx.pop_stack();
|
||||||
if let Some(previous_scope_id) = previous_scope_id {
|
|
||||||
ctx.set_current_scope_id(previous_scope_id);
|
ctx.set_current_scope_id(previous_scope_id);
|
||||||
}
|
|
||||||
traverser.exit_switch_statement(&mut *node, ctx);
|
traverser.exit_switch_statement(&mut *node, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2254,14 +2244,13 @@ pub(crate) unsafe fn walk_function<'a, Tr: Traverse<'a>>(
|
||||||
ctx: &mut TraverseCtx<'a>,
|
ctx: &mut TraverseCtx<'a>,
|
||||||
) {
|
) {
|
||||||
traverser.enter_function(&mut *node, ctx);
|
traverser.enter_function(&mut *node, ctx);
|
||||||
let mut previous_scope_id = None;
|
let previous_scope_id = ctx.current_scope_id();
|
||||||
if let Some(scope_id) = (*((node as *mut u8).add(ancestor::OFFSET_FUNCTION_SCOPE_ID)
|
ctx.set_current_scope_id(
|
||||||
|
(*((node as *mut u8).add(ancestor::OFFSET_FUNCTION_SCOPE_ID)
|
||||||
as *mut Cell<Option<ScopeId>>))
|
as *mut Cell<Option<ScopeId>>))
|
||||||
.get()
|
.get()
|
||||||
{
|
.unwrap(),
|
||||||
previous_scope_id = Some(ctx.current_scope_id());
|
);
|
||||||
ctx.set_current_scope_id(scope_id);
|
|
||||||
}
|
|
||||||
ctx.push_stack(Ancestor::FunctionId(ancestor::FunctionWithoutId(node)));
|
ctx.push_stack(Ancestor::FunctionId(ancestor::FunctionWithoutId(node)));
|
||||||
if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_FUNCTION_ID)
|
if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_FUNCTION_ID)
|
||||||
as *mut Option<BindingIdentifier>)
|
as *mut Option<BindingIdentifier>)
|
||||||
|
|
@ -2300,9 +2289,7 @@ pub(crate) unsafe fn walk_function<'a, Tr: Traverse<'a>>(
|
||||||
walk_function_body(traverser, (&mut **field) as *mut _, ctx);
|
walk_function_body(traverser, (&mut **field) as *mut _, ctx);
|
||||||
}
|
}
|
||||||
ctx.pop_stack();
|
ctx.pop_stack();
|
||||||
if let Some(previous_scope_id) = previous_scope_id {
|
|
||||||
ctx.set_current_scope_id(previous_scope_id);
|
ctx.set_current_scope_id(previous_scope_id);
|
||||||
}
|
|
||||||
traverser.exit_function(&mut *node, ctx);
|
traverser.exit_function(&mut *node, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2383,15 +2370,13 @@ pub(crate) unsafe fn walk_arrow_function_expression<'a, Tr: Traverse<'a>>(
|
||||||
ctx: &mut TraverseCtx<'a>,
|
ctx: &mut TraverseCtx<'a>,
|
||||||
) {
|
) {
|
||||||
traverser.enter_arrow_function_expression(&mut *node, ctx);
|
traverser.enter_arrow_function_expression(&mut *node, ctx);
|
||||||
let mut previous_scope_id = None;
|
let previous_scope_id = ctx.current_scope_id();
|
||||||
if let Some(scope_id) = (*((node as *mut u8)
|
ctx.set_current_scope_id(
|
||||||
.add(ancestor::OFFSET_ARROW_FUNCTION_EXPRESSION_SCOPE_ID)
|
(*((node as *mut u8).add(ancestor::OFFSET_ARROW_FUNCTION_EXPRESSION_SCOPE_ID)
|
||||||
as *mut Cell<Option<ScopeId>>))
|
as *mut Cell<Option<ScopeId>>))
|
||||||
.get()
|
.get()
|
||||||
{
|
.unwrap(),
|
||||||
previous_scope_id = Some(ctx.current_scope_id());
|
);
|
||||||
ctx.set_current_scope_id(scope_id);
|
|
||||||
}
|
|
||||||
ctx.push_stack(Ancestor::ArrowFunctionExpressionTypeParameters(
|
ctx.push_stack(Ancestor::ArrowFunctionExpressionTypeParameters(
|
||||||
ancestor::ArrowFunctionExpressionWithoutTypeParameters(node),
|
ancestor::ArrowFunctionExpressionWithoutTypeParameters(node),
|
||||||
));
|
));
|
||||||
|
|
@ -2423,9 +2408,7 @@ pub(crate) unsafe fn walk_arrow_function_expression<'a, Tr: Traverse<'a>>(
|
||||||
ctx,
|
ctx,
|
||||||
);
|
);
|
||||||
ctx.pop_stack();
|
ctx.pop_stack();
|
||||||
if let Some(previous_scope_id) = previous_scope_id {
|
|
||||||
ctx.set_current_scope_id(previous_scope_id);
|
ctx.set_current_scope_id(previous_scope_id);
|
||||||
}
|
|
||||||
traverser.exit_arrow_function_expression(&mut *node, ctx);
|
traverser.exit_arrow_function_expression(&mut *node, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2465,14 +2448,12 @@ pub(crate) unsafe fn walk_class<'a, Tr: Traverse<'a>>(
|
||||||
ctx.retag_stack(AncestorType::ClassId);
|
ctx.retag_stack(AncestorType::ClassId);
|
||||||
walk_binding_identifier(traverser, field as *mut _, ctx);
|
walk_binding_identifier(traverser, field as *mut _, ctx);
|
||||||
}
|
}
|
||||||
let mut previous_scope_id = None;
|
let previous_scope_id = ctx.current_scope_id();
|
||||||
if let Some(scope_id) = (*((node as *mut u8).add(ancestor::OFFSET_CLASS_SCOPE_ID)
|
ctx.set_current_scope_id(
|
||||||
as *mut Cell<Option<ScopeId>>))
|
(*((node as *mut u8).add(ancestor::OFFSET_CLASS_SCOPE_ID) as *mut Cell<Option<ScopeId>>))
|
||||||
.get()
|
.get()
|
||||||
{
|
.unwrap(),
|
||||||
previous_scope_id = Some(ctx.current_scope_id());
|
);
|
||||||
ctx.set_current_scope_id(scope_id);
|
|
||||||
}
|
|
||||||
if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_CLASS_TYPE_PARAMETERS)
|
if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_CLASS_TYPE_PARAMETERS)
|
||||||
as *mut Option<Box<TSTypeParameterDeclaration>>)
|
as *mut Option<Box<TSTypeParameterDeclaration>>)
|
||||||
{
|
{
|
||||||
|
|
@ -2507,9 +2488,7 @@ pub(crate) unsafe fn walk_class<'a, Tr: Traverse<'a>>(
|
||||||
ctx,
|
ctx,
|
||||||
);
|
);
|
||||||
ctx.pop_stack();
|
ctx.pop_stack();
|
||||||
if let Some(previous_scope_id) = previous_scope_id {
|
|
||||||
ctx.set_current_scope_id(previous_scope_id);
|
ctx.set_current_scope_id(previous_scope_id);
|
||||||
}
|
|
||||||
traverser.exit_class(&mut *node, ctx);
|
traverser.exit_class(&mut *node, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2641,14 +2620,13 @@ pub(crate) unsafe fn walk_static_block<'a, Tr: Traverse<'a>>(
|
||||||
ctx: &mut TraverseCtx<'a>,
|
ctx: &mut TraverseCtx<'a>,
|
||||||
) {
|
) {
|
||||||
traverser.enter_static_block(&mut *node, ctx);
|
traverser.enter_static_block(&mut *node, ctx);
|
||||||
let mut previous_scope_id = None;
|
let previous_scope_id = ctx.current_scope_id();
|
||||||
if let Some(scope_id) = (*((node as *mut u8).add(ancestor::OFFSET_STATIC_BLOCK_SCOPE_ID)
|
ctx.set_current_scope_id(
|
||||||
|
(*((node as *mut u8).add(ancestor::OFFSET_STATIC_BLOCK_SCOPE_ID)
|
||||||
as *mut Cell<Option<ScopeId>>))
|
as *mut Cell<Option<ScopeId>>))
|
||||||
.get()
|
.get()
|
||||||
{
|
.unwrap(),
|
||||||
previous_scope_id = Some(ctx.current_scope_id());
|
);
|
||||||
ctx.set_current_scope_id(scope_id);
|
|
||||||
}
|
|
||||||
ctx.push_stack(Ancestor::StaticBlockBody(ancestor::StaticBlockWithoutBody(node)));
|
ctx.push_stack(Ancestor::StaticBlockBody(ancestor::StaticBlockWithoutBody(node)));
|
||||||
walk_statements(
|
walk_statements(
|
||||||
traverser,
|
traverser,
|
||||||
|
|
@ -2656,9 +2634,7 @@ pub(crate) unsafe fn walk_static_block<'a, Tr: Traverse<'a>>(
|
||||||
ctx,
|
ctx,
|
||||||
);
|
);
|
||||||
ctx.pop_stack();
|
ctx.pop_stack();
|
||||||
if let Some(previous_scope_id) = previous_scope_id {
|
|
||||||
ctx.set_current_scope_id(previous_scope_id);
|
ctx.set_current_scope_id(previous_scope_id);
|
||||||
}
|
|
||||||
traverser.exit_static_block(&mut *node, ctx);
|
traverser.exit_static_block(&mut *node, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3638,14 +3614,13 @@ pub(crate) unsafe fn walk_ts_enum_declaration<'a, Tr: Traverse<'a>>(
|
||||||
(node as *mut u8).add(ancestor::OFFSET_TS_ENUM_DECLARATION_ID) as *mut BindingIdentifier,
|
(node as *mut u8).add(ancestor::OFFSET_TS_ENUM_DECLARATION_ID) as *mut BindingIdentifier,
|
||||||
ctx,
|
ctx,
|
||||||
);
|
);
|
||||||
let mut previous_scope_id = None;
|
let previous_scope_id = ctx.current_scope_id();
|
||||||
if let Some(scope_id) = (*((node as *mut u8).add(ancestor::OFFSET_TS_ENUM_DECLARATION_SCOPE_ID)
|
ctx.set_current_scope_id(
|
||||||
|
(*((node as *mut u8).add(ancestor::OFFSET_TS_ENUM_DECLARATION_SCOPE_ID)
|
||||||
as *mut Cell<Option<ScopeId>>))
|
as *mut Cell<Option<ScopeId>>))
|
||||||
.get()
|
.get()
|
||||||
{
|
.unwrap(),
|
||||||
previous_scope_id = Some(ctx.current_scope_id());
|
);
|
||||||
ctx.set_current_scope_id(scope_id);
|
|
||||||
}
|
|
||||||
ctx.retag_stack(AncestorType::TSEnumDeclarationMembers);
|
ctx.retag_stack(AncestorType::TSEnumDeclarationMembers);
|
||||||
for item in (*((node as *mut u8).add(ancestor::OFFSET_TS_ENUM_DECLARATION_MEMBERS)
|
for item in (*((node as *mut u8).add(ancestor::OFFSET_TS_ENUM_DECLARATION_MEMBERS)
|
||||||
as *mut Vec<TSEnumMember>))
|
as *mut Vec<TSEnumMember>))
|
||||||
|
|
@ -3654,9 +3629,7 @@ pub(crate) unsafe fn walk_ts_enum_declaration<'a, Tr: Traverse<'a>>(
|
||||||
walk_ts_enum_member(traverser, item as *mut _, ctx);
|
walk_ts_enum_member(traverser, item as *mut _, ctx);
|
||||||
}
|
}
|
||||||
ctx.pop_stack();
|
ctx.pop_stack();
|
||||||
if let Some(previous_scope_id) = previous_scope_id {
|
|
||||||
ctx.set_current_scope_id(previous_scope_id);
|
ctx.set_current_scope_id(previous_scope_id);
|
||||||
}
|
|
||||||
traverser.exit_ts_enum_declaration(&mut *node, ctx);
|
traverser.exit_ts_enum_declaration(&mut *node, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3929,14 +3902,13 @@ pub(crate) unsafe fn walk_ts_conditional_type<'a, Tr: Traverse<'a>>(
|
||||||
ctx: &mut TraverseCtx<'a>,
|
ctx: &mut TraverseCtx<'a>,
|
||||||
) {
|
) {
|
||||||
traverser.enter_ts_conditional_type(&mut *node, ctx);
|
traverser.enter_ts_conditional_type(&mut *node, ctx);
|
||||||
let mut previous_scope_id = None;
|
let previous_scope_id = ctx.current_scope_id();
|
||||||
if let Some(scope_id) = (*((node as *mut u8).add(ancestor::OFFSET_TS_CONDITIONAL_TYPE_SCOPE_ID)
|
ctx.set_current_scope_id(
|
||||||
|
(*((node as *mut u8).add(ancestor::OFFSET_TS_CONDITIONAL_TYPE_SCOPE_ID)
|
||||||
as *mut Cell<Option<ScopeId>>))
|
as *mut Cell<Option<ScopeId>>))
|
||||||
.get()
|
.get()
|
||||||
{
|
.unwrap(),
|
||||||
previous_scope_id = Some(ctx.current_scope_id());
|
);
|
||||||
ctx.set_current_scope_id(scope_id);
|
|
||||||
}
|
|
||||||
ctx.push_stack(Ancestor::TSConditionalTypeCheckType(
|
ctx.push_stack(Ancestor::TSConditionalTypeCheckType(
|
||||||
ancestor::TSConditionalTypeWithoutCheckType(node),
|
ancestor::TSConditionalTypeWithoutCheckType(node),
|
||||||
));
|
));
|
||||||
|
|
@ -3964,9 +3936,7 @@ pub(crate) unsafe fn walk_ts_conditional_type<'a, Tr: Traverse<'a>>(
|
||||||
ctx,
|
ctx,
|
||||||
);
|
);
|
||||||
ctx.pop_stack();
|
ctx.pop_stack();
|
||||||
if let Some(previous_scope_id) = previous_scope_id {
|
|
||||||
ctx.set_current_scope_id(previous_scope_id);
|
ctx.set_current_scope_id(previous_scope_id);
|
||||||
}
|
|
||||||
traverser.exit_ts_conditional_type(&mut *node, ctx);
|
traverser.exit_ts_conditional_type(&mut *node, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4488,15 +4458,13 @@ pub(crate) unsafe fn walk_ts_type_alias_declaration<'a, Tr: Traverse<'a>>(
|
||||||
as *mut BindingIdentifier,
|
as *mut BindingIdentifier,
|
||||||
ctx,
|
ctx,
|
||||||
);
|
);
|
||||||
let mut previous_scope_id = None;
|
let previous_scope_id = ctx.current_scope_id();
|
||||||
if let Some(scope_id) = (*((node as *mut u8)
|
ctx.set_current_scope_id(
|
||||||
.add(ancestor::OFFSET_TS_TYPE_ALIAS_DECLARATION_SCOPE_ID)
|
(*((node as *mut u8).add(ancestor::OFFSET_TS_TYPE_ALIAS_DECLARATION_SCOPE_ID)
|
||||||
as *mut Cell<Option<ScopeId>>))
|
as *mut Cell<Option<ScopeId>>))
|
||||||
.get()
|
.get()
|
||||||
{
|
.unwrap(),
|
||||||
previous_scope_id = Some(ctx.current_scope_id());
|
);
|
||||||
ctx.set_current_scope_id(scope_id);
|
|
||||||
}
|
|
||||||
if let Some(field) = &mut *((node as *mut u8)
|
if let Some(field) = &mut *((node as *mut u8)
|
||||||
.add(ancestor::OFFSET_TS_TYPE_ALIAS_DECLARATION_TYPE_PARAMETERS)
|
.add(ancestor::OFFSET_TS_TYPE_ALIAS_DECLARATION_TYPE_PARAMETERS)
|
||||||
as *mut Option<Box<TSTypeParameterDeclaration>>)
|
as *mut Option<Box<TSTypeParameterDeclaration>>)
|
||||||
|
|
@ -4512,9 +4480,7 @@ pub(crate) unsafe fn walk_ts_type_alias_declaration<'a, Tr: Traverse<'a>>(
|
||||||
ctx,
|
ctx,
|
||||||
);
|
);
|
||||||
ctx.pop_stack();
|
ctx.pop_stack();
|
||||||
if let Some(previous_scope_id) = previous_scope_id {
|
|
||||||
ctx.set_current_scope_id(previous_scope_id);
|
ctx.set_current_scope_id(previous_scope_id);
|
||||||
}
|
|
||||||
traverser.exit_ts_type_alias_declaration(&mut *node, ctx);
|
traverser.exit_ts_type_alias_declaration(&mut *node, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4558,15 +4524,13 @@ pub(crate) unsafe fn walk_ts_interface_declaration<'a, Tr: Traverse<'a>>(
|
||||||
as *mut BindingIdentifier,
|
as *mut BindingIdentifier,
|
||||||
ctx,
|
ctx,
|
||||||
);
|
);
|
||||||
let mut previous_scope_id = None;
|
let previous_scope_id = ctx.current_scope_id();
|
||||||
if let Some(scope_id) = (*((node as *mut u8)
|
ctx.set_current_scope_id(
|
||||||
.add(ancestor::OFFSET_TS_INTERFACE_DECLARATION_SCOPE_ID)
|
(*((node as *mut u8).add(ancestor::OFFSET_TS_INTERFACE_DECLARATION_SCOPE_ID)
|
||||||
as *mut Cell<Option<ScopeId>>))
|
as *mut Cell<Option<ScopeId>>))
|
||||||
.get()
|
.get()
|
||||||
{
|
.unwrap(),
|
||||||
previous_scope_id = Some(ctx.current_scope_id());
|
);
|
||||||
ctx.set_current_scope_id(scope_id);
|
|
||||||
}
|
|
||||||
if let Some(field) = &mut *((node as *mut u8)
|
if let Some(field) = &mut *((node as *mut u8)
|
||||||
.add(ancestor::OFFSET_TS_INTERFACE_DECLARATION_EXTENDS)
|
.add(ancestor::OFFSET_TS_INTERFACE_DECLARATION_EXTENDS)
|
||||||
as *mut Option<Vec<TSInterfaceHeritage>>)
|
as *mut Option<Vec<TSInterfaceHeritage>>)
|
||||||
|
|
@ -4591,9 +4555,7 @@ pub(crate) unsafe fn walk_ts_interface_declaration<'a, Tr: Traverse<'a>>(
|
||||||
ctx,
|
ctx,
|
||||||
);
|
);
|
||||||
ctx.pop_stack();
|
ctx.pop_stack();
|
||||||
if let Some(previous_scope_id) = previous_scope_id {
|
|
||||||
ctx.set_current_scope_id(previous_scope_id);
|
ctx.set_current_scope_id(previous_scope_id);
|
||||||
}
|
|
||||||
traverser.exit_ts_interface_declaration(&mut *node, ctx);
|
traverser.exit_ts_interface_declaration(&mut *node, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4735,14 +4697,13 @@ pub(crate) unsafe fn walk_ts_method_signature<'a, Tr: Traverse<'a>>(
|
||||||
ctx: &mut TraverseCtx<'a>,
|
ctx: &mut TraverseCtx<'a>,
|
||||||
) {
|
) {
|
||||||
traverser.enter_ts_method_signature(&mut *node, ctx);
|
traverser.enter_ts_method_signature(&mut *node, ctx);
|
||||||
let mut previous_scope_id = None;
|
let previous_scope_id = ctx.current_scope_id();
|
||||||
if let Some(scope_id) = (*((node as *mut u8).add(ancestor::OFFSET_TS_METHOD_SIGNATURE_SCOPE_ID)
|
ctx.set_current_scope_id(
|
||||||
|
(*((node as *mut u8).add(ancestor::OFFSET_TS_METHOD_SIGNATURE_SCOPE_ID)
|
||||||
as *mut Cell<Option<ScopeId>>))
|
as *mut Cell<Option<ScopeId>>))
|
||||||
.get()
|
.get()
|
||||||
{
|
.unwrap(),
|
||||||
previous_scope_id = Some(ctx.current_scope_id());
|
);
|
||||||
ctx.set_current_scope_id(scope_id);
|
|
||||||
}
|
|
||||||
ctx.push_stack(Ancestor::TSMethodSignatureKey(ancestor::TSMethodSignatureWithoutKey(node)));
|
ctx.push_stack(Ancestor::TSMethodSignatureKey(ancestor::TSMethodSignatureWithoutKey(node)));
|
||||||
walk_property_key(
|
walk_property_key(
|
||||||
traverser,
|
traverser,
|
||||||
|
|
@ -4778,9 +4739,7 @@ pub(crate) unsafe fn walk_ts_method_signature<'a, Tr: Traverse<'a>>(
|
||||||
walk_ts_type_parameter_declaration(traverser, (&mut **field) as *mut _, ctx);
|
walk_ts_type_parameter_declaration(traverser, (&mut **field) as *mut _, ctx);
|
||||||
}
|
}
|
||||||
ctx.pop_stack();
|
ctx.pop_stack();
|
||||||
if let Some(previous_scope_id) = previous_scope_id {
|
|
||||||
ctx.set_current_scope_id(previous_scope_id);
|
ctx.set_current_scope_id(previous_scope_id);
|
||||||
}
|
|
||||||
traverser.exit_ts_method_signature(&mut *node, ctx);
|
traverser.exit_ts_method_signature(&mut *node, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4790,15 +4749,13 @@ pub(crate) unsafe fn walk_ts_construct_signature_declaration<'a, Tr: Traverse<'a
|
||||||
ctx: &mut TraverseCtx<'a>,
|
ctx: &mut TraverseCtx<'a>,
|
||||||
) {
|
) {
|
||||||
traverser.enter_ts_construct_signature_declaration(&mut *node, ctx);
|
traverser.enter_ts_construct_signature_declaration(&mut *node, ctx);
|
||||||
let mut previous_scope_id = None;
|
let previous_scope_id = ctx.current_scope_id();
|
||||||
if let Some(scope_id) = (*((node as *mut u8)
|
ctx.set_current_scope_id(
|
||||||
.add(ancestor::OFFSET_TS_CONSTRUCT_SIGNATURE_DECLARATION_SCOPE_ID)
|
(*((node as *mut u8).add(ancestor::OFFSET_TS_CONSTRUCT_SIGNATURE_DECLARATION_SCOPE_ID)
|
||||||
as *mut Cell<Option<ScopeId>>))
|
as *mut Cell<Option<ScopeId>>))
|
||||||
.get()
|
.get()
|
||||||
{
|
.unwrap(),
|
||||||
previous_scope_id = Some(ctx.current_scope_id());
|
);
|
||||||
ctx.set_current_scope_id(scope_id);
|
|
||||||
}
|
|
||||||
ctx.push_stack(Ancestor::TSConstructSignatureDeclarationParams(
|
ctx.push_stack(Ancestor::TSConstructSignatureDeclarationParams(
|
||||||
ancestor::TSConstructSignatureDeclarationWithoutParams(node),
|
ancestor::TSConstructSignatureDeclarationWithoutParams(node),
|
||||||
));
|
));
|
||||||
|
|
@ -4823,9 +4780,7 @@ pub(crate) unsafe fn walk_ts_construct_signature_declaration<'a, Tr: Traverse<'a
|
||||||
walk_ts_type_parameter_declaration(traverser, (&mut **field) as *mut _, ctx);
|
walk_ts_type_parameter_declaration(traverser, (&mut **field) as *mut _, ctx);
|
||||||
}
|
}
|
||||||
ctx.pop_stack();
|
ctx.pop_stack();
|
||||||
if let Some(previous_scope_id) = previous_scope_id {
|
|
||||||
ctx.set_current_scope_id(previous_scope_id);
|
ctx.set_current_scope_id(previous_scope_id);
|
||||||
}
|
|
||||||
traverser.exit_ts_construct_signature_declaration(&mut *node, ctx);
|
traverser.exit_ts_construct_signature_declaration(&mut *node, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4927,15 +4882,13 @@ pub(crate) unsafe fn walk_ts_module_declaration<'a, Tr: Traverse<'a>>(
|
||||||
as *mut TSModuleDeclarationName,
|
as *mut TSModuleDeclarationName,
|
||||||
ctx,
|
ctx,
|
||||||
);
|
);
|
||||||
let mut previous_scope_id = None;
|
let previous_scope_id = ctx.current_scope_id();
|
||||||
if let Some(scope_id) = (*((node as *mut u8)
|
ctx.set_current_scope_id(
|
||||||
.add(ancestor::OFFSET_TS_MODULE_DECLARATION_SCOPE_ID)
|
(*((node as *mut u8).add(ancestor::OFFSET_TS_MODULE_DECLARATION_SCOPE_ID)
|
||||||
as *mut Cell<Option<ScopeId>>))
|
as *mut Cell<Option<ScopeId>>))
|
||||||
.get()
|
.get()
|
||||||
{
|
.unwrap(),
|
||||||
previous_scope_id = Some(ctx.current_scope_id());
|
);
|
||||||
ctx.set_current_scope_id(scope_id);
|
|
||||||
}
|
|
||||||
if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_TS_MODULE_DECLARATION_BODY)
|
if let Some(field) = &mut *((node as *mut u8).add(ancestor::OFFSET_TS_MODULE_DECLARATION_BODY)
|
||||||
as *mut Option<TSModuleDeclarationBody>)
|
as *mut Option<TSModuleDeclarationBody>)
|
||||||
{
|
{
|
||||||
|
|
@ -4943,9 +4896,7 @@ pub(crate) unsafe fn walk_ts_module_declaration<'a, Tr: Traverse<'a>>(
|
||||||
walk_ts_module_declaration_body(traverser, field as *mut _, ctx);
|
walk_ts_module_declaration_body(traverser, field as *mut _, ctx);
|
||||||
}
|
}
|
||||||
ctx.pop_stack();
|
ctx.pop_stack();
|
||||||
if let Some(previous_scope_id) = previous_scope_id {
|
|
||||||
ctx.set_current_scope_id(previous_scope_id);
|
ctx.set_current_scope_id(previous_scope_id);
|
||||||
}
|
|
||||||
traverser.exit_ts_module_declaration(&mut *node, ctx);
|
traverser.exit_ts_module_declaration(&mut *node, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5263,14 +5214,13 @@ pub(crate) unsafe fn walk_ts_mapped_type<'a, Tr: Traverse<'a>>(
|
||||||
ctx: &mut TraverseCtx<'a>,
|
ctx: &mut TraverseCtx<'a>,
|
||||||
) {
|
) {
|
||||||
traverser.enter_ts_mapped_type(&mut *node, ctx);
|
traverser.enter_ts_mapped_type(&mut *node, ctx);
|
||||||
let mut previous_scope_id = None;
|
let previous_scope_id = ctx.current_scope_id();
|
||||||
if let Some(scope_id) = (*((node as *mut u8).add(ancestor::OFFSET_TS_MAPPED_TYPE_SCOPE_ID)
|
ctx.set_current_scope_id(
|
||||||
|
(*((node as *mut u8).add(ancestor::OFFSET_TS_MAPPED_TYPE_SCOPE_ID)
|
||||||
as *mut Cell<Option<ScopeId>>))
|
as *mut Cell<Option<ScopeId>>))
|
||||||
.get()
|
.get()
|
||||||
{
|
.unwrap(),
|
||||||
previous_scope_id = Some(ctx.current_scope_id());
|
);
|
||||||
ctx.set_current_scope_id(scope_id);
|
|
||||||
}
|
|
||||||
ctx.push_stack(Ancestor::TSMappedTypeTypeParameter(
|
ctx.push_stack(Ancestor::TSMappedTypeTypeParameter(
|
||||||
ancestor::TSMappedTypeWithoutTypeParameter(node),
|
ancestor::TSMappedTypeWithoutTypeParameter(node),
|
||||||
));
|
));
|
||||||
|
|
@ -5294,9 +5244,7 @@ pub(crate) unsafe fn walk_ts_mapped_type<'a, Tr: Traverse<'a>>(
|
||||||
walk_ts_type(traverser, field as *mut _, ctx);
|
walk_ts_type(traverser, field as *mut _, ctx);
|
||||||
}
|
}
|
||||||
ctx.pop_stack();
|
ctx.pop_stack();
|
||||||
if let Some(previous_scope_id) = previous_scope_id {
|
|
||||||
ctx.set_current_scope_id(previous_scope_id);
|
ctx.set_current_scope_id(previous_scope_id);
|
||||||
}
|
|
||||||
traverser.exit_ts_mapped_type(&mut *node, ctx);
|
traverser.exit_ts_mapped_type(&mut *node, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue