mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
refactor(syntax): turn the AstNodeId::dummy into a constant field. (#4308)
This commit is contained in:
parent
96af45933a
commit
fc0b17d5a0
4 changed files with 8 additions and 11 deletions
|
|
@ -29,7 +29,7 @@ fn labeled_statement_with_multiple_loops_continue_and_break() {
|
|||
cfg.ctx(None).default().allow_break().allow_continue();
|
||||
cfg.ctx(None).mark_break(c2).mark_continue(c2).resolve_with_upper_label();
|
||||
|
||||
cfg.append_break(AstNodeId::dummy(), A);
|
||||
cfg.append_break(AstNodeId::DUMMY, A);
|
||||
|
||||
// labeled block end
|
||||
cfg.ctx(A).mark_break(labeled).resolve();
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ impl<'a> SemanticBuilder<'a> {
|
|||
/// # Panics
|
||||
pub fn build(mut self, program: &Program<'a>) -> SemanticBuilderReturn<'a> {
|
||||
if self.source_type.is_typescript_definition() {
|
||||
let scope_id = self.scope.add_scope(None, AstNodeId::dummy(), ScopeFlags::Top);
|
||||
let scope_id = self.scope.add_scope(None, AstNodeId::DUMMY, ScopeFlags::Top);
|
||||
program.scope_id.set(Some(scope_id));
|
||||
} else {
|
||||
self.visit_program(program);
|
||||
|
|
@ -252,7 +252,7 @@ impl<'a> SemanticBuilder<'a> {
|
|||
#[inline]
|
||||
fn record_ast_nodes(&mut self) {
|
||||
if self.cfg.is_some() {
|
||||
self.ast_node_records.push(AstNodeId::dummy());
|
||||
self.ast_node_records.push(AstNodeId::DUMMY);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -273,7 +273,7 @@ impl<'a> SemanticBuilder<'a> {
|
|||
// <https://github.com/oxc-project/oxc/pull/4273>
|
||||
if self.cfg.is_some() {
|
||||
if let Some(record) = self.ast_node_records.last_mut() {
|
||||
if *record == AstNodeId::dummy() {
|
||||
if *record == AstNodeId::DUMMY {
|
||||
*record = self.current_node_id;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,10 +6,7 @@ define_index_type! {
|
|||
}
|
||||
|
||||
impl AstNodeId {
|
||||
#[inline]
|
||||
pub fn dummy() -> Self {
|
||||
Self::new(0)
|
||||
}
|
||||
pub const DUMMY: Self = AstNodeId::from_raw_unchecked(0);
|
||||
}
|
||||
|
||||
#[cfg(feature = "serialize")]
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ impl TraverseScoping {
|
|||
/// `flags` provided are amended to inherit from parent scope's flags.
|
||||
pub fn create_scope_child_of_current(&mut self, flags: ScopeFlags) -> ScopeId {
|
||||
let flags = self.scopes.get_new_scope_flags(flags, self.current_scope_id);
|
||||
self.scopes.add_scope(Some(self.current_scope_id), AstNodeId::dummy(), flags)
|
||||
self.scopes.add_scope(Some(self.current_scope_id), AstNodeId::DUMMY, flags)
|
||||
}
|
||||
|
||||
/// Insert a scope into scope tree below a statement.
|
||||
|
|
@ -268,7 +268,7 @@ impl TraverseScoping {
|
|||
flag: ReferenceFlag,
|
||||
) -> ReferenceId {
|
||||
let reference =
|
||||
Reference::new_with_symbol_id(SPAN, name, AstNodeId::dummy(), symbol_id, flag);
|
||||
Reference::new_with_symbol_id(SPAN, name, AstNodeId::DUMMY, symbol_id, flag);
|
||||
let reference_id = self.symbols.create_reference(reference);
|
||||
self.symbols.resolved_references[symbol_id].push(reference_id);
|
||||
reference_id
|
||||
|
|
@ -297,7 +297,7 @@ impl TraverseScoping {
|
|||
name: CompactStr,
|
||||
flag: ReferenceFlag,
|
||||
) -> ReferenceId {
|
||||
let reference = Reference::new(SPAN, name.clone(), AstNodeId::dummy(), flag);
|
||||
let reference = Reference::new(SPAN, name.clone(), AstNodeId::DUMMY, flag);
|
||||
let reference_id = self.symbols.create_reference(reference);
|
||||
self.scopes.add_root_unresolved_reference(name, reference_id);
|
||||
reference_id
|
||||
|
|
|
|||
Loading…
Reference in a new issue