summaryrefslogtreecommitdiff
path: root/src/types
diff options
context:
space:
mode:
Diffstat (limited to 'src/types')
-rw-r--r--src/types/expression_stack.rs1
-rw-r--r--src/types/operator.rs3
2 files changed, 4 insertions, 0 deletions
diff --git a/src/types/expression_stack.rs b/src/types/expression_stack.rs
index 8e1c87d..228fa2d 100644
--- a/src/types/expression_stack.rs
+++ b/src/types/expression_stack.rs
@@ -63,6 +63,7 @@ impl ExpressionStack {
Operator::BitNot => { pop!(a); push!(!a) },
Operator::Length => { pop!(a); push!(width(a) as isize) },
Operator::Tally => { pop!(a); push!(tally(a) as isize) },
+ Operator::Absolute => { pop!(a); push!(a.wrapping_abs()) },
}
return Ok(());
}
diff --git a/src/types/operator.rs b/src/types/operator.rs
index d5b5e94..da4dfb4 100644
--- a/src/types/operator.rs
+++ b/src/types/operator.rs
@@ -20,6 +20,7 @@ pub enum Operator {
BitNot,
Length,
Tally,
+ Absolute,
}
impl Operator {
@@ -59,6 +60,7 @@ impl Operator {
"<not>" => Some(Operator::BitNot),
"<len>" => Some(Operator::Length),
"<tal>" => Some(Operator::Tally),
+ "<abs>" => Some(Operator::Absolute),
_ => None,
}
}
@@ -87,6 +89,7 @@ impl std::fmt::Display for Operator {
Operator::BitNot => "<not>",
Operator::Length => "<len>",
Operator::Tally => "<tal>",
+ Operator::Absolute => "<abs>",
};
write!(f, "{string}")
}