Skip to content
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
10 changes: 9 additions & 1 deletion c2rust-transpile/src/c_ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2169,7 +2169,15 @@ impl Display for CUnTypeOp {
}

impl CUnOp {
/// Check is the operator is rendered before or after is operand.
pub fn underlying_compound_assignment(&self) -> Option<CBinOp> {
Some(match self {
CUnOp::PreIncrement | CUnOp::PostIncrement => CBinOp::AssignAdd,
CUnOp::PreDecrement | CUnOp::PostDecrement => CBinOp::AssignSubtract,
_ => return None,
})
}

/// Returns whether the operator is placed before its operand.
pub fn is_prefix(&self) -> bool {
!matches!(*self, CUnOp::PostIncrement | CUnOp::PostDecrement)
}
Expand Down
Loading
Loading