mirror of
https://github.com/danbulant/oxc
synced 2026-05-21 05:08:45 +00:00
refactor(semantic): use Stack for function stack node ids (#7984)
This commit is contained in:
parent
3631eed975
commit
efe96ecc12
3 changed files with 5 additions and 2 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -1920,6 +1920,7 @@ dependencies = [
|
||||||
"oxc_allocator",
|
"oxc_allocator",
|
||||||
"oxc_ast",
|
"oxc_ast",
|
||||||
"oxc_cfg",
|
"oxc_cfg",
|
||||||
|
"oxc_data_structures",
|
||||||
"oxc_diagnostics",
|
"oxc_diagnostics",
|
||||||
"oxc_ecmascript",
|
"oxc_ecmascript",
|
||||||
"oxc_index",
|
"oxc_index",
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ doctest = false
|
||||||
oxc_allocator = { workspace = true }
|
oxc_allocator = { workspace = true }
|
||||||
oxc_ast = { workspace = true }
|
oxc_ast = { workspace = true }
|
||||||
oxc_cfg = { workspace = true }
|
oxc_cfg = { workspace = true }
|
||||||
|
oxc_data_structures = { workspace = true }
|
||||||
oxc_diagnostics = { workspace = true }
|
oxc_diagnostics = { workspace = true }
|
||||||
oxc_ecmascript = { workspace = true }
|
oxc_ecmascript = { workspace = true }
|
||||||
oxc_index = { workspace = true }
|
oxc_index = { workspace = true }
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ use std::{
|
||||||
mem,
|
mem,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use oxc_data_structures::stack::Stack;
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
use oxc_ast::{ast::*, AstKind, Visit};
|
use oxc_ast::{ast::*, AstKind, Visit};
|
||||||
|
|
@ -77,7 +78,7 @@ pub struct SemanticBuilder<'a> {
|
||||||
pub(crate) current_symbol_flags: SymbolFlags,
|
pub(crate) current_symbol_flags: SymbolFlags,
|
||||||
pub(crate) current_scope_id: ScopeId,
|
pub(crate) current_scope_id: ScopeId,
|
||||||
/// Stores current `AstKind::Function` and `AstKind::ArrowFunctionExpression` during AST visit
|
/// Stores current `AstKind::Function` and `AstKind::ArrowFunctionExpression` during AST visit
|
||||||
pub(crate) function_stack: Vec<NodeId>,
|
pub(crate) function_stack: Stack<NodeId>,
|
||||||
// To make a namespace/module value like
|
// To make a namespace/module value like
|
||||||
// we need the to know the modules we are inside
|
// we need the to know the modules we are inside
|
||||||
// and when we reach a value declaration we set it
|
// and when we reach a value declaration we set it
|
||||||
|
|
@ -137,7 +138,7 @@ impl<'a> SemanticBuilder<'a> {
|
||||||
current_symbol_flags: SymbolFlags::empty(),
|
current_symbol_flags: SymbolFlags::empty(),
|
||||||
current_reference_flags: ReferenceFlags::empty(),
|
current_reference_flags: ReferenceFlags::empty(),
|
||||||
current_scope_id,
|
current_scope_id,
|
||||||
function_stack: vec![],
|
function_stack: Stack::with_capacity(16),
|
||||||
namespace_stack: vec![],
|
namespace_stack: vec![],
|
||||||
nodes: AstNodes::default(),
|
nodes: AstNodes::default(),
|
||||||
hoisting_variables: FxHashMap::default(),
|
hoisting_variables: FxHashMap::default(),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue