Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(semantic/cfg): remove unused types. #3677

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 0 additions & 99 deletions crates/oxc_semantic/src/control_flow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ mod dot;

use itertools::Itertools;
use oxc_ast::AstKind;
use oxc_span::CompactStr;
use oxc_syntax::operator::{
AssignmentOperator, BinaryOperator, LogicalOperator, UnaryOperator, UpdateOperator,
};
use petgraph::{
stable_graph::NodeIndex,
visit::{depth_first_search, Control, DfsEvent, EdgeRef},
Expand All @@ -20,101 +16,6 @@ pub use dot::{DebugDot, DebugDotContext, DisplayDot};

pub type BasicBlockId = NodeIndex;

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Register {
Index(u32),
Return,
}

#[derive(Debug, Clone)]
pub enum ObjectPropertyAccessBy {
PrivateProperty(CompactStr),
Property(CompactStr),
Expression(Register),
}

#[derive(Debug, Clone)]
pub struct CollectionAssignmentValue {
pub id: AstNodeId,
pub elements: Vec<Register>,
pub spreads: Vec<usize>,
pub collection_type: CollectionType,
}

#[derive(Debug, Clone)]
pub struct CalleeWithArgumentsAssignmentValue {
pub id: AstNodeId,
pub callee: Register,
pub arguments: Vec<Register>,
pub spreads: Vec<usize>,
pub call_type: CallType,
}

#[derive(Debug, Clone)]
pub struct ObjectPropertyAccessAssignmentValue {
pub id: AstNodeId,
pub access_on: Register,
pub access_by: ObjectPropertyAccessBy,
pub optional: bool,
}

#[derive(Debug, Clone)]
pub struct BinaryAssignmentValue {
pub id: AstNodeId,
pub a: Register,
pub b: Register,
pub operator: BinaryOp,
}

#[derive(Debug, Clone)]
pub struct UpdateAssignmentValue {
pub id: AstNodeId,
pub expr: Register,
pub op: UpdateOperator,
pub prefix: bool,
}

#[derive(Debug, Clone)]
pub struct UnaryExpressioneAssignmentValue(pub AstNodeId, pub UnaryOperator, pub Register);

#[derive(Debug, Clone)]
pub enum AssignmentValue {
ImplicitUndefined,
NotImplicitUndefined,
}

#[derive(Debug, Clone)]
pub enum BinaryOp {
BinaryOperator(BinaryOperator),
LogicalOperator(LogicalOperator),
AssignmentOperator(AssignmentOperator),
}

#[derive(Debug, Clone)]
pub enum CollectionType {
Array,
// Note: we do not currently track object names in objects.
Object,
JSXElement,
JSXFragment,
// doesn't use spreads
Class,
TemplateLiteral,
}

#[derive(Debug, Clone)]
pub enum CallType {
New,
CallExpression,
// the callee is the yielded value, arguments are always empty
// spreads are always empty
Yield,
// spreads are always empty
TaggedTemplate,
// spreads are always empty
Import,
}

#[derive(Debug)]
pub struct BasicBlock {
pub instructions: Vec<Instruction>,
Expand Down
8 changes: 3 additions & 5 deletions crates/oxc_semantic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@ use rustc_hash::FxHashSet;

pub use crate::{
control_flow::{
AssignmentValue, BasicBlock, BasicBlockId, BinaryAssignmentValue, BinaryOp, CallType,
CalleeWithArgumentsAssignmentValue, CollectionAssignmentValue, ControlFlowGraph, DebugDot,
DebugDotContext, DisplayDot, EdgeType, ErrorEdgeKind, Instruction, InstructionKind,
LabeledInstruction, ObjectPropertyAccessAssignmentValue, Register, ReturnInstructionKind,
UnaryExpressioneAssignmentValue, UpdateAssignmentValue,
BasicBlock, BasicBlockId, ControlFlowGraph, DebugDot, DebugDotContext, DisplayDot,
EdgeType, ErrorEdgeKind, Instruction, InstructionKind, LabeledInstruction,
ReturnInstructionKind,
},
node::{AstNode, AstNodeId, AstNodes},
reference::{Reference, ReferenceFlag, ReferenceId},
Expand Down