mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
refactor(semantic/cfg)!: re-export petgraph as control_flow::graph. (#3722)
So we can replace or extend it easily.
This commit is contained in:
parent
f42c325a06
commit
4bce59df68
9 changed files with 29 additions and 25 deletions
|
|
@ -9,7 +9,8 @@ use oxc_diagnostics::OxcDiagnostic;
|
|||
|
||||
use oxc_macros::declare_oxc_lint;
|
||||
use oxc_semantic::{
|
||||
pg::neighbors_filtered_by_edge_weight, EdgeType, InstructionKind, ReturnInstructionKind,
|
||||
control_flow::graph::visit::neighbors_filtered_by_edge_weight, EdgeType, InstructionKind,
|
||||
ReturnInstructionKind,
|
||||
};
|
||||
use oxc_span::Span;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,10 @@ use oxc_ast::{
|
|||
use oxc_diagnostics::OxcDiagnostic;
|
||||
use oxc_macros::declare_oxc_lint;
|
||||
use oxc_semantic::{
|
||||
petgraph::{visit::EdgeRef, Direction},
|
||||
pg::neighbors_filtered_by_edge_weight,
|
||||
control_flow::graph::{
|
||||
visit::{neighbors_filtered_by_edge_weight, EdgeRef},
|
||||
Direction,
|
||||
},
|
||||
BasicBlockId, EdgeType, ErrorEdgeKind, InstructionKind,
|
||||
};
|
||||
use oxc_span::{GetSpan, Span};
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ use oxc_ast::{
|
|||
};
|
||||
use oxc_macros::declare_oxc_lint;
|
||||
use oxc_semantic::{
|
||||
petgraph::visit::EdgeRef, pg::neighbors_filtered_by_edge_weight, AstNodeId, BasicBlockId,
|
||||
ControlFlowGraph, EdgeType,
|
||||
control_flow::graph::visit::{neighbors_filtered_by_edge_weight, EdgeRef},
|
||||
AstNodeId, BasicBlockId, ControlFlowGraph, EdgeType,
|
||||
};
|
||||
use oxc_span::{GetSpan, Span};
|
||||
|
||||
|
|
@ -156,11 +156,8 @@ impl NoThisBeforeSuper {
|
|||
fn analyze(
|
||||
cfg: &ControlFlowGraph,
|
||||
id: BasicBlockId,
|
||||
basic_blocks_with_super_called: &HashSet<oxc_semantic::petgraph::prelude::NodeIndex>,
|
||||
basic_blocks_with_local_violations: &HashMap<
|
||||
oxc_semantic::petgraph::prelude::NodeIndex,
|
||||
Vec<AstNodeId>,
|
||||
>,
|
||||
basic_blocks_with_super_called: &HashSet<BasicBlockId>,
|
||||
basic_blocks_with_local_violations: &HashMap<BasicBlockId, Vec<AstNodeId>>,
|
||||
follow_join: bool,
|
||||
) -> Vec<DefinitelyCallsThisBeforeSuper> {
|
||||
neighbors_filtered_by_edge_weight(
|
||||
|
|
@ -219,11 +216,8 @@ impl NoThisBeforeSuper {
|
|||
fn check_for_violation(
|
||||
cfg: &ControlFlowGraph,
|
||||
output: Vec<DefinitelyCallsThisBeforeSuper>,
|
||||
basic_blocks_with_super_called: &HashSet<oxc_semantic::petgraph::prelude::NodeIndex>,
|
||||
basic_blocks_with_local_violations: &HashMap<
|
||||
oxc_semantic::petgraph::prelude::NodeIndex,
|
||||
Vec<AstNodeId>,
|
||||
>,
|
||||
basic_blocks_with_super_called: &HashSet<BasicBlockId>,
|
||||
basic_blocks_with_local_violations: &HashMap<BasicBlockId, Vec<AstNodeId>>,
|
||||
) -> bool {
|
||||
// Deciding whether we definitely call this before super in all
|
||||
// codepaths is as simple as seeing if any individual codepath
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use oxc_ast::{ast::VariableDeclarationKind, AstKind};
|
|||
use oxc_diagnostics::OxcDiagnostic;
|
||||
use oxc_macros::declare_oxc_lint;
|
||||
use oxc_semantic::{
|
||||
petgraph::{
|
||||
control_flow::graph::{
|
||||
visit::{depth_first_search, Control, DfsEvent, EdgeRef},
|
||||
Direction,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ use oxc_diagnostics::OxcDiagnostic;
|
|||
|
||||
use oxc_macros::declare_oxc_lint;
|
||||
use oxc_semantic::{
|
||||
pg::neighbors_filtered_by_edge_weight, EdgeType, Instruction, InstructionKind,
|
||||
ReturnInstructionKind,
|
||||
control_flow::graph::visit::neighbors_filtered_by_edge_weight, EdgeType, Instruction,
|
||||
InstructionKind, ReturnInstructionKind,
|
||||
};
|
||||
use oxc_span::{GetSpan, Span};
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@ use oxc_ast::{
|
|||
};
|
||||
use oxc_macros::declare_oxc_lint;
|
||||
use oxc_semantic::{
|
||||
algo, petgraph::visit::Control, AstNodeId, AstNodes, EdgeType, ErrorEdgeKind, InstructionKind,
|
||||
control_flow::graph::{algo, visit::Control},
|
||||
AstNodeId, AstNodes, EdgeType, ErrorEdgeKind, InstructionKind,
|
||||
};
|
||||
use oxc_span::{Atom, CompactStr};
|
||||
use oxc_syntax::operator::AssignmentOperator;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
mod builder;
|
||||
mod dot;
|
||||
pub mod visit;
|
||||
|
||||
use itertools::Itertools;
|
||||
use oxc_ast::AstKind;
|
||||
|
|
@ -9,9 +10,17 @@ use petgraph::{
|
|||
Direction, Graph,
|
||||
};
|
||||
|
||||
pub mod graph {
|
||||
pub use petgraph::*;
|
||||
pub mod visit {
|
||||
pub use super::super::visit::*;
|
||||
pub use petgraph::visit::*;
|
||||
}
|
||||
}
|
||||
|
||||
use crate::{AstNodeId, AstNodes};
|
||||
|
||||
pub use builder::{ControlFlowGraphBuilder, CtxCursor, CtxFlags};
|
||||
pub(crate) use builder::{ControlFlowGraphBuilder, CtxCursor, CtxFlags};
|
||||
pub use dot::{DebugDot, DebugDotContext, DisplayDot};
|
||||
|
||||
pub type BasicBlockId = NodeIndex;
|
||||
|
|
|
|||
|
|
@ -2,21 +2,18 @@ mod binder;
|
|||
mod builder;
|
||||
mod checker;
|
||||
mod class;
|
||||
mod control_flow;
|
||||
mod diagnostics;
|
||||
mod jsdoc;
|
||||
mod label;
|
||||
mod module_record;
|
||||
mod node;
|
||||
pub mod pg;
|
||||
mod reference;
|
||||
mod scope;
|
||||
mod symbol;
|
||||
|
||||
use std::sync::Arc;
|
||||
pub mod control_flow;
|
||||
|
||||
pub use petgraph;
|
||||
pub use petgraph::algo;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub use builder::{SemanticBuilder, SemanticBuilderReturn};
|
||||
use class::ClassTable;
|
||||
|
|
|
|||
Loading…
Reference in a new issue